… | |
… | |
43 | * along with this program; if not, write to the Free Software |
43 | * along with this program; if not, write to the Free Software |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
45 | *----------------------------------------------------------------------*/ |
45 | *----------------------------------------------------------------------*/ |
46 | |
46 | |
47 | /*{{{ includes: */ |
47 | /*{{{ includes: */ |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" |
|
|
50 | #include "rxvtperl.h" |
50 | #include "version.h" |
51 | #include "version.h" |
51 | #include "command.h" |
52 | #include "command.h" |
|
|
53 | |
|
|
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
52 | |
58 | |
53 | #ifdef KEYSYM_RESOURCE |
59 | #ifdef KEYSYM_RESOURCE |
54 | # include "keyboard.h" |
60 | # include "keyboard.h" |
55 | #endif |
61 | #endif |
56 | |
62 | |
… | |
… | |
155 | } |
161 | } |
156 | |
162 | |
157 | x--; |
163 | x--; |
158 | } |
164 | } |
159 | } |
165 | } |
160 | #endif |
|
|
161 | |
166 | |
162 | void |
167 | void |
163 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
168 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
164 | { |
169 | { |
165 | #if ENABLE_OVERLAY |
|
|
166 | rxvt_fontset *fs = FONTSET (r); |
170 | rxvt_fontset *fs = FONTSET (r); |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
171 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
168 | wchar_t *chr, *alloc, ch2, *fname; |
172 | wchar_t *chr, *alloc, ch2, *fname; |
169 | int len; |
173 | int len; |
170 | |
174 | |
… | |
… | |
238 | |
242 | |
239 | # if ENABLE_COMBINING |
243 | # if ENABLE_COMBINING |
240 | if (alloc) |
244 | if (alloc) |
241 | delete [] alloc; |
245 | delete [] alloc; |
242 | # endif |
246 | # endif |
243 | #endif |
|
|
244 | } |
247 | } |
|
|
248 | #endif |
245 | |
249 | |
246 | void |
250 | void |
247 | rxvt_term::commit_iso14755 () |
251 | rxvt_term::commit_iso14755 () |
248 | { |
252 | { |
249 | wchar_t ch[2]; |
253 | wchar_t ch[2]; |
… | |
… | |
264 | mb[0] = ch[0]; |
268 | mb[0] = ch[0]; |
265 | len = 1; |
269 | len = 1; |
266 | } |
270 | } |
267 | |
271 | |
268 | if (len > 0) |
272 | if (len > 0) |
269 | tt_write ((unsigned char *)mb, len); |
273 | tt_write (mb, len); |
270 | else |
274 | else |
271 | scr_bell (); |
275 | scr_bell (); |
272 | } |
276 | } |
273 | |
277 | |
274 | iso14755buf = 0; |
278 | iso14755buf = 0; |
… | |
… | |
302 | KeySym keysym; |
306 | KeySym keysym; |
303 | #ifdef DEBUG_CMD |
307 | #ifdef DEBUG_CMD |
304 | static int debug_key = 1; /* accessible by a debugger only */ |
308 | static int debug_key = 1; /* accessible by a debugger only */ |
305 | #endif |
309 | #endif |
306 | int valid_keysym; |
310 | int valid_keysym; |
307 | unsigned char kbuf[KBUFSZ]; |
311 | char kbuf[KBUFSZ]; |
308 | |
312 | |
309 | /* |
313 | /* |
310 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
311 | * escape sequence to toggle the Keypad. |
315 | * escape sequence to toggle the Keypad. |
312 | * |
316 | * |
… | |
… | |
330 | Status status_return; |
334 | Status status_return; |
331 | |
335 | |
332 | #if 0 |
336 | #if 0 |
333 | #ifdef X_HAVE_UTF8_STRING |
337 | #ifdef X_HAVE_UTF8_STRING |
334 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
338 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
335 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
339 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
336 | KBUFSZ, &keysym, &status_return); |
340 | KBUFSZ, &keysym, &status_return); |
337 | else |
341 | else |
338 | #endif |
342 | #endif |
339 | #endif |
343 | #endif |
340 | { |
344 | { |
… | |
… | |
377 | || status_return == XLookupBoth; |
381 | || status_return == XLookupBoth; |
378 | } |
382 | } |
379 | else |
383 | else |
380 | #endif |
384 | #endif |
381 | { |
385 | { |
382 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
386 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
383 | valid_keysym = keysym != NoSymbol; |
387 | valid_keysym = keysym != NoSymbol; |
384 | } |
388 | } |
385 | |
389 | |
386 | if (valid_keysym) |
390 | if (valid_keysym) |
387 | { |
391 | { |
… | |
… | |
851 | { |
855 | { |
852 | #ifdef META8_OPTION |
856 | #ifdef META8_OPTION |
853 | /* set 8-bit on */ |
857 | /* set 8-bit on */ |
854 | if (meta && (meta_char == 0x80)) |
858 | if (meta && (meta_char == 0x80)) |
855 | { |
859 | { |
856 | unsigned char *ch; |
860 | char *ch; |
857 | |
861 | |
858 | for (ch = kbuf; ch < kbuf + len; ch++) |
862 | for (ch = kbuf; ch < kbuf + len; ch++) |
859 | *ch |= 0x80; |
863 | *ch |= 0x80; |
860 | |
864 | |
861 | meta = 0; |
865 | meta = 0; |
… | |
… | |
863 | #endif |
867 | #endif |
864 | /* nil */ ; |
868 | /* nil */ ; |
865 | } |
869 | } |
866 | } |
870 | } |
867 | |
871 | |
|
|
872 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_STRING_LEN, kbuf, len, DT_END))) |
|
|
873 | return; |
|
|
874 | |
868 | if (len <= 0) |
875 | if (len <= 0) |
869 | return; /* not mapped */ |
876 | return; /* not mapped */ |
870 | |
877 | |
871 | if (options & Opt_scrollTtyKeypress) |
878 | if (OPTION (Opt_scrollTtyKeypress)) |
872 | if (view_start) |
879 | if (view_start) |
873 | { |
880 | { |
874 | view_start = 0; |
881 | view_start = 0; |
875 | want_refresh = 1; |
882 | want_refresh = 1; |
876 | } |
883 | } |
… | |
… | |
894 | #ifdef META8_OPTION |
901 | #ifdef META8_OPTION |
895 | && meta_char == C0_ESC |
902 | && meta_char == C0_ESC |
896 | #endif |
903 | #endif |
897 | ) |
904 | ) |
898 | { |
905 | { |
899 | const unsigned char ch = C0_ESC; |
906 | const char ch = C0_ESC; |
900 | tt_write (&ch, 1); |
907 | tt_write (&ch, 1); |
901 | } |
908 | } |
902 | |
909 | |
903 | #if defined(DEBUG_CMD) |
910 | #if defined(DEBUG_CMD) |
904 | /* Display keyboard buffer contents */ |
911 | /* Display keyboard buffer contents */ |
… | |
… | |
916 | |
923 | |
917 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
924 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
918 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
925 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
919 | /* attempt to `write' count to the input buffer */ |
926 | /* attempt to `write' count to the input buffer */ |
920 | unsigned int |
927 | unsigned int |
921 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
928 | rxvt_term::cmd_write (const char *str, unsigned int count) |
922 | { |
929 | { |
923 | unsigned int n, s; |
930 | unsigned int n, s; |
924 | |
931 | |
925 | n = cmdbuf_ptr - cmdbuf_base; |
932 | n = cmdbuf_ptr - cmdbuf_base; |
926 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
933 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
963 | } |
970 | } |
964 | #endif |
971 | #endif |
965 | |
972 | |
966 | if (want_refresh) |
973 | if (want_refresh) |
967 | { |
974 | { |
|
|
975 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
976 | { |
|
|
977 | int row = -view_start; |
|
|
978 | |
|
|
979 | while (row > -nsaved && ROW (row - 1).is_longer ()) |
|
|
980 | --row; |
|
|
981 | |
|
|
982 | while (row < -view_start + nrow) |
|
|
983 | { |
|
|
984 | int start_row = row; |
|
|
985 | line_t *l; |
|
|
986 | |
|
|
987 | do |
|
|
988 | { |
|
|
989 | l = &ROW (row); |
|
|
990 | |
|
|
991 | if (!(l->f & LINE_FILTERED)) |
|
|
992 | { |
|
|
993 | // line not filtered, mark it as filtered |
|
|
994 | l->f |= LINE_FILTERED; |
|
|
995 | while (l->is_longer ()) |
|
|
996 | { |
|
|
997 | l = &ROW (++row); |
|
|
998 | l->f |= LINE_FILTERED; |
|
|
999 | } |
|
|
1000 | |
|
|
1001 | // and filter it |
|
|
1002 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
1003 | |
|
|
1004 | break; |
|
|
1005 | } |
|
|
1006 | } |
|
|
1007 | while (l->is_longer ()); |
|
|
1008 | |
|
|
1009 | row++; |
|
|
1010 | } |
|
|
1011 | |
|
|
1012 | } |
|
|
1013 | |
968 | scr_refresh (refresh_type); |
1014 | scr_refresh (refresh_type); |
969 | scrollbar_show (1); |
1015 | scrollbar_show (1); |
970 | #ifdef USE_XIM |
1016 | #ifdef USE_XIM |
971 | IMSendSpot (); |
1017 | IMSendSpot (); |
972 | #endif |
1018 | #endif |
… | |
… | |
982 | SET_LOCALE (locale); |
1028 | SET_LOCALE (locale); |
983 | |
1029 | |
984 | display->flush (); |
1030 | display->flush (); |
985 | |
1031 | |
986 | if (want_refresh && !flush_ev.active) |
1032 | if (want_refresh && !flush_ev.active) |
987 | flush_ev.start (NOW + 0.01); |
1033 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
988 | } |
1034 | } |
989 | |
1035 | |
990 | void |
1036 | void |
991 | rxvt_term::flush_cb (time_watcher &w) |
1037 | rxvt_term::flush_cb (time_watcher &w) |
992 | { |
1038 | { |
… | |
… | |
1067 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1113 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1068 | } |
1114 | } |
1069 | } |
1115 | } |
1070 | #endif |
1116 | #endif |
1071 | |
1117 | |
|
|
1118 | #if HAVE_SCHED_YIELD |
|
|
1119 | static struct event_handler |
|
|
1120 | { |
|
|
1121 | check_watcher cw_yield; |
|
|
1122 | |
|
|
1123 | void yield (check_watcher &w) |
|
|
1124 | { |
|
|
1125 | sched_yield (); |
|
|
1126 | w.stop (); |
|
|
1127 | } |
|
|
1128 | |
|
|
1129 | event_handler () |
|
|
1130 | : cw_yield (this, &event_handler::yield) |
|
|
1131 | { |
|
|
1132 | } |
|
|
1133 | } event_handler; |
|
|
1134 | #endif |
|
|
1135 | |
1072 | bool |
1136 | bool |
1073 | rxvt_term::pty_fill () |
1137 | rxvt_term::pty_fill () |
1074 | { |
1138 | { |
1075 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1139 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1076 | |
1140 | |
1077 | if (CBUFSIZ == n) |
1141 | if (CBUFSIZ == n) |
1078 | { |
1142 | { |
1079 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1143 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1080 | n = 0; |
1144 | n = 0; |
1081 | } |
1145 | } |
1082 | |
1146 | |
1083 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1147 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1084 | cmdbuf_ptr = cmdbuf_base; |
1148 | cmdbuf_ptr = cmdbuf_base; |
1085 | cmdbuf_endp = cmdbuf_ptr + n; |
1149 | cmdbuf_endp = cmdbuf_ptr + n; |
1086 | |
1150 | |
1087 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1151 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1088 | |
1152 | |
1089 | if (n > 0) |
1153 | if (r > 0) |
1090 | { |
1154 | { |
1091 | cmdbuf_endp += n; |
1155 | cmdbuf_endp += r; |
1092 | return true; |
1156 | return true; |
1093 | } |
1157 | } |
1094 | else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) |
1158 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1159 | { |
|
|
1160 | #if HAVE_SCHED_YIELD |
|
|
1161 | if (display->is_local) |
|
|
1162 | event_handler.cw_yield.start (); |
|
|
1163 | #endif |
|
|
1164 | } |
|
|
1165 | else |
1095 | { |
1166 | { |
1096 | pty_ev.stop (); |
1167 | pty_ev.stop (); |
1097 | |
1168 | |
1098 | if (!(options & Opt_hold)) |
1169 | if (!OPTION (Opt_hold)) |
1099 | destroy (); |
1170 | destroy (); |
1100 | } |
1171 | } |
1101 | |
1172 | |
1102 | return false; |
1173 | return false; |
1103 | } |
1174 | } |
… | |
… | |
1125 | recolour_cursor (); |
1196 | recolour_cursor (); |
1126 | |
1197 | |
1127 | #ifdef POINTER_BLANK |
1198 | #ifdef POINTER_BLANK |
1128 | hidden_pointer = 0; |
1199 | hidden_pointer = 0; |
1129 | |
1200 | |
1130 | if (options & Opt_pointerBlank) |
1201 | if (OPTION (Opt_pointerBlank)) |
1131 | pointer_ev.start (NOW + pointerBlankDelay); |
1202 | pointer_ev.start (NOW + pointerBlankDelay); |
1132 | #endif |
1203 | #endif |
1133 | } |
1204 | } |
1134 | |
1205 | |
1135 | #ifdef POINTER_BLANK |
1206 | #ifdef POINTER_BLANK |
1136 | void |
1207 | void |
1137 | rxvt_term::pointer_blank () |
1208 | rxvt_term::pointer_blank () |
1138 | { |
1209 | { |
1139 | if (! (options & Opt_pointerBlank)) |
1210 | if (!OPTION (Opt_pointerBlank)) |
1140 | return; |
1211 | return; |
1141 | |
1212 | |
1142 | XDefineCursor (display->display, vt, display->blank_cursor); |
1213 | XDefineCursor (display->display, vt, display->blank_cursor); |
1143 | XFlush (display->display); |
1214 | XFlush (display->display); |
1144 | |
1215 | |
… | |
… | |
1242 | |
1313 | |
1243 | SET_R (this); |
1314 | SET_R (this); |
1244 | SET_LOCALE (locale); |
1315 | SET_LOCALE (locale); |
1245 | |
1316 | |
1246 | #if defined(CURSOR_BLINK) |
1317 | #if defined(CURSOR_BLINK) |
1247 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
1318 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1248 | { |
1319 | { |
1249 | if (hidden_cursor) |
1320 | if (hidden_cursor) |
1250 | { |
1321 | { |
1251 | hidden_cursor = 0; |
1322 | hidden_cursor = 0; |
1252 | want_refresh = 1; |
1323 | want_refresh = 1; |
… | |
… | |
1255 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1326 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1256 | } |
1327 | } |
1257 | #endif |
1328 | #endif |
1258 | |
1329 | |
1259 | #if defined(POINTER_BLANK) |
1330 | #if defined(POINTER_BLANK) |
1260 | if ((options & Opt_pointerBlank) && pointerBlankDelay > 0) |
1331 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1261 | { |
1332 | { |
1262 | if (ev.type == MotionNotify |
1333 | if (ev.type == MotionNotify |
1263 | || ev.type == ButtonPress |
1334 | || ev.type == ButtonPress |
1264 | || ev.type == ButtonRelease) |
1335 | || ev.type == ButtonRelease) |
1265 | if (hidden_pointer) |
1336 | if (hidden_pointer) |
… | |
… | |
1343 | # endif |
1414 | # endif |
1344 | else |
1415 | else |
1345 | iso14755buf = 0; |
1416 | iso14755buf = 0; |
1346 | } |
1417 | } |
1347 | #endif |
1418 | #endif |
|
|
1419 | |
|
|
1420 | if (ev.xany.window == vt && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
1421 | break; |
1348 | |
1422 | |
1349 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1423 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1350 | if (!(ev.xkey.state & ControlMask)) |
1424 | if (!(ev.xkey.state & ControlMask)) |
1351 | slip_wheel_ev.stop (); |
1425 | slip_wheel_ev.stop (); |
1352 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1426 | else if (ks == XK_Control_L || ks == XK_Control_R) |
… | |
… | |
1461 | seen_resize = 1; |
1535 | seen_resize = 1; |
1462 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1536 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1463 | } |
1537 | } |
1464 | |
1538 | |
1465 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1539 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1466 | if (options & Opt_transparent) |
1540 | if (OPTION (Opt_transparent)) |
1467 | check_our_parents (); |
1541 | check_our_parents (); |
1468 | #endif |
1542 | #endif |
1469 | } |
1543 | } |
1470 | break; |
1544 | break; |
1471 | |
1545 | |
… | |
… | |
1567 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1641 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1568 | break; |
1642 | break; |
1569 | |
1643 | |
1570 | if (ev.xany.window == vt) |
1644 | if (ev.xany.window == vt) |
1571 | { |
1645 | { |
|
|
1646 | if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1647 | ; // nop |
1572 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1648 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1573 | { |
1649 | { |
1574 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1650 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1575 | ; |
1651 | ; |
1576 | |
1652 | |
1577 | XQueryPointer (disp, vt, |
1653 | XQueryPointer (disp, vt, |
… | |
… | |
1672 | { |
1748 | { |
1673 | if (!focus) |
1749 | if (!focus) |
1674 | { |
1750 | { |
1675 | focus = 1; |
1751 | focus = 1; |
1676 | want_refresh = 1; |
1752 | want_refresh = 1; |
|
|
1753 | |
|
|
1754 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1755 | |
1677 | #if USE_XIM |
1756 | #if USE_XIM |
1678 | if (Input_Context != NULL) |
1757 | if (Input_Context != NULL) |
1679 | { |
1758 | { |
1680 | IMSetStatusPosition (); |
1759 | IMSetStatusPosition (); |
1681 | XSetICFocus (Input_Context); |
1760 | XSetICFocus (Input_Context); |
1682 | } |
1761 | } |
1683 | #endif |
1762 | #endif |
1684 | #if CURSOR_BLINK |
1763 | #if CURSOR_BLINK |
1685 | if (options & Opt_cursorBlink) |
1764 | if (OPTION (Opt_cursorBlink)) |
1686 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1765 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1687 | #endif |
1766 | #endif |
1688 | #if OFF_FOCUS_FADING |
1767 | #if OFF_FOCUS_FADING |
1689 | if (rs[Rs_fade]) |
1768 | if (rs[Rs_fade]) |
1690 | { |
1769 | { |
… | |
… | |
1701 | if (focus) |
1780 | if (focus) |
1702 | { |
1781 | { |
1703 | focus = 0; |
1782 | focus = 0; |
1704 | want_refresh = 1; |
1783 | want_refresh = 1; |
1705 | |
1784 | |
|
|
1785 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1786 | |
1706 | #if ENABLE_FRILLS || ISO_14755 |
1787 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1788 | if (iso14755buf) |
|
|
1789 | { |
1707 | iso14755buf = 0; |
1790 | iso14755buf = 0; |
1708 | #endif |
|
|
1709 | #if ENABLE_OVERLAY |
1791 | # if ENABLE_OVERLAY |
1710 | scr_overlay_off (); |
1792 | scr_overlay_off (); |
|
|
1793 | # endif |
|
|
1794 | } |
1711 | #endif |
1795 | #endif |
1712 | #if USE_XIM |
1796 | #if USE_XIM |
1713 | if (Input_Context != NULL) |
1797 | if (Input_Context != NULL) |
1714 | XUnsetICFocus (Input_Context); |
1798 | XUnsetICFocus (Input_Context); |
1715 | #endif |
1799 | #endif |
1716 | #if CURSOR_BLINK |
1800 | #if CURSOR_BLINK |
1717 | if (options & Opt_cursorBlink) |
1801 | if (OPTION (Opt_cursorBlink)) |
1718 | cursor_blink_ev.stop (); |
1802 | cursor_blink_ev.stop (); |
1719 | hidden_cursor = 0; |
1803 | hidden_cursor = 0; |
1720 | #endif |
1804 | #endif |
1721 | #if OFF_FOCUS_FADING |
1805 | #if OFF_FOCUS_FADING |
1722 | if (rs[Rs_fade]) |
1806 | if (rs[Rs_fade]) |
… | |
… | |
1746 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1830 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1747 | return; |
1831 | return; |
1748 | |
1832 | |
1749 | /* FALLTHROUGH */ |
1833 | /* FALLTHROUGH */ |
1750 | case ReparentNotify: |
1834 | case ReparentNotify: |
1751 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1835 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
1752 | want_refresh = want_full_refresh = 1; |
1836 | want_refresh = want_full_refresh = 1; |
1753 | break; |
1837 | break; |
1754 | } |
1838 | } |
1755 | } |
1839 | } |
1756 | #endif |
1840 | #endif |
… | |
… | |
1759 | rxvt_term::button_press (XButtonEvent &ev) |
1843 | rxvt_term::button_press (XButtonEvent &ev) |
1760 | { |
1844 | { |
1761 | int reportmode = 0, clickintime; |
1845 | int reportmode = 0, clickintime; |
1762 | |
1846 | |
1763 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1847 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1848 | |
1764 | if (!bypass_keystate) |
1849 | if (!bypass_keystate) |
1765 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1850 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1766 | |
1851 | |
1767 | /* |
1852 | /* |
1768 | * VT window processing of button press |
1853 | * VT window processing of button press |
… | |
… | |
1817 | else |
1902 | else |
1818 | { |
1903 | { |
1819 | if (ev.button != MEvent.button) |
1904 | if (ev.button != MEvent.button) |
1820 | MEvent.clicks = 0; |
1905 | MEvent.clicks = 0; |
1821 | |
1906 | |
|
|
1907 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
1822 | switch (ev.button) |
1908 | switch (ev.button) |
1823 | { |
1909 | { |
1824 | case Button1: |
1910 | case Button1: |
1825 | /* allow meta + click to select rectangular areas */ |
1911 | /* allow meta + click to select rectangular areas */ |
1826 | /* should be done in screen.C */ |
1912 | /* should be done in screen.C */ |
1827 | #if ENABLE_FRILLS |
1913 | #if ENABLE_FRILLS |
1828 | selection.rect = !!(ev.state & ModMetaMask); |
1914 | selection.rect = !!(ev.state & ModMetaMask); |
1829 | #else |
1915 | #else |
1830 | selection.rect = false; |
1916 | selection.rect = false; |
1831 | #endif |
1917 | #endif |
1832 | |
1918 | |
1833 | /* allow shift+left click to extend selection */ |
1919 | /* allow shift+left click to extend selection */ |
1834 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1920 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1835 | { |
1921 | { |
1836 | if (MEvent.button == Button1 && clickintime) |
1922 | if (MEvent.button == Button1 && clickintime) |
1837 | selection_rotate (ev.x, ev.y); |
1923 | selection_rotate (ev.x, ev.y); |
1838 | else |
1924 | else |
1839 | selection_extend (ev.x, ev.y, 1); |
1925 | selection_extend (ev.x, ev.y, 1); |
1840 | } |
1926 | } |
1841 | else |
1927 | else |
1842 | { |
1928 | { |
1843 | if (MEvent.button == Button1 && clickintime) |
1929 | if (MEvent.button == Button1 && clickintime) |
1844 | MEvent.clicks++; |
1930 | MEvent.clicks++; |
1845 | else |
1931 | else |
1846 | MEvent.clicks = 1; |
1932 | MEvent.clicks = 1; |
1847 | |
1933 | |
1848 | selection_click (MEvent.clicks, ev.x, ev.y); |
1934 | selection_click (MEvent.clicks, ev.x, ev.y); |
1849 | } |
1935 | } |
1850 | |
1936 | |
1851 | MEvent.button = Button1; |
1937 | MEvent.button = Button1; |
1852 | break; |
1938 | break; |
1853 | |
1939 | |
1854 | case Button3: |
1940 | case Button3: |
1855 | if (MEvent.button == Button3 && clickintime) |
1941 | if (MEvent.button == Button3 && clickintime) |
1856 | selection_rotate (ev.x, ev.y); |
1942 | selection_rotate (ev.x, ev.y); |
1857 | else |
1943 | else |
1858 | selection_extend (ev.x, ev.y, 1); |
1944 | selection_extend (ev.x, ev.y, 1); |
1859 | |
1945 | |
1860 | MEvent.button = Button3; |
1946 | MEvent.button = Button3; |
1861 | break; |
1947 | break; |
1862 | } |
1948 | } |
1863 | } |
1949 | } |
1864 | |
1950 | |
1865 | MEvent.time = ev.time; |
1951 | MEvent.time = ev.time; |
1866 | return; |
1952 | return; |
1867 | } |
1953 | } |
1868 | |
1954 | |
… | |
… | |
2078 | if (priv_modes & PrivMode_mouse_report |
2164 | if (priv_modes & PrivMode_mouse_report |
2079 | && bypass_keystate |
2165 | && bypass_keystate |
2080 | && ev.button == Button1 && MEvent.clicks <= 1) |
2166 | && ev.button == Button1 && MEvent.clicks <= 1) |
2081 | selection_extend (ev.x, ev.y, 0); |
2167 | selection_extend (ev.x, ev.y, 0); |
2082 | |
2168 | |
|
|
2169 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2170 | return; |
|
|
2171 | |
2083 | switch (ev.button) |
2172 | switch (ev.button) |
2084 | { |
2173 | { |
2085 | case Button1: |
2174 | case Button1: |
2086 | case Button3: |
2175 | case Button3: |
2087 | selection_make (ev.time); |
2176 | selection_make (ev.time); |
… | |
… | |
2098 | |
2187 | |
2099 | v = ev.button == Button4 ? UP : DN; |
2188 | v = ev.button == Button4 ? UP : DN; |
2100 | |
2189 | |
2101 | if (ev.state & ShiftMask) |
2190 | if (ev.state & ShiftMask) |
2102 | i = 1; |
2191 | i = 1; |
2103 | else if (options & Opt_mouseWheelScrollPage) |
2192 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2104 | i = nrow - 1; |
2193 | i = nrow - 1; |
2105 | else |
2194 | else |
2106 | i = 5; |
2195 | i = 5; |
2107 | |
2196 | |
2108 | # ifdef MOUSE_SLIP_WHEELING |
2197 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2394 | XWindowAttributes wattr, wrootattr; |
2483 | XWindowAttributes wattr, wrootattr; |
2395 | dDisp; |
2484 | dDisp; |
2396 | |
2485 | |
2397 | pchanged = 0; |
2486 | pchanged = 0; |
2398 | |
2487 | |
2399 | if (!(options & Opt_transparent)) |
2488 | if (!OPTION (Opt_transparent)) |
2400 | return pchanged; /* Don't try any more */ |
2489 | return pchanged; /* Don't try any more */ |
2401 | |
2490 | |
2402 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2491 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2403 | rootdepth = wrootattr.depth; |
2492 | rootdepth = wrootattr.depth; |
2404 | |
2493 | |
… | |
… | |
2632 | bool |
2721 | bool |
2633 | rxvt_term::cmd_parse () |
2722 | rxvt_term::cmd_parse () |
2634 | { |
2723 | { |
2635 | bool flag = false; |
2724 | bool flag = false; |
2636 | unicode_t ch = NOCHAR; |
2725 | unicode_t ch = NOCHAR; |
2637 | unsigned char *seq_begin; // remember start of esc-sequence here |
2726 | char *seq_begin; // remember start of esc-sequence here |
2638 | |
2727 | |
2639 | for (;;) |
2728 | for (;;) |
2640 | { |
2729 | { |
2641 | if (ch == NOCHAR) |
2730 | if (ch == NOCHAR) |
2642 | { |
2731 | { |
2643 | seq_begin = cmdbuf_ptr; |
2732 | seq_begin = cmdbuf_ptr; |
2644 | ch = next_char (); |
2733 | ch = next_char (); |
2645 | } |
|
|
2646 | |
2734 | |
2647 | if (ch == NOCHAR) // TODO: improve |
2735 | if (ch == NOCHAR) |
2648 | break; |
2736 | break; |
|
|
2737 | } |
2649 | |
2738 | |
2650 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2739 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2651 | { |
2740 | { |
2652 | if (!seen_input) |
2741 | if (!seen_input) |
2653 | { |
2742 | { |
… | |
… | |
2682 | if (ch == C0_LF) |
2771 | if (ch == C0_LF) |
2683 | nlines++; |
2772 | nlines++; |
2684 | |
2773 | |
2685 | refresh_count++; |
2774 | refresh_count++; |
2686 | |
2775 | |
2687 | if (!(options & Opt_jumpScroll) |
2776 | if (!OPTION (Opt_jumpScroll) |
2688 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2777 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2689 | { |
2778 | { |
2690 | refreshnow = true; |
2779 | refreshnow = true; |
|
|
2780 | refresh_count = 0; |
2691 | ch = NOCHAR; |
2781 | ch = NOCHAR; |
2692 | break; |
2782 | break; |
2693 | } |
2783 | } |
2694 | |
2784 | |
2695 | // scr_add_lines only works for nlines <= nrow - 1. |
2785 | // scr_add_lines only works for nlines <= nrow - 1. |
2696 | if (nlines >= nrow - 1) |
2786 | if (nlines >= nrow - 1) |
2697 | { |
2787 | { |
|
|
2788 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) |
2698 | scr_add_lines (buf, nlines, str - buf); |
2789 | scr_add_lines (buf, nlines, str - buf); |
|
|
2790 | |
2699 | nlines = 0; |
2791 | nlines = 0; |
2700 | str = buf; |
2792 | str = buf; |
2701 | eol = str + min (ncol, UBUFSIZ); |
2793 | eol = str + min (ncol, UBUFSIZ); |
2702 | } |
2794 | } |
2703 | |
2795 | |
… | |
… | |
2716 | |
2808 | |
2717 | seq_begin = cmdbuf_ptr; |
2809 | seq_begin = cmdbuf_ptr; |
2718 | ch = next_char (); |
2810 | ch = next_char (); |
2719 | } |
2811 | } |
2720 | |
2812 | |
|
|
2813 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) |
2721 | scr_add_lines (buf, nlines, str - buf); |
2814 | scr_add_lines (buf, nlines, str - buf); |
2722 | |
2815 | |
2723 | /* |
2816 | /* |
2724 | * If there have been a lot of new lines, then update the screen |
2817 | * If there have been a lot of new lines, then update the screen |
2725 | * What the heck I'll cheat and only refresh less than every page-full. |
2818 | * What the heck I'll cheat and only refresh less than every page-full. |
2726 | * the number of pages between refreshes is refresh_limit, which |
2819 | * the number of pages between refreshes is refresh_limit, which |
2727 | * is incremented here because we must be doing flat-out scrolling. |
2820 | * is incremented here because we must be doing flat-out scrolling. |
2728 | */ |
2821 | */ |
2729 | if (refreshnow) |
2822 | if (refreshnow) |
2730 | { |
2823 | { |
2731 | if ((options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2824 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2732 | refresh_limit++; |
2825 | refresh_limit++; |
2733 | else |
2826 | else |
2734 | { |
2827 | { |
2735 | flag = true; |
2828 | flag = true; |
2736 | scr_refresh (refresh_type); |
2829 | scr_refresh (refresh_type); |
|
|
2830 | flush_ev.stop (); |
2737 | } |
2831 | } |
2738 | } |
2832 | } |
2739 | |
2833 | |
2740 | } |
2834 | } |
2741 | else |
2835 | else |
… | |
… | |
2772 | rxvt_term::next_char () |
2866 | rxvt_term::next_char () |
2773 | { |
2867 | { |
2774 | while (cmdbuf_ptr < cmdbuf_endp) |
2868 | while (cmdbuf_ptr < cmdbuf_endp) |
2775 | { |
2869 | { |
2776 | // assume 7-bit to be ascii ALWAYS |
2870 | // assume 7-bit to be ascii ALWAYS |
2777 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2871 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2778 | return *cmdbuf_ptr++; |
2872 | return *cmdbuf_ptr++; |
2779 | |
2873 | |
2780 | wchar_t wc; |
2874 | wchar_t wc; |
2781 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2875 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2782 | |
2876 | |
2783 | if (len == (size_t)-2) |
2877 | if (len == (size_t)-2) |
2784 | { |
2878 | { |
2785 | // the mbstate stores incomplete sequences. didn't know this :/ |
2879 | // the mbstate stores incomplete sequences. didn't know this :/ |
2786 | cmdbuf_ptr = cmdbuf_endp; |
2880 | cmdbuf_ptr = cmdbuf_endp; |
… | |
… | |
2925 | case C0_ESC: |
3019 | case C0_ESC: |
2926 | process_escape_seq (); |
3020 | process_escape_seq (); |
2927 | break; |
3021 | break; |
2928 | case C0_ENQ: /* terminal Status */ |
3022 | case C0_ENQ: /* terminal Status */ |
2929 | if (rs[Rs_answerbackstring]) |
3023 | if (rs[Rs_answerbackstring]) |
2930 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
3024 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2931 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2932 | else |
3025 | else |
2933 | tt_write ((unsigned char *)VT100_ANS, |
3026 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2934 | (unsigned int)strlen (VT100_ANS)); |
|
|
2935 | break; |
3027 | break; |
2936 | case C0_BEL: /* bell */ |
3028 | case C0_BEL: /* bell */ |
2937 | scr_bell (); |
3029 | scr_bell (); |
2938 | break; |
3030 | break; |
2939 | case C0_BS: /* backspace */ |
3031 | case C0_BS: /* backspace */ |
… | |
… | |
3127 | process_dcs_seq (); |
3219 | process_dcs_seq (); |
3128 | break; |
3220 | break; |
3129 | |
3221 | |
3130 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3222 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3131 | case C1_SCI: /* ESC Z */ |
3223 | case C1_SCI: /* ESC Z */ |
3132 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3224 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3133 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3134 | break; /* steal obsolete ESC [ c */ |
3225 | break; /* steal obsolete ESC [ c */ |
3135 | |
3226 | |
3136 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3227 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3137 | case C1_CSI: /* ESC [ */ |
3228 | case C1_CSI: /* ESC [ */ |
3138 | process_csi_seq (); |
3229 | process_csi_seq (); |
… | |
… | |
3382 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3473 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3383 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3474 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3384 | break; |
3475 | break; |
3385 | |
3476 | |
3386 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3477 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3387 | tt_write ((const unsigned char *)VT100_ANS, |
3478 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3388 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3389 | break; |
3479 | break; |
3390 | |
3480 | |
3391 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3481 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3392 | process_sgr_mode (nargs, arg); |
3482 | process_sgr_mode (nargs, arg); |
3393 | break; |
3483 | break; |
… | |
… | |
3400 | break; |
3490 | break; |
3401 | case 6: /* CPR requested */ |
3491 | case 6: /* CPR requested */ |
3402 | scr_report_position (); |
3492 | scr_report_position (); |
3403 | break; |
3493 | break; |
3404 | case 7: /* unofficial extension */ |
3494 | case 7: /* unofficial extension */ |
3405 | if (options & Opt_insecure) |
3495 | if (OPTION (Opt_insecure)) |
3406 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3496 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3407 | break; |
3497 | break; |
3408 | case 8: /* unofficial extension */ |
3498 | case 8: /* unofficial extension */ |
3409 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3499 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3410 | break; |
3500 | break; |
… | |
… | |
3574 | break; |
3664 | break; |
3575 | case 20: /* report icon label */ |
3665 | case 20: /* report icon label */ |
3576 | { |
3666 | { |
3577 | char *s; |
3667 | char *s; |
3578 | XGetIconName (disp, parent[0], &s); |
3668 | XGetIconName (disp, parent[0], &s); |
3579 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3669 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3580 | XFree (s); |
3670 | XFree (s); |
3581 | } |
3671 | } |
3582 | break; |
3672 | break; |
3583 | case 21: /* report window title */ |
3673 | case 21: /* report window title */ |
3584 | { |
3674 | { |
3585 | char *s; |
3675 | char *s; |
3586 | XFetchName (disp, parent[0], &s); |
3676 | XFetchName (disp, parent[0], &s); |
3587 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3677 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3588 | XFree (s); |
3678 | XFree (s); |
3589 | } |
3679 | } |
3590 | break; |
3680 | break; |
3591 | } |
3681 | } |
3592 | } |
3682 | } |
… | |
… | |
3595 | /*----------------------------------------------------------------------*/ |
3685 | /*----------------------------------------------------------------------*/ |
3596 | /* |
3686 | /* |
3597 | * get input up until STRING TERMINATOR (or BEL) |
3687 | * get input up until STRING TERMINATOR (or BEL) |
3598 | * ends_how is terminator used. returned input must be free()'d |
3688 | * ends_how is terminator used. returned input must be free()'d |
3599 | */ |
3689 | */ |
3600 | unsigned char * |
3690 | char * |
3601 | rxvt_term::get_to_st (unicode_t &ends_how) |
3691 | rxvt_term::get_to_st (unicode_t &ends_how) |
3602 | { |
3692 | { |
3603 | unicode_t ch; |
3693 | unicode_t ch; |
3604 | bool seen_esc = false; |
3694 | bool seen_esc = false; |
3605 | unsigned int n = 0; |
3695 | unsigned int n = 0; |
… | |
… | |
3638 | |
3728 | |
3639 | string[n++] = '\0'; |
3729 | string[n++] = '\0'; |
3640 | |
3730 | |
3641 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3731 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3642 | |
3732 | |
3643 | return (unsigned char *)rxvt_wcstombs (string); |
3733 | return rxvt_wcstombs (string); |
3644 | } |
3734 | } |
3645 | |
3735 | |
3646 | /*----------------------------------------------------------------------*/ |
3736 | /*----------------------------------------------------------------------*/ |
3647 | /* |
3737 | /* |
3648 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3738 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3649 | */ |
3739 | */ |
3650 | void |
3740 | void |
3651 | rxvt_term::process_dcs_seq () |
3741 | rxvt_term::process_dcs_seq () |
3652 | { |
3742 | { |
3653 | unsigned char *s; |
3743 | char *s; |
3654 | unicode_t eh; |
3744 | unicode_t eh; |
3655 | |
3745 | |
3656 | /* |
3746 | /* |
3657 | * Not handled yet |
3747 | * Not handled yet |
3658 | */ |
3748 | */ |
… | |
… | |
3677 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3767 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3678 | arg = arg * 10 + (ch - '0'); |
3768 | arg = arg * 10 + (ch - '0'); |
3679 | |
3769 | |
3680 | if (ch == ';') |
3770 | if (ch == ';') |
3681 | { |
3771 | { |
3682 | unsigned char *s = get_to_st (eh); |
3772 | char *s = get_to_st (eh); |
3683 | |
3773 | |
3684 | if (s) |
3774 | if (s) |
3685 | { |
3775 | { |
3686 | process_xterm_seq (arg, (char *)s, eh); |
3776 | process_xterm_seq (arg, s, eh); |
3687 | free (s); |
3777 | free (s); |
3688 | } |
3778 | } |
3689 | } |
3779 | } |
3690 | } |
3780 | } |
3691 | |
3781 | |
3692 | void |
3782 | void |
3693 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3783 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3694 | { |
3784 | { |
3695 | if (str[0] == '?' && !str[1]) |
3785 | if (str[0] == '?' && !str[1]) |
3696 | { |
3786 | { |
3697 | unsigned short r, g, b; |
3787 | unsigned short r, g, b; |
3698 | pix_colors_focused[color].get (display, r, g, b); |
3788 | pix_colors_focused[color].get (display, r, g, b); |
… | |
… | |
3704 | |
3794 | |
3705 | /* |
3795 | /* |
3706 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3796 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3707 | */ |
3797 | */ |
3708 | void |
3798 | void |
3709 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3799 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3710 | { |
3800 | { |
3711 | int changed = 0; |
3801 | int changed = 0; |
3712 | int color; |
3802 | int color; |
3713 | char *buf, *name; |
3803 | char *buf, *name; |
3714 | bool query = str[0] == '?' && !str[1]; |
3804 | bool query = str[0] == '?' && !str[1]; |
… | |
… | |
3868 | // TODO, when secure mode? |
3958 | // TODO, when secure mode? |
3869 | break; |
3959 | break; |
3870 | |
3960 | |
3871 | #ifdef MENUBAR |
3961 | #ifdef MENUBAR |
3872 | case URxvt_Menu: |
3962 | case URxvt_Menu: |
3873 | if (options & Opt_insecure) |
3963 | if (OPTION (Opt_insecure)) |
3874 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
3964 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
3875 | break; |
3965 | break; |
3876 | #endif |
3966 | #endif |
3877 | #if 0 |
3967 | #if 0 |
3878 | case XTerm_dumpscreen: /* no error notices */ |
3968 | case XTerm_dumpscreen: /* no error notices */ |
… | |
… | |
3894 | case URxvt_italicFont: |
3984 | case URxvt_italicFont: |
3895 | case URxvt_boldItalicFont: |
3985 | case URxvt_boldItalicFont: |
3896 | #endif |
3986 | #endif |
3897 | if (query) |
3987 | if (query) |
3898 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3988 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3899 | (options & Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3989 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3900 | ? fontset[op - URxvt_font]->fontdesc : "", |
3990 | ? fontset[op - URxvt_font]->fontdesc : "", |
3901 | resp); |
3991 | resp); |
3902 | else |
3992 | else |
3903 | { |
3993 | { |
3904 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3994 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
3910 | break; |
4000 | break; |
3911 | |
4001 | |
3912 | #if ENABLE_FRILLS |
4002 | #if ENABLE_FRILLS |
3913 | case URxvt_locale: |
4003 | case URxvt_locale: |
3914 | if (query) |
4004 | if (query) |
3915 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); |
4005 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3916 | else |
4006 | else |
3917 | { |
4007 | { |
3918 | set_locale (str); |
4008 | set_locale (str); |
3919 | pty.set_utf8_mode (enc_utf8); |
4009 | pty.set_utf8_mode (enc_utf8); |
3920 | init_xlocale (); |
4010 | init_xlocale (); |
3921 | } |
4011 | } |
3922 | break; |
4012 | break; |
3923 | |
4013 | |
3924 | case URxvt_view_up: |
4014 | case URxvt_view_up: |
3925 | case URxvt_view_down: |
4015 | case URxvt_view_down: |
|
|
4016 | { |
3926 | int lines = atoi (str); |
4017 | int lines = atoi (str); |
3927 | |
4018 | |
3928 | if (lines) |
4019 | if (lines) |
3929 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
4020 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3930 | else |
4021 | else |
3931 | { |
|
|
3932 | scr_erase_savelines (); |
4022 | scr_erase_savelines (); |
3933 | } |
4023 | } |
3934 | |
4024 | |
|
|
4025 | break; |
|
|
4026 | #endif |
|
|
4027 | |
|
|
4028 | #if ENABLE_PERL |
|
|
4029 | case URxvt_perl: |
|
|
4030 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) |
|
|
4031 | ; // no responses yet |
3935 | break; |
4032 | break; |
3936 | #endif |
4033 | #endif |
3937 | } |
4034 | } |
3938 | } |
4035 | } |
3939 | /*----------------------------------------------------------------------*/ |
4036 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4048 | } |
4145 | } |
4049 | |
4146 | |
4050 | /* extra handling for values with state unkept */ |
4147 | /* extra handling for values with state unkept */ |
4051 | switch (arg[i]) |
4148 | switch (arg[i]) |
4052 | { |
4149 | { |
|
|
4150 | #if ENABLE_STYLES |
|
|
4151 | case 1021: |
|
|
4152 | if (mode) |
|
|
4153 | SET_OPTION (Opt_intensityStyles); |
|
|
4154 | else |
|
|
4155 | CLR_OPTION (Opt_intensityStyles); |
|
|
4156 | |
|
|
4157 | scr_touch (true); |
|
|
4158 | break; |
|
|
4159 | #endif |
4053 | case 1048: /* alternative cursor save */ |
4160 | case 1048: /* alternative cursor save */ |
4054 | case 1049: |
4161 | case 1049: |
4055 | if (options & Opt_secondaryScreen) |
4162 | if (OPTION (Opt_secondaryScreen)) |
4056 | if (mode == 0) |
4163 | if (mode == 0) |
4057 | scr_cursor (RESTORE); |
4164 | scr_cursor (RESTORE); |
4058 | else if (mode == 1) |
4165 | else if (mode == 1) |
4059 | scr_cursor (SAVE); |
4166 | scr_cursor (SAVE); |
4060 | break; |
4167 | break; |
… | |
… | |
4075 | case 3: /* 80/132 */ |
4182 | case 3: /* 80/132 */ |
4076 | if (priv_modes & PrivMode_132OK) |
4183 | if (priv_modes & PrivMode_132OK) |
4077 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4184 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4078 | break; |
4185 | break; |
4079 | case 4: /* smooth scrolling */ |
4186 | case 4: /* smooth scrolling */ |
4080 | if (state) |
4187 | if (!state) |
4081 | options &= ~Opt_jumpScroll; |
4188 | SET_OPTION (Opt_jumpScroll); |
4082 | else |
4189 | else |
4083 | options |= Opt_jumpScroll; |
4190 | CLR_OPTION (Opt_jumpScroll); |
4084 | break; |
4191 | break; |
4085 | case 5: /* reverse video */ |
4192 | case 5: /* reverse video */ |
4086 | scr_rvideo_mode (state); |
4193 | scr_rvideo_mode (state); |
4087 | break; |
4194 | break; |
4088 | case 6: /* relative/absolute origins */ |
4195 | case 6: /* relative/absolute origins */ |
… | |
… | |
4129 | #if 0 |
4236 | #if 0 |
4130 | case 1001: |
4237 | case 1001: |
4131 | break; /* X11 mouse highlighting */ |
4238 | break; /* X11 mouse highlighting */ |
4132 | #endif |
4239 | #endif |
4133 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4240 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4134 | if (state) |
4241 | if (!state) |
4135 | options &= ~Opt_scrollTtyOutput; |
4242 | SET_OPTION (Opt_scrollTtyOutput); |
4136 | else |
4243 | else |
4137 | options |= Opt_scrollTtyOutput; |
4244 | CLR_OPTION (Opt_scrollTtyOutput); |
4138 | break; |
4245 | break; |
4139 | case 1011: /* scroll to bottom on key press */ |
4246 | case 1011: /* scroll to bottom on key press */ |
4140 | if (state) |
4247 | if (state) |
4141 | options |= Opt_scrollTtyKeypress; |
4248 | SET_OPTION (Opt_scrollTtyKeypress); |
4142 | else |
4249 | else |
4143 | options &= ~Opt_scrollTtyKeypress; |
4250 | CLR_OPTION (Opt_scrollTtyKeypress); |
4144 | break; |
4251 | break; |
4145 | case 1047: /* secondary screen w/ clearing last */ |
4252 | case 1047: /* secondary screen w/ clearing last */ |
4146 | if (options & Opt_secondaryScreen) |
4253 | if (OPTION (Opt_secondaryScreen)) |
4147 | if (current_screen != PRIMARY) |
4254 | if (current_screen != PRIMARY) |
4148 | scr_erase_screen (2); |
4255 | scr_erase_screen (2); |
4149 | scr_change_screen (state); |
4256 | scr_change_screen (state); |
4150 | break; |
4257 | break; |
4151 | case 1049: /* secondary screen w/ clearing first */ |
4258 | case 1049: /* secondary screen w/ clearing first */ |
4152 | scr_change_screen (state); |
4259 | scr_change_screen (state); |
4153 | if (options & Opt_secondaryScreen) |
4260 | if (OPTION (Opt_secondaryScreen)) |
4154 | if (current_screen != PRIMARY) |
4261 | if (current_screen != PRIMARY) |
4155 | scr_erase_screen (2); |
4262 | scr_erase_screen (2); |
4156 | break; |
4263 | break; |
4157 | default: |
4264 | default: |
4158 | break; |
4265 | break; |
… | |
… | |
4286 | scr_color (Color_bg, Color_bg); |
4393 | scr_color (Color_bg, Color_bg); |
4287 | break; |
4394 | break; |
4288 | |
4395 | |
4289 | //case 50: // not variable spacing |
4396 | //case 50: // not variable spacing |
4290 | |
4397 | |
4291 | #ifndef NO_BRIGHTCOLOR |
4398 | #if ENABLE_FRILLS |
4292 | case 90: |
4399 | case 90: |
4293 | case 91: /* set bright fg color */ |
4400 | case 91: /* set bright fg color */ |
4294 | case 92: |
4401 | case 92: |
4295 | case 93: |
4402 | case 93: |
4296 | case 94: |
4403 | case 94: |
… | |
… | |
4308 | case 106: |
4415 | case 106: |
4309 | case 107: |
4416 | case 107: |
4310 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4417 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4311 | break; |
4418 | break; |
4312 | #endif |
4419 | #endif |
4313 | |
|
|
4314 | } |
4420 | } |
4315 | } |
4421 | } |
4316 | } |
4422 | } |
4317 | /*}}} */ |
4423 | /*}}} */ |
4318 | |
4424 | |
… | |
… | |
4342 | */ |
4448 | */ |
4343 | void |
4449 | void |
4344 | rxvt_term::tt_printf (const char *fmt,...) |
4450 | rxvt_term::tt_printf (const char *fmt,...) |
4345 | { |
4451 | { |
4346 | va_list arg_ptr; |
4452 | va_list arg_ptr; |
4347 | unsigned char buf[256]; |
4453 | char buf[256]; |
4348 | |
4454 | |
4349 | va_start (arg_ptr, fmt); |
4455 | va_start (arg_ptr, fmt); |
4350 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4456 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4351 | va_end (arg_ptr); |
4457 | va_end (arg_ptr); |
4352 | tt_write (buf, strlen (buf)); |
4458 | tt_write (buf, strlen (buf)); |
… | |
… | |
4357 | * or generated by us in response to a query ESC sequence. |
4463 | * or generated by us in response to a query ESC sequence. |
4358 | */ |
4464 | */ |
4359 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4465 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4360 | |
4466 | |
4361 | void |
4467 | void |
4362 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4468 | rxvt_term::tt_write (const char *data, unsigned int len) |
4363 | { |
4469 | { |
|
|
4470 | if (pty.pty < 0) |
|
|
4471 | return; |
|
|
4472 | |
4364 | if (v_buflen == 0) |
4473 | if (v_buflen == 0) |
4365 | { |
4474 | { |
4366 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4475 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4367 | |
4476 | |
4368 | if ((unsigned int)written == len) |
4477 | if ((unsigned int)written == len) |
… | |
… | |
4370 | |
4479 | |
4371 | data += written; |
4480 | data += written; |
4372 | len -= written; |
4481 | len -= written; |
4373 | } |
4482 | } |
4374 | |
4483 | |
4375 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4484 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4376 | |
4485 | |
4377 | memcpy (v_buffer + v_buflen, data, len); |
4486 | memcpy (v_buffer + v_buflen, data, len); |
4378 | v_buflen += len; |
4487 | v_buflen += len; |
4379 | |
4488 | |
4380 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4489 | pty_ev.set (EVENT_READ | EVENT_WRITE); |