--- rxvt-unicode/src/command.C 2004/02/10 00:40:39 1.41 +++ rxvt-unicode/src/command.C 2004/03/15 00:08:11 1.73 @@ -27,6 +27,7 @@ * Copyright (c) 2001 Marius Gedminas * - Ctrl/Mod4+Tab works like Meta+Tab (options) * Copyright (c) 2003 Rob McMullen + * Copyright (c) 2003-2004 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,13 +58,13 @@ void rxvt_term::lookup_key (XKeyEvent &ev) { - int ctrl, meta, shft, len; - unsigned int newlen; - KeySym keysym; + int ctrl, meta, shft, len; + unsigned int newlen; + KeySym keysym; #ifdef DEBUG_CMD - static int debug_key = 1; /* accessible by a debugger only */ + static int debug_key = 1; /* accessible by a debugger only */ #endif - int valid_keysym; + int valid_keysym; unsigned char kbuf[KBUFSZ]; /* @@ -79,7 +80,7 @@ if (numlock_state || (ev.state & ModNumLockMask)) { numlock_state = (ev.state & ModNumLockMask); - PrivMode((!numlock_state), PrivMode_aplKP); + PrivMode ((!numlock_state), PrivMode_aplKP); } kbuf[0] = 0; @@ -90,12 +91,11 @@ Status status_return; #ifdef X_HAVE_UTF8_STRING - if (enc_utf8 && 0) + if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, KBUFSZ, &keysym, &status_return); else #endif - { wchar_t wkbuf[KBUFSZ + 1]; @@ -110,51 +110,38 @@ SET_LOCALE (locale); if (status_return == XLookupChars - || status_return == XLookupBoth) + || status_return == XLookupBoth) { - wkbuf[len] = 0; - len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); - if (len < 0) - len = 0; + /* make sure the user can type ctrl-@, i.e. NUL */ + if (len == 1 && *wkbuf == 0) + { + kbuf[0] = 0; + len = 1; + } + else + { + wkbuf[len] = 0; + len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); + if (len < 0) + len = 0; + } } else len = 0; } valid_keysym = status_return == XLookupKeySym - || status_return == XLookupBoth; + || status_return == XLookupBoth; } else #endif - { len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); - valid_keysym = !len; + valid_keysym = keysym != NoSymbol; } if (valid_keysym) { - /* for some backwards compatibility */ -#if defined(HOTKEY_CTRL) || defined(HOTKEY_META) -# ifdef HOTKEY_CTRL - if (ctrl) -# else - if (meta) -# endif - { - if (keysym == ks_bigfont) - { - change_font (0, FONT_UP); - return; - } - else if (keysym == ks_smallfont) - { - change_font (0, FONT_DN); - return; - } - } -#endif - if (TermWin.saveLines) { #ifdef UNSHIFTED_SCROLLKEYS @@ -164,7 +151,7 @@ if (IS_SCROLL_MOD) { #endif - int lnsppg; + int lnsppg; #ifdef PAGING_CONTEXT_LINES lnsppg = TermWin.nrow - PAGING_CONTEXT_LINES; @@ -212,7 +199,6 @@ } } #endif - } if (shft) @@ -233,10 +219,10 @@ return; /* rxvt extras */ case XK_KP_Add: /* Shift+KP_Add = bigger font */ - change_font (0, FONT_UP); + change_font (FONT_UP); return; case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ - change_font (0, FONT_DN); + change_font (FONT_DN); return; } } @@ -248,47 +234,34 @@ return; } #endif -#ifdef GREEK_SUPPORT - if (keysym == ks_greekmodeswith) - { - greek_mode = !greek_mode; - if (greek_mode) - { - xterm_seq (XTerm_title, - (greek_getmode() == GREEK_ELOT928 - ? "[Greek: iso]" : "[Greek: ibm]"), CHAR_ST); - greek_reset(); - } - else - xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); - return; - } -#endif if (keysym >= 0xFF00 && keysym <= 0xFFFF) { #ifdef KEYSYM_RESOURCE - if (!(shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) + if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) { unsigned int l; const unsigned char *kbuf0; - const unsigned char ch = C0_ESC; kbuf0 = (Keysym_map[keysym & 0xFF]); l = (unsigned int)*kbuf0++; /* escape prefix */ - if (meta) + if (meta # ifdef META8_OPTION - if (meta_char == C0_ESC) + && meta_char == C0_ESC # endif + ) + { + const unsigned char ch = C0_ESC; tt_write (&ch, 1); + } + tt_write (kbuf0, l); return; } else #endif - { newlen = 1; switch (keysym) @@ -297,46 +270,22 @@ case XK_BackSpace: if (PrivateModes & PrivMode_HaveBackSpace) { - kbuf[0] = (!!(PrivateModes & PrivMode_BackSpace) + kbuf[0] = (!! (PrivateModes & PrivMode_BackSpace) ^ !!ctrl) ? '\b' : '\177'; kbuf[1] = '\0'; } else - STRCPY(kbuf, key_backspace); -# ifdef MULTICHAR_SET - if ((Options & Opt_mc_hack) && screen.cur.col > 0) - { - int col, row; - - newlen = STRLEN(kbuf); - col = screen.cur.col - 1; - row = screen.cur.row + TermWin.saveLines; - if (IS_MULTI2(screen.rend[row][col])) - MEMMOVE(kbuf + newlen, kbuf, newlen + 1); - } -# endif + STRCPY (kbuf, key_backspace); break; #endif #ifndef NO_DELETE_KEY case XK_Delete: - STRCPY(kbuf, key_delete); -# ifdef MULTICHAR_SET - if (Options & Opt_mc_hack) - { - int col, row; - - newlen = STRLEN(kbuf); - col = screen.cur.col; - row = screen.cur.row + TermWin.saveLines; - if (IS_MULTI1(screen.rend[row][col])) - MEMMOVE(kbuf + newlen, kbuf, newlen + 1); - } -# endif + STRCPY (kbuf, key_delete); break; #endif case XK_Tab: if (shft) - STRCPY(kbuf, "\033[Z"); + STRCPY (kbuf, "\033[Z"); else { #ifdef CTRL_TAB_MAKES_META @@ -351,7 +300,6 @@ } break; - #ifdef XK_KP_Left case XK_KP_Up: /* \033Ox or standard */ case XK_KP_Down: /* \033Or or standard */ @@ -359,8 +307,8 @@ case XK_KP_Left: /* \033Ot or standard */ if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - STRCPY(kbuf, "\033OZ"); - kbuf[2] = ("txvr"[keysym - XK_KP_Left]); + STRCPY (kbuf, "\033OZ"); + kbuf[2] = "txvr"[keysym - XK_KP_Left]; break; } else @@ -372,53 +320,18 @@ case XK_Down: /* "\033[B" */ case XK_Right: /* "\033[C" */ case XK_Left: /* "\033[D" */ - STRCPY(kbuf, "\033[Z"); - kbuf[2] = ("DACB"[keysym - XK_Left]); + STRCPY (kbuf, "\033[Z"); + kbuf[2] = "DACB"[keysym - XK_Left]; /* do Shift first */ if (shft) - kbuf[2] = ("dacb"[keysym - XK_Left]); + kbuf[2] = "dacb"[keysym - XK_Left]; else if (ctrl) { kbuf[1] = 'O'; - kbuf[2] = ("dacb"[keysym - XK_Left]); + kbuf[2] = "dacb"[keysym - XK_Left]; } else if (PrivateModes & PrivMode_aplCUR) kbuf[1] = 'O'; -#ifdef MULTICHAR_SET - //TODO: ?? - if (Options & Opt_mc_hack) - { - int col, row, m; - - col = screen.cur.col; - row = screen.cur.row + TermWin.saveLines; - m = 0; - if (keysym == XK_Right - && IS_MULTI1(screen.rend[row][col])) - m = 1; - else if (keysym == XK_Left) - { - if (col > 0) - { - if (IS_MULTI2(screen.rend[row][col - 1])) - m = 1; - } - else if (screen.cur.row > 0) - { - col = screen.tlen[--row]; - if (col == -1) - col = TermWin.ncol - 1; - else - col--; - if (col > 0 - && IS_MULTI2(screen.rend[row][col])) - m = 1; - } - } - if (m) - MEMMOVE(kbuf + 3, kbuf, 3 + 1); - } -#endif break; #ifndef UNSHIFTED_SCROLLKEYS @@ -427,33 +340,33 @@ /* allow shift to override */ if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - STRCPY(kbuf, "\033Oy"); + STRCPY (kbuf, "\033Oy"); break; } /* FALLTHROUGH */ # endif case XK_Prior: - STRCPY(kbuf, "\033[5~"); + STRCPY (kbuf, "\033[5~"); break; # ifdef XK_KP_Next case XK_KP_Next: /* allow shift to override */ if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - STRCPY(kbuf, "\033Os"); + STRCPY (kbuf, "\033Os"); break; } /* FALLTHROUGH */ # endif case XK_Next: - STRCPY(kbuf, "\033[6~"); + STRCPY (kbuf, "\033[6~"); break; #endif case XK_KP_Enter: /* allow shift to override */ if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - STRCPY(kbuf, "\033OM"); + STRCPY (kbuf, "\033OM"); } else { @@ -464,27 +377,27 @@ #ifdef XK_KP_Begin case XK_KP_Begin: - STRCPY(kbuf, "\033Ou"); + STRCPY (kbuf, "\033Ou"); break; case XK_KP_Insert: - STRCPY(kbuf, "\033Op"); + STRCPY (kbuf, "\033Op"); break; case XK_KP_Delete: - STRCPY(kbuf, "\033On"); + STRCPY (kbuf, "\033On"); break; #endif case XK_KP_F1: /* "\033OP" */ case XK_KP_F2: /* "\033OQ" */ case XK_KP_F3: /* "\033OR" */ case XK_KP_F4: /* "\033OS" */ - STRCPY(kbuf, "\033OP"); + STRCPY (kbuf, "\033OP"); kbuf[2] += (keysym - XK_KP_F1); break; case XK_KP_Multiply: /* "\033Oj" : "*" */ - case XK_KP_Add: /* "\033Ok" : "+" */ + case XK_KP_Add: /* "\033Ok" : "+" */ case XK_KP_Separator: /* "\033Ol" : "," */ case XK_KP_Subtract: /* "\033Om" : "-" */ case XK_KP_Decimal: /* "\033On" : "." */ @@ -502,7 +415,7 @@ /* allow shift to override */ if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - STRCPY(kbuf, "\033Oj"); + STRCPY (kbuf, "\033Oj"); kbuf[2] += (keysym - XK_KP_Multiply); } else @@ -513,80 +426,80 @@ break; case XK_Find: - STRCPY(kbuf, "\033[1~"); + STRCPY (kbuf, "\033[1~"); break; case XK_Insert: - STRCPY(kbuf, "\033[2~"); + STRCPY (kbuf, "\033[2~"); break; #ifdef DXK_Remove /* support for DEC remove like key */ case DXK_Remove: /* FALLTHROUGH */ #endif case XK_Execute: - STRCPY(kbuf, "\033[3~"); + STRCPY (kbuf, "\033[3~"); break; case XK_Select: - STRCPY(kbuf, "\033[4~"); + STRCPY (kbuf, "\033[4~"); break; #ifdef XK_KP_End case XK_KP_End: /* allow shift to override */ if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - STRCPY(kbuf, "\033Oq"); + STRCPY (kbuf, "\033Oq"); break; } /* FALLTHROUGH */ #endif case XK_End: - STRCPY(kbuf, KS_END); + STRCPY (kbuf, KS_END); break; #ifdef XK_KP_Home case XK_KP_Home: /* allow shift to override */ if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - STRCPY(kbuf, "\033Ow"); + STRCPY (kbuf, "\033Ow"); break; } /* FALLTHROUGH */ #endif case XK_Home: - STRCPY(kbuf, KS_HOME); + STRCPY (kbuf, KS_HOME); break; #define FKEY(n, fkey) \ - sprintf((char *)kbuf,"\033[%2d~", (int)((n) + (keysym - fkey))) + sprintf ((char *)kbuf,"\033[%2d~", (int) ((n) + (keysym - fkey))) case XK_F1: /* "\033[11~" */ case XK_F2: /* "\033[12~" */ case XK_F3: /* "\033[13~" */ case XK_F4: /* "\033[14~" */ case XK_F5: /* "\033[15~" */ - FKEY(11, XK_F1); + FKEY (11, XK_F1); break; case XK_F6: /* "\033[17~" */ case XK_F7: /* "\033[18~" */ case XK_F8: /* "\033[19~" */ case XK_F9: /* "\033[20~" */ case XK_F10: /* "\033[21~" */ - FKEY(17, XK_F6); + FKEY (17, XK_F6); break; case XK_F11: /* "\033[23~" */ case XK_F12: /* "\033[24~" */ case XK_F13: /* "\033[25~" */ case XK_F14: /* "\033[26~" */ - FKEY(23, XK_F11); + FKEY (23, XK_F11); break; case XK_F15: /* "\033[28~" */ case XK_F16: /* "\033[29~" */ - FKEY(28, XK_F15); + FKEY (28, XK_F15); break; case XK_Help: /* "\033[28~" */ - FKEY(28, XK_Help); + FKEY (28, XK_Help); break; case XK_Menu: /* "\033[29~" */ - FKEY(29, XK_Menu); + FKEY (29, XK_Menu); break; case XK_F17: /* "\033[31~" */ case XK_F18: /* "\033[32~" */ @@ -607,7 +520,7 @@ case XK_F33: /* "\033[47~" */ case XK_F34: /* "\033[48~" */ case XK_F35: /* "\033[49~" */ - FKEY(31, XK_F17); + FKEY (31, XK_F17); break; #undef FKEY default: @@ -615,8 +528,9 @@ break; } if (newlen) - len = STRLEN(kbuf); + len = STRLEN (kbuf); } + /* * Pass meta for all function keys, if 'meta' option set */ @@ -641,13 +555,10 @@ for (ch = kbuf; ch < kbuf + len; ch++) *ch |= 0x80; + meta = 0; } #endif -#ifdef GREEK_SUPPORT - if (greek_mode) - len = greek_xlat(kbuf, len); -#endif /* nil */ ; } } @@ -679,32 +590,30 @@ /* escape prefix */ if (meta #ifdef META8_OPTION - && (meta_char == C0_ESC) + && meta_char == C0_ESC #endif ) { const unsigned char ch = C0_ESC; - - tt_write(&ch, 1); - } -#ifdef DEBUG_CMD - if (debug_key) - { /* Display keyboard buffer contents */ - char *p; - int i; - - fprintf(stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); - for (i = 0, p = kbuf; i < len; i++, p++) - fprintf(stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); - fprintf(stderr, "'\n"); + tt_write (&ch, 1); } + +#if defined(DEBUG_CMD) + /* Display keyboard buffer contents */ + unsigned char *p; + int i; + + fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); + for (i = 0, p = kbuf; i < len; i++, p++) + fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); + fprintf (stderr, "'\n"); #endif /* DEBUG_CMD */ tt_write (kbuf, (unsigned int)len); } /*}}} */ #if (MENUBAR_MAX) -/*{{{ rxvt_cmd_write(), rxvt_cmd_getc() */ +/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ /* attempt to `write' count to the input buffer */ unsigned int rxvt_term::cmd_write (const unsigned char *str, unsigned int count) @@ -713,21 +622,27 @@ n = cmdbuf_ptr - cmdbuf_base; s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; + if (n > 0 && s < count) { - MEMMOVE(cmdbuf_base, cmdbuf_ptr, - (unsigned int)(cmdbuf_endp - cmdbuf_ptr)); + MEMMOVE (cmdbuf_base, cmdbuf_ptr, + (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); cmdbuf_ptr = cmdbuf_base; cmdbuf_endp -= n; s += n; } + if (count > s) { - rxvt_print_error("data loss: cmd_write too large"); + rxvt_print_error ("data loss: cmd_write too large"); count = s; } + for (; count--;) *cmdbuf_endp++ = *str++; + + cmd_parse (); + return 0; } #endif /* MENUBAR_MAX */ @@ -755,7 +670,7 @@ } - XFlush (display->display); + display->flush (); } void @@ -809,7 +724,7 @@ } else if (n < 0 && errno != EAGAIN) destroy (); - + return false; } @@ -836,123 +751,139 @@ tt_winch (); } - uint32_t ch = NOCHAR; + if (cmd_parse ()) + break; + } + } +} + +bool +rxvt_term::cmd_parse () +{ + bool flag = false; + unicode_t ch = NOCHAR; + + for (;;) + { + if (ch == NOCHAR) + ch = next_char (); + + if (ch == NOCHAR) // TODO: improve + break; + + if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') + { + /* Read a text string from the input buffer */ + unicode_t buf[BUFSIZ]; + bool refreshnow = false; + int nlines = 0; + unicode_t *str = buf; + + *str++ = ch; for (;;) { - if (ch == NOCHAR) - ch = next_char (); + ch = next_char (); - if (ch == NOCHAR) // TODO: improve + if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) break; - - if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') + else { - /* Read a text string from the input buffer */ - uint32_t buf[BUFSIZ]; - bool refreshnow = false; - int nlines = 0; - uint32_t *str = buf; - *str++ = ch; - for (;;) + if (ch == '\n') { - ch = next_char (); + nlines++; + refresh_count++; - if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) - break; - else + if (! (Options & Opt_jumpScroll) + || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) { - *str++ = ch; + refreshnow = true; + flag = false; + ch = NOCHAR; + break; + } - if (ch == '\n') - { - nlines++; - refresh_count++; - - if (!(Options & Opt_jumpScroll) - || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) - { - refreshnow = true; - flag = false; - ch = NOCHAR; - break; - } - - // scr_add_lines only works for nlines < TermWin.nrow - 1. - if (nlines >= TermWin.nrow - 1) - { - scr_add_lines (buf, nlines, str - buf); - nlines = 0; - str = buf; - } - } - - if (str >= buf + BUFSIZ) - { - ch = NOCHAR; - break; - } + // scr_add_lines only works for nlines < TermWin.nrow - 1. + if (nlines >= TermWin.nrow - 1) + { + scr_add_lines (buf, nlines, str - buf); + nlines = 0; + str = buf; } } - scr_add_lines (buf, nlines, str - buf); - - /* - * If there have been a lot of new lines, then update the screen - * What the heck I'll cheat and only refresh less than every page-full. - * the number of pages between refreshes is refresh_limit, which - * is incremented here because we must be doing flat-out scrolling. - * - * refreshing should be correct for small scrolls, because of the - * time-out - */ - if (refreshnow) + if (str >= buf + BUFSIZ) { - if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) - refresh_limit++; - - scr_refresh (refresh_type); + ch = NOCHAR; + break; } - } - else - { - switch (ch) - { - default: - process_nonprinting (ch); - break; - case C0_ESC: /* escape char */ - process_escape_seq (); - break; - /*case 0x9b: */ /* CSI */ - /* process_csi_seq (); */ - } + } - ch = NOCHAR; - } + scr_add_lines (buf, nlines, str - buf); + + /* + * If there have been a lot of new lines, then update the screen + * What the heck I'll cheat and only refresh less than every page-full. + * the number of pages between refreshes is refresh_limit, which + * is incremented here because we must be doing flat-out scrolling. + * + * refreshing should be correct for small scrolls, because of the + * time-out + */ + if (refreshnow) + { + if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) + refresh_limit++; + + scr_refresh (refresh_type); + } + + } + else + { + switch (ch) + { + default: + process_nonprinting (ch); + break; + case C0_ESC: /* escape char */ + process_escape_seq (); + break; + /*case 0x9b: */ /* CSI */ + /* process_csi_seq (); */ } + + ch = NOCHAR; } } + + return flag; } // read the next character, currently handles UTF-8 // will probably handle all sorts of other stuff in the future -uint32_t +unicode_t rxvt_term::next_char () { while (cmdbuf_ptr < cmdbuf_endp) { - if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh + // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh + if ((*cmdbuf_ptr <= 0x7f && 0x20 <= *cmdbuf_ptr) + || !*cmdbuf_ptr) return *cmdbuf_ptr++; wchar_t wc; - size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, &mbstate.mbs); + size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); if (len == (size_t)-2) - return NOCHAR; + { + // the mbstate stores incomplete sequences. didn't know this :/ + cmdbuf_ptr = cmdbuf_endp; + break; + } if (len == (size_t)-1) return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through @@ -965,17 +896,17 @@ return NOCHAR; } -/* rxvt_cmd_getc() - Return next input character */ +/* rxvt_cmd_getc () - Return next input character */ /* * Return the next input character after first passing any keyboard input * to the command. */ -uint32_t +unicode_t rxvt_term::cmd_getc () { for (;;) { - uint32_t c = next_char (); + unicode_t c = next_char (); if (c != NOCHAR) return c; @@ -1003,7 +934,7 @@ void rxvt_term::pointer_blank () { - if (!(Options & Opt_pointerBlank)) + if (! (Options & Opt_pointerBlank)) return; XDefineCursor (display->display, TermWin.vt, blank_cursor); @@ -1023,10 +954,10 @@ #endif void -rxvt_term::mouse_report (const XButtonEvent &ev) +rxvt_term::mouse_report (XButtonEvent &ev) { - int button_number, key_state = 0; - int x, y; + int button_number, key_state = 0; + int x, y; x = ev.x; y = ev.y; @@ -1073,21 +1004,21 @@ } #ifdef DEBUG_MOUSEREPORT - fprintf(stderr, "Mouse ["); + fprintf (stderr, "Mouse ["); if (key_state & 16) - fputc('C', stderr); + fputc ('C', stderr); if (key_state & 4) - fputc('S', stderr); + fputc ('S', stderr); if (key_state & 8) - fputc('A', stderr); + fputc ('A', stderr); if (key_state & 32) - fputc('2', stderr); - fprintf(stderr, "]: <%d>, %d/%d\n", + fputc ('2', stderr); + fprintf (stderr, "]: <%d>, %d/%d\n", button_number, x + 1, y + 1); #else - tt_printf("\033[M%c%c%c", + tt_printf ("\033[M%c%c%c", (32 + button_number + key_state), (32 + x + 1), (32 + y + 1)); @@ -1096,9 +1027,9 @@ #ifdef USING_W11LIB void -rxvt_W11_process_x_event(XEvent *ev) +rxvt_W11_process_x_event (XEvent *ev) { - rxvt_t *r = rxvt_get_r(); + rxvt_t *r = rxvt_get_r (); x_cb (*ev); } @@ -1191,9 +1122,9 @@ #ifdef DEBUG_X struct timeval tp; struct tm *ltt; - (void)gettimeofday(&tp, NULL); - ltt = localtime(&(tp.tv_sec)); - D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev.type], (ev.xany.window == TermWin.parent[0] ? "parent" : (ev.xany.window == TermWin.vt ? "vt" : (ev.xany.window == scrollBar.win ? "scroll" : (ev.xany.window == menuBar.win ? "menubar" : "UNKNOWN")))), (ev.xany.window == TermWin.parent[0] ? TermWin.parent[0] : (ev.xany.window == TermWin.vt ? TermWin.vt : (ev.xany.window == scrollBar.win ? scrollBar.win : (ev.xany.window == menuBar.win ? menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev.xany.send_event ? "S" : " ", ev.xany.serial)); + (void)gettimeofday (&tp, NULL); + ltt = localtime (& (tp.tv_sec)); + D_X ((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev.type], (ev.xany.window == TermWin.parent[0] ? "parent" : (ev.xany.window == TermWin.vt ? "vt" : (ev.xany.window == scrollBar.win ? "scroll" : (ev.xany.window == menuBar.win ? "menubar" : "UNKNOWN")))), (ev.xany.window == TermWin.parent[0] ? TermWin.parent[0] : (ev.xany.window == TermWin.vt ? TermWin.vt : (ev.xany.window == scrollBar.win ? scrollBar.win : (ev.xany.window == menuBar.win ? menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev.xany.send_event ? "S" : " ", ev.xany.serial)); #endif switch (ev.type) @@ -1205,13 +1136,13 @@ #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) case KeyRelease: { - if (!(ev.xkey.state & ControlMask)) + if (! (ev.xkey.state & ControlMask)) mouse_slip_wheel_speed = 0; else { KeySym ks; - ks = XKeycodeToKeysym(display->display, ev.xkey.keycode, 0); + ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0); if (ks == XK_Control_L || ks == XK_Control_R) mouse_slip_wheel_speed = 0; } @@ -1244,25 +1175,25 @@ unsigned char *data; unsigned long Size, RemainingBytes; - XGetWindowProperty(display->display, display->root, + XGetWindowProperty (display->display, display->root, xa[XA_DNDSELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType, &ActualFormat, &Size, &RemainingBytes, &data); - XChangeProperty(display->display, display->root, + XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, - data, STRLEN(data)); + data, STRLEN (data)); selection_paste (display->root, XA_CUT_BUFFER0, True); - XSetInputFocus(display->display, display->root, RevertToNone, CurrentTime); + XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); } #endif /* OFFIX_DND */ break; case MappingNotify: - XRefreshKeyboardMapping(&(ev.xmapping)); + XRefreshKeyboardMapping (& (ev.xmapping)); break; /* @@ -1297,7 +1228,7 @@ want_refresh = 1; #ifdef USE_XIM if (Input_Context != NULL) - XSetICFocus(Input_Context); + XSetICFocus (Input_Context); #endif #ifdef CURSOR_BLINK if (Options & Opt_cursorBlink) @@ -1314,7 +1245,7 @@ want_refresh = 1; #ifdef USE_XIM if (Input_Context != NULL) - XUnsetICFocus(Input_Context); + XUnsetICFocus (Input_Context); #endif #ifdef CURSOR_BLINK if (Options & Opt_cursorBlink) @@ -1334,19 +1265,19 @@ { /* Wrap lots of configures into one */ width = ev.xconfigure.width; height = ev.xconfigure.height; - D_SIZE((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); + D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); } - while (XCheckTypedWindowEvent(display->display, ev.xconfigure.window, ConfigureNotify, &ev)); + while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); if (szHint.width != width || szHint.height != height) { - D_SIZE((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height)); + D_SIZE ((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height)); resize_all_windows (width, height, 1); } #ifdef DEBUG_SIZE else { - D_SIZE((stderr, "Size: Not resizing")); + D_SIZE ((stderr, "Size: Not resizing")); } #endif #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ @@ -1415,25 +1346,21 @@ { XEvent unused_event; - while (XCheckTypedWindowEvent(display->display, ev.xany.window, + while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) ; - while (XCheckTypedWindowEvent(display->display, ev.xany.window, + while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) ; - if (isScrollbarWindow(ev.xany.window)) + if (isScrollbarWindow (ev.xany.window)) { - scrollBar.setIdle(); + scrollBar.setIdle (); scrollbar_show (0); } #ifdef MENUBAR - if (menubar_visible () && isMenuBarWindow(ev.xany.window)) + if (menubar_visible () && isMenuBarWindow (ev.xany.window)) menubar_expose (); #endif -#ifdef RXVT_GRAPHICS - Gr_expose (ev.xany.window); -#endif - } break; @@ -1443,13 +1370,13 @@ pointer_unblank (); #endif #if MENUBAR - if (isMenuBarWindow(ev.xany.window)) + if (isMenuBarWindow (ev.xany.window)) { - menubar_control (&(ev.xbutton)); + menubar_control (ev.xbutton); break; } #endif - if ((PrivateModes & PrivMode_mouse_report) && !(bypass_keystate)) + if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) break; if (ev.xany.window == TermWin.vt) @@ -1459,10 +1386,10 @@ while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev)) ; - XQueryPointer(display->display, TermWin.vt, + XQueryPointer (display->display, TermWin.vt, &unused_root, &unused_child, &unused_root_x, &unused_root_y, - &(ev.xbutton.x), &(ev.xbutton.y), + & (ev.xbutton.x), & (ev.xbutton.y), &unused_mask); #ifdef MOUSE_THRESHOLD /* deal with a `jumpy' mouse */ @@ -1473,7 +1400,7 @@ (ev.xbutton.state & Button3Mask) ? 2 : 0); #ifdef SELECTION_SCROLLING if (ev.xbutton.y < TermWin.int_bwidth - || Pixel2Row(ev.xbutton.y) > (TermWin.nrow-1)) + || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) { int dist; @@ -1505,9 +1432,9 @@ dist = ev.xbutton.y - (TermWin.int_bwidth + TermWin.height); } - scroll_selection_lines=(Pixel2Height(dist)/ + scroll_selection_lines= (Pixel2Height (dist)/ SELECTION_SCROLL_LINE_SPEEDUP)+1; - MIN_IT(scroll_selection_lines, + MIN_IT (scroll_selection_lines, SELECTION_SCROLL_MAX_LINES); } else @@ -1525,17 +1452,17 @@ } } - else if (isScrollbarWindow(ev.xany.window) && scrollbar_isMotion()) + else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) { - while (XCheckTypedWindowEvent(display->display, scrollBar.win, + while (XCheckTypedWindowEvent (display->display, scrollBar.win, MotionNotify, &ev)) ; - XQueryPointer(display->display, scrollBar.win, + XQueryPointer (display->display, scrollBar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, - &(ev.xbutton.x), &(ev.xbutton.y), + & (ev.xbutton.x), & (ev.xbutton.y), &unused_mask); - scr_move_to (scrollbar_position(ev.xbutton.y) - csrO, - scrollbar_size()); + scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, + scrollbar_size ()); scr_refresh (refresh_type); refresh_limit = 0; scrollbar_show (1); @@ -1567,7 +1494,7 @@ * use the property to determine the pixmap. We use it later on. */ if (xa[XA_XROOTPMAPID] == 0) - xa[XA_XROOTPMAPID] = XInternAtom(display->display, "_XROOTPMAP_ID", False); + xa[XA_XROOTPMAPID] = XInternAtom (display->display, "_XROOTPMAP_ID", False); if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) return; @@ -1584,106 +1511,98 @@ } void -rxvt_term::button_press (const XButtonEvent &ev) +rxvt_term::button_press (XButtonEvent &ev) { int reportmode = 0, clickintime; bypass_keystate = ev.state & (ModMetaMask | ShiftMask); if (!bypass_keystate) - reportmode = !!(PrivateModes & PrivMode_mouse_report); + reportmode = !! (PrivateModes & PrivMode_mouse_report); /* * VT window processing of button press */ if (ev.window == TermWin.vt) { -#if RXVT_GRAPHICS - if (ev.subwindow != None) - rxvt_Gr_ButtonPress (ev.x, ev.y); - else -#endif - + clickintime = ev.time - MEvent.time < MULTICLICK_TIME; + if (reportmode) { - clickintime = ev.time - MEvent.time < MULTICLICK_TIME; - if (reportmode) - { - /* mouse report from vt window */ - /* save the xbutton state (for ButtonRelease) */ - MEvent.state = ev.state; + /* mouse report from vt window */ + /* save the xbutton state (for ButtonRelease) */ + MEvent.state = ev.state; #ifdef MOUSE_REPORT_DOUBLECLICK - if (ev.button == MEvent.button && clickintime) - { - /* same button, within alloted time */ - MEvent.clicks++; - if (MEvent.clicks > 1) - { - /* only report double clicks */ - MEvent.clicks = 2; - mouse_report (ev); - - /* don't report the release */ - MEvent.clicks = 0; - MEvent.button = AnyButton; - } - } - else + if (ev.button == MEvent.button && clickintime) + { + /* same button, within alloted time */ + MEvent.clicks++; + if (MEvent.clicks > 1) { - /* different button, or time expired */ - MEvent.clicks = 1; - MEvent.button = ev.button; + /* only report double clicks */ + MEvent.clicks = 2; mouse_report (ev); + + /* don't report the release */ + MEvent.clicks = 0; + MEvent.button = AnyButton; } -#else + } + else + { + /* different button, or time expired */ + MEvent.clicks = 1; MEvent.button = ev.button; mouse_report (ev); + } +#else + MEvent.button = ev.button; + mouse_report (ev); #endif /* MOUSE_REPORT_DOUBLECLICK */ - } - else + } + else + { + if (ev.button != MEvent.button) + MEvent.clicks = 0; + switch (ev.button) { - if (ev.button != MEvent.button) - MEvent.clicks = 0; - switch (ev.button) - { - case Button1: - /* allow shift+left click to extend selection */ - if (ev.state & ShiftMask && !(PrivateModes & PrivMode_mouse_report)) - { - if (MEvent.button == Button1 && clickintime) - selection_rotate (ev.x, ev.y); - else - selection_extend (ev.x, ev.y, 1); - } + case Button1: + /* allow shift+left click to extend selection */ + if (ev.state & ShiftMask && ! (PrivateModes & PrivMode_mouse_report)) + { + if (MEvent.button == Button1 && clickintime) + selection_rotate (ev.x, ev.y); else - { - if (MEvent.button == Button1 && clickintime) - MEvent.clicks++; - else - MEvent.clicks = 1; + selection_extend (ev.x, ev.y, 1); + } + else + { + if (MEvent.button == Button1 && clickintime) + MEvent.clicks++; + else + MEvent.clicks = 1; - selection_click (MEvent.clicks, ev.x, ev.y); - } + selection_click (MEvent.clicks, ev.x, ev.y); + } - MEvent.button = Button1; - break; + MEvent.button = Button1; + break; - case Button3: - if (MEvent.button == Button3 && clickintime) - selection_rotate (ev.x, ev.y); - else - selection_extend (ev.x, ev.y, 1); - MEvent.button = Button3; - break; - } + case Button3: + if (MEvent.button == Button3 && clickintime) + selection_rotate (ev.x, ev.y); + else + selection_extend (ev.x, ev.y, 1); + MEvent.button = Button3; + break; } - MEvent.time = ev.time; - return; } + MEvent.time = ev.time; + return; } /* * Scrollbar window processing of button press */ - if (isScrollbarWindow(ev.window)) + if (isScrollbarWindow (ev.window)) { scrollBar.setIdle (); /* @@ -1705,26 +1624,26 @@ * click on scrollbar - send pageup/down */ if ((scrollBar.style == R_SB_NEXT - && scrollbarnext_upButton(ev.y)) + && scrollbarnext_upButton (ev.y)) || (scrollBar.style == R_SB_RXVT - && scrollbarrxvt_upButton(ev.y))) - tt_printf("\033[A"); + && scrollbarrxvt_upButton (ev.y))) + tt_printf ("\033[A"); else if ((scrollBar.style == R_SB_NEXT - && scrollbarnext_dnButton(ev.y)) + && scrollbarnext_dnButton (ev.y)) || (scrollBar.style == R_SB_RXVT - && scrollbarrxvt_dnButton(ev.y))) - tt_printf("\033[B"); + && scrollbarrxvt_dnButton (ev.y))) + tt_printf ("\033[B"); else switch (ev.button) { case Button2: - tt_printf("\014"); + tt_printf ("\014"); break; case Button1: - tt_printf("\033[6~"); + tt_printf ("\033[6~"); break; case Button3: - tt_printf("\033[5~"); + tt_printf ("\033[5~"); break; } } @@ -1736,16 +1655,16 @@ if (scrollBar.style == R_SB_NEXT) { - if (scrollbarnext_upButton(ev.y)) + if (scrollbarnext_upButton (ev.y)) upordown = -1; /* up */ - else if (scrollbarnext_dnButton(ev.y)) + else if (scrollbarnext_dnButton (ev.y)) upordown = 1; /* down */ } else if (scrollBar.style == R_SB_RXVT) { - if (scrollbarrxvt_upButton(ev.y)) + if (scrollbarrxvt_upButton (ev.y)) upordown = -1; /* up */ - else if (scrollbarrxvt_dnButton(ev.y)) + else if (scrollbarrxvt_dnButton (ev.y)) upordown = 1; /* down */ } if (upordown) @@ -1778,10 +1697,10 @@ break; } if (scrollBar.style == R_SB_XTERM - || scrollbar_above_slider(ev.y) - || scrollbar_below_slider(ev.y)) - scr_move_to ( scrollbar_position(ev.y) - csrO, - scrollbar_size()); + || scrollbar_above_slider (ev.y) + || scrollbar_below_slider (ev.y)) + scr_move_to ( scrollbar_position (ev.y) - csrO, + scrollbar_size ()); scrollBar.setMotion (); break; @@ -1793,13 +1712,13 @@ case Button3: if (scrollBar.style != R_SB_XTERM) { - if (scrollbar_above_slider(ev.y)) + if (scrollbar_above_slider (ev.y)) # ifdef RXVT_SCROLL_FULL scr_page (UP, TermWin.nrow - 1); # else scr_page (UP, TermWin.nrow / 4); # endif - else if (scrollbar_below_slider(ev.y)) + else if (scrollbar_below_slider (ev.y)) # ifdef RXVT_SCROLL_FULL scr_page (DN, TermWin.nrow - 1); # else @@ -1812,8 +1731,8 @@ { scr_page ((ev.button == Button1 ? DN : UP), (TermWin.nrow - * scrollbar_position(ev.y) - / scrollbar_size())); + * scrollbar_position (ev.y) + / scrollbar_size ())); } break; } @@ -1824,21 +1743,21 @@ /* * Menubar window processing of button press */ - if (isMenuBarWindow(ev.window)) + if (isMenuBarWindow (ev.window)) menubar_control (ev); #endif } void -rxvt_term::button_release (const XButtonEvent &ev) +rxvt_term::button_release (XButtonEvent &ev) { int reportmode = 0; csrO = 0; /* reset csr Offset */ if (!bypass_keystate) - reportmode = !!(PrivateModes & PrivMode_mouse_report); + reportmode = !! (PrivateModes & PrivMode_mouse_report); - if (scrollbar_isUpDn()) + if (scrollbar_isUpDn ()) { scrollBar.setIdle (); scrollbar_show (0); @@ -1852,97 +1771,89 @@ #endif if (ev.window == TermWin.vt) { -#ifdef RXVT_GRAPHICS - if (ev.subwindow != None) - rxvt_Gr_ButtonRelease(ev.x, ev.y); - else -#endif - + if (reportmode) { - if (reportmode) - { - /* mouse report from vt window */ - /* don't report release of wheel "buttons" */ - if (ev.button >= 4) - return; + /* mouse report from vt window */ + /* don't report release of wheel "buttons" */ + if (ev.button >= 4) + return; #ifdef MOUSE_REPORT_DOUBLECLICK - /* only report the release of 'slow' single clicks */ - if (MEvent.button != AnyButton - && (ev.button != MEvent.button - || (ev.time - MEvent.time - > MULTICLICK_TIME / 2))) - { - MEvent.clicks = 0; - MEvent.button = AnyButton; - mouse_report (ev); - } -#else /* MOUSE_REPORT_DOUBLECLICK */ + /* only report the release of 'slow' single clicks */ + if (MEvent.button != AnyButton + && (ev.button != MEvent.button + || (ev.time - MEvent.time + > MULTICLICK_TIME / 2))) + { + MEvent.clicks = 0; MEvent.button = AnyButton; mouse_report (ev); -#endif /* MOUSE_REPORT_DOUBLECLICK */ - return; } - /* - * dumb hack to compensate for the failure of click-and-drag - * when overriding mouse reporting - */ - if (PrivateModes & PrivMode_mouse_report - && bypass_keystate - && ev.button == Button1 && MEvent.clicks <= 1) - selection_extend (ev.x, ev.y, 0); - - switch (ev.button) - { - case Button1: - case Button3: - selection_make (ev.time); - break; - case Button2: - selection_request (ev.time, ev.x, ev.y); - break; +#else /* MOUSE_REPORT_DOUBLECLICK */ + MEvent.button = AnyButton; + mouse_report (ev); +#endif /* MOUSE_REPORT_DOUBLECLICK */ + return; + } + /* + * dumb hack to compensate for the failure of click-and-drag + * when overriding mouse reporting + */ + if (PrivateModes & PrivMode_mouse_report + && bypass_keystate + && ev.button == Button1 && MEvent.clicks <= 1) + selection_extend (ev.x, ev.y, 0); + + switch (ev.button) + { + case Button1: + case Button3: + selection_make (ev.time); + break; + case Button2: + selection_request (ev.time, ev.x, ev.y); + break; #ifdef MOUSE_WHEEL - case Button4: - case Button5: - { - int i; - page_dirn v; + case Button4: + case Button5: + { + int i; + page_dirn v; - v = (ev.button == Button4) ? UP : DN; - if (ev.state & ShiftMask) - i = 1; - else if ((Options & Opt_mouseWheelScrollPage)) - i = TermWin.nrow - 1; - else - i = 5; + v = (ev.button == Button4) ? UP : DN; + if (ev.state & ShiftMask) + i = 1; + else if ((Options & Opt_mouseWheelScrollPage)) + i = TermWin.nrow - 1; + else + i = 5; # ifdef MOUSE_SLIP_WHEELING - if (ev.state & ControlMask) - { - mouse_slip_wheel_speed += (v ? -1 : 1); - mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; - } + if (ev.state & ControlMask) + { + mouse_slip_wheel_speed += (v ? -1 : 1); + mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; + } # endif # ifdef JUMP_MOUSE_WHEEL - scr_page (v, i); + scr_page (v, i); + scr_refresh (SMOOTH_REFRESH); + scrollbar_show (1); +# else + while (i--) + { + scr_page (v, 1); scr_refresh (SMOOTH_REFRESH); scrollbar_show (1); -# else - while (i--) - { - scr_page (v, 1); - scr_refresh (SMOOTH_REFRESH); - scrollbar_show (1); - } + } # endif - } - break; + } + break; #endif - } } } #ifdef MENUBAR - else if (isMenuBarWindow(ev.window)) + else if (isMenuBarWindow (ev.window)) menubar_control (ev); #endif } @@ -1966,19 +1877,19 @@ pchanged = 0; - if (!(Options & Opt_transparent)) + if (! (Options & Opt_transparent)) return pchanged; /* Don't try any more */ - XGetWindowAttributes(display->display, display->root, &wrootattr); + XGetWindowAttributes (display->display, display->root, &wrootattr); rootdepth = wrootattr.depth; - XGetWindowAttributes(display->display, TermWin.parent[0], &wattr); + XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); if (rootdepth != wattr.depth) { if (am_transparent) { pchanged = 1; - XSetWindowBackground(display->display, TermWin.vt, + XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); am_transparent = am_pixmap_trans = 0; } @@ -1986,7 +1897,7 @@ } /* Get all X ops out of the queue so that our information is up-to-date. */ - XSync(display->display, False); + XSync (display->display, False); /* * Make the frame window set by the window manager have @@ -1994,7 +1905,7 @@ * windows for each client, so we have to take care about that. */ i = (xa[XA_XROOTPMAPID] != 0 - && (XGetWindowProperty(display->display, display->root, xa[XA_XROOTPMAPID], + && (XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], 0L, 1L, False, XA_PIXMAP, &atype, &aformat, &nitems, &bytes_after, &prop) == Success)); if (!i || prop == NULL) @@ -2002,42 +1913,45 @@ else { have_pixmap = 1; - rootpixmap = *((Pixmap *)prop); - XFree(prop); + rootpixmap = * ((Pixmap *)prop); + XFree (prop); } if (have_pixmap) { /* * Copy display->root pixmap transparency */ - int sx, sy, nx, ny; - unsigned int nw, nh; - Window cr; - XImage *image; - GC gc; - XGCValues gcvalue; + int sx, sy, nx, ny; + unsigned int nw, nh; + Window cr; + XImage *image; + GC gc; + XGCValues gcvalue; - XTranslateCoordinates(display->display, TermWin.parent[0], display->root, + XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 0, 0, &sx, &sy, &cr); nw = (unsigned int)szHint.width; nh = (unsigned int)szHint.height; nx = ny = 0; + if (sx < 0) { nw += sx; nx = -sx; sx = 0; } + if (sy < 0) { nh += sy; ny = -sy; sy = 0; } - MIN_IT(nw, (unsigned int)(wrootattr.width - sx)); - MIN_IT(nh, (unsigned int)(wrootattr.height - sy)); + + MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); + MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); allowedxerror = -1; - image = XGetImage(display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, + image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); /* XXX: handle BadMatch - usually because we're outside the pixmap */ /* XXX: may need a delay here? */ @@ -2049,7 +1963,7 @@ pchanged = 1; if (TermWin.pixmap != None) { - XFreePixmap(display->display, TermWin.pixmap); + XFreePixmap (display->display, TermWin.pixmap); TermWin.pixmap = None; } } @@ -2058,39 +1972,40 @@ else { if (TermWin.pixmap != None) - XFreePixmap(display->display, TermWin.pixmap); - TermWin.pixmap = XCreatePixmap(display->display, TermWin.vt, + XFreePixmap (display->display, TermWin.pixmap); + TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, (unsigned int)szHint.width, (unsigned int)szHint.height, (unsigned int)image->depth); - gc = XCreateGC(display->display, TermWin.vt, 0UL, &gcvalue); - XPutImage(display->display, TermWin.pixmap, gc, image, 0, 0, + gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); + XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, nx, ny, (unsigned int)image->width, (unsigned int)image->height); - XFreeGC(display->display, gc); - XDestroyImage(image); - XSetWindowBackgroundPixmap(display->display, TermWin.vt, + XFreeGC (display->display, gc); + XDestroyImage (image); + XSetWindowBackgroundPixmap (display->display, TermWin.vt, TermWin.pixmap); if (!am_transparent || !am_pixmap_trans) pchanged = 1; am_transparent = am_pixmap_trans = 1; } } + if (!am_pixmap_trans) { unsigned int n; /* * InheritPixmap transparency */ - D_X((stderr, "InheritPixmap Seeking to %08lx", display->root)); - for (i = 1; i < (int)(sizeof(TermWin.parent) / sizeof(Window)); + D_X ((stderr, "InheritPixmap Seeking to %08lx", display->root)); + for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) { oldp = TermWin.parent[i]; - XQueryTree(display->display, TermWin.parent[i - 1], &root, + XQueryTree (display->display, TermWin.parent[i - 1], &root, &TermWin.parent[i], &list, &n); - XFree(list); - D_X((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i])); + XFree (list); + D_X ((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i])); if (TermWin.parent[i] == display->root) { if (oldp != None) @@ -2100,27 +2015,30 @@ if (oldp != TermWin.parent[i]) pchanged = 1; } + n = 0; + if (pchanged) { for (; n < (unsigned int)i; n++) { - XGetWindowAttributes(display->display, TermWin.parent[n], &wattr); - D_X((stderr, "InheritPixmap Checking Parent[%d]: %s", n, (wattr.depth == rootdepth && wattr.class != InputOnly) ? "OK" : "FAIL")); + XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); + D_X ((stderr, "InheritPixmap Checking Parent[%d]: %s", n, (wattr.depth == rootdepth && wattr.class != InputOnly) ? "OK" : "FAIL")); if (wattr.depth != rootdepth || wattr.c_class == InputOnly) { - n = (int)(sizeof(TermWin.parent) / sizeof(Window)) + 1; + n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; break; } } } - if (n > (int)(sizeof(TermWin.parent) - / sizeof(TermWin.parent[0]))) + + if (n > (int) (sizeof (TermWin.parent) + / sizeof (TermWin.parent[0]))) { - D_X((stderr, "InheritPixmap Turning off")); - XSetWindowBackground(display->display, TermWin.parent[0], + D_X ((stderr, "InheritPixmap Turning off")); + XSetWindowBackground (display->display, TermWin.parent[0], PixColors[Color_fg]); - XSetWindowBackground(display->display, TermWin.vt, + XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); am_transparent = 0; /* XXX: also turn off Opt_transparent? */ @@ -2134,19 +2052,20 @@ rqt.tv_sec = 1; rqt.tv_nsec = 0; - nanosleep(&rqt, NULL); + nanosleep (&rqt, NULL); # else - sleep(1); + sleep (1); # endif - D_X((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); + D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); for (n = 0; n < (unsigned int)i; n++) - XSetWindowBackgroundPixmap(display->display, TermWin.parent[n], + XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); - XSetWindowBackgroundPixmap(display->display, TermWin.vt, + XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); am_transparent = 1; } - for (; i < (int)(sizeof(TermWin.parent) / sizeof(Window)); i++) + + for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) TermWin.parent[i] = None; } return pchanged; @@ -2161,10 +2080,10 @@ FILE * rxvt_term::popen_printer () { - FILE *stream = popen(rs[Rs_print_pipe], "w"); + FILE *stream = popen (rs[Rs_print_pipe], "w"); if (stream == NULL) - rxvt_print_error("can't open printer pipe"); + rxvt_print_error ("can't open printer pipe"); return stream; } @@ -2172,7 +2091,7 @@ rxvt_term::pclose_printer (FILE *stream) { fflush (stream); - /* pclose() reported not to work on SunOS 4.1.3 */ + /* pclose () reported not to work on SunOS 4.1.3 */ # if defined (__sun__) /* TODO: RESOLVE THIS */ /* pclose works provided SIGCHLD handler uses waitpid */ return pclose (stream); /* return fclose (stream); */ @@ -2205,7 +2124,7 @@ if ((ch = cmd_getc ()) != C0_ESC) { - if (putc(ch, fd) == EOF) + if (putc (ch, fd) == EOF) break; /* done = 1 */ } else @@ -2227,7 +2146,7 @@ } } for (i = 0; i < len; i++) - if (putc(buf[i], fd) == EOF) + if (putc (buf[i], fd) == EOF) { done = 1; break; @@ -2257,12 +2176,12 @@ { case C0_ENQ: /* terminal Status */ if (rs[Rs_answerbackstring]) - tt_write( + tt_write ( (const unsigned char *)rs[Rs_answerbackstring], - (unsigned int)STRLEN(rs[Rs_answerbackstring])); + (unsigned int)STRLEN (rs[Rs_answerbackstring])); else - tt_write((unsigned char *)VT100_ANS, - (unsigned int)STRLEN(VT100_ANS)); + tt_write ((unsigned char *)VT100_ANS, + (unsigned int)STRLEN (VT100_ANS)); break; case C0_BEL: /* bell */ scr_bell (); @@ -2334,10 +2253,10 @@ scr_gotorc (row, col, 0); break; case 'Z': /* identify the terminal type */ - tt_printf("\033/Z"); /* I am a VT100 emulating a VT52 */ + tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ break; case '<': /* turn off VT52 mode */ - PrivMode(0, PrivMode_vt52); + PrivMode (0, PrivMode_vt52); break; case 'F': /* use special graphics character set */ case 'G': /* use regular character set */ @@ -2383,11 +2302,6 @@ case '+': scr_charset_set (3, (unsigned int)cmd_getc ()); break; -#ifdef MULTICHAR_SET - case '$': - scr_charset_set (-2, (unsigned int)cmd_getc ()); - break; -#endif #ifndef NO_FRILLS case '6': scr_backindex (); @@ -2406,7 +2320,7 @@ #endif case '=': case '>': - PrivMode((ch == '='), PrivMode_aplKP); + PrivMode ((ch == '='), PrivMode_aplKP); break; case C1_40: @@ -2419,7 +2333,7 @@ /* 8.3.87: NEXT LINE */ case C1_NEL: /* ESC E */ { - uint32_t nlcr[] = { '\n', '\r' }; + unicode_t nlcr[] = { L'\n', L'\r' }; scr_add_lines (nlcr, 1, 2); } break; @@ -2452,8 +2366,8 @@ /* 8.3.110: SINGLE CHARACTER INTRODUCER */ case C1_SCI: /* ESC Z */ - tt_write((const unsigned char *)ESCZ_ANSWER, - (unsigned int)(sizeof(ESCZ_ANSWER) - 1)); + tt_write ((const unsigned char *)ESCZ_ANSWER, + (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); break; /* steal obsolete ESC [ c */ /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ @@ -2503,18 +2417,18 @@ (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) #define get_byte_array_bit(array, bit) \ - (!!((array)[(bit) / 8] & (128 >> ((bit) & 7)))) + (!! ((array)[ (bit) / 8] & (128 >> ((bit) & 7)))) const unsigned char csi_defaults[] = { - make_byte(1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ - make_byte(1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ - make_byte(1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ - make_byte(1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ - make_byte(1,1,1,0,1,1,1,0), /* `, a, b, c, d, e, f, g, */ - make_byte(0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */ - make_byte(0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */ - make_byte(0,0,0,0,0,0,0,0) /* x, y, z, {, |, }, ~, */ + make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ + make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ + make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ + make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ + make_byte (1,1,1,0,1,1,1,0), /* `, a, b, c, d, e, f, g, */ + make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */ + make_byte (0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */ + make_byte (0,0,0,0,0,0,0,0) /* x, y, z, {, |, }, ~, */ }; /* *INDENT-ON* */ @@ -2539,7 +2453,7 @@ /* read any numerical arguments */ for (n = -1; ch < CSI_ICH; ) { - if (isdigit(ch)) + if (isdigit (ch)) { if (n < 0) n = ch - '0'; @@ -2575,16 +2489,16 @@ arg[nargs++] = n; i = ch - CSI_ICH; - ndef = get_byte_array_bit(csi_defaults, i); + ndef = get_byte_array_bit (csi_defaults, i); for (p = 0; p < nargs; p++) if (arg[p] == -1) arg[p] = ndef; #ifdef DEBUG_CMD - fprintf(stderr, "CSI "); + fprintf (stderr, "CSI "); for (p = 0; p < nargs; p++) - fprintf(stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); - fprintf(stderr, "%c\n", ch); + fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); + fprintf (stderr, "%c\n", ch); #endif /* @@ -2596,7 +2510,7 @@ { case '>': if (ch == CSI_DA) /* secondary device attributes */ - tt_printf("\033[>%d;%-.8s;0c", 'R', VSTRING); + tt_printf ("\033[>%d;%-.8s;0c", 'R', VSTRING); break; case '?': if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') @@ -2609,7 +2523,7 @@ switch (ch) { /* - * ISO/IEC 6429:1992(E) CSI sequences (defaults in parentheses) + * ISO/IEC 6429:1992 (E) CSI sequences (defaults in parentheses) */ #ifdef PRINTPIPE case CSI_MC: /* 8.3.83: (0) MEDIA COPY */ @@ -2715,8 +2629,8 @@ break; case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ - tt_write((const unsigned char *)VT100_ANS, - (unsigned int)(sizeof(VT100_ANS) - 1)); + tt_write ((const unsigned char *)VT100_ANS, + (unsigned int) (sizeof (VT100_ANS) - 1)); break; case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ @@ -2727,18 +2641,18 @@ switch (arg[0]) { case 5: /* DSR requested */ - tt_printf("\033[0n"); + tt_printf ("\033[0n"); break; case 6: /* CPR requested */ scr_report_position (); break; #if defined (ENABLE_DISPLAY_ANSWER) case 7: /* unofficial extension */ - tt_printf("%-.250s\n", rs[Rs_display_name]); + tt_printf ("%-.250s\n", rs[Rs_display_name]); break; #endif case 8: /* unofficial extension */ - xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); + xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); break; } break; @@ -2815,7 +2729,7 @@ case CSI_78: /* DECREQTPARM */ if (arg[0] == 0 || arg[0] == 1) - tt_printf("\033[%d;1;1;128;128;1;0x", arg[0] + 2); + tt_printf ("\033[%d;1;1;128;128;1;0x", arg[0] + 2); /* FALLTHROUGH */ default: @@ -2844,65 +2758,65 @@ * commands */ case 1: /* deiconify window */ - XMapWindow(display->display, TermWin.parent[0]); + XMapWindow (display->display, TermWin.parent[0]); break; case 2: /* iconify window */ - XIconifyWindow(display->display, TermWin.parent[0], - DefaultScreen(display->display)); + XIconifyWindow (display->display, TermWin.parent[0], + DefaultScreen (display->display)); break; case 3: /* set position (pixels) */ - XMoveWindow(display->display, TermWin.parent[0], args[1], args[2]); + XMoveWindow (display->display, TermWin.parent[0], args[1], args[2]); break; case 4: /* set size (pixels) */ set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); break; case 5: /* raise window */ - XRaiseWindow(display->display, TermWin.parent[0]); + XRaiseWindow (display->display, TermWin.parent[0]); break; case 6: /* lower window */ - XLowerWindow(display->display, TermWin.parent[0]); + XLowerWindow (display->display, TermWin.parent[0]); break; case 7: /* refresh window */ scr_touch (true); break; case 8: /* set size (chars) */ - set_widthheight ((unsigned int)(args[2] * TermWin.fwidth), - (unsigned int)(args[1] * TermWin.fheight)); + set_widthheight ((unsigned int) (args[2] * TermWin.fwidth), + (unsigned int) (args[1] * TermWin.fheight)); break; default: if (args[0] >= 24) /* set height (chars) */ set_widthheight ((unsigned int)TermWin.width, - (unsigned int)(args[1] * TermWin.fheight)); + (unsigned int) (args[1] * TermWin.fheight)); break; /* * reports - some output format copied from XTerm */ case 11: /* report window state */ - XGetWindowAttributes(display->display, TermWin.parent[0], &wattr); - tt_printf("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); + XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); + tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); break; case 13: /* report window position */ - XGetWindowAttributes(display->display, TermWin.parent[0], &wattr); - XTranslateCoordinates(display->display, TermWin.parent[0], wattr.root, + XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); + XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root, -wattr.border_width, -wattr.border_width, &x, &y, &wdummy); - tt_printf("\033[3;%d;%dt", x, y); + tt_printf ("\033[3;%d;%dt", x, y); break; case 14: /* report window size (pixels) */ - XGetWindowAttributes(display->display, TermWin.parent[0], &wattr); - tt_printf("\033[4;%d;%dt", wattr.height, wattr.width); + XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); + tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); break; case 18: /* report window size (chars) */ - tt_printf("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); + tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); break; #if 0 /* XXX: currently disabled due to security concerns */ case 20: /* report icon label */ - XGetIconName(display->display, TermWin.parent[0], &s); - tt_printf("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ + XGetIconName (display->display, TermWin.parent[0], &s); + tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ break; case 21: /* report window title */ - XFetchName(display->display, TermWin.parent[0], &s); - tt_printf("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ + XFetchName (display->display, TermWin.parent[0], &s); + tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ break; #endif @@ -2913,7 +2827,7 @@ /*----------------------------------------------------------------------*/ /* * get input up until STRING TERMINATOR (or BEL) - * ends_how is terminator used. returned input must be free()d + * ends_how is terminator used. returned input must be free ()d */ unsigned char * rxvt_term::get_to_st (unsigned char *ends_how) @@ -2938,15 +2852,15 @@ ch = ' '; /* translate '\t' to space */ else if (ch < 0x08 || (ch > 0x0d && ch < 0x20)) return NULL; /* other control character - exit */ - if (n < sizeof(string) - 1) + if (n < sizeof (string) - 1) string[n++] = ch; seen_esc = 0; } string[n++] = '\0'; - if ((s = (unsigned char *)rxvt_malloc(n)) == NULL) + if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) return NULL; *ends_how = (ch == 0x5c ? C0_ESC : ch); - STRNCPY(s, string, n); + STRNCPY (s, string, n); return s; } @@ -2963,7 +2877,7 @@ */ s = get_to_st (&eh); if (s) - free(s); + free (s); return; } @@ -2978,7 +2892,7 @@ int arg; ch = cmd_getc (); - for (arg = 0; isdigit(ch); ch = cmd_getc ()) + for (arg = 0; isdigit (ch); ch = cmd_getc ()) arg = arg * 10 + (ch - '0'); if (ch == ';') @@ -2987,7 +2901,7 @@ if (s) { /* - * rxvt_menubar_dispatch() violates the constness of the string, + * rxvt_menubar_dispatch () violates the constness of the string, * so do it here */ if (arg == XTerm_Menu) @@ -2998,7 +2912,7 @@ #endif else xterm_seq (arg, (char *)s, eh); - free(s); + free (s); } } } @@ -3022,15 +2936,17 @@ * 39 = change default fg color * 49 = change default bg color * 55 = dump scrollback buffer and all of screen + * 701 = change locale + * 702 = find font */ void -rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__((unused))) +rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) { int changed = 0; int color; char *buf, *name; - assert(str != NULL); + assert (str != NULL); switch (op) { case XTerm_name: @@ -3045,13 +2961,13 @@ case XTerm_Color: for (buf = (char *)str; buf && *buf;) { - if ((name = STRCHR(buf, ';')) == NULL) + if ((name = STRCHR (buf, ';')) == NULL) break; *name++ = '\0'; - color = atoi(buf); + color = atoi (buf); if (color < 0 || color >= TOTAL_COLORS) break; - if ((buf = STRCHR(name, ';')) != NULL) + if ((buf = STRCHR (name, ';')) != NULL) *buf++ = '\0'; set_window_color (color + minCOLOR, name); } @@ -3078,7 +2994,7 @@ case XTerm_Menu: /* - * rxvt_menubar_dispatch() violates the constness of the string, + * rxvt_menubar_dispatch () violates the constness of the string, * so DON'T do it here */ break; @@ -3091,7 +3007,7 @@ #endif scr_touch (true); } - while ((str = STRCHR(str, ';')) != NULL) + while ((str = STRCHR (str, ';')) != NULL) { str++; #if XPM_BACKGROUND @@ -3117,16 +3033,35 @@ case XTerm_logfile: break; case XTerm_font: - change_font (0, str); + change_font (str); break; +#ifndef NO_FRILLS + case XTerm_locale: + if (str[0] == '?' && !str[1]) + tt_printf ("%-.250s\n", locale); + else + { + set_locale (str); +# ifdef USE_XIM + im_cb (); +# endif + } + break; + case XTerm_findfont: + { + int fid = TermWin.fontset->find_font (atoi (str)); + tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name); + } + break; +#endif #if 0 case XTerm_dumpscreen: /* no error notices */ { int fd; - if ((fd = open(str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) + if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) { scr_dump (fd); - close(fd); + close (fd); } } break; @@ -3161,15 +3096,15 @@ if (mode == 'r') state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ else - state = (mode == 't') ? !(PrivateModes & bit) : mode; - PrivMode(state, bit); + state = (mode == 't') ? ! (PrivateModes & bit) : mode; + PrivMode (state, bit); } return state; } /* we're not using priv _yet_ */ void -rxvt_term::process_terminal_mode (int mode, int priv __attribute__((unused)), unsigned int nargs, const int *arg) +rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) { unsigned int i, j; int state; @@ -3193,19 +3128,32 @@ #ifdef scrollBar_esc { scrollBar_esc, PrivMode_scrollBar }, #endif + // 18, 19 printing-related { 25, PrivMode_VisibleCursor }, - { 35, PrivMode_ShiftKeys }, + // 30 show scrollbar rxvt. extension + { 35, PrivMode_ShiftKeys }, // rxvt extension { 40, PrivMode_132OK }, + // 41 xterm more fixes NYI + // 45 margin bell NYI + // 46 start logging { 47, PrivMode_Screen }, { 66, PrivMode_aplKP }, #ifndef NO_BACKSPACE_KEY { 67, PrivMode_BackSpace }, #endif { 1000, PrivMode_MouseX11 }, - { 1010, PrivMode_TtyOutputInh }, - { 1011, PrivMode_Keypress }, + // 1001 Use Hilite Mouse Tracking. NYI, TODO + // 1002 Use Cell Motion Mouse Tracking. NYI, TODO + // 1003 Use All Motion Mouse Tracking. NYI, TODO + { 1010, PrivMode_TtyOutputInh }, // rxvt extension + { 1011, PrivMode_Keypress }, // rxvt extension + // 1035 enable modifiers for alt, numlock NYI + // 1036 send ESC for meta keys NYI + // 1037 send DEL for keypad delete NYI { 1047, PrivMode_Screen }, + // 1048 save and restore cursor { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */ + // 1051, 1052, 1060, 1061 keyboard emulation NYI }; if (nargs == 0) @@ -3222,7 +3170,7 @@ state = -1; /* basic handling */ - for (j = 0; j < (sizeof(argtopriv)/sizeof(argtopriv[0])); j++) + for (j = 0; j < (sizeof (argtopriv)/sizeof (argtopriv[0])); j++) if (argtopriv[j].argval == arg[i]) { state = privcases (mode, argtopriv[j].bit); @@ -3230,110 +3178,108 @@ } /* extra handling for values with state unkept */ - if (state == -1) - switch (arg[i]) - { - case 1048: /* alternative cursor save */ - if (mode == 0) - scr_cursor (RESTORE); - else if (mode == 1) - scr_cursor (SAVE); - /* FALLTHROUGH */ - default: - continue; /* for(;i;) */ - } - - /* extra handling for values with valid 0 or 1 state */ switch (arg[i]) { - /* case 1: - application cursor keys */ - case 2: /* VT52 mode */ - /* oddball mode. should be set regardless of set/reset - * parameter. Return from VT52 mode with an ESC < from - * within VT52 mode - */ - PrivMode(1, PrivMode_vt52); - break; - case 3: /* 80/132 */ - if (PrivateModes & PrivMode_132OK) - set_widthheight ( (unsigned int)((state ? 132 : 80) * TermWin.fwidth), - (unsigned int)TermWin.height); - break; - case 4: /* smooth scrolling */ - if (state) - Options &= ~Opt_jumpScroll; - else - Options |= Opt_jumpScroll; - break; - case 5: /* reverse video */ - scr_rvideo_mode (state); - break; - case 6: /* relative/absolute origins */ - scr_relative_origin (state); - break; - case 7: /* autowrap */ - scr_autowrap (state); - break; - /* case 8: - auto repeat, can't do on a per window basis */ - case 9: /* X10 mouse reporting */ - if (state) /* orthogonal */ - PrivateModes &= ~(PrivMode_MouseX11); - break; + case 1048: /* alternative cursor save */ + case 1049: + if (mode == 0) + scr_cursor (RESTORE); + else if (mode == 1) + scr_cursor (SAVE); + /* FALLTHROUGH */ + } + + if (state >= 0) + /* extra handling for values with valid 0 or 1 state */ + switch (arg[i]) + { + /* case 1: - application cursor keys */ + case 2: /* VT52 mode */ + /* oddball mode. should be set regardless of set/reset + * parameter. Return from VT52 mode with an ESC < from + * within VT52 mode + */ + PrivMode (1, PrivMode_vt52); + break; + case 3: /* 80/132 */ + if (PrivateModes & PrivMode_132OK) + set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); + break; + case 4: /* smooth scrolling */ + if (state) + Options &= ~Opt_jumpScroll; + else + Options |= Opt_jumpScroll; + break; + case 5: /* reverse video */ + scr_rvideo_mode (state); + break; + case 6: /* relative/absolute origins */ + scr_relative_origin (state); + break; + case 7: /* autowrap */ + scr_autowrap (state); + break; + /* case 8: - auto repeat, can't do on a per window basis */ + case 9: /* X10 mouse reporting */ + if (state) /* orthogonal */ + PrivateModes &= ~ (PrivMode_MouseX11); + break; #ifdef menuBar_esc - case menuBar_esc: + case menuBar_esc: #ifdef MENUBAR - map_menuBar (state); + map_menuBar (state); #endif - break; + break; #endif #ifdef scrollBar_esc - case scrollBar_esc: - if (scrollbar_mapping (state)) - { - resize_all_windows (0, 0, 0); - scr_touch (true); - } - break; + case scrollBar_esc: + if (scrollbar_mapping (state)) + { + resize_all_windows (0, 0, 0); + scr_touch (true); + } + break; #endif - case 25: /* visible/invisible cursor */ - scr_cursor_visible (state); - break; - /* case 35: - shift keys */ - /* case 40: - 80 <--> 132 mode */ - case 47: /* secondary screen */ - scr_change_screen (state); - break; - /* case 66: - application key pad */ - /* case 67: - backspace key */ - case 1000: /* X11 mouse reporting */ - if (state) /* orthogonal */ - PrivateModes &= ~(PrivMode_MouseX10); - break; + case 25: /* visible/invisible cursor */ + scr_cursor_visible (state); + break; + /* case 35: - shift keys */ + /* case 40: - 80 <--> 132 mode */ + case 47: /* secondary screen */ + scr_change_screen (state); + break; + /* case 66: - application key pad */ + /* case 67: - backspace key */ + case 1000: /* X11 mouse reporting */ + if (state) /* orthogonal */ + PrivateModes &= ~ (PrivMode_MouseX10); + break; #if 0 - case 1001: - break; /* X11 mouse highlighting */ + case 1001: + break; /* X11 mouse highlighting */ #endif - case 1010: /* scroll to bottom on TTY output inhibit */ - if (state) - Options &= ~Opt_scrollTtyOutput; - else - Options |= Opt_scrollTtyOutput; - break; - case 1011: /* scroll to bottom on key press */ - if (state) - Options |= Opt_scrollTtyKeypress; - else - Options &= ~Opt_scrollTtyKeypress; - break; - case 1047: /* secondary screen w/ clearing */ - case 1049: /* better secondary screen w/ clearing, but not fully implemented */ - if (current_screen != PRIMARY) - scr_erase_screen (2); - scr_change_screen (state); - /* FALLTHROUGH */ - default: - break; - } + case 1010: /* scroll to bottom on TTY output inhibit */ + if (state) + Options &= ~Opt_scrollTtyOutput; + else + Options |= Opt_scrollTtyOutput; + break; + case 1011: /* scroll to bottom on key press */ + if (state) + Options |= Opt_scrollTtyKeypress; + else + Options &= ~Opt_scrollTtyKeypress; + break; + case 1047: /* secondary screen w/ clearing */ + case 1049: /* better secondary screen w/ clearing, but not fully implemented */ + if (current_screen != PRIMARY) + scr_erase_screen (2); + scr_change_screen (state); + /* FALLTHROUGH */ + default: + break; + } } } /*}}} */ @@ -3371,6 +3317,9 @@ case 7: rendset = 1, rendstyle = RS_RVid; break; + case 8: + // invisible. NYI + break; case 22: rendset = 0, rendstyle = RS_Bold; break; @@ -3383,11 +3332,15 @@ case 27: rendset = 0, rendstyle = RS_RVid; break; + case 28: + // visible. NYI + break; } + if (rendset != -1) { scr_rendition (rendset, rendstyle); - continue; /* for(;i;) */ + continue; /* for (;i;) */ } switch (arg[i]) @@ -3400,15 +3353,13 @@ case 35: case 36: case 37: - scr_color ((unsigned int)(minCOLOR + (arg[i] - 30)), - Color_fg); + scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); break; #ifdef TTY_256COLOR case 38: if (nargs > i + 2 && arg[i + 1] == 5) { - scr_color ((unsigned int)(minCOLOR + arg[i + 2]), - Color_fg); + scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); i += 2; } break; @@ -3425,15 +3376,13 @@ case 45: case 46: case 47: - scr_color ((unsigned int)(minCOLOR + (arg[i] - 40)), - Color_bg); + scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); break; #ifdef TTY_256COLOR case 48: if (nargs > i + 2 && arg[i + 1] == 5) { - scr_color ((unsigned int)(minCOLOR + arg[i + 2]), - Color_bg); + scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); i += 2; } break; @@ -3451,7 +3400,7 @@ case 95: case 96: case 97: - scr_color ((unsigned int)(minBrightCOLOR + (arg[i] - 90)), + scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), Color_fg); break; case 100: @@ -3462,7 +3411,7 @@ case 105: case 106: case 107: - scr_color ((unsigned int)(minBrightCOLOR + (arg[i] - 100)), + scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); break; #endif @@ -3478,68 +3427,22 @@ { unsigned char ch, cmd = cmd_getc (); -#ifndef RXVT_GRAPHICS if (cmd == 'Q') { /* query graphics */ - tt_printf("\033G0\n"); /* no graphics */ + tt_printf ("\033G0\n"); /* no graphics */ return; } /* swallow other graphics sequences until terminating ':' */ do ch = cmd_getc (); while (ch != ':'); -#else - unsigned int nargs; - int args[NGRX_PTS]; - unsigned char *text = NULL; - - if (cmd == 'Q') - { /* query graphics */ - tt_printf("\033G1\n"); /* yes, graphics (color) */ - return; - } - for (nargs = 0; nargs < (sizeof(args) / sizeof(args[0])) - 1;) - { - int neg; - - ch = cmd_getc (); - neg = (ch == '-'); - if (neg || ch == '+') - ch = cmd_getc (); - - for (args[nargs] = 0; isdigit(ch); ch = cmd_getc ()) - args[nargs] = args[nargs] * 10 + (ch - '0'); - if (neg) - args[nargs] = -args[nargs]; - - nargs++; - args[nargs] = 0; - if (ch != ';') - break; - } - - if ((cmd == 'T') && (nargs >= 5)) - { - int i, len = args[4]; - - text = (unsigned char *)rxvt_malloc((len + 1) * sizeof(char)); - - if (text != NULL) - { - for (i = 0; i < len; i++) - text[i] = cmd_getc (); - text[len] = '\0'; - } - } - Gr_do_graphics (cmd, nargs, args, text); -#endif } /*}}} */ /* ------------------------------------------------------------------------- */ /* - * Send printf() formatted output to the command. + * Send printf () formatted output to the command. * Only use for small amounts of data. */ void