ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.131 by root, Fri Aug 13 22:38:57 2004 UTC vs.
Revision 1.145 by root, Mon Aug 16 12:04:57 2004 UTC

57#define IS_CONTROL(ch) !((ch) & 0xffffff60UL) 57#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
58 58
59// exception thrown when the command parser runs out of input data 59// exception thrown when the command parser runs out of input data
60class out_of_input { } out_of_input; 60class out_of_input { } out_of_input;
61 61
62#ifndef NO_FRILLS 62#if ENABLE_FRILLS || ISO_14755
63 63
64#define ISO_14755_KEYCODE_VALID 0x80000000UL
65#define ISO_14755_ACTIVE 0x40000000UL 64#define ISO_14755_STARTED 0x80000000UL
66#define ISO_14755_ESCAPE_NEXT 0x20000000UL 65#define ISO_14755_51 0x40000000UL // basic (section 5.1)
66#define ISO_14755_52 0x20000000UL // keycap (section 5.2)
67#define ISO_14755_54 0x10000000UL // code feedback (section 5.4)
68#define ISO_14755_MASK 0x0fffffffUL
67 69
70#if ISO_14755
68static unsigned short iso14755_symtab[] = { 71static unsigned short iso14755_symtab[] = {
69 // keysym, unicode 72 // keysym, unicode
70 XK_Left, 0x2190, 73 XK_Left, 0x2190,
71 XK_KP_Left, 0x2190, 74 XK_KP_Left, 0x2190,
72 XK_Up, 0x2191, 75 XK_Up, 0x2191,
115 XK_KP_Space, 0x2422, 118 XK_KP_Space, 0x2422,
116 0, 119 0,
117}; 120};
118 121
119void 122void
123rxvt_term::iso14755_54 (int x, int y)
124{
125 x = Pixel2Col (x);
126 y = Pixel2Row (y);
127
128 if (x < 0 || x >= TermWin.ncol
129 || y < 0 || y >= TermWin.nrow)
130 return;
131
132 for (;;)
133 {
134 text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x];
135
136 if (t != NOCHAR || !x)
137 {
138 iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x]);
139 iso14755buf = ISO_14755_54;
140 break;
141 }
142
143 x--;
144 }
145
146}
147#endif
148
149#if ENABLE_OVERLAY
150void
151rxvt_term::iso14755_51 (wchar_t ch)
152{
153 wchar_t *chr, *alloc;
154 int len;
155
156#if ENABLE_COMBINING
157 if (IS_COMPOSE (ch))
158 {
159 len = rxvt_composite.expand (ch, 0);
160 alloc = chr = new wchar_t[len];
161 rxvt_composite.expand (ch, chr);
162 }
163 else
164#endif
165 {
166 alloc = 0;
167 chr = &ch;
168 len = 1;
169 }
170
171 scr_overlay_new (0, -1, 8 + 5, len);
172
173 for (int y = 0; y < len; y++)
174 {
175 char buf[9];
176
177 ch = *chr++;
178
179 sprintf (buf, "%8x", ch);
180 scr_overlay_set (0, y, buf);
181 scr_overlay_set (9, y, '=');
182#if !UNICODE3
183 if (ch >= 0x10000)
184 ch = 0xfffd;
185#endif
186 scr_overlay_set (11, y, ch);
187 scr_overlay_set (12, y, NOCHAR);
188 }
189
190#if ENABLE_COMBINING
191 if (alloc)
192 delete [] alloc;
193#endif
194}
195#endif
196
197void
120rxvt_term::commit_iso14755 () 198rxvt_term::commit_iso14755 ()
121{ 199{
122 wchar_t ch[2]; 200 wchar_t ch[2];
123 201
124 ch[0] = iso14755buf & 0x1fffffffUL; // actually, unicode needs a 0x1fffff mask 202 ch[0] = iso14755buf & ISO_14755_MASK;
125 ch[1] = 0; 203 ch[1] = 0;
126 204
127 if (iso14755buf & ISO_14755_KEYCODE_VALID) 205 if (iso14755buf & ISO_14755_51)
128 { 206 {
129 char mb[16]; 207 char mb[16];
130 int len; 208 int len;
131 209
132 // allow verbatim 0-bytes and control-bytes to be entered 210 // allow verbatim 0-bytes and control-bytes to be entered
320 if (keysym >= XK_F1 && keysym <= XK_F10) 398 if (keysym >= XK_F1 && keysym <= XK_F10)
321 { 399 {
322 keysym += (XK_F11 - XK_F1); 400 keysym += (XK_F11 - XK_F1);
323 shft = 0; /* turn off Shift */ 401 shft = 0; /* turn off Shift */
324 } 402 }
325 else if (!ctrl && !meta && (PrivateModes & PrivMode_ShiftKeys)) 403 else if (!ctrl && !meta && (priv_modes & PrivMode_ShiftKeys))
326 { 404 {
327 switch (keysym) 405 switch (keysym)
328 { 406 {
329 /* normal XTerm key bindings */ 407 /* normal XTerm key bindings */
330 case XK_Insert: /* Shift+Insert = paste mouse selection */ 408 case XK_Insert: /* Shift+Insert = paste mouse selection */
341#endif 419#endif
342 } 420 }
343 } 421 }
344 } 422 }
345 423
346#ifndef NO_FRILLS 424#if ENABLE_FRILLS || ISO_14755
347 // ISO 14755 support 425 // ISO 14755 support
348 if (shft && ctrl) 426 if (shft && ctrl)
349 { 427 {
350 int hv; 428 int hv;
351 429
430 if (iso14755buf & ISO_14755_51
352 if (keysym == XK_space || keysym == XK_KP_Space 431 && (keysym == XK_space || keysym == XK_KP_Space
353 || keysym == XK_Return || keysym == XK_KP_Enter) 432 || keysym == XK_Return || keysym == XK_KP_Enter))
354 { 433 {
355 commit_iso14755 (); 434 commit_iso14755 ();
435 iso14755buf = ISO_14755_51;
436# if ISO_14755
437 iso14755_51 (0);
438# endif
356 return; 439 return;
357 } 440 }
358 else if ((hv = hex_keyval (ev)) >= 0) 441 else if ((hv = hex_keyval (ev)) >= 0)
359 { 442 {
360 iso14755buf = (iso14755buf << 4) | hv | ISO_14755_KEYCODE_VALID; 443 iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK)
444 | hv | ISO_14755_51;
445# if ISO_14755
446 iso14755_51 (iso14755buf & ISO_14755_MASK);
447# endif
361 return; 448 return;
362 } 449 }
363 else 450 else
451 {
452# if ENABLE_OVERLAY
453 scr_overlay_off ();
454# endif
364 iso14755buf = 0; 455 iso14755buf = 0;
456 }
365 } 457 }
366 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) 458 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R))
367 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) 459 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R)))
460 if (!(iso14755buf & ISO_14755_STARTED))
461 {
368 iso14755buf |= ISO_14755_ACTIVE; 462 iso14755buf |= ISO_14755_STARTED;
463# if ENABLE_OVERLAY
464 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1);
465 scr_overlay_set (0, 0, "ISO 14755 mode");
466# endif
467 }
369#endif 468#endif
370 469
371#ifdef PRINTPIPE 470#ifdef PRINTPIPE
372 if (keysym == XK_Print) 471 if (keysym == XK_Print)
373 { 472 {
407 newlen = 1; 506 newlen = 1;
408 switch (keysym) 507 switch (keysym)
409 { 508 {
410#ifndef NO_BACKSPACE_KEY 509#ifndef NO_BACKSPACE_KEY
411 case XK_BackSpace: 510 case XK_BackSpace:
412 if (PrivateModes & PrivMode_HaveBackSpace) 511 if (priv_modes & PrivMode_HaveBackSpace)
413 { 512 {
414 kbuf[0] = (!! (PrivateModes & PrivMode_BackSpace) 513 kbuf[0] = (!! (priv_modes & PrivMode_BackSpace)
415 ^ !!ctrl) ? '\b' : '\177'; 514 ^ !!ctrl) ? '\b' : '\177';
416 kbuf[1] = '\0'; 515 kbuf[1] = '\0';
417 } 516 }
418 else 517 else
419 STRCPY (kbuf, key_backspace); 518 strcpy (kbuf, key_backspace);
420 break; 519 break;
421#endif 520#endif
422#ifndef NO_DELETE_KEY 521#ifndef NO_DELETE_KEY
423 case XK_Delete: 522 case XK_Delete:
424 STRCPY (kbuf, key_delete); 523 strcpy (kbuf, key_delete);
425 break; 524 break;
426#endif 525#endif
427 case XK_Tab: 526 case XK_Tab:
428 if (shft) 527 if (shft)
429 STRCPY (kbuf, "\033[Z"); 528 strcpy (kbuf, "\033[Z");
430 else 529 else
431 { 530 {
432#ifdef CTRL_TAB_MAKES_META 531#ifdef CTRL_TAB_MAKES_META
433 if (ctrl) 532 if (ctrl)
434 meta = 1; 533 meta = 1;
444#ifdef XK_KP_Left 543#ifdef XK_KP_Left
445 case XK_KP_Up: /* \033Ox or standard */ 544 case XK_KP_Up: /* \033Ox or standard */
446 case XK_KP_Down: /* \033Or or standard */ 545 case XK_KP_Down: /* \033Or or standard */
447 case XK_KP_Right: /* \033Ov or standard */ 546 case XK_KP_Right: /* \033Ov or standard */
448 case XK_KP_Left: /* \033Ot or standard */ 547 case XK_KP_Left: /* \033Ot or standard */
449 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) 548 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
450 { 549 {
451 STRCPY (kbuf, "\033OZ"); 550 strcpy (kbuf, "\033OZ");
452 kbuf[2] = "txvr"[keysym - XK_KP_Left]; 551 kbuf[2] = "txvr"[keysym - XK_KP_Left];
453 break; 552 break;
454 } 553 }
455 else 554 else
456 /* translate to std. cursor key */ 555 /* translate to std. cursor key */
459#endif 558#endif
460 case XK_Up: /* "\033[A" */ 559 case XK_Up: /* "\033[A" */
461 case XK_Down: /* "\033[B" */ 560 case XK_Down: /* "\033[B" */
462 case XK_Right: /* "\033[C" */ 561 case XK_Right: /* "\033[C" */
463 case XK_Left: /* "\033[D" */ 562 case XK_Left: /* "\033[D" */
464 STRCPY (kbuf, "\033[Z"); 563 strcpy (kbuf, "\033[Z");
465 kbuf[2] = "DACB"[keysym - XK_Left]; 564 kbuf[2] = "DACB"[keysym - XK_Left];
466 /* do Shift first */ 565 /* do Shift first */
467 if (shft) 566 if (shft)
468 kbuf[2] = "dacb"[keysym - XK_Left]; 567 kbuf[2] = "dacb"[keysym - XK_Left];
469 else if (ctrl) 568 else if (ctrl)
470 { 569 {
471 kbuf[1] = 'O'; 570 kbuf[1] = 'O';
472 kbuf[2] = "dacb"[keysym - XK_Left]; 571 kbuf[2] = "dacb"[keysym - XK_Left];
473 } 572 }
474 else if (PrivateModes & PrivMode_aplCUR) 573 else if (priv_modes & PrivMode_aplCUR)
475 kbuf[1] = 'O'; 574 kbuf[1] = 'O';
476 break; 575 break;
477 576
478#ifndef UNSHIFTED_SCROLLKEYS 577#ifndef UNSHIFTED_SCROLLKEYS
479# ifdef XK_KP_Prior 578# ifdef XK_KP_Prior
480 case XK_KP_Prior: 579 case XK_KP_Prior:
481 /* allow shift to override */ 580 /* allow shift to override */
482 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) 581 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
483 { 582 {
484 STRCPY (kbuf, "\033Oy"); 583 strcpy (kbuf, "\033Oy");
485 break; 584 break;
486 } 585 }
487 /* FALLTHROUGH */ 586 /* FALLTHROUGH */
488# endif 587# endif
489 case XK_Prior: 588 case XK_Prior:
490 STRCPY (kbuf, "\033[5~"); 589 strcpy (kbuf, "\033[5~");
491 break; 590 break;
492# ifdef XK_KP_Next 591# ifdef XK_KP_Next
493 case XK_KP_Next: 592 case XK_KP_Next:
494 /* allow shift to override */ 593 /* allow shift to override */
495 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) 594 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
496 { 595 {
497 STRCPY (kbuf, "\033Os"); 596 strcpy (kbuf, "\033Os");
498 break; 597 break;
499 } 598 }
500 /* FALLTHROUGH */ 599 /* FALLTHROUGH */
501# endif 600# endif
502 case XK_Next: 601 case XK_Next:
503 STRCPY (kbuf, "\033[6~"); 602 strcpy (kbuf, "\033[6~");
504 break; 603 break;
505#endif 604#endif
506 case XK_KP_Enter: 605 case XK_KP_Enter:
507 /* allow shift to override */ 606 /* allow shift to override */
508 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) 607 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
509 { 608 {
510 STRCPY (kbuf, "\033OM"); 609 strcpy (kbuf, "\033OM");
610 break;
611 }
612
613 /* FALLTHROUGH */
614
615 case XK_Return:
616 if (priv_modes & PrivMode_LFNL)
617 {
618 kbuf[0] = '\015';
619 kbuf[1] = '\012';
620 kbuf[2] = '\0';
511 } 621 }
512 else 622 else
513 { 623 {
514 kbuf[0] = '\r'; 624 kbuf[0] = '\015';
515 kbuf[1] = '\0'; 625 kbuf[1] = '\0';
516 } 626 }
517 break; 627 break;
518 628
519#ifdef XK_KP_Begin 629#ifdef XK_KP_Begin
520 case XK_KP_Begin: 630 case XK_KP_Begin:
521 STRCPY (kbuf, "\033Ou"); 631 strcpy (kbuf, "\033Ou");
522 break; 632 break;
523 633
524 case XK_KP_Insert: 634 case XK_KP_Insert:
525 STRCPY (kbuf, "\033Op"); 635 strcpy (kbuf, "\033Op");
526 break; 636 break;
527 637
528 case XK_KP_Delete: 638 case XK_KP_Delete:
529 STRCPY (kbuf, "\033On"); 639 strcpy (kbuf, "\033On");
530 break; 640 break;
531#endif 641#endif
532 case XK_KP_F1: /* "\033OP" */ 642 case XK_KP_F1: /* "\033OP" */
533 case XK_KP_F2: /* "\033OQ" */ 643 case XK_KP_F2: /* "\033OQ" */
534 case XK_KP_F3: /* "\033OR" */ 644 case XK_KP_F3: /* "\033OR" */
535 case XK_KP_F4: /* "\033OS" */ 645 case XK_KP_F4: /* "\033OS" */
536 STRCPY (kbuf, "\033OP"); 646 strcpy (kbuf, "\033OP");
537 kbuf[2] += (keysym - XK_KP_F1); 647 kbuf[2] += (keysym - XK_KP_F1);
538 break; 648 break;
539 649
540 case XK_KP_Multiply: /* "\033Oj" : "*" */ 650 case XK_KP_Multiply: /* "\033Oj" : "*" */
541 case XK_KP_Add: /* "\033Ok" : "+" */ 651 case XK_KP_Add: /* "\033Ok" : "+" */
552 case XK_KP_6: /* "\033Ov" : "6" */ 662 case XK_KP_6: /* "\033Ov" : "6" */
553 case XK_KP_7: /* "\033Ow" : "7" */ 663 case XK_KP_7: /* "\033Ow" : "7" */
554 case XK_KP_8: /* "\033Ox" : "8" */ 664 case XK_KP_8: /* "\033Ox" : "8" */
555 case XK_KP_9: /* "\033Oy" : "9" */ 665 case XK_KP_9: /* "\033Oy" : "9" */
556 /* allow shift to override */ 666 /* allow shift to override */
557 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) 667 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
558 { 668 {
559 STRCPY (kbuf, "\033Oj"); 669 strcpy (kbuf, "\033Oj");
560 kbuf[2] += (keysym - XK_KP_Multiply); 670 kbuf[2] += (keysym - XK_KP_Multiply);
561 } 671 }
562 else 672 else
563 { 673 {
564 kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); 674 kbuf[0] = ('*' + (keysym - XK_KP_Multiply));
565 kbuf[1] = '\0'; 675 kbuf[1] = '\0';
566 } 676 }
567 break; 677 break;
568 678
569 case XK_Find: 679 case XK_Find:
570 STRCPY (kbuf, "\033[1~"); 680 strcpy (kbuf, "\033[1~");
571 break; 681 break;
572 case XK_Insert: 682 case XK_Insert:
573 STRCPY (kbuf, "\033[2~"); 683 strcpy (kbuf, "\033[2~");
574 break; 684 break;
575#ifdef DXK_Remove /* support for DEC remove like key */ 685#ifdef DXK_Remove /* support for DEC remove like key */
576 case DXK_Remove: 686 case DXK_Remove:
577 /* FALLTHROUGH */ 687 /* FALLTHROUGH */
578#endif 688#endif
579 case XK_Execute: 689 case XK_Execute:
580 STRCPY (kbuf, "\033[3~"); 690 strcpy (kbuf, "\033[3~");
581 break; 691 break;
582 case XK_Select: 692 case XK_Select:
583 STRCPY (kbuf, "\033[4~"); 693 strcpy (kbuf, "\033[4~");
584 break; 694 break;
585#ifdef XK_KP_End 695#ifdef XK_KP_End
586 case XK_KP_End: 696 case XK_KP_End:
587 /* allow shift to override */ 697 /* allow shift to override */
588 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) 698 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
589 { 699 {
590 STRCPY (kbuf, "\033Oq"); 700 strcpy (kbuf, "\033Oq");
591 break; 701 break;
592 } 702 }
593 /* FALLTHROUGH */ 703 /* FALLTHROUGH */
594#endif 704#endif
595 case XK_End: 705 case XK_End:
596 STRCPY (kbuf, KS_END); 706 strcpy (kbuf, KS_END);
597 break; 707 break;
598#ifdef XK_KP_Home 708#ifdef XK_KP_Home
599 case XK_KP_Home: 709 case XK_KP_Home:
600 /* allow shift to override */ 710 /* allow shift to override */
601 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) 711 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
602 { 712 {
603 STRCPY (kbuf, "\033Ow"); 713 strcpy (kbuf, "\033Ow");
604 break; 714 break;
605 } 715 }
606 /* FALLTHROUGH */ 716 /* FALLTHROUGH */
607#endif 717#endif
608 case XK_Home: 718 case XK_Home:
609 STRCPY (kbuf, KS_HOME); 719 strcpy (kbuf, KS_HOME);
610 break; 720 break;
611 721
612#define FKEY(n, fkey) \ 722#define FKEY(n, fkey) \
613 sprintf ((char *)kbuf,"\033[%2d~", (int) ((n) + (keysym - fkey))) 723 sprintf ((char *)kbuf,"\033[%2d~", (int) ((n) + (keysym - fkey)))
614 724
667 default: 777 default:
668 newlen = 0; 778 newlen = 0;
669 break; 779 break;
670 } 780 }
671 if (newlen) 781 if (newlen)
672 len = STRLEN (kbuf); 782 len = strlen (kbuf);
673 } 783 }
674 784
675 /* 785 /*
676 * Pass meta for all function keys, if 'meta' option set 786 * Pass meta for all function keys, if 'meta' option set
677 */ 787 */
705 } 815 }
706 816
707 if (len <= 0) 817 if (len <= 0)
708 return; /* not mapped */ 818 return; /* not mapped */
709 819
710 if (Options & Opt_scrollTtyKeypress) 820 if (options & Opt_scrollTtyKeypress)
711 if (TermWin.view_start) 821 if (TermWin.view_start)
712 { 822 {
713 TermWin.view_start = 0; 823 TermWin.view_start = 0;
714 want_refresh = 1; 824 want_refresh = 1;
715 } 825 }
764 n = cmdbuf_ptr - cmdbuf_base; 874 n = cmdbuf_ptr - cmdbuf_base;
765 s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; 875 s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp;
766 876
767 if (n > 0 && s < count) 877 if (n > 0 && s < count)
768 { 878 {
769 MEMMOVE (cmdbuf_base, cmdbuf_ptr, 879 memmove (cmdbuf_base, cmdbuf_ptr,
770 (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); 880 (unsigned int) (cmdbuf_endp - cmdbuf_ptr));
771 cmdbuf_ptr = cmdbuf_base; 881 cmdbuf_ptr = cmdbuf_base;
772 cmdbuf_endp -= n; 882 cmdbuf_endp -= n;
773 s += n; 883 s += n;
774 } 884 }
917 1027
918 memmove (cmdbuf_base, cmdbuf_ptr, n); 1028 memmove (cmdbuf_base, cmdbuf_ptr, n);
919 cmdbuf_ptr = cmdbuf_base; 1029 cmdbuf_ptr = cmdbuf_base;
920 cmdbuf_endp = cmdbuf_ptr + n; 1030 cmdbuf_endp = cmdbuf_ptr + n;
921 1031
922 n = read (cmd_fd, cmdbuf_endp, CBUFSIZ - n); 1032 n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n);
923 1033
924 if (n > 0) 1034 if (n > 0)
925 { 1035 {
926 cmdbuf_endp += n; 1036 cmdbuf_endp += n;
927 return true; 1037 return true;
954 recolour_cursor (); 1064 recolour_cursor ();
955 1065
956#ifdef POINTER_BLANK 1066#ifdef POINTER_BLANK
957 hidden_pointer = 0; 1067 hidden_pointer = 0;
958 1068
959 if (Options & Opt_pointerBlank) 1069 if (options & Opt_pointerBlank)
960 pointer_ev.start (NOW + pointerBlankDelay); 1070 pointer_ev.start (NOW + pointerBlankDelay);
961#endif 1071#endif
962} 1072}
963 1073
964#ifdef POINTER_BLANK 1074#ifdef POINTER_BLANK
965void 1075void
966rxvt_term::pointer_blank () 1076rxvt_term::pointer_blank ()
967{ 1077{
968 if (! (Options & Opt_pointerBlank)) 1078 if (! (options & Opt_pointerBlank))
969 return; 1079 return;
970 1080
971 XDefineCursor (display->display, TermWin.vt, blank_cursor); 1081 XDefineCursor (display->display, TermWin.vt, blank_cursor);
972 XFlush (display->display); 1082 XFlush (display->display);
973 1083
993 x = ev.x; 1103 x = ev.x;
994 y = ev.y; 1104 y = ev.y;
995 pixel_position (&x, &y); 1105 pixel_position (&x, &y);
996 1106
997 if (MEvent.button == AnyButton) 1107 if (MEvent.button == AnyButton)
998 {
999 button_number = 3; 1108 button_number = 3;
1000 }
1001 else 1109 else
1002 { 1110 {
1003 button_number = MEvent.button - Button1; 1111 button_number = MEvent.button - Button1;
1004 /* add 0x3D for wheel events, like xterm does */ 1112 /* add 0x3D for wheel events, like xterm does */
1005 if (button_number >= 3) 1113 if (button_number >= 3)
1006 button_number += (64 - 3); 1114 button_number += (64 - 3);
1007 } 1115 }
1008 1116
1009 if (PrivateModes & PrivMode_MouseX10) 1117 if (priv_modes & PrivMode_MouseX10)
1010 { 1118 {
1011 /* 1119 /*
1012 * do not report ButtonRelease 1120 * do not report ButtonRelease
1013 * no state info allowed 1121 * no state info allowed
1014 */ 1122 */
1072{ 1180{
1073 SET_R (this); 1181 SET_R (this);
1074 SET_LOCALE (locale); 1182 SET_LOCALE (locale);
1075 1183
1076#if defined(CURSOR_BLINK) 1184#if defined(CURSOR_BLINK)
1077 if ((Options & Opt_cursorBlink) && ev.type == KeyPress) 1185 if ((options & Opt_cursorBlink) && ev.type == KeyPress)
1078 { 1186 {
1079 if (hidden_cursor) 1187 if (hidden_cursor)
1080 { 1188 {
1081 hidden_cursor = 0; 1189 hidden_cursor = 0;
1082 want_refresh = 1; 1190 want_refresh = 1;
1085 cursor_blink_ev.start (NOW + BLINK_INTERVAL); 1193 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1086 } 1194 }
1087#endif 1195#endif
1088 1196
1089#if defined(POINTER_BLANK) 1197#if defined(POINTER_BLANK)
1090 if ((Options & Opt_pointerBlank) && pointerBlankDelay > 0) 1198 if ((options & Opt_pointerBlank) && pointerBlankDelay > 0)
1091 { 1199 {
1092 if (ev.type == MotionNotify 1200 if (ev.type == MotionNotify
1093 || ev.type == ButtonPress 1201 || ev.type == ButtonPress
1094 || ev.type == ButtonRelease) 1202 || ev.type == ButtonRelease)
1095 if (hidden_pointer) 1203 if (hidden_pointer)
1107 1215
1108 Window unused_root, unused_child; 1216 Window unused_root, unused_child;
1109 int unused_root_x, unused_root_y; 1217 int unused_root_x, unused_root_y;
1110 unsigned int unused_mask; 1218 unsigned int unused_mask;
1111 1219
1112#ifdef DEBUG_X
1113 const char *const eventnames[] =
1114 { /* mason - this matches my system */
1115 "",
1116 "",
1117 "KeyPress",
1118 "KeyRelease",
1119 "ButtonPress",
1120 "ButtonRelease",
1121 "MotionNotify",
1122 "EnterNotify",
1123 "LeaveNotify",
1124 "FocusIn",
1125 "FocusOut",
1126 "KeymapNotify",
1127 "Expose",
1128 "GraphicsExpose",
1129 "NoExpose",
1130 "VisibilityNotify",
1131 "CreateNotify",
1132 "DestroyNotify",
1133 "UnmapNotify",
1134 "MapNotify",
1135 "MapRequest",
1136 "ReparentNotify",
1137 "ConfigureNotify",
1138 "ConfigureRequest",
1139 "GravityNotify",
1140 "ResizeRequest",
1141 "CirculateNotify",
1142 "CirculateRequest",
1143 "PropertyNotify",
1144 "SelectionClear",
1145 "SelectionRequest",
1146 "SelectionNotify",
1147 "ColormapNotify",
1148 "ClientMessage",
1149 "MappingNotify"
1150 };
1151#endif
1152
1153#ifdef DEBUG_X
1154 struct timeval tp;
1155 struct tm *ltt;
1156 (void)gettimeofday (&tp, NULL);
1157 ltt = localtime (& (tp.tv_sec));
1158 D_X ((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev.type], (ev.xany.window == TermWin.parent[0] ? "parent" : (ev.xany.window == TermWin.vt ? "vt" : (ev.xany.window == scrollBar.win ? "scroll" : (ev.xany.window == menuBar.win ? "menubar" : "UNKNOWN")))), (ev.xany.window == TermWin.parent[0] ? TermWin.parent[0] : (ev.xany.window == TermWin.vt ? TermWin.vt : (ev.xany.window == scrollBar.win ? scrollBar.win : (ev.xany.window == menuBar.win ? menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev.xany.send_event ? "S" : " ", ev.xany.serial));
1159#endif
1160
1161 switch (ev.type) 1220 switch (ev.type)
1162 { 1221 {
1163 case KeyPress: 1222 case KeyPress:
1223#if ISO_14755
1164 if (!(iso14755buf & ISO_14755_ESCAPE_NEXT)) 1224 if (!(iso14755buf & ISO_14755_52))
1225#endif
1165 lookup_key (ev.xkey); 1226 lookup_key (ev.xkey);
1166 1227
1167 break; 1228 break;
1168 1229
1169 case KeyRelease: 1230 case KeyRelease:
1170 { 1231 {
1171#if (defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)) || !defined (NO_FRILLS) 1232#if (defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)) || defined (ENABLE_FRILLS)
1172 KeySym ks; 1233 KeySym ks;
1173 1234
1174 ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ 1235 ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
1175#endif 1236#endif
1176 1237
1177#ifndef NO_FRILLS 1238#if ENABLE_FRILLS || ISO_14755
1178 // ISO 14755 support 1239 // ISO 14755 support
1179 if (iso14755buf) 1240 if (iso14755buf)
1180 if (iso14755buf & ISO_14755_ESCAPE_NEXT) 1241 if (iso14755buf & ISO_14755_52)
1181 { 1242 {
1243# if ENABLE_OVERLAY
1244 scr_overlay_off ();
1245# endif
1246# if ISO_14755
1182 // iso14755 part 5.2 handling: release time 1247 // iso14755 part 5.2 handling: release time
1183 // first: controls 1248 // first: controls
1184 if ((ev.xkey.state & ControlMask) 1249 if ((ev.xkey.state & ControlMask)
1185 && ((ks >= 0x40 && ks <= 0x5f) 1250 && ((ks >= 0x40 && ks <= 0x5f)
1186 || (ks >= 0x61 && ks <= 0x7f))) 1251 || (ks >= 0x61 && ks <= 0x7f)))
1187 { 1252 {
1188 iso14755buf = ISO_14755_KEYCODE_VALID | 0x2400 | (ks & 0x1f); 1253 iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f);
1189 commit_iso14755 (); 1254 commit_iso14755 ();
1190 return; // case-break; 1255 return; // case-break;
1191 } 1256 }
1192 1257
1193 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) 1258 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2)
1194 if (i[0] == ks) 1259 if (i[0] == ks)
1195 { 1260 {
1196 iso14755buf = ISO_14755_KEYCODE_VALID | i[1]; 1261 iso14755buf = ISO_14755_51 | i[1];
1197 commit_iso14755 (); 1262 commit_iso14755 ();
1198 return; // case-break; 1263 return; // case-break;
1199 } 1264 }
1200 1265
1266 scr_bell ();
1267# endif
1201 iso14755buf = 0; 1268 iso14755buf = 0;
1202 scr_bell ();
1203 break; 1269 break;
1204 } 1270 }
1205 else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) 1271 else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask))
1206 { 1272 {
1273# if ENABLE_OVERLAY
1274 scr_overlay_off ();
1275# endif
1207 if (iso14755buf & ISO_14755_KEYCODE_VALID) 1276 if (iso14755buf & ISO_14755_51)
1208 commit_iso14755 (); 1277 commit_iso14755 ();
1278#if ISO_14755
1209 else if (iso14755buf & ISO_14755_ACTIVE) 1279 else if (iso14755buf & ISO_14755_STARTED)
1280 {
1210 iso14755buf = ISO_14755_ESCAPE_NEXT; // iso14755 part 5.2: remember empty begin/end pair 1281 iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair
1282
1283 scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1);
1284 scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE");
1285 }
1286# endif
1287 else
1288 iso14755buf = 0;
1211 } 1289 }
1212#endif 1290#endif
1213 1291
1214#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1292#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1215 if (!(ev.xkey.state & ControlMask)) 1293 if (!(ev.xkey.state & ControlMask))
1253 &Size, &RemainingBytes, 1331 &Size, &RemainingBytes,
1254 &data); 1332 &data);
1255 XChangeProperty (display->display, display->root, 1333 XChangeProperty (display->display, display->root,
1256 XA_CUT_BUFFER0, XA_STRING, 1334 XA_CUT_BUFFER0, XA_STRING,
1257 8, PropModeReplace, 1335 8, PropModeReplace,
1258 data, STRLEN (data)); 1336 data, strlen (data));
1259 XFree (data); 1337 XFree (data);
1260 selection_paste (display->root, XA_CUT_BUFFER0, True); 1338 selection_paste (display->root, XA_CUT_BUFFER0, True);
1261 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); 1339 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime);
1262 } 1340 }
1263#endif /* OFFIX_DND */ 1341#endif /* OFFIX_DND */
1297 { 1375 {
1298 TermWin.focus = 1; 1376 TermWin.focus = 1;
1299 want_refresh = 1; 1377 want_refresh = 1;
1300#ifdef USE_XIM 1378#ifdef USE_XIM
1301 if (Input_Context != NULL) 1379 if (Input_Context != NULL)
1380 {
1381 IMSetStatusPosition ();
1302 XSetICFocus (Input_Context); 1382 XSetICFocus (Input_Context);
1383 }
1303#endif 1384#endif
1304#ifdef CURSOR_BLINK 1385#ifdef CURSOR_BLINK
1305 if (Options & Opt_cursorBlink) 1386 if (options & Opt_cursorBlink)
1306 cursor_blink_ev.start (NOW + BLINK_INTERVAL); 1387 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1307#endif 1388#endif
1308#ifdef OFF_FOCUS_FADING 1389#ifdef OFF_FOCUS_FADING
1309 if (rs[Rs_fade]) 1390 if (rs[Rs_fade])
1310 { 1391 {
1311 PixColors = PixColorsFocused; 1392 pix_colors = pix_colors_focused;
1312 set_colorfgbg (); 1393 set_colorfgbg ();
1313 scr_clear (); 1394 scr_clear ();
1314 scr_touch (true); 1395 scr_touch (true);
1315 } 1396 }
1316#endif 1397#endif
1326#ifdef USE_XIM 1407#ifdef USE_XIM
1327 if (Input_Context != NULL) 1408 if (Input_Context != NULL)
1328 XUnsetICFocus (Input_Context); 1409 XUnsetICFocus (Input_Context);
1329#endif 1410#endif
1330#ifdef CURSOR_BLINK 1411#ifdef CURSOR_BLINK
1331 if (Options & Opt_cursorBlink) 1412 if (options & Opt_cursorBlink)
1332 cursor_blink_ev.stop (); 1413 cursor_blink_ev.stop ();
1333 hidden_cursor = 0; 1414 hidden_cursor = 0;
1334#endif 1415#endif
1335#ifdef OFF_FOCUS_FADING 1416#ifdef OFF_FOCUS_FADING
1336 if (rs[Rs_fade]) 1417 if (rs[Rs_fade])
1337 { 1418 {
1338 PixColors = PixColorsUnFocused; 1419 pix_colors = pix_colors_unfocused;
1339 set_colorfgbg (); 1420 set_colorfgbg ();
1340 scr_clear (); 1421 scr_clear ();
1341 scr_touch (true); 1422 scr_touch (true);
1342 } 1423 }
1343#endif 1424#endif
1360 1441
1361 if (szHint.width != width || szHint.height != height) 1442 if (szHint.width != width || szHint.height != height)
1362 resize_all_windows (width, height, 1); 1443 resize_all_windows (width, height, 1);
1363 1444
1364#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1445#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1365 if (Options & Opt_transparent) 1446 if (options & Opt_transparent)
1366 { 1447 {
1367 check_our_parents (); 1448 check_our_parents ();
1368 if (am_transparent) 1449 if (am_transparent)
1369 want_refresh = want_full_refresh = 1; 1450 want_refresh = want_full_refresh = 1;
1370 } 1451 }
1466 { 1547 {
1467 menubar_control (ev.xbutton); 1548 menubar_control (ev.xbutton);
1468 break; 1549 break;
1469 } 1550 }
1470#endif 1551#endif
1471 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) 1552 if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate))
1472 break; 1553 break;
1473 1554
1474 if (ev.xany.window == TermWin.vt) 1555 if (ev.xany.window == TermWin.vt)
1475 { 1556 {
1476 if ((ev.xbutton.state & (Button1Mask | Button3Mask))) 1557 if (ev.xbutton.state & (Button1Mask | Button3Mask))
1477 { 1558 {
1478 while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev)) 1559 while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev))
1479 ; 1560 ;
1480 1561
1481 XQueryPointer (display->display, TermWin.vt, 1562 XQueryPointer (display->display, TermWin.vt,
1482 &unused_root, &unused_child, 1563 &unused_root, &unused_child,
1483 &unused_root_x, &unused_root_y, 1564 &unused_root_x, &unused_root_y,
1484 & (ev.xbutton.x), & (ev.xbutton.y), 1565 & (ev.xbutton.x), & (ev.xbutton.y),
1485 &unused_mask); 1566 &unused_mask);
1486#ifdef MOUSE_THRESHOLD 1567#ifdef MOUSE_THRESHOLD
1487 /* deal with a `jumpy' mouse */ 1568 /* deal with a `jumpy' mouse */
1488 if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) 1569 if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD)
1489 { 1570 {
1490#endif 1571#endif
1572#if ISO_14755
1573 // 5.4
1574 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54))
1575 {
1576 iso14755_54 (ev.xbutton.x, ev.xbutton.y);
1577 break;
1578 }
1579#endif
1491 selection_extend ((ev.xbutton.x), (ev.xbutton.y), 1580 selection_extend (ev.xbutton.x, ev.xbutton.y,
1492 (ev.xbutton.state & Button3Mask) ? 2 : 0); 1581 (ev.xbutton.state & Button3Mask) ? 2 : 0);
1493#ifdef SELECTION_SCROLLING 1582#ifdef SELECTION_SCROLLING
1494 if (ev.xbutton.y < TermWin.int_bwidth 1583 if (ev.xbutton.y < TermWin.int_bwidth
1495 || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) 1584 || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1))
1496 { 1585 {
1503 sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); 1592 sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY);
1504 1593
1505 /* save the event params so we can highlight 1594 /* save the event params so we can highlight
1506 * the selection in the pending-scroll loop 1595 * the selection in the pending-scroll loop
1507 */ 1596 */
1508 selection_save_x=ev.xbutton.x; 1597 selection_save_x = ev.xbutton.x;
1509 selection_save_y=ev.xbutton.y; 1598 selection_save_y = ev.xbutton.y;
1510 selection_save_state=
1511 (ev.xbutton.state & Button3Mask) ? 2 : 0; 1599 selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0;
1512 1600
1513 /* calc number of lines to scroll */ 1601 /* calc number of lines to scroll */
1514 if (ev.xbutton.y<TermWin.int_bwidth) 1602 if (ev.xbutton.y<TermWin.int_bwidth)
1515 { 1603 {
1516 scroll_selection_dir = UP; 1604 scroll_selection_dir = UP;
1517 dist = TermWin.int_bwidth - ev.xbutton.y; 1605 dist = TermWin.int_bwidth - ev.xbutton.y;
1518 } 1606 }
1519 else 1607 else
1520 { 1608 {
1521 scroll_selection_dir = DN; 1609 scroll_selection_dir = DN;
1522 dist = ev.xbutton.y -
1523 (TermWin.int_bwidth + TermWin.height); 1610 dist = ev.xbutton.y - (TermWin.int_bwidth + TermWin.height);
1524 } 1611 }
1612
1525 scroll_selection_lines= (Pixel2Height (dist)/ 1613 scroll_selection_lines = Pixel2Height (dist)
1526 SELECTION_SCROLL_LINE_SPEEDUP)+1; 1614 / SELECTION_SCROLL_LINE_SPEEDUP
1615 + 1;
1527 MIN_IT (scroll_selection_lines, 1616 MIN_IT (scroll_selection_lines,
1528 SELECTION_SCROLL_MAX_LINES); 1617 SELECTION_SCROLL_MAX_LINES);
1529 } 1618 }
1530 else 1619 else
1531 { 1620 {
1532 /* we are within the text window, so we 1621 /* we are within the text window, so we
1533 * shouldn't be scrolling 1622 * shouldn't be scrolling
1535 if (sel_scroll_ev.active) 1624 if (sel_scroll_ev.active)
1536 sel_scroll_ev.stop(); 1625 sel_scroll_ev.stop();
1537 } 1626 }
1538#endif 1627#endif
1539#ifdef MOUSE_THRESHOLD 1628#ifdef MOUSE_THRESHOLD
1540
1541 } 1629 }
1542#endif 1630#endif
1543
1544 } 1631 }
1545 } 1632 }
1546 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) 1633 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ())
1547 { 1634 {
1548 while (XCheckTypedWindowEvent (display->display, scrollBar.win, 1635 while (XCheckTypedWindowEvent (display->display, scrollBar.win,
1549 MotionNotify, &ev)) ; 1636 MotionNotify, &ev)) ;
1550 XQueryPointer (display->display, scrollBar.win, 1637 XQueryPointer (display->display, scrollBar.win,
1551 &unused_root, &unused_child, 1638 &unused_root, &unused_child,
1552 &unused_root_x, &unused_root_y, 1639 &unused_root_x, &unused_root_y,
1553 & (ev.xbutton.x), & (ev.xbutton.y), 1640 & (ev.xbutton.x), & (ev.xbutton.y),
1554 &unused_mask); 1641 &unused_mask);
1582 if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) 1669 if (ev.xproperty.atom != xa[XA_XROOTPMAPID])
1583 return; 1670 return;
1584 1671
1585 /* FALLTHROUGH */ 1672 /* FALLTHROUGH */
1586 case ReparentNotify: 1673 case ReparentNotify:
1587 if ((Options & Opt_transparent) && check_our_parents () && am_transparent) 1674 if ((options & Opt_transparent) && check_our_parents () && am_transparent)
1588 want_refresh = want_full_refresh = 1; 1675 want_refresh = want_full_refresh = 1;
1589 break; 1676 break;
1590 } 1677 }
1591} 1678}
1592#endif 1679#endif
1596{ 1683{
1597 int reportmode = 0, clickintime; 1684 int reportmode = 0, clickintime;
1598 1685
1599 bypass_keystate = ev.state & (ModMetaMask | ShiftMask); 1686 bypass_keystate = ev.state & (ModMetaMask | ShiftMask);
1600 if (!bypass_keystate) 1687 if (!bypass_keystate)
1601 reportmode = !! (PrivateModes & PrivMode_mouse_report); 1688 reportmode = !! (priv_modes & PrivMode_mouse_report);
1689
1602 /* 1690 /*
1603 * VT window processing of button press 1691 * VT window processing of button press
1604 */ 1692 */
1605 if (ev.window == TermWin.vt) 1693 if (ev.window == TermWin.vt)
1606 { 1694 {
1695#if ISO_14755
1696 // 5.4
1697 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54))
1698 {
1699 iso14755_54 (ev.x, ev.y);
1700 return;
1701 }
1702#endif
1703
1607 clickintime = ev.time - MEvent.time < MULTICLICK_TIME; 1704 clickintime = ev.time - MEvent.time < MULTICLICK_TIME;
1608 if (reportmode) 1705 if (reportmode)
1609 { 1706 {
1610 /* mouse report from vt window */ 1707 /* mouse report from vt window */
1611 /* save the xbutton state (for ButtonRelease) */ 1708 /* save the xbutton state (for ButtonRelease) */
1645 MEvent.clicks = 0; 1742 MEvent.clicks = 0;
1646 switch (ev.button) 1743 switch (ev.button)
1647 { 1744 {
1648 case Button1: 1745 case Button1:
1649 /* allow shift+left click to extend selection */ 1746 /* allow shift+left click to extend selection */
1650 if (ev.state & ShiftMask && ! (PrivateModes & PrivMode_mouse_report)) 1747 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report))
1651 { 1748 {
1652 if (MEvent.button == Button1 && clickintime) 1749 if (MEvent.button == Button1 && clickintime)
1653 selection_rotate (ev.x, ev.y); 1750 selection_rotate (ev.x, ev.y);
1654 else 1751 else
1655 selection_extend (ev.x, ev.y, 1); 1752 selection_extend (ev.x, ev.y, 1);
1670 case Button3: 1767 case Button3:
1671 if (MEvent.button == Button3 && clickintime) 1768 if (MEvent.button == Button3 && clickintime)
1672 selection_rotate (ev.x, ev.y); 1769 selection_rotate (ev.x, ev.y);
1673 else 1770 else
1674 selection_extend (ev.x, ev.y, 1); 1771 selection_extend (ev.x, ev.y, 1);
1772
1675 MEvent.button = Button3; 1773 MEvent.button = Button3;
1676 break; 1774 break;
1677 } 1775 }
1678 } 1776 }
1777
1679 MEvent.time = ev.time; 1778 MEvent.time = ev.time;
1680 return; 1779 return;
1681 } 1780 }
1682 1781
1683 /* 1782 /*
1836{ 1935{
1837 int reportmode = 0; 1936 int reportmode = 0;
1838 1937
1839 csrO = 0; /* reset csr Offset */ 1938 csrO = 0; /* reset csr Offset */
1840 if (!bypass_keystate) 1939 if (!bypass_keystate)
1841 reportmode = !! (PrivateModes & PrivMode_mouse_report); 1940 reportmode = !! (priv_modes & PrivMode_mouse_report);
1842 1941
1843 if (scrollbar_isUpDn ()) 1942 if (scrollbar_isUpDn ())
1844 { 1943 {
1845 scrollBar.setIdle (); 1944 scrollBar.setIdle ();
1846 scrollbar_show (0); 1945 scrollbar_show (0);
1847#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1946#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1848 refresh_type &= ~SMOOTH_REFRESH; 1947 refresh_type &= ~SMOOTH_REFRESH;
1849#endif 1948#endif
1850
1851 } 1949 }
1950
1852#ifdef SELECTION_SCROLLING 1951#ifdef SELECTION_SCROLLING
1853 if (sel_scroll_ev.active) 1952 if (sel_scroll_ev.active)
1854 sel_scroll_ev.stop(); 1953 sel_scroll_ev.stop();
1855#endif 1954#endif
1955
1856 if (ev.window == TermWin.vt) 1956 if (ev.window == TermWin.vt)
1857 { 1957 {
1958#if ISO_14755
1959 // 5.4
1960 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54))
1961 return;
1962#endif
1858 if (reportmode) 1963 if (reportmode)
1859 { 1964 {
1860 /* mouse report from vt window */ 1965 /* mouse report from vt window */
1861 /* don't report release of wheel "buttons" */ 1966 /* don't report release of wheel "buttons" */
1862 if (ev.button >= 4) 1967 if (ev.button >= 4)
1876 MEvent.button = AnyButton; 1981 MEvent.button = AnyButton;
1877 mouse_report (ev); 1982 mouse_report (ev);
1878#endif /* MOUSE_REPORT_DOUBLECLICK */ 1983#endif /* MOUSE_REPORT_DOUBLECLICK */
1879 return; 1984 return;
1880 } 1985 }
1986
1881 /* 1987 /*
1882 * dumb hack to compensate for the failure of click-and-drag 1988 * dumb hack to compensate for the failure of click-and-drag
1883 * when overriding mouse reporting 1989 * when overriding mouse reporting
1884 */ 1990 */
1885 if (PrivateModes & PrivMode_mouse_report 1991 if (priv_modes & PrivMode_mouse_report
1886 && bypass_keystate 1992 && bypass_keystate
1887 && ev.button == Button1 && MEvent.clicks <= 1) 1993 && ev.button == Button1 && MEvent.clicks <= 1)
1888 selection_extend (ev.x, ev.y, 0); 1994 selection_extend (ev.x, ev.y, 0);
1889 1995
1890 switch (ev.button) 1996 switch (ev.button)
1905 2011
1906 v = ev.button == Button4 ? UP : DN; 2012 v = ev.button == Button4 ? UP : DN;
1907 2013
1908 if (ev.state & ShiftMask) 2014 if (ev.state & ShiftMask)
1909 i = 1; 2015 i = 1;
1910 else if (Options & Opt_mouseWheelScrollPage) 2016 else if (options & Opt_mouseWheelScrollPage)
1911 i = TermWin.nrow - 1; 2017 i = TermWin.nrow - 1;
1912 else 2018 else
1913 i = 5; 2019 i = 5;
1914 2020
1915# ifdef MOUSE_SLIP_WHEELING 2021# ifdef MOUSE_SLIP_WHEELING
2200 Pixmap rootpixmap = None; 2306 Pixmap rootpixmap = None;
2201 XWindowAttributes wattr, wrootattr; 2307 XWindowAttributes wattr, wrootattr;
2202 2308
2203 pchanged = 0; 2309 pchanged = 0;
2204 2310
2205 if (!(Options & Opt_transparent)) 2311 if (!(options & Opt_transparent))
2206 return pchanged; /* Don't try any more */ 2312 return pchanged; /* Don't try any more */
2207 2313
2208 XGetWindowAttributes (display->display, display->root, &wrootattr); 2314 XGetWindowAttributes (display->display, display->root, &wrootattr);
2209 rootdepth = wrootattr.depth; 2315 rootdepth = wrootattr.depth;
2210 2316
2213 if (rootdepth != wattr.depth) 2319 if (rootdepth != wattr.depth)
2214 { 2320 {
2215 if (am_transparent) 2321 if (am_transparent)
2216 { 2322 {
2217 pchanged = 1; 2323 pchanged = 1;
2218 XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]); 2324 XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]);
2219 am_transparent = am_pixmap_trans = 0; 2325 am_transparent = am_pixmap_trans = 0;
2220 } 2326 }
2221 2327
2222 return pchanged; /* Don't try any more */ 2328 return pchanged; /* Don't try any more */
2223 } 2329 }
2318 if (ISSET_PIXCOLOR (Color_tint)) 2424 if (ISSET_PIXCOLOR (Color_tint))
2319 { 2425 {
2320 unsigned short rm, gm, bm; 2426 unsigned short rm, gm, bm;
2321 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; 2427 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2322 2428
2323 PixColorsFocused[Color_tint].get (display, rm, gm, bm); 2429 pix_colors_focused[Color_tint].get (display, rm, gm, bm);
2324 2430
2325 ShadeXImage (display, image, shade, rm, gm, bm); 2431 ShadeXImage (display, image, shade, rm, gm, bm);
2326 } 2432 }
2327#endif 2433#endif
2328 2434
2347 { 2453 {
2348 unsigned int n; 2454 unsigned int n;
2349 /* 2455 /*
2350 * InheritPixmap transparency 2456 * InheritPixmap transparency
2351 */ 2457 */
2352 D_X ((stderr, "InheritPixmap Seeking to %08lx", display->root));
2353 for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2458 for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2354 { 2459 {
2355 oldp = TermWin.parent[i]; 2460 oldp = TermWin.parent[i];
2356 XQueryTree (display->display, TermWin.parent[i - 1], &root, 2461 XQueryTree (display->display, TermWin.parent[i - 1], &root,
2357 &TermWin.parent[i], &list, &n); 2462 &TermWin.parent[i], &list, &n);
2358 XFree (list); 2463 XFree (list);
2359 D_X ((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i]));
2360 2464
2361 if (TermWin.parent[i] == display->root) 2465 if (TermWin.parent[i] == display->root)
2362 { 2466 {
2363 if (oldp != None) 2467 if (oldp != None)
2364 pchanged = 1; 2468 pchanged = 1;
2375 if (pchanged) 2479 if (pchanged)
2376 { 2480 {
2377 for (; n < (unsigned int)i; n++) 2481 for (; n < (unsigned int)i; n++)
2378 { 2482 {
2379 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); 2483 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr);
2380 D_X ((stderr, "InheritPixmap Checking Parent[%d]: %s", n, (wattr.depth == rootdepth && wattr.class != InputOnly) ? "OK" : "FAIL"));
2381 if (wattr.depth != rootdepth || wattr.c_class == InputOnly) 2484 if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
2382 { 2485 {
2383 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; 2486 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1;
2384 break; 2487 break;
2385 } 2488 }
2386 } 2489 }
2387 } 2490 }
2388 2491
2389 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) 2492 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0])))
2390 { 2493 {
2391 D_X ((stderr, "InheritPixmap Turning off"));
2392 XSetWindowBackground (display->display, TermWin.parent[0], PixColorsFocused[Color_fg]); 2494 XSetWindowBackground (display->display, TermWin.parent[0], pix_colors_focused[Color_fg]);
2393 XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]); 2495 XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]);
2394 am_transparent = 0; 2496 am_transparent = 0;
2395 /* XXX: also turn off Opt_transparent? */ 2497 /* XXX: also turn off Opt_transparent? */
2396 } 2498 }
2397 else 2499 else
2398 { 2500 {
2399#if WAIT_FOR_WM 2501#if WAIT_FOR_WM
2400 /* wait (an arbitrary period) for the WM to do its thing 2502 /* wait (an arbitrary period) for the WM to do its thing
2401 * needed for fvwm2.2.2 (and before?) */ 2503 * needed for fvwm2.2.2 (and before?) */
2402 sleep (1); 2504 sleep (1);
2403#endif 2505#endif
2404 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1));
2405 for (n = 0; n < (unsigned int)i; n++) 2506 for (n = 0; n < (unsigned int)i; n++)
2406 { 2507 {
2407 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); 2508 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative);
2408 XClearWindow (display->display, TermWin.parent[n]); 2509 XClearWindow (display->display, TermWin.parent[n]);
2409 } 2510 }
2449 if (ch == NOCHAR) // TODO: improve 2550 if (ch == NOCHAR) // TODO: improve
2450 break; 2551 break;
2451 2552
2452 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) 2553 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)
2453 { 2554 {
2555 if (!seen_input)
2556 {
2557 seen_input = 1;
2558 // many badly-written programs (e.g. jed) contain a race condition:
2559 // they first read the screensize and then install a SIGWINCH handler.
2560 // some window managers resize the window early, and these programs
2561 // then sometimes get the size wrong.
2562 kill (-cmd_pid, SIGWINCH);
2563 }
2564
2454 /* Read a text string from the input buffer */ 2565 /* Read a text string from the input buffer */
2455 unicode_t buf[UBUFSIZ]; 2566 unicode_t buf[UBUFSIZ];
2456 bool refreshnow = false; 2567 bool refreshnow = false;
2457 int nlines = 0; 2568 int nlines = 0;
2458 unicode_t *str = buf; 2569 unicode_t *str = buf;
2467 if (ch == C0_LF) 2578 if (ch == C0_LF)
2468 { 2579 {
2469 nlines++; 2580 nlines++;
2470 refresh_count++; 2581 refresh_count++;
2471 2582
2472 if (!(Options & Opt_jumpScroll) 2583 if (!(options & Opt_jumpScroll)
2473 || (refresh_count >= refresh_limit * (TermWin.nrow - 1))) 2584 || (refresh_count >= refresh_limit * (TermWin.nrow - 1)))
2474 { 2585 {
2475 refreshnow = true; 2586 refreshnow = true;
2476 ch = NOCHAR; 2587 ch = NOCHAR;
2477 break; 2588 break;
2504 * the number of pages between refreshes is refresh_limit, which 2615 * the number of pages between refreshes is refresh_limit, which
2505 * is incremented here because we must be doing flat-out scrolling. 2616 * is incremented here because we must be doing flat-out scrolling.
2506 */ 2617 */
2507 if (refreshnow) 2618 if (refreshnow)
2508 { 2619 {
2509 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2620 if ((options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2510 refresh_limit++; 2621 refresh_limit++;
2511 else 2622 else
2512 { 2623 {
2513 flag = true; 2624 flag = true;
2514 scr_refresh (refresh_type); 2625 scr_refresh (refresh_type);
2704 process_escape_seq (); 2815 process_escape_seq ();
2705 break; 2816 break;
2706 case C0_ENQ: /* terminal Status */ 2817 case C0_ENQ: /* terminal Status */
2707 if (rs[Rs_answerbackstring]) 2818 if (rs[Rs_answerbackstring])
2708 tt_write ((const unsigned char *)rs[Rs_answerbackstring], 2819 tt_write ((const unsigned char *)rs[Rs_answerbackstring],
2709 (unsigned int)STRLEN (rs[Rs_answerbackstring])); 2820 (unsigned int)strlen (rs[Rs_answerbackstring]));
2710 else 2821 else
2711 tt_write ((unsigned char *)VT100_ANS, 2822 tt_write ((unsigned char *)VT100_ANS,
2712 (unsigned int)STRLEN (VT100_ANS)); 2823 (unsigned int)strlen (VT100_ANS));
2713 break; 2824 break;
2714 case C0_BEL: /* bell */ 2825 case C0_BEL: /* bell */
2715 scr_bell (); 2826 scr_bell ();
2716 break; 2827 break;
2717 case C0_BS: /* backspace */ 2828 case C0_BS: /* backspace */
2816void 2927void
2817rxvt_term::process_escape_seq () 2928rxvt_term::process_escape_seq ()
2818{ 2929{
2819 unicode_t ch = cmd_getc (); 2930 unicode_t ch = cmd_getc ();
2820 2931
2821 if (PrivateModes & PrivMode_vt52) 2932 if (priv_modes & PrivMode_vt52)
2822 { 2933 {
2823 process_escape_vt52 (ch); 2934 process_escape_vt52 (ch);
2824 return; 2935 return;
2825 } 2936 }
2826 2937
2841 scr_charset_set (2, (unsigned int)cmd_getc ()); 2952 scr_charset_set (2, (unsigned int)cmd_getc ());
2842 break; 2953 break;
2843 case '+': 2954 case '+':
2844 scr_charset_set (3, (unsigned int)cmd_getc ()); 2955 scr_charset_set (3, (unsigned int)cmd_getc ());
2845 break; 2956 break;
2846#ifndef NO_FRILLS 2957#if ENABLE_FRILLS
2847 case '6': 2958 case '6':
2848 scr_backindex (); 2959 scr_backindex ();
2849 break; 2960 break;
2850#endif 2961#endif
2851 case '7': 2962 case '7':
2852 scr_cursor (SAVE); 2963 scr_cursor (SAVE);
2853 break; 2964 break;
2854 case '8': 2965 case '8':
2855 scr_cursor (RESTORE); 2966 scr_cursor (RESTORE);
2856 break; 2967 break;
2857#ifndef NO_FRILLS 2968#if ENABLE_FRILLS
2858 case '9': 2969 case '9':
2859 scr_forwardindex (); 2970 scr_forwardindex ();
2860 break; 2971 break;
2861#endif 2972#endif
2862 case '=': 2973 case '=':
3161 scr_scroll_text (screen.tscroll, screen.bscroll, arg[0], 0); 3272 scr_scroll_text (screen.tscroll, screen.bscroll, arg[0], 0);
3162 break; 3273 break;
3163 3274
3164 case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ 3275 case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */
3165 tt_write ((const unsigned char *)VT100_ANS, 3276 tt_write ((const unsigned char *)VT100_ANS,
3166 (unsigned int) (sizeof (VT100_ANS) - 1)); 3277 (unsigned int) (sizeof (VT100_ANS) - 1));
3167 break; 3278 break;
3168 3279
3169 case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ 3280 case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */
3170 process_sgr_mode (nargs, arg); 3281 process_sgr_mode (nargs, arg);
3171 break; 3282 break;
3178 break; 3289 break;
3179 case 6: /* CPR requested */ 3290 case 6: /* CPR requested */
3180 scr_report_position (); 3291 scr_report_position ();
3181 break; 3292 break;
3182 case 7: /* unofficial extension */ 3293 case 7: /* unofficial extension */
3183 if (Options & Opt_insecure) 3294 if (options & Opt_insecure)
3184 tt_printf ("%-.250s\n", rs[Rs_display_name]); 3295 tt_printf ("%-.250s\012", rs[Rs_display_name]);
3185 break; 3296 break;
3186 case 8: /* unofficial extension */ 3297 case 8: /* unofficial extension */
3187 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); 3298 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
3188 break; 3299 break;
3189 } 3300 }
3225 break; 3336 break;
3226 3337
3227 case CSI_RM: /* 8.3.107: RESET MODE */ 3338 case CSI_RM: /* 8.3.107: RESET MODE */
3228 if (arg[0] == 4) 3339 if (arg[0] == 4)
3229 scr_insert_mode (0); 3340 scr_insert_mode (0);
3341 else if (arg[0] == 20)
3342 priv_modes &= ~PrivMode_LFNL;
3230 break; 3343 break;
3231 3344
3232 case CSI_SM: /* 8.3.126: SET MODE */ 3345 case CSI_SM: /* 8.3.126: SET MODE */
3233 if (arg[0] == 4) 3346 if (arg[0] == 4)
3234 scr_insert_mode (1); 3347 scr_insert_mode (1);
3348 else if (arg[0] == 20)
3349 priv_modes |= PrivMode_LFNL;
3235 break; 3350 break;
3236 3351
3237 /* 3352 /*
3238 * PRIVATE USE beyond this point. All CSI_7? sequences here 3353 * PRIVATE USE beyond this point. All CSI_7? sequences here
3239 */ 3354 */
3251 break; 3366 break;
3252 case CSI_75: 3367 case CSI_75:
3253 scr_cursor (RESTORE); 3368 scr_cursor (RESTORE);
3254 break; 3369 break;
3255 3370
3256#ifndef NO_FRILLS 3371#if ENABLE_FRILLS
3257 case CSI_74: 3372 case CSI_74:
3258 process_window_ops (arg, nargs); 3373 process_window_ops (arg, nargs);
3259 break; 3374 break;
3260#endif 3375#endif
3261 3376
3268 break; 3383 break;
3269 } 3384 }
3270} 3385}
3271/*}}} */ 3386/*}}} */
3272 3387
3273#ifndef NO_FRILLS 3388#if ENABLE_FRILLS
3274/* ARGSUSED */ 3389/* ARGSUSED */
3275void 3390void
3276rxvt_term::process_window_ops (const int *args, unsigned int nargs) 3391rxvt_term::process_window_ops (const int *args, unsigned int nargs)
3277{ 3392{
3278 int x, y; 3393 int x, y;
3348 break; 3463 break;
3349 case 20: /* report icon label */ 3464 case 20: /* report icon label */
3350 { 3465 {
3351 char *s; 3466 char *s;
3352 XGetIconName (display->display, TermWin.parent[0], &s); 3467 XGetIconName (display->display, TermWin.parent[0], &s);
3353 tt_printf ("\033]L%-.250s\234", (Options & Opt_insecure) && s ? s : ""); /* 8bit ST */ 3468 tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */
3354 XFree (s); 3469 XFree (s);
3355 } 3470 }
3356 break; 3471 break;
3357 case 21: /* report window title */ 3472 case 21: /* report window title */
3358 { 3473 {
3359 char *s; 3474 char *s;
3360 XFetchName (display->display, TermWin.parent[0], &s); 3475 XFetchName (display->display, TermWin.parent[0], &s);
3361 tt_printf ("\033]l%-.250s\234", (Options & Opt_insecure) && s ? s : ""); /* 8bit ST */ 3476 tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */
3362 XFree (s); 3477 XFree (s);
3363 } 3478 }
3364 break; 3479 break;
3365 } 3480 }
3366} 3481}
3410 3525
3411 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) 3526 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL)
3412 return NULL; 3527 return NULL;
3413 3528
3414 ends_how = (ch == 0x5c ? C0_ESC : ch); 3529 ends_how = (ch == 0x5c ? C0_ESC : ch);
3415 STRNCPY (s, string, n); 3530 strncpy (s, string, n);
3416 return s; 3531 return s;
3417} 3532}
3418 3533
3419/*----------------------------------------------------------------------*/ 3534/*----------------------------------------------------------------------*/
3420/* 3535/*
3466rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) 3581rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp)
3467{ 3582{
3468 if (str[0] == '?' && !str[1]) 3583 if (str[0] == '?' && !str[1])
3469 { 3584 {
3470 unsigned short r, g, b; 3585 unsigned short r, g, b;
3471 PixColorsFocused[color].get (display, r, g, b); 3586 pix_colors_focused[color].get (display, r, g, b);
3472 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); 3587 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp);
3473 } 3588 }
3474 else 3589 else
3475 set_window_color (color, str); 3590 set_window_color (color, str);
3476} 3591}
3563 break; 3678 break;
3564 3679
3565 case XTerm_Color: 3680 case XTerm_Color:
3566 for (buf = (char *)str; buf && *buf;) 3681 for (buf = (char *)str; buf && *buf;)
3567 { 3682 {
3568 if ((name = STRCHR (buf, ';')) == NULL) 3683 if ((name = strchr (buf, ';')) == NULL)
3569 break; 3684 break;
3570 3685
3571 *name++ = '\0'; 3686 *name++ = '\0';
3572 color = atoi (buf); 3687 color = atoi (buf);
3573 3688
3574 if (color < 0 || color >= TOTAL_COLORS) 3689 if (color < 0 || color >= TOTAL_COLORS)
3575 break; 3690 break;
3576 3691
3577 if ((buf = STRCHR (name, ';')) != NULL) 3692 if ((buf = strchr (name, ';')) != NULL)
3578 *buf++ = '\0'; 3693 *buf++ = '\0';
3579 3694
3580 if (name[0] == '?' && !name[1]) 3695 if (name[0] == '?' && !name[1])
3581 { 3696 {
3582 unsigned short r, g, b; 3697 unsigned short r, g, b;
3583 PixColorsFocused[color + minCOLOR].get (display, r, g, b); 3698 pix_colors_focused[color + minCOLOR].get (display, r, g, b);
3584 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); 3699 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3585 } 3700 }
3586 else 3701 else
3587 set_window_color (color + minCOLOR, name); 3702 set_window_color (color + minCOLOR, name);
3588 } 3703 }
3623 scale_pixmap (""); /* reset to default scaling */ 3738 scale_pixmap (""); /* reset to default scaling */
3624 set_bgPixmap (str); /* change pixmap */ 3739 set_bgPixmap (str); /* change pixmap */
3625#endif 3740#endif
3626 scr_touch (true); 3741 scr_touch (true);
3627 } 3742 }
3628 while ((str = STRCHR (str, ';')) != NULL) 3743 while ((str = strchr (str, ';')) != NULL)
3629 { 3744 {
3630 str++; 3745 str++;
3631#if XPM_BACKGROUND 3746#if XPM_BACKGROUND
3632 changed += scale_pixmap (str); 3747 changed += scale_pixmap (str);
3633#endif 3748#endif
3654 break; 3769 break;
3655 3770
3656 case XTerm_font: 3771 case XTerm_font:
3657 if (query) 3772 if (query)
3658 tt_printf ("\33]%d;%-.250s%c", XTerm_font, 3773 tt_printf ("\33]%d;%-.250s%c", XTerm_font,
3659 (Options & Opt_insecure) && TermWin.fontset->fontdesc 3774 (options & Opt_insecure) && TermWin.fontset->fontdesc
3660 ? TermWin.fontset->fontdesc : "", 3775 ? TermWin.fontset->fontdesc : "",
3661 resp); 3776 resp);
3662 else 3777 else
3663 change_font (str); 3778 change_font (str);
3664 break; 3779 break;
3665 3780
3666#ifndef NO_FRILLS 3781#if ENABLE_FRILLS
3667 case XTerm_locale: 3782 case XTerm_locale:
3668 if (query) 3783 if (query)
3669 tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (Options & Opt_insecure) ? locale : "", resp); 3784 tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp);
3670 else 3785 else
3671 { 3786 {
3672 set_locale (str); 3787 set_locale (str);
3673# ifdef USE_XIM 3788# ifdef USE_XIM
3674 im_cb (); 3789 im_cb ();
3679 case XTerm_findfont: 3794 case XTerm_findfont:
3680 { 3795 {
3681 int fid = TermWin.fontset->find_font (atoi (str)); 3796 int fid = TermWin.fontset->find_font (atoi (str));
3682 tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont, 3797 tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont,
3683 fid, 3798 fid,
3684 (Options & Opt_insecure) ? (*TermWin.fontset)[fid]->name : "", 3799 (options & Opt_insecure) ? (*TermWin.fontset)[fid]->name : "",
3685 resp); 3800 resp);
3686 } 3801 }
3687 break; 3802 break;
3688#endif 3803#endif
3689 3804
3690#ifdef MENUBAR 3805#ifdef MENUBAR
3691 case XTerm_Menu: 3806 case XTerm_Menu:
3692 if (Options & Opt_insecure) 3807 if (options & Opt_insecure)
3693 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked 3808 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3694 break; 3809 break;
3695#endif 3810#endif
3696#if 0 3811#if 0
3697 case XTerm_dumpscreen: /* no error notices */ 3812 case XTerm_dumpscreen: /* no error notices */
3724{ 3839{
3725 int state; 3840 int state;
3726 3841
3727 if (mode == 's') 3842 if (mode == 's')
3728 { 3843 {
3729 SavedModes |= (PrivateModes & bit); 3844 SavedModes |= (priv_modes & bit);
3730 return -1; 3845 return -1;
3731 } 3846 }
3732 else 3847 else
3733 { 3848 {
3734 if (mode == 'r') 3849 if (mode == 'r')
3735 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ 3850 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */
3736 else 3851 else
3737 state = (mode == 't') ? ! (PrivateModes & bit) : mode; 3852 state = (mode == 't') ? ! (priv_modes & bit) : mode;
3738 PrivMode (state, bit); 3853 PrivMode (state, bit);
3739 } 3854 }
3740 3855
3741 return state; 3856 return state;
3742} 3857}
3760 { 3, PrivMode_132 }, 3875 { 3, PrivMode_132 },
3761 { 4, PrivMode_smoothScroll }, 3876 { 4, PrivMode_smoothScroll },
3762 { 5, PrivMode_rVideo }, 3877 { 5, PrivMode_rVideo },
3763 { 6, PrivMode_relOrigin }, 3878 { 6, PrivMode_relOrigin },
3764 { 7, PrivMode_Autowrap }, 3879 { 7, PrivMode_Autowrap },
3880 // 8, bi-directional support mode
3765 { 9, PrivMode_MouseX10 }, 3881 { 9, PrivMode_MouseX10 },
3766#ifdef menuBar_esc 3882#ifdef menuBar_esc
3767 { menuBar_esc, PrivMode_menuBar }, 3883 { menuBar_esc, PrivMode_menuBar },
3768#endif 3884#endif
3885 // 18, 19 printing-related
3886 { 25, PrivMode_VisibleCursor },
3769#ifdef scrollBar_esc 3887#ifdef scrollBar_esc
3770 { scrollBar_esc, PrivMode_scrollBar }, 3888 { scrollBar_esc, PrivMode_scrollBar },
3771#endif 3889#endif
3772 // 18, 19 printing-related
3773 { 25, PrivMode_VisibleCursor },
3774 // 30 show scrollbar rxvt. extension
3775 { 35, PrivMode_ShiftKeys }, // rxvt extension 3890 { 35, PrivMode_ShiftKeys }, // rxvt extension
3776 { 40, PrivMode_132OK }, 3891 { 40, PrivMode_132OK },
3777 // 41 xterm more fixes NYI 3892 // 41 xterm more fixes NYI
3778 // 45 margin bell NYI 3893 // 45 margin bell NYI
3779 // 46 start logging 3894 // 46 start logging
3820 3935
3821 /* extra handling for values with state unkept */ 3936 /* extra handling for values with state unkept */
3822 switch (arg[i]) 3937 switch (arg[i])
3823 { 3938 {
3824 case 1048: /* alternative cursor save */ 3939 case 1048: /* alternative cursor save */
3825 if (Options & Opt_secondaryScreen) 3940 if (options & Opt_secondaryScreen)
3826 if (mode == 0) 3941 if (mode == 0)
3827 scr_cursor (RESTORE); 3942 scr_cursor (RESTORE);
3828 else if (mode == 1) 3943 else if (mode == 1)
3829 scr_cursor (SAVE); 3944 scr_cursor (SAVE);
3830 break; 3945 break;
3841 * within VT52 mode 3956 * within VT52 mode
3842 */ 3957 */
3843 PrivMode (1, PrivMode_vt52); 3958 PrivMode (1, PrivMode_vt52);
3844 break; 3959 break;
3845 case 3: /* 80/132 */ 3960 case 3: /* 80/132 */
3846 if (PrivateModes & PrivMode_132OK) 3961 if (priv_modes & PrivMode_132OK)
3847 set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); 3962 set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height);
3848 break; 3963 break;
3849 case 4: /* smooth scrolling */ 3964 case 4: /* smooth scrolling */
3850 if (state) 3965 if (state)
3851 Options &= ~Opt_jumpScroll; 3966 options &= ~Opt_jumpScroll;
3852 else 3967 else
3853 Options |= Opt_jumpScroll; 3968 options |= Opt_jumpScroll;
3854 break; 3969 break;
3855 case 5: /* reverse video */ 3970 case 5: /* reverse video */
3856 scr_rvideo_mode (state); 3971 scr_rvideo_mode (state);
3857 break; 3972 break;
3858 case 6: /* relative/absolute origins */ 3973 case 6: /* relative/absolute origins */
3862 scr_autowrap (state); 3977 scr_autowrap (state);
3863 break; 3978 break;
3864 /* case 8: - auto repeat, can't do on a per window basis */ 3979 /* case 8: - auto repeat, can't do on a per window basis */
3865 case 9: /* X10 mouse reporting */ 3980 case 9: /* X10 mouse reporting */
3866 if (state) /* orthogonal */ 3981 if (state) /* orthogonal */
3867 PrivateModes &= ~PrivMode_MouseX11; 3982 priv_modes &= ~PrivMode_MouseX11;
3868 break; 3983 break;
3869#ifdef menuBar_esc 3984#ifdef menuBar_esc
3870 case menuBar_esc: 3985 case menuBar_esc:
3871#ifdef MENUBAR 3986#ifdef MENUBAR
3872 map_menuBar (state); 3987 map_menuBar (state);
3892 break; 4007 break;
3893 /* case 66: - application key pad */ 4008 /* case 66: - application key pad */
3894 /* case 67: - backspace key */ 4009 /* case 67: - backspace key */
3895 case 1000: /* X11 mouse reporting */ 4010 case 1000: /* X11 mouse reporting */
3896 if (state) /* orthogonal */ 4011 if (state) /* orthogonal */
3897 PrivateModes &= ~PrivMode_MouseX10; 4012 priv_modes &= ~PrivMode_MouseX10;
3898 break; 4013 break;
3899#if 0 4014#if 0
3900 case 1001: 4015 case 1001:
3901 break; /* X11 mouse highlighting */ 4016 break; /* X11 mouse highlighting */
3902#endif 4017#endif
3903 case 1010: /* scroll to bottom on TTY output inhibit */ 4018 case 1010: /* scroll to bottom on TTY output inhibit */
3904 if (state) 4019 if (state)
3905 Options &= ~Opt_scrollTtyOutput; 4020 options &= ~Opt_scrollTtyOutput;
3906 else 4021 else
3907 Options |= Opt_scrollTtyOutput; 4022 options |= Opt_scrollTtyOutput;
3908 break; 4023 break;
3909 case 1011: /* scroll to bottom on key press */ 4024 case 1011: /* scroll to bottom on key press */
3910 if (state) 4025 if (state)
3911 Options |= Opt_scrollTtyKeypress; 4026 options |= Opt_scrollTtyKeypress;
3912 else 4027 else
3913 Options &= ~Opt_scrollTtyKeypress; 4028 options &= ~Opt_scrollTtyKeypress;
3914 break; 4029 break;
3915 case 1047: /* secondary screen w/ clearing last */ 4030 case 1047: /* secondary screen w/ clearing last */
3916 if (Options & Opt_secondaryScreen) 4031 if (options & Opt_secondaryScreen)
3917 if (current_screen != PRIMARY) 4032 if (current_screen != PRIMARY)
3918 scr_erase_screen (2); 4033 scr_erase_screen (2);
3919 scr_change_screen (state); 4034 scr_change_screen (state);
3920 break; 4035 break;
3921 case 1049: /* secondary screen w/ clearing first */ 4036 case 1049: /* secondary screen w/ clearing first */
3922 scr_change_screen (state); 4037 scr_change_screen (state);
3923 if (Options & Opt_secondaryScreen) 4038 if (options & Opt_secondaryScreen)
3924 if (current_screen != PRIMARY) 4039 if (current_screen != PRIMARY)
3925 scr_erase_screen (2); 4040 scr_erase_screen (2);
3926 break; 4041 break;
3927 default: 4042 default:
3928 break; 4043 break;
3955 break; 4070 break;
3956 case 1: 4071 case 1:
3957 rendset = 1, rendstyle = RS_Bold; 4072 rendset = 1, rendstyle = RS_Bold;
3958 break; 4073 break;
3959 //case 2: // faint or second colour 4074 //case 2: // faint or second colour
4075 //case 3: // italic
3960 case 4: 4076 case 4:
3961 rendset = 1, rendstyle = RS_Uline; 4077 rendset = 1, rendstyle = RS_Uline;
3962 break; 4078 break;
3963 case 5: // slowly blinking 4079 case 5: // slowly blinking
3964 case 6: // rapidly blinking 4080 case 6: // rapidly blinking
3989 rendset = 0, rendstyle = RS_Uline; 4105 rendset = 0, rendstyle = RS_Uline;
3990 break; 4106 break;
3991 case 25: 4107 case 25:
3992 rendset = 0, rendstyle = RS_Blink; 4108 rendset = 0, rendstyle = RS_Blink;
3993 break; 4109 break;
4110 case 26:
4111 rendset = 0, rendstyle = RS_Blink;
4112 break;
3994 case 27: 4113 case 27:
3995 rendset = 0, rendstyle = RS_RVid; 4114 rendset = 0, rendstyle = RS_RVid;
3996 break; 4115 break;
3997 //case 28: // visible. NYI 4116 //case 28: // visible. NYI
3998 //case 29: // not crossed-out 4117 //case 29: // not crossed-out
4088{ 4207{
4089 unicode_t ch, cmd = cmd_getc (); 4208 unicode_t ch, cmd = cmd_getc ();
4090 4209
4091 if (cmd == 'Q') 4210 if (cmd == 'Q')
4092 { /* query graphics */ 4211 { /* query graphics */
4093 tt_printf ("\033G0\n"); /* no graphics */ 4212 tt_printf ("\033G0\012"); /* no graphics */
4094 return; 4213 return;
4095 } 4214 }
4096 /* swallow other graphics sequences until terminating ':' */ 4215 /* swallow other graphics sequences until terminating ':' */
4097 do 4216 do
4098 ch = cmd_getc (); 4217 ch = cmd_getc ();
4113 unsigned char buf[256]; 4232 unsigned char buf[256];
4114 4233
4115 va_start (arg_ptr, fmt); 4234 va_start (arg_ptr, fmt);
4116 vsnprintf ((char *)buf, 256, fmt, arg_ptr); 4235 vsnprintf ((char *)buf, 256, fmt, arg_ptr);
4117 va_end (arg_ptr); 4236 va_end (arg_ptr);
4118 tt_write (buf, STRLEN (buf)); 4237 tt_write (buf, strlen (buf));
4119} 4238}
4120 4239
4121/* ---------------------------------------------------------------------- */ 4240/* ---------------------------------------------------------------------- */
4122/* Write data to the pty as typed by the user, pasted with the mouse, 4241/* Write data to the pty as typed by the user, pasted with the mouse,
4123 * or generated by us in response to a query ESC sequence. 4242 * or generated by us in response to a query ESC sequence.
4129 4248
4130 if (len) 4249 if (len)
4131 { 4250 {
4132 if (v_buflen == 0) 4251 if (v_buflen == 0)
4133 { 4252 {
4134 ssize_t written = write (cmd_fd, data, min (MAX_PTY_WRITE, len)); 4253 ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE));
4135 4254
4136 if ((unsigned int)written == len) 4255 if ((unsigned int)written == len)
4137 return; 4256 return;
4138 4257
4139 data += written; 4258 data += written;
4147 v_buflen += len; 4266 v_buflen += len;
4148 } 4267 }
4149 4268
4150 for (;;) 4269 for (;;)
4151 { 4270 {
4152 int written = write (cmd_fd, v_buffer, min (MAX_PTY_WRITE, v_buflen)); 4271 int written = write (pty.pty, v_buffer, min (MAX_PTY_WRITE, v_buflen));
4153 4272
4154 if (written > 0) 4273 if (written > 0)
4155 { 4274 {
4156 v_buflen -= written; 4275 v_buflen -= written;
4157 4276

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines