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.362 by ayin, Sat Nov 10 16:04:49 2007 UTC vs.
Revision 1.392 by root, Sat Jan 12 22:13:46 2008 UTC

25 * - extensive modifications 25 * - extensive modifications
26 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> 26 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org>
27 * Copyright (c) 2001 Marius Gedminas 27 * Copyright (c) 2001 Marius Gedminas
28 * - Ctrl/Mod4+Tab works like Meta+Tab (options) 28 * - Ctrl/Mod4+Tab works like Meta+Tab (options)
29 * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> 29 * Copyright (c) 2003 Rob McMullen <robm@flipturn.org>
30 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> 30 * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com>
31 * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it>
31 * 32 *
32 * This program is free software; you can redistribute it and/or modify 33 * This program is free software; you can redistribute it and/or modify
33 * it under the terms of the GNU General Public License as published by 34 * it under the terms of the GNU General Public License as published by
34 * the Free Software Foundation; either version 2 of the License, or 35 * the Free Software Foundation; either version 2 of the License, or
35 * (at your option) any later version. 36 * (at your option) any later version.
198 r & RS_Uline ? " uline" : "", 199 r & RS_Uline ? " uline" : "",
199 r & RS_Careful ? " careful" : ""); 200 r & RS_Careful ? " careful" : "");
200 201
201 int width = wcswidth (fname, wcslen (fname)); 202 int width = wcswidth (fname, wcslen (fname));
202 203
203 max_it (width, 8+5); // for char + hey 204 max_it (width, 8+5); // for char + hex
204 max_it (width, strlen (attr)); 205 max_it (width, strlen (attr));
205 206
206 if (y >= 0) 207 if (y >= 0)
207 { 208 {
208 y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; 209 y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1;
220 ch = *chr++; 221 ch = *chr++;
221 222
222 sprintf (buf, "%8x", ch); 223 sprintf (buf, "%8x", ch);
223 scr_overlay_set (0, y, buf); 224 scr_overlay_set (0, y, buf);
224 scr_overlay_set (9, y, '='); 225 scr_overlay_set (9, y, '=');
225# if !UNICODE3 226# if !UNICODE_3
226 if (ch >= 0x10000) 227 if (ch >= 0x10000)
227 ch = 0xfffd; 228 ch = 0xfffd;
228# endif 229# endif
229 scr_overlay_set (11, y, ch, r); 230 scr_overlay_set (11, y, ch, r);
230 231
549 if (keysym >= 0xFF00 && keysym <= 0xFFFF) 550 if (keysym >= 0xFF00 && keysym <= 0xFFFF)
550 { 551 {
551 { 552 {
552 bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; 553 bool kp = priv_modes & PrivMode_aplKP ? !shft : shft;
553 newlen = 1; 554 newlen = 1;
555#ifdef XK_KP_Home
556 static const KeySym keypadtrans[] = {
557 XK_KP_7, // XK_KP_Home
558 XK_KP_4, // XK_KP_Left
559 XK_KP_8, // XK_KP_Up
560 XK_KP_6, // XK_KP_Right
561 XK_KP_2, // XK_KP_Down
562#ifndef UNSHIFTED_SCROLLKEYS
563 XK_KP_9, // XK_KP_Prior
564 XK_KP_3, // XK_KP_Next
565#else
566 XK_Prior,
567 XK_Next,
568#endif
569 XK_KP_1, // XK_KP_End
570 XK_KP_5, // XK_KP_Begin
571 };
572
573 if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin))
574 {
575 unsigned int index = keysym - XK_KP_Home;
576 keysym = kp ? keypadtrans[index] : XK_Home + index;
577 }
578 else if (keysym == XK_KP_Insert)
579 keysym = kp ? XK_KP_0 : XK_Insert;
580#ifndef NO_DELETE_KEY
581 else if (keysym == XK_KP_Delete)
582 keysym = kp ? XK_KP_Decimal : XK_Delete;
583#endif
584#endif
554 switch (keysym) 585 switch (keysym)
555 { 586 {
556#ifndef NO_BACKSPACE_KEY 587#ifndef NO_BACKSPACE_KEY
557 case XK_BackSpace: 588 case XK_BackSpace:
558 if (priv_modes & PrivMode_HaveBackSpace) 589 if (priv_modes & PrivMode_HaveBackSpace)
564 else 595 else
565 strcpy (kbuf, rs[Rs_backspace_key]); 596 strcpy (kbuf, rs[Rs_backspace_key]);
566 break; 597 break;
567#endif 598#endif
568#ifndef NO_DELETE_KEY 599#ifndef NO_DELETE_KEY
569# ifdef XK_KP_Delete
570 case XK_KP_Delete:
571 /* allow shift to override */
572 if (kp)
573 {
574 strcpy (kbuf, "\033On");
575 break;
576 }
577 /* FALLTHROUGH */
578# endif
579 case XK_Delete: 600 case XK_Delete:
580 strcpy (kbuf, rs[Rs_delete_key]); 601 strcpy (kbuf, rs[Rs_delete_key]);
581 break; 602 break;
582#endif 603#endif
583 case XK_Tab: 604 case XK_Tab:
595#endif 616#endif
596 newlen = 0; 617 newlen = 0;
597 } 618 }
598 break; 619 break;
599 620
600#ifdef XK_KP_Left
601 case XK_KP_Left: /* \033Ot or standard */
602 case XK_KP_Up: /* \033Ox or standard */
603 case XK_KP_Right: /* \033Ov or standard */
604 case XK_KP_Down: /* \033Or or standard */
605 if (kp)
606 {
607 strcpy (kbuf, "\033OZ");
608 kbuf[2] = "txvr"[keysym - XK_KP_Left];
609 break;
610 }
611 else
612 /* translate to std. cursor key */
613 keysym = XK_Left + (keysym - XK_KP_Left);
614 /* FALLTHROUGH */
615#endif
616 case XK_Up: /* "\033[A" */ 621 case XK_Up: /* "\033[A" */
617 case XK_Down: /* "\033[B" */ 622 case XK_Down: /* "\033[B" */
618 case XK_Right: /* "\033[C" */ 623 case XK_Right: /* "\033[C" */
619 case XK_Left: /* "\033[D" */ 624 case XK_Left: /* "\033[D" */
620 strcpy (kbuf, "\033[Z"); 625 strcpy (kbuf, "\033[Z");
630 else if (priv_modes & PrivMode_aplCUR) 635 else if (priv_modes & PrivMode_aplCUR)
631 kbuf[1] = 'O'; 636 kbuf[1] = 'O';
632 break; 637 break;
633 638
634#ifndef UNSHIFTED_SCROLLKEYS 639#ifndef UNSHIFTED_SCROLLKEYS
635# ifdef XK_KP_Prior
636 case XK_KP_Prior:
637 /* allow shift to override */
638 if (kp)
639 {
640 strcpy (kbuf, "\033Oy");
641 break;
642 }
643 /* FALLTHROUGH */
644# endif
645 case XK_Prior: 640 case XK_Prior:
646 strcpy (kbuf, "\033[5~"); 641 strcpy (kbuf, "\033[5~");
647 break; 642 break;
648# ifdef XK_KP_Next
649 case XK_KP_Next:
650 /* allow shift to override */
651 if (kp)
652 {
653 strcpy (kbuf, "\033Os");
654 break;
655 }
656 /* FALLTHROUGH */
657# endif
658 case XK_Next: 643 case XK_Next:
659 strcpy (kbuf, "\033[6~"); 644 strcpy (kbuf, "\033[6~");
660 break; 645 break;
661#endif 646#endif
662 case XK_KP_Enter: 647 case XK_KP_Enter:
681 kbuf[0] = '\015'; 666 kbuf[0] = '\015';
682 kbuf[1] = '\0'; 667 kbuf[1] = '\0';
683 } 668 }
684 break; 669 break;
685 670
686#ifdef XK_KP_Begin
687 case XK_KP_Begin:
688 strcpy (kbuf, "\033Ou");
689 break;
690
691#endif
692 case XK_KP_F1: /* "\033OP" */ 671 case XK_KP_F1: /* "\033OP" */
693 case XK_KP_F2: /* "\033OQ" */ 672 case XK_KP_F2: /* "\033OQ" */
694 case XK_KP_F3: /* "\033OR" */ 673 case XK_KP_F3: /* "\033OR" */
695 case XK_KP_F4: /* "\033OS" */ 674 case XK_KP_F4: /* "\033OS" */
696 strcpy (kbuf, "\033OP"); 675 strcpy (kbuf, "\033OP");
728 707
729 case XK_Find: 708 case XK_Find:
730 strcpy (kbuf, "\033[1~"); 709 strcpy (kbuf, "\033[1~");
731 break; 710 break;
732 711
733#ifdef XK_KP_Insert
734 case XK_KP_Insert:
735 /* allow shift to override */
736 if (kp)
737 {
738 strcpy (kbuf, "\033Op");
739 break;
740 }
741 /* FALLTHROUGH */
742#endif
743 case XK_Insert: 712 case XK_Insert:
744 strcpy (kbuf, "\033[2~"); 713 strcpy (kbuf, "\033[2~");
745 break; 714 break;
746#ifdef DXK_Remove /* support for DEC remove like key */ 715#ifdef DXK_Remove /* support for DEC remove like key */
747 case DXK_Remove: 716 case DXK_Remove:
751 strcpy (kbuf, "\033[3~"); 720 strcpy (kbuf, "\033[3~");
752 break; 721 break;
753 case XK_Select: 722 case XK_Select:
754 strcpy (kbuf, "\033[4~"); 723 strcpy (kbuf, "\033[4~");
755 break; 724 break;
756#ifdef XK_KP_End
757 case XK_KP_End:
758 /* allow shift to override */
759 if (kp)
760 {
761 strcpy (kbuf, "\033Oq");
762 break;
763 }
764 /* FALLTHROUGH */
765#endif
766 case XK_End: 725 case XK_End:
767 strcpy (kbuf, KS_END); 726 strcpy (kbuf, KS_END);
768 break; 727 break;
769#ifdef XK_KP_Home
770 case XK_KP_Home:
771 /* allow shift to override */
772 if (kp)
773 {
774 strcpy (kbuf, "\033Ow");
775 break;
776 }
777 /* FALLTHROUGH */
778#endif
779 case XK_Home: 728 case XK_Home:
780 strcpy (kbuf, KS_HOME); 729 strcpy (kbuf, KS_HOME);
781 break; 730 break;
782 731
783#define FKEY(n, fkey) \ 732#define FKEY(n, fkey) \
1093 } 1042 }
1094 1043
1095 display->flush (); 1044 display->flush ();
1096} 1045}
1097 1046
1047/* checks wether a refresh is requested and starts the refresh timer */
1098void 1048void
1099rxvt_term::check_cb (check_watcher &w) 1049rxvt_term::refresh_check ()
1100{ 1050{
1101 make_current (); 1051 if (want_refresh && !flush_ev.is_active ())
1052 flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally
1102 1053
1103 display->flush (); 1054 display->flush ();
1104
1105 if (want_refresh && !flush_ev.active)
1106 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally
1107} 1055}
1108 1056
1109void 1057void
1110rxvt_term::flush_cb (time_watcher &w) 1058rxvt_term::flush_cb (ev::timer &w, int revents)
1111{ 1059{
1112 make_current (); 1060 make_current ();
1113 1061
1114 refresh_count = 0; 1062 refresh_count = 0;
1115 flush (); 1063 flush ();
1116} 1064}
1117 1065
1118#ifdef CURSOR_BLINK 1066#ifdef CURSOR_BLINK
1119void 1067void
1120rxvt_term::cursor_blink_cb (time_watcher &w) 1068rxvt_term::cursor_blink_cb (ev::timer &w, int revents)
1121{ 1069{
1122 hidden_cursor = !hidden_cursor; 1070 hidden_cursor = !hidden_cursor;
1123 want_refresh = 1; 1071 want_refresh = 1;
1124 1072 refresh_check ();
1125 w.start (w.at + CURSOR_BLINK_INTERVAL);
1126} 1073}
1127#endif 1074#endif
1128 1075
1129#ifdef TEXT_BLINK 1076#ifdef TEXT_BLINK
1130void 1077void
1131rxvt_term::text_blink_cb (time_watcher &w) 1078rxvt_term::text_blink_cb (ev::timer &w, int revents)
1132{ 1079{
1133 if (scr_refresh_rend (RS_Blink, RS_Blink)) 1080 if (scr_refresh_rend (RS_Blink, RS_Blink))
1134 { 1081 {
1135 hidden_text = !hidden_text; 1082 hidden_text = !hidden_text;
1136 want_refresh = 1; 1083 want_refresh = 1;
1137 w.start (w.at + TEXT_BLINK_INTERVAL); 1084 refresh_check ();
1138 } 1085 }
1086 else
1087 w.stop ();
1139} 1088}
1140#endif 1089#endif
1141 1090
1142#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1091#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1143void 1092void
1144rxvt_term::cont_scroll_cb (time_watcher &w) 1093rxvt_term::cont_scroll_cb (ev::timer &w, int revents)
1145{ 1094{
1146 if ((scrollbar_isUp() || scrollbar_isDn()) && 1095 if ((scrollbar_isUp () || scrollbar_isDn ())
1147 scr_page (scrollbar_isUp() ? UP : DN, 1)) 1096 && scr_page (scrollbar_isUp () ? UP : DN, 1))
1148 { 1097 {
1149 want_refresh = 1; 1098 want_refresh = 1;
1150 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1099 refresh_check ();
1151 } 1100 }
1101 else
1102 w.stop ();
1152} 1103}
1153#endif 1104#endif
1154 1105
1155#ifdef SELECTION_SCROLLING 1106#ifdef SELECTION_SCROLLING
1156void 1107void
1157rxvt_term::sel_scroll_cb (time_watcher &w) 1108rxvt_term::sel_scroll_cb (ev::timer &w, int revents)
1158{ 1109{
1159 if (scr_page (scroll_selection_dir, scroll_selection_lines)) 1110 if (scr_page (scroll_selection_dir, scroll_selection_lines))
1160 { 1111 {
1161 selection_extend (selection_save_x, selection_save_y, selection_save_state); 1112 selection_extend (selection_save_x, selection_save_y, selection_save_state);
1162 want_refresh = 1; 1113 want_refresh = 1;
1163 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1114 refresh_check ();
1164 } 1115 }
1116 else
1117 w.stop ();
1165} 1118}
1166#endif 1119#endif
1167 1120
1168#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1121#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1169void 1122void
1170rxvt_term::slip_wheel_cb (time_watcher &w) 1123rxvt_term::slip_wheel_cb (ev::timer &w, int revents)
1171{ 1124{
1172 if (mouse_slip_wheel_speed == 0 1125 if (scr_changeview (view_start - mouse_slip_wheel_speed))
1173 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed)
1174 : scr_page (UP, mouse_slip_wheel_speed))
1175 { 1126 {
1176 if (view_start == top_row || view_start == 0)
1177 mouse_slip_wheel_speed = 0;
1178
1179 want_refresh = 1; 1127 want_refresh = 1;
1180 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1128 refresh_check ();
1129 }
1130
1131 if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0)
1132 {
1133 mouse_slip_wheel_speed = 0;
1134 w.stop ();
1181 } 1135 }
1182} 1136}
1183#endif 1137#endif
1184 1138
1185#if LINUX_YIELD_HACK 1139#if LINUX_YIELD_HACK
1186static struct event_handler 1140static struct event_handler
1187{ 1141{
1188 check_watcher yield_ev; 1142 ev::prepare yield_ev;
1189 1143
1190 void yield_cb (check_watcher &w) 1144 void yield_cb (ev::prepare &w, int revents)
1191 { 1145 {
1192 // this should really be sched_yield(), but the linux guys thought 1146 // this should really be sched_yield(), but the linux guys thought
1193 // that giving a process calling sched_yield () less cpu time than 1147 // that giving a process calling sched_yield () less cpu time than
1194 // ones with high nice levels is a useful thing to do. It surely is is 1148 // ones with high nice levels is a useful thing to do. It surely is is
1195 // allowed by the sus... as is returning ENOSYS. 1149 // allowed by the sus... as is returning ENOSYS.
1246 1200
1247 return false; 1201 return false;
1248} 1202}
1249 1203
1250void 1204void
1251rxvt_term::pty_cb (io_watcher &w, short revents) 1205rxvt_term::pty_cb (ev::io &w, int revents)
1252{ 1206{
1253 make_current (); 1207 make_current ();
1254 1208
1255 if (revents & EVENT_READ) 1209 if (revents & ev::READ)
1256 // loop, but don't allow a single term to monopolize us 1210 // loop, but don't allow a single term to monopolize us
1257 while (pty_fill ()) 1211 while (pty_fill ())
1258 if (cmd_parse ()) 1212 if (cmd_parse ())
1259 break; 1213 break;
1260 1214
1261 if (revents & EVENT_WRITE) 1215 if (revents & ev::WRITE)
1262 pty_write (); 1216 pty_write ();
1217
1218 refresh_check ();
1263} 1219}
1264 1220
1265void 1221void
1266rxvt_term::pointer_unblank () 1222rxvt_term::pointer_unblank ()
1267{ 1223{
1270 1226
1271#ifdef POINTER_BLANK 1227#ifdef POINTER_BLANK
1272 hidden_pointer = 0; 1228 hidden_pointer = 0;
1273 1229
1274 if (option (Opt_pointerBlank)) 1230 if (option (Opt_pointerBlank))
1275 pointer_ev.start (NOW + pointerBlankDelay); 1231 pointer_ev.start (pointerBlankDelay);
1276#endif 1232#endif
1277} 1233}
1278 1234
1279#ifdef POINTER_BLANK 1235#ifdef POINTER_BLANK
1280void 1236void
1288 1244
1289 hidden_pointer = 1; 1245 hidden_pointer = 1;
1290} 1246}
1291 1247
1292void 1248void
1293rxvt_term::pointer_cb (time_watcher &w) 1249rxvt_term::pointer_cb (ev::timer &w, int revents)
1294{ 1250{
1295 make_current (); 1251 make_current ();
1296 1252
1297 pointer_blank (); 1253 pointer_blank ();
1298} 1254}
1305 int x, y; 1261 int x, y;
1306 int code = 32; 1262 int code = 32;
1307 1263
1308 x = Pixel2Col (ev.x); 1264 x = Pixel2Col (ev.x);
1309 y = Pixel2Row (ev.y); 1265 y = Pixel2Row (ev.y);
1310 if (ev.type == MotionNotify) { 1266 if (ev.type == MotionNotify)
1267 {
1311 if (x == mouse_row && y == mouse_col) 1268 if (x == mouse_row && y == mouse_col)
1312 return; 1269 return;
1313 mouse_row = x; 1270 mouse_row = x;
1314 mouse_col = y; 1271 mouse_col = y;
1315 code += 32; 1272 code += 32;
1316 } 1273 }
1317 1274
1318 if (MEvent.button == AnyButton) 1275 if (MEvent.button == AnyButton)
1319 button_number = 3; 1276 button_number = 3;
1320 else 1277 else
1321 { 1278 {
1501#ifdef HAVE_BG_PIXMAP 1458#ifdef HAVE_BG_PIXMAP
1502 if (bgPixmap.window_position_sensitive ()) 1459 if (bgPixmap.window_position_sensitive ())
1503 update_background (); 1460 update_background ();
1504#endif 1461#endif
1505 } 1462 }
1463
1506 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1464 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1507 } 1465 }
1508 break; 1466 break;
1509 1467
1510 case PropertyNotify: 1468 case PropertyNotify:
1529 break; 1487 break;
1530 1488
1531 case MapNotify: 1489 case MapNotify:
1532 mapped = 1; 1490 mapped = 1;
1533#ifdef TEXT_BLINK 1491#ifdef TEXT_BLINK
1534 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); 1492 text_blink_ev.start ();
1535#endif 1493#endif
1536 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1494 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1537 break; 1495 break;
1538 1496
1539 case UnmapNotify: 1497 case UnmapNotify:
1560 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) 1518 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev))
1561 { 1519 {
1562 scr_expose (ev.xexpose.x, ev.xexpose.y, 1520 scr_expose (ev.xexpose.x, ev.xexpose.y,
1563 ev.xexpose.width, ev.xexpose.height, False); 1521 ev.xexpose.width, ev.xexpose.height, False);
1564 } 1522 }
1523
1565 want_refresh = 1; 1524 want_refresh = 1;
1566 } 1525 }
1567 else 1526 else
1568 { 1527 {
1569 XEvent unused_event; 1528 XEvent unused_event;
1571 while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) 1530 while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event))
1572 ; 1531 ;
1573 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) 1532 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event))
1574 ; 1533 ;
1575 1534
1576 if (isScrollbarWindow (ev.xany.window)) 1535 if (scrollBar.state && ev.xany.window == scrollBar.win)
1577 { 1536 {
1578 scrollBar.setIdle (); 1537 scrollBar.setIdle ();
1579 scrollbar_show (0); 1538 scrollbar_show (0);
1580 } 1539 }
1581 } 1540 }
1630 int dist; 1589 int dist;
1631 1590
1632 /* don't clobber the current delay if we are 1591 /* don't clobber the current delay if we are
1633 * already in the middle of scrolling. 1592 * already in the middle of scrolling.
1634 */ 1593 */
1635 if (!sel_scroll_ev.active) 1594 if (!sel_scroll_ev.is_active ())
1636 sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); 1595 sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
1637 1596
1638 /* save the event params so we can highlight 1597 /* save the event params so we can highlight
1639 * the selection in the pending-scroll loop 1598 * the selection in the pending-scroll loop
1640 */ 1599 */
1641 selection_save_x = ev.xbutton.x; 1600 selection_save_x = ev.xbutton.x;
1663 else 1622 else
1664 { 1623 {
1665 /* we are within the text window, so we 1624 /* we are within the text window, so we
1666 * shouldn't be scrolling 1625 * shouldn't be scrolling
1667 */ 1626 */
1668 if (sel_scroll_ev.active)
1669 sel_scroll_ev.stop(); 1627 sel_scroll_ev.stop();
1670 } 1628 }
1671#endif 1629#endif
1672#ifdef MOUSE_THRESHOLD 1630#ifdef MOUSE_THRESHOLD
1673 } 1631 }
1674#endif 1632#endif
1675 } 1633 }
1676 } 1634 }
1677 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) 1635 else if (scrollbar_isMotion () && ev.xany.window == scrollBar.win)
1678 { 1636 {
1679 while (XCheckTypedWindowEvent (dpy, scrollBar.win, 1637 while (XCheckTypedWindowEvent (dpy, scrollBar.win,
1680 MotionNotify, &ev)) 1638 MotionNotify, &ev))
1681 ; 1639 ;
1682 1640
1700 { 1658 {
1701 hidden_cursor = 0; 1659 hidden_cursor = 0;
1702 want_refresh = 1; 1660 want_refresh = 1;
1703 } 1661 }
1704 1662
1705 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); 1663 cursor_blink_ev.again ();
1706 } 1664 }
1707#endif 1665#endif
1708 1666
1709#if defined(POINTER_BLANK) 1667#if defined(POINTER_BLANK)
1710 if (option (Opt_pointerBlank) && pointerBlankDelay > 0) 1668 if (option (Opt_pointerBlank) && pointerBlankDelay > 0)
1717 1675
1718 if (ev.type == KeyPress && hidden_pointer == 0) 1676 if (ev.type == KeyPress && hidden_pointer == 0)
1719 pointer_blank (); 1677 pointer_blank ();
1720 } 1678 }
1721#endif 1679#endif
1680
1681 refresh_check ();
1722} 1682}
1723 1683
1724void 1684void
1725rxvt_term::focus_in () 1685rxvt_term::focus_in ()
1726{ 1686{
1738 XSetICFocus (Input_Context); 1698 XSetICFocus (Input_Context);
1739 } 1699 }
1740#endif 1700#endif
1741#if CURSOR_BLINK 1701#if CURSOR_BLINK
1742 if (option (Opt_cursorBlink)) 1702 if (option (Opt_cursorBlink))
1743 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); 1703 cursor_blink_ev.again ();
1744#endif 1704#endif
1745#if OFF_FOCUS_FADING 1705#if OFF_FOCUS_FADING
1746 if (rs[Rs_fade]) 1706 if (rs[Rs_fade])
1747 { 1707 {
1748 pix_colors = pix_colors_focused; 1708 pix_colors = pix_colors_focused;
1786 XUnsetICFocus (Input_Context); 1746 XUnsetICFocus (Input_Context);
1787#endif 1747#endif
1788#if CURSOR_BLINK 1748#if CURSOR_BLINK
1789 if (option (Opt_cursorBlink)) 1749 if (option (Opt_cursorBlink))
1790 cursor_blink_ev.stop (); 1750 cursor_blink_ev.stop ();
1751
1791 hidden_cursor = 0; 1752 hidden_cursor = 0;
1792#endif 1753#endif
1793#if OFF_FOCUS_FADING 1754#if OFF_FOCUS_FADING
1794 if (rs[Rs_fade]) 1755 if (rs[Rs_fade])
1795 { 1756 {
1835 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) 1796 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1836 { 1797 {
1837 bgPixmap.set_root_pixmap (); 1798 bgPixmap.set_root_pixmap ();
1838 update_background (); 1799 update_background ();
1839 } 1800 }
1801
1840 break; 1802 break;
1841 } 1803 }
1842# endif 1804# endif
1805
1806 refresh_check ();
1843} 1807}
1844#endif 1808#endif
1845 1809
1846void 1810void
1847rxvt_term::button_press (XButtonEvent &ev) 1811rxvt_term::button_press (XButtonEvent &ev)
1902 mouse_report (ev); 1866 mouse_report (ev);
1903 } 1867 }
1904#else 1868#else
1905 MEvent.button = ev.button; 1869 MEvent.button = ev.button;
1906 mouse_report (ev); 1870 mouse_report (ev);
1907#endif /* MOUSE_REPORT_DOUBLECLICK */ 1871#endif /* MOUSE_REPORT_DOUBLECLICK */
1908 1872
1909 } 1873 }
1910 else 1874 else
1911 { 1875 {
1912 if (ev.button != MEvent.button) 1876 if (ev.button != MEvent.button)
1960 } 1924 }
1961 1925
1962 /* 1926 /*
1963 * Scrollbar window processing of button press 1927 * Scrollbar window processing of button press
1964 */ 1928 */
1965 if (isScrollbarWindow (ev.window)) 1929 if (scrollBar.state && ev.window == scrollBar.win)
1966 { 1930 {
1967 scrollBar.setIdle (); 1931 scrollBar.setIdle ();
1968 /* 1932 /*
1969 * Rxvt-style scrollbar: 1933 * Rxvt-style scrollbar:
1970 * move up if mouse is above slider 1934 * move up if mouse is above slider
2006 tt_printf ("\033[5~"); 1970 tt_printf ("\033[5~");
2007 break; 1971 break;
2008 } 1972 }
2009 } 1973 }
2010 else 1974 else
2011#endif /* NO_SCROLLBAR_REPORT */ 1975#endif /* NO_SCROLLBAR_REPORT */
2012 1976
2013 { 1977 {
2014 char upordown = 0; 1978 char upordown = 0;
2015 1979
2016 if (scrollBar.style == R_SB_NEXT) 1980 if (scrollBar.style == R_SB_NEXT)
2017 { 1981 {
2018 if (scrollbarnext_upButton (ev.y)) 1982 if (scrollbarnext_upButton (ev.y))
2019 upordown = -1; /* up */ 1983 upordown = -1; /* up */
2025 if (scrollbarrxvt_upButton (ev.y)) 1989 if (scrollbarrxvt_upButton (ev.y))
2026 upordown = -1; /* up */ 1990 upordown = -1; /* up */
2027 else if (scrollbarrxvt_dnButton (ev.y)) 1991 else if (scrollbarrxvt_dnButton (ev.y))
2028 upordown = 1; /* down */ 1992 upordown = 1; /* down */
2029 } 1993 }
1994
2030 if (upordown) 1995 if (upordown)
2031 { 1996 {
2032#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1997#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1998 if (!cont_scroll_ev.is_active ())
2033 cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); 1999 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2034#endif 2000#endif
2035 if (scr_page (upordown < 0 ? UP : DN, 1)) 2001 if (scr_page (upordown < 0 ? UP : DN, 1))
2036 { 2002 {
2037 if (upordown < 0) 2003 if (upordown < 0)
2038 scrollBar.setUp (); 2004 scrollBar.setUp ();
2042 } 2008 }
2043 else 2009 else
2044 switch (ev.button) 2010 switch (ev.button)
2045 { 2011 {
2046 case Button2: 2012 case Button2:
2047 switch (scrollbar_align) 2013 switch (scrollBar.align)
2048 { 2014 {
2049 case R_SB_ALIGN_TOP: 2015 case R_SB_ALIGN_TOP:
2050 csrO = 0; 2016 csrO = 0;
2051 break; 2017 break;
2052 case R_SB_ALIGN_CENTRE: 2018 case R_SB_ALIGN_CENTRE:
2064 2030
2065 scrollBar.setMotion (); 2031 scrollBar.setMotion ();
2066 break; 2032 break;
2067 2033
2068 case Button1: 2034 case Button1:
2069 if (scrollbar_align == R_SB_ALIGN_CENTRE) 2035 if (scrollBar.align == R_SB_ALIGN_CENTRE)
2070 csrO = ev.y - scrollBar.top; 2036 csrO = ev.y - scrollBar.top;
2071 /* FALLTHROUGH */ 2037 /* FALLTHROUGH */
2072 2038
2073 case Button3: 2039 case Button3:
2074 if (scrollBar.style != R_SB_XTERM) 2040 if (scrollBar.style != R_SB_XTERM)
2118 scrollBar.setIdle (); 2084 scrollBar.setIdle ();
2119 scrollbar_show (0); 2085 scrollbar_show (0);
2120 } 2086 }
2121 2087
2122#ifdef SELECTION_SCROLLING 2088#ifdef SELECTION_SCROLLING
2123 if (sel_scroll_ev.active)
2124 sel_scroll_ev.stop(); 2089 sel_scroll_ev.stop();
2125#endif 2090#endif
2126 2091
2127 if (ev.window == vt) 2092 if (ev.window == vt)
2128 { 2093 {
2129 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) 2094 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END)))
2153 mouse_report (ev); 2118 mouse_report (ev);
2154 } 2119 }
2155#else /* MOUSE_REPORT_DOUBLECLICK */ 2120#else /* MOUSE_REPORT_DOUBLECLICK */
2156 MEvent.button = AnyButton; 2121 MEvent.button = AnyButton;
2157 mouse_report (ev); 2122 mouse_report (ev);
2158#endif /* MOUSE_REPORT_DOUBLECLICK */ 2123#endif /* MOUSE_REPORT_DOUBLECLICK */
2159 return; 2124 return;
2160 } 2125 }
2161 2126
2162 /* 2127 /*
2163 * dumb hack to compensate for the failure of click-and-drag 2128 * dumb hack to compensate for the failure of click-and-drag
2201 { 2166 {
2202 mouse_slip_wheel_speed += v ? -1 : 1; 2167 mouse_slip_wheel_speed += v ? -1 : 1;
2203 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; 2168 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow;
2204 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; 2169 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow;
2205 2170
2206 if (slip_wheel_ev.at < NOW) 2171 if (!slip_wheel_ev.is_active ())
2207 slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; 2172 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2208
2209 slip_wheel_ev.start ();
2210 } 2173 }
2211 else 2174 else
2175# endif
2212 { 2176 {
2213# endif
2214 scr_page (v, i); 2177 scr_page (v, i);
2215 scrollbar_show (1); 2178 scrollbar_show (1);
2216# ifdef MOUSE_SLIP_WHEELING
2217 } 2179 }
2218# endif
2219 } 2180 }
2220 break; 2181 break;
2221#endif 2182#endif
2222 } 2183 }
2223 } 2184 }
2282 2243
2283 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) 2244 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1)
2284 { 2245 {
2285 refresh_count = 0; 2246 refresh_count = 0;
2286 2247
2287 if (!option (Opt_skipScroll) || io_manager::now () > NOW + 1. / 60.) 2248 if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.)
2288 { 2249 {
2289 refreshnow = true; 2250 refreshnow = true;
2290 ch = NOCHAR; 2251 ch = NOCHAR;
2291 break; 2252 break;
2292 } 2253 }
2503 } 2464 }
2504 } 2465 }
2505 2466
2506 pclose_printer (fd); 2467 pclose_printer (fd);
2507} 2468}
2508#endif /* PRINTPIPE */ 2469#endif /* PRINTPIPE */
2509/*}}} */ 2470/*}}} */
2510 2471
2511/* *INDENT-OFF* */ 2472/* *INDENT-OFF* */
2512enum { 2473enum {
2513 C1_40 = 0x40, 2474 C1_40 = 0x40,
2806 nargs = 0; 2767 nargs = 0;
2807 2768
2808 priv = 0; 2769 priv = 0;
2809 ch = cmd_getc (); 2770 ch = cmd_getc ();
2810 if (ch >= '<' && ch <= '?') 2771 if (ch >= '<' && ch <= '?')
2772 {
2811 { /* '<' '=' '>' '?' */ 2773 /* '<' '=' '>' '?' */
2812 priv = ch; 2774 priv = ch;
2813 ch = cmd_getc (); 2775 ch = cmd_getc ();
2814 } 2776 }
2815 2777
2816 /* read any numerical arguments */ 2778 /* read any numerical arguments */
3428#if ENABLE_TRANSPARENCY 3390#if ENABLE_TRANSPARENCY
3429 case URxvt_Color_tint: 3391 case URxvt_Color_tint:
3430 process_color_seq (op, Color_tint, str, resp); 3392 process_color_seq (op, Color_tint, str, resp);
3431 { 3393 {
3432 bool changed = false; 3394 bool changed = false;
3395
3433 if (ISSET_PIXCOLOR (Color_tint)) 3396 if (ISSET_PIXCOLOR (Color_tint))
3434 changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); 3397 changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]);
3435 else 3398 else
3436 changed = bgPixmap.unset_tint (); 3399 changed = bgPixmap.unset_tint ();
3400
3437 if (changed) 3401 if (changed)
3438 update_background (); 3402 update_background ();
3439 } 3403 }
3440 3404
3441 break; 3405 break;
3464 changed++; 3428 changed++;
3465 str = strchr (str, ';'); 3429 str = strchr (str, ';');
3466 if (str == NULL) 3430 if (str == NULL)
3467 bgPixmap.set_defaultGeometry (); 3431 bgPixmap.set_defaultGeometry ();
3468 } 3432 }
3433
3469 while (str) 3434 while (str)
3470 { 3435 {
3471 str++; 3436 str++;
3472 if (bgPixmap.set_geometry (str)) 3437 if (bgPixmap.set_geometry (str))
3473 changed++; 3438 changed++;
3474 str = strchr (str, ';'); 3439 str = strchr (str, ';');
3475 } 3440 }
3441
3476 if (changed) 3442 if (changed)
3477 update_background (); 3443 update_background ();
3478 } 3444 }
3479 break; 3445 break;
3480#endif 3446#endif
3481 3447
3482 case Rxvt_restoreFG: 3448 case Rxvt_restoreFG:
3636 { 66, PrivMode_aplKP }, 3602 { 66, PrivMode_aplKP },
3637#ifndef NO_BACKSPACE_KEY 3603#ifndef NO_BACKSPACE_KEY
3638 { 67, PrivMode_BackSpace }, 3604 { 67, PrivMode_BackSpace },
3639#endif 3605#endif
3640 { 1000, PrivMode_MouseX11 }, 3606 { 1000, PrivMode_MouseX11 },
3641 // 1001 Use Hilite Mouse Tracking. NYI, TODO
3642 { 1002, PrivMode_MouseBtnEvent }, 3607 { 1002, PrivMode_MouseBtnEvent },
3643 { 1003, PrivMode_MouseAnyEvent }, 3608 { 1003, PrivMode_MouseAnyEvent },
3644 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3609 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3645 { 1011, PrivMode_Keypress }, // rxvt extension 3610 { 1011, PrivMode_Keypress }, // rxvt extension
3646 // 1035 enable modifiers for alt, numlock NYI 3611 // 1035 enable modifiers for alt, numlock NYI
3705 */ 3670 */
3706 PrivMode (1, PrivMode_vt52); 3671 PrivMode (1, PrivMode_vt52);
3707 break; 3672 break;
3708 case 3: /* 80/132 */ 3673 case 3: /* 80/132 */
3709 if (priv_modes & PrivMode_132OK) 3674 if (priv_modes & PrivMode_132OK)
3675 {
3676 scr_poweron ();
3710 set_widthheight (((state ? 132 : 80) * fwidth), height); 3677 set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight);
3678 }
3711 break; 3679 break;
3712 case 4: /* smooth scrolling */ 3680 case 4: /* smooth scrolling */
3713 set_option (Opt_jumpScroll, !state); 3681 set_option (Opt_jumpScroll, !state);
3714 break; 3682 break;
3715 case 5: /* reverse video */ 3683 case 5: /* reverse video */
3747 /* case 67: - backspace key */ 3715 /* case 67: - backspace key */
3748 case 1000: /* X11 mouse reporting */ 3716 case 1000: /* X11 mouse reporting */
3749 if (state) /* orthogonal */ 3717 if (state) /* orthogonal */
3750 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); 3718 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
3751 break; 3719 break;
3752#if 0
3753 case 1001:
3754 break; /* X11 mouse highlighting */
3755#endif
3756 case 1002: 3720 case 1002:
3757 case 1003: 3721 case 1003:
3758 if (state) { 3722 if (state)
3723 {
3759 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); 3724 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11);
3760 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; 3725 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
3761 vt_emask_mouse = PointerMotionMask; 3726 vt_emask_mouse = PointerMotionMask;
3727 }
3762 } else 3728 else
3763 vt_emask_mouse = NoEventMask; 3729 vt_emask_mouse = NoEventMask;
3764 vt_select_input (); 3730 vt_select_input ();
3765 break; 3731 break;
3766 case 1010: /* scroll to bottom on TTY output inhibit */ 3732 case 1010: /* scroll to bottom on TTY output inhibit */
3767 set_option (Opt_scrollTtyOutput, !state); 3733 set_option (Opt_scrollTtyOutput, !state);
3947rxvt_term::process_graphics () 3913rxvt_term::process_graphics ()
3948{ 3914{
3949 unicode_t ch, cmd = cmd_getc (); 3915 unicode_t ch, cmd = cmd_getc ();
3950 3916
3951 if (cmd == 'Q') 3917 if (cmd == 'Q')
3918 {
3952 { /* query graphics */ 3919 /* query graphics */
3953 tt_printf ("\033G0\012"); /* no graphics */ 3920 tt_printf ("\033G0\012"); /* no graphics */
3954 return; 3921 return;
3955 } 3922 }
3956 /* swallow other graphics sequences until terminating ':' */ 3923 /* swallow other graphics sequences until terminating ':' */
3957 do 3924 do
4007 v_buffer = (char *)realloc (v_buffer, v_buflen + len); 3974 v_buffer = (char *)realloc (v_buffer, v_buflen + len);
4008 3975
4009 memcpy (v_buffer + v_buflen, data, len); 3976 memcpy (v_buffer + v_buflen, data, len);
4010 v_buflen += len; 3977 v_buflen += len;
4011 3978
4012 pty_ev.set (EVENT_READ | EVENT_WRITE); 3979 pty_ev.set (ev::READ | ev::WRITE);
4013} 3980}
4014 3981
4015void rxvt_term::pty_write () 3982void rxvt_term::pty_write ()
4016{ 3983{
4017 int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); 3984 int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE));
4023 if (v_buflen == 0) 3990 if (v_buflen == 0)
4024 { 3991 {
4025 free (v_buffer); 3992 free (v_buffer);
4026 v_buffer = 0; 3993 v_buffer = 0;
4027 3994
4028 pty_ev.set (EVENT_READ); 3995 pty_ev.set (ev::READ);
4029 return; 3996 return;
4030 } 3997 }
4031 3998
4032 memmove (v_buffer, v_buffer + written, v_buflen); 3999 memmove (v_buffer, v_buffer + written, v_buflen);
4033 } 4000 }
4034 else if (written != -1 || (errno != EAGAIN && errno != EINTR)) 4001 else if (written != -1 || (errno != EAGAIN && errno != EINTR))
4035 pty_ev.set (EVENT_READ); 4002 pty_ev.set (ev::READ);
4036} 4003}
4037 4004
4038/*----------------------- end-of-file (C source) -----------------------*/ 4005/*----------------------- end-of-file (C source) -----------------------*/
4039 4006

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines