… | |
… | |
291 | ^ !!ctrl) ? '\b' : '\177'; |
291 | ^ !!ctrl) ? '\b' : '\177'; |
292 | kbuf[1] = '\0'; |
292 | kbuf[1] = '\0'; |
293 | } |
293 | } |
294 | else |
294 | else |
295 | STRCPY (kbuf, key_backspace); |
295 | 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; |
296 | break; |
309 | #endif |
297 | #endif |
310 | #ifndef NO_DELETE_KEY |
298 | #ifndef NO_DELETE_KEY |
311 | case XK_Delete: |
299 | case XK_Delete: |
312 | STRCPY (kbuf, key_delete); |
300 | 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; |
301 | break; |
326 | #endif |
302 | #endif |
327 | case XK_Tab: |
303 | case XK_Tab: |
328 | if (shft) |
304 | if (shft) |
329 | STRCPY (kbuf, "\033[Z"); |
305 | STRCPY (kbuf, "\033[Z"); |
… | |
… | |
371 | kbuf[1] = 'O'; |
347 | kbuf[1] = 'O'; |
372 | kbuf[2] = "dacb"[keysym - XK_Left]; |
348 | kbuf[2] = "dacb"[keysym - XK_Left]; |
373 | } |
349 | } |
374 | else if (PrivateModes & PrivMode_aplCUR) |
350 | else if (PrivateModes & PrivMode_aplCUR) |
375 | kbuf[1] = 'O'; |
351 | 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; |
352 | break; |
412 | |
353 | |
413 | #ifndef UNSHIFTED_SCROLLKEYS |
354 | #ifndef UNSHIFTED_SCROLLKEYS |
414 | # ifdef XK_KP_Prior |
355 | # ifdef XK_KP_Prior |
415 | case XK_KP_Prior: |
356 | case XK_KP_Prior: |
… | |
… | |
942 | uint32_t |
883 | uint32_t |
943 | rxvt_term::next_char () |
884 | rxvt_term::next_char () |
944 | { |
885 | { |
945 | while (cmdbuf_ptr < cmdbuf_endp) |
886 | while (cmdbuf_ptr < cmdbuf_endp) |
946 | { |
887 | { |
947 | if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh |
888 | // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh |
|
|
889 | if ((*cmdbuf_ptr <= 0x7f && 0x20 <= *cmdbuf_ptr) |
|
|
890 | || !*cmdbuf_ptr) |
948 | return *cmdbuf_ptr++; |
891 | return *cmdbuf_ptr++; |
949 | |
892 | |
950 | wchar_t wc; |
893 | wchar_t wc; |
951 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
894 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
952 | |
895 | |
953 | if (len == (size_t)-2) |
896 | if (len == (size_t)-2) |
954 | return NOCHAR; |
897 | { |
|
|
898 | // the mbstate stores incomplete sequences. didn't know this :/ |
|
|
899 | cmdbuf_ptr = cmdbuf_endp; |
|
|
900 | break; |
|
|
901 | } |
955 | |
902 | |
956 | if (len == (size_t)-1) |
903 | if (len == (size_t)-1) |
957 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
904 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
958 | |
905 | |
959 | // assume wchar == unicode |
906 | // assume wchar == unicode |
… | |
… | |
1987 | if (have_pixmap) |
1934 | if (have_pixmap) |
1988 | { |
1935 | { |
1989 | /* |
1936 | /* |
1990 | * Copy display->root pixmap transparency |
1937 | * Copy display->root pixmap transparency |
1991 | */ |
1938 | */ |
1992 | int sx, sy, nx, ny; |
1939 | int sx, sy, nx, ny; |
1993 | unsigned int nw, nh; |
1940 | unsigned int nw, nh; |
1994 | Window cr; |
1941 | Window cr; |
1995 | XImage *image; |
1942 | XImage *image; |
1996 | GC gc; |
1943 | GC gc; |
1997 | XGCValues gcvalue; |
1944 | XGCValues gcvalue; |
1998 | |
1945 | |
1999 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
1946 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
2000 | 0, 0, &sx, &sy, &cr); |
1947 | 0, 0, &sx, &sy, &cr); |
2001 | nw = (unsigned int)szHint.width; |
1948 | nw = (unsigned int)szHint.width; |
2002 | nh = (unsigned int)szHint.height; |
1949 | nh = (unsigned int)szHint.height; |
2003 | nx = ny = 0; |
1950 | nx = ny = 0; |
|
|
1951 | |
2004 | if (sx < 0) |
1952 | if (sx < 0) |
2005 | { |
1953 | { |
2006 | nw += sx; |
1954 | nw += sx; |
2007 | nx = -sx; |
1955 | nx = -sx; |
2008 | sx = 0; |
1956 | sx = 0; |
2009 | } |
1957 | } |
|
|
1958 | |
2010 | if (sy < 0) |
1959 | if (sy < 0) |
2011 | { |
1960 | { |
2012 | nh += sy; |
1961 | nh += sy; |
2013 | ny = -sy; |
1962 | ny = -sy; |
2014 | sy = 0; |
1963 | sy = 0; |
2015 | } |
1964 | } |
|
|
1965 | |
2016 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
1966 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2017 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
1967 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2018 | allowedxerror = -1; |
1968 | allowedxerror = -1; |
2019 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
1969 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
2020 | ZPixmap); |
1970 | ZPixmap); |
… | |
… | |
2053 | if (!am_transparent || !am_pixmap_trans) |
2003 | if (!am_transparent || !am_pixmap_trans) |
2054 | pchanged = 1; |
2004 | pchanged = 1; |
2055 | am_transparent = am_pixmap_trans = 1; |
2005 | am_transparent = am_pixmap_trans = 1; |
2056 | } |
2006 | } |
2057 | } |
2007 | } |
|
|
2008 | |
2058 | if (!am_pixmap_trans) |
2009 | if (!am_pixmap_trans) |
2059 | { |
2010 | { |
2060 | unsigned int n; |
2011 | unsigned int n; |
2061 | /* |
2012 | /* |
2062 | * InheritPixmap transparency |
2013 | * InheritPixmap transparency |
… | |
… | |
2077 | break; |
2028 | break; |
2078 | } |
2029 | } |
2079 | if (oldp != TermWin.parent[i]) |
2030 | if (oldp != TermWin.parent[i]) |
2080 | pchanged = 1; |
2031 | pchanged = 1; |
2081 | } |
2032 | } |
|
|
2033 | |
2082 | n = 0; |
2034 | n = 0; |
|
|
2035 | |
2083 | if (pchanged) |
2036 | if (pchanged) |
2084 | { |
2037 | { |
2085 | for (; n < (unsigned int)i; n++) |
2038 | for (; n < (unsigned int)i; n++) |
2086 | { |
2039 | { |
2087 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
2040 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
… | |
… | |
2091 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2044 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2092 | break; |
2045 | break; |
2093 | } |
2046 | } |
2094 | } |
2047 | } |
2095 | } |
2048 | } |
|
|
2049 | |
2096 | if (n > (int) (sizeof (TermWin.parent) |
2050 | if (n > (int) (sizeof (TermWin.parent) |
2097 | / sizeof (TermWin.parent[0]))) |
2051 | / sizeof (TermWin.parent[0]))) |
2098 | { |
2052 | { |
2099 | D_X ((stderr, "InheritPixmap Turning off")); |
2053 | D_X ((stderr, "InheritPixmap Turning off")); |
2100 | XSetWindowBackground (display->display, TermWin.parent[0], |
2054 | XSetWindowBackground (display->display, TermWin.parent[0], |
… | |
… | |
2123 | ParentRelative); |
2077 | ParentRelative); |
2124 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2078 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2125 | ParentRelative); |
2079 | ParentRelative); |
2126 | am_transparent = 1; |
2080 | am_transparent = 1; |
2127 | } |
2081 | } |
|
|
2082 | |
2128 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2083 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2129 | TermWin.parent[i] = None; |
2084 | TermWin.parent[i] = None; |
2130 | } |
2085 | } |
2131 | return pchanged; |
2086 | return pchanged; |
2132 | } |
2087 | } |
… | |
… | |
2138 | /*----------------------------------------------------------------------*/ |
2093 | /*----------------------------------------------------------------------*/ |
2139 | #ifdef PRINTPIPE |
2094 | #ifdef PRINTPIPE |
2140 | FILE * |
2095 | FILE * |
2141 | rxvt_term::popen_printer () |
2096 | rxvt_term::popen_printer () |
2142 | { |
2097 | { |
2143 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2098 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2144 | |
2099 | |
2145 | if (stream == NULL) |
2100 | if (stream == NULL) |
2146 | rxvt_print_error ("can't open printer pipe"); |
2101 | rxvt_print_error ("can't open printer pipe"); |
2147 | return stream; |
2102 | return stream; |
2148 | } |
2103 | } |
… | |
… | |
2360 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2315 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2361 | break; |
2316 | break; |
2362 | case '+': |
2317 | case '+': |
2363 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2318 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2364 | break; |
2319 | break; |
2365 | #ifdef MULTICHAR_SET |
|
|
2366 | case '$': |
|
|
2367 | scr_charset_set (-2, (unsigned int)cmd_getc ()); |
|
|
2368 | break; |
|
|
2369 | #endif |
|
|
2370 | #ifndef NO_FRILLS |
2320 | #ifndef NO_FRILLS |
2371 | case '6': |
2321 | case '6': |
2372 | scr_backindex (); |
2322 | scr_backindex (); |
2373 | break; |
2323 | break; |
2374 | #endif |
2324 | #endif |
… | |
… | |
2715 | case 7: /* unofficial extension */ |
2665 | case 7: /* unofficial extension */ |
2716 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2666 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2717 | break; |
2667 | break; |
2718 | #endif |
2668 | #endif |
2719 | case 8: /* unofficial extension */ |
2669 | case 8: /* unofficial extension */ |
2720 | xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); |
2670 | xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
2721 | break; |
2671 | break; |
2722 | } |
2672 | } |
2723 | break; |
2673 | break; |
2724 | |
2674 | |
2725 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
2675 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
… | |
… | |
2994 | * 19 = change underlined character color |
2944 | * 19 = change underlined character color |
2995 | * 46 = change logfile (not implemented) |
2945 | * 46 = change logfile (not implemented) |
2996 | * 50 = change font |
2946 | * 50 = change font |
2997 | * |
2947 | * |
2998 | * rxvt extensions: |
2948 | * rxvt extensions: |
2999 | * 9 = change locale (NYI) |
|
|
3000 | * 10 = menu (may change in future) |
2949 | * 10 = menu (may change in future) |
3001 | * 20 = bg pixmap |
2950 | * 20 = bg pixmap |
3002 | * 39 = change default fg color |
2951 | * 39 = change default fg color |
3003 | * 49 = change default bg color |
2952 | * 49 = change default bg color |
3004 | * 55 = dump scrollback buffer and all of screen |
2953 | * 55 = dump scrollback buffer and all of screen |
|
|
2954 | * 701 = change locale |
|
|
2955 | * 702 = find font |
3005 | */ |
2956 | */ |
3006 | void |
2957 | void |
3007 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
2958 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
3008 | { |
2959 | { |
3009 | int changed = 0; |
2960 | int changed = 0; |
… | |
… | |
3097 | case XTerm_logfile: |
3048 | case XTerm_logfile: |
3098 | break; |
3049 | break; |
3099 | case XTerm_font: |
3050 | case XTerm_font: |
3100 | change_font (str); |
3051 | change_font (str); |
3101 | break; |
3052 | break; |
|
|
3053 | #ifndef NO_FRILLS |
3102 | case XTerm_locale: |
3054 | case XTerm_locale: |
3103 | if (str[0] == '?' && !str[1]) |
3055 | if (str[0] == '?' && !str[1]) |
3104 | tt_printf ("%-.250s\n", locale); |
3056 | tt_printf ("%-.250s\n", locale); |
3105 | else |
3057 | else |
3106 | { |
3058 | { |
3107 | set_locale (str); |
3059 | set_locale (str); |
|
|
3060 | # ifdef USE_XIM |
3108 | im_cb (); |
3061 | im_cb (); |
3109 | |
3062 | # endif |
3110 | // TODO: call selection_make with the right values set |
|
|
3111 | // to re-fresh the selection. |
|
|
3112 | if (display->selection_owner == this) |
|
|
3113 | display->set_selection_owner (0); |
|
|
3114 | } |
3063 | } |
3115 | break; |
3064 | break; |
|
|
3065 | case XTerm_findfont: |
|
|
3066 | { |
|
|
3067 | int fid = TermWin.fontset->find_font (atoi (str)); |
|
|
3068 | tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name); |
|
|
3069 | } |
|
|
3070 | break; |
|
|
3071 | #endif |
3116 | #if 0 |
3072 | #if 0 |
3117 | case XTerm_dumpscreen: /* no error notices */ |
3073 | case XTerm_dumpscreen: /* no error notices */ |
3118 | { |
3074 | { |
3119 | int fd; |
3075 | int fd; |
3120 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3076 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
… | |
… | |
3248 | */ |
3204 | */ |
3249 | PrivMode (1, PrivMode_vt52); |
3205 | PrivMode (1, PrivMode_vt52); |
3250 | break; |
3206 | break; |
3251 | case 3: /* 80/132 */ |
3207 | case 3: /* 80/132 */ |
3252 | if (PrivateModes & PrivMode_132OK) |
3208 | if (PrivateModes & PrivMode_132OK) |
3253 | set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth), |
3209 | set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); |
3254 | (unsigned int)TermWin.height); |
|
|
3255 | break; |
3210 | break; |
3256 | case 4: /* smooth scrolling */ |
3211 | case 4: /* smooth scrolling */ |
3257 | if (state) |
3212 | if (state) |
3258 | Options &= ~Opt_jumpScroll; |
3213 | Options &= ~Opt_jumpScroll; |
3259 | else |
3214 | else |