… | |
… | |
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 | #ifdef KEYSYM_RESOURCE |
|
|
54 | # include "keyboard.h" |
|
|
55 | #endif |
|
|
56 | |
53 | #include <wchar.h> |
57 | #include <cwchar> |
|
|
58 | #include <csignal> |
54 | |
59 | |
55 | /*----------------------------------------------------------------------*/ |
60 | /*----------------------------------------------------------------------*/ |
56 | |
61 | |
57 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
62 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | |
63 | |
… | |
… | |
133 | { |
138 | { |
134 | text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x]; |
139 | text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x]; |
135 | |
140 | |
136 | if (t != NOCHAR || !x) |
141 | if (t != NOCHAR || !x) |
137 | { |
142 | { |
138 | iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x]); |
143 | iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x], |
|
|
144 | screen.rend[y + TermWin.saveLines - TermWin.view_start][x]); |
139 | iso14755buf = ISO_14755_54; |
145 | iso14755buf = ISO_14755_54; |
140 | break; |
146 | break; |
141 | } |
147 | } |
142 | |
148 | |
143 | x--; |
149 | x--; |
… | |
… | |
146 | } |
152 | } |
147 | #endif |
153 | #endif |
148 | |
154 | |
149 | #if ENABLE_OVERLAY |
155 | #if ENABLE_OVERLAY |
150 | void |
156 | void |
151 | rxvt_term::iso14755_51 (wchar_t ch) |
157 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r) |
152 | { |
158 | { |
|
|
159 | rxvt_fontset *fs = FONTSET (r); |
|
|
160 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
153 | wchar_t *chr, *alloc; |
161 | wchar_t *chr, *alloc, ch2; |
154 | int len; |
162 | int len; |
155 | |
163 | |
156 | #if ENABLE_COMBINING |
164 | #if ENABLE_COMBINING |
157 | if (IS_COMPOSE (ch)) |
165 | if (IS_COMPOSE (ch)) |
158 | { |
166 | { |
… | |
… | |
161 | rxvt_composite.expand (ch, chr); |
169 | rxvt_composite.expand (ch, chr); |
162 | } |
170 | } |
163 | else |
171 | else |
164 | #endif |
172 | #endif |
165 | { |
173 | { |
|
|
174 | ch2 = ch; |
|
|
175 | |
166 | alloc = 0; |
176 | alloc = 0; |
167 | chr = &ch; |
177 | chr = &ch2; |
168 | len = 1; |
178 | len = 1; |
169 | } |
179 | } |
170 | |
180 | |
171 | scr_overlay_new (0, -1, 8 + 5, len); |
181 | int width = strlen (f->name); |
|
|
182 | |
|
|
183 | scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); |
|
|
184 | |
|
|
185 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
172 | |
186 | |
173 | for (int y = 0; y < len; y++) |
187 | for (int y = 0; y < len; y++) |
174 | { |
188 | { |
175 | char buf[9]; |
189 | char buf[9]; |
176 | |
190 | |
… | |
… | |
181 | scr_overlay_set (9, y, '='); |
195 | scr_overlay_set (9, y, '='); |
182 | #if !UNICODE3 |
196 | #if !UNICODE3 |
183 | if (ch >= 0x10000) |
197 | if (ch >= 0x10000) |
184 | ch = 0xfffd; |
198 | ch = 0xfffd; |
185 | #endif |
199 | #endif |
186 | scr_overlay_set (11, y, ch); |
200 | scr_overlay_set (11, y, ch, r); |
187 | scr_overlay_set (12, y, NOCHAR); |
201 | scr_overlay_set (12, y, NOCHAR, r); |
188 | } |
202 | } |
|
|
203 | |
|
|
204 | scr_overlay_set (0, len, f->name); |
189 | |
205 | |
190 | #if ENABLE_COMBINING |
206 | #if ENABLE_COMBINING |
191 | if (alloc) |
207 | if (alloc) |
192 | delete [] alloc; |
208 | delete [] alloc; |
193 | #endif |
209 | #endif |
… | |
… | |
332 | valid_keysym = keysym != NoSymbol; |
348 | valid_keysym = keysym != NoSymbol; |
333 | } |
349 | } |
334 | |
350 | |
335 | if (valid_keysym) |
351 | if (valid_keysym) |
336 | { |
352 | { |
|
|
353 | #ifdef KEYSYM_RESOURCE |
|
|
354 | if (keyboard->dispatch (this, keysym, ev.state)) |
|
|
355 | return; |
|
|
356 | #endif |
|
|
357 | |
337 | if (TermWin.saveLines) |
358 | if (TermWin.saveLines) |
338 | { |
359 | { |
339 | #ifdef UNSHIFTED_SCROLLKEYS |
360 | #ifdef UNSHIFTED_SCROLLKEYS |
340 | if (!ctrl && !meta) |
361 | if (!ctrl && !meta) |
341 | #else |
362 | #else |
… | |
… | |
406 | { |
427 | { |
407 | /* normal XTerm key bindings */ |
428 | /* normal XTerm key bindings */ |
408 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
429 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
409 | selection_request (ev.time, 0, 0); |
430 | selection_request (ev.time, 0, 0); |
410 | return; |
431 | return; |
411 | #if TODO // TODO |
432 | #if TODO |
412 | /* rxvt extras */ |
433 | /* rxvt extras */ |
413 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
434 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
414 | change_font (FONT_UP); |
435 | change_font (FONT_UP); |
415 | return; |
436 | return; |
416 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
437 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
… | |
… | |
475 | } |
496 | } |
476 | #endif |
497 | #endif |
477 | |
498 | |
478 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
499 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
479 | { |
500 | { |
480 | #ifdef KEYSYM_RESOURCE |
|
|
481 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
|
|
482 | { |
|
|
483 | unsigned int l; |
|
|
484 | const unsigned char *kbuf0; |
|
|
485 | |
|
|
486 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
|
|
487 | l = (unsigned int)*kbuf0++; |
|
|
488 | |
|
|
489 | /* escape prefix */ |
|
|
490 | if (meta |
|
|
491 | # ifdef META8_OPTION |
|
|
492 | && meta_char == C0_ESC |
|
|
493 | # endif |
|
|
494 | ) |
|
|
495 | { |
|
|
496 | const unsigned char ch = C0_ESC; |
|
|
497 | tt_write (&ch, 1); |
|
|
498 | } |
|
|
499 | |
|
|
500 | tt_write (kbuf0, l); |
|
|
501 | return; |
|
|
502 | } |
|
|
503 | else |
|
|
504 | #endif |
|
|
505 | { |
501 | { |
506 | newlen = 1; |
502 | newlen = 1; |
507 | switch (keysym) |
503 | switch (keysym) |
508 | { |
504 | { |
509 | #ifndef NO_BACKSPACE_KEY |
505 | #ifndef NO_BACKSPACE_KEY |
… | |
… | |
776 | #undef FKEY |
772 | #undef FKEY |
777 | default: |
773 | default: |
778 | newlen = 0; |
774 | newlen = 0; |
779 | break; |
775 | break; |
780 | } |
776 | } |
|
|
777 | |
781 | if (newlen) |
778 | if (newlen) |
782 | len = strlen (kbuf); |
779 | len = strlen (kbuf); |
783 | } |
780 | } |
784 | |
781 | |
785 | /* |
782 | /* |
… | |
… | |
793 | } |
790 | } |
794 | else if (ctrl && keysym == XK_minus) |
791 | else if (ctrl && keysym == XK_minus) |
795 | { |
792 | { |
796 | len = 1; |
793 | len = 1; |
797 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
794 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
795 | } |
|
|
796 | else if (keysym == XK_ISO_Left_Tab) |
|
|
797 | { |
|
|
798 | strcpy (kbuf, "\033[Z"); |
|
|
799 | len = 3; |
798 | } |
800 | } |
799 | else |
801 | else |
800 | { |
802 | { |
801 | #ifdef META8_OPTION |
803 | #ifdef META8_OPTION |
802 | /* set 8-bit on */ |
804 | /* set 8-bit on */ |
… | |
… | |
861 | #endif /* DEBUG_CMD */ |
863 | #endif /* DEBUG_CMD */ |
862 | tt_write (kbuf, (unsigned int)len); |
864 | tt_write (kbuf, (unsigned int)len); |
863 | } |
865 | } |
864 | /*}}} */ |
866 | /*}}} */ |
865 | |
867 | |
866 | #if (MENUBAR_MAX) |
868 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
867 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
869 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
868 | /* attempt to `write' count to the input buffer */ |
870 | /* attempt to `write' count to the input buffer */ |
869 | unsigned int |
871 | unsigned int |
870 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
872 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
871 | { |
873 | { |
… | |
… | |
894 | |
896 | |
895 | cmd_parse (); |
897 | cmd_parse (); |
896 | |
898 | |
897 | return 0; |
899 | return 0; |
898 | } |
900 | } |
899 | #endif /* MENUBAR_MAX */ |
901 | #endif |
900 | |
902 | |
901 | void |
903 | void |
902 | rxvt_term::flush () |
904 | rxvt_term::flush () |
903 | { |
905 | { |
|
|
906 | flush_ev.stop (); |
|
|
907 | |
904 | #ifdef TRANSPARENT |
908 | #ifdef TRANSPARENT |
905 | if (want_full_refresh) |
909 | if (want_full_refresh) |
906 | { |
910 | { |
907 | want_full_refresh = 0; |
911 | want_full_refresh = 0; |
908 | scr_clear (); |
912 | scr_clear (); |
… | |
… | |
918 | IMSendSpot (); |
922 | IMSendSpot (); |
919 | #endif |
923 | #endif |
920 | } |
924 | } |
921 | |
925 | |
922 | display->flush (); |
926 | display->flush (); |
923 | |
|
|
924 | flush_ev.stop (); |
|
|
925 | } |
927 | } |
926 | |
928 | |
927 | void |
929 | void |
928 | rxvt_term::check_cb (check_watcher &w) |
930 | rxvt_term::check_cb (check_watcher &w) |
929 | { |
931 | { |
… | |
… | |
1005 | { |
1007 | { |
1006 | if (mouse_slip_wheel_speed == 0 |
1008 | if (mouse_slip_wheel_speed == 0 |
1007 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1009 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1008 | : scr_page (UP, mouse_slip_wheel_speed)) |
1010 | : scr_page (UP, mouse_slip_wheel_speed)) |
1009 | { |
1011 | { |
|
|
1012 | if (TermWin.view_start == TermWin.nscrolled || |
|
|
1013 | TermWin.view_start == 0) |
|
|
1014 | mouse_slip_wheel_speed = 0; |
|
|
1015 | |
1010 | refresh_type |= SMOOTH_REFRESH; |
1016 | refresh_type |= SMOOTH_REFRESH; |
1011 | want_refresh = 1; |
1017 | want_refresh = 1; |
1012 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1018 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1013 | } |
1019 | } |
1014 | } |
1020 | } |
… | |
… | |
1046 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1052 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1047 | { |
1053 | { |
1048 | SET_R (this); |
1054 | SET_R (this); |
1049 | SET_LOCALE (locale); |
1055 | SET_LOCALE (locale); |
1050 | |
1056 | |
1051 | if (revents & EVENT_WRITE) |
|
|
1052 | tt_write (0, 0); |
|
|
1053 | else if (revents & EVENT_READ) |
1057 | if (revents & EVENT_READ) |
1054 | // loop, but don't allow a single term to monopolize us |
1058 | // loop, but don't allow a single term to monopolize us |
1055 | while (pty_fill ()) |
1059 | while (pty_fill ()) |
1056 | if (cmd_parse ()) |
1060 | if (cmd_parse ()) |
1057 | break; |
1061 | break; |
|
|
1062 | |
|
|
1063 | if (revents & EVENT_WRITE) |
|
|
1064 | pty_write (); |
1058 | } |
1065 | } |
1059 | |
1066 | |
1060 | void |
1067 | void |
1061 | rxvt_term::pointer_unblank () |
1068 | rxvt_term::pointer_unblank () |
1062 | { |
1069 | { |
… | |
… | |
1076 | rxvt_term::pointer_blank () |
1083 | rxvt_term::pointer_blank () |
1077 | { |
1084 | { |
1078 | if (! (options & Opt_pointerBlank)) |
1085 | if (! (options & Opt_pointerBlank)) |
1079 | return; |
1086 | return; |
1080 | |
1087 | |
1081 | XDefineCursor (display->display, TermWin.vt, blank_cursor); |
1088 | XDefineCursor (display->display, TermWin.vt, display->blank_cursor); |
1082 | XFlush (display->display); |
1089 | XFlush (display->display); |
1083 | |
1090 | |
1084 | hidden_pointer = 1; |
1091 | hidden_pointer = 1; |
1085 | } |
1092 | } |
1086 | |
1093 | |
… | |
… | |
1137 | + ((MEvent.state & ModMetaMask) ? 8 : 0) |
1144 | + ((MEvent.state & ModMetaMask) ? 8 : 0) |
1138 | + ((MEvent.state & ControlMask) ? 16 : 0); |
1145 | + ((MEvent.state & ControlMask) ? 16 : 0); |
1139 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1146 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1140 | key_state += ((MEvent.clicks > 1) ? 32 : 0); |
1147 | key_state += ((MEvent.clicks > 1) ? 32 : 0); |
1141 | #endif |
1148 | #endif |
1142 | |
|
|
1143 | } |
1149 | } |
1144 | |
1150 | |
1145 | #ifdef DEBUG_MOUSEREPORT |
1151 | #if DEBUG_MOUSEREPORT |
1146 | fprintf (stderr, "Mouse ["); |
1152 | fprintf (stderr, "Mouse ["); |
1147 | if (key_state & 16) |
1153 | if (key_state & 16) |
1148 | fputc ('C', stderr); |
1154 | fputc ('C', stderr); |
1149 | if (key_state & 4) |
1155 | if (key_state & 4) |
1150 | fputc ('S', stderr); |
1156 | fputc ('S', stderr); |
… | |
… | |
1154 | fputc ('2', stderr); |
1160 | fputc ('2', stderr); |
1155 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1161 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1156 | button_number, |
1162 | button_number, |
1157 | x + 1, |
1163 | x + 1, |
1158 | y + 1); |
1164 | y + 1); |
1159 | #else |
1165 | #endif |
|
|
1166 | |
1160 | tt_printf ("\033[M%c%c%c", |
1167 | tt_printf ("\033[M%c%c%c", |
1161 | (32 + button_number + key_state), |
1168 | (32 + button_number + key_state), |
1162 | (32 + x + 1), |
1169 | (32 + x + 1), |
1163 | (32 + y + 1)); |
1170 | (32 + y + 1)); |
1164 | #endif |
|
|
1165 | } |
1171 | } |
1166 | |
1172 | |
1167 | #ifdef USING_W11LIB |
1173 | #ifdef USING_W11LIB |
1168 | void |
1174 | void |
1169 | rxvt_W11_process_x_event (XEvent *ev) |
1175 | rxvt_W11_process_x_event (XEvent *ev) |
… | |
… | |
1206 | if (ev.type == KeyPress && hidden_pointer == 0) |
1212 | if (ev.type == KeyPress && hidden_pointer == 0) |
1207 | pointer_blank (); |
1213 | pointer_blank (); |
1208 | } |
1214 | } |
1209 | #endif |
1215 | #endif |
1210 | |
1216 | |
1211 | #ifdef USE_XIM |
|
|
1212 | if (XFilterEvent (&ev, None)) |
|
|
1213 | return; |
|
|
1214 | #endif |
|
|
1215 | |
|
|
1216 | Window unused_root, unused_child; |
1217 | Window unused_root, unused_child; |
1217 | int unused_root_x, unused_root_y; |
1218 | int unused_root_x, unused_root_y; |
1218 | unsigned int unused_mask; |
1219 | unsigned int unused_mask; |
1219 | |
1220 | |
1220 | switch (ev.type) |
1221 | switch (ev.type) |
1221 | { |
1222 | { |
1222 | case KeyPress: |
1223 | case KeyPress: |
1223 | #if ISO_14755 |
1224 | #if ISO_14755 |
… | |
… | |
1227 | |
1228 | |
1228 | break; |
1229 | break; |
1229 | |
1230 | |
1230 | case KeyRelease: |
1231 | case KeyRelease: |
1231 | { |
1232 | { |
1232 | #if (defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)) || defined (ENABLE_FRILLS) |
1233 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1233 | KeySym ks; |
1234 | KeySym ks; |
1234 | |
1235 | |
1235 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1236 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1236 | #endif |
1237 | #endif |
1237 | |
1238 | |
… | |
… | |
1328 | 0L, 1000000L, |
1329 | 0L, 1000000L, |
1329 | False, AnyPropertyType, |
1330 | False, AnyPropertyType, |
1330 | &ActualType, &ActualFormat, |
1331 | &ActualType, &ActualFormat, |
1331 | &Size, &RemainingBytes, |
1332 | &Size, &RemainingBytes, |
1332 | &data); |
1333 | &data); |
1333 | XChangeProperty (display->display, display->root, |
1334 | set_string_property (XA_CUT_BUFFER0, data); |
1334 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1335 | 8, PropModeReplace, |
|
|
1336 | data, strlen (data)); |
|
|
1337 | XFree (data); |
1335 | XFree (data); |
1338 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1336 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1339 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1337 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1340 | } |
1338 | } |
1341 | #endif /* OFFIX_DND */ |
1339 | #endif /* OFFIX_DND */ |
1342 | break; |
1340 | break; |
1343 | |
1341 | |
… | |
… | |
1388 | #endif |
1386 | #endif |
1389 | #ifdef OFF_FOCUS_FADING |
1387 | #ifdef OFF_FOCUS_FADING |
1390 | if (rs[Rs_fade]) |
1388 | if (rs[Rs_fade]) |
1391 | { |
1389 | { |
1392 | pix_colors = pix_colors_focused; |
1390 | pix_colors = pix_colors_focused; |
1393 | set_colorfgbg (); |
|
|
1394 | scr_clear (); |
1391 | scr_recolour (); |
1395 | scr_touch (true); |
|
|
1396 | } |
1392 | } |
1397 | #endif |
1393 | #endif |
1398 | |
1394 | |
1399 | } |
1395 | } |
1400 | break; |
1396 | break; |
… | |
… | |
1402 | case FocusOut: |
1398 | case FocusOut: |
1403 | if (TermWin.focus) |
1399 | if (TermWin.focus) |
1404 | { |
1400 | { |
1405 | TermWin.focus = 0; |
1401 | TermWin.focus = 0; |
1406 | want_refresh = 1; |
1402 | want_refresh = 1; |
|
|
1403 | |
|
|
1404 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1405 | iso14755buf = 0; |
|
|
1406 | #endif |
|
|
1407 | #if ENABLE_OVERLAY |
|
|
1408 | scr_overlay_off (); |
|
|
1409 | #endif |
1407 | #ifdef USE_XIM |
1410 | #ifdef USE_XIM |
1408 | if (Input_Context != NULL) |
1411 | if (Input_Context != NULL) |
1409 | XUnsetICFocus (Input_Context); |
1412 | XUnsetICFocus (Input_Context); |
1410 | #endif |
1413 | #endif |
1411 | #ifdef CURSOR_BLINK |
1414 | #ifdef CURSOR_BLINK |
… | |
… | |
1415 | #endif |
1418 | #endif |
1416 | #ifdef OFF_FOCUS_FADING |
1419 | #ifdef OFF_FOCUS_FADING |
1417 | if (rs[Rs_fade]) |
1420 | if (rs[Rs_fade]) |
1418 | { |
1421 | { |
1419 | pix_colors = pix_colors_unfocused; |
1422 | pix_colors = pix_colors_unfocused; |
1420 | set_colorfgbg (); |
|
|
1421 | scr_clear (); |
1423 | scr_recolour (); |
1422 | scr_touch (true); |
|
|
1423 | } |
1424 | } |
1424 | #endif |
1425 | #endif |
1425 | |
|
|
1426 | } |
1426 | } |
1427 | break; |
1427 | break; |
1428 | |
1428 | |
1429 | case ConfigureNotify: |
1429 | case ConfigureNotify: |
1430 | if (ev.xconfigure.window == TermWin.parent[0]) |
1430 | if (ev.xconfigure.window == TermWin.parent[0]) |
… | |
… | |
1438 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1438 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1439 | } |
1439 | } |
1440 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1440 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1441 | |
1441 | |
1442 | if (szHint.width != width || szHint.height != height) |
1442 | if (szHint.width != width || szHint.height != height) |
|
|
1443 | { |
|
|
1444 | seen_resize = 1; |
1443 | resize_all_windows (width, height, 1); |
1445 | resize_all_windows (width, height, 1); |
|
|
1446 | } |
1444 | |
1447 | |
1445 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1448 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1446 | if (options & Opt_transparent) |
1449 | if (options & Opt_transparent) |
1447 | { |
|
|
1448 | check_our_parents (); |
1450 | check_our_parents (); |
1449 | if (am_transparent) |
|
|
1450 | want_refresh = want_full_refresh = 1; |
|
|
1451 | } |
|
|
1452 | #endif |
1451 | #endif |
1453 | } |
1452 | } |
1454 | break; |
1453 | break; |
1455 | |
1454 | |
1456 | case PropertyNotify: |
1455 | case PropertyNotify: |
… | |
… | |
1464 | selection_clear (); |
1463 | selection_clear (); |
1465 | break; |
1464 | break; |
1466 | |
1465 | |
1467 | case SelectionNotify: |
1466 | case SelectionNotify: |
1468 | if (selection_wait == Sel_normal) |
1467 | if (selection_wait == Sel_normal) |
1469 | selection_paste (ev.xselection.requestor, |
1468 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1470 | ev.xselection.property, True); |
|
|
1471 | break; |
1469 | break; |
1472 | |
1470 | |
1473 | case SelectionRequest: |
1471 | case SelectionRequest: |
1474 | selection_send (ev.xselectionrequest); |
1472 | selection_send (ev.xselectionrequest); |
1475 | break; |
1473 | break; |
… | |
… | |
1547 | { |
1545 | { |
1548 | menubar_control (ev.xbutton); |
1546 | menubar_control (ev.xbutton); |
1549 | break; |
1547 | break; |
1550 | } |
1548 | } |
1551 | #endif |
1549 | #endif |
1552 | if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1550 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1553 | break; |
1551 | break; |
1554 | |
1552 | |
1555 | if (ev.xany.window == TermWin.vt) |
1553 | if (ev.xany.window == TermWin.vt) |
1556 | { |
1554 | { |
1557 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1555 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
… | |
… | |
1560 | ; |
1558 | ; |
1561 | |
1559 | |
1562 | XQueryPointer (display->display, TermWin.vt, |
1560 | XQueryPointer (display->display, TermWin.vt, |
1563 | &unused_root, &unused_child, |
1561 | &unused_root, &unused_child, |
1564 | &unused_root_x, &unused_root_y, |
1562 | &unused_root_x, &unused_root_y, |
1565 | & (ev.xbutton.x), & (ev.xbutton.y), |
1563 | &ev.xbutton.x, &ev.xbutton.y, |
1566 | &unused_mask); |
1564 | &ev.xbutton.state); |
1567 | #ifdef MOUSE_THRESHOLD |
1565 | #ifdef MOUSE_THRESHOLD |
1568 | /* deal with a `jumpy' mouse */ |
1566 | /* deal with a `jumpy' mouse */ |
1569 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1567 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1570 | { |
1568 | { |
1571 | #endif |
1569 | #endif |
… | |
… | |
1576 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1574 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1577 | break; |
1575 | break; |
1578 | } |
1576 | } |
1579 | #endif |
1577 | #endif |
1580 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1578 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1581 | (ev.xbutton.state & Button3Mask) ? 2 : 0); |
1579 | ev.xbutton.state & Button3Mask ? 2 : 0); |
|
|
1580 | |
1582 | #ifdef SELECTION_SCROLLING |
1581 | #ifdef SELECTION_SCROLLING |
1583 | if (ev.xbutton.y < TermWin.int_bwidth |
1582 | if (ev.xbutton.y < TermWin.int_bwidth |
1584 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1583 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1585 | { |
1584 | { |
1586 | int dist; |
1585 | int dist; |
… | |
… | |
1597 | selection_save_x = ev.xbutton.x; |
1596 | selection_save_x = ev.xbutton.x; |
1598 | selection_save_y = ev.xbutton.y; |
1597 | selection_save_y = ev.xbutton.y; |
1599 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1598 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1600 | |
1599 | |
1601 | /* calc number of lines to scroll */ |
1600 | /* calc number of lines to scroll */ |
1602 | if (ev.xbutton.y<TermWin.int_bwidth) |
1601 | if (ev.xbutton.y < TermWin.int_bwidth) |
1603 | { |
1602 | { |
1604 | scroll_selection_dir = UP; |
1603 | scroll_selection_dir = UP; |
1605 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1604 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1606 | } |
1605 | } |
1607 | else |
1606 | else |
… | |
… | |
1631 | } |
1630 | } |
1632 | } |
1631 | } |
1633 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1632 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1634 | { |
1633 | { |
1635 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1634 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1636 | MotionNotify, &ev)) ; |
1635 | MotionNotify, &ev)) |
|
|
1636 | ; |
|
|
1637 | |
1637 | XQueryPointer (display->display, scrollBar.win, |
1638 | XQueryPointer (display->display, scrollBar.win, |
1638 | &unused_root, &unused_child, |
1639 | &unused_root, &unused_child, |
1639 | &unused_root_x, &unused_root_y, |
1640 | &unused_root_x, &unused_root_y, |
1640 | & (ev.xbutton.x), & (ev.xbutton.y), |
1641 | &ev.xbutton.x, &ev.xbutton.y, |
1641 | &unused_mask); |
1642 | &unused_mask); |
1642 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1643 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1643 | scrollbar_size ()); |
1644 | scrollbar_size ()); |
1644 | scr_refresh (refresh_type); |
1645 | scr_refresh (refresh_type); |
1645 | refresh_limit = 0; |
1646 | refresh_limit = 0; |
… | |
… | |
1661 | case PropertyNotify: |
1662 | case PropertyNotify: |
1662 | /* |
1663 | /* |
1663 | * if user used some Esetroot compatible prog to set the root bg, |
1664 | * 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. |
1665 | * use the property to determine the pixmap. We use it later on. |
1665 | */ |
1666 | */ |
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]) |
1667 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
|
|
1668 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1670 | return; |
1669 | return; |
1671 | |
1670 | |
1672 | /* FALLTHROUGH */ |
1671 | /* FALLTHROUGH */ |
1673 | case ReparentNotify: |
1672 | case ReparentNotify: |
1674 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1673 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
… | |
… | |
1700 | return; |
1699 | return; |
1701 | } |
1700 | } |
1702 | #endif |
1701 | #endif |
1703 | |
1702 | |
1704 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1703 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
|
|
1704 | |
1705 | if (reportmode) |
1705 | if (reportmode) |
1706 | { |
1706 | { |
1707 | /* mouse report from vt window */ |
1707 | /* mouse report from vt window */ |
1708 | /* save the xbutton state (for ButtonRelease) */ |
1708 | /* save the xbutton state (for ButtonRelease) */ |
1709 | MEvent.state = ev.state; |
1709 | MEvent.state = ev.state; |
… | |
… | |
1738 | } |
1738 | } |
1739 | else |
1739 | else |
1740 | { |
1740 | { |
1741 | if (ev.button != MEvent.button) |
1741 | if (ev.button != MEvent.button) |
1742 | MEvent.clicks = 0; |
1742 | MEvent.clicks = 0; |
|
|
1743 | |
1743 | switch (ev.button) |
1744 | switch (ev.button) |
1744 | { |
1745 | { |
1745 | case Button1: |
1746 | case Button1: |
|
|
1747 | /* allow meta + click to select rectangular areas */ |
|
|
1748 | /* should be done in screen.C */ |
|
|
1749 | #if ENABLE_FRILLS |
|
|
1750 | selection.rect = !!(ev.state & ModMetaMask); |
|
|
1751 | #else |
|
|
1752 | selection.rect = false; |
|
|
1753 | #endif |
|
|
1754 | |
1746 | /* allow shift+left click to extend selection */ |
1755 | /* allow shift+left click to extend selection */ |
1747 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1756 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1748 | { |
1757 | { |
1749 | if (MEvent.button == Button1 && clickintime) |
1758 | if (MEvent.button == Button1 && clickintime) |
1750 | selection_rotate (ev.x, ev.y); |
1759 | selection_rotate (ev.x, ev.y); |
… | |
… | |
2334 | /* |
2343 | /* |
2335 | * Make the frame window set by the window manager have |
2344 | * Make the frame window set by the window manager have |
2336 | * the root background. Some window managers put multiple nested frame |
2345 | * the root background. Some window managers put multiple nested frame |
2337 | * windows for each client, so we have to take care about that. |
2346 | * windows for each client, so we have to take care about that. |
2338 | */ |
2347 | */ |
2339 | i = (xa[XA_XROOTPMAPID] |
2348 | i = (xa[XA_XROOTPMAP_ID] |
2340 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], |
2349 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID], |
2341 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2350 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2342 | &nitems, &bytes_after, &prop) == Success); |
2351 | &nitems, &bytes_after, &prop) == Success); |
2343 | |
2352 | |
2344 | if (!i || prop == NULL) |
2353 | if (!i || prop == NULL) |
2345 | i = (xa[XA_XSETROOTID] |
2354 | i = (xa[XA_ESETROOT_PMAP_ID] |
2346 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2355 | && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID], |
2347 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2356 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2348 | &nitems, &bytes_after, &prop) == Success); |
2357 | &nitems, &bytes_after, &prop) == Success); |
2349 | |
2358 | |
2350 | if (!i || prop == NULL |
2359 | if (!i || prop == NULL |
2351 | #if TINTING |
2360 | #if TINTING |
… | |
… | |
2392 | sy = 0; |
2401 | sy = 0; |
2393 | } |
2402 | } |
2394 | |
2403 | |
2395 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2404 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2396 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2405 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2406 | |
|
|
2407 | XSync (display->display, False); |
2397 | allowedxerror = -1; |
2408 | allowedxerror = -1; |
2398 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2409 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2399 | |
2410 | |
2400 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2411 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2401 | /* XXX: may need a delay here? */ |
2412 | /* XXX: may need a delay here? */ |
… | |
… | |
2447 | |
2458 | |
2448 | am_transparent = am_pixmap_trans = 1; |
2459 | am_transparent = am_pixmap_trans = 1; |
2449 | } |
2460 | } |
2450 | } |
2461 | } |
2451 | |
2462 | |
2452 | if (!am_pixmap_trans) |
2463 | if (am_pixmap_trans) |
|
|
2464 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
|
|
2465 | else |
2453 | { |
2466 | { |
2454 | unsigned int n; |
2467 | unsigned int n; |
2455 | /* |
2468 | /* |
2456 | * InheritPixmap transparency |
2469 | * InheritPixmap transparency |
2457 | */ |
2470 | */ |
… | |
… | |
2515 | |
2528 | |
2516 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2529 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2517 | TermWin.parent[i] = None; |
2530 | TermWin.parent[i] = None; |
2518 | } |
2531 | } |
2519 | |
2532 | |
2520 | // this is experimental |
|
|
2521 | if (scrollBar.win) |
2533 | if (scrollBar.win) |
2522 | { |
2534 | { |
2523 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2535 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2524 | XClearWindow (display->display, scrollBar.win); |
|
|
2525 | scrollBar.setIdle (); |
2536 | scrollBar.setIdle (); |
2526 | scrollbar_show (0); |
2537 | scrollbar_show (0); |
|
|
2538 | } |
|
|
2539 | |
|
|
2540 | if (am_transparent) |
|
|
2541 | { |
|
|
2542 | want_refresh = want_full_refresh = 1; |
|
|
2543 | if (am_pixmap_trans) |
|
|
2544 | flush (); |
2527 | } |
2545 | } |
2528 | |
2546 | |
2529 | return pchanged; |
2547 | return pchanged; |
2530 | } |
2548 | } |
2531 | #endif |
2549 | #endif |
… | |
… | |
2557 | seen_input = 1; |
2575 | seen_input = 1; |
2558 | // many badly-written programs (e.g. jed) contain a race condition: |
2576 | // many badly-written programs (e.g. jed) contain a race condition: |
2559 | // they first read the screensize and then install a SIGWINCH handler. |
2577 | // they first read the screensize and then install a SIGWINCH handler. |
2560 | // some window managers resize the window early, and these programs |
2578 | // some window managers resize the window early, and these programs |
2561 | // then sometimes get the size wrong. |
2579 | // then sometimes get the size wrong. |
|
|
2580 | // unfortunately other programs are even more buggy and dislike |
|
|
2581 | // being sent SIGWINCH, so only do it when we were in fact being |
|
|
2582 | // resized. |
|
|
2583 | if (seen_resize) |
2562 | kill (-cmd_pid, SIGWINCH); |
2584 | kill (-cmd_pid, SIGWINCH); |
2563 | } |
2585 | } |
2564 | |
2586 | |
2565 | /* Read a text string from the input buffer */ |
2587 | /* Read a text string from the input buffer */ |
2566 | unicode_t buf[UBUFSIZ]; |
2588 | unicode_t buf[UBUFSIZ]; |
2567 | bool refreshnow = false; |
2589 | bool refreshnow = false; |
… | |
… | |
2679 | if (len == (size_t)-1) |
2701 | if (len == (size_t)-1) |
2680 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2702 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2681 | |
2703 | |
2682 | // assume wchar == unicode |
2704 | // assume wchar == unicode |
2683 | cmdbuf_ptr += len; |
2705 | cmdbuf_ptr += len; |
2684 | return wc; |
2706 | return wc & UNICODE_MASK; |
2685 | } |
2707 | } |
2686 | |
2708 | |
2687 | return NOCHAR; |
2709 | return NOCHAR; |
2688 | } |
2710 | } |
2689 | |
2711 | |
… | |
… | |
3487 | * ends_how is terminator used. returned input must be free()'d |
3509 | * ends_how is terminator used. returned input must be free()'d |
3488 | */ |
3510 | */ |
3489 | unsigned char * |
3511 | unsigned char * |
3490 | rxvt_term::get_to_st (unicode_t &ends_how) |
3512 | rxvt_term::get_to_st (unicode_t &ends_how) |
3491 | { |
3513 | { |
3492 | unicode_t prev = 0, ch; |
3514 | unicode_t ch; |
|
|
3515 | bool seen_esc = false; |
3493 | unsigned int n = 0; |
3516 | unsigned int n = 0; |
3494 | unsigned char *s; |
|
|
3495 | unsigned char string[STRING_MAX]; |
3517 | wchar_t string[STRING_MAX]; |
3496 | |
3518 | |
3497 | while ((ch = cmd_getc ()) != NOCHAR) |
3519 | while ((ch = cmd_getc ()) != NOCHAR) |
3498 | { |
3520 | { |
3499 | if (prev == C0_ESC) |
3521 | if (seen_esc) |
3500 | { |
3522 | { |
3501 | if (ch == 0x5c) /* 7bit ST */ |
3523 | if (ch == 0x5c) /* 7bit ST */ |
3502 | break; |
3524 | break; |
3503 | else |
3525 | else |
3504 | return NULL; |
3526 | return NULL; |
3505 | } |
3527 | } |
|
|
3528 | else if (ch == C0_ESC) |
|
|
3529 | { |
|
|
3530 | seen_esc = true; |
|
|
3531 | continue; |
|
|
3532 | } |
3506 | else if (ch == C0_BEL || ch == CHAR_ST) |
3533 | else if (ch == C0_BEL || ch == CHAR_ST) |
3507 | break; |
3534 | break; |
3508 | else if (ch < 0x20) |
3535 | else if (ch < 0x20) |
3509 | return NULL; /* other control character - exit */ |
3536 | return NULL; /* other control character - exit */ |
|
|
3537 | |
|
|
3538 | seen_esc = false; |
3510 | |
3539 | |
3511 | if (n >= sizeof (string) - 1) |
3540 | if (n >= sizeof (string) - 1) |
3512 | // stop at some sane length |
3541 | // stop at some sane length |
3513 | return NULL; |
3542 | return NULL; |
3514 | |
3543 | |
3515 | if (ch == C0_SYN) |
3544 | if (ch == C0_SYN) |
3516 | { |
|
|
3517 | string[n++] = cmd_get8 (); |
3545 | string[n++] = cmd_get8 (); |
3518 | prev = 0; |
|
|
3519 | } |
|
|
3520 | else |
3546 | else |
3521 | string[n++] = prev = ch; |
3547 | string[n++] = ch; |
3522 | } |
3548 | } |
3523 | |
3549 | |
3524 | string[n++] = '\0'; |
3550 | string[n++] = '\0'; |
3525 | |
3551 | |
3526 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3527 | return NULL; |
|
|
3528 | |
|
|
3529 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3552 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3530 | strncpy (s, string, n); |
3553 | |
3531 | return s; |
3554 | return (unsigned char *)rxvt_wcstombs (string); |
3532 | } |
3555 | } |
3533 | |
3556 | |
3534 | /*----------------------------------------------------------------------*/ |
3557 | /*----------------------------------------------------------------------*/ |
3535 | /* |
3558 | /* |
3536 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3559 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3620 | { |
3643 | { |
3621 | int changed = 0; |
3644 | int changed = 0; |
3622 | int color; |
3645 | int color; |
3623 | char *buf, *name; |
3646 | char *buf, *name; |
3624 | bool query = str[0] == '?' && !str[1]; |
3647 | bool query = str[0] == '?' && !str[1]; |
|
|
3648 | int saveop = op; |
3625 | |
3649 | |
3626 | assert (str != NULL); |
3650 | assert (str != NULL); |
3627 | switch (op) |
3651 | switch (op) |
3628 | { |
3652 | { |
3629 | case XTerm_name: |
3653 | case XTerm_name: |
… | |
… | |
3636 | set_title (str); |
3660 | set_title (str); |
3637 | break; |
3661 | break; |
3638 | case XTerm_property: |
3662 | case XTerm_property: |
3639 | if (str[0] == '?') |
3663 | if (str[0] == '?') |
3640 | { |
3664 | { |
3641 | Atom prop = XInternAtom (display->display, str + 1, True); |
3665 | Atom prop = display->atom (str + 1); |
3642 | Atom actual_type; |
3666 | Atom actual_type; |
3643 | int actual_format; |
3667 | int actual_format; |
3644 | unsigned long nitems; |
3668 | unsigned long nitems; |
3645 | unsigned long bytes_after; |
3669 | unsigned long bytes_after; |
3646 | unsigned char *value = 0; |
3670 | unsigned char *value = 0; |
… | |
… | |
3664 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3688 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3665 | |
3689 | |
3666 | if (eq) |
3690 | if (eq) |
3667 | { |
3691 | { |
3668 | *eq = 0; |
3692 | *eq = 0; |
3669 | XChangeProperty (display->display, TermWin.parent[0], |
3693 | 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 | } |
3694 | } |
3674 | else |
3695 | else |
3675 | XDeleteProperty (display->display, TermWin.parent[0], |
3696 | XDeleteProperty (display->display, TermWin.parent[0], |
3676 | display->atom (str)); |
3697 | display->atom (str)); |
3677 | } |
3698 | } |
… | |
… | |
3721 | break; |
3742 | break; |
3722 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3743 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3723 | case XTerm_Color_BD: |
3744 | case XTerm_Color_BD: |
3724 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3745 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3725 | break; |
3746 | break; |
|
|
3747 | case XTerm_Color_IT: |
|
|
3748 | process_color_seq (XTerm_Color_IT, Color_IT, str, resp); |
|
|
3749 | break; |
3726 | case XTerm_Color_UL: |
3750 | case XTerm_Color_UL: |
3727 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3751 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3728 | break; |
3752 | break; |
3729 | case XTerm_Color_RV: |
3753 | case XTerm_Color_RV: |
3730 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3754 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3755 | break; |
|
|
3756 | #endif |
|
|
3757 | #if TRANSPARENT && TINTING |
|
|
3758 | case XTerm_Color_tint: |
|
|
3759 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
|
|
3760 | check_our_parents (); |
|
|
3761 | if (am_transparent) |
|
|
3762 | want_full_refresh = want_refresh = 1; |
3731 | break; |
3763 | break; |
3732 | #endif |
3764 | #endif |
3733 | |
3765 | |
3734 | case XTerm_Pixmap: |
3766 | case XTerm_Pixmap: |
3735 | if (*str != ';') |
3767 | if (*str != ';') |
… | |
… | |
3744 | { |
3776 | { |
3745 | str++; |
3777 | str++; |
3746 | #if XPM_BACKGROUND |
3778 | #if XPM_BACKGROUND |
3747 | changed += scale_pixmap (str); |
3779 | changed += scale_pixmap (str); |
3748 | #endif |
3780 | #endif |
3749 | |
|
|
3750 | } |
3781 | } |
|
|
3782 | |
3751 | if (changed) |
3783 | if (changed) |
3752 | { |
3784 | { |
3753 | #ifdef XPM_BACKGROUND |
3785 | #ifdef XPM_BACKGROUND |
3754 | resize_pixmap (); |
3786 | resize_pixmap (); |
3755 | #endif |
3787 | #endif |
… | |
… | |
3767 | case XTerm_logfile: |
3799 | case XTerm_logfile: |
3768 | // TODO, when secure mode? |
3800 | // TODO, when secure mode? |
3769 | break; |
3801 | break; |
3770 | |
3802 | |
3771 | case XTerm_font: |
3803 | case XTerm_font: |
|
|
3804 | op = URxvt_font; |
|
|
3805 | case URxvt_font: |
|
|
3806 | #if ENABLE_STYLES |
|
|
3807 | case URxvt_boldFont: |
|
|
3808 | case URxvt_italicFont: |
|
|
3809 | case URxvt_boldItalicFont: |
|
|
3810 | #endif |
3772 | if (query) |
3811 | if (query) |
3773 | tt_printf ("\33]%d;%-.250s%c", XTerm_font, |
3812 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3774 | (options & Opt_insecure) && TermWin.fontset->fontdesc |
3813 | (options & Opt_insecure) && TermWin.fontset[op - URxvt_font]->fontdesc |
3775 | ? TermWin.fontset->fontdesc : "", |
3814 | ? TermWin.fontset[op - URxvt_font]->fontdesc : "", |
3776 | resp); |
3815 | resp); |
3777 | else |
3816 | else |
|
|
3817 | { |
|
|
3818 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
|
|
3819 | |
|
|
3820 | res = strdup (str); |
|
|
3821 | allocated.push_back ((void *)res); |
3778 | change_font (str); |
3822 | set_fonts (); |
|
|
3823 | } |
3779 | break; |
3824 | break; |
3780 | |
3825 | |
3781 | #if ENABLE_FRILLS |
3826 | #if ENABLE_FRILLS |
3782 | case XTerm_locale: |
3827 | case XTerm_locale: |
3783 | if (query) |
3828 | if (query) |
3784 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3829 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3785 | else |
3830 | else |
3786 | { |
3831 | { |
3787 | set_locale (str); |
3832 | set_locale (str); |
|
|
3833 | pty.set_utf8_mode (enc_utf8); |
3788 | # ifdef USE_XIM |
3834 | # ifdef USE_XIM |
3789 | im_cb (); |
3835 | im_cb (); |
3790 | # endif |
3836 | # endif |
3791 | } |
3837 | } |
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; |
3838 | break; |
3803 | #endif |
3839 | #endif |
3804 | |
3840 | |
3805 | #ifdef MENUBAR |
3841 | #ifdef MENUBAR |
3806 | case XTerm_Menu: |
3842 | case XTerm_Menu: |
… | |
… | |
3935 | |
3971 | |
3936 | /* extra handling for values with state unkept */ |
3972 | /* extra handling for values with state unkept */ |
3937 | switch (arg[i]) |
3973 | switch (arg[i]) |
3938 | { |
3974 | { |
3939 | case 1048: /* alternative cursor save */ |
3975 | case 1048: /* alternative cursor save */ |
|
|
3976 | case 1049: |
3940 | if (options & Opt_secondaryScreen) |
3977 | if (options & Opt_secondaryScreen) |
3941 | if (mode == 0) |
3978 | if (mode == 0) |
3942 | scr_cursor (RESTORE); |
3979 | scr_cursor (RESTORE); |
3943 | else if (mode == 1) |
3980 | else if (mode == 1) |
3944 | scr_cursor (SAVE); |
3981 | scr_cursor (SAVE); |
… | |
… | |
4069 | rendset = 0, rendstyle = ~RS_None; |
4106 | rendset = 0, rendstyle = ~RS_None; |
4070 | break; |
4107 | break; |
4071 | case 1: |
4108 | case 1: |
4072 | rendset = 1, rendstyle = RS_Bold; |
4109 | rendset = 1, rendstyle = RS_Bold; |
4073 | break; |
4110 | break; |
4074 | //case 2: // faint or second colour |
4111 | //case 2: // low intensity |
4075 | //case 3: // italic |
4112 | case 3: |
|
|
4113 | rendset = 1, rendstyle = RS_Italic; |
|
|
4114 | break; |
4076 | case 4: |
4115 | case 4: |
4077 | rendset = 1, rendstyle = RS_Uline; |
4116 | rendset = 1, rendstyle = RS_Uline; |
4078 | break; |
4117 | break; |
4079 | case 5: // slowly blinking |
4118 | case 5: // slowly blinking |
4080 | case 6: // rapidly blinking |
4119 | case 6: // rapidly blinking |
… | |
… | |
4092 | //case 11: // scoansi acs on, first alt font |
4131 | //case 11: // scoansi acs on, first alt font |
4093 | //case 12: // scoansi acs on, |0x80, second alt font |
4132 | //case 12: // scoansi acs on, |0x80, second alt font |
4094 | //... |
4133 | //... |
4095 | //case 19: // ninth alt font |
4134 | //case 19: // ninth alt font |
4096 | //case 20: // gothic |
4135 | //case 20: // gothic |
4097 | case 21: // disable bold, faint |
4136 | case 21: // disable bold, faint, sometimes doubly underlined (iso 8613) |
4098 | rendset = 0, rendstyle = RS_Bold; |
4137 | rendset = 0, rendstyle = RS_Bold; |
4099 | break; |
4138 | break; |
4100 | case 22: |
4139 | case 22: // normal intensity |
4101 | rendset = 0, rendstyle = RS_Bold; |
4140 | rendset = 0, rendstyle = RS_Bold; |
4102 | break; |
4141 | break; |
4103 | //case 23: disable italic |
4142 | case 23: // disable italic |
|
|
4143 | rendset = 0, rendstyle = RS_Italic; |
|
|
4144 | break; |
4104 | case 24: |
4145 | case 24: |
4105 | rendset = 0, rendstyle = RS_Uline; |
4146 | rendset = 0, rendstyle = RS_Uline; |
4106 | break; |
4147 | break; |
4107 | case 25: |
4148 | case 25: |
4108 | rendset = 0, rendstyle = RS_Blink; |
4149 | rendset = 0, rendstyle = RS_Blink; |
4109 | break; |
4150 | break; |
4110 | case 26: |
4151 | case 26: // variable spacing (iso 8613) |
4111 | rendset = 0, rendstyle = RS_Blink; |
4152 | rendset = 0, rendstyle = RS_Blink; |
4112 | break; |
4153 | break; |
4113 | case 27: |
4154 | case 27: |
4114 | rendset = 0, rendstyle = RS_RVid; |
4155 | rendset = 0, rendstyle = RS_RVid; |
4115 | break; |
4156 | break; |
… | |
… | |
4133 | case 35: |
4174 | case 35: |
4134 | case 36: |
4175 | case 36: |
4135 | case 37: |
4176 | case 37: |
4136 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
4177 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
4137 | break; |
4178 | break; |
4138 | #ifdef TTY_256COLOR |
4179 | case 38: // set fg color, ISO 8613-6 |
4139 | case 38: |
|
|
4140 | if (nargs > i + 2 && arg[i + 1] == 5) |
4180 | if (nargs > i + 2 && arg[i + 1] == 5) |
4141 | { |
4181 | { |
4142 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
4182 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
4143 | i += 2; |
4183 | i += 2; |
4144 | } |
4184 | } |
4145 | break; |
4185 | break; |
4146 | #endif |
|
|
4147 | case 39: /* default fg */ |
4186 | case 39: /* default fg */ |
4148 | scr_color (Color_fg, Color_fg); |
4187 | scr_color (Color_fg, Color_fg); |
4149 | break; |
4188 | break; |
4150 | |
4189 | |
4151 | case 40: |
4190 | case 40: |
… | |
… | |
4156 | case 45: |
4195 | case 45: |
4157 | case 46: |
4196 | case 46: |
4158 | case 47: |
4197 | case 47: |
4159 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
4198 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
4160 | break; |
4199 | break; |
4161 | #ifdef TTY_256COLOR |
4200 | case 48: // set bg color, ISO 8613-6 |
4162 | case 48: |
|
|
4163 | if (nargs > i + 2 && arg[i + 1] == 5) |
4201 | if (nargs > i + 2 && arg[i + 1] == 5) |
4164 | { |
4202 | { |
4165 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
4203 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
4166 | i += 2; |
4204 | i += 2; |
4167 | } |
4205 | } |
4168 | break; |
4206 | break; |
4169 | #endif |
|
|
4170 | case 49: /* default bg */ |
4207 | case 49: /* default bg */ |
4171 | scr_color (Color_bg, Color_bg); |
4208 | scr_color (Color_bg, Color_bg); |
4172 | break; |
4209 | break; |
|
|
4210 | |
|
|
4211 | //case 50: // not variable spacing |
4173 | |
4212 | |
4174 | #ifndef NO_BRIGHTCOLOR |
4213 | #ifndef NO_BRIGHTCOLOR |
4175 | case 90: |
4214 | case 90: |
4176 | case 91: /* set bright fg color */ |
4215 | case 91: /* set bright fg color */ |
4177 | case 92: |
4216 | case 92: |
4178 | case 93: |
4217 | case 93: |
4179 | case 94: |
4218 | case 94: |
4180 | case 95: |
4219 | case 95: |
4181 | case 96: |
4220 | case 96: |
4182 | case 97: |
4221 | case 97: |
4183 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), |
4222 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), Color_fg); |
4184 | Color_fg); |
|
|
4185 | break; |
4223 | break; |
4186 | case 100: |
4224 | case 100: |
4187 | case 101: /* set bright bg color */ |
4225 | case 101: /* set bright bg color */ |
4188 | case 102: |
4226 | case 102: |
4189 | case 103: |
4227 | case 103: |
4190 | case 104: |
4228 | case 104: |
4191 | case 105: |
4229 | case 105: |
4192 | case 106: |
4230 | case 106: |
4193 | case 107: |
4231 | case 107: |
4194 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), |
4232 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4195 | Color_bg); |
|
|
4196 | break; |
4233 | break; |
4197 | #endif |
4234 | #endif |
4198 | |
4235 | |
4199 | } |
4236 | } |
4200 | } |
4237 | } |
… | |
… | |
4239 | |
4276 | |
4240 | /* ---------------------------------------------------------------------- */ |
4277 | /* ---------------------------------------------------------------------- */ |
4241 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4278 | /* 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. |
4279 | * or generated by us in response to a query ESC sequence. |
4243 | */ |
4280 | */ |
|
|
4281 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4282 | |
4244 | void |
4283 | void |
4245 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4284 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4246 | { |
4285 | { |
4247 | enum { MAX_PTY_WRITE = 255 }; // minimum MAX_INPUT |
4286 | if (v_buflen == 0) |
|
|
4287 | { |
|
|
4288 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4248 | |
4289 | |
4249 | if (len) |
4290 | if ((unsigned int)written == len) |
|
|
4291 | return; |
|
|
4292 | |
|
|
4293 | data += written; |
|
|
4294 | len -= written; |
4250 | { |
4295 | } |
|
|
4296 | |
|
|
4297 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4298 | |
|
|
4299 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4300 | v_buflen += len; |
|
|
4301 | |
|
|
4302 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4303 | } |
|
|
4304 | |
|
|
4305 | void rxvt_term::pty_write () |
|
|
4306 | { |
|
|
4307 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4308 | |
|
|
4309 | if (written > 0) |
|
|
4310 | { |
|
|
4311 | v_buflen -= written; |
|
|
4312 | |
4251 | if (v_buflen == 0) |
4313 | if (v_buflen == 0) |
4252 | { |
4314 | { |
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); |
4315 | free (v_buffer); |
4280 | v_buffer = 0; |
4316 | v_buffer = 0; |
4281 | v_buflen = 0; |
4317 | v_buflen = 0; |
4282 | |
4318 | |
4283 | pty_ev.set (EVENT_READ); |
4319 | 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; |
4320 | return; |
4296 | } |
4321 | } |
|
|
4322 | |
|
|
4323 | memmove (v_buffer, v_buffer + written, v_buflen); |
4297 | } |
4324 | } |
|
|
4325 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4326 | // original code just ignores this... |
|
|
4327 | destroy (); |
4298 | } |
4328 | } |
4299 | |
4329 | |
4300 | /*----------------------- end-of-file (C source) -----------------------*/ |
4330 | /*----------------------- end-of-file (C source) -----------------------*/ |
4301 | |
4331 | |