… | |
… | |
140 | valid_keysym = keysym != NoSymbol; |
140 | valid_keysym = keysym != NoSymbol; |
141 | } |
141 | } |
142 | |
142 | |
143 | if (valid_keysym) |
143 | if (valid_keysym) |
144 | { |
144 | { |
145 | /* for some backwards compatibility */ |
|
|
146 | #if defined(HOTKEY_CTRL) || defined(HOTKEY_META) |
|
|
147 | # ifdef HOTKEY_CTRL |
|
|
148 | if (ctrl) |
|
|
149 | # else |
|
|
150 | if (meta) |
|
|
151 | # endif |
|
|
152 | { |
|
|
153 | if (keysym == ks_bigfont) |
|
|
154 | { |
|
|
155 | change_font (FONT_UP); |
|
|
156 | return; |
|
|
157 | } |
|
|
158 | else if (keysym == ks_smallfont) |
|
|
159 | { |
|
|
160 | change_font (FONT_DN); |
|
|
161 | return; |
|
|
162 | } |
|
|
163 | } |
|
|
164 | #endif |
|
|
165 | |
|
|
166 | if (TermWin.saveLines) |
145 | if (TermWin.saveLines) |
167 | { |
146 | { |
168 | #ifdef UNSHIFTED_SCROLLKEYS |
147 | #ifdef UNSHIFTED_SCROLLKEYS |
169 | if (!ctrl && !meta) |
148 | if (!ctrl && !meta) |
170 | { |
149 | { |
… | |
… | |
261 | #ifdef KEYSYM_RESOURCE |
240 | #ifdef KEYSYM_RESOURCE |
262 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
241 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
263 | { |
242 | { |
264 | unsigned int l; |
243 | unsigned int l; |
265 | const unsigned char *kbuf0; |
244 | const unsigned char *kbuf0; |
266 | const unsigned char ch = C0_ESC; |
|
|
267 | |
245 | |
268 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
246 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
269 | l = (unsigned int)*kbuf0++; |
247 | l = (unsigned int)*kbuf0++; |
270 | |
248 | |
271 | /* escape prefix */ |
249 | /* escape prefix */ |
272 | if (meta) |
250 | if (meta |
273 | # ifdef META8_OPTION |
251 | # ifdef META8_OPTION |
274 | if (meta_char == C0_ESC) |
252 | && meta_char == C0_ESC |
275 | # endif |
253 | # endif |
|
|
254 | ) |
|
|
255 | { |
|
|
256 | const unsigned char ch = C0_ESC; |
276 | tt_write (&ch, 1); |
257 | tt_write (&ch, 1); |
|
|
258 | } |
|
|
259 | |
277 | tt_write (kbuf0, l); |
260 | tt_write (kbuf0, l); |
278 | return; |
261 | return; |
279 | } |
262 | } |
280 | else |
263 | else |
281 | #endif |
264 | #endif |
… | |
… | |
291 | ^ !!ctrl) ? '\b' : '\177'; |
274 | ^ !!ctrl) ? '\b' : '\177'; |
292 | kbuf[1] = '\0'; |
275 | kbuf[1] = '\0'; |
293 | } |
276 | } |
294 | else |
277 | else |
295 | STRCPY (kbuf, key_backspace); |
278 | STRCPY (kbuf, key_backspace); |
296 | # ifdef MULTICHAR_SET |
|
|
297 | if ((Options & Opt_mc_hack) && screen.cur.col > 0) |
|
|
298 | { |
|
|
299 | int col, row; |
|
|
300 | |
|
|
301 | newlen = STRLEN (kbuf); |
|
|
302 | col = screen.cur.col - 1; |
|
|
303 | row = screen.cur.row + TermWin.saveLines; |
|
|
304 | if (IS_MULTI2 (screen.rend[row][col])) |
|
|
305 | MEMMOVE (kbuf + newlen, kbuf, newlen + 1); |
|
|
306 | } |
|
|
307 | # endif |
|
|
308 | break; |
279 | break; |
309 | #endif |
280 | #endif |
310 | #ifndef NO_DELETE_KEY |
281 | #ifndef NO_DELETE_KEY |
311 | case XK_Delete: |
282 | case XK_Delete: |
312 | STRCPY (kbuf, key_delete); |
283 | STRCPY (kbuf, key_delete); |
313 | # ifdef MULTICHAR_SET |
|
|
314 | if (Options & Opt_mc_hack) |
|
|
315 | { |
|
|
316 | int col, row; |
|
|
317 | |
|
|
318 | newlen = STRLEN (kbuf); |
|
|
319 | col = screen.cur.col; |
|
|
320 | row = screen.cur.row + TermWin.saveLines; |
|
|
321 | if (IS_MULTI1 (screen.rend[row][col])) |
|
|
322 | MEMMOVE (kbuf + newlen, kbuf, newlen + 1); |
|
|
323 | } |
|
|
324 | # endif |
|
|
325 | break; |
284 | break; |
326 | #endif |
285 | #endif |
327 | case XK_Tab: |
286 | case XK_Tab: |
328 | if (shft) |
287 | if (shft) |
329 | STRCPY (kbuf, "\033[Z"); |
288 | STRCPY (kbuf, "\033[Z"); |
… | |
… | |
371 | kbuf[1] = 'O'; |
330 | kbuf[1] = 'O'; |
372 | kbuf[2] = "dacb"[keysym - XK_Left]; |
331 | kbuf[2] = "dacb"[keysym - XK_Left]; |
373 | } |
332 | } |
374 | else if (PrivateModes & PrivMode_aplCUR) |
333 | else if (PrivateModes & PrivMode_aplCUR) |
375 | kbuf[1] = 'O'; |
334 | kbuf[1] = 'O'; |
376 | #ifdef MULTICHAR_SET |
|
|
377 | //TODO: ?? |
|
|
378 | if (Options & Opt_mc_hack) |
|
|
379 | { |
|
|
380 | int col, row, m; |
|
|
381 | |
|
|
382 | col = screen.cur.col; |
|
|
383 | row = screen.cur.row + TermWin.saveLines; |
|
|
384 | m = 0; |
|
|
385 | if (keysym == XK_Right |
|
|
386 | && IS_MULTI1 (screen.rend[row][col])) |
|
|
387 | m = 1; |
|
|
388 | else if (keysym == XK_Left) |
|
|
389 | { |
|
|
390 | if (col > 0) |
|
|
391 | { |
|
|
392 | if (IS_MULTI2 (screen.rend[row][col - 1])) |
|
|
393 | m = 1; |
|
|
394 | } |
|
|
395 | else if (screen.cur.row > 0) |
|
|
396 | { |
|
|
397 | col = screen.tlen[--row]; |
|
|
398 | if (col == -1) |
|
|
399 | col = TermWin.ncol - 1; |
|
|
400 | else |
|
|
401 | col--; |
|
|
402 | if (col > 0 |
|
|
403 | && IS_MULTI2 (screen.rend[row][col])) |
|
|
404 | m = 1; |
|
|
405 | } |
|
|
406 | } |
|
|
407 | if (m) |
|
|
408 | MEMMOVE (kbuf + 3, kbuf, 3 + 1); |
|
|
409 | } |
|
|
410 | #endif |
|
|
411 | break; |
335 | break; |
412 | |
336 | |
413 | #ifndef UNSHIFTED_SCROLLKEYS |
337 | #ifndef UNSHIFTED_SCROLLKEYS |
414 | # ifdef XK_KP_Prior |
338 | # ifdef XK_KP_Prior |
415 | case XK_KP_Prior: |
339 | case XK_KP_Prior: |
… | |
… | |
604 | break; |
528 | break; |
605 | } |
529 | } |
606 | if (newlen) |
530 | if (newlen) |
607 | len = STRLEN (kbuf); |
531 | len = STRLEN (kbuf); |
608 | } |
532 | } |
|
|
533 | |
609 | /* |
534 | /* |
610 | * Pass meta for all function keys, if 'meta' option set |
535 | * Pass meta for all function keys, if 'meta' option set |
611 | */ |
536 | */ |
612 | #ifdef META8_OPTION |
537 | #ifdef META8_OPTION |
613 | if (meta && (meta_char == 0x80) && len > 0) |
538 | if (meta && (meta_char == 0x80) && len > 0) |
… | |
… | |
628 | { |
553 | { |
629 | unsigned char *ch; |
554 | unsigned char *ch; |
630 | |
555 | |
631 | for (ch = kbuf; ch < kbuf + len; ch++) |
556 | for (ch = kbuf; ch < kbuf + len; ch++) |
632 | *ch |= 0x80; |
557 | *ch |= 0x80; |
|
|
558 | |
633 | meta = 0; |
559 | meta = 0; |
634 | } |
560 | } |
635 | #endif |
561 | #endif |
636 | /* nil */ ; |
562 | /* nil */ ; |
637 | } |
563 | } |
… | |
… | |
942 | uint32_t |
868 | uint32_t |
943 | rxvt_term::next_char () |
869 | rxvt_term::next_char () |
944 | { |
870 | { |
945 | while (cmdbuf_ptr < cmdbuf_endp) |
871 | while (cmdbuf_ptr < cmdbuf_endp) |
946 | { |
872 | { |
947 | if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh |
873 | // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh |
|
|
874 | if ((*cmdbuf_ptr <= 0x7f && 0x20 <= *cmdbuf_ptr) |
|
|
875 | || !*cmdbuf_ptr) |
948 | return *cmdbuf_ptr++; |
876 | return *cmdbuf_ptr++; |
949 | |
877 | |
950 | wchar_t wc; |
878 | wchar_t wc; |
951 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
879 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
952 | |
880 | |
953 | if (len == (size_t)-2) |
881 | if (len == (size_t)-2) |
954 | return NOCHAR; |
882 | { |
|
|
883 | // the mbstate stores incomplete sequences. didn't know this :/ |
|
|
884 | cmdbuf_ptr = cmdbuf_endp; |
|
|
885 | break; |
|
|
886 | } |
955 | |
887 | |
956 | if (len == (size_t)-1) |
888 | if (len == (size_t)-1) |
957 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
889 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
958 | |
890 | |
959 | // assume wchar == unicode |
891 | // assume wchar == unicode |
… | |
… | |
1987 | if (have_pixmap) |
1919 | if (have_pixmap) |
1988 | { |
1920 | { |
1989 | /* |
1921 | /* |
1990 | * Copy display->root pixmap transparency |
1922 | * Copy display->root pixmap transparency |
1991 | */ |
1923 | */ |
1992 | int sx, sy, nx, ny; |
1924 | int sx, sy, nx, ny; |
1993 | unsigned int nw, nh; |
1925 | unsigned int nw, nh; |
1994 | Window cr; |
1926 | Window cr; |
1995 | XImage *image; |
1927 | XImage *image; |
1996 | GC gc; |
1928 | GC gc; |
1997 | XGCValues gcvalue; |
1929 | XGCValues gcvalue; |
1998 | |
1930 | |
1999 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
1931 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
2000 | 0, 0, &sx, &sy, &cr); |
1932 | 0, 0, &sx, &sy, &cr); |
2001 | nw = (unsigned int)szHint.width; |
1933 | nw = (unsigned int)szHint.width; |
2002 | nh = (unsigned int)szHint.height; |
1934 | nh = (unsigned int)szHint.height; |
2003 | nx = ny = 0; |
1935 | nx = ny = 0; |
|
|
1936 | |
2004 | if (sx < 0) |
1937 | if (sx < 0) |
2005 | { |
1938 | { |
2006 | nw += sx; |
1939 | nw += sx; |
2007 | nx = -sx; |
1940 | nx = -sx; |
2008 | sx = 0; |
1941 | sx = 0; |
2009 | } |
1942 | } |
|
|
1943 | |
2010 | if (sy < 0) |
1944 | if (sy < 0) |
2011 | { |
1945 | { |
2012 | nh += sy; |
1946 | nh += sy; |
2013 | ny = -sy; |
1947 | ny = -sy; |
2014 | sy = 0; |
1948 | sy = 0; |
2015 | } |
1949 | } |
|
|
1950 | |
2016 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
1951 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2017 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
1952 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2018 | allowedxerror = -1; |
1953 | allowedxerror = -1; |
2019 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
1954 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
2020 | ZPixmap); |
1955 | ZPixmap); |
… | |
… | |
2053 | if (!am_transparent || !am_pixmap_trans) |
1988 | if (!am_transparent || !am_pixmap_trans) |
2054 | pchanged = 1; |
1989 | pchanged = 1; |
2055 | am_transparent = am_pixmap_trans = 1; |
1990 | am_transparent = am_pixmap_trans = 1; |
2056 | } |
1991 | } |
2057 | } |
1992 | } |
|
|
1993 | |
2058 | if (!am_pixmap_trans) |
1994 | if (!am_pixmap_trans) |
2059 | { |
1995 | { |
2060 | unsigned int n; |
1996 | unsigned int n; |
2061 | /* |
1997 | /* |
2062 | * InheritPixmap transparency |
1998 | * InheritPixmap transparency |
… | |
… | |
2077 | break; |
2013 | break; |
2078 | } |
2014 | } |
2079 | if (oldp != TermWin.parent[i]) |
2015 | if (oldp != TermWin.parent[i]) |
2080 | pchanged = 1; |
2016 | pchanged = 1; |
2081 | } |
2017 | } |
|
|
2018 | |
2082 | n = 0; |
2019 | n = 0; |
|
|
2020 | |
2083 | if (pchanged) |
2021 | if (pchanged) |
2084 | { |
2022 | { |
2085 | for (; n < (unsigned int)i; n++) |
2023 | for (; n < (unsigned int)i; n++) |
2086 | { |
2024 | { |
2087 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
2025 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
… | |
… | |
2091 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2029 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2092 | break; |
2030 | break; |
2093 | } |
2031 | } |
2094 | } |
2032 | } |
2095 | } |
2033 | } |
|
|
2034 | |
2096 | if (n > (int) (sizeof (TermWin.parent) |
2035 | if (n > (int) (sizeof (TermWin.parent) |
2097 | / sizeof (TermWin.parent[0]))) |
2036 | / sizeof (TermWin.parent[0]))) |
2098 | { |
2037 | { |
2099 | D_X ((stderr, "InheritPixmap Turning off")); |
2038 | D_X ((stderr, "InheritPixmap Turning off")); |
2100 | XSetWindowBackground (display->display, TermWin.parent[0], |
2039 | XSetWindowBackground (display->display, TermWin.parent[0], |
… | |
… | |
2123 | ParentRelative); |
2062 | ParentRelative); |
2124 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2063 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2125 | ParentRelative); |
2064 | ParentRelative); |
2126 | am_transparent = 1; |
2065 | am_transparent = 1; |
2127 | } |
2066 | } |
|
|
2067 | |
2128 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2068 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2129 | TermWin.parent[i] = None; |
2069 | TermWin.parent[i] = None; |
2130 | } |
2070 | } |
2131 | return pchanged; |
2071 | return pchanged; |
2132 | } |
2072 | } |
… | |
… | |
2138 | /*----------------------------------------------------------------------*/ |
2078 | /*----------------------------------------------------------------------*/ |
2139 | #ifdef PRINTPIPE |
2079 | #ifdef PRINTPIPE |
2140 | FILE * |
2080 | FILE * |
2141 | rxvt_term::popen_printer () |
2081 | rxvt_term::popen_printer () |
2142 | { |
2082 | { |
2143 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2083 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2144 | |
2084 | |
2145 | if (stream == NULL) |
2085 | if (stream == NULL) |
2146 | rxvt_print_error ("can't open printer pipe"); |
2086 | rxvt_print_error ("can't open printer pipe"); |
2147 | return stream; |
2087 | return stream; |
2148 | } |
2088 | } |
… | |
… | |
2360 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2300 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2361 | break; |
2301 | break; |
2362 | case '+': |
2302 | case '+': |
2363 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2303 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2364 | break; |
2304 | break; |
2365 | #ifdef MULTICHAR_SET |
|
|
2366 | case '$': |
|
|
2367 | scr_charset_set (-2, (unsigned int)cmd_getc ()); |
|
|
2368 | break; |
|
|
2369 | #endif |
|
|
2370 | #ifndef NO_FRILLS |
2305 | #ifndef NO_FRILLS |
2371 | case '6': |
2306 | case '6': |
2372 | scr_backindex (); |
2307 | scr_backindex (); |
2373 | break; |
2308 | break; |
2374 | #endif |
2309 | #endif |
… | |
… | |
2715 | case 7: /* unofficial extension */ |
2650 | case 7: /* unofficial extension */ |
2716 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2651 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2717 | break; |
2652 | break; |
2718 | #endif |
2653 | #endif |
2719 | case 8: /* unofficial extension */ |
2654 | case 8: /* unofficial extension */ |
2720 | xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); |
2655 | xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
2721 | break; |
2656 | break; |
2722 | } |
2657 | } |
2723 | break; |
2658 | break; |
2724 | |
2659 | |
2725 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
2660 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
… | |
… | |
2994 | * 19 = change underlined character color |
2929 | * 19 = change underlined character color |
2995 | * 46 = change logfile (not implemented) |
2930 | * 46 = change logfile (not implemented) |
2996 | * 50 = change font |
2931 | * 50 = change font |
2997 | * |
2932 | * |
2998 | * rxvt extensions: |
2933 | * rxvt extensions: |
2999 | * 9 = change locale (NYI) |
|
|
3000 | * 10 = menu (may change in future) |
2934 | * 10 = menu (may change in future) |
3001 | * 20 = bg pixmap |
2935 | * 20 = bg pixmap |
3002 | * 39 = change default fg color |
2936 | * 39 = change default fg color |
3003 | * 49 = change default bg color |
2937 | * 49 = change default bg color |
3004 | * 55 = dump scrollback buffer and all of screen |
2938 | * 55 = dump scrollback buffer and all of screen |
|
|
2939 | * 701 = change locale |
|
|
2940 | * 702 = find font |
3005 | */ |
2941 | */ |
3006 | void |
2942 | void |
3007 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
2943 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
3008 | { |
2944 | { |
3009 | int changed = 0; |
2945 | int changed = 0; |
… | |
… | |
3097 | case XTerm_logfile: |
3033 | case XTerm_logfile: |
3098 | break; |
3034 | break; |
3099 | case XTerm_font: |
3035 | case XTerm_font: |
3100 | change_font (str); |
3036 | change_font (str); |
3101 | break; |
3037 | break; |
|
|
3038 | #ifndef NO_FRILLS |
3102 | case XTerm_locale: |
3039 | case XTerm_locale: |
3103 | if (str[0] == '?' && !str[1]) |
3040 | if (str[0] == '?' && !str[1]) |
3104 | tt_printf ("%-.250s\n", locale); |
3041 | tt_printf ("%-.250s\n", locale); |
3105 | else |
3042 | else |
3106 | { |
3043 | { |
3107 | set_locale (str); |
3044 | set_locale (str); |
|
|
3045 | # ifdef USE_XIM |
3108 | im_cb (); |
3046 | im_cb (); |
|
|
3047 | # endif |
3109 | } |
3048 | } |
3110 | break; |
3049 | break; |
|
|
3050 | case XTerm_findfont: |
|
|
3051 | { |
|
|
3052 | int fid = TermWin.fontset->find_font (atoi (str)); |
|
|
3053 | tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name); |
|
|
3054 | } |
|
|
3055 | break; |
|
|
3056 | #endif |
3111 | #if 0 |
3057 | #if 0 |
3112 | case XTerm_dumpscreen: /* no error notices */ |
3058 | case XTerm_dumpscreen: /* no error notices */ |
3113 | { |
3059 | { |
3114 | int fd; |
3060 | int fd; |
3115 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3061 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
… | |
… | |
3243 | */ |
3189 | */ |
3244 | PrivMode (1, PrivMode_vt52); |
3190 | PrivMode (1, PrivMode_vt52); |
3245 | break; |
3191 | break; |
3246 | case 3: /* 80/132 */ |
3192 | case 3: /* 80/132 */ |
3247 | if (PrivateModes & PrivMode_132OK) |
3193 | if (PrivateModes & PrivMode_132OK) |
3248 | set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth), |
3194 | set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); |
3249 | (unsigned int)TermWin.height); |
|
|
3250 | break; |
3195 | break; |
3251 | case 4: /* smooth scrolling */ |
3196 | case 4: /* smooth scrolling */ |
3252 | if (state) |
3197 | if (state) |
3253 | Options &= ~Opt_jumpScroll; |
3198 | Options &= ~Opt_jumpScroll; |
3254 | else |
3199 | else |