Commit 803eba3bce9ddcadce8c854ade0d87921b471aa9

Authored by Perry Werneck
1 parent 48355f11

Adjusments on preparation for oversize support.

lib3270.cbp
... ... @@ -110,6 +110,9 @@
110 110 <Unit filename="src/core/log.c">
111 111 <Option compilerVar="CC" />
112 112 </Unit>
  113 + <Unit filename="src/core/model.c">
  114 + <Option compilerVar="CC" />
  115 + </Unit>
113 116 <Unit filename="src/core/options.c">
114 117 <Option compilerVar="CC" />
115 118 </Unit>
... ...
src/core/ansi.c
... ... @@ -533,10 +533,10 @@ static enum lib3270_ansi_state ansi_newline(H3270 *hSession, int GNUC_UNUSED(ig1
533 533 {
534 534 int nc;
535 535  
536   - cursor_move(hSession,hSession->cursor_addr - (hSession->cursor_addr % hSession->cols));
537   - nc = hSession->cursor_addr + hSession->cols;
  536 + cursor_move(hSession,hSession->cursor_addr - (hSession->cursor_addr % hSession->view.cols));
  537 + nc = hSession->cursor_addr + hSession->view.cols;
538 538  
539   - if (nc < hSession->scroll_bottom * hSession->cols)
  539 + if (nc < hSession->scroll_bottom * hSession->view.cols)
540 540 cursor_move(hSession,nc);
541 541 else
542 542 ansi_scroll(hSession);
... ... @@ -552,11 +552,11 @@ ansi_cursor_up(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
552 552  
553 553 if (nn < 1)
554 554 nn = 1;
555   - rr = hSession->cursor_addr / hSession->cols;
  555 + rr = hSession->cursor_addr / hSession->view.cols;
556 556 if (rr - nn < 0)
557   - cursor_move(hSession, hSession->cursor_addr % hSession->cols);
  557 + cursor_move(hSession, hSession->cursor_addr % hSession->view.cols);
558 558 else
559   - cursor_move(hSession, hSession->cursor_addr - (nn * hSession->cols));
  559 + cursor_move(hSession, hSession->cursor_addr - (nn * hSession->view.cols));
560 560 hSession->held_wrap = 0;
561 561 return DATA;
562 562 }
... ... @@ -607,17 +607,17 @@ static enum lib3270_ansi_state ansi_reset(H3270 *hSession, int GNUC_UNUSED(ig1),
607 607 hSession->saved_altbuffer = 0;
608 608  
609 609 hSession->scroll_top = 1;
610   - hSession->scroll_bottom = hSession->rows;
  610 + hSession->scroll_bottom = hSession->view.rows;
611 611  
612   - Replace(hSession->tabs, (unsigned char *)lib3270_malloc((hSession->cols+7)/8));
613   - for (i = 0; i < (hSession->cols+7)/8; i++)
  612 + Replace(hSession->tabs, (unsigned char *)lib3270_malloc((hSession->view.cols+7)/8));
  613 + for (i = 0; i < (hSession->view.cols+7)/8; i++)
614 614 hSession->tabs[i] = 0x01;
615 615  
616 616 hSession->held_wrap = 0;
617 617 if (!hSession->ansi_reset)
618 618 {
619 619 ctlr_altbuffer(hSession,True);
620   - ctlr_aclear(hSession, 0, hSession->rows * hSession->cols, 1);
  620 + ctlr_aclear(hSession, 0, hSession->view.rows * hSession->view.cols, 1);
621 621 ctlr_altbuffer(hSession,False);
622 622 ctlr_clear(hSession,False);
623 623 hSession->cbk.set_width(hSession,80);
... ... @@ -630,8 +630,8 @@ static enum lib3270_ansi_state ansi_reset(H3270 *hSession, int GNUC_UNUSED(ig1),
630 630 static enum lib3270_ansi_state
631 631 ansi_insert_chars(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
632 632 {
633   - int cc = hSession->cursor_addr % hSession->cols; /* current col */
634   - int mc = hSession->cols - cc; /* max chars that can be inserted */
  633 + int cc = hSession->cursor_addr % hSession->view.cols; /* current col */
  634 + int mc = hSession->view.cols - cc; /* max chars that can be inserted */
635 635 int ns; /* chars that are shifting */
636 636  
637 637 if (nn < 1)
... ... @@ -656,11 +656,11 @@ ansi_cursor_down(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
656 656  
657 657 if (nn < 1)
658 658 nn = 1;
659   - rr = hSession->cursor_addr / hSession->cols;
660   - if (rr + nn >= hSession->cols)
661   - cursor_move(hSession,(hSession->cols-1)*hSession->cols + (hSession->cursor_addr%hSession->cols));
  659 + rr = hSession->cursor_addr / hSession->view.cols;
  660 + if (rr + nn >= hSession->view.cols)
  661 + cursor_move(hSession,(hSession->view.cols-1)*hSession->view.cols + (hSession->cursor_addr % hSession->view.cols));
662 662 else
663   - cursor_move(hSession,hSession->cursor_addr + (nn * hSession->cols));
  663 + cursor_move(hSession,hSession->cursor_addr + (nn * hSession->view.cols));
664 664 hSession->held_wrap = 0;
665 665 return DATA;
666 666 }
... ... @@ -671,11 +671,11 @@ static enum lib3270_ansi_state ansi_cursor_right(H3270 *hSession, int nn, int GN
671 671  
672 672 if (nn < 1)
673 673 nn = 1;
674   - cc = hSession->cursor_addr % hSession->cols;
675   - if (cc == hSession->cols-1)
  674 + cc = hSession->cursor_addr % hSession->view.cols;
  675 + if (cc == hSession->view.cols-1)
676 676 return DATA;
677   - if (cc + nn >= hSession->cols)
678   - nn = hSession->cols - 1 - cc;
  677 + if (cc + nn >= hSession->view.cols)
  678 + nn = hSession->view.cols - 1 - cc;
679 679 cursor_move(hSession,hSession->cursor_addr + nn);
680 680 hSession->held_wrap = 0;
681 681 return DATA;
... ... @@ -693,7 +693,7 @@ ansi_cursor_left(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
693 693 }
694 694 if (nn < 1)
695 695 nn = 1;
696   - cc = hSession->cursor_addr % hSession->cols;
  696 + cc = hSession->cursor_addr % hSession->view.cols;
697 697 if (!cc)
698 698 return DATA;
699 699 if (nn > cc)
... ... @@ -706,10 +706,10 @@ static enum lib3270_ansi_state
706 706 ansi_cursor_motion(H3270 *hSession, int n1, int n2)
707 707 {
708 708 if (n1 < 1) n1 = 1;
709   - if (n1 > hSession->rows) n1 = hSession->rows;
  709 + if (n1 > hSession->view.rows) n1 = hSession->view.rows;
710 710 if (n2 < 1) n2 = 1;
711   - if (n2 > hSession->cols) n2 = hSession->cols;
712   - cursor_move(hSession,(n1 - 1) * hSession->cols + (n2 - 1));
  711 + if (n2 > hSession->view.cols) n2 = hSession->view.cols;
  712 + cursor_move(hSession,(n1 - 1) * hSession->view.cols + (n2 - 1));
713 713 hSession->held_wrap = 0;
714 714 return DATA;
715 715 }
... ... @@ -719,14 +719,14 @@ ansi_erase_in_display(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
719 719 {
720 720 switch (nn) {
721 721 case 0: /* below */
722   - ctlr_aclear(hSession, hSession->cursor_addr, (hSession->rows * hSession->cols) - hSession->cursor_addr, 1);
  722 + ctlr_aclear(hSession, hSession->cursor_addr, (hSession->view.rows * hSession->view.cols) - hSession->cursor_addr, 1);
723 723 break;
724 724 case 1: /* above */
725 725 ctlr_aclear(hSession, 0, hSession->cursor_addr + 1, 1);
726 726 break;
727 727 case 2: /* all (without moving cursor) */
728 728 // if (hSession->cursor_addr == 0 && !hSession->is_altbuffer) scroll_save(hSession->rows, True);
729   - ctlr_aclear(hSession, 0, hSession->rows * hSession->cols, 1);
  729 + ctlr_aclear(hSession, 0, hSession->view.rows * hSession->view.cols, 1);
730 730 break;
731 731 }
732 732 return DATA;
... ... @@ -735,17 +735,17 @@ ansi_erase_in_display(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
735 735 static enum lib3270_ansi_state
736 736 ansi_erase_in_line(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
737 737 {
738   - int nc = hSession->cursor_addr % hSession->cols;
  738 + int nc = hSession->cursor_addr % hSession->view.cols;
739 739  
740 740 switch (nn) {
741 741 case 0: /* to right */
742   - ctlr_aclear(hSession, hSession->cursor_addr, hSession->cols - nc, 1);
  742 + ctlr_aclear(hSession, hSession->cursor_addr, hSession->view.cols - nc, 1);
743 743 break;
744 744 case 1: /* to left */
745 745 ctlr_aclear(hSession, hSession->cursor_addr - nc, nc+1, 1);
746 746 break;
747 747 case 2: /* all */
748   - ctlr_aclear(hSession, hSession->cursor_addr - nc, hSession->cols, 1);
  748 + ctlr_aclear(hSession, hSession->cursor_addr - nc, hSession->view.cols, 1);
749 749 break;
750 750 }
751 751 return DATA;
... ... @@ -754,7 +754,7 @@ ansi_erase_in_line(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
754 754 static enum lib3270_ansi_state
755 755 ansi_insert_lines(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
756 756 {
757   - int rr = hSession->cursor_addr / hSession->cols; /* current row */
  757 + int rr = hSession->cursor_addr / hSession->view.cols; /* current row */
758 758 int mr = hSession->scroll_bottom - rr; /* rows left at and below this one */
759 759 int ns; /* rows that are shifting */
760 760  
... ... @@ -770,17 +770,17 @@ ansi_insert_lines(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
770 770 /* Move the victims down */
771 771 ns = mr - nn;
772 772 if (ns)
773   - ctlr_bcopy(hSession,rr * hSession->cols, (rr + nn) * hSession->cols, ns * hSession->cols, 1);
  773 + ctlr_bcopy(hSession,rr * hSession->view.cols, (rr + nn) * hSession->view.cols, ns * hSession->view.cols, 1);
774 774  
775 775 /* Clear the middle of the screen */
776   - ctlr_aclear(hSession, rr * hSession->cols, nn * hSession->cols, 1);
  776 + ctlr_aclear(hSession, rr * hSession->view.cols, nn * hSession->view.cols, 1);
777 777 return DATA;
778 778 }
779 779  
780 780 static enum lib3270_ansi_state
781 781 ansi_delete_lines(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
782 782 {
783   - int rr = hSession->cursor_addr / hSession->cols; /* current row */
  783 + int rr = hSession->cursor_addr / hSession->view.cols; /* current row */
784 784 int mr = hSession->scroll_bottom - rr; /* max rows that can be deleted */
785 785 int ns; /* rows that are shifting */
786 786  
... ... @@ -796,19 +796,19 @@ ansi_delete_lines(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
796 796 /* Move the surviving rows up */
797 797 ns = mr - nn;
798 798 if (ns)
799   - ctlr_bcopy(hSession,(rr + nn) * hSession->cols, rr * hSession->cols, ns * hSession->cols, 1);
  799 + ctlr_bcopy(hSession,(rr + nn) * hSession->view.cols, rr * hSession->view.cols, ns * hSession->view.cols, 1);
800 800  
801 801 /* Clear the rest of the screen */
802   - ctlr_aclear(hSession, (rr + ns) * hSession->cols, nn * hSession->cols, 1);
  802 + ctlr_aclear(hSession, (rr + ns) * hSession->view.cols, nn * hSession->view.cols, 1);
803 803 return DATA;
804 804 }
805 805  
806 806 static enum lib3270_ansi_state
807 807 ansi_delete_chars(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
808 808 {
809   - int cc = hSession->cursor_addr % hSession->cols; /* current col */
810   - int mc = hSession->cols - cc; /* max chars that can be deleted */
811   - int ns; /* chars that are shifting */
  809 + int cc = hSession->cursor_addr % hSession->view.cols; /* current col */
  810 + int mc = hSession->view.cols - cc; /* max chars that can be deleted */
  811 + int ns; /* chars that are shifting */
812 812  
813 813 if (nn < 1)
814 814 nn = 1;
... ... @@ -947,12 +947,12 @@ static enum lib3270_ansi_state ansi_backspace(H3270 *hSession, int GNUC_UNUSED(i
947 947  
948 948 if (hSession->rev_wraparound_mode)
949 949 {
950   - if (hSession->cursor_addr > (hSession->scroll_top - 1) * hSession->cols)
  950 + if (hSession->cursor_addr > (hSession->scroll_top - 1) * hSession->view.cols)
951 951 cursor_move(hSession,hSession->cursor_addr - 1);
952 952 }
953 953 else
954 954 {
955   - if (hSession->cursor_addr % hSession->cols)
  955 + if (hSession->cursor_addr % hSession->view.cols)
956 956 cursor_move(hSession,hSession->cursor_addr - 1);
957 957 }
958 958 return DATA;
... ... @@ -960,8 +960,8 @@ static enum lib3270_ansi_state ansi_backspace(H3270 *hSession, int GNUC_UNUSED(i
960 960  
961 961 static enum lib3270_ansi_state ansi_cr(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
962 962 {
963   - if (hSession->cursor_addr % hSession->cols)
964   - cursor_move(hSession,hSession->cursor_addr - (hSession->cursor_addr % hSession->cols));
  963 + if (hSession->cursor_addr % hSession->view.cols)
  964 + cursor_move(hSession,hSession->cursor_addr - (hSession->cursor_addr % hSession->view.cols));
965 965  
966 966 if (hSession->auto_newline_mode)
967 967 (void) ansi_lf(hSession, 0, 0);
... ... @@ -972,19 +972,19 @@ static enum lib3270_ansi_state ansi_cr(H3270 *hSession, int GNUC_UNUSED(ig1), in
972 972  
973 973 static enum lib3270_ansi_state ansi_lf(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
974 974 {
975   - int nc = hSession->cursor_addr + hSession->cols;
  975 + int nc = hSession->cursor_addr + hSession->view.cols;
976 976  
977 977 hSession->held_wrap = 0;
978 978  
979 979 // If we're below the scrolling region, don't scroll.
980   - if((hSession->cursor_addr / hSession->cols) >= hSession->scroll_bottom)
  980 + if((hSession->cursor_addr / hSession->view.cols) >= hSession->scroll_bottom)
981 981 {
982   - if (nc < hSession->rows * hSession->cols)
  982 + if (nc < hSession->view.rows * hSession->view.cols)
983 983 cursor_move(hSession,nc);
984 984 return DATA;
985 985 }
986 986  
987   - if (nc < hSession->scroll_bottom * hSession->cols)
  987 + if (nc < hSession->scroll_bottom * hSession->view.cols)
988 988 cursor_move(hSession,nc);
989 989 else
990 990 ansi_scroll(hSession);
... ... @@ -993,13 +993,13 @@ static enum lib3270_ansi_state ansi_lf(H3270 *hSession, int GNUC_UNUSED(ig1), in
993 993  
994 994 static enum lib3270_ansi_state ansi_htab(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
995 995 {
996   - int col = hSession->cursor_addr % hSession->cols;
  996 + int col = hSession->cursor_addr % hSession->view.cols;
997 997 int i;
998 998  
999 999 hSession->held_wrap = 0;
1000   - if (col == hSession->cols-1)
  1000 + if (col == hSession->view.cols-1)
1001 1001 return DATA;
1002   - for (i = col+1; i < hSession->cols-1; i++)
  1002 + for (i = col+1; i < hSession->view.cols-1; i++)
1003 1003 if (hSession->tabs[i/8] & 1<<(i%8))
1004 1004 break;
1005 1005 cursor_move(hSession,hSession->cursor_addr - col + i);
... ... @@ -1018,14 +1018,14 @@ static enum lib3270_ansi_state ansi_nop(H3270 GNUC_UNUSED(*hSession), int GNUC_U
1018 1018  
1019 1019 #define PWRAP { \
1020 1020 nc = hSession->cursor_addr + 1; \
1021   - if (nc < hSession->scroll_bottom * hSession->cols) \
  1021 + if (nc < hSession->scroll_bottom * hSession->view.cols) \
1022 1022 cursor_move(hSession,nc); \
1023 1023 else { \
1024   - if (hSession->cursor_addr / hSession->cols >= hSession->scroll_bottom) \
1025   - cursor_move(hSession,hSession->cursor_addr / hSession->cols * hSession->cols); \
  1024 + if (hSession->cursor_addr / hSession->view.cols >= hSession->scroll_bottom) \
  1025 + cursor_move(hSession,hSession->cursor_addr / hSession->view.cols * hSession->view.cols); \
1026 1026 else { \
1027 1027 ansi_scroll(hSession); \
1028   - cursor_move(hSession,nc - hSession->cols); \
  1028 + cursor_move(hSession,nc - hSession->view.cols); \
1029 1029 } \
1030 1030 } \
1031 1031 }
... ... @@ -1198,13 +1198,13 @@ ansi_printing(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
1198 1198 * In my opinion, very strange, but among other things, 'vi'
1199 1199 * depends on it!
1200 1200 */
1201   - if (!((hSession->cursor_addr + 1) % hSession->cols)) {
  1201 + if (!((hSession->cursor_addr + 1) % hSession->view.cols)) {
1202 1202 hSession->held_wrap = 1;
1203 1203 } else {
1204 1204 PWRAP;
1205 1205 }
1206 1206 } else {
1207   - if ((hSession->cursor_addr % hSession->cols) != (hSession->cols - 1))
  1207 + if ((hSession->cursor_addr % hSession->view.cols) != (hSession->view.cols - 1))
1208 1208 cursor_move(hSession,hSession->cursor_addr + 1);
1209 1209 }
1210 1210 return DATA;
... ... @@ -1277,10 +1277,10 @@ static enum lib3270_ansi_state ansi_digit(H3270 *hSession, int GNUC_UNUSED(ig1),
1277 1277  
1278 1278 static enum lib3270_ansi_state ansi_reverse_index(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
1279 1279 {
1280   - int rr = hSession->cursor_addr / hSession->cols; /* current row */
1281   - int np = (hSession->scroll_top - 1) - rr; /* number of rows in the scrolling region, above this line */
1282   - int ns; /* number of rows to scroll */
1283   - int nn = 1; /* number of rows to index */
  1280 + int rr = hSession->cursor_addr / hSession->view.cols; /* current row */
  1281 + int np = (hSession->scroll_top - 1) - rr; /* number of rows in the scrolling region, above this line */
  1282 + int ns; /* number of rows to scroll */
  1283 + int nn = 1; /* number of rows to index */
1284 1284  
1285 1285 hSession->held_wrap = 0;
1286 1286  
... ... @@ -1360,7 +1360,7 @@ static enum lib3270_ansi_state ansi_status_report(H3270 *hSession, int nn, int G
1360 1360 break;
1361 1361  
1362 1362 case 6:
1363   - (void) snprintf(cpr, 22, "\033[%d;%dR",(hSession->cursor_addr/hSession->cols) + 1, (hSession->cursor_addr%hSession->cols) + 1);
  1363 + (void) snprintf(cpr, 22, "\033[%d;%dR",(hSession->cursor_addr/hSession->view.cols) + 1, (hSession->cursor_addr%hSession->view.cols) + 1);
1364 1364 net_sends(hSession,cpr);
1365 1365 break;
1366 1366 }
... ... @@ -1564,10 +1564,10 @@ dec_scrolling_region(H3270 *hSession, int top, int bottom)
1564 1564 {
1565 1565 if (top < 1)
1566 1566 top = 1;
1567   - if (bottom > hSession->rows)
1568   - bottom = hSession->rows;
  1567 + if (bottom > hSession->view.rows)
  1568 + bottom = hSession->view.rows;
1569 1569  
1570   - if (top <= bottom && (top > 1 || bottom < hSession->rows))
  1570 + if (top <= bottom && (top > 1 || bottom < hSession->view.rows))
1571 1571 {
1572 1572 hSession->scroll_top = top;
1573 1573 hSession->scroll_bottom = bottom;
... ... @@ -1576,7 +1576,7 @@ dec_scrolling_region(H3270 *hSession, int top, int bottom)
1576 1576 else
1577 1577 {
1578 1578 hSession->scroll_top = 1;
1579   - hSession->scroll_bottom = hSession->rows;
  1579 + hSession->scroll_bottom = hSession->view.rows;
1580 1580 }
1581 1581 return DATA;
1582 1582 }
... ... @@ -1651,7 +1651,7 @@ xterm_text_do(H3270 GNUC_UNUSED(*hSession), int GNUC_UNUSED(ig1), int GNUC_UNUSE
1651 1651 static enum lib3270_ansi_state
1652 1652 ansi_htab_set(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
1653 1653 {
1654   - register int col = hSession->cursor_addr % hSession->cols;
  1654 + register int col = hSession->cursor_addr % hSession->view.cols;
1655 1655  
1656 1656 hSession->tabs[col/8] |= 1<<(col%8);
1657 1657 return DATA;
... ... @@ -1665,11 +1665,11 @@ ansi_htab_clear(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
1665 1665 switch (nn)
1666 1666 {
1667 1667 case 0:
1668   - col = hSession->cursor_addr % hSession->cols;
  1668 + col = hSession->cursor_addr % hSession->view.cols;
1669 1669 hSession->tabs[col/8] &= ~(1<<(col%8));
1670 1670 break;
1671 1671 case 3:
1672   - for (i = 0; i < (hSession->cols+7)/8; i++)
  1672 + for (i = 0; i < (hSession->view.cols+7)/8; i++)
1673 1673 hSession->tabs[i] = 0;
1674 1674 break;
1675 1675 }
... ... @@ -1684,7 +1684,7 @@ static void ansi_scroll(H3270 *hSession)
1684 1684 hSession->held_wrap = 0;
1685 1685  
1686 1686 /* Save the top line */
1687   - if (hSession->scroll_top == 1 && hSession->scroll_bottom == hSession->rows)
  1687 + if (hSession->scroll_top == 1 && hSession->scroll_bottom == hSession->view.rows)
1688 1688 {
1689 1689 // if (!hSession->is_altbuffer)
1690 1690 // scroll_save(1, False);
... ... @@ -1694,13 +1694,13 @@ static void ansi_scroll(H3270 *hSession)
1694 1694  
1695 1695 /* Scroll all but the last line up */
1696 1696 if (hSession->scroll_bottom > hSession->scroll_top)
1697   - ctlr_bcopy(hSession,hSession->scroll_top * hSession->cols,
1698   - (hSession->scroll_top - 1) * hSession->cols,
1699   - (hSession->scroll_bottom - hSession->scroll_top) * hSession->cols,
  1697 + ctlr_bcopy(hSession,hSession->scroll_top * hSession->view.cols,
  1698 + (hSession->scroll_top - 1) * hSession->view.cols,
  1699 + (hSession->scroll_bottom - hSession->scroll_top) * hSession->view.cols,
1700 1700 1);
1701 1701  
1702 1702 /* Clear the last line */
1703   - ctlr_aclear(hSession, (hSession->scroll_bottom - 1) * hSession->cols, hSession->cols, 1);
  1703 + ctlr_aclear(hSession, (hSession->scroll_bottom - 1) * hSession->view.cols, hSession->view.cols, 1);
1704 1704 }
1705 1705  
1706 1706 /* Callback for when we enter ANSI mode. */
... ...
src/core/bounds.c
... ... @@ -61,7 +61,7 @@ LIB3270_EXPORT int lib3270_get_field_bounds(H3270 *hSession, int baddr, int *sta
61 61  
62 62 if(end)
63 63 {
64   - int maxlen = (hSession->rows * hSession->cols)-1;
  64 + int maxlen = (hSession->view.rows * hSession->view.cols)-1;
65 65 *end = first + lib3270_field_length(hSession,first);
66 66 if(*end > maxlen)
67 67 *end = maxlen;
... ... @@ -88,7 +88,7 @@ LIB3270_EXPORT int lib3270_get_word_bounds(H3270 *session, int baddr, int *start
88 88  
89 89 if(end)
90 90 {
91   - int maxlen = session->rows * session->cols;
  91 + int maxlen = session->view.rows * session->view.cols;
92 92 for(pos = baddr; pos < maxlen && !isspace(session->text[pos].chr);pos++);
93 93  
94 94 *end = pos < maxlen ? pos-1 : maxlen;
... ...
src/core/charset.c
... ... @@ -302,10 +302,10 @@ LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession)
302 302  
303 303 trace("%s","Showing charset table");
304 304  
305   - (void) memset((char *) hSession->ea_buf, 0, hSession->rows*hSession->cols*sizeof(struct lib3270_ea));
  305 + (void) memset((char *) hSession->ea_buf, 0, hSession->view.rows * hSession->view.cols * sizeof(struct lib3270_ea));
306 306  
307   - baddr = margin_left+hSession->maxCOLS;
308   - s = (hSession->maxCOLS * 0x11);
  307 + baddr = margin_left+hSession->max.cols;
  308 + s = (hSession->max.cols * 0x11);
309 309 for(f=4;f<=0x0f;f++)
310 310 {
311 311 baddr += 2;
... ... @@ -316,7 +316,7 @@ LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession)
316 316 hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0;
317 317 }
318 318  
319   - baddr = margin_left+(hSession->maxCOLS*2);
  319 + baddr = margin_left+(hSession->max.cols*2);
320 320 s = 0x1a;
321 321 for(f=0;f<=0x0f;f++)
322 322 {
... ... @@ -325,14 +325,14 @@ LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession)
325 325 hSession->ea_buf[baddr+s].cs = hSession->ea_buf[baddr].cs = 0;
326 326 hSession->ea_buf[baddr+s].cc = hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) hChars[f]];
327 327 hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0;
328   - baddr += hSession->maxCOLS;
  328 + baddr += hSession->max.cols;
329 329 }
330 330  
331 331 chr = 0x40;
332 332  
333 333 for(f=0;f<0x0c;f++)
334 334 {
335   - baddr = (margin_left+(hSession->maxCOLS*2))+(f*2)+2;
  335 + baddr = (margin_left+(hSession->max.cols*2))+(f*2)+2;
336 336 for(r=0;r<=0x0f;r++)
337 337 {
338 338 hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_YELLOW;
... ... @@ -340,11 +340,11 @@ LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession)
340 340 hSession->ea_buf[baddr].cs = 0;
341 341 hSession->ea_buf[baddr].cc = chr++;
342 342 hSession->ea_buf[baddr].gr = 0;
343   - baddr += hSession->maxCOLS;
  343 + baddr += hSession->max.cols;
344 344 }
345 345 }
346 346  
347   - baddr = margin_left+0x1d+(hSession->maxCOLS*2);
  347 + baddr = margin_left+0x1d+(hSession->max.cols*2);
348 348 for(ptr=label;*ptr;ptr++)
349 349 {
350 350 hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_WHITE;
... ...
src/core/ctlr.c
... ... @@ -97,7 +97,7 @@ static const unsigned char code_table[64] =
97 97 #define IsBlank(c) ((c == EBC_null) || (c == EBC_space))
98 98  
99 99  
100   -#define ALL_CHANGED(h) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,0,(h)->rows*(h)->cols);
  100 +#define ALL_CHANGED(h) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,0,(h)->view.rows*(h)->view.cols);
101 101 #define REGION_CHANGED(h, f, l) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,f,l)
102 102 #define ONE_CHANGED(h,n) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,n,n+1);
103 103  
... ... @@ -136,7 +136,7 @@ void ctlr_reinit(H3270 *session, unsigned cmask)
136 136 {
137 137 /* Allocate buffers */
138 138 struct lib3270_ea *tmp;
139   - size_t sz = (session->maxROWS * session->maxCOLS);
  139 + size_t sz = (session->max.rows * session->max.cols);
140 140  
141 141 session->buffer[0] = tmp = lib3270_calloc(sizeof(struct lib3270_ea), sz+1, session->buffer[0]);
142 142 session->ea_buf = tmp + 1;
... ... @@ -152,168 +152,6 @@ void ctlr_reinit(H3270 *session, unsigned cmask)
152 152 }
153 153 }
154 154  
155   - /**
156   - * @brief Parse the model number.
157   - *
158   - * @param session Session Handle.
159   - * @param m Model number.
160   - *
161   - * @return -1 (error), 0 (default), or the specified number.
162   - */
163   -static int parse_model_number(H3270 *session, const char *m)
164   -{
165   - int sl;
166   - int n;
167   -
168   - if(!m)
169   - return 0;
170   -
171   - sl = strlen(m);
172   -
173   - /* An empty model number is no good. */
174   - if (!sl)
175   - return 0;
176   -
177   - if (sl > 1) {
178   - /*
179   - * If it's longer than one character, it needs to start with
180   - * '327[89]', and it sets the m3279 resource.
181   - */
182   - if (!strncmp(m, "3278", 4))
183   - {
184   - session->m3279 = 0;
185   - }
186   - else if (!strncmp(m, "3279", 4))
187   - {
188   - session->m3279 = 1;
189   - }
190   - else
191   - {
192   - return -1;
193   - }
194   - m += 4;
195   - sl -= 4;
196   -
197   - /* Check more syntax. -E is allowed, but ignored. */
198   - switch (m[0]) {
199   - case '\0':
200   - /* Use default model number. */
201   - return 0;
202   - case '-':
203   - /* Model number specified. */
204   - m++;
205   - sl--;
206   - break;
207   - default:
208   - return -1;
209   - }
210   - switch (sl) {
211   - case 1: /* n */
212   - break;
213   - case 3: /* n-E */
214   - if (strcasecmp(m + 1, "-E")) {
215   - return -1;
216   - }
217   - break;
218   - default:
219   - return -1;
220   - }
221   - }
222   -
223   - /* Check the numeric model number. */
224   - n = atoi(m);
225   - if (n >= 2 && n <= 5) {
226   - return n;
227   - } else {
228   - return -1;
229   - }
230   -
231   -}
232   -
233   -/**
234   - * @brief Get current 3270 model.
235   - *
236   - * @param hSession selected 3270 session.
237   - * @return Current model number.
238   - */
239   -int lib3270_get_model_number(H3270 *hSession)
240   -{
241   - CHECK_SESSION_HANDLE(hSession);
242   - return hSession->model_num;
243   -}
244   -
245   -const char * lib3270_get_model(H3270 *hSession)
246   -{
247   - CHECK_SESSION_HANDLE(hSession);
248   - return hSession->model_name;
249   -}
250   -
251   -int lib3270_set_model(H3270 *hSession, const char *model)
252   -{
253   - int ovc, ovr;
254   - char junk;
255   - int model_number;
256   -
257   - if(hSession->cstate != LIB3270_NOT_CONNECTED)
258   - return errno = EISCONN;
259   -
260   - strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH);
261   - hSession->model_name = &hSession->full_model_name[4];
262   -
263   - if(!*model)
264   - model = "2"; // No model, use the default one
265   -
266   - model_number = parse_model_number(hSession,model);
267   - if (model_number < 0)
268   - {
269   - popup_an_error(hSession,"Invalid model number: %s", model);
270   - model_number = 0;
271   - }
272   -
273   - if (!model_number)
274   - {
275   -#if defined(RESTRICT_3279)
276   - model_number = 3;
277   -#else
278   - model_number = 4;
279   -#endif
280   - }
281   -
282   - if(hSession->mono)
283   - hSession->m3279 = 0;
284   - else
285   - hSession->m3279 = 1;
286   -
287   - if(!hSession->extended)
288   - hSession->oversize = CN;
289   -
290   -#if defined(RESTRICT_3279)
291   - if (hSession->m3279 && model_number == 4)
292   - model_number = 3;
293   -#endif
294   -
295   - trace("Model_number: %d",model_number);
296   -
297   - if (!hSession->extended || hSession->oversize == CN || sscanf(hSession->oversize, "%dx%d%c", &ovc, &ovr, &junk) != 2)
298   - {
299   - ovc = 0;
300   - ovr = 0;
301   - }
302   - ctlr_set_rows_cols(hSession, model_number, ovc, ovr);
303   -
304   - if (hSession->termname != CN)
305   - hSession->termtype = hSession->termname;
306   - else
307   - hSession->termtype = hSession->full_model_name;
308   -
309   - trace("Termtype: %s",hSession->termtype);
310   -
311   - ctlr_reinit(hSession,MODEL_CHANGE);
312   - screen_update(hSession,0,hSession->rows*hSession->cols);
313   -
314   - return 0;
315   -}
316   -
317 155 void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr)
318 156 {
319 157 static const struct _sz
... ... @@ -340,23 +178,74 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr)
340 178 update_model_info(session,mn,sz[idx].cols,sz[idx].rows);
341 179  
342 180 // Apply oversize.
343   - session->ov_cols = 0;
344   - session->ov_rows = 0;
  181 + session->oversize.cols = 0;
  182 + session->oversize.rows = 0;
345 183 if (ovc != 0 || ovr != 0)
346 184 {
347 185 if (ovc <= 0 || ovr <= 0)
348   - popup_an_error(session,"Invalid %s %dx%d:\nNegative or zero",ResOversize, ovc, ovr);
  186 + {
  187 + lib3270_popup_dialog(
  188 + session,
  189 + LIB3270_NOTIFY_ERROR,
  190 + _( "Invalid oversize" ),
  191 + _( "The oversize values are invalid." ), \
  192 + _( "%dx%d is negative or zero" ),
  193 + ovc, ovr
  194 + );
  195 +
  196 + // popup_an_error(session,"Invalid %s %dx%d:\nNegative or zero",ResOversize, ovc, ovr);
  197 +
  198 + }
349 199 else if (ovc * ovr >= 0x4000)
350   - popup_an_error(session,"Invalid %s %dx%d:\nToo big",ResOversize, ovc, ovr);
351   - else if (ovc > 0 && ovc < session->maxCOLS)
352   - popup_an_error(session,"Invalid %s cols (%d):\nLess than model %d cols (%d)",ResOversize, ovc, session->model_num, session->maxCOLS);
353   - else if (ovr > 0 && ovr < session->maxROWS)
354   - popup_an_error(session,"Invalid %s rows (%d):\nLess than model %d rows (%d)",ResOversize, ovr, session->model_num, session->maxROWS);
  200 + {
  201 + lib3270_popup_dialog(
  202 + session,
  203 + LIB3270_NOTIFY_ERROR,
  204 + _( "Invalid oversize" ),
  205 + _( "The oversize values are too big." ), \
  206 + _( "%dx%d screen size is bigger than the maximum size" ),
  207 + ovc, ovr
  208 + );
  209 +
  210 +// popup_an_error(session,"Invalid %s %dx%d:\nToo big",ResOversize, ovc, ovr);
  211 +
  212 + }
  213 + else if (ovc > 0 && ovc < session->max.cols)
  214 + {
  215 +
  216 + lib3270_popup_dialog(
  217 + session,
  218 + LIB3270_NOTIFY_ERROR,
  219 + _( "Invalid oversize" ),
  220 + _( "The oversize width is too small." ), \
  221 + _( "The width %d is less than model %d columns (%d)" ),
  222 + ovc, session->model_num, session->max.cols
  223 + );
  224 +
  225 +// popup_an_error(session,"Invalid %s cols (%d):\nLess than model %d cols (%d)",ResOversize, ovc, session->model_num, session->maxCOLS);
  226 + }
  227 + else if (ovr > 0 && ovr < session->max.rows)
  228 + {
  229 +
  230 + lib3270_popup_dialog(
  231 + session,
  232 + LIB3270_NOTIFY_ERROR,
  233 + _( "Invalid oversize" ),
  234 + _( "The oversize height is too small." ), \
  235 + _( "The height %d is less than model %d rows (%d)" ),
  236 + ovr, session->model_num, session->max.rows
  237 + );
  238 +
  239 +// popup_an_error(session,"Invalid %s rows (%d):\nLess than model %d rows (%d)",ResOversize, ovr, session->model_num, session->maxROWS);
  240 +
  241 + }
355 242 else
356   - update_model_info(session,mn,session->ov_cols = ovc,session->ov_rows = ovr);
  243 + {
  244 + update_model_info(session,mn,session->oversize.cols = ovc,session->oversize.rows = ovr);
  245 + }
357 246 }
358 247  
359   - set_viewsize(session,sz[idx].rows,sz[idx].cols);
  248 + set_viewsize(session,session->max.rows,session->max.cols);
360 249  
361 250 }
362 251  
... ... @@ -636,8 +525,8 @@ LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0)
636 525 return 0;
637 526 }
638 527  
639   -LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, int row, int col) {
640   - return lib3270_get_is_protected(h, ((row-1) * h->cols) + (col-1));
  528 +LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, unsigned int row, unsigned int col) {
  529 + return lib3270_get_is_protected(h, ((row-1) * h->view.cols) + (col-1));
641 530 }
642 531  
643 532 LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr)
... ... @@ -659,7 +548,7 @@ LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr)
659 548  
660 549  
661 550 /**
662   - * Perform an erase command, which may include changing the (virtual) screen size.
  551 + * @brief Perform an erase command, which may include changing the (virtual) screen size.
663 552 *
664 553 */
665 554 void ctlr_erase(H3270 *session, int alt)
... ... @@ -677,13 +566,12 @@ void ctlr_erase(H3270 *session, int alt)
677 566 {
678 567 // Going from 24x80 to maximum.
679 568 session->cbk.display(session);
680   -
681   - set_viewsize(session,session->maxROWS,session->maxCOLS);
  569 + set_viewsize(session,session->max.rows,session->max.cols);
682 570 }
683 571 else
684 572 {
685 573 // Going from maximum to 24x80.
686   - if (session->maxROWS > 24 || session->maxCOLS > 80)
  574 + if (session->max.rows > 24 || session->max.cols > 80)
687 575 {
688 576 if(session->vcontrol)
689 577 {
... ... @@ -694,7 +582,7 @@ void ctlr_erase(H3270 *session, int alt)
694 582 if(lib3270_get_toggle(session,LIB3270_TOGGLE_ALTSCREEN))
695 583 set_viewsize(session,24,80);
696 584 else
697   - set_viewsize(session,session->maxROWS,80);
  585 + set_viewsize(session,session->max.rows,80);
698 586 }
699 587 }
700 588  
... ... @@ -702,8 +590,8 @@ void ctlr_erase(H3270 *session, int alt)
702 590  
703 591 }
704 592  
705   -/*
706   - * Interpret an incoming 3270 command.
  593 +/**
  594 + * @brief Interpret an incoming 3270 command.
707 595 */
708 596 enum pds process_ds(H3270 *hSession, unsigned char *buf, int buflen)
709 597 {
... ... @@ -943,7 +831,7 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all)
943 831 space3270out(hSession,3);
944 832 *hSession->obptr++ = ORDER_SBA;
945 833 ENCODE_BADDR(hSession->obptr, baddr);
946   - trace_ds(hSession," SetBufferAddress%s (Cols: %d Rows: %d)", rcba(hSession,baddr), hSession->cols, hSession->rows);
  834 + trace_ds(hSession," SetBufferAddress%s (Cols: %d Rows: %d)", rcba(hSession,baddr), hSession->view.cols, hSession->view.rows);
947 835 while (!hSession->ea_buf[baddr].fa)
948 836 {
949 837  
... ... @@ -1357,7 +1245,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1357 1245 END_TEXT("SetBufferAddress");
1358 1246 previous = SBA;
1359 1247 trace_ds(hSession,"%s",rcba(hSession,hSession->buffer_addr));
1360   - if(hSession->buffer_addr >= hSession->cols * hSession->rows)
  1248 + if(hSession->buffer_addr >= hSession->view.cols * hSession->view.rows)
1361 1249 {
1362 1250 ABORT_WRITE("invalid SBA address");
1363 1251 }
... ... @@ -1508,7 +1396,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1508 1396 trace_ds(hSession,"'");
1509 1397  
1510 1398 }
1511   - if (baddr >= hSession->cols * hSession->rows)
  1399 + if (baddr >= hSession->view.cols * hSession->view.rows)
1512 1400 {
1513 1401 ABORT_WRITE("invalid RA address");
1514 1402 }
... ... @@ -1556,7 +1444,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1556 1444 trace_ds(hSession,"%s",rcba(hSession,baddr));
1557 1445  
1558 1446 previous = ORDER;
1559   - if (baddr >= hSession->cols * hSession->rows)
  1447 + if (baddr >= hSession->view.cols * hSession->view.rows)
1560 1448 {
1561 1449 ABORT_WRITE("invalid EUA address");
1562 1450 }
... ... @@ -1861,7 +1749,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1861 1749 DEC_BA(baddr);
1862 1750 while (!aborted &&
1863 1751 ((fa_addr >= 0 && baddr != fa_addr) ||
1864   - (fa_addr < 0 && baddr != hSession->rows*hSession->cols - 1))) {
  1752 + (fa_addr < 0 && baddr != hSession->view.rows*hSession->view.cols - 1))) {
1865 1753 if (hSession->ea_buf[baddr].cc == FCORDER_SI) {
1866 1754 ABORT_WRITE("double SI");
1867 1755 }
... ... @@ -2069,8 +1957,8 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen)
2069 1957 * Insert NULLs to the end of the line and advance to
2070 1958 * the beginning of the next line.
2071 1959 */
2072   - s_row = hSession->buffer_addr / hSession->cols;
2073   - while ((hSession->buffer_addr / hSession->cols) == s_row)
  1960 + s_row = hSession->buffer_addr / hSession->view.cols;
  1961 + while ((hSession->buffer_addr / hSession->view.cols) == s_row)
2074 1962 {
2075 1963 ctlr_add(hSession,hSession->buffer_addr, EBC_null, hSession->default_cs);
2076 1964 ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg);
... ... @@ -2450,7 +2338,7 @@ int ctlr_any_data(H3270 *session)
2450 2338 {
2451 2339 register int i;
2452 2340  
2453   - for(i = 0; i < session->rows*session->cols; i++)
  2341 + for(i = 0; i < session->view.rows * session->view.cols; i++)
2454 2342 {
2455 2343 if (!IsBlank(session->ea_buf[i].cc))
2456 2344 return 1;
... ... @@ -2477,7 +2365,7 @@ void ctlr_clear(H3270 *session, Boolean can_snap)
2477 2365 #endif
2478 2366  
2479 2367 /* Clear the screen. */
2480   - (void) memset((char *)session->ea_buf, 0, session->rows*session->cols*sizeof(struct lib3270_ea));
  2368 + (void) memset((char *)session->ea_buf, 0, session->view.rows * session->view.cols * sizeof(struct lib3270_ea));
2481 2369 cursor_move(session,0);
2482 2370 session->buffer_addr = 0;
2483 2371  
... ... @@ -2506,7 +2394,7 @@ static void ctlr_blanks(H3270 *session)
2506 2394 {
2507 2395 int baddr;
2508 2396  
2509   - for (baddr = 0; baddr < session->rows*session->cols; baddr++)
  2397 + for (baddr = 0; baddr < session->view.rows * session->view.cols; baddr++)
2510 2398 {
2511 2399 if (!session->ea_buf[baddr].fa)
2512 2400 session->ea_buf[baddr].cc = EBC_space;
... ... @@ -2634,8 +2522,8 @@ static void ctlr_add_ic(H3270 *hSession, int baddr, unsigned char ic)
2634 2522 hSession->ea_buf[baddr].ic = ic;
2635 2523 }
2636 2524  
2637   -/*
2638   - * Wrapping bersion of ctlr_bcopy.
  2525 +/**
  2526 + * @brief Wrapping bersion of ctlr_bcopy.
2639 2527 */
2640 2528 void ctlr_wrapping_memmove(H3270 *hSession, int baddr_to, int baddr_from, int count)
2641 2529 {
... ... @@ -2647,8 +2535,8 @@ void ctlr_wrapping_memmove(H3270 *hSession, int baddr_to, int baddr_from, int co
2647 2535 * It's faster to figure out if none of this is true, then do a slow
2648 2536 * location-at-a-time version only if it happens.
2649 2537 */
2650   - if (baddr_from + count <= hSession->rows*hSession->cols &&
2651   - baddr_to + count <= hSession->rows*hSession->cols) {
  2538 + if (baddr_from + count <= hSession->view.rows * hSession->view.cols &&
  2539 + baddr_to + count <= hSession->view.rows * hSession->view.cols) {
2652 2540 ctlr_bcopy(hSession,baddr_from, baddr_to, count, True);
2653 2541 } else {
2654 2542 int i, from, to;
... ... @@ -2656,12 +2544,12 @@ void ctlr_wrapping_memmove(H3270 *hSession, int baddr_to, int baddr_from, int co
2656 2544 for (i = 0; i < count; i++) {
2657 2545 if (baddr_to > baddr_from) {
2658 2546 /* Shifting right, move left. */
2659   - to = (baddr_to + count - 1 - i) % hSession->rows*hSession->cols;
2660   - from = (baddr_from + count - 1 - i) % hSession->rows*hSession->cols;
  2547 + to = (baddr_to + count - 1 - i) % hSession->view.rows * hSession->view.cols;
  2548 + from = (baddr_from + count - 1 - i) % hSession->view.rows * hSession->view.cols;
2661 2549 } else {
2662 2550 /* Shifting left, move right. */
2663   - to = (baddr_to + i) % hSession->rows*hSession->cols;
2664   - from = (baddr_from + i) % hSession->rows*hSession->cols;
  2551 + to = (baddr_to + i) % hSession->view.rows * hSession->view.cols;
  2552 + from = (baddr_from + i) % hSession->view.rows * hSession->view.cols;
2665 2553 }
2666 2554 ctlr_bcopy(hSession,from, to, 1, True);
2667 2555 }
... ... @@ -2714,7 +2602,7 @@ void ctlr_aclear(H3270 *hSession, int baddr, int count, int GNUC_UNUSED(clear_ea
2714 2602 */
2715 2603 void ctlr_scroll(H3270 *hSession)
2716 2604 {
2717   - int qty = (hSession->rows - 1) * hSession->cols;
  2605 + int qty = (hSession->view.rows - 1) * hSession->view.cols;
2718 2606  
2719 2607 /* Make sure nothing is selected. (later this can be fixed) */
2720 2608 // unselect(0, ROWS*COLS);
... ... @@ -2722,10 +2610,10 @@ void ctlr_scroll(H3270 *hSession)
2722 2610 /* Synchronize pending changes prior to this. */
2723 2611  
2724 2612 /* Move ea_buf. */
2725   - (void) memmove(&hSession->ea_buf[0], &hSession->ea_buf[hSession->cols],qty * sizeof(struct lib3270_ea));
  2613 + (void) memmove(&hSession->ea_buf[0], &hSession->ea_buf[hSession->view.cols],qty * sizeof(struct lib3270_ea));
2726 2614  
2727 2615 /* Clear the last line. */
2728   - (void) memset((char *) &hSession->ea_buf[qty], 0, hSession->cols * sizeof(struct lib3270_ea));
  2616 + (void) memset((char *) &hSession->ea_buf[qty], 0, hSession->view.cols * sizeof(struct lib3270_ea));
2729 2617  
2730 2618 hSession->cbk.display(hSession);
2731 2619  
... ...
src/core/cursor.c
... ... @@ -263,9 +263,9 @@ static int cursor_up(H3270 *hSession)
263 263 }
264 264 #endif /*]*/
265 265  
266   - baddr = hSession->cursor_addr - hSession->cols;
  266 + baddr = hSession->cursor_addr - hSession->view.cols;
267 267 if (baddr < 0)
268   - baddr = (hSession->cursor_addr + (hSession->rows * hSession->cols)) - hSession->cols;
  268 + baddr = (hSession->cursor_addr + (hSession->view.rows * hSession->view.cols)) - hSession->view.cols;
269 269 cursor_move(hSession,baddr);
270 270 return 0;
271 271 }
... ... @@ -294,7 +294,7 @@ static int cursor_down(H3270 *hSession)
294 294 return 0;
295 295 }
296 296 #endif /*]*/
297   - baddr = (hSession->cursor_addr + hSession->cols) % (hSession->cols * hSession->rows);
  297 + baddr = (hSession->cursor_addr + hSession->view.cols) % (hSession->view.cols * hSession->view.rows);
298 298 cursor_move(hSession,baddr);
299 299 return 0;
300 300 }
... ...
src/core/keyboard/actions.c
... ... @@ -201,7 +201,8 @@ LIB3270_EXPORT int lib3270_firstfield(H3270 *hSession)
201 201 cursor_move(hSession,0);
202 202 return 0;
203 203 }
204   - cursor_move(hSession,lib3270_get_next_unprotected(hSession,hSession->rows*hSession->cols-1));
  204 +
  205 + cursor_move(hSession,lib3270_get_next_unprotected(hSession,hSession->view.rows * hSession->view.cols-1));
205 206  
206 207 return 0;
207 208 }
... ... @@ -288,9 +289,9 @@ static Boolean do_delete(H3270 *hSession)
288 289 }
289 290 else
290 291 {
291   - if ((baddr % hSession->cols) == hSession->cols - ndel)
  292 + if ((baddr % hSession->view.cols) == hSession->view.cols - ndel)
292 293 return True;
293   - end_baddr = baddr + (hSession->cols - (baddr % hSession->cols)) - 1;
  294 + end_baddr = baddr + (hSession->view.cols - (baddr % hSession->view.cols)) - 1;
294 295 }
295 296  
296 297 /* Shift the remainder of the field left. */
... ... @@ -301,8 +302,8 @@ static Boolean do_delete(H3270 *hSession)
301 302 else if (end_baddr != baddr)
302 303 {
303 304 /* XXX: Need to verify this. */
304   - ctlr_bcopy(hSession,baddr + ndel, baddr,((hSession->rows * hSession->cols) - 1) - (baddr + ndel) + 1, 0);
305   - ctlr_bcopy(hSession,0, (hSession->rows * hSession->cols) - ndel, ndel, 0);
  305 + ctlr_bcopy(hSession,baddr + ndel, baddr,((hSession->view.rows * hSession->view.cols) - 1) - (baddr + ndel) + 1, 0);
  306 + ctlr_bcopy(hSession,0, (hSession->view.rows * hSession->view.cols) - ndel, ndel, 0);
306 307 ctlr_bcopy(hSession,ndel, 0, end_baddr - ndel + 1, 0);
307 308 }
308 309  
... ...
src/core/keyboard/kybd.c
... ... @@ -574,7 +574,7 @@ static Boolean ins_prep(H3270 *hSession, int faddr, int baddr, int count)
574 574 if (faddr == -1)
575 575 {
576 576 /* Unformatted. Use the end of the line. */
577   - next_faddr = (((baddr / hSession->cols) + 1) * hSession->cols) % (hSession->rows*hSession->cols);
  577 + next_faddr = (((baddr / hSession->view.cols) + 1) * hSession->view.cols) % (hSession->view.rows*hSession->view.cols);
578 578 }
579 579 else
580 580 {
... ... @@ -639,8 +639,8 @@ static Boolean ins_prep(H3270 *hSession, int faddr, int baddr, int count)
639 639 /* Shift right n_nulls worth. */
640 640 copy_len = first_null - baddr;
641 641 if (copy_len < 0)
642   - copy_len += hSession->rows*hSession->cols;
643   - to = (baddr + n_nulls) % (hSession->rows*hSession->cols);
  642 + copy_len += hSession->view.rows * hSession->view.cols;
  643 + to = (baddr + n_nulls) % (hSession->view.rows * hSession->view.cols);
644 644 /*
645 645 #if defined(_ST)
646 646 printf("found %d NULLs at %d\n", n_nulls, first_null);
... ... @@ -876,7 +876,7 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean
876 876 while (baddr_fill != faddr) {
877 877  
878 878 /* Check for backward line wrap. */
879   - if ((baddr_fill % hSession->cols) == hSession->cols - 1)
  879 + if ((baddr_fill % hSession->view.cols) == hSession->view.cols - 1)
880 880 {
881 881 Boolean aborted = True;
882 882 register int baddr_scan = baddr_fill;
... ... @@ -891,7 +891,7 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean
891 891 aborted = False;
892 892 break;
893 893 }
894   - if (!(baddr_scan % hSession->cols))
  894 + if (!(baddr_scan % hSession->view.cols))
895 895 break;
896 896 DEC_BA(baddr_scan);
897 897 }
... ... @@ -947,7 +947,7 @@ LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *st
947 947 for(pos = 0; pos < length && str[pos] && !rc; pos++)
948 948 rc = key_ACharacter(hSession,(str[pos] & 0xff), KT_STD, IA_KEY, NULL);
949 949  
950   - screen_update(hSession,0,hSession->rows*hSession->cols);
  950 + screen_update(hSession,0,hSession->view.rows * hSession->view.cols);
951 951  
952 952 return rc;
953 953 }
... ... @@ -1228,8 +1228,8 @@ LIB3270_EXPORT int lib3270_newline(H3270 *hSession)
1228 1228 return 0;
1229 1229 }
1230 1230 #endif /*]*/
1231   - baddr = (hSession->cursor_addr + hSession->cols) % (hSession->cols * hSession->rows); /* down */
1232   - baddr = (baddr / hSession->cols) * hSession->cols; /* 1st col */
  1231 + baddr = (hSession->cursor_addr + hSession->view.cols) % (hSession->view.cols * hSession->view.rows); /* down */
  1232 + baddr = (baddr / hSession->view.cols) * hSession->view.cols; /* 1st col */
1233 1233 faddr = lib3270_field_addr(hSession,baddr);
1234 1234 fa = hSession->ea_buf[faddr].fa;
1235 1235 if (faddr != baddr && !FA_IS_PROTECTED(fa))
... ...
src/core/model.c 0 → 100644
... ... @@ -0,0 +1,222 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como - e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include <lib3270-internals.h>
  31 + #include "screen.h"
  32 + #include "ctlrc.h"
  33 + #include "popupsc.h"
  34 + #include <lib3270/trace.h>
  35 + #include <lib3270/log.h>
  36 +
  37 + const char * lib3270_get_oversize(H3270 *hSession)
  38 + {
  39 + return hSession->oversize.str;
  40 + }
  41 +
  42 + int lib3270_set_oversize(H3270 *hSession, const char GNUC_UNUSED(*value))
  43 + {
  44 + if(hSession->cstate != LIB3270_NOT_CONNECTED)
  45 + return errno = EISCONN;
  46 +
  47 + if(!hSession->extended)
  48 + return errno = ENOTSUP;
  49 +
  50 + // TODO: Implement it!
  51 + // Replace(hSession->oversize.str,value);
  52 +
  53 + return errno = ENOTSUP;
  54 +
  55 + }
  56 +
  57 +/**
  58 + * @brief Get current 3270 model.
  59 + *
  60 + * @param hSession selected 3270 session.
  61 + * @return Current model number.
  62 + */
  63 +int lib3270_get_model_number(H3270 *hSession)
  64 +{
  65 + CHECK_SESSION_HANDLE(hSession);
  66 + return hSession->model_num;
  67 +}
  68 +
  69 +const char * lib3270_get_model(H3270 *hSession)
  70 +{
  71 + CHECK_SESSION_HANDLE(hSession);
  72 + return hSession->model_name;
  73 +}
  74 +
  75 + /**
  76 + * @brief Parse the model number.
  77 + *
  78 + * @param session Session Handle.
  79 + * @param m Model number.
  80 + *
  81 + * @return -1 (error), 0 (default), or the specified number.
  82 + */
  83 +static int parse_model_number(H3270 *session, const char *m)
  84 +{
  85 + int sl;
  86 + int n;
  87 +
  88 + if(!m)
  89 + return 0;
  90 +
  91 + sl = strlen(m);
  92 +
  93 + /* An empty model number is no good. */
  94 + if (!sl)
  95 + return 0;
  96 +
  97 + if (sl > 1) {
  98 + /*
  99 + * If it's longer than one character, it needs to start with
  100 + * '327[89]', and it sets the m3279 resource.
  101 + */
  102 + if (!strncmp(m, "3278", 4))
  103 + {
  104 + session->m3279 = 0;
  105 + }
  106 + else if (!strncmp(m, "3279", 4))
  107 + {
  108 + session->m3279 = 1;
  109 + }
  110 + else
  111 + {
  112 + return -1;
  113 + }
  114 + m += 4;
  115 + sl -= 4;
  116 +
  117 + /* Check more syntax. -E is allowed, but ignored. */
  118 + switch (m[0]) {
  119 + case '\0':
  120 + /* Use default model number. */
  121 + return 0;
  122 + case '-':
  123 + /* Model number specified. */
  124 + m++;
  125 + sl--;
  126 + break;
  127 + default:
  128 + return -1;
  129 + }
  130 + switch (sl) {
  131 + case 1: /* n */
  132 + break;
  133 + case 3: /* n-E */
  134 + if (strcasecmp(m + 1, "-E")) {
  135 + return -1;
  136 + }
  137 + break;
  138 + default:
  139 + return -1;
  140 + }
  141 + }
  142 +
  143 + /* Check the numeric model number. */
  144 + n = atoi(m);
  145 + if (n >= 2 && n <= 5) {
  146 + return n;
  147 + } else {
  148 + return -1;
  149 + }
  150 +
  151 +}
  152 +
  153 +int lib3270_set_model(H3270 *hSession, const char *model)
  154 +{
  155 + int ovc, ovr;
  156 + char junk;
  157 + int model_number;
  158 +
  159 + if(hSession->cstate != LIB3270_NOT_CONNECTED)
  160 + return errno = EISCONN;
  161 +
  162 + strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH);
  163 + hSession->model_name = &hSession->full_model_name[4];
  164 +
  165 + if(!*model)
  166 + model = "2"; // No model, use the default one
  167 +
  168 + model_number = parse_model_number(hSession,model);
  169 + if (model_number < 0)
  170 + {
  171 + popup_an_error(hSession,"Invalid model number: %s", model);
  172 + model_number = 0;
  173 + }
  174 +
  175 + if (!model_number)
  176 + {
  177 +#if defined(RESTRICT_3279)
  178 + model_number = 3;
  179 +#else
  180 + model_number = 4;
  181 +#endif
  182 + }
  183 +
  184 + if(hSession->mono)
  185 + hSession->m3279 = 0;
  186 + else
  187 + hSession->m3279 = 1;
  188 +
  189 + if(!hSession->extended)
  190 + {
  191 + if(hSession->oversize.str)
  192 + lib3270_free(hSession->oversize.str);
  193 + hSession->oversize.str = CN;
  194 + }
  195 +
  196 +#if defined(RESTRICT_3279)
  197 + if (hSession->m3279 && model_number == 4)
  198 + model_number = 3;
  199 +#endif
  200 +
  201 + trace("Model_number: %d",model_number);
  202 +
  203 + if (!hSession->extended || hSession->oversize.str == CN || sscanf(hSession->oversize.str, "%dx%d%c", &ovc, &ovr, &junk) != 2)
  204 + {
  205 + ovc = 0;
  206 + ovr = 0;
  207 + }
  208 + ctlr_set_rows_cols(hSession, model_number, ovc, ovr);
  209 +
  210 + if (hSession->termname != CN)
  211 + hSession->termtype = hSession->termname;
  212 + else
  213 + hSession->termtype = hSession->full_model_name;
  214 +
  215 + trace("Termtype: %s",hSession->termtype);
  216 +
  217 + ctlr_reinit(hSession,MODEL_CHANGE);
  218 + screen_update(hSession,0,hSession->view.rows*hSession->view.cols);
  219 +
  220 + return 0;
  221 +}
  222 +
... ...
src/core/paste.c
... ... @@ -193,8 +193,8 @@ static int set_string(H3270 *hSession, const unsigned char *str, int length)
193 193 int faddr;
194 194 unsigned char fa;
195 195  
196   - baddr = (hSession->cursor_addr + hSession->cols) % (hSession->cols * hSession->rows); /* down */
197   - baddr = (baddr / hSession->cols) * hSession->cols; /* 1st col */
  196 + baddr = (hSession->cursor_addr + hSession->view.cols) % (hSession->view.cols * hSession->view.rows); /* down */
  197 + baddr = (baddr / hSession->view.cols) * hSession->view.cols; /* 1st col */
198 198 faddr = lib3270_field_addr(hSession,baddr);
199 199 fa = hSession->ea_buf[faddr].fa;
200 200 if (faddr != baddr && !FA_IS_PROTECTED(fa))
... ... @@ -248,12 +248,12 @@ LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsi
248 248 row--;
249 249 col--;
250 250  
251   - if(row > hSession->rows || col > hSession->cols)
  251 + if(row > hSession->view.rows || col > hSession->view.cols)
252 252 return - (errno = EOVERFLOW);
253 253  
254 254 hSession->cbk.suspend(hSession);
255 255  
256   - hSession->cursor_addr = (row * hSession->cols) + col;
  256 + hSession->cursor_addr = (row * hSession->view.cols) + col;
257 257 rc = set_string(hSession, str, length);
258 258 hSession->cbk.resume(hSession);
259 259  
... ...
src/core/properties/string.c
... ... @@ -132,6 +132,13 @@
132 132 NULL // Set value.
133 133 },
134 134  
  135 + {
  136 + "oversize", // Property name.
  137 + N_( "Screen oversize if larger than the chosen model"), // Property description.
  138 + lib3270_get_oversize, // Get value.
  139 + lib3270_set_oversize // Set value.
  140 + },
  141 +
135 142 /*
136 143 {
137 144 "", // Property name.
... ...
src/core/screen.c
... ... @@ -99,9 +99,9 @@ LIB3270_EXPORT LIB3270_ATTR lib3270_get_attribute_at_address(H3270 *hSession, un
99 99 if(check_online_session(hSession))
100 100 return (LIB3270_ATTR) -1;
101 101  
102   - if(!hSession->text ||baddr > (hSession->rows*hSession->cols))
  102 + if(!hSession->text ||baddr > (hSession->view.rows*hSession->view.cols))
103 103 {
104   - errno = EINVAL;
  104 + errno = EOVERFLOW;
105 105 return (LIB3270_ATTR) -1;
106 106 }
107 107  
... ... @@ -112,9 +112,9 @@ LIB3270_EXPORT int lib3270_is_selected(H3270 *hSession, unsigned int baddr)
112 112 {
113 113 FAIL_IF_NOT_ONLINE(hSession);
114 114  
115   - if(!hSession->text || baddr > (hSession->rows*hSession->cols))
  115 + if(!hSession->text || baddr > (hSession->view.rows * hSession->view.cols))
116 116 {
117   - errno = EINVAL;
  117 + errno = EOVERFLOW;
118 118 return -1;
119 119 }
120 120  
... ... @@ -125,9 +125,9 @@ LIB3270_EXPORT int lib3270_get_element(H3270 *hSession, unsigned int baddr, unsi
125 125 {
126 126 FAIL_IF_NOT_ONLINE(hSession);
127 127  
128   - if(!hSession->text || baddr > (hSession->rows*hSession->cols))
  128 + if(!hSession->text || baddr > (hSession->view.rows * hSession->view.cols))
129 129 {
130   - errno = EINVAL;
  130 + errno = EOVERFLOW;
131 131 return -1;
132 132 }
133 133  
... ... @@ -248,14 +248,14 @@ static unsigned short calc_attrs(H3270 *session, int baddr, int fa_addr, int fa)
248 248 LIB3270_EXPORT unsigned int lib3270_get_length(H3270 *h)
249 249 {
250 250 CHECK_SESSION_HANDLE(h);
251   - return h->rows * h->cols;
  251 + return h->view.rows * h->view.cols;
252 252 }
253 253  
254 254 LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, unsigned int *r, unsigned int *c)
255 255 {
256 256 CHECK_SESSION_HANDLE(h);
257   - *r = h->rows;
258   - *c = h->cols;
  257 + *r = h->view.rows;
  258 + *c = h->view.cols;
259 259  
260 260 // trace("%s: %d - %d",__FUNCTION__, h->rows, h->cols);
261 261  
... ... @@ -264,22 +264,22 @@ LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, unsigned int *r, unsigned
264 264 LIB3270_EXPORT unsigned int lib3270_get_width(H3270 *h)
265 265 {
266 266 CHECK_SESSION_HANDLE(h);
267   - return h->cols;
  267 + return h->view.cols;
268 268 }
269 269  
270 270 LIB3270_EXPORT unsigned int lib3270_get_height(H3270 *h)
271 271 {
272 272 CHECK_SESSION_HANDLE(h);
273   - return h->rows;
  273 + return h->view.rows;
274 274 }
275 275  
276 276 void update_model_info(H3270 *session, unsigned int model, unsigned int cols, unsigned int rows)
277 277 {
278   - if(model == session->model_num && session->maxROWS == rows && session->maxCOLS == cols)
  278 + if(model == session->model_num && session->max.rows == rows && session->max.cols == cols)
279 279 return;
280 280  
281   - session->maxCOLS = cols;
282   - session->maxROWS = rows;
  281 + session->max.cols = cols;
  282 + session->max.rows = rows;
283 283 session->model_num = model;
284 284  
285 285 /* Update the model name. */
... ... @@ -296,7 +296,7 @@ LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned
296 296  
297 297 CHECK_SESSION_HANDLE(h);
298 298  
299   - len = h->rows * h->cols;
  299 + len = h->view.rows * h->view.cols;
300 300  
301 301 if(first > len || last > len || first < 0 || last < 0)
302 302 return EFAULT;
... ... @@ -377,7 +377,7 @@ void screen_update(H3270 *session, int bstart, int bend)
377 377  
378 378 for(f=first;f<last;f++)
379 379 {
380   - if(f%session->cols == 0)
  380 + if(f%session->view.cols == 0)
381 381 len++;
382 382 }
383 383  
... ... @@ -430,10 +430,10 @@ LIB3270_EXPORT int lib3270_translate_to_address(H3270 *hSession, unsigned int ro
430 430 row--;
431 431 col--;
432 432  
433   - if(row > hSession->rows || col > hSession->cols)
  433 + if(row > hSession->view.rows || col > hSession->view.cols)
434 434 return - (errno = EOVERFLOW);
435 435  
436   - return (row * hSession->cols) + col;
  436 + return (row * hSession->view.cols) + col;
437 437 }
438 438  
439 439  
... ... @@ -443,7 +443,7 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int badd
443 443  
444 444 trace("%s(%d)",__FUNCTION__,baddr);
445 445  
446   - if(baddr > (hSession->rows * hSession->cols))
  446 + if(baddr > (hSession->view.rows * hSession->view.cols))
447 447 return - (errno = EOVERFLOW);
448 448  
449 449 if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED))
... ... @@ -481,8 +481,8 @@ int cursor_move(H3270 *hSession, int baddr)
481 481 hSession->cursor_addr = baddr;
482 482 hSession->cbk.update_cursor(
483 483 hSession,
484   - (unsigned short) (baddr/hSession->cols),
485   - (unsigned short) (baddr%hSession->cols),
  484 + (unsigned short) (baddr/hSession->view.cols),
  485 + (unsigned short) (baddr%hSession->view.cols),
486 486 hSession->text[baddr].chr,
487 487 hSession->text[baddr].attr
488 488 );
... ... @@ -652,16 +652,16 @@ void set_viewsize(H3270 *session, unsigned int rows, unsigned int cols)
652 652 {
653 653 CHECK_SESSION_HANDLE(session);
654 654  
655   - if(rows == session->rows && session->cols == cols)
  655 + if(rows == session->view.rows && session->view.cols == cols)
656 656 return;
657 657  
658   - session->rows = rows;
659   - session->cols = cols;
  658 + session->view.rows = rows;
  659 + session->view.cols = cols;
660 660  
661 661 trace("View size changes to %dx%d",rows,cols);
662 662  
663 663 if(session->cbk.configure)
664   - session->cbk.configure(session,session->rows,session->cols);
  664 + session->cbk.configure(session,session->view.rows,session->view.cols);
665 665  
666 666 }
667 667  
... ... @@ -896,7 +896,7 @@ LIB3270_EXPORT int lib3270_testpattern(H3270 *hSession)
896 896  
897 897 FAIL_IF_ONLINE(hSession);
898 898  
899   - max = (hSession->maxROWS * hSession->maxCOLS);
  899 + max = (hSession->max.rows * hSession->max.cols);
900 900 for(f=0;f<max;f++)
901 901 {
902 902 if(!pat[row].cc[pos])
... ...
src/core/session.c
... ... @@ -273,7 +273,7 @@ static void set_timer(H3270 GNUC_UNUSED(*session), unsigned char GNUC_UNUSED(on)
273 273 static void screen_disp(H3270 *session)
274 274 {
275 275 CHECK_SESSION_HANDLE(session);
276   - screen_update(session,0,session->rows*session->cols);
  276 + screen_update(session,0,session->view.rows*session->view.cols);
277 277 }
278 278  
279 279 static void nop_int(H3270 GNUC_UNUSED(*session), int GNUC_UNUSED(width))
... ...
src/core/sf.c
... ... @@ -552,14 +552,14 @@ static enum pds sf_create_partition(H3270 *hSession, unsigned char buf[], int bu
552 552 GET16(h, &buf[6]);
553 553 trace_ds(hSession,",h=%d", h);
554 554 } else
555   - h = hSession->maxROWS;
  555 + h = hSession->max.rows;
556 556  
557 557 if (buflen > 9)
558 558 {
559 559 GET16(w, &buf[8]);
560 560 trace_ds(hSession,",w=%d", w);
561 561 } else
562   - w = hSession->maxCOLS;
  562 + w = hSession->max.cols;
563 563  
564 564 if (buflen > 11)
565 565 {
... ... @@ -579,14 +579,14 @@ static enum pds sf_create_partition(H3270 *hSession, unsigned char buf[], int bu
579 579 GET16(hv, &buf[14]);
580 580 trace_ds(hSession,",hv=%d", hv);
581 581 } else
582   - hv = (h > hSession->maxROWS)? hSession->maxROWS: h;
  582 + hv = (h > hSession->max.rows)? hSession->max.rows: h;
583 583  
584 584 if (buflen > 17)
585 585 {
586 586 GET16(wv, &buf[16]);
587 587 trace_ds(hSession,",wv=%d", wv);
588 588 } else
589   - wv = (w > hSession->maxCOLS)? hSession->maxCOLS: w;
  589 + wv = (w > hSession->max.cols)? hSession->max.cols: w;
590 590  
591 591 if (buflen > 19)
592 592 {
... ... @@ -787,8 +787,8 @@ static void do_qr_usable_area(H3270 *hSession)
787 787 space3270out(hSession,19);
788 788 *hSession->obptr++ = 0x01; /* 12/14-bit addressing */
789 789 *hSession->obptr++ = 0x00; /* no special character features */
790   - SET16(hSession->obptr, hSession->maxCOLS); /* usable width */
791   - SET16(hSession->obptr, hSession->maxROWS); /* usable height */
  790 + SET16(hSession->obptr, hSession->max.cols); /* usable width */
  791 + SET16(hSession->obptr, hSession->max.rows); /* usable height */
792 792 *hSession->obptr++ = 0x01; /* units (mm) */
793 793 num = display_widthMM();
794 794 denom = display_width();
... ... @@ -810,7 +810,7 @@ static void do_qr_usable_area(H3270 *hSession)
810 810 SET16(hSession->obptr, (int)denom); /* Yr denominator */
811 811 *hSession->obptr++ = *char_width; /* AW */
812 812 *hSession->obptr++ = *char_height; /* AH */
813   - SET16(hSession->obptr, hSession->maxCOLS * hSession->maxROWS); /* buffer, questionable */
  813 + SET16(hSession->obptr, hSession->max.cols * hSession->max.cols); /* buffer, questionable */
814 814 }
815 815  
816 816 static void do_qr_color(H3270 *hSession)
... ... @@ -897,7 +897,7 @@ static void do_qr_alpha_part(H3270 *hSession)
897 897 trace_ds(hSession,"> QueryReply(AlphanumericPartitions)\n");
898 898 space3270out(hSession,4);
899 899 *hSession->obptr++ = 0; /* 1 partition */
900   - SET16(hSession->obptr, hSession->maxROWS * hSession->maxCOLS); /* buffer space */
  900 + SET16(hSession->obptr, hSession->max.cols * hSession->max.rows); /* buffer space */
901 901 *hSession->obptr++ = 0; /* no special features */
902 902 }
903 903  
... ... @@ -1009,8 +1009,8 @@ static void do_qr_imp_part(H3270 *hSession)
1009 1009 *hSession->obptr++ = 0x00; /* reserved */
1010 1010 SET16(hSession->obptr, 80); /* implicit partition width */
1011 1011 SET16(hSession->obptr, 24); /* implicit partition height */
1012   - SET16(hSession->obptr, hSession->maxCOLS); /* alternate height */
1013   - SET16(hSession->obptr, hSession->maxROWS); /* alternate width */
  1012 + SET16(hSession->obptr, hSession->max.cols); /* alternate height */
  1013 + SET16(hSession->obptr, hSession->max.rows); /* alternate width */
1014 1014 }
1015 1015  
1016 1016 static void query_reply_end(H3270 *hSession)
... ...
src/core/telnet.c
... ... @@ -246,9 +246,8 @@ static const char *trsp_flag[2] = { &quot;POSITIVE-RESPONSE&quot;, &quot;NEGATIVE-RESPONSE&quot; };
246 246 #endif /*]*/
247 247 #endif /*]*/
248 248  
249   -#define XMIT_ROWS hSession->maxROWS
250   -#define XMIT_COLS hSession->maxCOLS
251   -
  249 +#define XMIT_ROWS hSession->max.rows
  250 +#define XMIT_COLS hSession->max.cols
252 251  
253 252 #if defined(_WIN32) /*[*/
254 253 #define socket_errno() WSAGetLastError()
... ...
src/core/toggles.c
... ... @@ -338,7 +338,7 @@ LIB3270_EXPORT int lib3270_toggle(H3270 *session, LIB3270_TOGGLE ix)
338 338 static void toggle_altscreen(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE GNUC_UNUSED(tt))
339 339 {
340 340 if(!session->screen_alt)
341   - set_viewsize(session,t->value ? 24 : session->maxROWS,80);
  341 + set_viewsize(session,t->value ? 24 : session->max.rows,80);
342 342 }
343 343  
344 344 static void toggle_redraw(H3270 *session, struct lib3270_toggle GNUC_UNUSED(*t), LIB3270_TOGGLE_TYPE GNUC_UNUSED(tt))
... ...
src/core/trace_ds.c
... ... @@ -77,7 +77,7 @@ static void wtrace(H3270 *session, const char *fmt, ...);
77 77 const char * rcba(H3270 *hSession, int baddr)
78 78 {
79 79 static char buf[48];
80   - (void) snprintf(buf, 48, "(%d,%d)", baddr/hSession->cols + 1, baddr%hSession->cols + 1);
  80 + (void) snprintf(buf, 48, "(%d,%d)", baddr/hSession->view.cols + 1, baddr%hSession->view.cols + 1);
81 81 return buf;
82 82 }
83 83  
... ... @@ -262,12 +262,12 @@ void trace_screen(H3270 *session)
262 262 {
263 263 unsigned int row, baddr;
264 264  
265   - for(row=baddr=0;row < session->rows;row++)
  265 + for(row=baddr=0;row < session->view.rows;row++)
266 266 {
267 267 unsigned int col;
268 268 wtrace(session,"%02d ",row+1);
269 269  
270   - for(col = 0; col < session->cols;col++)
  270 + for(col = 0; col < session->view.cols;col++)
271 271 {
272 272 if(session->text[baddr].attr & LIB3270_ATTR_CG)
273 273 wtrace(session,"%c",'.');
... ... @@ -305,7 +305,7 @@ void trace_ansi_disc(H3270 *hSession)
305 305 unsigned int i;
306 306  
307 307 wtrace(hSession,"%c",'\n');
308   - for (i = 0; i < hSession->cols; i++)
  308 + for (i = 0; i < hSession->view.cols; i++)
309 309 wtrace(hSession,"%c",'=');
310 310 wtrace(hSession,"%c",'\n');
311 311  
... ...
src/include/3270ds.h
... ... @@ -141,11 +141,11 @@
141 141 #define QR_IMP_PART 0xa6 /* implicit partition */
142 142 #define QR_NULL 0xff /* null */
143 143  
144   -#define BA_TO_ROW(ba) ((ba) / hSession->cols)
145   -#define BA_TO_COL(ba) ((ba) % hSession->cols)
146   -#define ROWCOL_TO_BA(r,c) (((r) * hSession->cols) + c)
147   -#define INC_BA(ba) { (ba) = ((ba) + 1) % (hSession->cols * hSession->rows); }
148   -#define DEC_BA(ba) { (ba) = (ba) ? (ba - 1) : (((int) (hSession->cols*hSession->rows)) - 1); }
  144 +#define BA_TO_ROW(ba) ((ba) / hSession->view.cols)
  145 +#define BA_TO_COL(ba) ((ba) % hSession->view.cols)
  146 +#define ROWCOL_TO_BA(r,c) (((r) * hSession->view.cols) + c)
  147 +#define INC_BA(ba) { (ba) = ((ba) + 1) % (hSession->view.cols * hSession->view.rows); }
  148 +#define DEC_BA(ba) { (ba) = (ba) ? (ba - 1) : (((int) (hSession->view.cols*hSession->view.rows)) - 1); }
149 149  
150 150 /** Field attributes. */
151 151 #define FA_PRINTABLE 0xc0 ///< @brief these make the character "printable" */
... ...
src/include/lib3270-internals.h
... ... @@ -362,7 +362,7 @@ struct _h3270
362 362 int modified_sel : 1;
363 363 int mono : 1; ///< @brief Forces monochrome display
364 364 int m3279 : 1;
365   - int extended : 1;
  365 + int extended : 1; ///< @brief Extended data stream.
366 366 int typeahead : 1;
367 367 int numeric_lock : 1;
368 368 int oerr_lock : 1; ///< @brief If true, operator errors will lock the keyboard.
... ... @@ -385,8 +385,6 @@ struct _h3270
385 385 int formatted : 1; /**< @brief Formatted screen flag */
386 386 int starting : 1; /**< @brief Is starting (no first screen)? */
387 387  
388   - char * oversize;
389   -
390 388 struct lib3270_toggle
391 389 {
392 390 char value; /**< toggle value */
... ... @@ -428,12 +426,28 @@ struct _h3270
428 426 H3270FT * ft; /**< @brief Active file transfer data */
429 427  
430 428 // screen info
431   - unsigned int ov_rows;
432   - unsigned int ov_cols;
433   - unsigned int maxROWS;
434   - unsigned int maxCOLS;
435   - unsigned int rows;
436   - unsigned int cols;
  429 +
  430 + // Oversize.
  431 + struct
  432 + {
  433 + char * str;
  434 + unsigned int rows;
  435 + unsigned int cols;
  436 + } oversize;
  437 +
  438 + // Maximum screen size.
  439 + struct
  440 + {
  441 + unsigned int rows;
  442 + unsigned int cols;
  443 + } max;
  444 +
  445 + // View size
  446 + struct {
  447 + unsigned int rows;
  448 + unsigned int cols;
  449 + } view;
  450 +
437 451 LIB3270_POINTER pointer; /**< @brief Current pointer. */
438 452 int cursor_addr;
439 453 int buffer_addr;
... ...
src/include/lib3270.h
... ... @@ -1196,7 +1196,7 @@
1196 1196 * @param col Desired col.
1197 1197 *
1198 1198 */
1199   - LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, int row, int col);
  1199 + LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, unsigned int row, unsigned int col);
1200 1200  
1201 1201 /**
1202 1202 * @brief Get address of the first blank.
... ...
src/include/lib3270/properties.h
... ... @@ -128,6 +128,7 @@
128 128 /**
129 129 * @brief Set lib3270 integer property by name.
130 130 *
  131 + * @param hSession Session handle.
131 132 * @param name Nome of the property.
132 133 * @param value New property value.
133 134 * @param seconds Time (in seconds) whe should wait for "ready" state (0 = none).
... ... @@ -137,6 +138,31 @@
137 138 */
138 139 LIB3270_EXPORT int lib3270_set_string_property(H3270 * hSession, const char *name, const char * value, int seconds);
139 140  
  141 +
  142 + /**
  143 + * @brief Get Oversize.
  144 + *
  145 + * @param hSession Session handle.
  146 + *
  147 + * @return Oversize definition (NULL if not set).
  148 + *
  149 + */
  150 + LIB3270_EXPORT const char * lib3270_get_oversize(H3270 *hSession);
  151 +
  152 + /**
  153 + * @brief Set oversize.
  154 + *
  155 + * @param hSession Session handle.
  156 + * @param value Oversize value.
  157 + *
  158 + * @return 0 if success, error code if not (sets errno)
  159 + *
  160 + * @retval EISCONN Already connected to host.
  161 + * @retval ENOTSUP Oversize is not supported.
  162 + *
  163 + */
  164 + LIB3270_EXPORT int lib3270_set_oversize(H3270 *hSession, const char *value);
  165 +
140 166 #ifdef __cplusplus
141 167 }
142 168 #endif
... ...
src/selection/actions.c
... ... @@ -51,7 +51,7 @@ LIB3270_EXPORT int lib3270_unselect(H3270 *hSession)
51 51 {
52 52 hSession->selected = 0;
53 53  
54   - for(a = 0; a < ((int) (hSession->rows*hSession->cols)); a++)
  54 + for(a = 0; a < ((int) (hSession->view.rows * hSession->view.cols)); a++)
55 55 {
56 56 if(hSession->text[a].attr & LIB3270_ATTR_SELECTED)
57 57 {
... ... @@ -94,7 +94,7 @@ LIB3270_EXPORT int lib3270_select_region(H3270 *h, int start, int end)
94 94 if(!lib3270_connected(h))
95 95 return ENOTCONN;
96 96  
97   - maxlen = (h->rows * h->cols);
  97 + maxlen = (h->view.rows * h->view.cols);
98 98  
99 99 // Check bounds
100 100 if(start < 0 || start > maxlen || end < 0 || end > maxlen || start > end)
... ... @@ -143,7 +143,7 @@ LIB3270_EXPORT int lib3270_select_all(H3270 * hSession)
143 143 {
144 144 FAIL_IF_NOT_ONLINE(hSession);
145 145  
146   - do_select(hSession,0,(hSession->rows*hSession->cols)-1,0);
  146 + do_select(hSession,0,(hSession->view.rows * hSession->view.cols)-1,0);
147 147  
148 148 return 0;
149 149 }
... ... @@ -200,28 +200,28 @@ LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to)
200 200 if(!lib3270_get_selection_bounds(hSession,&pos[0],&pos[1]))
201 201 return from;
202 202  
203   - rows = (to / hSession->cols) - (from / hSession->cols);
204   - cols = (to % hSession->cols) - (from % hSession->cols);
  203 + rows = (to / hSession->view.cols) - (from / hSession->view.cols);
  204 + cols = (to % hSession->view.cols) - (from % hSession->view.cols);
205 205  
206 206 for(f=0;f<2;f++)
207 207 {
208   - int row = (pos[f] / hSession->cols) + rows;
209   - int col = (pos[f] % hSession->cols) + cols;
  208 + int row = (pos[f] / hSession->view.cols) + rows;
  209 + int col = (pos[f] % hSession->view.cols) + cols;
210 210  
211 211 if(row < 0)
212   - rows = - (pos[f] / hSession->cols);
  212 + rows = - (pos[f] / hSession->view.cols);
213 213  
214 214 if(col < 0)
215   - cols = - (pos[f] % hSession->cols);
  215 + cols = - (pos[f] % hSession->view.cols);
216 216  
217   - if(row >= ((int) hSession->rows))
218   - rows = hSession->rows - ((pos[f] / hSession->cols)+1);
  217 + if(row >= ((int) hSession->view.rows))
  218 + rows = hSession->view.rows - ((pos[f] / hSession->view.cols)+1);
219 219  
220   - if(col >= ((int) hSession->cols))
221   - cols = hSession->cols - ((pos[f] % hSession->cols)+1);
  220 + if(col >= ((int) hSession->view.cols))
  221 + cols = hSession->view.cols - ((pos[f] % hSession->view.cols)+1);
222 222 }
223 223  
224   - step = (rows * hSession->cols) + cols;
  224 + step = (rows * hSession->view.cols) + cols;
225 225  
226 226 do_select(hSession,hSession->select.start + step,hSession->select.end + step,hSession->rectsel);
227 227 cursor_move(hSession,hSession->select.end);
... ... @@ -251,20 +251,20 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig
251 251 else if((flag&0x8F) == SELECTION_ACTIVE)
252 252 return lib3270_move_selected_area(h,origin,baddr);
253 253  
254   - row = baddr/h->cols;
255   - col = baddr%h->cols;
  254 + row = baddr/h->view.cols;
  255 + col = baddr%h->view.cols;
256 256  
257 257 if(flag & SELECTION_LEFT) // Update left margin
258   - origin = first = ((first/h->cols)*h->cols) + col;
  258 + origin = first = ((first/h->view.cols)*h->view.cols) + col;
259 259  
260 260 if(flag & SELECTION_TOP) // Update top margin
261   - origin = first = (row*h->cols) + (first%h->cols);
  261 + origin = first = (row*h->view.cols) + (first%h->view.cols);
262 262  
263 263 if(flag & SELECTION_RIGHT) // Update right margin
264   - origin = last = ((last/h->cols)*h->cols) + col;
  264 + origin = last = ((last/h->view.cols)*h->view.cols) + col;
265 265  
266 266 if(flag & SELECTION_BOTTOM) // Update bottom margin
267   - origin = last = (row*h->cols) + (last%h->cols);
  267 + origin = last = (row*h->view.cols) + (last%h->view.cols);
268 268  
269 269 trace("origin=%d first=%d last=%d",origin,first,last);
270 270  
... ... @@ -291,28 +291,28 @@ LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir
291 291 switch(dir)
292 292 {
293 293 case LIB3270_DIR_UP:
294   - if(start <= ((int) hSession->cols))
  294 + if(start <= ((int) hSession->view.cols))
295 295 return EINVAL;
296   - start -= hSession->cols;
297   - end -= hSession->cols;
  296 + start -= hSession->view.cols;
  297 + end -= hSession->view.cols;
298 298 break;
299 299  
300 300 case LIB3270_DIR_DOWN:
301   - if(end >= ((int) (hSession->cols * (hSession->rows-1))))
  301 + if(end >= ((int) (hSession->view.cols * (hSession->view.rows-1))))
302 302 return EINVAL;
303   - start += hSession->cols;
304   - end += hSession->cols;
  303 + start += hSession->view.cols;
  304 + end += hSession->view.cols;
305 305 break;
306 306  
307 307 case LIB3270_DIR_LEFT:
308   - if( (start % hSession->cols) < 1)
  308 + if( (start % hSession->view.cols) < 1)
309 309 return EINVAL;
310 310 start--;
311 311 end--;
312 312 break;
313 313  
314 314 case LIB3270_DIR_RIGHT:
315   - if( (end % hSession->cols) >= (hSession->cols-1))
  315 + if( (end % hSession->view.cols) >= (hSession->view.cols-1))
316 316 return EINVAL;
317 317 start++;
318 318 end++;
... ...
src/selection/get.c
... ... @@ -53,7 +53,7 @@ LIB3270_EXPORT char * lib3270_get_selected_text(H3270 *hSession, char tok, LIB32
53 53 {
54 54 int row, col, baddr;
55 55 char * ret;
56   - size_t buflen = (hSession->rows * (hSession->cols+1))+1;
  56 + size_t buflen = (hSession->view.rows * (hSession->view.cols+1))+1;
57 57 size_t sz = 0;
58 58 unsigned short attr = 0xFFFF;
59 59 char cut = (options & LIB3270_SELECTION_CUT) != 0;
... ... @@ -73,11 +73,11 @@ LIB3270_EXPORT char * lib3270_get_selected_text(H3270 *hSession, char tok, LIB32
73 73 baddr = 0;
74 74 unsigned char fa = 0;
75 75  
76   - for(row=0;row < ((int) hSession->rows);row++)
  76 + for(row=0;row < ((int) hSession->view.rows);row++)
77 77 {
78 78 int cr = 0;
79 79  
80   - for(col = 0; col < ((int) hSession->cols);col++)
  80 + for(col = 0; col < ((int) hSession->view.cols);col++)
81 81 {
82 82 if(hSession->ea_buf[baddr].fa) {
83 83 fa = hSession->ea_buf[baddr].fa;
... ...
src/selection/selection.c
... ... @@ -65,10 +65,10 @@ static void update_selected_rectangle(H3270 *session)
65 65 get_selected_addr(session,&begin,&end);
66 66  
67 67 // Get start & end posision
68   - p[0].row = (begin/session->cols);
69   - p[0].col = (begin%session->cols);
70   - p[1].row = (end/session->cols);
71   - p[1].col = (end%session->cols);
  68 + p[0].row = (begin/session->view.cols);
  69 + p[0].col = (begin%session->view.cols);
  70 + p[1].row = (end/session->view.cols);
  71 + p[1].col = (end%session->view.cols);
72 72  
73 73 if(p[0].row > p[1].row)
74 74 {
... ... @@ -86,9 +86,9 @@ static void update_selected_rectangle(H3270 *session)
86 86  
87 87 // First remove unselected areas
88 88 baddr = 0;
89   - for(row=0;row < ((int) session->rows);row++)
  89 + for(row=0;row < ((int) session->view.rows);row++)
90 90 {
91   - for(col = 0; col < ((int) session->cols);col++)
  91 + for(col = 0; col < ((int) session->view.cols);col++)
92 92 {
93 93 if(!(row >= p[0].row && row <= p[1].row && col >= p[0].col && col <= p[1].col) && (session->text[baddr].attr & LIB3270_ATTR_SELECTED))
94 94 {
... ... @@ -101,9 +101,9 @@ static void update_selected_rectangle(H3270 *session)
101 101  
102 102 // Then, draw selected ones
103 103 baddr = 0;
104   - for(row=0;row < ((int) session->rows);row++)
  104 + for(row=0;row < ((int) session->view.rows);row++)
105 105 {
106   - for(col = 0; col < ((int) session->cols);col++)
  106 + for(col = 0; col < ((int) session->view.cols);col++)
107 107 {
108 108 if((row >= p[0].row && row <= p[1].row && col >= p[0].col && col <= p[1].col) && !(session->text[baddr].attr & LIB3270_ATTR_SELECTED))
109 109 {
... ... @@ -119,7 +119,7 @@ static void update_selected_rectangle(H3270 *session)
119 119 static void update_selected_region(H3270 *session)
120 120 {
121 121 int baddr,begin,end;
122   - int len = session->rows*session->cols;
  122 + int len = session->view.rows * session->view.cols;
123 123  
124 124 get_selected_addr(session,&begin,&end);
125 125  
... ... @@ -167,7 +167,7 @@ void toggle_rectselect(H3270 *session, struct lib3270_toggle GNUC_UNUSED(*t), LI
167 167  
168 168 void do_select(H3270 *h, unsigned int start, unsigned int end, unsigned int rect)
169 169 {
170   - if(end > (h->rows * h->cols))
  170 + if(end > (h->view.rows * h->view.cols))
171 171 return;
172 172  
173 173 // Do we really need to change selection?
... ... @@ -209,11 +209,11 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba
209 209 if(!(lib3270_connected(hSession) && (hSession->text[baddr].attr & LIB3270_ATTR_SELECTED)))
210 210 return rc;
211 211  
212   - row = baddr / hSession->cols;
213   - col = baddr % hSession->cols;
  212 + row = baddr / hSession->view.cols;
  213 + col = baddr % hSession->view.cols;
214 214 rc |= SELECTION_ACTIVE;
215 215  
216   - if( (hSession->select.start % hSession->cols) == (hSession->select.end % hSession->cols) )
  216 + if( (hSession->select.start % hSession->view.cols) == (hSession->select.end % hSession->view.cols) )
217 217 {
218 218 rc |= SELECTION_SINGLE_COL;
219 219 }
... ... @@ -224,20 +224,20 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba
224 224  
225 225 /// FIXME: It should test if baddr is the last element before the +1.
226 226  
227   - if( (col == ((int) hSession->cols)) || !(hSession->text[baddr+1].attr & LIB3270_ATTR_SELECTED) )
  227 + if( (col == ((int) hSession->view.cols)) || !(hSession->text[baddr+1].attr & LIB3270_ATTR_SELECTED) )
228 228 rc |= SELECTION_RIGHT;
229 229 }
230 230  
231   - if( (hSession->select.start / hSession->cols) == (hSession->select.end / hSession->cols) )
  231 + if( (hSession->select.start / hSession->view.cols) == (hSession->select.end / hSession->view.cols) )
232 232 {
233 233 rc |= SELECTION_SINGLE_ROW;
234 234 }
235 235 else
236 236 {
237   - if( (row == 0) || !(hSession->text[baddr-hSession->cols].attr & LIB3270_ATTR_SELECTED) )
  237 + if( (row == 0) || !(hSession->text[baddr-hSession->view.cols].attr & LIB3270_ATTR_SELECTED) )
238 238 rc |= SELECTION_TOP;
239 239  
240   - if( (row == ((int) hSession->rows)) || !(hSession->text[baddr+hSession->cols].attr & LIB3270_ATTR_SELECTED) )
  240 + if( (row == ((int) hSession->view.rows)) || !(hSession->text[baddr+hSession->view.cols].attr & LIB3270_ATTR_SELECTED) )
241 241 rc |= SELECTION_BOTTOM;
242 242 }
243 243  
... ... @@ -254,7 +254,7 @@ LIB3270_EXPORT char * lib3270_get_region(H3270 *h, int start_pos, int end_pos, u
254 254 if(check_online_session(h))
255 255 return NULL;
256 256  
257   - maxlen = h->rows * (h->cols+1);
  257 + maxlen = h->view.rows * (h->view.cols+1);
258 258  
259 259 if(start_pos < 0 || start_pos > maxlen || end_pos < 0 || end_pos > maxlen || end_pos < start_pos)
260 260 return NULL;
... ... @@ -266,7 +266,7 @@ LIB3270_EXPORT char * lib3270_get_region(H3270 *h, int start_pos, int end_pos, u
266 266 if(all || h->text[baddr].attr & LIB3270_ATTR_SELECTED)
267 267 text[sz++] = (h->text[baddr].attr & LIB3270_ATTR_CG) ? ' ' : h->text[baddr].chr;
268 268  
269   - if((baddr%h->cols) == 0 && sz > 0)
  269 + if((baddr%h->view.cols) == 0 && sz > 0)
270 270 text[sz++] = '\n';
271 271 }
272 272 text[sz++] = 0;
... ... @@ -291,7 +291,7 @@ LIB3270_EXPORT char * lib3270_get_string_at_address(H3270 *h, int offset, int le
291 291 if(offset < 0)
292 292 offset = lib3270_get_cursor_address(h);
293 293  
294   - maxlen = (h->rows * (h->cols+ (lf ? 1 : 0) )) - offset;
  294 + maxlen = (h->view.rows * (h->view.cols+ (lf ? 1 : 0) )) - offset;
295 295 if(maxlen <= 0 || offset < 0)
296 296 {
297 297 errno = EOVERFLOW;
... ... @@ -321,7 +321,7 @@ LIB3270_EXPORT char * lib3270_get_string_at_address(H3270 *h, int offset, int le
321 321 offset++;
322 322 len--;
323 323  
324   - if(lf && (offset%h->cols) == 0 && len > 0)
  324 + if(lf && (offset%h->view.cols) == 0 && len > 0)
325 325 {
326 326 *(ptr++) = lf;
327 327 len--;
... ... @@ -408,16 +408,16 @@ LIB3270_EXPORT int lib3270_get_selection_rectangle(H3270 *hSession, unsigned int
408 408 if(!hSession->selected || hSession->select.start == hSession->select.end)
409 409 return errno = ENOENT;
410 410  
411   - minRow = hSession->rows;
412   - minCol = hSession->cols;
  411 + minRow = hSession->view.rows;
  412 + minCol = hSession->view.cols;
413 413 maxRow = 0;
414 414 maxCol = 0;
415 415 baddr = 0;
416 416 count = 0;
417 417  
418   - for(r=0;r < hSession->rows;r++)
  418 + for(r=0;r < hSession->view.rows;r++)
419 419 {
420   - for(c = 0; c < hSession->cols;c++)
  420 + for(c = 0; c < hSession->view.cols;c++)
421 421 {
422 422 if(hSession->text[baddr].attr & LIB3270_ATTR_SELECTED)
423 423 {
... ...