Commit 45c502d8fd102b9c943d2a52e4cb9fcb5424be92
1 parent
1704e934
Exists in
master
and in
5 other branches
Migrando funções ANSI para multi-sessão
Showing
6 changed files
with
335 additions
and
273 deletions
Show diff stats
src/include/lib3270/session.h
@@ -264,6 +264,34 @@ | @@ -264,6 +264,34 @@ | ||
264 | int end; | 264 | int end; |
265 | } select; | 265 | } select; |
266 | 266 | ||
267 | + // ansi.c | ||
268 | + int scroll_top; | ||
269 | + int scroll_bottom; | ||
270 | + int once_cset; | ||
271 | + int saved_cursor; | ||
272 | + | ||
273 | + int held_wrap : 1; | ||
274 | + | ||
275 | + int insert_mode : 1; | ||
276 | + int auto_newline_mode : 1; | ||
277 | + | ||
278 | + int appl_cursor : 1; | ||
279 | + int saved_appl_cursor : 1; | ||
280 | + | ||
281 | + int wraparound_mode : 1; | ||
282 | + int saved_wraparound_mode : 1; | ||
283 | + | ||
284 | + int rev_wraparound_mode : 1; | ||
285 | + int saved_rev_wraparound_mode : 1; | ||
286 | + | ||
287 | + int allow_wide_mode : 1; | ||
288 | + int saved_allow_wide_mode : 1; | ||
289 | + | ||
290 | + int wide_mode : 1; | ||
291 | + int saved_wide_mode : 1; | ||
292 | + | ||
293 | + int saved_altbuffer : 1; | ||
294 | + | ||
267 | // xio | 295 | // xio |
268 | void * ns_read_id; | 296 | void * ns_read_id; |
269 | void * ns_exception_id; | 297 | void * ns_exception_id; |
src/lib3270/ansi.c
@@ -184,7 +184,8 @@ static enum state ansi_one_g3(H3270 *, int, int); | @@ -184,7 +184,8 @@ static enum state ansi_one_g3(H3270 *, int, int); | ||
184 | static enum state ansi_multibyte(H3270 *, int, int); | 184 | static enum state ansi_multibyte(H3270 *, int, int); |
185 | 185 | ||
186 | typedef enum state (*afn_t)(H3270 *, int, int); | 186 | typedef enum state (*afn_t)(H3270 *, int, int); |
187 | -static afn_t ansi_fn[] = { | 187 | + |
188 | +static const afn_t ansi_fn[] = { | ||
188 | /* 0 */ &ansi_data_mode, | 189 | /* 0 */ &ansi_data_mode, |
189 | /* 1 */ &dec_save_cursor, | 190 | /* 1 */ &dec_save_cursor, |
190 | /* 2 */ &dec_restore_cursor, | 191 | /* 2 */ &dec_restore_cursor, |
@@ -243,7 +244,7 @@ static afn_t ansi_fn[] = { | @@ -243,7 +244,7 @@ static afn_t ansi_fn[] = { | ||
243 | /* 55 */ &ansi_multibyte, | 244 | /* 55 */ &ansi_multibyte, |
244 | }; | 245 | }; |
245 | 246 | ||
246 | -static unsigned char st[8][256] = { | 247 | +static const unsigned char st[8][256] = { |
247 | /* | 248 | /* |
248 | * State table for base processing (state == DATA) | 249 | * State table for base processing (state == DATA) |
249 | */ | 250 | */ |
@@ -439,7 +440,7 @@ static unsigned char st[8][256] = { | @@ -439,7 +440,7 @@ static unsigned char st[8][256] = { | ||
439 | #define CSD_UK 1 | 440 | #define CSD_UK 1 |
440 | #define CSD_US 2 | 441 | #define CSD_US 2 |
441 | 442 | ||
442 | -static int saved_cursor = 0; | 443 | +// static int saved_cursor = 0; |
443 | #define NN 20 | 444 | #define NN 20 |
444 | static int n[NN], nx = 0; | 445 | static int n[NN], nx = 0; |
445 | #define NT 256 | 446 | #define NT 256 |
@@ -456,25 +457,27 @@ static int cset = CS_G0; | @@ -456,25 +457,27 @@ static int cset = CS_G0; | ||
456 | static int saved_cset = CS_G0; | 457 | static int saved_cset = CS_G0; |
457 | static int csd[4] = { CSD_US, CSD_US, CSD_US, CSD_US }; | 458 | static int csd[4] = { CSD_US, CSD_US, CSD_US, CSD_US }; |
458 | static int saved_csd[4] = { CSD_US, CSD_US, CSD_US, CSD_US }; | 459 | static int saved_csd[4] = { CSD_US, CSD_US, CSD_US, CSD_US }; |
459 | -static int once_cset = -1; | ||
460 | -static int insert_mode = 0; | ||
461 | -static int auto_newline_mode = 0; | ||
462 | -static int appl_cursor = 0; | ||
463 | -static int saved_appl_cursor = 0; | ||
464 | -static int wraparound_mode = 1; | ||
465 | -static int saved_wraparound_mode = 1; | ||
466 | -static int rev_wraparound_mode = 0; | ||
467 | -static int saved_rev_wraparound_mode = 0; | ||
468 | -static int allow_wide_mode = 0; | ||
469 | -static int saved_allow_wide_mode = 0; | ||
470 | -static int wide_mode = 0; | ||
471 | -static int saved_wide_mode = 0; | ||
472 | -static Boolean saved_altbuffer = False; | ||
473 | -static int scroll_top = -1; | ||
474 | -static int scroll_bottom = -1; | 460 | +// static int once_cset = -1; |
461 | +// static int insert_mode = 0; | ||
462 | +// static int auto_newline_mode = 0; | ||
463 | +// static int appl_cursor = 0; | ||
464 | +// static int saved_appl_cursor = 0; | ||
465 | +//static int wraparound_mode = 1; | ||
466 | +// static int saved_wraparound_mode = 1; | ||
467 | +// static int rev_wraparound_mode = 0; | ||
468 | +// static int saved_rev_wraparound_mode = 0; | ||
469 | +// static int allow_wide_mode = 0; | ||
470 | +// static int saved_allow_wide_mode = 0; | ||
471 | +// static int wide_mode = 0; | ||
472 | +// static int saved_wide_mode = 0; | ||
473 | +// static Boolean saved_altbuffer = False; | ||
474 | +// static int scroll_top = -1; | ||
475 | +// static int scroll_bottom = -1; | ||
475 | static unsigned char *tabs = (unsigned char *) NULL; | 476 | static unsigned char *tabs = (unsigned char *) NULL; |
476 | -static char gnnames[] = "()*+"; | ||
477 | -static char csnames[] = "0AB"; | 477 | + |
478 | +static const char gnnames[] = "()*+"; | ||
479 | +static const char csnames[] = "0AB"; | ||
480 | + | ||
478 | static int cs_to_change; | 481 | static int cs_to_change; |
479 | #if defined(X3270_DBCS) /*[*/ | 482 | #if defined(X3270_DBCS) /*[*/ |
480 | static unsigned char mb_pending = 0; | 483 | static unsigned char mb_pending = 0; |
@@ -484,9 +487,9 @@ static int dbcs_process(int ch, unsigned char ebc[]); | @@ -484,9 +487,9 @@ static int dbcs_process(int ch, unsigned char ebc[]); | ||
484 | static int pmi = 0; | 487 | static int pmi = 0; |
485 | static char pending_mbs[MB_MAX]; | 488 | static char pending_mbs[MB_MAX]; |
486 | 489 | ||
487 | -static Boolean held_wrap = False; | 490 | +// static Boolean held_wrap = False; |
488 | 491 | ||
489 | -static void ansi_scroll(void); | 492 | +static void ansi_scroll(H3270 *hSession); |
490 | 493 | ||
491 | static enum state | 494 | static enum state |
492 | ansi_data_mode(H3270 *hSession, int ig1 unused, int ig2 unused) | 495 | ansi_data_mode(H3270 *hSession, int ig1 unused, int ig2 unused) |
@@ -499,7 +502,7 @@ dec_save_cursor(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -499,7 +502,7 @@ dec_save_cursor(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
499 | { | 502 | { |
500 | int i; | 503 | int i; |
501 | 504 | ||
502 | - saved_cursor = h3270.cursor_addr; | 505 | + hSession->saved_cursor = hSession->cursor_addr; |
503 | saved_cset = cset; | 506 | saved_cset = cset; |
504 | for (i = 0; i < 4; i++) | 507 | for (i = 0; i < 4; i++) |
505 | saved_csd[i] = csd[i]; | 508 | saved_csd[i] = csd[i]; |
@@ -509,8 +512,7 @@ dec_save_cursor(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -509,8 +512,7 @@ dec_save_cursor(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
509 | return DATA; | 512 | return DATA; |
510 | } | 513 | } |
511 | 514 | ||
512 | -static enum state | ||
513 | -dec_restore_cursor(H3270 *hSession, int ig1 unused, int ig2 unused) | 515 | +static enum state dec_restore_cursor(H3270 *hSession, int ig1 unused, int ig2 unused) |
514 | { | 516 | { |
515 | int i; | 517 | int i; |
516 | 518 | ||
@@ -520,23 +522,24 @@ dec_restore_cursor(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -520,23 +522,24 @@ dec_restore_cursor(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
520 | fg = saved_fg; | 522 | fg = saved_fg; |
521 | bg = saved_bg; | 523 | bg = saved_bg; |
522 | gr = saved_gr; | 524 | gr = saved_gr; |
523 | - cursor_move(&h3270,saved_cursor); | ||
524 | - held_wrap = False; | 525 | + cursor_move(hSession,hSession->saved_cursor); |
526 | + hSession->held_wrap = 0; | ||
525 | return DATA; | 527 | return DATA; |
526 | } | 528 | } |
527 | 529 | ||
528 | -static enum state | ||
529 | -ansi_newline(H3270 *hSession, int ig1 unused, int ig2 unused) | 530 | +static enum state ansi_newline(H3270 *hSession, int ig1 unused, int ig2 unused) |
530 | { | 531 | { |
531 | int nc; | 532 | int nc; |
532 | 533 | ||
533 | - cursor_move(&h3270,h3270.cursor_addr - (h3270.cursor_addr % h3270.cols)); | ||
534 | - nc = h3270.cursor_addr + h3270.cols; | ||
535 | - if (nc < scroll_bottom * h3270.cols) | ||
536 | - cursor_move(&h3270,nc); | 534 | + cursor_move(hSession,hSession->cursor_addr - (hSession->cursor_addr % hSession->cols)); |
535 | + nc = hSession->cursor_addr + hSession->cols; | ||
536 | + | ||
537 | + if (nc < hSession->scroll_bottom * hSession->cols) | ||
538 | + cursor_move(hSession,nc); | ||
537 | else | 539 | else |
538 | - ansi_scroll(); | ||
539 | - held_wrap = False; | 540 | + ansi_scroll(hSession); |
541 | + | ||
542 | + hSession->held_wrap = 0; | ||
540 | return DATA; | 543 | return DATA; |
541 | } | 544 | } |
542 | 545 | ||
@@ -552,7 +555,7 @@ ansi_cursor_up(H3270 *hSession, int nn, int ig2 unused) | @@ -552,7 +555,7 @@ ansi_cursor_up(H3270 *hSession, int nn, int ig2 unused) | ||
552 | cursor_move(&h3270, h3270.cursor_addr % h3270.cols); | 555 | cursor_move(&h3270, h3270.cursor_addr % h3270.cols); |
553 | else | 556 | else |
554 | cursor_move(&h3270, h3270.cursor_addr - (nn * h3270.cols)); | 557 | cursor_move(&h3270, h3270.cursor_addr - (nn * h3270.cols)); |
555 | - held_wrap = False; | 558 | + hSession->held_wrap = 0; |
556 | return DATA; | 559 | return DATA; |
557 | } | 560 | } |
558 | 561 | ||
@@ -583,27 +586,30 @@ ansi_reset(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -583,27 +586,30 @@ ansi_reset(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
583 | saved_cset = CS_G0; | 586 | saved_cset = CS_G0; |
584 | csd[0] = csd[1] = csd[2] = csd[3] = CSD_US; | 587 | csd[0] = csd[1] = csd[2] = csd[3] = CSD_US; |
585 | saved_csd[0] = saved_csd[1] = saved_csd[2] = saved_csd[3] = CSD_US; | 588 | saved_csd[0] = saved_csd[1] = saved_csd[2] = saved_csd[3] = CSD_US; |
586 | - once_cset = -1; | ||
587 | - saved_cursor = 0; | ||
588 | - insert_mode = 0; | ||
589 | - auto_newline_mode = 0; | ||
590 | - appl_cursor = 0; | ||
591 | - saved_appl_cursor = 0; | ||
592 | - wraparound_mode = 1; | ||
593 | - saved_wraparound_mode = 1; | ||
594 | - rev_wraparound_mode = 0; | ||
595 | - saved_rev_wraparound_mode = 0; | ||
596 | - allow_wide_mode = 0; | ||
597 | - saved_allow_wide_mode = 0; | ||
598 | - wide_mode = 0; | ||
599 | - allow_wide_mode = 0; | ||
600 | - saved_altbuffer = False; | ||
601 | - scroll_top = 1; | ||
602 | - scroll_bottom = h3270.rows; | 589 | + hSession->once_cset = -1; |
590 | + hSession->saved_cursor = 0; | ||
591 | + hSession->insert_mode = 0; | ||
592 | + hSession->auto_newline_mode = 0; | ||
593 | + hSession->appl_cursor = 0; | ||
594 | + hSession->saved_appl_cursor = 0; | ||
595 | + hSession->wraparound_mode = 1; | ||
596 | + hSession->saved_wraparound_mode = 1; | ||
597 | + hSession->rev_wraparound_mode = 0; | ||
598 | + hSession->saved_rev_wraparound_mode = 0; | ||
599 | + hSession->allow_wide_mode = 0; | ||
600 | +// allow_wide_mode = 0; | ||
601 | + | ||
602 | + hSession->saved_allow_wide_mode = 0; | ||
603 | + hSession->wide_mode = 0; | ||
604 | + hSession->saved_altbuffer = 0; | ||
605 | + | ||
606 | + hSession->scroll_top = 1; | ||
607 | + hSession->scroll_bottom = hSession->rows; | ||
608 | + | ||
603 | Replace(tabs, (unsigned char *)lib3270_malloc((h3270.cols+7)/8)); | 609 | Replace(tabs, (unsigned char *)lib3270_malloc((h3270.cols+7)/8)); |
604 | for (i = 0; i < (h3270.cols+7)/8; i++) | 610 | for (i = 0; i < (h3270.cols+7)/8; i++) |
605 | tabs[i] = 0x01; | 611 | tabs[i] = 0x01; |
606 | - held_wrap = False; | 612 | + hSession->held_wrap = 0; |
607 | if (!first) { | 613 | if (!first) { |
608 | ctlr_altbuffer(&h3270,True); | 614 | ctlr_altbuffer(&h3270,True); |
609 | ctlr_aclear(&h3270, 0, h3270.rows * h3270.cols, 1); | 615 | ctlr_aclear(&h3270, 0, h3270.rows * h3270.cols, 1); |
@@ -650,7 +656,7 @@ ansi_cursor_down(H3270 *hSession, int nn, int ig2 unused) | @@ -650,7 +656,7 @@ ansi_cursor_down(H3270 *hSession, int nn, int ig2 unused) | ||
650 | cursor_move(&h3270,(h3270.cols-1)*h3270.cols + (h3270.cursor_addr%h3270.cols)); | 656 | cursor_move(&h3270,(h3270.cols-1)*h3270.cols + (h3270.cursor_addr%h3270.cols)); |
651 | else | 657 | else |
652 | cursor_move(&h3270,h3270.cursor_addr + (nn * h3270.cols)); | 658 | cursor_move(&h3270,h3270.cursor_addr + (nn * h3270.cols)); |
653 | - held_wrap = False; | 659 | + hSession->held_wrap = 0; |
654 | return DATA; | 660 | return DATA; |
655 | } | 661 | } |
656 | 662 | ||
@@ -667,7 +673,7 @@ ansi_cursor_right(H3270 *hSession, int nn, int ig2 unused) | @@ -667,7 +673,7 @@ ansi_cursor_right(H3270 *hSession, int nn, int ig2 unused) | ||
667 | if (cc + nn >= h3270.cols) | 673 | if (cc + nn >= h3270.cols) |
668 | nn = h3270.cols - 1 - cc; | 674 | nn = h3270.cols - 1 - cc; |
669 | cursor_move(&h3270,h3270.cursor_addr + nn); | 675 | cursor_move(&h3270,h3270.cursor_addr + nn); |
670 | - held_wrap = False; | 676 | + hSession->held_wrap = 0; |
671 | return DATA; | 677 | return DATA; |
672 | } | 678 | } |
673 | 679 | ||
@@ -676,18 +682,19 @@ ansi_cursor_left(H3270 *hSession, int nn, int ig2 unused) | @@ -676,18 +682,19 @@ ansi_cursor_left(H3270 *hSession, int nn, int ig2 unused) | ||
676 | { | 682 | { |
677 | int cc; | 683 | int cc; |
678 | 684 | ||
679 | - if (held_wrap) { | ||
680 | - held_wrap = False; | 685 | + if (hSession->held_wrap) |
686 | + { | ||
687 | + hSession->held_wrap = 0; | ||
681 | return DATA; | 688 | return DATA; |
682 | } | 689 | } |
683 | if (nn < 1) | 690 | if (nn < 1) |
684 | nn = 1; | 691 | nn = 1; |
685 | - cc = h3270.cursor_addr % h3270.cols; | 692 | + cc = hSession->cursor_addr % hSession->cols; |
686 | if (!cc) | 693 | if (!cc) |
687 | return DATA; | 694 | return DATA; |
688 | if (nn > cc) | 695 | if (nn > cc) |
689 | nn = cc; | 696 | nn = cc; |
690 | - cursor_move(&h3270,h3270.cursor_addr - nn); | 697 | + cursor_move(hSession,hSession->cursor_addr - nn); |
691 | return DATA; | 698 | return DATA; |
692 | } | 699 | } |
693 | 700 | ||
@@ -695,11 +702,11 @@ static enum state | @@ -695,11 +702,11 @@ static enum state | ||
695 | ansi_cursor_motion(H3270 *hSession, int n1, int n2) | 702 | ansi_cursor_motion(H3270 *hSession, int n1, int n2) |
696 | { | 703 | { |
697 | if (n1 < 1) n1 = 1; | 704 | if (n1 < 1) n1 = 1; |
698 | - if (n1 > h3270.rows) n1 = h3270.rows; | 705 | + if (n1 > hSession->rows) n1 = hSession->rows; |
699 | if (n2 < 1) n2 = 1; | 706 | if (n2 < 1) n2 = 1; |
700 | - if (n2 > h3270.cols) n2 = h3270.cols; | ||
701 | - cursor_move(&h3270,(n1 - 1) * h3270.cols + (n2 - 1)); | ||
702 | - held_wrap = False; | 707 | + if (n2 > hSession->cols) n2 = hSession->cols; |
708 | + cursor_move(hSession,(n1 - 1) * hSession->cols + (n2 - 1)); | ||
709 | + hSession->held_wrap = 0; | ||
703 | return DATA; | 710 | return DATA; |
704 | } | 711 | } |
705 | 712 | ||
@@ -744,11 +751,11 @@ static enum state | @@ -744,11 +751,11 @@ static enum state | ||
744 | ansi_insert_lines(H3270 *hSession, int nn, int ig2 unused) | 751 | ansi_insert_lines(H3270 *hSession, int nn, int ig2 unused) |
745 | { | 752 | { |
746 | int rr = h3270.cursor_addr / h3270.cols; /* current row */ | 753 | int rr = h3270.cursor_addr / h3270.cols; /* current row */ |
747 | - int mr = scroll_bottom - rr; /* rows left at and below this one */ | ||
748 | - int ns; /* rows that are shifting */ | 754 | + int mr = hSession->scroll_bottom - rr; /* rows left at and below this one */ |
755 | + int ns; /* rows that are shifting */ | ||
749 | 756 | ||
750 | /* If outside of the scrolling region, do nothing */ | 757 | /* If outside of the scrolling region, do nothing */ |
751 | - if (rr < scroll_top - 1 || rr >= scroll_bottom) | 758 | + if (rr < hSession->scroll_top - 1 || rr >= hSession->scroll_bottom) |
752 | return DATA; | 759 | return DATA; |
753 | 760 | ||
754 | if (nn < 1) | 761 | if (nn < 1) |
@@ -769,12 +776,12 @@ ansi_insert_lines(H3270 *hSession, int nn, int ig2 unused) | @@ -769,12 +776,12 @@ ansi_insert_lines(H3270 *hSession, int nn, int ig2 unused) | ||
769 | static enum state | 776 | static enum state |
770 | ansi_delete_lines(H3270 *hSession, int nn, int ig2 unused) | 777 | ansi_delete_lines(H3270 *hSession, int nn, int ig2 unused) |
771 | { | 778 | { |
772 | - int rr = h3270.cursor_addr / h3270.cols; /* current row */ | ||
773 | - int mr = scroll_bottom - rr; /* max rows that can be deleted */ | ||
774 | - int ns; /* rows that are shifting */ | 779 | + int rr = hSession->cursor_addr / hSession->cols; /* current row */ |
780 | + int mr = hSession->scroll_bottom - rr; /* max rows that can be deleted */ | ||
781 | + int ns; /* rows that are shifting */ | ||
775 | 782 | ||
776 | /* If outside of the scrolling region, do nothing */ | 783 | /* If outside of the scrolling region, do nothing */ |
777 | - if (rr < scroll_top - 1 || rr >= scroll_bottom) | 784 | + if (rr < hSession->scroll_top - 1 || rr >= hSession->scroll_bottom) |
778 | return DATA; | 785 | return DATA; |
779 | 786 | ||
780 | if (nn < 1) | 787 | if (nn < 1) |
@@ -785,19 +792,19 @@ ansi_delete_lines(H3270 *hSession, int nn, int ig2 unused) | @@ -785,19 +792,19 @@ ansi_delete_lines(H3270 *hSession, int nn, int ig2 unused) | ||
785 | /* Move the surviving rows up */ | 792 | /* Move the surviving rows up */ |
786 | ns = mr - nn; | 793 | ns = mr - nn; |
787 | if (ns) | 794 | if (ns) |
788 | - ctlr_bcopy((rr + nn) * h3270.cols, rr * h3270.cols, ns * h3270.cols, 1); | 795 | + ctlr_bcopy((rr + nn) * hSession->cols, rr * hSession->cols, ns * hSession->cols, 1); |
789 | 796 | ||
790 | /* Clear the rest of the screen */ | 797 | /* Clear the rest of the screen */ |
791 | - ctlr_aclear(&h3270, (rr + ns) * h3270.cols, nn * h3270.cols, 1); | 798 | + ctlr_aclear(hSession, (rr + ns) * hSession->cols, nn * hSession->cols, 1); |
792 | return DATA; | 799 | return DATA; |
793 | } | 800 | } |
794 | 801 | ||
795 | static enum state | 802 | static enum state |
796 | ansi_delete_chars(H3270 *hSession, int nn, int ig2 unused) | 803 | ansi_delete_chars(H3270 *hSession, int nn, int ig2 unused) |
797 | { | 804 | { |
798 | - int cc = h3270.cursor_addr % h3270.cols; /* current col */ | ||
799 | - int mc = h3270.cols - cc; /* max chars that can be deleted */ | ||
800 | - int ns; /* chars that are shifting */ | 805 | + int cc = hSession->cursor_addr % hSession->cols; /* current col */ |
806 | + int mc = hSession->cols - cc; /* max chars that can be deleted */ | ||
807 | + int ns; /* chars that are shifting */ | ||
801 | 808 | ||
802 | if (nn < 1) | 809 | if (nn < 1) |
803 | nn = 1; | 810 | nn = 1; |
@@ -807,10 +814,10 @@ ansi_delete_chars(H3270 *hSession, int nn, int ig2 unused) | @@ -807,10 +814,10 @@ ansi_delete_chars(H3270 *hSession, int nn, int ig2 unused) | ||
807 | /* Move the surviving chars left */ | 814 | /* Move the surviving chars left */ |
808 | ns = mc - nn; | 815 | ns = mc - nn; |
809 | if (ns) | 816 | if (ns) |
810 | - ctlr_bcopy(h3270.cursor_addr + nn, h3270.cursor_addr, ns, 1); | 817 | + ctlr_bcopy(hSession->cursor_addr + nn, hSession->cursor_addr, ns, 1); |
811 | 818 | ||
812 | /* Clear the end of the line */ | 819 | /* Clear the end of the line */ |
813 | - ctlr_aclear(&h3270, h3270.cursor_addr + ns, nn, 1); | 820 | + ctlr_aclear(hSession, hSession->cursor_addr + ns, nn, 1); |
814 | return DATA; | 821 | return DATA; |
815 | } | 822 | } |
816 | 823 | ||
@@ -920,26 +927,29 @@ ansi_bell(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -920,26 +927,29 @@ ansi_bell(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
920 | return DATA; | 927 | return DATA; |
921 | } | 928 | } |
922 | 929 | ||
923 | -static enum state | ||
924 | -ansi_newpage(H3270 *hSession, int ig1 unused, int ig2 unused) | 930 | +static enum state ansi_newpage(H3270 *hSession, int ig1 unused, int ig2 unused) |
925 | { | 931 | { |
926 | ctlr_clear(&h3270,False); | 932 | ctlr_clear(&h3270,False); |
927 | return DATA; | 933 | return DATA; |
928 | } | 934 | } |
929 | 935 | ||
930 | -static enum state | ||
931 | -ansi_backspace(H3270 *hSession, int ig1 unused, int ig2 unused) | 936 | +static enum state ansi_backspace(H3270 *hSession, int ig1 unused, int ig2 unused) |
932 | { | 937 | { |
933 | - if (held_wrap) { | ||
934 | - held_wrap = False; | 938 | + if (hSession->held_wrap) |
939 | + { | ||
940 | + hSession->held_wrap = 0; | ||
935 | return DATA; | 941 | return DATA; |
936 | } | 942 | } |
937 | - if (rev_wraparound_mode) { | ||
938 | - if (h3270.cursor_addr > (scroll_top - 1) * h3270.cols) | ||
939 | - cursor_move(&h3270,h3270.cursor_addr - 1); | ||
940 | - } else { | ||
941 | - if (h3270.cursor_addr % h3270.cols) | ||
942 | - cursor_move(&h3270,h3270.cursor_addr - 1); | 943 | + |
944 | + if (hSession->rev_wraparound_mode) | ||
945 | + { | ||
946 | + if (hSession->cursor_addr > (hSession->scroll_top - 1) * hSession->cols) | ||
947 | + cursor_move(hSession,hSession->cursor_addr - 1); | ||
948 | + } | ||
949 | + else | ||
950 | + { | ||
951 | + if (hSession->cursor_addr % hSession->cols) | ||
952 | + cursor_move(hSession,hSession->cursor_addr - 1); | ||
943 | } | 953 | } |
944 | return DATA; | 954 | return DATA; |
945 | } | 955 | } |
@@ -947,48 +957,51 @@ ansi_backspace(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -947,48 +957,51 @@ ansi_backspace(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
947 | static enum state | 957 | static enum state |
948 | ansi_cr(H3270 *hSession, int ig1 unused, int ig2 unused) | 958 | ansi_cr(H3270 *hSession, int ig1 unused, int ig2 unused) |
949 | { | 959 | { |
950 | - if (h3270.cursor_addr % h3270.cols) | ||
951 | - cursor_move(&h3270,h3270.cursor_addr - (h3270.cursor_addr % h3270.cols)); | ||
952 | - if (auto_newline_mode) | 960 | + if (hSession->cursor_addr % hSession->cols) |
961 | + cursor_move(hSession,hSession->cursor_addr - (hSession->cursor_addr % hSession->cols)); | ||
962 | + | ||
963 | + if (hSession->auto_newline_mode) | ||
953 | (void) ansi_lf(hSession, 0, 0); | 964 | (void) ansi_lf(hSession, 0, 0); |
954 | - held_wrap = False; | 965 | + |
966 | + hSession->held_wrap = 0; | ||
955 | return DATA; | 967 | return DATA; |
956 | } | 968 | } |
957 | 969 | ||
958 | static enum state | 970 | static enum state |
959 | ansi_lf(H3270 *hSession, int ig1 unused, int ig2 unused) | 971 | ansi_lf(H3270 *hSession, int ig1 unused, int ig2 unused) |
960 | { | 972 | { |
961 | - int nc = h3270.cursor_addr + h3270.cols; | 973 | + int nc = hSession->cursor_addr + hSession->cols; |
962 | 974 | ||
963 | - held_wrap = False; | 975 | + hSession->held_wrap = 0; |
964 | 976 | ||
965 | /* If we're below the scrolling region, don't scroll. */ | 977 | /* If we're below the scrolling region, don't scroll. */ |
966 | - if ((h3270.cursor_addr / h3270.cols) >= scroll_bottom) { | ||
967 | - if (nc < h3270.rows * h3270.cols) | ||
968 | - cursor_move(&h3270,nc); | 978 | + if((hSession->cursor_addr / hSession->cols) >= hSession->scroll_bottom) |
979 | + { | ||
980 | + if (nc < hSession->rows * hSession->cols) | ||
981 | + cursor_move(hSession,nc); | ||
969 | return DATA; | 982 | return DATA; |
970 | } | 983 | } |
971 | 984 | ||
972 | - if (nc < scroll_bottom * h3270.cols) | ||
973 | - cursor_move(&h3270,nc); | 985 | + if (nc < hSession->scroll_bottom * hSession->cols) |
986 | + cursor_move(hSession,nc); | ||
974 | else | 987 | else |
975 | - ansi_scroll(); | 988 | + ansi_scroll(hSession); |
976 | return DATA; | 989 | return DATA; |
977 | } | 990 | } |
978 | 991 | ||
979 | static enum state | 992 | static enum state |
980 | ansi_htab(H3270 *hSession, int ig1 unused, int ig2 unused) | 993 | ansi_htab(H3270 *hSession, int ig1 unused, int ig2 unused) |
981 | { | 994 | { |
982 | - int col = h3270.cursor_addr % h3270.cols; | 995 | + int col = hSession->cursor_addr % hSession->cols; |
983 | int i; | 996 | int i; |
984 | 997 | ||
985 | - held_wrap = False; | ||
986 | - if (col == h3270.cols-1) | 998 | + hSession->held_wrap = 0; |
999 | + if (col == hSession->cols-1) | ||
987 | return DATA; | 1000 | return DATA; |
988 | - for (i = col+1; i < h3270.cols-1; i++) | 1001 | + for (i = col+1; i < hSession->cols-1; i++) |
989 | if (tabs[i/8] & 1<<(i%8)) | 1002 | if (tabs[i/8] & 1<<(i%8)) |
990 | break; | 1003 | break; |
991 | - cursor_move(&h3270,h3270.cursor_addr - col + i); | 1004 | + cursor_move(hSession,hSession->cursor_addr - col + i); |
992 | return DATA; | 1005 | return DATA; |
993 | } | 1006 | } |
994 | 1007 | ||
@@ -1006,13 +1019,13 @@ ansi_nop(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1006,13 +1019,13 @@ ansi_nop(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1006 | 1019 | ||
1007 | #define PWRAP { \ | 1020 | #define PWRAP { \ |
1008 | nc = h3270.cursor_addr + 1; \ | 1021 | nc = h3270.cursor_addr + 1; \ |
1009 | - if (nc < scroll_bottom * h3270.cols) \ | 1022 | + if (nc < h3270.scroll_bottom * h3270.cols) \ |
1010 | cursor_move(&h3270,nc); \ | 1023 | cursor_move(&h3270,nc); \ |
1011 | else { \ | 1024 | else { \ |
1012 | - if (h3270.cursor_addr / h3270.cols >= scroll_bottom) \ | 1025 | + if (h3270.cursor_addr / h3270.cols >= h3270.scroll_bottom) \ |
1013 | cursor_move(&h3270,h3270.cursor_addr / h3270.cols * h3270.cols); \ | 1026 | cursor_move(&h3270,h3270.cursor_addr / h3270.cols * h3270.cols); \ |
1014 | else { \ | 1027 | else { \ |
1015 | - ansi_scroll(); \ | 1028 | + ansi_scroll(&h3270); \ |
1016 | cursor_move(&h3270,nc - h3270.cols); \ | 1029 | cursor_move(&h3270,nc - h3270.cols); \ |
1017 | } \ | 1030 | } \ |
1018 | } \ | 1031 | } \ |
@@ -1059,14 +1072,16 @@ ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1059,14 +1072,16 @@ ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1059 | } | 1072 | } |
1060 | pmi = 0; | 1073 | pmi = 0; |
1061 | 1074 | ||
1062 | - if (held_wrap) { | 1075 | + if (hSession->held_wrap) |
1076 | + { | ||
1063 | PWRAP; | 1077 | PWRAP; |
1064 | - held_wrap = False; | 1078 | + hSession->held_wrap = 0; |
1065 | } | 1079 | } |
1066 | 1080 | ||
1067 | - if (insert_mode) | 1081 | + if (hSession->insert_mode) |
1068 | (void) ansi_insert_chars(hSession,1, 0); | 1082 | (void) ansi_insert_chars(hSession,1, 0); |
1069 | - switch (csd[(once_cset != -1) ? once_cset : cset]) { | 1083 | + |
1084 | + switch (csd[(hSession->once_cset != -1) ? hSession->once_cset : cset]) { | ||
1070 | case CSD_LD: /* line drawing "0" */ | 1085 | case CSD_LD: /* line drawing "0" */ |
1071 | if (ansi_ch >= 0x5f && ansi_ch <= 0x7e) | 1086 | if (ansi_ch >= 0x5f && ansi_ch <= 0x7e) |
1072 | ctlr_add(&h3270,h3270.cursor_addr, (unsigned char)(ansi_ch - 0x5f),CS_LINEDRAW); | 1087 | ctlr_add(&h3270,h3270.cursor_addr, (unsigned char)(ansi_ch - 0x5f),CS_LINEDRAW); |
@@ -1110,7 +1125,7 @@ ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1110,7 +1125,7 @@ ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1110 | ctlr_add_bg(cursor_addr, bg); | 1125 | ctlr_add_bg(cursor_addr, bg); |
1111 | if (wraparound_mode) { | 1126 | if (wraparound_mode) { |
1112 | if (!((cursor_addr + 1) % COLS)) { | 1127 | if (!((cursor_addr + 1) % COLS)) { |
1113 | - held_wrap = True; | 1128 | + held_wrap = 1; |
1114 | } else { | 1129 | } else { |
1115 | PWRAP; | 1130 | PWRAP; |
1116 | } | 1131 | } |
@@ -1155,18 +1170,18 @@ ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1155,18 +1170,18 @@ ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1155 | ea_buf[cursor_addr].db = DBCS_NONE; | 1170 | ea_buf[cursor_addr].db = DBCS_NONE; |
1156 | } | 1171 | } |
1157 | #endif /*]*/ | 1172 | #endif /*]*/ |
1158 | - ctlr_add(&h3270,h3270.cursor_addr, ebc_ch, default_cs); | 1173 | + ctlr_add(hSession,hSession->cursor_addr, ebc_ch, default_cs); |
1159 | #if defined(X3270_DBCS) /*[*/ | 1174 | #if defined(X3270_DBCS) /*[*/ |
1160 | if (default_cs == CS_DBCS) | 1175 | if (default_cs == CS_DBCS) |
1161 | (void) ctlr_dbcs_postprocess(); | 1176 | (void) ctlr_dbcs_postprocess(); |
1162 | #endif /*]*/ | 1177 | #endif /*]*/ |
1163 | break; | 1178 | break; |
1164 | } | 1179 | } |
1165 | - once_cset = -1; | ||
1166 | - ctlr_add_gr(&h3270,h3270.cursor_addr, gr); | ||
1167 | - ctlr_add_fg(&h3270,h3270.cursor_addr, fg); | ||
1168 | - ctlr_add_bg(&h3270,h3270.cursor_addr, bg); | ||
1169 | - if (wraparound_mode) { | 1180 | + hSession->once_cset = -1; |
1181 | + ctlr_add_gr(hSession,hSession->cursor_addr, gr); | ||
1182 | + ctlr_add_fg(hSession,hSession->cursor_addr, fg); | ||
1183 | + ctlr_add_bg(hSession,hSession->cursor_addr, bg); | ||
1184 | + if (hSession->wraparound_mode) { | ||
1170 | /* | 1185 | /* |
1171 | * There is a fascinating behavior of xterm which we will | 1186 | * There is a fascinating behavior of xterm which we will |
1172 | * attempt to emulate here. When a character is printed in the | 1187 | * attempt to emulate here. When a character is printed in the |
@@ -1180,14 +1195,14 @@ ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1180,14 +1195,14 @@ ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1180 | * In my opinion, very strange, but among other things, 'vi' | 1195 | * In my opinion, very strange, but among other things, 'vi' |
1181 | * depends on it! | 1196 | * depends on it! |
1182 | */ | 1197 | */ |
1183 | - if (!((h3270.cursor_addr + 1) % h3270.cols)) { | ||
1184 | - held_wrap = True; | 1198 | + if (!((hSession->cursor_addr + 1) % hSession->cols)) { |
1199 | + hSession->held_wrap = 1; | ||
1185 | } else { | 1200 | } else { |
1186 | PWRAP; | 1201 | PWRAP; |
1187 | } | 1202 | } |
1188 | } else { | 1203 | } else { |
1189 | - if ((h3270.cursor_addr % h3270.cols) != (h3270.cols - 1)) | ||
1190 | - cursor_move(&h3270,h3270.cursor_addr + 1); | 1204 | + if ((hSession->cursor_addr % hSession->cols) != (hSession->cols - 1)) |
1205 | + cursor_move(hSession,hSession->cursor_addr + 1); | ||
1191 | } | 1206 | } |
1192 | return DATA; | 1207 | return DATA; |
1193 | } | 1208 | } |
@@ -1257,13 +1272,12 @@ ansi_digit(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1257,13 +1272,12 @@ ansi_digit(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1257 | static enum state | 1272 | static enum state |
1258 | ansi_reverse_index(H3270 *hSession, int ig1 unused, int ig2 unused) | 1273 | ansi_reverse_index(H3270 *hSession, int ig1 unused, int ig2 unused) |
1259 | { | 1274 | { |
1260 | - int rr = h3270.cursor_addr / h3270.cols; /* current row */ | ||
1261 | - int np = (scroll_top - 1) - rr; /* number of rows in the scrolling | ||
1262 | - region, above this line */ | ||
1263 | - int ns; /* number of rows to scroll */ | ||
1264 | - int nn = 1; /* number of rows to index */ | 1275 | + int rr = hSession->cursor_addr / hSession->cols; /* current row */ |
1276 | + int np = (hSession->scroll_top - 1) - rr; /* number of rows in the scrolling region, above this line */ | ||
1277 | + int ns; /* number of rows to scroll */ | ||
1278 | + int nn = 1; /* number of rows to index */ | ||
1265 | 1279 | ||
1266 | - held_wrap = False; | 1280 | + hSession->held_wrap = 0; |
1267 | 1281 | ||
1268 | /* If the cursor is above the scrolling region, do a simple margined | 1282 | /* If the cursor is above the scrolling region, do a simple margined |
1269 | cursor up. */ | 1283 | cursor up. */ |
@@ -1307,12 +1321,13 @@ dec_return_terminal_id(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1307,12 +1321,13 @@ dec_return_terminal_id(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1307 | static enum state | 1321 | static enum state |
1308 | ansi_set_mode(H3270 *hSession, int nn, int ig2 unused) | 1322 | ansi_set_mode(H3270 *hSession, int nn, int ig2 unused) |
1309 | { | 1323 | { |
1310 | - switch (nn) { | ||
1311 | - case 4: | ||
1312 | - insert_mode = 1; | 1324 | + switch (nn) |
1325 | + { | ||
1326 | + case 4: | ||
1327 | + hSession->insert_mode = 1; | ||
1313 | break; | 1328 | break; |
1314 | - case 20: | ||
1315 | - auto_newline_mode = 1; | 1329 | + case 20: |
1330 | + hSession->auto_newline_mode = 1; | ||
1316 | break; | 1331 | break; |
1317 | } | 1332 | } |
1318 | return DATA; | 1333 | return DATA; |
@@ -1321,12 +1336,13 @@ ansi_set_mode(H3270 *hSession, int nn, int ig2 unused) | @@ -1321,12 +1336,13 @@ ansi_set_mode(H3270 *hSession, int nn, int ig2 unused) | ||
1321 | static enum state | 1336 | static enum state |
1322 | ansi_reset_mode(H3270 *hSession, int nn, int ig2 unused) | 1337 | ansi_reset_mode(H3270 *hSession, int nn, int ig2 unused) |
1323 | { | 1338 | { |
1324 | - switch (nn) { | ||
1325 | - case 4: | ||
1326 | - insert_mode = 0; | 1339 | + switch (nn) |
1340 | + { | ||
1341 | + case 4: | ||
1342 | + hSession->insert_mode = 0; | ||
1327 | break; | 1343 | break; |
1328 | - case 20: | ||
1329 | - auto_newline_mode = 0; | 1344 | + case 20: |
1345 | + hSession->auto_newline_mode = 0; | ||
1330 | break; | 1346 | break; |
1331 | } | 1347 | } |
1332 | return DATA; | 1348 | return DATA; |
@@ -1395,14 +1411,14 @@ ansi_select_g3(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1395,14 +1411,14 @@ ansi_select_g3(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1395 | static enum state | 1411 | static enum state |
1396 | ansi_one_g2(H3270 *hSession, int ig1 unused, int ig2 unused) | 1412 | ansi_one_g2(H3270 *hSession, int ig1 unused, int ig2 unused) |
1397 | { | 1413 | { |
1398 | - once_cset = CS_G2; | 1414 | + hSession->once_cset = CS_G2; |
1399 | return DATA; | 1415 | return DATA; |
1400 | } | 1416 | } |
1401 | 1417 | ||
1402 | static enum state | 1418 | static enum state |
1403 | ansi_one_g3(H3270 *hSession, int ig1 unused, int ig2 unused) | 1419 | ansi_one_g3(H3270 *hSession, int ig1 unused, int ig2 unused) |
1404 | { | 1420 | { |
1405 | - once_cset = CS_G3; | 1421 | + hSession->once_cset = CS_G3; |
1406 | return DATA; | 1422 | return DATA; |
1407 | } | 1423 | } |
1408 | 1424 | ||
@@ -1418,30 +1434,32 @@ dec_set(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1418,30 +1434,32 @@ dec_set(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1418 | int i; | 1434 | int i; |
1419 | 1435 | ||
1420 | for (i = 0; i <= nx && i < NN; i++) | 1436 | for (i = 0; i <= nx && i < NN; i++) |
1421 | - switch (n[i]) { | ||
1422 | - case 1: /* application cursor keys */ | ||
1423 | - appl_cursor = 1; | 1437 | + switch (n[i]) |
1438 | + { | ||
1439 | + case 1: /* application cursor keys */ | ||
1440 | + hSession->appl_cursor = 1; | ||
1424 | break; | 1441 | break; |
1425 | - case 2: /* set G0-G3 */ | 1442 | + case 2: /* set G0-G3 */ |
1426 | csd[0] = csd[1] = csd[2] = csd[3] = CSD_US; | 1443 | csd[0] = csd[1] = csd[2] = csd[3] = CSD_US; |
1427 | break; | 1444 | break; |
1428 | - case 3: /* 132-column mode */ | ||
1429 | - if (allow_wide_mode) { | ||
1430 | - wide_mode = 1; | 1445 | + case 3: /* 132-column mode */ |
1446 | + if (hSession->allow_wide_mode) | ||
1447 | + { | ||
1448 | + hSession->wide_mode = 1; | ||
1431 | screen_132(); | 1449 | screen_132(); |
1432 | } | 1450 | } |
1433 | break; | 1451 | break; |
1434 | - case 7: /* wraparound mode */ | ||
1435 | - wraparound_mode = 1; | 1452 | + case 7: /* wraparound mode */ |
1453 | + hSession->wraparound_mode = 1; | ||
1436 | break; | 1454 | break; |
1437 | - case 40: /* allow 80/132 switching */ | ||
1438 | - allow_wide_mode = 1; | 1455 | + case 40: /* allow 80/132 switching */ |
1456 | + hSession->allow_wide_mode = 1; | ||
1439 | break; | 1457 | break; |
1440 | - case 45: /* reverse-wraparound mode */ | ||
1441 | - rev_wraparound_mode = 1; | 1458 | + case 45: /* reverse-wraparound mode */ |
1459 | + hSession->rev_wraparound_mode = 1; | ||
1442 | break; | 1460 | break; |
1443 | - case 47: /* alt buffer */ | ||
1444 | - ctlr_altbuffer(&h3270,True); | 1461 | + case 47: /* alt buffer */ |
1462 | + ctlr_altbuffer(hSession,True); | ||
1445 | break; | 1463 | break; |
1446 | } | 1464 | } |
1447 | return DATA; | 1465 | return DATA; |
@@ -1453,56 +1471,58 @@ dec_reset(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1453,56 +1471,58 @@ dec_reset(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1453 | int i; | 1471 | int i; |
1454 | 1472 | ||
1455 | for (i = 0; i <= nx && i < NN; i++) | 1473 | for (i = 0; i <= nx && i < NN; i++) |
1456 | - switch (n[i]) { | ||
1457 | - case 1: /* normal cursor keys */ | ||
1458 | - appl_cursor = 0; | 1474 | + switch (n[i]) |
1475 | + { | ||
1476 | + case 1: /* normal cursor keys */ | ||
1477 | + hSession->appl_cursor = 0; | ||
1459 | break; | 1478 | break; |
1460 | - case 3: /* 132-column mode */ | ||
1461 | - if (allow_wide_mode) { | ||
1462 | - wide_mode = 0; | 1479 | + case 3: /* 132-column mode */ |
1480 | + if (hSession->allow_wide_mode) | ||
1481 | + { | ||
1482 | + hSession->wide_mode = 0; | ||
1463 | screen_80(); | 1483 | screen_80(); |
1464 | } | 1484 | } |
1465 | break; | 1485 | break; |
1466 | - case 7: /* no wraparound mode */ | ||
1467 | - wraparound_mode = 0; | 1486 | + case 7: /* no wraparound mode */ |
1487 | + hSession->wraparound_mode = 0; | ||
1468 | break; | 1488 | break; |
1469 | - case 40: /* allow 80/132 switching */ | ||
1470 | - allow_wide_mode = 0; | 1489 | + case 40: /* allow 80/132 switching */ |
1490 | + hSession->allow_wide_mode = 0; | ||
1471 | break; | 1491 | break; |
1472 | - case 45: /* no reverse-wraparound mode */ | ||
1473 | - rev_wraparound_mode = 0; | 1492 | + case 45: /* no reverse-wraparound mode */ |
1493 | + hSession->rev_wraparound_mode = 0; | ||
1474 | break; | 1494 | break; |
1475 | - case 47: /* alt buffer */ | ||
1476 | - ctlr_altbuffer(&h3270,False); | 1495 | + case 47: /* alt buffer */ |
1496 | + ctlr_altbuffer(hSession,False); | ||
1477 | break; | 1497 | break; |
1478 | } | 1498 | } |
1479 | return DATA; | 1499 | return DATA; |
1480 | } | 1500 | } |
1481 | 1501 | ||
1482 | -static enum state | ||
1483 | -dec_save(H3270 *hSession, int ig1 unused, int ig2 unused) | 1502 | +static enum state dec_save(H3270 *hSession, int ig1 unused, int ig2 unused) |
1484 | { | 1503 | { |
1485 | int i; | 1504 | int i; |
1486 | 1505 | ||
1487 | for (i = 0; i <= nx && i < NN; i++) | 1506 | for (i = 0; i <= nx && i < NN; i++) |
1488 | - switch (n[i]) { | ||
1489 | - case 1: /* application cursor keys */ | ||
1490 | - saved_appl_cursor = appl_cursor; | 1507 | + switch (n[i]) |
1508 | + { | ||
1509 | + case 1: /* application cursor keys */ | ||
1510 | + hSession->saved_appl_cursor = hSession->appl_cursor; | ||
1491 | break; | 1511 | break; |
1492 | - case 3: /* 132-column mode */ | ||
1493 | - saved_wide_mode = wide_mode; | 1512 | + case 3: /* 132-column mode */ |
1513 | + hSession->saved_wide_mode = hSession->wide_mode; | ||
1494 | break; | 1514 | break; |
1495 | - case 7: /* wraparound mode */ | ||
1496 | - saved_wraparound_mode = wraparound_mode; | 1515 | + case 7: /* wraparound mode */ |
1516 | + hSession->saved_wraparound_mode = hSession->wraparound_mode; | ||
1497 | break; | 1517 | break; |
1498 | - case 40: /* allow 80/132 switching */ | ||
1499 | - saved_allow_wide_mode = allow_wide_mode; | 1518 | + case 40: /* allow 80/132 switching */ |
1519 | + hSession->saved_allow_wide_mode = hSession->allow_wide_mode; | ||
1500 | break; | 1520 | break; |
1501 | - case 45: /* reverse-wraparound mode */ | ||
1502 | - saved_rev_wraparound_mode = rev_wraparound_mode; | 1521 | + case 45: /* reverse-wraparound mode */ |
1522 | + hSession->saved_rev_wraparound_mode = hSession->rev_wraparound_mode; | ||
1503 | break; | 1523 | break; |
1504 | - case 47: /* alt buffer */ | ||
1505 | - saved_altbuffer = h3270.is_altbuffer; | 1524 | + case 47: /* alt buffer */ |
1525 | + hSession->saved_altbuffer = hSession->is_altbuffer; | ||
1506 | break; | 1526 | break; |
1507 | } | 1527 | } |
1508 | return DATA; | 1528 | return DATA; |
@@ -1514,30 +1534,32 @@ dec_restore(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1514,30 +1534,32 @@ dec_restore(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1514 | int i; | 1534 | int i; |
1515 | 1535 | ||
1516 | for (i = 0; i <= nx && i < NN; i++) | 1536 | for (i = 0; i <= nx && i < NN; i++) |
1517 | - switch (n[i]) { | ||
1518 | - case 1: /* application cursor keys */ | ||
1519 | - appl_cursor = saved_appl_cursor; | 1537 | + switch (n[i]) |
1538 | + { | ||
1539 | + case 1: /* application cursor keys */ | ||
1540 | + hSession->appl_cursor = hSession->saved_appl_cursor; | ||
1520 | break; | 1541 | break; |
1521 | - case 3: /* 132-column mode */ | ||
1522 | - if (allow_wide_mode) { | ||
1523 | - wide_mode = saved_wide_mode; | ||
1524 | - if (wide_mode) | 1542 | + case 3: /* 132-column mode */ |
1543 | + if (hSession->allow_wide_mode) | ||
1544 | + { | ||
1545 | + hSession->wide_mode = hSession->saved_wide_mode; | ||
1546 | + if (hSession->wide_mode) | ||
1525 | screen_132(); | 1547 | screen_132(); |
1526 | else | 1548 | else |
1527 | screen_80(); | 1549 | screen_80(); |
1528 | } | 1550 | } |
1529 | break; | 1551 | break; |
1530 | - case 7: /* wraparound mode */ | ||
1531 | - wraparound_mode = saved_wraparound_mode; | 1552 | + case 7: /* wraparound mode */ |
1553 | + hSession->wraparound_mode = hSession->saved_wraparound_mode; | ||
1532 | break; | 1554 | break; |
1533 | - case 40: /* allow 80/132 switching */ | ||
1534 | - allow_wide_mode = saved_allow_wide_mode; | 1555 | + case 40: /* allow 80/132 switching */ |
1556 | + hSession->allow_wide_mode = hSession->saved_allow_wide_mode; | ||
1535 | break; | 1557 | break; |
1536 | - case 45: /* reverse-wraparound mode */ | ||
1537 | - rev_wraparound_mode = saved_rev_wraparound_mode; | 1558 | + case 45: /* reverse-wraparound mode */ |
1559 | + hSession->rev_wraparound_mode = hSession->saved_rev_wraparound_mode; | ||
1538 | break; | 1560 | break; |
1539 | - case 47: /* alt buffer */ | ||
1540 | - ctlr_altbuffer(&h3270,saved_altbuffer); | 1561 | + case 47: /* alt buffer */ |
1562 | + ctlr_altbuffer(hSession,hSession->saved_altbuffer); | ||
1541 | break; | 1563 | break; |
1542 | } | 1564 | } |
1543 | return DATA; | 1565 | return DATA; |
@@ -1548,15 +1570,19 @@ dec_scrolling_region(H3270 *hSession, int top, int bottom) | @@ -1548,15 +1570,19 @@ dec_scrolling_region(H3270 *hSession, int top, int bottom) | ||
1548 | { | 1570 | { |
1549 | if (top < 1) | 1571 | if (top < 1) |
1550 | top = 1; | 1572 | top = 1; |
1551 | - if (bottom > h3270.rows) | ||
1552 | - bottom = h3270.rows; | ||
1553 | - if (top <= bottom && (top > 1 || bottom < h3270.rows)) { | ||
1554 | - scroll_top = top; | ||
1555 | - scroll_bottom = bottom; | ||
1556 | - cursor_move(&h3270,0); | ||
1557 | - } else { | ||
1558 | - scroll_top = 1; | ||
1559 | - scroll_bottom = h3270.rows; | 1573 | + if (bottom > hSession->rows) |
1574 | + bottom = hSession->rows; | ||
1575 | + | ||
1576 | + if (top <= bottom && (top > 1 || bottom < hSession->rows)) | ||
1577 | + { | ||
1578 | + hSession->scroll_top = top; | ||
1579 | + hSession->scroll_bottom = bottom; | ||
1580 | + cursor_move(hSession,0); | ||
1581 | + } | ||
1582 | + else | ||
1583 | + { | ||
1584 | + hSession->scroll_top = 1; | ||
1585 | + hSession->scroll_bottom = hSession->rows; | ||
1560 | } | 1586 | } |
1561 | return DATA; | 1587 | return DATA; |
1562 | } | 1588 | } |
@@ -1631,7 +1657,7 @@ xterm_text_do(H3270 *hSession, int ig1 unused, int ig2 unused) | @@ -1631,7 +1657,7 @@ xterm_text_do(H3270 *hSession, int ig1 unused, int ig2 unused) | ||
1631 | static enum state | 1657 | static enum state |
1632 | ansi_htab_set(H3270 *hSession, int ig1 unused, int ig2 unused) | 1658 | ansi_htab_set(H3270 *hSession, int ig1 unused, int ig2 unused) |
1633 | { | 1659 | { |
1634 | - register int col = h3270.cursor_addr % h3270.cols; | 1660 | + register int col = hSession->cursor_addr % hSession->cols; |
1635 | 1661 | ||
1636 | tabs[col/8] |= 1<<(col%8); | 1662 | tabs[col/8] |= 1<<(col%8); |
1637 | return DATA; | 1663 | return DATA; |
@@ -1642,13 +1668,14 @@ ansi_htab_clear(H3270 *hSession, int nn, int ig2 unused) | @@ -1642,13 +1668,14 @@ ansi_htab_clear(H3270 *hSession, int nn, int ig2 unused) | ||
1642 | { | 1668 | { |
1643 | register int col, i; | 1669 | register int col, i; |
1644 | 1670 | ||
1645 | - switch (nn) { | ||
1646 | - case 0: | ||
1647 | - col = h3270.cursor_addr % h3270.cols; | 1671 | + switch (nn) |
1672 | + { | ||
1673 | + case 0: | ||
1674 | + col = hSession->cursor_addr % hSession->cols; | ||
1648 | tabs[col/8] &= ~(1<<(col%8)); | 1675 | tabs[col/8] &= ~(1<<(col%8)); |
1649 | break; | 1676 | break; |
1650 | - case 3: | ||
1651 | - for (i = 0; i < (h3270.cols+7)/8; i++) | 1677 | + case 3: |
1678 | + for (i = 0; i < (hSession->cols+7)/8; i++) | ||
1652 | tabs[i] = 0; | 1679 | tabs[i] = 0; |
1653 | break; | 1680 | break; |
1654 | } | 1681 | } |
@@ -1658,29 +1685,28 @@ ansi_htab_clear(H3270 *hSession, int nn, int ig2 unused) | @@ -1658,29 +1685,28 @@ ansi_htab_clear(H3270 *hSession, int nn, int ig2 unused) | ||
1658 | /* | 1685 | /* |
1659 | * Scroll the screen or the scrolling region. | 1686 | * Scroll the screen or the scrolling region. |
1660 | */ | 1687 | */ |
1661 | -static void | ||
1662 | -ansi_scroll(void) | 1688 | +static void ansi_scroll(H3270 *hSession) |
1663 | { | 1689 | { |
1664 | - held_wrap = False; | 1690 | + hSession->held_wrap = 0; |
1665 | 1691 | ||
1666 | /* Save the top line */ | 1692 | /* Save the top line */ |
1667 | - if (scroll_top == 1 && scroll_bottom == h3270.rows) | 1693 | + if (hSession->scroll_top == 1 && hSession->scroll_bottom == hSession->rows) |
1668 | { | 1694 | { |
1669 | // if (!h3270.is_altbuffer) | 1695 | // if (!h3270.is_altbuffer) |
1670 | // scroll_save(1, False); | 1696 | // scroll_save(1, False); |
1671 | - ctlr_scroll(&h3270); | 1697 | + ctlr_scroll(hSession); |
1672 | return; | 1698 | return; |
1673 | } | 1699 | } |
1674 | 1700 | ||
1675 | /* Scroll all but the last line up */ | 1701 | /* Scroll all but the last line up */ |
1676 | - if (scroll_bottom > scroll_top) | ||
1677 | - ctlr_bcopy(scroll_top * h3270.cols, | ||
1678 | - (scroll_top - 1) * h3270.cols, | ||
1679 | - (scroll_bottom - scroll_top) * h3270.cols, | 1702 | + if (hSession->scroll_bottom > hSession->scroll_top) |
1703 | + ctlr_bcopy(hSession->scroll_top * hSession->cols, | ||
1704 | + (hSession->scroll_top - 1) * hSession->cols, | ||
1705 | + (hSession->scroll_bottom - hSession->scroll_top) * hSession->cols, | ||
1680 | 1); | 1706 | 1); |
1681 | 1707 | ||
1682 | /* Clear the last line */ | 1708 | /* Clear the last line */ |
1683 | - ctlr_aclear(&h3270, (scroll_bottom - 1) * h3270.cols, h3270.cols, 1); | 1709 | + ctlr_aclear(hSession, (hSession->scroll_bottom - 1) * hSession->cols, hSession->cols, 1); |
1684 | } | 1710 | } |
1685 | 1711 | ||
1686 | /* Callback for when we enter ANSI mode. */ | 1712 | /* Callback for when we enter ANSI mode. */ |
@@ -1707,7 +1733,7 @@ static void trace_pending_mb(void) | @@ -1707,7 +1733,7 @@ static void trace_pending_mb(void) | ||
1707 | * External entry points | 1733 | * External entry points |
1708 | */ | 1734 | */ |
1709 | void | 1735 | void |
1710 | -ansi_process(unsigned int c) | 1736 | +ansi_process(H3270 *hSession, unsigned int c) |
1711 | { | 1737 | { |
1712 | afn_t fn; | 1738 | afn_t fn; |
1713 | 1739 | ||
@@ -1717,73 +1743,75 @@ ansi_process(unsigned int c) | @@ -1717,73 +1743,75 @@ ansi_process(unsigned int c) | ||
1717 | // scroll_to_bottom(); | 1743 | // scroll_to_bottom(); |
1718 | 1744 | ||
1719 | #if defined(X3270_TRACE) /*[*/ | 1745 | #if defined(X3270_TRACE) /*[*/ |
1720 | - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_SCREEN_TRACE)) | ||
1721 | - trace_char(&h3270,(char)c); | 1746 | + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE)) |
1747 | + trace_char(hSession,(char)c); | ||
1722 | #endif /*]*/ | 1748 | #endif /*]*/ |
1723 | 1749 | ||
1724 | fn = ansi_fn[st[(int)state][c]]; | 1750 | fn = ansi_fn[st[(int)state][c]]; |
1751 | + | ||
1725 | #if defined(X3270_DBCS) /*[*/ | 1752 | #if defined(X3270_DBCS) /*[*/ |
1726 | if (mb_pending && fn != &ansi_printing) | 1753 | if (mb_pending && fn != &ansi_printing) |
1727 | { | 1754 | { |
1728 | - trace_ds(&h3270,"Dropped incomplete multi-byte character"); | 1755 | + trace_ds(hSession,"Dropped incomplete multi-byte character"); |
1729 | trace_pending_mb(); | 1756 | trace_pending_mb(); |
1730 | - trace_ds(&h3270,"\n"); | 1757 | + trace_ds(hSession,"\n"); |
1731 | mb_pending = 0; | 1758 | mb_pending = 0; |
1732 | } | 1759 | } |
1733 | #endif /*]*/ | 1760 | #endif /*]*/ |
1734 | - state = (*fn)(&h3270, n[0], n[1]); | 1761 | + |
1762 | + state = (*fn)(hSession, n[0], n[1]); | ||
1735 | } | 1763 | } |
1736 | 1764 | ||
1737 | void | 1765 | void |
1738 | -ansi_send_up(void) | 1766 | +ansi_send_up(H3270 *hSession) |
1739 | { | 1767 | { |
1740 | - if (appl_cursor) | 1768 | + if (hSession->appl_cursor) |
1741 | net_sends("\033OA"); | 1769 | net_sends("\033OA"); |
1742 | else | 1770 | else |
1743 | net_sends("\033[A"); | 1771 | net_sends("\033[A"); |
1744 | } | 1772 | } |
1745 | 1773 | ||
1746 | void | 1774 | void |
1747 | -ansi_send_down(void) | 1775 | +ansi_send_down(H3270 *hSession) |
1748 | { | 1776 | { |
1749 | - if (appl_cursor) | 1777 | + if (hSession->appl_cursor) |
1750 | net_sends("\033OB"); | 1778 | net_sends("\033OB"); |
1751 | else | 1779 | else |
1752 | net_sends("\033[B"); | 1780 | net_sends("\033[B"); |
1753 | } | 1781 | } |
1754 | 1782 | ||
1755 | void | 1783 | void |
1756 | -ansi_send_right(void) | 1784 | +ansi_send_right(H3270 *hSession) |
1757 | { | 1785 | { |
1758 | - if (appl_cursor) | 1786 | + if (hSession->appl_cursor) |
1759 | net_sends("\033OC"); | 1787 | net_sends("\033OC"); |
1760 | else | 1788 | else |
1761 | net_sends("\033[C"); | 1789 | net_sends("\033[C"); |
1762 | } | 1790 | } |
1763 | 1791 | ||
1764 | void | 1792 | void |
1765 | -ansi_send_left(void) | 1793 | +ansi_send_left(H3270 *hSession) |
1766 | { | 1794 | { |
1767 | - if (appl_cursor) | 1795 | + if (hSession->appl_cursor) |
1768 | net_sends("\033OD"); | 1796 | net_sends("\033OD"); |
1769 | else | 1797 | else |
1770 | net_sends("\033[D"); | 1798 | net_sends("\033[D"); |
1771 | } | 1799 | } |
1772 | 1800 | ||
1773 | void | 1801 | void |
1774 | -ansi_send_home(void) | 1802 | +ansi_send_home(H3270 *hSession) |
1775 | { | 1803 | { |
1776 | net_sends("\033[H"); | 1804 | net_sends("\033[H"); |
1777 | } | 1805 | } |
1778 | 1806 | ||
1779 | void | 1807 | void |
1780 | -ansi_send_clear(void) | 1808 | +ansi_send_clear(H3270 *hSession) |
1781 | { | 1809 | { |
1782 | net_sends("\033[2K"); | 1810 | net_sends("\033[2K"); |
1783 | } | 1811 | } |
1784 | 1812 | ||
1785 | void | 1813 | void |
1786 | -ansi_send_pf(int nn) | 1814 | +ansi_send_pf(H3270 *hSession, int nn) |
1787 | { | 1815 | { |
1788 | static char fn_buf[6]; | 1816 | static char fn_buf[6]; |
1789 | static int code[] = { | 1817 | static int code[] = { |
@@ -1809,7 +1837,7 @@ ansi_send_pf(int nn) | @@ -1809,7 +1837,7 @@ ansi_send_pf(int nn) | ||
1809 | } | 1837 | } |
1810 | 1838 | ||
1811 | void | 1839 | void |
1812 | -ansi_send_pa(int nn) | 1840 | +ansi_send_pa(H3270 *hSession, int nn) |
1813 | { | 1841 | { |
1814 | static char fn_buf[4]; | 1842 | static char fn_buf[4]; |
1815 | static char code[4] = { 'P', 'Q', 'R', 'S' }; | 1843 | static char code[4] = { 'P', 'Q', 'R', 'S' }; |
@@ -1820,12 +1848,12 @@ ansi_send_pa(int nn) | @@ -1820,12 +1848,12 @@ ansi_send_pa(int nn) | ||
1820 | net_sends(fn_buf); | 1848 | net_sends(fn_buf); |
1821 | } | 1849 | } |
1822 | 1850 | ||
1823 | -void toggle_lineWrap(H3270 *session, struct lib3270_toggle *t unused, LIB3270_TOGGLE_TYPE type unused) | 1851 | +void toggle_lineWrap(H3270 *hSession, struct lib3270_toggle *t unused, LIB3270_TOGGLE_TYPE type unused) |
1824 | { | 1852 | { |
1825 | - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_LINE_WRAP)) | ||
1826 | - wraparound_mode = 1; | 1853 | + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_LINE_WRAP)) |
1854 | + hSession->wraparound_mode = 1; | ||
1827 | else | 1855 | else |
1828 | - wraparound_mode = 0; | 1856 | + hSession->wraparound_mode = 0; |
1829 | } | 1857 | } |
1830 | 1858 | ||
1831 | #if defined(X3270_DBCS) /*[*/ | 1859 | #if defined(X3270_DBCS) /*[*/ |
src/lib3270/ansic.h
@@ -19,15 +19,15 @@ | @@ -19,15 +19,15 @@ | ||
19 | 19 | ||
20 | #if defined(X3270_ANSI) /*[*/ | 20 | #if defined(X3270_ANSI) /*[*/ |
21 | 21 | ||
22 | -LIB3270_INTERNAL void ansi_process(unsigned int c); | ||
23 | -LIB3270_INTERNAL void ansi_send_clear(void); | ||
24 | -LIB3270_INTERNAL void ansi_send_down(void); | ||
25 | -LIB3270_INTERNAL void ansi_send_home(void); | ||
26 | -LIB3270_INTERNAL void ansi_send_left(void); | ||
27 | -LIB3270_INTERNAL void ansi_send_pa(int nn); | ||
28 | -LIB3270_INTERNAL void ansi_send_pf(int nn); | ||
29 | -LIB3270_INTERNAL void ansi_send_right(void); | ||
30 | -LIB3270_INTERNAL void ansi_send_up(void); | 22 | +LIB3270_INTERNAL void ansi_process(H3270 *hSession, unsigned int c); |
23 | +LIB3270_INTERNAL void ansi_send_clear(H3270 *hSession); | ||
24 | +LIB3270_INTERNAL void ansi_send_down(H3270 *hSession); | ||
25 | +LIB3270_INTERNAL void ansi_send_home(H3270 *hSession); | ||
26 | +LIB3270_INTERNAL void ansi_send_left(H3270 *hSession); | ||
27 | +LIB3270_INTERNAL void ansi_send_pa(H3270 *hSession, int nn); | ||
28 | +LIB3270_INTERNAL void ansi_send_pf(H3270 *hSession, int nn); | ||
29 | +LIB3270_INTERNAL void ansi_send_right(H3270 *hSession); | ||
30 | +LIB3270_INTERNAL void ansi_send_up(H3270 *hSession); | ||
31 | LIB3270_INTERNAL void ansi_in3270(H3270 *session, int in3270, void *dunno); | 31 | LIB3270_INTERNAL void ansi_in3270(H3270 *session, int in3270, void *dunno); |
32 | 32 | ||
33 | LIB3270_INTERNAL void toggle_lineWrap(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE type); | 33 | LIB3270_INTERNAL void toggle_lineWrap(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE type); |
src/lib3270/kybd.c
@@ -507,12 +507,12 @@ static void key_AID(H3270 *hSession, unsigned char aid_code) | @@ -507,12 +507,12 @@ static void key_AID(H3270 *hSession, unsigned char aid_code) | ||
507 | } | 507 | } |
508 | for (i = 0; i < PF_SZ; i++) | 508 | for (i = 0; i < PF_SZ; i++) |
509 | if (aid_code == pf_xlate[i]) { | 509 | if (aid_code == pf_xlate[i]) { |
510 | - ansi_send_pf(i+1); | 510 | + ansi_send_pf(hSession,i+1); |
511 | return; | 511 | return; |
512 | } | 512 | } |
513 | for (i = 0; i < PA_SZ; i++) | 513 | for (i = 0; i < PA_SZ; i++) |
514 | if (aid_code == pa_xlate[i]) { | 514 | if (aid_code == pa_xlate[i]) { |
515 | - ansi_send_pa(i+1); | 515 | + ansi_send_pa(hSession,i+1); |
516 | return; | 516 | return; |
517 | } | 517 | } |
518 | return; | 518 | return; |
@@ -1186,7 +1186,7 @@ LIB3270_ACTION( firstfield ) | @@ -1186,7 +1186,7 @@ LIB3270_ACTION( firstfield ) | ||
1186 | } | 1186 | } |
1187 | #if defined(X3270_ANSI) /*[*/ | 1187 | #if defined(X3270_ANSI) /*[*/ |
1188 | if (IN_ANSI) { | 1188 | if (IN_ANSI) { |
1189 | - ansi_send_home(); | 1189 | + ansi_send_home(hSession); |
1190 | return 0; | 1190 | return 0; |
1191 | } | 1191 | } |
1192 | #endif /*]*/ | 1192 | #endif /*]*/ |
@@ -1234,7 +1234,7 @@ LIB3270_CURSOR_ACTION( left ) | @@ -1234,7 +1234,7 @@ LIB3270_CURSOR_ACTION( left ) | ||
1234 | #if defined(X3270_ANSI) /*[*/ | 1234 | #if defined(X3270_ANSI) /*[*/ |
1235 | if (IN_ANSI) | 1235 | if (IN_ANSI) |
1236 | { | 1236 | { |
1237 | - ansi_send_left(); | 1237 | + ansi_send_left(hSession); |
1238 | return 0; | 1238 | return 0; |
1239 | } | 1239 | } |
1240 | #endif /*]*/ | 1240 | #endif /*]*/ |
@@ -1503,7 +1503,7 @@ LIB3270_CURSOR_ACTION( right ) | @@ -1503,7 +1503,7 @@ LIB3270_CURSOR_ACTION( right ) | ||
1503 | } | 1503 | } |
1504 | #if defined(X3270_ANSI) /*[*/ | 1504 | #if defined(X3270_ANSI) /*[*/ |
1505 | if (IN_ANSI) { | 1505 | if (IN_ANSI) { |
1506 | - ansi_send_right(); | 1506 | + ansi_send_right(hSession); |
1507 | return 0; | 1507 | return 0; |
1508 | } | 1508 | } |
1509 | #endif /*]*/ | 1509 | #endif /*]*/ |
@@ -1734,7 +1734,7 @@ LIB3270_CURSOR_ACTION( up ) | @@ -1734,7 +1734,7 @@ LIB3270_CURSOR_ACTION( up ) | ||
1734 | } | 1734 | } |
1735 | #if defined(X3270_ANSI) /*[*/ | 1735 | #if defined(X3270_ANSI) /*[*/ |
1736 | if (IN_ANSI) { | 1736 | if (IN_ANSI) { |
1737 | - ansi_send_up(); | 1737 | + ansi_send_up(hSession); |
1738 | return 0; | 1738 | return 0; |
1739 | } | 1739 | } |
1740 | #endif /*]*/ | 1740 | #endif /*]*/ |
@@ -1772,7 +1772,7 @@ LIB3270_CURSOR_ACTION( down ) | @@ -1772,7 +1772,7 @@ LIB3270_CURSOR_ACTION( down ) | ||
1772 | #if defined(X3270_ANSI) /*[*/ | 1772 | #if defined(X3270_ANSI) /*[*/ |
1773 | if (IN_ANSI) | 1773 | if (IN_ANSI) |
1774 | { | 1774 | { |
1775 | - ansi_send_down(); | 1775 | + ansi_send_down(hSession); |
1776 | return 0; | 1776 | return 0; |
1777 | } | 1777 | } |
1778 | #endif /*]*/ | 1778 | #endif /*]*/ |
@@ -1915,7 +1915,7 @@ LIB3270_ACTION( clear ) | @@ -1915,7 +1915,7 @@ LIB3270_ACTION( clear ) | ||
1915 | } | 1915 | } |
1916 | #if defined(X3270_ANSI) /*[*/ | 1916 | #if defined(X3270_ANSI) /*[*/ |
1917 | if (IN_ANSI) { | 1917 | if (IN_ANSI) { |
1918 | - ansi_send_clear(); | 1918 | + ansi_send_clear(hSession); |
1919 | return 0; | 1919 | return 0; |
1920 | } | 1920 | } |
1921 | #endif /*]*/ | 1921 | #endif /*]*/ |
src/lib3270/session.c
@@ -202,6 +202,12 @@ static void lib3270_session_init(H3270 *hSession, const char *model) | @@ -202,6 +202,12 @@ static void lib3270_session_init(H3270 *hSession, const char *model) | ||
202 | hSession->reply_mode = SF_SRM_FIELD; | 202 | hSession->reply_mode = SF_SRM_FIELD; |
203 | hSession->linemode = 1; | 203 | hSession->linemode = 1; |
204 | hSession->tn3270e_submode = E_NONE; | 204 | hSession->tn3270e_submode = E_NONE; |
205 | + hSession->scroll_top = -1; | ||
206 | + hSession->scroll_bottom = -1; | ||
207 | + hSession->wraparound_mode = 1; | ||
208 | + hSession->saved_wraparound_mode = 1; | ||
209 | + hSession->once_cset = -1; | ||
210 | + | ||
205 | 211 | ||
206 | #ifdef _WIN32 | 212 | #ifdef _WIN32 |
207 | hSession->sockEvent = NULL; | 213 | hSession->sockEvent = NULL; |
src/lib3270/telnet.c
@@ -1259,8 +1259,8 @@ static int telnet_fsm(H3270 *session, unsigned char c) | @@ -1259,8 +1259,8 @@ static int telnet_fsm(H3270 *session, unsigned char c) | ||
1259 | if (!session->syncing) | 1259 | if (!session->syncing) |
1260 | { | 1260 | { |
1261 | if (session->linemode && session->onlcr && c == '\n') | 1261 | if (session->linemode && session->onlcr && c == '\n') |
1262 | - ansi_process((unsigned int) '\r'); | ||
1263 | - ansi_process((unsigned int) c); | 1262 | + ansi_process(session,(unsigned int) '\r'); |
1263 | + ansi_process(session,(unsigned int) c); | ||
1264 | // sms_store(c); | 1264 | // sms_store(c); |
1265 | } | 1265 | } |
1266 | #endif /*]*/ | 1266 | #endif /*]*/ |
@@ -1293,7 +1293,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) | @@ -1293,7 +1293,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) | ||
1293 | session->ansi_data = 4 + sl; | 1293 | session->ansi_data = 4 + sl; |
1294 | } | 1294 | } |
1295 | trace_dsn(session,"%s",see_chr); | 1295 | trace_dsn(session,"%s",see_chr); |
1296 | - ansi_process((unsigned int) c); | 1296 | + ansi_process(session,(unsigned int) c); |
1297 | #endif /*]*/ | 1297 | #endif /*]*/ |
1298 | } | 1298 | } |
1299 | else | 1299 | else |
@@ -1983,7 +1983,7 @@ process_eor(H3270 *hSession) | @@ -1983,7 +1983,7 @@ process_eor(H3270 *hSession) | ||
1983 | hSession->tn3270e_submode = E_NVT; | 1983 | hSession->tn3270e_submode = E_NVT; |
1984 | check_in3270(hSession); | 1984 | check_in3270(hSession); |
1985 | for (s = hSession->ibuf; s < hSession->ibptr; s++) { | 1985 | for (s = hSession->ibuf; s < hSession->ibptr; s++) { |
1986 | - ansi_process(*s++); | 1986 | + ansi_process(hSession,*s++); |
1987 | } | 1987 | } |
1988 | return 0; | 1988 | return 0; |
1989 | case TN3270E_DT_SSCP_LU_DATA: | 1989 | case TN3270E_DT_SSCP_LU_DATA: |
@@ -2233,7 +2233,7 @@ static void | @@ -2233,7 +2233,7 @@ static void | ||
2233 | ansi_process_s(const char *data) | 2233 | ansi_process_s(const char *data) |
2234 | { | 2234 | { |
2235 | while (*data) | 2235 | while (*data) |
2236 | - ansi_process((unsigned int) *data++); | 2236 | + ansi_process(&h3270,(unsigned int) *data++); |
2237 | } | 2237 | } |
2238 | 2238 | ||
2239 | static void forward_data(H3270 *hSession) | 2239 | static void forward_data(H3270 *hSession) |
@@ -2250,7 +2250,7 @@ static void do_data(H3270 *hSession, char c) | @@ -2250,7 +2250,7 @@ static void do_data(H3270 *hSession, char c) | ||
2250 | if (c == '\r') | 2250 | if (c == '\r') |
2251 | *hSession->lbptr++ = '\0'; | 2251 | *hSession->lbptr++ = '\0'; |
2252 | if (c == '\t') | 2252 | if (c == '\t') |
2253 | - ansi_process((unsigned int) c); | 2253 | + ansi_process(hSession,(unsigned int) c); |
2254 | else | 2254 | else |
2255 | ansi_process_s(ctl_see((int) c)); | 2255 | ansi_process_s(ctl_see((int) c)); |
2256 | } | 2256 | } |