… | |
… | |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
50 | #include "version.h" |
50 | #include "version.h" |
51 | #include "command.h" |
51 | #include "command.h" |
52 | |
52 | |
53 | #include <wchar.h> |
53 | #include <cwchar> |
|
|
54 | #include <csignal> |
54 | |
55 | |
55 | /*----------------------------------------------------------------------*/ |
56 | /*----------------------------------------------------------------------*/ |
56 | |
57 | |
57 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | |
59 | |
… | |
… | |
133 | { |
134 | { |
134 | text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x]; |
135 | text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x]; |
135 | |
136 | |
136 | if (t != NOCHAR || !x) |
137 | if (t != NOCHAR || !x) |
137 | { |
138 | { |
138 | iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x]); |
139 | iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x], |
|
|
140 | screen.rend[y + TermWin.saveLines - TermWin.view_start][x]); |
139 | iso14755buf = ISO_14755_54; |
141 | iso14755buf = ISO_14755_54; |
140 | break; |
142 | break; |
141 | } |
143 | } |
142 | |
144 | |
143 | x--; |
145 | x--; |
… | |
… | |
146 | } |
148 | } |
147 | #endif |
149 | #endif |
148 | |
150 | |
149 | #if ENABLE_OVERLAY |
151 | #if ENABLE_OVERLAY |
150 | void |
152 | void |
151 | rxvt_term::iso14755_51 (wchar_t ch) |
153 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r) |
152 | { |
154 | { |
|
|
155 | rxvt_fontset *fs = FONTSET (r); |
|
|
156 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
153 | wchar_t *chr, *alloc; |
157 | wchar_t *chr, *alloc, ch2; |
154 | int len; |
158 | int len; |
155 | |
159 | |
156 | #if ENABLE_COMBINING |
160 | #if ENABLE_COMBINING |
157 | if (IS_COMPOSE (ch)) |
161 | if (IS_COMPOSE (ch)) |
158 | { |
162 | { |
… | |
… | |
161 | rxvt_composite.expand (ch, chr); |
165 | rxvt_composite.expand (ch, chr); |
162 | } |
166 | } |
163 | else |
167 | else |
164 | #endif |
168 | #endif |
165 | { |
169 | { |
|
|
170 | ch2 = ch; |
|
|
171 | |
166 | alloc = 0; |
172 | alloc = 0; |
167 | chr = &ch; |
173 | chr = &ch2; |
168 | len = 1; |
174 | len = 1; |
169 | } |
175 | } |
170 | |
176 | |
171 | scr_overlay_new (0, -1, 8 + 5, len); |
177 | int width = strlen (f->name); |
|
|
178 | |
|
|
179 | scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); |
|
|
180 | |
|
|
181 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
172 | |
182 | |
173 | for (int y = 0; y < len; y++) |
183 | for (int y = 0; y < len; y++) |
174 | { |
184 | { |
175 | char buf[9]; |
185 | char buf[9]; |
176 | |
186 | |
… | |
… | |
181 | scr_overlay_set (9, y, '='); |
191 | scr_overlay_set (9, y, '='); |
182 | #if !UNICODE3 |
192 | #if !UNICODE3 |
183 | if (ch >= 0x10000) |
193 | if (ch >= 0x10000) |
184 | ch = 0xfffd; |
194 | ch = 0xfffd; |
185 | #endif |
195 | #endif |
186 | scr_overlay_set (11, y, ch); |
196 | scr_overlay_set (11, y, ch, r); |
187 | scr_overlay_set (12, y, NOCHAR); |
197 | scr_overlay_set (12, y, NOCHAR, r); |
188 | } |
198 | } |
|
|
199 | |
|
|
200 | scr_overlay_set (0, len, f->name); |
189 | |
201 | |
190 | #if ENABLE_COMBINING |
202 | #if ENABLE_COMBINING |
191 | if (alloc) |
203 | if (alloc) |
192 | delete [] alloc; |
204 | delete [] alloc; |
193 | #endif |
205 | #endif |
… | |
… | |
406 | { |
418 | { |
407 | /* normal XTerm key bindings */ |
419 | /* normal XTerm key bindings */ |
408 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
420 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
409 | selection_request (ev.time, 0, 0); |
421 | selection_request (ev.time, 0, 0); |
410 | return; |
422 | return; |
411 | #if TODO // TODO |
423 | #if TODO |
412 | /* rxvt extras */ |
424 | /* rxvt extras */ |
413 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
425 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
414 | change_font (FONT_UP); |
426 | change_font (FONT_UP); |
415 | return; |
427 | return; |
416 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
428 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
… | |
… | |
476 | #endif |
488 | #endif |
477 | |
489 | |
478 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
490 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
479 | { |
491 | { |
480 | #ifdef KEYSYM_RESOURCE |
492 | #ifdef KEYSYM_RESOURCE |
481 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
493 | if (!(shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
482 | { |
494 | { |
483 | unsigned int l; |
495 | unsigned int l; |
484 | const unsigned char *kbuf0; |
496 | const unsigned char *kbuf0; |
485 | |
497 | |
486 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
498 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
… | |
… | |
773 | case XK_F35: /* "\033[49~" */ |
785 | case XK_F35: /* "\033[49~" */ |
774 | FKEY (31, XK_F17); |
786 | FKEY (31, XK_F17); |
775 | break; |
787 | break; |
776 | #undef FKEY |
788 | #undef FKEY |
777 | default: |
789 | default: |
778 | newlen = 0; |
790 | if (len == 0 |
779 | break; |
791 | && (keysym & 0xfff0) != 0xff70 |
|
|
792 | && (keysym & 0xfff0) != 0xffe0) |
|
|
793 | /* generate a keycode for every remaining keypress */ |
|
|
794 | sprintf ((char *)kbuf, "\033[%x;%xA", (unsigned char)ev.state, (unsigned short)keysym); |
780 | } |
795 | } |
|
|
796 | |
781 | if (newlen) |
797 | if (newlen) |
782 | len = strlen (kbuf); |
798 | len = strlen (kbuf); |
783 | } |
799 | } |
784 | |
800 | |
785 | /* |
801 | /* |
… | |
… | |
793 | } |
809 | } |
794 | else if (ctrl && keysym == XK_minus) |
810 | else if (ctrl && keysym == XK_minus) |
795 | { |
811 | { |
796 | len = 1; |
812 | len = 1; |
797 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
813 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
814 | } |
|
|
815 | else if (keysym == XK_ISO_Left_Tab) |
|
|
816 | { |
|
|
817 | strcpy (kbuf, "\033[Z"); |
|
|
818 | len = 3; |
|
|
819 | } |
|
|
820 | else if (len == 0 |
|
|
821 | && (keysym & 0xffe0) != 0xfe00 |
|
|
822 | && (keysym < 0xfe50 || keysym > 0xfe6f)) |
|
|
823 | { |
|
|
824 | /* generate a keycode for every remaining keypress */ |
|
|
825 | len = sprintf ((char *)kbuf, "\033[%x;%xA", (unsigned char)ev.state, (unsigned short)keysym); |
798 | } |
826 | } |
799 | else |
827 | else |
800 | { |
828 | { |
801 | #ifdef META8_OPTION |
829 | #ifdef META8_OPTION |
802 | /* set 8-bit on */ |
830 | /* set 8-bit on */ |
… | |
… | |
899 | #endif /* MENUBAR_MAX */ |
927 | #endif /* MENUBAR_MAX */ |
900 | |
928 | |
901 | void |
929 | void |
902 | rxvt_term::flush () |
930 | rxvt_term::flush () |
903 | { |
931 | { |
|
|
932 | flush_ev.stop (); |
|
|
933 | |
904 | #ifdef TRANSPARENT |
934 | #ifdef TRANSPARENT |
905 | if (want_full_refresh) |
935 | if (want_full_refresh) |
906 | { |
936 | { |
907 | want_full_refresh = 0; |
937 | want_full_refresh = 0; |
908 | scr_clear (); |
938 | scr_clear (); |
… | |
… | |
918 | IMSendSpot (); |
948 | IMSendSpot (); |
919 | #endif |
949 | #endif |
920 | } |
950 | } |
921 | |
951 | |
922 | display->flush (); |
952 | display->flush (); |
923 | |
|
|
924 | flush_ev.stop (); |
|
|
925 | } |
953 | } |
926 | |
954 | |
927 | void |
955 | void |
928 | rxvt_term::check_cb (check_watcher &w) |
956 | rxvt_term::check_cb (check_watcher &w) |
929 | { |
957 | { |
… | |
… | |
1046 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1074 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1047 | { |
1075 | { |
1048 | SET_R (this); |
1076 | SET_R (this); |
1049 | SET_LOCALE (locale); |
1077 | SET_LOCALE (locale); |
1050 | |
1078 | |
1051 | if (revents & EVENT_WRITE) |
|
|
1052 | tt_write (0, 0); |
|
|
1053 | else if (revents & EVENT_READ) |
1079 | if (revents & EVENT_READ) |
1054 | // loop, but don't allow a single term to monopolize us |
1080 | // loop, but don't allow a single term to monopolize us |
1055 | while (pty_fill ()) |
1081 | while (pty_fill ()) |
1056 | if (cmd_parse ()) |
1082 | if (cmd_parse ()) |
1057 | break; |
1083 | break; |
|
|
1084 | |
|
|
1085 | if (revents & EVENT_WRITE) |
|
|
1086 | pty_write (); |
1058 | } |
1087 | } |
1059 | |
1088 | |
1060 | void |
1089 | void |
1061 | rxvt_term::pointer_unblank () |
1090 | rxvt_term::pointer_unblank () |
1062 | { |
1091 | { |
… | |
… | |
1137 | + ((MEvent.state & ModMetaMask) ? 8 : 0) |
1166 | + ((MEvent.state & ModMetaMask) ? 8 : 0) |
1138 | + ((MEvent.state & ControlMask) ? 16 : 0); |
1167 | + ((MEvent.state & ControlMask) ? 16 : 0); |
1139 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1168 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1140 | key_state += ((MEvent.clicks > 1) ? 32 : 0); |
1169 | key_state += ((MEvent.clicks > 1) ? 32 : 0); |
1141 | #endif |
1170 | #endif |
1142 | |
|
|
1143 | } |
1171 | } |
1144 | |
1172 | |
1145 | #ifdef DEBUG_MOUSEREPORT |
1173 | #if DEBUG_MOUSEREPORT |
1146 | fprintf (stderr, "Mouse ["); |
1174 | fprintf (stderr, "Mouse ["); |
1147 | if (key_state & 16) |
1175 | if (key_state & 16) |
1148 | fputc ('C', stderr); |
1176 | fputc ('C', stderr); |
1149 | if (key_state & 4) |
1177 | if (key_state & 4) |
1150 | fputc ('S', stderr); |
1178 | fputc ('S', stderr); |
… | |
… | |
1154 | fputc ('2', stderr); |
1182 | fputc ('2', stderr); |
1155 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1183 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1156 | button_number, |
1184 | button_number, |
1157 | x + 1, |
1185 | x + 1, |
1158 | y + 1); |
1186 | y + 1); |
1159 | #else |
1187 | #endif |
|
|
1188 | |
1160 | tt_printf ("\033[M%c%c%c", |
1189 | tt_printf ("\033[M%c%c%c", |
1161 | (32 + button_number + key_state), |
1190 | (32 + button_number + key_state), |
1162 | (32 + x + 1), |
1191 | (32 + x + 1), |
1163 | (32 + y + 1)); |
1192 | (32 + y + 1)); |
1164 | #endif |
|
|
1165 | } |
1193 | } |
1166 | |
1194 | |
1167 | #ifdef USING_W11LIB |
1195 | #ifdef USING_W11LIB |
1168 | void |
1196 | void |
1169 | rxvt_W11_process_x_event (XEvent *ev) |
1197 | rxvt_W11_process_x_event (XEvent *ev) |
… | |
… | |
1206 | if (ev.type == KeyPress && hidden_pointer == 0) |
1234 | if (ev.type == KeyPress && hidden_pointer == 0) |
1207 | pointer_blank (); |
1235 | pointer_blank (); |
1208 | } |
1236 | } |
1209 | #endif |
1237 | #endif |
1210 | |
1238 | |
1211 | #ifdef USE_XIM |
|
|
1212 | if (XFilterEvent (&ev, None)) |
|
|
1213 | return; |
|
|
1214 | #endif |
|
|
1215 | |
|
|
1216 | Window unused_root, unused_child; |
1239 | Window unused_root, unused_child; |
1217 | int unused_root_x, unused_root_y; |
1240 | int unused_root_x, unused_root_y; |
1218 | unsigned int unused_mask; |
1241 | unsigned int unused_mask; |
1219 | |
1242 | |
1220 | switch (ev.type) |
1243 | switch (ev.type) |
1221 | { |
1244 | { |
1222 | case KeyPress: |
1245 | case KeyPress: |
1223 | #if ISO_14755 |
1246 | #if ISO_14755 |
… | |
… | |
1227 | |
1250 | |
1228 | break; |
1251 | break; |
1229 | |
1252 | |
1230 | case KeyRelease: |
1253 | case KeyRelease: |
1231 | { |
1254 | { |
1232 | #if (defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)) || defined (ENABLE_FRILLS) |
1255 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1233 | KeySym ks; |
1256 | KeySym ks; |
1234 | |
1257 | |
1235 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1258 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1236 | #endif |
1259 | #endif |
1237 | |
1260 | |
… | |
… | |
1328 | 0L, 1000000L, |
1351 | 0L, 1000000L, |
1329 | False, AnyPropertyType, |
1352 | False, AnyPropertyType, |
1330 | &ActualType, &ActualFormat, |
1353 | &ActualType, &ActualFormat, |
1331 | &Size, &RemainingBytes, |
1354 | &Size, &RemainingBytes, |
1332 | &data); |
1355 | &data); |
1333 | XChangeProperty (display->display, display->root, |
1356 | set_string_property (XA_CUT_BUFFER0, data); |
1334 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1335 | 8, PropModeReplace, |
|
|
1336 | data, strlen (data)); |
|
|
1337 | XFree (data); |
1357 | XFree (data); |
1338 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1358 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1339 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1359 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1340 | } |
1360 | } |
1341 | #endif /* OFFIX_DND */ |
1361 | #endif /* OFFIX_DND */ |
1342 | break; |
1362 | break; |
1343 | |
1363 | |
… | |
… | |
1388 | #endif |
1408 | #endif |
1389 | #ifdef OFF_FOCUS_FADING |
1409 | #ifdef OFF_FOCUS_FADING |
1390 | if (rs[Rs_fade]) |
1410 | if (rs[Rs_fade]) |
1391 | { |
1411 | { |
1392 | pix_colors = pix_colors_focused; |
1412 | pix_colors = pix_colors_focused; |
1393 | set_colorfgbg (); |
|
|
1394 | scr_clear (); |
1413 | scr_recolour (); |
1395 | scr_touch (true); |
|
|
1396 | } |
1414 | } |
1397 | #endif |
1415 | #endif |
1398 | |
1416 | |
1399 | } |
1417 | } |
1400 | break; |
1418 | break; |
… | |
… | |
1402 | case FocusOut: |
1420 | case FocusOut: |
1403 | if (TermWin.focus) |
1421 | if (TermWin.focus) |
1404 | { |
1422 | { |
1405 | TermWin.focus = 0; |
1423 | TermWin.focus = 0; |
1406 | want_refresh = 1; |
1424 | want_refresh = 1; |
|
|
1425 | |
|
|
1426 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1427 | iso14755buf = 0; |
|
|
1428 | #endif |
|
|
1429 | #if ENABLE_OVERLAY |
|
|
1430 | scr_overlay_off (); |
|
|
1431 | #endif |
1407 | #ifdef USE_XIM |
1432 | #ifdef USE_XIM |
1408 | if (Input_Context != NULL) |
1433 | if (Input_Context != NULL) |
1409 | XUnsetICFocus (Input_Context); |
1434 | XUnsetICFocus (Input_Context); |
1410 | #endif |
1435 | #endif |
1411 | #ifdef CURSOR_BLINK |
1436 | #ifdef CURSOR_BLINK |
… | |
… | |
1415 | #endif |
1440 | #endif |
1416 | #ifdef OFF_FOCUS_FADING |
1441 | #ifdef OFF_FOCUS_FADING |
1417 | if (rs[Rs_fade]) |
1442 | if (rs[Rs_fade]) |
1418 | { |
1443 | { |
1419 | pix_colors = pix_colors_unfocused; |
1444 | pix_colors = pix_colors_unfocused; |
1420 | set_colorfgbg (); |
|
|
1421 | scr_clear (); |
1445 | scr_recolour (); |
1422 | scr_touch (true); |
|
|
1423 | } |
1446 | } |
1424 | #endif |
1447 | #endif |
1425 | |
|
|
1426 | } |
1448 | } |
1427 | break; |
1449 | break; |
1428 | |
1450 | |
1429 | case ConfigureNotify: |
1451 | case ConfigureNotify: |
1430 | if (ev.xconfigure.window == TermWin.parent[0]) |
1452 | if (ev.xconfigure.window == TermWin.parent[0]) |
… | |
… | |
1438 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1460 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1439 | } |
1461 | } |
1440 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1462 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1441 | |
1463 | |
1442 | if (szHint.width != width || szHint.height != height) |
1464 | if (szHint.width != width || szHint.height != height) |
|
|
1465 | { |
|
|
1466 | seen_resize = 1; |
1443 | resize_all_windows (width, height, 1); |
1467 | resize_all_windows (width, height, 1); |
|
|
1468 | } |
1444 | |
1469 | |
1445 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1470 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1446 | if (options & Opt_transparent) |
1471 | if (options & Opt_transparent) |
1447 | { |
|
|
1448 | check_our_parents (); |
1472 | check_our_parents (); |
1449 | if (am_transparent) |
|
|
1450 | want_refresh = want_full_refresh = 1; |
|
|
1451 | } |
|
|
1452 | #endif |
1473 | #endif |
1453 | } |
1474 | } |
1454 | break; |
1475 | break; |
1455 | |
1476 | |
1456 | case PropertyNotify: |
1477 | case PropertyNotify: |
… | |
… | |
1464 | selection_clear (); |
1485 | selection_clear (); |
1465 | break; |
1486 | break; |
1466 | |
1487 | |
1467 | case SelectionNotify: |
1488 | case SelectionNotify: |
1468 | if (selection_wait == Sel_normal) |
1489 | if (selection_wait == Sel_normal) |
1469 | selection_paste (ev.xselection.requestor, |
1490 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1470 | ev.xselection.property, True); |
|
|
1471 | break; |
1491 | break; |
1472 | |
1492 | |
1473 | case SelectionRequest: |
1493 | case SelectionRequest: |
1474 | selection_send (ev.xselectionrequest); |
1494 | selection_send (ev.xselectionrequest); |
1475 | break; |
1495 | break; |
… | |
… | |
1547 | { |
1567 | { |
1548 | menubar_control (ev.xbutton); |
1568 | menubar_control (ev.xbutton); |
1549 | break; |
1569 | break; |
1550 | } |
1570 | } |
1551 | #endif |
1571 | #endif |
1552 | if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1572 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1553 | break; |
1573 | break; |
1554 | |
1574 | |
1555 | if (ev.xany.window == TermWin.vt) |
1575 | if (ev.xany.window == TermWin.vt) |
1556 | { |
1576 | { |
1557 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1577 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
… | |
… | |
1560 | ; |
1580 | ; |
1561 | |
1581 | |
1562 | XQueryPointer (display->display, TermWin.vt, |
1582 | XQueryPointer (display->display, TermWin.vt, |
1563 | &unused_root, &unused_child, |
1583 | &unused_root, &unused_child, |
1564 | &unused_root_x, &unused_root_y, |
1584 | &unused_root_x, &unused_root_y, |
1565 | & (ev.xbutton.x), & (ev.xbutton.y), |
1585 | &ev.xbutton.x, &ev.xbutton.y, |
1566 | &unused_mask); |
1586 | &ev.xbutton.state); |
1567 | #ifdef MOUSE_THRESHOLD |
1587 | #ifdef MOUSE_THRESHOLD |
1568 | /* deal with a `jumpy' mouse */ |
1588 | /* deal with a `jumpy' mouse */ |
1569 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1589 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1570 | { |
1590 | { |
1571 | #endif |
1591 | #endif |
… | |
… | |
1576 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1596 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1577 | break; |
1597 | break; |
1578 | } |
1598 | } |
1579 | #endif |
1599 | #endif |
1580 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1600 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1581 | (ev.xbutton.state & Button3Mask) ? 2 : 0); |
1601 | ev.xbutton.state & Button3Mask ? 2 : 0); |
|
|
1602 | |
1582 | #ifdef SELECTION_SCROLLING |
1603 | #ifdef SELECTION_SCROLLING |
1583 | if (ev.xbutton.y < TermWin.int_bwidth |
1604 | if (ev.xbutton.y < TermWin.int_bwidth |
1584 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1605 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1585 | { |
1606 | { |
1586 | int dist; |
1607 | int dist; |
… | |
… | |
1597 | selection_save_x = ev.xbutton.x; |
1618 | selection_save_x = ev.xbutton.x; |
1598 | selection_save_y = ev.xbutton.y; |
1619 | selection_save_y = ev.xbutton.y; |
1599 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1620 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1600 | |
1621 | |
1601 | /* calc number of lines to scroll */ |
1622 | /* calc number of lines to scroll */ |
1602 | if (ev.xbutton.y<TermWin.int_bwidth) |
1623 | if (ev.xbutton.y < TermWin.int_bwidth) |
1603 | { |
1624 | { |
1604 | scroll_selection_dir = UP; |
1625 | scroll_selection_dir = UP; |
1605 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1626 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1606 | } |
1627 | } |
1607 | else |
1628 | else |
… | |
… | |
1631 | } |
1652 | } |
1632 | } |
1653 | } |
1633 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1654 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1634 | { |
1655 | { |
1635 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1656 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1636 | MotionNotify, &ev)) ; |
1657 | MotionNotify, &ev)) |
|
|
1658 | ; |
|
|
1659 | |
1637 | XQueryPointer (display->display, scrollBar.win, |
1660 | XQueryPointer (display->display, scrollBar.win, |
1638 | &unused_root, &unused_child, |
1661 | &unused_root, &unused_child, |
1639 | &unused_root_x, &unused_root_y, |
1662 | &unused_root_x, &unused_root_y, |
1640 | & (ev.xbutton.x), & (ev.xbutton.y), |
1663 | &ev.xbutton.x, &ev.xbutton.y, |
1641 | &unused_mask); |
1664 | &unused_mask); |
1642 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1665 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1643 | scrollbar_size ()); |
1666 | scrollbar_size ()); |
1644 | scr_refresh (refresh_type); |
1667 | scr_refresh (refresh_type); |
1645 | refresh_limit = 0; |
1668 | refresh_limit = 0; |
… | |
… | |
1661 | case PropertyNotify: |
1684 | case PropertyNotify: |
1662 | /* |
1685 | /* |
1663 | * if user used some Esetroot compatible prog to set the root bg, |
1686 | * if user used some Esetroot compatible prog to set the root bg, |
1664 | * use the property to determine the pixmap. We use it later on. |
1687 | * use the property to determine the pixmap. We use it later on. |
1665 | */ |
1688 | */ |
1666 | if (xa[XA_XROOTPMAPID] == 0) |
|
|
1667 | xa[XA_XROOTPMAPID] = XInternAtom (display->display, "_XROOTPMAP_ID", False); |
|
|
1668 | |
|
|
1669 | if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) |
1689 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
|
|
1690 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1670 | return; |
1691 | return; |
1671 | |
1692 | |
1672 | /* FALLTHROUGH */ |
1693 | /* FALLTHROUGH */ |
1673 | case ReparentNotify: |
1694 | case ReparentNotify: |
1674 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1695 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
… | |
… | |
1700 | return; |
1721 | return; |
1701 | } |
1722 | } |
1702 | #endif |
1723 | #endif |
1703 | |
1724 | |
1704 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1725 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
|
|
1726 | |
1705 | if (reportmode) |
1727 | if (reportmode) |
1706 | { |
1728 | { |
1707 | /* mouse report from vt window */ |
1729 | /* mouse report from vt window */ |
1708 | /* save the xbutton state (for ButtonRelease) */ |
1730 | /* save the xbutton state (for ButtonRelease) */ |
1709 | MEvent.state = ev.state; |
1731 | MEvent.state = ev.state; |
… | |
… | |
1738 | } |
1760 | } |
1739 | else |
1761 | else |
1740 | { |
1762 | { |
1741 | if (ev.button != MEvent.button) |
1763 | if (ev.button != MEvent.button) |
1742 | MEvent.clicks = 0; |
1764 | MEvent.clicks = 0; |
|
|
1765 | |
1743 | switch (ev.button) |
1766 | switch (ev.button) |
1744 | { |
1767 | { |
1745 | case Button1: |
1768 | case Button1: |
|
|
1769 | /* allow meta + click to select rectangular areas */ |
|
|
1770 | /* should be done in screen.C */ |
|
|
1771 | #if ENABLE_FRILLS |
|
|
1772 | selection.rect = !! (ev.state & ModMetaMask); |
|
|
1773 | #else |
|
|
1774 | selection.rect = false; |
|
|
1775 | #endif |
|
|
1776 | |
1746 | /* allow shift+left click to extend selection */ |
1777 | /* allow shift+left click to extend selection */ |
1747 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1778 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1748 | { |
1779 | { |
1749 | if (MEvent.button == Button1 && clickintime) |
1780 | if (MEvent.button == Button1 && clickintime) |
1750 | selection_rotate (ev.x, ev.y); |
1781 | selection_rotate (ev.x, ev.y); |
… | |
… | |
2334 | /* |
2365 | /* |
2335 | * Make the frame window set by the window manager have |
2366 | * Make the frame window set by the window manager have |
2336 | * the root background. Some window managers put multiple nested frame |
2367 | * the root background. Some window managers put multiple nested frame |
2337 | * windows for each client, so we have to take care about that. |
2368 | * windows for each client, so we have to take care about that. |
2338 | */ |
2369 | */ |
2339 | i = (xa[XA_XROOTPMAPID] |
2370 | i = (xa[XA_XROOTPMAP_ID] |
2340 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], |
2371 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID], |
2341 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2372 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2342 | &nitems, &bytes_after, &prop) == Success); |
2373 | &nitems, &bytes_after, &prop) == Success); |
2343 | |
2374 | |
2344 | if (!i || prop == NULL) |
2375 | if (!i || prop == NULL) |
2345 | i = (xa[XA_XSETROOTID] |
2376 | i = (xa[XA_ESETROOT_PMAP_ID] |
2346 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2377 | && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID], |
2347 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2378 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2348 | &nitems, &bytes_after, &prop) == Success); |
2379 | &nitems, &bytes_after, &prop) == Success); |
2349 | |
2380 | |
2350 | if (!i || prop == NULL |
2381 | if (!i || prop == NULL |
2351 | #if TINTING |
2382 | #if TINTING |
… | |
… | |
2392 | sy = 0; |
2423 | sy = 0; |
2393 | } |
2424 | } |
2394 | |
2425 | |
2395 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2426 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2396 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2427 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2428 | |
|
|
2429 | XSync (display->display, False); |
2397 | allowedxerror = -1; |
2430 | allowedxerror = -1; |
2398 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2431 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2399 | |
2432 | |
2400 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2433 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2401 | /* XXX: may need a delay here? */ |
2434 | /* XXX: may need a delay here? */ |
… | |
… | |
2447 | |
2480 | |
2448 | am_transparent = am_pixmap_trans = 1; |
2481 | am_transparent = am_pixmap_trans = 1; |
2449 | } |
2482 | } |
2450 | } |
2483 | } |
2451 | |
2484 | |
2452 | if (!am_pixmap_trans) |
2485 | if (am_pixmap_trans) |
|
|
2486 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
|
|
2487 | else |
2453 | { |
2488 | { |
2454 | unsigned int n; |
2489 | unsigned int n; |
2455 | /* |
2490 | /* |
2456 | * InheritPixmap transparency |
2491 | * InheritPixmap transparency |
2457 | */ |
2492 | */ |
… | |
… | |
2515 | |
2550 | |
2516 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2551 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2517 | TermWin.parent[i] = None; |
2552 | TermWin.parent[i] = None; |
2518 | } |
2553 | } |
2519 | |
2554 | |
2520 | // this is experimental |
|
|
2521 | if (scrollBar.win) |
2555 | if (scrollBar.win) |
2522 | { |
2556 | { |
2523 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2557 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2524 | XClearWindow (display->display, scrollBar.win); |
|
|
2525 | scrollBar.setIdle (); |
2558 | scrollBar.setIdle (); |
2526 | scrollbar_show (0); |
2559 | scrollbar_show (0); |
|
|
2560 | } |
|
|
2561 | |
|
|
2562 | if (am_transparent) |
|
|
2563 | { |
|
|
2564 | want_refresh = want_full_refresh = 1; |
|
|
2565 | if (am_pixmap_trans) |
|
|
2566 | flush (); |
2527 | } |
2567 | } |
2528 | |
2568 | |
2529 | return pchanged; |
2569 | return pchanged; |
2530 | } |
2570 | } |
2531 | #endif |
2571 | #endif |
… | |
… | |
2557 | seen_input = 1; |
2597 | seen_input = 1; |
2558 | // many badly-written programs (e.g. jed) contain a race condition: |
2598 | // many badly-written programs (e.g. jed) contain a race condition: |
2559 | // they first read the screensize and then install a SIGWINCH handler. |
2599 | // they first read the screensize and then install a SIGWINCH handler. |
2560 | // some window managers resize the window early, and these programs |
2600 | // some window managers resize the window early, and these programs |
2561 | // then sometimes get the size wrong. |
2601 | // then sometimes get the size wrong. |
|
|
2602 | // unfortunately other programs are even more buggy and dislike |
|
|
2603 | // being sent SIGWINCH, so only do it when we were in fact being |
|
|
2604 | // resized. |
|
|
2605 | if (seen_resize) |
2562 | kill (-cmd_pid, SIGWINCH); |
2606 | kill (-cmd_pid, SIGWINCH); |
2563 | } |
2607 | } |
2564 | |
2608 | |
2565 | /* Read a text string from the input buffer */ |
2609 | /* Read a text string from the input buffer */ |
2566 | unicode_t buf[UBUFSIZ]; |
2610 | unicode_t buf[UBUFSIZ]; |
2567 | bool refreshnow = false; |
2611 | bool refreshnow = false; |
… | |
… | |
2679 | if (len == (size_t)-1) |
2723 | if (len == (size_t)-1) |
2680 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2724 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2681 | |
2725 | |
2682 | // assume wchar == unicode |
2726 | // assume wchar == unicode |
2683 | cmdbuf_ptr += len; |
2727 | cmdbuf_ptr += len; |
2684 | return wc; |
2728 | return wc & UNICODE_MASK; |
2685 | } |
2729 | } |
2686 | |
2730 | |
2687 | return NOCHAR; |
2731 | return NOCHAR; |
2688 | } |
2732 | } |
2689 | |
2733 | |
… | |
… | |
3487 | * ends_how is terminator used. returned input must be free()'d |
3531 | * ends_how is terminator used. returned input must be free()'d |
3488 | */ |
3532 | */ |
3489 | unsigned char * |
3533 | unsigned char * |
3490 | rxvt_term::get_to_st (unicode_t &ends_how) |
3534 | rxvt_term::get_to_st (unicode_t &ends_how) |
3491 | { |
3535 | { |
3492 | unicode_t prev = 0, ch; |
3536 | unicode_t ch; |
|
|
3537 | bool seen_esc = false; |
3493 | unsigned int n = 0; |
3538 | unsigned int n = 0; |
3494 | unsigned char *s; |
|
|
3495 | unsigned char string[STRING_MAX]; |
3539 | wchar_t string[STRING_MAX]; |
3496 | |
3540 | |
3497 | while ((ch = cmd_getc ()) != NOCHAR) |
3541 | while ((ch = cmd_getc ()) != NOCHAR) |
3498 | { |
3542 | { |
3499 | if (prev == C0_ESC) |
3543 | if (seen_esc) |
3500 | { |
3544 | { |
3501 | if (ch == 0x5c) /* 7bit ST */ |
3545 | if (ch == 0x5c) /* 7bit ST */ |
3502 | break; |
3546 | break; |
3503 | else |
3547 | else |
3504 | return NULL; |
3548 | return NULL; |
3505 | } |
3549 | } |
|
|
3550 | else if (ch == C0_ESC) |
|
|
3551 | { |
|
|
3552 | seen_esc = true; |
|
|
3553 | continue; |
|
|
3554 | } |
3506 | else if (ch == C0_BEL || ch == CHAR_ST) |
3555 | else if (ch == C0_BEL || ch == CHAR_ST) |
3507 | break; |
3556 | break; |
3508 | else if (ch < 0x20) |
3557 | else if (ch < 0x20) |
3509 | return NULL; /* other control character - exit */ |
3558 | return NULL; /* other control character - exit */ |
|
|
3559 | |
|
|
3560 | seen_esc = false; |
3510 | |
3561 | |
3511 | if (n >= sizeof (string) - 1) |
3562 | if (n >= sizeof (string) - 1) |
3512 | // stop at some sane length |
3563 | // stop at some sane length |
3513 | return NULL; |
3564 | return NULL; |
3514 | |
3565 | |
3515 | if (ch == C0_SYN) |
3566 | if (ch == C0_SYN) |
3516 | { |
|
|
3517 | string[n++] = cmd_get8 (); |
3567 | string[n++] = cmd_get8 (); |
3518 | prev = 0; |
|
|
3519 | } |
|
|
3520 | else |
3568 | else |
3521 | string[n++] = prev = ch; |
3569 | string[n++] = ch; |
3522 | } |
3570 | } |
3523 | |
3571 | |
3524 | string[n++] = '\0'; |
3572 | string[n++] = '\0'; |
3525 | |
3573 | |
3526 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3527 | return NULL; |
|
|
3528 | |
|
|
3529 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3574 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3530 | strncpy (s, string, n); |
3575 | |
3531 | return s; |
3576 | return (unsigned char *)rxvt_wcstombs (string); |
3532 | } |
3577 | } |
3533 | |
3578 | |
3534 | /*----------------------------------------------------------------------*/ |
3579 | /*----------------------------------------------------------------------*/ |
3535 | /* |
3580 | /* |
3536 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3581 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3620 | { |
3665 | { |
3621 | int changed = 0; |
3666 | int changed = 0; |
3622 | int color; |
3667 | int color; |
3623 | char *buf, *name; |
3668 | char *buf, *name; |
3624 | bool query = str[0] == '?' && !str[1]; |
3669 | bool query = str[0] == '?' && !str[1]; |
|
|
3670 | int saveop = op; |
3625 | |
3671 | |
3626 | assert (str != NULL); |
3672 | assert (str != NULL); |
3627 | switch (op) |
3673 | switch (op) |
3628 | { |
3674 | { |
3629 | case XTerm_name: |
3675 | case XTerm_name: |
… | |
… | |
3636 | set_title (str); |
3682 | set_title (str); |
3637 | break; |
3683 | break; |
3638 | case XTerm_property: |
3684 | case XTerm_property: |
3639 | if (str[0] == '?') |
3685 | if (str[0] == '?') |
3640 | { |
3686 | { |
3641 | Atom prop = XInternAtom (display->display, str + 1, True); |
3687 | Atom prop = display->atom (str + 1); |
3642 | Atom actual_type; |
3688 | Atom actual_type; |
3643 | int actual_format; |
3689 | int actual_format; |
3644 | unsigned long nitems; |
3690 | unsigned long nitems; |
3645 | unsigned long bytes_after; |
3691 | unsigned long bytes_after; |
3646 | unsigned char *value = 0; |
3692 | unsigned char *value = 0; |
… | |
… | |
3664 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3710 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3665 | |
3711 | |
3666 | if (eq) |
3712 | if (eq) |
3667 | { |
3713 | { |
3668 | *eq = 0; |
3714 | *eq = 0; |
3669 | XChangeProperty (display->display, TermWin.parent[0], |
3715 | set_utf8_property (display->atom (str), eq + 1); |
3670 | display->atom (str), XA_STRING, 8, |
|
|
3671 | PropModeReplace, (unsigned char *)eq + 1, |
|
|
3672 | strlen (eq + 1)); |
|
|
3673 | } |
3716 | } |
3674 | else |
3717 | else |
3675 | XDeleteProperty (display->display, TermWin.parent[0], |
3718 | XDeleteProperty (display->display, TermWin.parent[0], |
3676 | display->atom (str)); |
3719 | display->atom (str)); |
3677 | } |
3720 | } |
… | |
… | |
3721 | break; |
3764 | break; |
3722 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3765 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3723 | case XTerm_Color_BD: |
3766 | case XTerm_Color_BD: |
3724 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3767 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3725 | break; |
3768 | break; |
|
|
3769 | case XTerm_Color_IT: |
|
|
3770 | process_color_seq (XTerm_Color_IT, Color_IT, str, resp); |
|
|
3771 | break; |
3726 | case XTerm_Color_UL: |
3772 | case XTerm_Color_UL: |
3727 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3773 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3728 | break; |
3774 | break; |
3729 | case XTerm_Color_RV: |
3775 | case XTerm_Color_RV: |
3730 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3776 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3777 | break; |
|
|
3778 | #endif |
|
|
3779 | #if TRANSPARENT && TINTING |
|
|
3780 | case XTerm_Color_tint: |
|
|
3781 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
|
|
3782 | check_our_parents (); |
|
|
3783 | if (am_transparent) |
|
|
3784 | want_full_refresh = want_refresh = 1; |
3731 | break; |
3785 | break; |
3732 | #endif |
3786 | #endif |
3733 | |
3787 | |
3734 | case XTerm_Pixmap: |
3788 | case XTerm_Pixmap: |
3735 | if (*str != ';') |
3789 | if (*str != ';') |
… | |
… | |
3767 | case XTerm_logfile: |
3821 | case XTerm_logfile: |
3768 | // TODO, when secure mode? |
3822 | // TODO, when secure mode? |
3769 | break; |
3823 | break; |
3770 | |
3824 | |
3771 | case XTerm_font: |
3825 | case XTerm_font: |
|
|
3826 | op = URxvt_font; |
|
|
3827 | case URxvt_font: |
|
|
3828 | #if ENABLE_STYLES |
|
|
3829 | case URxvt_boldFont: |
|
|
3830 | case URxvt_italicFont: |
|
|
3831 | case URxvt_boldItalicFont: |
|
|
3832 | #endif |
3772 | if (query) |
3833 | if (query) |
3773 | tt_printf ("\33]%d;%-.250s%c", XTerm_font, |
3834 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3774 | (options & Opt_insecure) && TermWin.fontset->fontdesc |
3835 | (options & Opt_insecure) && TermWin.fontset[op - URxvt_font]->fontdesc |
3775 | ? TermWin.fontset->fontdesc : "", |
3836 | ? TermWin.fontset[op - URxvt_font]->fontdesc : "", |
3776 | resp); |
3837 | resp); |
3777 | else |
3838 | else |
|
|
3839 | { |
|
|
3840 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
|
|
3841 | |
|
|
3842 | res = strdup (str); |
|
|
3843 | allocated.push_back ((void *)res); |
3778 | change_font (str); |
3844 | set_fonts (); |
|
|
3845 | } |
3779 | break; |
3846 | break; |
3780 | |
3847 | |
3781 | #if ENABLE_FRILLS |
3848 | #if ENABLE_FRILLS |
3782 | case XTerm_locale: |
3849 | case XTerm_locale: |
3783 | if (query) |
3850 | if (query) |
… | |
… | |
3787 | set_locale (str); |
3854 | set_locale (str); |
3788 | # ifdef USE_XIM |
3855 | # ifdef USE_XIM |
3789 | im_cb (); |
3856 | im_cb (); |
3790 | # endif |
3857 | # endif |
3791 | } |
3858 | } |
3792 | break; |
|
|
3793 | |
|
|
3794 | case XTerm_findfont: |
|
|
3795 | { |
|
|
3796 | int fid = TermWin.fontset->find_font (atoi (str)); |
|
|
3797 | tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont, |
|
|
3798 | fid, |
|
|
3799 | (options & Opt_insecure) ? (*TermWin.fontset)[fid]->name : "", |
|
|
3800 | resp); |
|
|
3801 | } |
|
|
3802 | break; |
3859 | break; |
3803 | #endif |
3860 | #endif |
3804 | |
3861 | |
3805 | #ifdef MENUBAR |
3862 | #ifdef MENUBAR |
3806 | case XTerm_Menu: |
3863 | case XTerm_Menu: |
… | |
… | |
3935 | |
3992 | |
3936 | /* extra handling for values with state unkept */ |
3993 | /* extra handling for values with state unkept */ |
3937 | switch (arg[i]) |
3994 | switch (arg[i]) |
3938 | { |
3995 | { |
3939 | case 1048: /* alternative cursor save */ |
3996 | case 1048: /* alternative cursor save */ |
|
|
3997 | case 1049: |
3940 | if (options & Opt_secondaryScreen) |
3998 | if (options & Opt_secondaryScreen) |
3941 | if (mode == 0) |
3999 | if (mode == 0) |
3942 | scr_cursor (RESTORE); |
4000 | scr_cursor (RESTORE); |
3943 | else if (mode == 1) |
4001 | else if (mode == 1) |
3944 | scr_cursor (SAVE); |
4002 | scr_cursor (SAVE); |
… | |
… | |
4069 | rendset = 0, rendstyle = ~RS_None; |
4127 | rendset = 0, rendstyle = ~RS_None; |
4070 | break; |
4128 | break; |
4071 | case 1: |
4129 | case 1: |
4072 | rendset = 1, rendstyle = RS_Bold; |
4130 | rendset = 1, rendstyle = RS_Bold; |
4073 | break; |
4131 | break; |
4074 | //case 2: // faint or second colour |
4132 | //case 2: // low intensity |
4075 | //case 3: // italic |
4133 | case 3: |
|
|
4134 | rendset = 1, rendstyle = RS_Italic; |
|
|
4135 | break; |
4076 | case 4: |
4136 | case 4: |
4077 | rendset = 1, rendstyle = RS_Uline; |
4137 | rendset = 1, rendstyle = RS_Uline; |
4078 | break; |
4138 | break; |
4079 | case 5: // slowly blinking |
4139 | case 5: // slowly blinking |
4080 | case 6: // rapidly blinking |
4140 | case 6: // rapidly blinking |
… | |
… | |
4092 | //case 11: // scoansi acs on, first alt font |
4152 | //case 11: // scoansi acs on, first alt font |
4093 | //case 12: // scoansi acs on, |0x80, second alt font |
4153 | //case 12: // scoansi acs on, |0x80, second alt font |
4094 | //... |
4154 | //... |
4095 | //case 19: // ninth alt font |
4155 | //case 19: // ninth alt font |
4096 | //case 20: // gothic |
4156 | //case 20: // gothic |
4097 | case 21: // disable bold, faint |
4157 | case 21: // disable bold, faint, sometimes doubly underlined (iso 8613) |
4098 | rendset = 0, rendstyle = RS_Bold; |
4158 | rendset = 0, rendstyle = RS_Bold; |
4099 | break; |
4159 | break; |
4100 | case 22: |
4160 | case 22: // normal intensity |
4101 | rendset = 0, rendstyle = RS_Bold; |
4161 | rendset = 0, rendstyle = RS_Bold; |
4102 | break; |
4162 | break; |
4103 | //case 23: disable italic |
4163 | case 23: // disable italic |
|
|
4164 | rendset = 0, rendstyle = RS_Italic; |
|
|
4165 | break; |
4104 | case 24: |
4166 | case 24: |
4105 | rendset = 0, rendstyle = RS_Uline; |
4167 | rendset = 0, rendstyle = RS_Uline; |
4106 | break; |
4168 | break; |
4107 | case 25: |
4169 | case 25: |
4108 | rendset = 0, rendstyle = RS_Blink; |
4170 | rendset = 0, rendstyle = RS_Blink; |
4109 | break; |
4171 | break; |
4110 | case 26: |
4172 | case 26: // variable spacing (iso 8613) |
4111 | rendset = 0, rendstyle = RS_Blink; |
4173 | rendset = 0, rendstyle = RS_Blink; |
4112 | break; |
4174 | break; |
4113 | case 27: |
4175 | case 27: |
4114 | rendset = 0, rendstyle = RS_RVid; |
4176 | rendset = 0, rendstyle = RS_RVid; |
4115 | break; |
4177 | break; |
… | |
… | |
4133 | case 35: |
4195 | case 35: |
4134 | case 36: |
4196 | case 36: |
4135 | case 37: |
4197 | case 37: |
4136 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
4198 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
4137 | break; |
4199 | break; |
4138 | #ifdef TTY_256COLOR |
4200 | case 38: // set fg color, ISO 8613-6 |
4139 | case 38: |
|
|
4140 | if (nargs > i + 2 && arg[i + 1] == 5) |
4201 | if (nargs > i + 2 && arg[i + 1] == 5) |
4141 | { |
4202 | { |
4142 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
4203 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
4143 | i += 2; |
4204 | i += 2; |
4144 | } |
4205 | } |
4145 | break; |
4206 | break; |
4146 | #endif |
|
|
4147 | case 39: /* default fg */ |
4207 | case 39: /* default fg */ |
4148 | scr_color (Color_fg, Color_fg); |
4208 | scr_color (Color_fg, Color_fg); |
4149 | break; |
4209 | break; |
4150 | |
4210 | |
4151 | case 40: |
4211 | case 40: |
… | |
… | |
4156 | case 45: |
4216 | case 45: |
4157 | case 46: |
4217 | case 46: |
4158 | case 47: |
4218 | case 47: |
4159 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
4219 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
4160 | break; |
4220 | break; |
4161 | #ifdef TTY_256COLOR |
4221 | case 48: // set bg color, ISO 8613-6 |
4162 | case 48: |
|
|
4163 | if (nargs > i + 2 && arg[i + 1] == 5) |
4222 | if (nargs > i + 2 && arg[i + 1] == 5) |
4164 | { |
4223 | { |
4165 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
4224 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
4166 | i += 2; |
4225 | i += 2; |
4167 | } |
4226 | } |
4168 | break; |
4227 | break; |
4169 | #endif |
|
|
4170 | case 49: /* default bg */ |
4228 | case 49: /* default bg */ |
4171 | scr_color (Color_bg, Color_bg); |
4229 | scr_color (Color_bg, Color_bg); |
4172 | break; |
4230 | break; |
|
|
4231 | |
|
|
4232 | //case 50: // not variable spacing |
4173 | |
4233 | |
4174 | #ifndef NO_BRIGHTCOLOR |
4234 | #ifndef NO_BRIGHTCOLOR |
4175 | case 90: |
4235 | case 90: |
4176 | case 91: /* set bright fg color */ |
4236 | case 91: /* set bright fg color */ |
4177 | case 92: |
4237 | case 92: |
4178 | case 93: |
4238 | case 93: |
4179 | case 94: |
4239 | case 94: |
4180 | case 95: |
4240 | case 95: |
4181 | case 96: |
4241 | case 96: |
4182 | case 97: |
4242 | case 97: |
4183 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), |
4243 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), Color_fg); |
4184 | Color_fg); |
|
|
4185 | break; |
4244 | break; |
4186 | case 100: |
4245 | case 100: |
4187 | case 101: /* set bright bg color */ |
4246 | case 101: /* set bright bg color */ |
4188 | case 102: |
4247 | case 102: |
4189 | case 103: |
4248 | case 103: |
4190 | case 104: |
4249 | case 104: |
4191 | case 105: |
4250 | case 105: |
4192 | case 106: |
4251 | case 106: |
4193 | case 107: |
4252 | case 107: |
4194 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), |
4253 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4195 | Color_bg); |
|
|
4196 | break; |
4254 | break; |
4197 | #endif |
4255 | #endif |
4198 | |
4256 | |
4199 | } |
4257 | } |
4200 | } |
4258 | } |
… | |
… | |
4239 | |
4297 | |
4240 | /* ---------------------------------------------------------------------- */ |
4298 | /* ---------------------------------------------------------------------- */ |
4241 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4299 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4242 | * or generated by us in response to a query ESC sequence. |
4300 | * or generated by us in response to a query ESC sequence. |
4243 | */ |
4301 | */ |
|
|
4302 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4303 | |
4244 | void |
4304 | void |
4245 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4305 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4246 | { |
4306 | { |
4247 | enum { MAX_PTY_WRITE = 255 }; // minimum MAX_INPUT |
4307 | if (v_buflen == 0) |
|
|
4308 | { |
|
|
4309 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4248 | |
4310 | |
4249 | if (len) |
4311 | if ((unsigned int)written == len) |
|
|
4312 | return; |
|
|
4313 | |
|
|
4314 | data += written; |
|
|
4315 | len -= written; |
4250 | { |
4316 | } |
|
|
4317 | |
|
|
4318 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4319 | |
|
|
4320 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4321 | v_buflen += len; |
|
|
4322 | |
|
|
4323 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4324 | } |
|
|
4325 | |
|
|
4326 | void rxvt_term::pty_write () |
|
|
4327 | { |
|
|
4328 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4329 | |
|
|
4330 | if (written > 0) |
|
|
4331 | { |
|
|
4332 | v_buflen -= written; |
|
|
4333 | |
4251 | if (v_buflen == 0) |
4334 | if (v_buflen == 0) |
4252 | { |
4335 | { |
4253 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
|
|
4254 | |
|
|
4255 | if ((unsigned int)written == len) |
|
|
4256 | return; |
|
|
4257 | |
|
|
4258 | data += written; |
|
|
4259 | len -= written; |
|
|
4260 | } |
|
|
4261 | |
|
|
4262 | |
|
|
4263 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4264 | |
|
|
4265 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4266 | v_buflen += len; |
|
|
4267 | } |
|
|
4268 | |
|
|
4269 | for (;;) |
|
|
4270 | { |
|
|
4271 | int written = write (pty.pty, v_buffer, min (MAX_PTY_WRITE, v_buflen)); |
|
|
4272 | |
|
|
4273 | if (written > 0) |
|
|
4274 | { |
|
|
4275 | v_buflen -= written; |
|
|
4276 | |
|
|
4277 | if (v_buflen == 0) |
|
|
4278 | { |
|
|
4279 | free (v_buffer); |
4336 | free (v_buffer); |
4280 | v_buffer = 0; |
4337 | v_buffer = 0; |
4281 | v_buflen = 0; |
4338 | v_buflen = 0; |
4282 | |
4339 | |
4283 | pty_ev.set (EVENT_READ); |
4340 | pty_ev.set (EVENT_READ); |
4284 | return; |
|
|
4285 | } |
|
|
4286 | |
|
|
4287 | memmove (v_buffer, v_buffer + written, v_buflen); |
|
|
4288 | } |
|
|
4289 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4290 | // original code just ignores this... |
|
|
4291 | destroy (); |
|
|
4292 | else |
|
|
4293 | { |
|
|
4294 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4295 | return; |
4341 | return; |
4296 | } |
4342 | } |
|
|
4343 | |
|
|
4344 | memmove (v_buffer, v_buffer + written, v_buflen); |
4297 | } |
4345 | } |
|
|
4346 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4347 | // original code just ignores this... |
|
|
4348 | destroy (); |
4298 | } |
4349 | } |
4299 | |
4350 | |
4300 | /*----------------------- end-of-file (C source) -----------------------*/ |
4351 | /*----------------------- end-of-file (C source) -----------------------*/ |
4301 | |
4352 | |