--- rxvt-unicode/src/command.C 2004/02/01 01:34:41 1.36 +++ rxvt-unicode/src/command.C 2004/02/22 08:28:36 1.51 @@ -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 @@ -55,15 +56,15 @@ /*{{{ Convert the keypress event into a string */ void -rxvt_term::lookup_key (XKeyEvent *ev) +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]; /* @@ -72,14 +73,14 @@ * * Always permit `shift' to override the current setting */ - shft = (ev->state & ShiftMask); - ctrl = (ev->state & ControlMask); - meta = (ev->state & ModMetaMask); + shft = (ev.state & ShiftMask); + ctrl = (ev.state & ControlMask); + meta = (ev.state & ModMetaMask); - if (numlock_state || (ev->state & ModNumLockMask)) + if (numlock_state || (ev.state & ModNumLockMask)) { - numlock_state = (ev->state & ModNumLockMask); - PrivMode((!numlock_state), PrivMode_aplKP); + numlock_state = (ev.state & ModNumLockMask); + PrivMode ((!numlock_state), PrivMode_aplKP); } kbuf[0] = 0; @@ -90,12 +91,11 @@ Status status_return; #ifdef X_HAVE_UTF8_STRING - if (enc_utf8 && 0) - len = Xutf8LookupString (Input_Context, ev, (char *)kbuf, + 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]; @@ -104,13 +104,13 @@ if (rs[Rs_imLocale]) SET_LOCALE (rs[Rs_imLocale]); // assume wchar_t == unicode or better - len = XwcLookupString (Input_Context, ev, wkbuf, + len = XwcLookupString (Input_Context, &ev, wkbuf, KBUFSZ, &keysym, &status_return); if (rs[Rs_imLocale]) SET_LOCALE (locale); if (status_return == XLookupChars - || status_return == XLookupBoth) + || status_return == XLookupBoth) { wkbuf[len] = 0; len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); @@ -122,14 +122,13 @@ } valid_keysym = status_return == XLookupKeySym - || status_return == XLookupBoth; + || status_return == XLookupBoth; } else #endif - { - len = XLookupString (ev, (char *)kbuf, KBUFSZ, &keysym, &compose); - valid_keysym = !len; + len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); + valid_keysym = keysym != NoSymbol; } if (valid_keysym) @@ -144,12 +143,12 @@ { if (keysym == ks_bigfont) { - change_font (0, FONT_UP); + change_font (FONT_UP); return; } else if (keysym == ks_smallfont) { - change_font (0, FONT_DN); + change_font (FONT_DN); return; } } @@ -164,7 +163,7 @@ if (IS_SCROLL_MOD) { #endif - int lnsppg; + int lnsppg; #ifdef PAGING_CONTEXT_LINES lnsppg = TermWin.nrow - PAGING_CONTEXT_LINES; @@ -212,7 +211,6 @@ } } #endif - } if (shft) @@ -229,14 +227,14 @@ { /* normal XTerm key bindings */ case XK_Insert: /* Shift+Insert = paste mouse selection */ - selection_request (ev->time, 0, 0); + selection_request (ev.time, 0, 0); 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,27 +246,11 @@ 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; @@ -288,7 +270,6 @@ } else #endif - { newlen = 1; switch (keysym) @@ -297,46 +278,46 @@ 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); + STRCPY (kbuf, key_backspace); # ifdef MULTICHAR_SET if ((Options & Opt_mc_hack) && screen.cur.col > 0) { int col, row; - newlen = STRLEN(kbuf); + 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); + if (IS_MULTI2 (screen.rend[row][col])) + MEMMOVE (kbuf + newlen, kbuf, newlen + 1); } # endif break; #endif #ifndef NO_DELETE_KEY case XK_Delete: - STRCPY(kbuf, key_delete); + STRCPY (kbuf, key_delete); # ifdef MULTICHAR_SET if (Options & Opt_mc_hack) { int col, row; - newlen = STRLEN(kbuf); + 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); + if (IS_MULTI1 (screen.rend[row][col])) + MEMMOVE (kbuf + newlen, kbuf, newlen + 1); } # endif break; #endif case XK_Tab: if (shft) - STRCPY(kbuf, "\033[Z"); + STRCPY (kbuf, "\033[Z"); else { #ifdef CTRL_TAB_MAKES_META @@ -344,14 +325,13 @@ meta = 1; #endif #ifdef MOD4_TAB_MAKES_META - if (ev->state & Mod4Mask) + if (ev.state & Mod4Mask) meta = 1; #endif newlen = 0; } break; - #ifdef XK_KP_Left case XK_KP_Up: /* \033Ox or standard */ case XK_KP_Down: /* \033Or or standard */ @@ -359,8 +339,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,15 +352,15 @@ 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'; @@ -394,13 +374,13 @@ row = screen.cur.row + TermWin.saveLines; m = 0; if (keysym == XK_Right - && IS_MULTI1(screen.rend[row][col])) + && IS_MULTI1 (screen.rend[row][col])) m = 1; else if (keysym == XK_Left) { if (col > 0) { - if (IS_MULTI2(screen.rend[row][col - 1])) + if (IS_MULTI2 (screen.rend[row][col - 1])) m = 1; } else if (screen.cur.row > 0) @@ -411,12 +391,12 @@ else col--; if (col > 0 - && IS_MULTI2(screen.rend[row][col])) + && IS_MULTI2 (screen.rend[row][col])) m = 1; } } if (m) - MEMMOVE(kbuf + 3, kbuf, 3 + 1); + MEMMOVE (kbuf + 3, kbuf, 3 + 1); } #endif break; @@ -427,33 +407,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 +444,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 +482,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 +493,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 +587,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,7 +595,7 @@ break; } if (newlen) - len = STRLEN(kbuf); + len = STRLEN (kbuf); } /* * Pass meta for all function keys, if 'meta' option set @@ -644,10 +624,6 @@ meta = 0; } #endif -#ifdef GREEK_SUPPORT - if (greek_mode) - len = greek_xlat(kbuf, len); -#endif /* nil */ ; } } @@ -685,7 +661,7 @@ { const unsigned char ch = C0_ESC; - tt_write(&ch, 1); + tt_write (&ch, 1); } #ifdef DEBUG_CMD if (debug_key) @@ -693,10 +669,10 @@ char *p; int i; - fprintf(stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); + 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"); + fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); + fprintf (stderr, "'\n"); } #endif /* DEBUG_CMD */ tt_write (kbuf, (unsigned int)len); @@ -704,7 +680,7 @@ /*}}} */ #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) @@ -715,15 +691,15 @@ 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--;) @@ -755,7 +731,7 @@ } - XFlush (Xdisplay); + display->flush (); } void @@ -767,50 +743,6 @@ flush (); } -void -rxvt_term::process_x_events () -{ - do - { - XEvent xev; - - XNextEvent (Xdisplay, &xev); - -#if defined(CURSOR_BLINK) - if ((Options & Opt_cursorBlink) && xev.type == KeyPress) - { - if (hidden_cursor) - { - hidden_cursor = 0; - want_refresh = 1; - } - - cursor_blink_ev.start (NOW + BLINK_INTERVAL); - } -#endif - -#if defined(POINTER_BLANK) - if ((Options & Opt_pointerBlank) && pointerBlankDelay > 0) - { - if (xev.type == MotionNotify - || xev.type == ButtonPress - || xev.type == ButtonRelease) - if (hidden_pointer) - pointer_unblank (); - - if (xev.type == KeyPress && hidden_pointer == 0) - pointer_blank (); - } -#endif - -#ifdef USE_XIM - if (!XFilterEvent (&xev, xev.xany.window)) -#endif - process_x_event (&xev); - } - while (XPending (Xdisplay)); -} - #ifdef CURSOR_BLINK void rxvt_term::cursor_blink_cb (time_watcher &w) @@ -835,15 +767,6 @@ } #endif -void -rxvt_term::x_cb (io_watcher &w, short revents) -{ - SET_R (this); - SET_LOCALE (locale); - - process_x_events (); -} - bool rxvt_term::pty_fill () { @@ -924,7 +847,7 @@ nlines++; refresh_count++; - if (!(Options & Opt_jumpScroll) + if (! (Options & Opt_jumpScroll) || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) { refreshnow = true; @@ -932,6 +855,14 @@ 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) @@ -994,7 +925,7 @@ 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; @@ -1010,7 +941,7 @@ 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. @@ -1036,7 +967,7 @@ void rxvt_term::pointer_unblank () { - XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor); + XDefineCursor (display->display, TermWin.vt, TermWin_cursor); recolour_cursor (); hidden_pointer = 0; @@ -1048,11 +979,11 @@ void rxvt_term::pointer_blank () { - if (!(Options & Opt_pointerBlank)) + if (! (Options & Opt_pointerBlank)) return; - XDefineCursor (Xdisplay, TermWin.vt, blank_cursor); - XFlush (Xdisplay); + XDefineCursor (display->display, TermWin.vt, blank_cursor); + XFlush (display->display); hidden_pointer = 1; } @@ -1068,13 +999,13 @@ #endif void -rxvt_term::mouse_report (const XButtonEvent *ev) +rxvt_term::mouse_report (const XButtonEvent &ev) { int button_number, key_state = 0; int x, y; - x = ev->x; - y = ev->y; + x = ev.x; + y = ev.y; pixel_position (&x, &y); if (MEvent.button == AnyButton) @@ -1118,21 +1049,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)); @@ -1141,18 +1072,53 @@ #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 (); - process_x_event (ev); + x_cb (*ev); } #endif /*{{{ process an X event */ void -rxvt_term::process_x_event (XEvent *ev) +rxvt_term::x_cb (XEvent &ev) { + SET_R (this); + SET_LOCALE (locale); + +#if defined(CURSOR_BLINK) + if ((Options & Opt_cursorBlink) && ev.type == KeyPress) + { + if (hidden_cursor) + { + hidden_cursor = 0; + want_refresh = 1; + } + + cursor_blink_ev.start (NOW + BLINK_INTERVAL); + } +#endif + +#if defined(POINTER_BLANK) + if ((Options & Opt_pointerBlank) && pointerBlankDelay > 0) + { + if (ev.type == MotionNotify + || ev.type == ButtonPress + || ev.type == ButtonRelease) + if (hidden_pointer) + pointer_unblank (); + + if (ev.type == KeyPress && hidden_pointer == 0) + pointer_blank (); + } +#endif + +#ifdef USE_XIM + if (XFilterEvent (&ev, None)) + return; +#endif + Window unused_root, unused_child; int unused_root_x, unused_root_y; unsigned int unused_mask; @@ -1201,27 +1167,27 @@ #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) + switch (ev.type) { case KeyPress: - lookup_key ((XKeyEvent *)ev); + lookup_key (ev.xkey); break; #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(Xdisplay, 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; } @@ -1230,23 +1196,23 @@ #endif case ButtonPress: - button_press ((XButtonEvent *)ev); + button_press (ev.xbutton); break; case ButtonRelease: - button_release ((XButtonEvent *)ev); + button_release (ev.xbutton); break; case ClientMessage: - if (ev->xclient.format == 32 - && (Atom)ev->xclient.data.l[0] == xa[XA_WMDELETEWINDOW]) + if (ev.xclient.format == 32 + && (Atom)ev.xclient.data.l[0] == xa[XA_WMDELETEWINDOW]) destroy (); #ifdef OFFIX_DND /* OffiX Dnd (drag 'n' drop) protocol */ - else if (ev->xclient.message_type == xa[XA_DNDPROTOCOL] - && (ev->xclient.data.l[0] == DndFile - || ev->xclient.data.l[0] == DndDir - || ev->xclient.data.l[0] == DndLink)) + else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] + && (ev.xclient.data.l[0] == DndFile + || ev.xclient.data.l[0] == DndDir + || ev.xclient.data.l[0] == DndLink)) { /* Get Dnd data */ Atom ActualType; @@ -1254,25 +1220,25 @@ unsigned char *data; unsigned long Size, RemainingBytes; - XGetWindowProperty(Xdisplay, Xroot, + XGetWindowProperty (display->display, display->root, xa[XA_DNDSELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType, &ActualFormat, &Size, &RemainingBytes, &data); - XChangeProperty(Xdisplay, Xroot, + XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, - data, STRLEN(data)); - selection_paste (Xroot, XA_CUT_BUFFER0, True); - XSetInputFocus(Xdisplay, Xroot, RevertToNone, CurrentTime); + data, STRLEN (data)); + selection_paste (display->root, XA_CUT_BUFFER0, True); + XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); } #endif /* OFFIX_DND */ break; case MappingNotify: - XRefreshKeyboardMapping(&(ev->xmapping)); + XRefreshKeyboardMapping (& (ev.xmapping)); break; /* @@ -1286,7 +1252,7 @@ * which ought to make things real slow! */ case VisibilityNotify: - switch (ev->xvisibility.state) + switch (ev.xvisibility.state) { case VisibilityUnobscured: refresh_type = FAST_REFRESH; @@ -1307,7 +1273,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) @@ -1324,7 +1290,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) @@ -1336,27 +1302,27 @@ break; case ConfigureNotify: - if (ev->xconfigure.window == TermWin.parent[0]) + if (ev.xconfigure.window == TermWin.parent[0]) { - int height, width; + int height, width; do { /* Wrap lots of configures into one */ - width = ev->xconfigure.width; - height = ev->xconfigure.height; - D_SIZE((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); + width = ev.xconfigure.width; + height = ev.xconfigure.height; + D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); } - while (XCheckTypedWindowEvent(Xdisplay, 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 */ @@ -1372,17 +1338,17 @@ break; case SelectionClear: - selection_clear (); + display->set_selection_owner (0); break; case SelectionNotify: if (selection_wait == Sel_normal) - selection_paste (ev->xselection.requestor, - ev->xselection.property, True); + selection_paste (ev.xselection.requestor, + ev.xselection.property, True); break; case SelectionRequest: - selection_send (&(ev->xselectionrequest)); + selection_send (ev.xselectionrequest); break; case UnmapNotify: @@ -1399,73 +1365,47 @@ #endif break; - case PropertyNotify: - if (ev->xproperty.atom == xa[XA_VT_SELECTION]) - { - if (ev->xproperty.state == PropertyNewValue) - selection_property (ev->xproperty.window, - ev->xproperty.atom); - break; - } #ifdef TRANSPARENT - /* - * if user used some Esetroot compatible prog to set the root bg, - * use the property to determine the pixmap. We use it later on. - */ - if (xa[XA_XROOTPMAPID] == 0) - xa[XA_XROOTPMAPID] = XInternAtom(Xdisplay, - "_XROOTPMAP_ID", False); - if (ev->xproperty.atom != xa[XA_XROOTPMAPID]) - break; - /* FALLTHROUGH */ case ReparentNotify: - if ((Options & Opt_transparent) && check_our_parents ()) - { - if (am_transparent) - want_full_refresh = 1; - } -#endif /* TRANSPARENT */ + rootwin_cb (ev); break; +#endif /* TRANSPARENT */ case GraphicsExpose: case Expose: - if (ev->xany.window == TermWin.vt) + if (ev.xany.window == TermWin.vt) { #ifdef NO_SLOW_LINK_SUPPORT - scr_expose (ev->xexpose.x, ev->xexpose.y, - ev->xexpose.width, ev->xexpose.height, False); + scr_expose (ev.xexpose.x, ev.xexpose.y, + ev.xexpose.width, ev.xexpose.height, False); #else // don't understand this, so commented it out - scr_expose (ev->xexpose.x, ev->xexpose.y, - ev->xexpose.width, ev->xexpose.height, False); - //scr_expose (ev->xexpose.x, 0, - // ev->xexpose.width, TermWin.height, False); + scr_expose (ev.xexpose.x, ev.xexpose.y, + ev.xexpose.width, ev.xexpose.height, False); + //scr_expose (ev.xexpose.x, 0, + // ev.xexpose.width, TermWin.height, False); #endif want_refresh = 1; } else { - XEvent unused_xevent; + XEvent unused_event; - while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, + while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, - &unused_xevent)) ; - while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, + &unused_event)) ; + while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, - &unused_xevent)) ; - if (isScrollbarWindow(ev->xany.window)) + &unused_event)) ; + 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; @@ -1475,36 +1415,37 @@ 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) + if (ev.xany.window == TermWin.vt) { - if ((ev->xbutton.state & (Button1Mask | Button3Mask))) + if ((ev.xbutton.state & (Button1Mask | Button3Mask))) { - while (XCheckTypedWindowEvent(Xdisplay, TermWin.vt, - MotionNotify, ev)) ; - XQueryPointer(Xdisplay, TermWin.vt, + while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev)) + ; + + 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 */ - if ((ev->xmotion.time - MEvent.time) > MOUSE_THRESHOLD) + if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) { #endif - selection_extend ((ev->xbutton.x), (ev->xbutton.y), - (ev->xbutton.state & Button3Mask) ? 2 : 0); + selection_extend ((ev.xbutton.x), (ev.xbutton.y), + (ev.xbutton.state & Button3Mask) ? 2 : 0); #ifdef SELECTION_SCROLLING - if (ev->xbutton.y < TermWin.int_bwidth - || Pixel2Row(ev->xbutton.y) > (TermWin.nrow-1)) + if (ev.xbutton.y < TermWin.int_bwidth + || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) { int dist; @@ -1519,26 +1460,26 @@ /* save the event params so we can highlight * the selection in the pending-scroll loop */ - selection_save_x=ev->xbutton.x; - selection_save_y=ev->xbutton.y; + selection_save_x=ev.xbutton.x; + selection_save_y=ev.xbutton.y; selection_save_state= - (ev->xbutton.state & Button3Mask) ? 2 : 0; + (ev.xbutton.state & Button3Mask) ? 2 : 0; /* calc number of lines to scroll */ - if (ev->xbutton.yxbutton.y; + dist = TermWin.int_bwidth - ev.xbutton.y; } else { scroll_selection_dir = DN; - dist = ev->xbutton.y - + 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 @@ -1556,17 +1497,17 @@ } } - else if (isScrollbarWindow(ev->xany.window) && scrollbar_isMotion()) + else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) { - while (XCheckTypedWindowEvent(Xdisplay, scrollBar.win, - MotionNotify, ev)) ; - XQueryPointer(Xdisplay, scrollBar.win, + while (XCheckTypedWindowEvent (display->display, scrollBar.win, + MotionNotify, &ev)) ; + 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); @@ -1576,106 +1517,137 @@ } void -rxvt_term::button_press (XButtonEvent *ev) +rxvt_term::rootwin_cb (XEvent &ev) +{ + SET_R (this); + SET_LOCALE (locale); + + switch (ev.type) + { + case PropertyNotify: + if (ev.xproperty.atom == xa[XA_VT_SELECTION]) + { + if (ev.xproperty.state == PropertyNewValue) + selection_property (ev.xproperty.window, ev.xproperty.atom); + break; + } +#ifdef TRANSPARENT + else + { + /* + * if user used some Esetroot compatible prog to set the root bg, + * 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); + + if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) + return; + } + + /* FALLTHROUGH */ + case ReparentNotify: + if ((Options & Opt_transparent) && check_our_parents ()) + if (am_transparent) + want_full_refresh = 1; + break; +#endif + } +} + +void +rxvt_term::button_press (const XButtonEvent &ev) { int reportmode = 0, clickintime; - bypass_keystate = ev->state & (ModMetaMask | ShiftMask); + 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 (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 - MEvent.button = ev->button; + } + 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 (); /* @@ -1697,26 +1669,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) + 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; } } @@ -1728,16 +1700,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) @@ -1754,7 +1726,7 @@ } } else - switch (ev->button) + switch (ev.button) { case Button2: switch (scrollbar_align) @@ -1770,28 +1742,28 @@ 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; case Button1: if (scrollbar_align == R_SB_ALIGN_CENTRE) - csrO = ev->y - scrollBar.top; + csrO = ev.y - scrollBar.top; /* FALLTHROUGH */ 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 @@ -1802,10 +1774,10 @@ } else { - scr_page ((ev->button == Button1 ? DN : UP), + scr_page ((ev.button == Button1 ? DN : UP), (TermWin.nrow - * scrollbar_position(ev->y) - / scrollbar_size())); + * scrollbar_position (ev.y) + / scrollbar_size ())); } break; } @@ -1816,21 +1788,21 @@ /* * Menubar window processing of button press */ - if (isMenuBarWindow(ev->window)) + if (isMenuBarWindow (ev.window)) menubar_control (ev); #endif } void -rxvt_term::button_release (XButtonEvent *ev) +rxvt_term::button_release (const XButtonEvent &ev) { - int reportmode = 0; + 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); @@ -1842,99 +1814,91 @@ #ifdef SELECTION_SCROLLING pending_scroll_selection=0; #endif - if (ev->window == TermWin.vt) + 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 } @@ -1958,19 +1922,19 @@ pchanged = 0; - if (!(Options & Opt_transparent)) + if (! (Options & Opt_transparent)) return pchanged; /* Don't try any more */ - XGetWindowAttributes(Xdisplay, Xroot, &wrootattr); + XGetWindowAttributes (display->display, display->root, &wrootattr); rootdepth = wrootattr.depth; - XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr); + XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); if (rootdepth != wattr.depth) { if (am_transparent) { pchanged = 1; - XSetWindowBackground(Xdisplay, TermWin.vt, + XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); am_transparent = am_pixmap_trans = 0; } @@ -1978,7 +1942,7 @@ } /* Get all X ops out of the queue so that our information is up-to-date. */ - XSync(Xdisplay, False); + XSync (display->display, False); /* * Make the frame window set by the window manager have @@ -1986,7 +1950,7 @@ * windows for each client, so we have to take care about that. */ i = (xa[XA_XROOTPMAPID] != 0 - && (XGetWindowProperty(Xdisplay, Xroot, 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) @@ -1994,13 +1958,13 @@ else { have_pixmap = 1; - rootpixmap = *((Pixmap *)prop); - XFree(prop); + rootpixmap = * ((Pixmap *)prop); + XFree (prop); } if (have_pixmap) { /* - * Copy Xroot pixmap transparency + * Copy display->root pixmap transparency */ int sx, sy, nx, ny; unsigned int nw, nh; @@ -2009,7 +1973,7 @@ GC gc; XGCValues gcvalue; - XTranslateCoordinates(Xdisplay, TermWin.parent[0], Xroot, + XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 0, 0, &sx, &sy, &cr); nw = (unsigned int)szHint.width; nh = (unsigned int)szHint.height; @@ -2026,10 +1990,10 @@ 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(Xdisplay, 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? */ @@ -2041,7 +2005,7 @@ pchanged = 1; if (TermWin.pixmap != None) { - XFreePixmap(Xdisplay, TermWin.pixmap); + XFreePixmap (display->display, TermWin.pixmap); TermWin.pixmap = None; } } @@ -2050,18 +2014,18 @@ else { if (TermWin.pixmap != None) - XFreePixmap(Xdisplay, TermWin.pixmap); - TermWin.pixmap = XCreatePixmap(Xdisplay, 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(Xdisplay, TermWin.vt, 0UL, &gcvalue); - XPutImage(Xdisplay, 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(Xdisplay, gc); - XDestroyImage(image); - XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt, + XFreeGC (display->display, gc); + XDestroyImage (image); + XSetWindowBackgroundPixmap (display->display, TermWin.vt, TermWin.pixmap); if (!am_transparent || !am_pixmap_trans) pchanged = 1; @@ -2074,16 +2038,16 @@ /* * InheritPixmap transparency */ - D_X((stderr, "InheritPixmap Seeking to %08lx", Xroot)); - 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(Xdisplay, 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])); - if (TermWin.parent[i] == Xroot) + XFree (list); + D_X ((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i])); + if (TermWin.parent[i] == display->root) { if (oldp != None) pchanged = 1; @@ -2097,22 +2061,22 @@ { for (; n < (unsigned int)i; n++) { - XGetWindowAttributes(Xdisplay, 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(Xdisplay, TermWin.parent[0], + D_X ((stderr, "InheritPixmap Turning off")); + XSetWindowBackground (display->display, TermWin.parent[0], PixColors[Color_fg]); - XSetWindowBackground(Xdisplay, TermWin.vt, + XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); am_transparent = 0; /* XXX: also turn off Opt_transparent? */ @@ -2126,19 +2090,19 @@ 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(Xdisplay, TermWin.parent[n], + XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); - XSetWindowBackgroundPixmap(Xdisplay, 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; @@ -2153,10 +2117,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; } @@ -2164,7 +2128,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); */ @@ -2197,7 +2161,7 @@ if ((ch = cmd_getc ()) != C0_ESC) { - if (putc(ch, fd) == EOF) + if (putc (ch, fd) == EOF) break; /* done = 1 */ } else @@ -2219,7 +2183,7 @@ } } for (i = 0; i < len; i++) - if (putc(buf[i], fd) == EOF) + if (putc (buf[i], fd) == EOF) { done = 1; break; @@ -2249,12 +2213,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 (); @@ -2326,10 +2290,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 */ @@ -2398,7 +2362,7 @@ #endif case '=': case '>': - PrivMode((ch == '='), PrivMode_aplKP); + PrivMode ((ch == '='), PrivMode_aplKP); break; case C1_40: @@ -2444,8 +2408,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 */ @@ -2495,18 +2459,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* */ @@ -2531,7 +2495,7 @@ /* read any numerical arguments */ for (n = -1; ch < CSI_ICH; ) { - if (isdigit(ch)) + if (isdigit (ch)) { if (n < 0) n = ch - '0'; @@ -2567,16 +2531,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 /* @@ -2588,7 +2552,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') @@ -2601,7 +2565,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 */ @@ -2707,8 +2671,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 */ @@ -2719,14 +2683,14 @@ 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 */ @@ -2807,7 +2771,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: @@ -2836,65 +2800,65 @@ * commands */ case 1: /* deiconify window */ - XMapWindow(Xdisplay, TermWin.parent[0]); + XMapWindow (display->display, TermWin.parent[0]); break; case 2: /* iconify window */ - XIconifyWindow(Xdisplay, TermWin.parent[0], - DefaultScreen(Xdisplay)); + XIconifyWindow (display->display, TermWin.parent[0], + DefaultScreen (display->display)); break; case 3: /* set position (pixels) */ - XMoveWindow(Xdisplay, 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(Xdisplay, TermWin.parent[0]); + XRaiseWindow (display->display, TermWin.parent[0]); break; case 6: /* lower window */ - XLowerWindow(Xdisplay, 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(Xdisplay, 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(Xdisplay, TermWin.parent[0], &wattr); - XTranslateCoordinates(Xdisplay, 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(Xdisplay, 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(Xdisplay, 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(Xdisplay, 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 @@ -2905,7 +2869,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) @@ -2930,15 +2894,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; } @@ -2955,7 +2919,7 @@ */ s = get_to_st (&eh); if (s) - free(s); + free (s); return; } @@ -2970,7 +2934,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 == ';') @@ -2979,7 +2943,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) @@ -2990,7 +2954,7 @@ #endif else xterm_seq (arg, (char *)s, eh); - free(s); + free (s); } } } @@ -3009,6 +2973,7 @@ * 50 = change font * * rxvt extensions: + * 9 = change locale (NYI) * 10 = menu (may change in future) * 20 = bg pixmap * 39 = change default fg color @@ -3016,13 +2981,13 @@ * 55 = dump scrollback buffer and all of screen */ 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: @@ -3037,13 +3002,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); } @@ -3070,7 +3035,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; @@ -3083,7 +3048,7 @@ #endif scr_touch (true); } - while ((str = STRCHR(str, ';')) != NULL) + while ((str = STRCHR (str, ';')) != NULL) { str++; #if XPM_BACKGROUND @@ -3109,16 +3074,19 @@ case XTerm_logfile: break; case XTerm_font: - change_font (0, str); + change_font (str); + break; + case XTerm_locale: + /* TODO */ break; #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; @@ -3153,15 +3121,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; @@ -3214,7 +3182,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); @@ -3232,7 +3200,7 @@ scr_cursor (SAVE); /* FALLTHROUGH */ default: - continue; /* for(;i;) */ + continue; /* for (;i;) */ } /* extra handling for values with valid 0 or 1 state */ @@ -3244,11 +3212,11 @@ * parameter. Return from VT52 mode with an ESC < from * within VT52 mode */ - PrivMode(1, PrivMode_vt52); + PrivMode (1, PrivMode_vt52); break; case 3: /* 80/132 */ if (PrivateModes & PrivMode_132OK) - set_widthheight ( (unsigned int)((state ? 132 : 80) * TermWin.fwidth), + set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth), (unsigned int)TermWin.height); break; case 4: /* smooth scrolling */ @@ -3269,7 +3237,7 @@ /* case 8: - auto repeat, can't do on a per window basis */ case 9: /* X10 mouse reporting */ if (state) /* orthogonal */ - PrivateModes &= ~(PrivMode_MouseX11); + PrivateModes &= ~ (PrivMode_MouseX11); break; #ifdef menuBar_esc case menuBar_esc: @@ -3299,7 +3267,7 @@ /* case 67: - backspace key */ case 1000: /* X11 mouse reporting */ if (state) /* orthogonal */ - PrivateModes &= ~(PrivMode_MouseX10); + PrivateModes &= ~ (PrivMode_MouseX10); break; #if 0 case 1001: @@ -3379,7 +3347,7 @@ if (rendset != -1) { scr_rendition (rendset, rendstyle); - continue; /* for(;i;) */ + continue; /* for (;i;) */ } switch (arg[i]) @@ -3392,14 +3360,14 @@ case 35: case 36: case 37: - scr_color ((unsigned int)(minCOLOR + (arg[i] - 30)), + 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]), + scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); i += 2; } @@ -3417,14 +3385,14 @@ case 45: case 46: case 47: - scr_color ((unsigned int)(minCOLOR + (arg[i] - 40)), + 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]), + scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); i += 2; } @@ -3443,7 +3411,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: @@ -3454,7 +3422,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 @@ -3470,68 +3438,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