From: pcg Date: Sat, 31 Jan 2004 00:20:20 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=966e42e163be9fe90bf6baf5b88c0838b635333a;p=dana%2Furxvt.git *** empty log message *** --- diff --git a/Changes b/Changes index f71e30ec..2e48883e 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ +1.8 + - almost total conversion to C++. Except for introducing + new bugs, this should not change much. + 1.7 Fri Jan 30 16:50:11 CET 2004 - further cleanups. - never do last-minute-changes: restore ability to have diff --git a/autoconf/configure.in b/autoconf/configure.in index c20683f2..97ca1dbd 100644 --- a/autoconf/configure.in +++ b/autoconf/configure.in @@ -1204,7 +1204,7 @@ if test x$codesets = xall; then codesets=jp,jp-ext,kr,cn,cn-ext,vn fi for codeset in `echo $codesets | tr "[a-z,\\-]" "[A-Z _]"`; do - AC_DEFINE(ENCODING_EU, 1, Define if you want europeean extended codesets) + AC_DEFINE(ENCODING_EU, 1, Define if you want european extended codesets) case "$codeset" in VN ) AC_DEFINE(ENCODING_VN, 1, Define if you want vietnamese codesets) ;; JP ) AC_DEFINE(ENCODING_JP, 1, Define if you want japanese codesets) ;; diff --git a/src/command.C b/src/command.C index e58c091c..0201d0ca 100644 --- a/src/command.C +++ b/src/command.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: command.c *----------------------------------------------------------------------* - * $Id: command.C,v 1.33 2004-01-30 18:12:17 pcg Exp $ + * $Id: command.C,v 1.34 2004-01-31 00:20:21 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -55,9 +55,8 @@ /*----------------------------------------------------------------------*/ /*{{{ Convert the keypress event into a string */ -/* INTPROTO */ void -rxvt_lookup_key(pR_ XKeyEvent *ev) +rxvt_term::lookup_key (XKeyEvent *ev) { int ctrl, meta, shft, len; unsigned int newlen; @@ -76,24 +75,24 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) */ shft = (ev->state & ShiftMask); ctrl = (ev->state & ControlMask); - meta = (ev->state & R->ModMetaMask); + meta = (ev->state & ModMetaMask); - if (R->numlock_state || (ev->state & R->ModNumLockMask)) + if (numlock_state || (ev->state & ModNumLockMask)) { - R->numlock_state = (ev->state & R->ModNumLockMask); - PrivMode((!R->numlock_state), PrivMode_aplKP); + numlock_state = (ev->state & ModNumLockMask); + PrivMode((!numlock_state), PrivMode_aplKP); } kbuf[0] = 0; #ifdef USE_XIM - if (R->Input_Context) + if (Input_Context) { Status status_return; #ifdef X_HAVE_UTF8_STRING - if (R->enc_utf8 && 0) - len = Xutf8LookupString (R->Input_Context, ev, (char *)kbuf, + if (enc_utf8 && 0) + len = Xutf8LookupString (Input_Context, ev, (char *)kbuf, KBUFSZ, &keysym, &status_return); else #endif @@ -102,13 +101,13 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) // the XOpenIM manpage lies about hardcoding the locale // at the point of XOpenIM, so temporarily switch locales - if (R->rs[Rs_imLocale]) - SET_LOCALE (R->rs[Rs_imLocale]); + if (rs[Rs_imLocale]) + SET_LOCALE (rs[Rs_imLocale]); // assume wchar_t == unicode or better - len = XwcLookupString (R->Input_Context, ev, wkbuf, + len = XwcLookupString (Input_Context, ev, wkbuf, KBUFSZ, &keysym, &status_return); - if (R->rs[Rs_imLocale]) - SET_LOCALE (R->locale); + if (rs[Rs_imLocale]) + SET_LOCALE (locale); if (status_return == XLookupChars || status_return == XLookupBoth) @@ -128,7 +127,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) else #endif { - len = XLookupString (ev, (char *)kbuf, KBUFSZ, &keysym, &R->compose); + len = XLookupString (ev, (char *)kbuf, KBUFSZ, &keysym, &compose); valid_keysym = !len; } @@ -142,20 +141,20 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) if (meta) # endif { - if (keysym == R->ks_bigfont) + if (keysym == ks_bigfont) { - rxvt_change_font(aR_ 0, FONT_UP); + change_font (0, FONT_UP); return; } - else if (keysym == R->ks_smallfont) + else if (keysym == ks_smallfont) { - rxvt_change_font(aR_ 0, FONT_DN); + change_font (0, FONT_DN); return; } } #endif - if (R->TermWin.saveLines) { + if (TermWin.saveLines) { #ifdef UNSHIFTED_SCROLLKEYS if (!ctrl && !meta) { #else @@ -164,25 +163,25 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) int lnsppg; #ifdef PAGING_CONTEXT_LINES - lnsppg = R->TermWin.nrow - PAGING_CONTEXT_LINES; + lnsppg = TermWin.nrow - PAGING_CONTEXT_LINES; #else - lnsppg = R->TermWin.nrow * 4 / 5; + lnsppg = TermWin.nrow * 4 / 5; #endif if (keysym == XK_Prior) { - rxvt_scr_page(aR_ UP, lnsppg); + scr_page (UP, lnsppg); return; } else if (keysym == XK_Next) { - rxvt_scr_page(aR_ DN, lnsppg); + scr_page (DN, lnsppg); return; } } #ifdef SCROLL_ON_UPDOWN_KEYS if (IS_SCROLL_MOD) { if (keysym == XK_Up) { - rxvt_scr_page(aR_ UP, 1); + scr_page (UP, 1); return; } else if (keysym == XK_Down) { - rxvt_scr_page(aR_ DN, 1); + scr_page (DN, 1); return; } } @@ -190,10 +189,10 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) #ifdef SCROLL_ON_HOMEEND_KEYS if (IS_SCROLL_MOD) { if (keysym == XK_Home) { - rxvt_scr_move_to(aR_ 0, 1); + scr_move_to (0, 1); return; } else if (keysym == XK_End) { - rxvt_scr_move_to(aR_ 1, 0); + scr_move_to (1, 0); return; } } @@ -205,59 +204,59 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) if (keysym >= XK_F1 && keysym <= XK_F10) { keysym += (XK_F11 - XK_F1); shft = 0; /* turn off Shift */ - } else if (!ctrl && !meta && (R->PrivateModes & PrivMode_ShiftKeys)) { + } else if (!ctrl && !meta && (PrivateModes & PrivMode_ShiftKeys)) { switch (keysym) { /* normal XTerm key bindings */ case XK_Insert: /* Shift+Insert = paste mouse selection */ - rxvt_selection_request(aR_ ev->time, 0, 0); + selection_request (ev->time, 0, 0); return; /* rxvt extras */ case XK_KP_Add: /* Shift+KP_Add = bigger font */ - rxvt_change_font(aR_ 0, FONT_UP); + change_font (0, FONT_UP); return; case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ - rxvt_change_font(aR_ 0, FONT_DN); + change_font (0, FONT_DN); return; } } } #ifdef PRINTPIPE if (keysym == XK_Print) { - rxvt_scr_printscreen(aR_ ctrl | shft); + scr_printscreen (ctrl | shft); return; } #endif #ifdef GREEK_SUPPORT - if (keysym == R->ks_greekmodeswith) { - R->greek_mode = !R->greek_mode; - if (R->greek_mode) { - rxvt_xterm_seq(aR_ XTerm_title, + 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 - rxvt_xterm_seq(aR_ XTerm_title, APL_NAME "-" VERSION, CHAR_ST); + xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); return; } #endif if (keysym >= 0xFF00 && keysym <= 0xFFFF) { #ifdef KEYSYM_RESOURCE - if (!(shft | ctrl) && R->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 = (R->Keysym_map[keysym & 0xFF]); + kbuf0 = (Keysym_map[keysym & 0xFF]); l = (unsigned int)*kbuf0++; /* escape prefix */ if (meta) # ifdef META8_OPTION - if (R->meta_char == C0_ESC) + if (meta_char == C0_ESC) # endif - R->tt_write (&ch, 1); - R->tt_write (kbuf0, l); + tt_write (&ch, 1); + tt_write (kbuf0, l); return; } else #endif @@ -266,20 +265,20 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) switch (keysym) { #ifndef NO_BACKSPACE_KEY case XK_BackSpace: - if (R->PrivateModes & PrivMode_HaveBackSpace) { - kbuf[0] = (!!(R->PrivateModes & PrivMode_BackSpace) + if (PrivateModes & PrivMode_HaveBackSpace) { + kbuf[0] = (!!(PrivateModes & PrivMode_BackSpace) ^ !!ctrl) ? '\b' : '\177'; kbuf[1] = '\0'; } else - STRCPY(kbuf, R->key_backspace); + STRCPY(kbuf, key_backspace); # ifdef MULTICHAR_SET - if ((R->Options & Opt_mc_hack) && R->screen.cur.col > 0) { + if ((Options & Opt_mc_hack) && screen.cur.col > 0) { int col, row; newlen = STRLEN(kbuf); - col = R->screen.cur.col - 1; - row = R->screen.cur.row + R->TermWin.saveLines; - if (IS_MULTI2(R->screen.rend[row][col])) + 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 @@ -287,15 +286,15 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) #endif #ifndef NO_DELETE_KEY case XK_Delete: - STRCPY(kbuf, R->key_delete); + STRCPY(kbuf, key_delete); # ifdef MULTICHAR_SET - if (R->Options & Opt_mc_hack) { + if (Options & Opt_mc_hack) { int col, row; newlen = STRLEN(kbuf); - col = R->screen.cur.col; - row = R->screen.cur.row + R->TermWin.saveLines; - if (IS_MULTI1(R->screen.rend[row][col])) + col = screen.cur.col; + row = screen.cur.row + TermWin.saveLines; + if (IS_MULTI1(screen.rend[row][col])) MEMMOVE(kbuf + newlen, kbuf, newlen + 1); } # endif @@ -323,7 +322,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) case XK_KP_Down: /* \033Or or standard */ case XK_KP_Right: /* \033Ov or standard */ case XK_KP_Left: /* \033Ot or standard */ - if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033OZ"); kbuf[2] = ("txvr"[keysym - XK_KP_Left]); break; @@ -344,31 +343,31 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) else if (ctrl) { kbuf[1] = 'O'; kbuf[2] = ("dacb"[keysym - XK_Left]); - } else if (R->PrivateModes & PrivMode_aplCUR) + } else if (PrivateModes & PrivMode_aplCUR) kbuf[1] = 'O'; #ifdef MULTICHAR_SET //TODO: ?? - if (R->Options & Opt_mc_hack) { + if (Options & Opt_mc_hack) { int col, row, m; - col = R->screen.cur.col; - row = R->screen.cur.row + R->TermWin.saveLines; + col = screen.cur.col; + row = screen.cur.row + TermWin.saveLines; m = 0; if (keysym == XK_Right - && IS_MULTI1(R->screen.rend[row][col])) + && IS_MULTI1(screen.rend[row][col])) m = 1; else if (keysym == XK_Left) { if (col > 0) { - if (IS_MULTI2(R->screen.rend[row][col - 1])) + if (IS_MULTI2(screen.rend[row][col - 1])) m = 1; - } else if (R->screen.cur.row > 0) { - col = R->screen.tlen[--row]; + } else if (screen.cur.row > 0) { + col = screen.tlen[--row]; if (col == -1) - col = R->TermWin.ncol - 1; + col = TermWin.ncol - 1; else col--; if (col > 0 - && IS_MULTI2(R->screen.rend[row][col])) + && IS_MULTI2(screen.rend[row][col])) m = 1; } } @@ -382,7 +381,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) # ifdef XK_KP_Prior case XK_KP_Prior: /* allow shift to override */ - if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033Oy"); break; } @@ -394,7 +393,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) # ifdef XK_KP_Next case XK_KP_Next: /* allow shift to override */ - if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033Os"); break; } @@ -406,7 +405,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) #endif case XK_KP_Enter: /* allow shift to override */ - if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033OM"); } else { kbuf[0] = '\r'; @@ -452,7 +451,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) case XK_KP_8: /* "\033Ox" : "8" */ case XK_KP_9: /* "\033Oy" : "9" */ /* allow shift to override */ - if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033Oj"); kbuf[2] += (keysym - XK_KP_Multiply); } else { @@ -480,7 +479,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) #ifdef XK_KP_End case XK_KP_End: /* allow shift to override */ - if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033Oq"); break; } @@ -492,7 +491,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) #ifdef XK_KP_Home case XK_KP_Home: /* allow shift to override */ - if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033Ow"); break; } @@ -568,7 +567,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) * Pass meta for all function keys, if 'meta' option set */ #ifdef META8_OPTION - if (meta && (R->meta_char == 0x80) && len > 0) + if (meta && (meta_char == 0x80) && len > 0) kbuf[len - 1] |= 0x80; #endif } else if (ctrl && keysym == XK_minus) { @@ -577,7 +576,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) } else { #ifdef META8_OPTION /* set 8-bit on */ - if (meta && (R->meta_char == 0x80)) { + if (meta && (meta_char == 0x80)) { unsigned char *ch; for (ch = kbuf; ch < kbuf + len; ch++) @@ -586,7 +585,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) } #endif #ifdef GREEK_SUPPORT - if (R->greek_mode) + if (greek_mode) len = greek_xlat(kbuf, len); #endif /* nil */ ; @@ -596,10 +595,10 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) if (len <= 0) return; /* not mapped */ - if (R->Options & Opt_scrollTtyKeypress) - if (R->TermWin.view_start) { - R->TermWin.view_start = 0; - R->want_refresh = 1; + if (Options & Opt_scrollTtyKeypress) + if (TermWin.view_start) { + TermWin.view_start = 0; + want_refresh = 1; } /* @@ -619,12 +618,12 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) /* escape prefix */ if (meta #ifdef META8_OPTION - && (R->meta_char == C0_ESC) + && (meta_char == C0_ESC) #endif ) { const unsigned char ch = C0_ESC; - R->tt_write(&ch, 1); + tt_write(&ch, 1); } #ifdef DEBUG_CMD if (debug_key) { /* Display keyboard buffer contents */ @@ -637,21 +636,17 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) fprintf(stderr, "'\n"); } #endif /* DEBUG_CMD */ - R->tt_write (kbuf, (unsigned int)len); + tt_write (kbuf, (unsigned int)len); } /*}}} */ #if (MENUBAR_MAX) /*{{{ rxvt_cmd_write(), rxvt_cmd_getc() */ /* attempt to `write' count to the input buffer */ -/* EXTPROTO */ unsigned int -rxvt_cmd_write(pR_ const unsigned char *str, unsigned int count) +rxvt_term::cmd_write (const unsigned char *str, unsigned int count) { unsigned int n, s; - unsigned char *cmdbuf_base = R->cmdbuf_base, - *cmdbuf_endp = R->cmdbuf_endp, - *cmdbuf_ptr = R->cmdbuf_ptr; n = cmdbuf_ptr - cmdbuf_base; s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; @@ -668,8 +663,6 @@ rxvt_cmd_write(pR_ const unsigned char *str, unsigned int count) } for (; count--;) *cmdbuf_endp++ = *str++; - R->cmdbuf_ptr = cmdbuf_ptr; - R->cmdbuf_endp = cmdbuf_endp; return 0; } #endif /* MENUBAR_MAX */ @@ -690,9 +683,9 @@ rxvt_term::flush () if (want_refresh) { scr_refresh (refresh_type); - rxvt_scrollbar_show (this, 1); + scrollbar_show (1); #ifdef USE_XIM - rxvt_IMSendSpot (this); + IMSendSpot (); #endif } @@ -747,7 +740,7 @@ rxvt_term::process_x_events () #ifdef USE_XIM if (!XFilterEvent (&xev, xev.xany.window)) #endif - rxvt_process_x_event (this, &xev); + process_x_event (&xev); } while (XPending (Xdisplay)); } @@ -883,7 +876,7 @@ rxvt_term::pty_cb (io_watcher &w, short revents) } } - rxvt_scr_add_lines (this, buf, nlines, str - buf); + scr_add_lines (buf, nlines, str - buf); /* * If there have been a lot of new lines, then update the screen @@ -908,13 +901,13 @@ rxvt_term::pty_cb (io_watcher &w, short revents) switch (ch) { default: - rxvt_process_nonprinting (this, ch); + process_nonprinting (ch); break; case C0_ESC: /* escape char */ - rxvt_process_escape_seq (this); + process_escape_seq (); break; /*case 0x9b: */ /* CSI */ - /* rxvt_process_csi_seq (this); */ + /* process_csi_seq (); */ } ch = NOCHAR; @@ -935,7 +928,7 @@ rxvt_term::next_char () return *cmdbuf_ptr++; wchar_t wc; - int 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.mbs); if (len == (size_t)-2) return NOCHAR; @@ -956,21 +949,20 @@ rxvt_term::next_char () * Return the next input character after first passing any keyboard input * to the command. */ -/* INTPROTO */ uint32_t -rxvt_cmd_getc(pR) +rxvt_term::cmd_getc () { for (;;) { - uint32_t c = R->next_char (); + uint32_t c = next_char (); if (c != NOCHAR) return c; // incomplete sequences should occur rarely, still, a better solution // would be preferred. either setjmp/longjmp or better design. - fcntl (R->cmd_fd, F_SETFL, 0); - R->pty_fill (); - fcntl (R->cmd_fd, F_SETFL, O_NONBLOCK); + fcntl (cmd_fd, F_SETFL, 0); + pty_fill (); + fcntl (cmd_fd, F_SETFL, O_NONBLOCK); } #if 0 @@ -986,49 +978,49 @@ rxvt_cmd_getc(pR) for (;;) { /* loop until we can return something */ - if (R->v_bufstr < R->v_bufptr) /* output any pending chars */ - R->tt_write(NULL, 0); + if (v_bufstr < v_bufptr) /* output any pending chars */ + tt_write(NULL, 0); #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) - if (R->mouse_slip_wheel_speed) { + if (mouse_slip_wheel_speed) { quick_timeout = 1; - if (!R->mouse_slip_wheel_delay-- - && rxvt_scr_page(aR_ R->mouse_slip_wheel_speed > 0 ? UP : DN, - abs(R->mouse_slip_wheel_speed))) { - R->mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; - R->refresh_type |= SMOOTH_REFRESH; - R->want_refresh = 1; + if (!mouse_slip_wheel_delay-- + && scr_page (mouse_slip_wheel_speed > 0 ? UP : DN, + abs(mouse_slip_wheel_speed))) { + mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; + refresh_type |= SMOOTH_REFRESH; + want_refresh = 1; } } #endif /* MOUSE_WHEEL && MOUSE_SLIP_WHEELING */ #ifdef SELECTION_SCROLLING - if (R->pending_scroll_selection) { + if (pending_scroll_selection) { quick_timeout = 1; - if (!R->scroll_selection_delay-- - && rxvt_scr_page(aR_ R->scroll_selection_dir, - R->scroll_selection_lines)) { - R->selection_extend (R->selection_save_x, - R->selection_save_y, R->selection_save_state); - R->scroll_selection_delay = SCROLLBAR_CONTINUOUS_DELAY; - R->refresh_type |= SMOOTH_REFRESH; - R->want_refresh = 1; + if (!scroll_selection_delay-- + && scr_page (scroll_selection_dir, + scroll_selection_lines)) { + selection_extend (selection_save_x, + selection_save_y, selection_save_state); + scroll_selection_delay = SCROLLBAR_CONTINUOUS_DELAY; + refresh_type |= SMOOTH_REFRESH; + want_refresh = 1; } } #endif #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING if (scrollbar_isUp() || scrollbar_isDn()) { quick_timeout = 1; - if (!R->scroll_arrow_delay-- - && rxvt_scr_page(aR_ scrollbar_isUp() ? UP : DN, 1)) { - R->scroll_arrow_delay = SCROLLBAR_CONTINUOUS_DELAY; - R->refresh_type |= SMOOTH_REFRESH; - R->want_refresh = 1; + if (!scroll_arrow_delay-- + && scr_page (scrollbar_isUp() ? UP : DN, 1)) { + scroll_arrow_delay = SCROLLBAR_CONTINUOUS_DELAY; + refresh_type |= SMOOTH_REFRESH; + want_refresh = 1; } } #endif /* NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING */ #ifdef TRANSPARENT - quick_timeout |= R->want_full_refresh; + quick_timeout |= want_full_refresh; #endif #endif } @@ -1068,27 +1060,26 @@ rxvt_term::pointer_cb (time_watcher &w) } #endif -/* INTPROTO */ void -rxvt_mouse_report(pR_ 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; - R->pixel_position (&x, &y); + pixel_position (&x, &y); - if (R->MEvent.button == AnyButton) { + if (MEvent.button == AnyButton) { button_number = 3; } else { - button_number = R->MEvent.button - Button1; + button_number = MEvent.button - Button1; /* add 0x3D for wheel events, like xterm does */ if (button_number >= 3) button_number += (64 - 3); } - if (R->PrivateModes & PrivMode_MouseX10) { + if (PrivateModes & PrivMode_MouseX10) { /* * do not report ButtonRelease * no state info allowed @@ -1104,11 +1095,11 @@ rxvt_mouse_report(pR_ const XButtonEvent *ev) * plus will add in our own Double-Click reporting * 32 = Double Click */ - key_state = ((R->MEvent.state & ShiftMask) ? 4 : 0) - + ((R->MEvent.state & R->ModMetaMask) ? 8 : 0) - + ((R->MEvent.state & ControlMask) ? 16 : 0); + key_state = ((MEvent.state & ShiftMask) ? 4 : 0) + + ((MEvent.state & ModMetaMask) ? 8 : 0) + + ((MEvent.state & ControlMask) ? 16 : 0); #ifdef MOUSE_REPORT_DOUBLECLICK - key_state += ((R->MEvent.clicks > 1) ? 32 : 0); + key_state += ((MEvent.clicks > 1) ? 32 : 0); #endif } @@ -1127,7 +1118,7 @@ rxvt_mouse_report(pR_ const XButtonEvent *ev) x + 1, y + 1); #else - R->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)); @@ -1135,22 +1126,19 @@ rxvt_mouse_report(pR_ const XButtonEvent *ev) } #ifdef USING_W11LIB -/* EXTPROTO */ void rxvt_W11_process_x_event(XEvent *ev) { rxvt_t *r = rxvt_get_r(); - rxvt_process_x_event(aR_ ev); + process_x_event (ev); } #endif /*{{{ process an X event */ -/* INTPROTO */ void -rxvt_process_x_event(pR_ XEvent *ev) +rxvt_term::process_x_event (XEvent *ev) { - int i, want_timeout; Window unused_root, unused_child; int unused_root_x, unused_root_y; unsigned int unused_mask; @@ -1201,45 +1189,45 @@ rxvt_process_x_event(pR_ XEvent *ev) 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 == R->TermWin.parent[0] ? "parent" : (ev->xany.window == R->TermWin.vt ? "vt" : (ev->xany.window == R->scrollBar.win ? "scroll" : (ev->xany.window == R->menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == R->TermWin.parent[0] ? R->TermWin.parent[0] : (ev->xany.window == R->TermWin.vt ? R->TermWin.vt : (ev->xany.window == R->scrollBar.win ? R->scrollBar.win : (ev->xany.window == R->menuBar.win ? R->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)); + 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) { case KeyPress: - rxvt_lookup_key(aR_ (XKeyEvent *)ev); + lookup_key ((XKeyEvent *)ev); break; #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) case KeyRelease: { if (!(ev->xkey.state & ControlMask)) - R->mouse_slip_wheel_speed = 0; + mouse_slip_wheel_speed = 0; else { KeySym ks; - ks = XKeycodeToKeysym(R->Xdisplay, ev->xkey.keycode, 0); + ks = XKeycodeToKeysym(Xdisplay, ev->xkey.keycode, 0); if (ks == XK_Control_L || ks == XK_Control_R) - R->mouse_slip_wheel_speed = 0; + mouse_slip_wheel_speed = 0; } break; } #endif case ButtonPress: - rxvt_button_press(aR_ (XButtonEvent *)ev); + button_press ((XButtonEvent *)ev); break; case ButtonRelease: - rxvt_button_release(aR_ (XButtonEvent *)ev); + button_release ((XButtonEvent *)ev); break; case ClientMessage: if (ev->xclient.format == 32 - && (Atom)ev->xclient.data.l[0] == R->xa[XA_WMDELETEWINDOW]) - R->destroy (); + && (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 == R->xa[XA_DNDPROTOCOL] + 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)) { @@ -1249,19 +1237,19 @@ rxvt_process_x_event(pR_ XEvent *ev) unsigned char *data; unsigned long Size, RemainingBytes; - XGetWindowProperty(R->Xdisplay, Xroot, - R->xa[XA_DNDSELECTION], + XGetWindowProperty(Xdisplay, Xroot, + xa[XA_DNDSELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType, &ActualFormat, &Size, &RemainingBytes, &data); - XChangeProperty(R->Xdisplay, Xroot, + XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, STRLEN(data)); - rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, True); - XSetInputFocus(R->Xdisplay, Xroot, RevertToNone, CurrentTime); + selection_paste (Xroot, XA_CUT_BUFFER0, True); + XSetInputFocus(Xdisplay, Xroot, RevertToNone, CurrentTime); } #endif /* OFFIX_DND */ break; @@ -1284,61 +1272,61 @@ rxvt_process_x_event(pR_ XEvent *ev) switch (ev->xvisibility.state) { case VisibilityUnobscured: - R->refresh_type = FAST_REFRESH; + refresh_type = FAST_REFRESH; break; case VisibilityPartiallyObscured: - R->refresh_type = SLOW_REFRESH; + refresh_type = SLOW_REFRESH; break; default: - R->refresh_type = NO_REFRESH; + refresh_type = NO_REFRESH; break; } break; case FocusIn: - if (!R->TermWin.focus) { - R->TermWin.focus = 1; - R->want_refresh = 1; + if (!TermWin.focus) { + TermWin.focus = 1; + want_refresh = 1; #ifdef USE_XIM - if (R->Input_Context != NULL) - XSetICFocus(R->Input_Context); + if (Input_Context != NULL) + XSetICFocus(Input_Context); #endif #ifdef CURSOR_BLINK - if (R->Options & Opt_cursorBlink) - R->cursor_blink_ev.start (NOW + BLINK_INTERVAL); + if (Options & Opt_cursorBlink) + cursor_blink_ev.start (NOW + BLINK_INTERVAL); #endif } break; case FocusOut: - if (R->TermWin.focus) { - R->TermWin.focus = 0; - R->want_refresh = 1; + if (TermWin.focus) { + TermWin.focus = 0; + want_refresh = 1; #ifdef USE_XIM - if (R->Input_Context != NULL) - XUnsetICFocus(R->Input_Context); + if (Input_Context != NULL) + XUnsetICFocus(Input_Context); #endif #ifdef CURSOR_BLINK - if (R->Options & Opt_cursorBlink) - R->cursor_blink_ev.stop (); - R->hidden_cursor = 0; + if (Options & Opt_cursorBlink) + cursor_blink_ev.stop (); + hidden_cursor = 0; #endif } break; case ConfigureNotify: - if (ev->xconfigure.window == R->TermWin.parent[0]) { + if (ev->xconfigure.window == TermWin.parent[0]) { 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)); - } while (XCheckTypedWindowEvent(R->Xdisplay, ev->xconfigure.window, + } while (XCheckTypedWindowEvent(Xdisplay, ev->xconfigure.window, ConfigureNotify, ev)); - if (R->szHint.width != width || R->szHint.height != height) { - D_SIZE((stderr, "Size: Resizing from: %4d x %4d", R->szHint.width, R->szHint.height)); - R->resize_all_windows (width, height, 1); + if (szHint.width != width || szHint.height != height) { + D_SIZE((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height)); + resize_all_windows (width, height, 1); } #ifdef DEBUG_SIZE else { @@ -1346,47 +1334,47 @@ rxvt_process_x_event(pR_ XEvent *ev) } #endif #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ - if (R->Options & Opt_transparent) { - rxvt_check_our_parents(aR); - if (R->am_transparent) - R->want_full_refresh = 1; + if (Options & Opt_transparent) { + check_our_parents (); + if (am_transparent) + want_full_refresh = 1; } #endif } break; case SelectionClear: - rxvt_selection_clear(aR); + selection_clear (); break; case SelectionNotify: - if (R->selection_wait == Sel_normal) - rxvt_selection_paste(aR_ ev->xselection.requestor, + if (selection_wait == Sel_normal) + selection_paste (ev->xselection.requestor, ev->xselection.property, True); break; case SelectionRequest: - rxvt_selection_send(aR_ &(ev->xselectionrequest)); + selection_send (&(ev->xselectionrequest)); break; case UnmapNotify: - R->TermWin.mapped = 0; + TermWin.mapped = 0; #ifdef TEXT_BLINK - R->text_blink_ev.stop (); + text_blink_ev.stop (); #endif break; case MapNotify: - R->TermWin.mapped = 1; + TermWin.mapped = 1; #ifdef TEXT_BLINK - R->text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); + text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); #endif break; case PropertyNotify: - if (ev->xproperty.atom == R->xa[XA_VT_SELECTION]) { + if (ev->xproperty.atom == xa[XA_VT_SELECTION]) { if (ev->xproperty.state == PropertyNewValue) - rxvt_selection_property(aR_ ev->xproperty.window, + selection_property (ev->xproperty.window, ev->xproperty.atom); break; } @@ -1395,127 +1383,127 @@ rxvt_process_x_event(pR_ XEvent *ev) * 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 (R->xa[XA_XROOTPMAPID] == 0) - R->xa[XA_XROOTPMAPID] = XInternAtom(R->Xdisplay, + if (xa[XA_XROOTPMAPID] == 0) + xa[XA_XROOTPMAPID] = XInternAtom(Xdisplay, "_XROOTPMAP_ID", False); - if (ev->xproperty.atom != R->xa[XA_XROOTPMAPID]) + if (ev->xproperty.atom != xa[XA_XROOTPMAPID]) break; /* FALLTHROUGH */ case ReparentNotify: - if ((R->Options & Opt_transparent) && rxvt_check_our_parents(aR)) { - if (R->am_transparent) - R->want_full_refresh = 1; + if ((Options & Opt_transparent) && check_our_parents ()) { + if (am_transparent) + want_full_refresh = 1; } #endif /* TRANSPARENT */ break; case GraphicsExpose: case Expose: - if (ev->xany.window == R->TermWin.vt) { + if (ev->xany.window == TermWin.vt) { #ifdef NO_SLOW_LINK_SUPPORT - R->scr_expose (ev->xexpose.x, ev->xexpose.y, + scr_expose (ev->xexpose.x, ev->xexpose.y, ev->xexpose.width, ev->xexpose.height, False); #else // don't understand this, so commented it out - R->scr_expose (ev->xexpose.x, ev->xexpose.y, + scr_expose (ev->xexpose.x, ev->xexpose.y, ev->xexpose.width, ev->xexpose.height, False); - //rxvt_scr_expose(aR_ ev->xexpose.x, 0, - // ev->xexpose.width, R->TermWin.height, False); + //scr_expose (ev->xexpose.x, 0, + // ev->xexpose.width, TermWin.height, False); #endif - R->want_refresh = 1; + want_refresh = 1; } else { XEvent unused_xevent; - while (XCheckTypedWindowEvent(R->Xdisplay, ev->xany.window, + while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, Expose, &unused_xevent)) ; - while (XCheckTypedWindowEvent(R->Xdisplay, ev->xany.window, + while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, GraphicsExpose, &unused_xevent)) ; if (isScrollbarWindow(ev->xany.window)) { - R->scrollBar.setIdle(); - rxvt_scrollbar_show(aR_ 0); + scrollBar.setIdle(); + scrollbar_show (0); } #ifdef MENUBAR - if (menubar_visible(aR) && isMenuBarWindow(ev->xany.window)) - rxvt_menubar_expose(aR); + if (menubar_visible () && isMenuBarWindow(ev->xany.window)) + menubar_expose (); #endif #ifdef RXVT_GRAPHICS - rxvt_Gr_expose(aR_ ev->xany.window); + Gr_expose (ev->xany.window); #endif } break; case MotionNotify: #ifdef POINTER_BLANK - if (R->hidden_pointer) - R->pointer_unblank (); + if (hidden_pointer) + pointer_unblank (); #endif #if MENUBAR if (isMenuBarWindow(ev->xany.window)) { - rxvt_menubar_control(aR_ &(ev->xbutton)); + menubar_control (&(ev->xbutton)); break; } #endif - if ((R->PrivateModes & PrivMode_mouse_report) && !(R->bypass_keystate)) + if ((PrivateModes & PrivMode_mouse_report) && !(bypass_keystate)) break; - if (ev->xany.window == R->TermWin.vt) { + if (ev->xany.window == TermWin.vt) { if ((ev->xbutton.state & (Button1Mask | Button3Mask))) { - while (XCheckTypedWindowEvent(R->Xdisplay, R->TermWin.vt, + while (XCheckTypedWindowEvent(Xdisplay, TermWin.vt, MotionNotify, ev)) ; - XQueryPointer(R->Xdisplay, R->TermWin.vt, + XQueryPointer(Xdisplay, TermWin.vt, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); #ifdef MOUSE_THRESHOLD /* deal with a `jumpy' mouse */ - if ((ev->xmotion.time - R->MEvent.time) > MOUSE_THRESHOLD) { + if ((ev->xmotion.time - MEvent.time) > MOUSE_THRESHOLD) { #endif - R->selection_extend ((ev->xbutton.x), (ev->xbutton.y), + selection_extend ((ev->xbutton.x), (ev->xbutton.y), (ev->xbutton.state & Button3Mask) ? 2 : 0); #ifdef SELECTION_SCROLLING - if (ev->xbutton.y < R->TermWin.int_bwidth - || Pixel2Row(ev->xbutton.y) > (R->TermWin.nrow-1)) { + if (ev->xbutton.y < TermWin.int_bwidth + || Pixel2Row(ev->xbutton.y) > (TermWin.nrow-1)) { int dist; - R->pending_scroll_selection=1; + pending_scroll_selection=1; /* don't clobber the current delay if we are * already in the middle of scrolling. */ - if (R->scroll_selection_delay<=0) - R->scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY; + if (scroll_selection_delay<=0) + scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY; /* save the event params so we can highlight * the selection in the pending-scroll loop */ - R->selection_save_x=ev->xbutton.x; - R->selection_save_y=ev->xbutton.y; - R->selection_save_state= + selection_save_x=ev->xbutton.x; + selection_save_y=ev->xbutton.y; + selection_save_state= (ev->xbutton.state & Button3Mask) ? 2 : 0; /* calc number of lines to scroll */ - if (ev->xbutton.yTermWin.int_bwidth) { - R->scroll_selection_dir = UP; - dist = R->TermWin.int_bwidth - ev->xbutton.y; + if (ev->xbutton.yxbutton.y; } else { - R->scroll_selection_dir = DN; + scroll_selection_dir = DN; dist = ev->xbutton.y - - (R->TermWin.int_bwidth + R->TermWin.height); + (TermWin.int_bwidth + TermWin.height); } - R->scroll_selection_lines=(Pixel2Height(dist)/ + scroll_selection_lines=(Pixel2Height(dist)/ SELECTION_SCROLL_LINE_SPEEDUP)+1; - MIN_IT(R->scroll_selection_lines, + MIN_IT(scroll_selection_lines, SELECTION_SCROLL_MAX_LINES); } else { /* we are within the text window, so we * shouldn't be scrolling */ - R->pending_scroll_selection = 0; + pending_scroll_selection = 0; } #endif #ifdef MOUSE_THRESHOLD @@ -1523,36 +1511,35 @@ rxvt_process_x_event(pR_ XEvent *ev) #endif } } else if (isScrollbarWindow(ev->xany.window) && scrollbar_isMotion()) { - while (XCheckTypedWindowEvent(R->Xdisplay, R->scrollBar.win, + while (XCheckTypedWindowEvent(Xdisplay, scrollBar.win, MotionNotify, ev)) ; - XQueryPointer(R->Xdisplay, R->scrollBar.win, + XQueryPointer(Xdisplay, scrollBar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); - rxvt_scr_move_to(aR_ scrollbar_position(ev->xbutton.y) - R->csrO, + scr_move_to (scrollbar_position(ev->xbutton.y) - csrO, scrollbar_size()); - R->scr_refresh (R->refresh_type); - R->refresh_limit = 0; - rxvt_scrollbar_show(aR_ 1); + scr_refresh (refresh_type); + refresh_limit = 0; + scrollbar_show (1); } break; } } -/* INTPROTO */ void -rxvt_button_press(pR_ XButtonEvent *ev) +rxvt_term::button_press (XButtonEvent *ev) { int reportmode = 0, clickintime; - R->bypass_keystate = ev->state & (R->ModMetaMask | ShiftMask); - if (!R->bypass_keystate) - reportmode = !!(R->PrivateModes & PrivMode_mouse_report); + bypass_keystate = ev->state & (ModMetaMask | ShiftMask); + if (!bypass_keystate) + reportmode = !!(PrivateModes & PrivMode_mouse_report); /* * VT window processing of button press */ - if (ev->window == R->TermWin.vt) + if (ev->window == TermWin.vt) { #if RXVT_GRAPHICS if (ev->subwindow != None) @@ -1560,78 +1547,78 @@ rxvt_button_press(pR_ XButtonEvent *ev) else #endif { - clickintime = ev->time - R->MEvent.time < MULTICLICK_TIME; + clickintime = ev->time - MEvent.time < MULTICLICK_TIME; if (reportmode) { /* mouse report from vt window */ /* save the xbutton state (for ButtonRelease) */ - R->MEvent.state = ev->state; + MEvent.state = ev->state; #ifdef MOUSE_REPORT_DOUBLECLICK - if (ev->button == R->MEvent.button && clickintime) + if (ev->button == MEvent.button && clickintime) { /* same button, within alloted time */ - R->MEvent.clicks++; - if (R->MEvent.clicks > 1) + MEvent.clicks++; + if (MEvent.clicks > 1) { /* only report double clicks */ - R->MEvent.clicks = 2; - rxvt_mouse_report(aR_ ev); + MEvent.clicks = 2; + mouse_report (ev); /* don't report the release */ - R->MEvent.clicks = 0; - R->MEvent.button = AnyButton; + MEvent.clicks = 0; + MEvent.button = AnyButton; } } else { /* different button, or time expired */ - R->MEvent.clicks = 1; - R->MEvent.button = ev->button; - rxvt_mouse_report(aR_ ev); + MEvent.clicks = 1; + MEvent.button = ev->button; + mouse_report (ev); } #else - R->MEvent.button = ev->button; - rxvt_mouse_report(aR_ ev); + MEvent.button = ev->button; + mouse_report (ev); #endif /* MOUSE_REPORT_DOUBLECLICK */ } else { - if (ev->button != R->MEvent.button) - R->MEvent.clicks = 0; + if (ev->button != MEvent.button) + MEvent.clicks = 0; switch (ev->button) { case Button1: /* allow shift+left click to extend selection */ - if (ev->state & ShiftMask && !(R->PrivateModes & PrivMode_mouse_report)) + if (ev->state & ShiftMask && !(PrivateModes & PrivMode_mouse_report)) { - if (R->MEvent.button == Button1 && clickintime) - R->selection_rotate (ev->x, ev->y); + if (MEvent.button == Button1 && clickintime) + selection_rotate (ev->x, ev->y); else - R->selection_extend (ev->x, ev->y, 1); + selection_extend (ev->x, ev->y, 1); } else { - if (R->MEvent.button == Button1 && clickintime) - R->MEvent.clicks++; + if (MEvent.button == Button1 && clickintime) + MEvent.clicks++; else - R->MEvent.clicks = 1; + MEvent.clicks = 1; - R->selection_click (R->MEvent.clicks, ev->x, ev->y); + selection_click (MEvent.clicks, ev->x, ev->y); } - R->MEvent.button = Button1; + MEvent.button = Button1; break; case Button3: - if (R->MEvent.button == Button3 && clickintime) - R->selection_rotate (ev->x, ev->y); + if (MEvent.button == Button3 && clickintime) + selection_rotate (ev->x, ev->y); else - R->selection_extend (ev->x, ev->y, 1); - R->MEvent.button = Button3; + selection_extend (ev->x, ev->y, 1); + MEvent.button = Button3; break; } } - R->MEvent.time = ev->time; + MEvent.time = ev->time; return; } } @@ -1641,7 +1628,7 @@ rxvt_button_press(pR_ XButtonEvent *ev) */ if (isScrollbarWindow(ev->window)) { - R->scrollBar.setIdle (); + scrollBar.setIdle (); /* * Rxvt-style scrollbar: * move up if mouse is above slider @@ -1659,26 +1646,26 @@ rxvt_button_press(pR_ XButtonEvent *ev) * arrow buttons - send up/down * click on scrollbar - send pageup/down */ - if ((R->scrollBar.style == R_SB_NEXT + if ((scrollBar.style == R_SB_NEXT && scrollbarnext_upButton(ev->y)) - || (R->scrollBar.style == R_SB_RXVT + || (scrollBar.style == R_SB_RXVT && scrollbarrxvt_upButton(ev->y))) - R->tt_printf("\033[A"); - else if ((R->scrollBar.style == R_SB_NEXT + tt_printf("\033[A"); + else if ((scrollBar.style == R_SB_NEXT && scrollbarnext_dnButton(ev->y)) - || (R->scrollBar.style == R_SB_RXVT + || (scrollBar.style == R_SB_RXVT && scrollbarrxvt_dnButton(ev->y))) - R->tt_printf("\033[B"); + tt_printf("\033[B"); else switch (ev->button) { case Button2: - R->tt_printf("\014"); + tt_printf("\014"); break; case Button1: - R->tt_printf("\033[6~"); + tt_printf("\033[6~"); break; case Button3: - R->tt_printf("\033[5~"); + tt_printf("\033[5~"); break; } } @@ -1687,12 +1674,12 @@ rxvt_button_press(pR_ XButtonEvent *ev) { char upordown = 0; - if (R->scrollBar.style == R_SB_NEXT) { + if (scrollBar.style == R_SB_NEXT) { if (scrollbarnext_upButton(ev->y)) upordown = -1; /* up */ else if (scrollbarnext_dnButton(ev->y)) upordown = 1; /* down */ - } else if (R->scrollBar.style == R_SB_RXVT) { + } else if (scrollBar.style == R_SB_RXVT) { if (scrollbarrxvt_upButton(ev->y)) upordown = -1; /* up */ else if (scrollbarrxvt_dnButton(ev->y)) @@ -1700,61 +1687,60 @@ rxvt_button_press(pR_ XButtonEvent *ev) } if (upordown) { #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - R->scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; + scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; #endif - if (rxvt_scr_page(aR_ upordown < 0 ? UP : DN, 1)) { + if (scr_page (upordown < 0 ? UP : DN, 1)) { if (upordown < 0) - R->scrollBar.setUp (); + scrollBar.setUp (); else - R->scrollBar.setDn (); + scrollBar.setDn (); } } else switch (ev->button) { case Button2: - switch (R->scrollbar_align) { + switch (scrollbar_align) { case R_SB_ALIGN_TOP: - R->csrO = 0; + csrO = 0; break; case R_SB_ALIGN_CENTRE: - R->csrO = (R->scrollBar.bot - R->scrollBar.top) / 2; + csrO = (scrollBar.bot - scrollBar.top) / 2; break; case R_SB_ALIGN_BOTTOM: - R->csrO = R->scrollBar.bot - R->scrollBar.top; + csrO = scrollBar.bot - scrollBar.top; break; } - if (R->scrollBar.style == R_SB_XTERM + if (scrollBar.style == R_SB_XTERM || scrollbar_above_slider(ev->y) || scrollbar_below_slider(ev->y)) - rxvt_scr_move_to(aR_ - scrollbar_position(ev->y) - R->csrO, + scr_move_to ( scrollbar_position(ev->y) - csrO, scrollbar_size()); - R->scrollBar.setMotion (); + scrollBar.setMotion (); break; case Button1: - if (R->scrollbar_align == R_SB_ALIGN_CENTRE) - R->csrO = ev->y - R->scrollBar.top; + if (scrollbar_align == R_SB_ALIGN_CENTRE) + csrO = ev->y - scrollBar.top; /* FALLTHROUGH */ case Button3: - if (R->scrollBar.style != R_SB_XTERM) { + if (scrollBar.style != R_SB_XTERM) { if (scrollbar_above_slider(ev->y)) # ifdef RXVT_SCROLL_FULL - rxvt_scr_page(aR_ UP, R->TermWin.nrow - 1); + scr_page (UP, TermWin.nrow - 1); # else - rxvt_scr_page(aR_ UP, R->TermWin.nrow / 4); + scr_page (UP, TermWin.nrow / 4); # endif else if (scrollbar_below_slider(ev->y)) # ifdef RXVT_SCROLL_FULL - rxvt_scr_page(aR_ DN, R->TermWin.nrow - 1); + scr_page (DN, TermWin.nrow - 1); # else - rxvt_scr_page(aR_ DN, R->TermWin.nrow / 4); + scr_page (DN, TermWin.nrow / 4); # endif else - R->scrollBar.setMotion (); + scrollBar.setMotion (); } else { - rxvt_scr_page(aR_ (ev->button == Button1 ? DN : UP), - (R->TermWin.nrow + scr_page ((ev->button == Button1 ? DN : UP), + (TermWin.nrow * scrollbar_position(ev->y) / scrollbar_size())); } @@ -1768,31 +1754,30 @@ rxvt_button_press(pR_ XButtonEvent *ev) * Menubar window processing of button press */ if (isMenuBarWindow(ev->window)) - rxvt_menubar_control(aR_ ev); + menubar_control (ev); #endif } -/* INTPROTO */ void -rxvt_button_release(pR_ XButtonEvent *ev) +rxvt_term::button_release (XButtonEvent *ev) { int reportmode = 0; - R->csrO = 0; /* reset csr Offset */ - if (!R->bypass_keystate) - reportmode = !!(R->PrivateModes & PrivMode_mouse_report); + csrO = 0; /* reset csr Offset */ + if (!bypass_keystate) + reportmode = !!(PrivateModes & PrivMode_mouse_report); if (scrollbar_isUpDn()) { - R->scrollBar.setIdle (); - rxvt_scrollbar_show(aR_ 0); + scrollBar.setIdle (); + scrollbar_show (0); #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - R->refresh_type &= ~SMOOTH_REFRESH; + refresh_type &= ~SMOOTH_REFRESH; #endif } #ifdef SELECTION_SCROLLING - R->pending_scroll_selection=0; + pending_scroll_selection=0; #endif - if (ev->window == R->TermWin.vt) + if (ev->window == TermWin.vt) { #ifdef RXVT_GRAPHICS if (ev->subwindow != None) @@ -1808,18 +1793,18 @@ rxvt_button_release(pR_ XButtonEvent *ev) return; #ifdef MOUSE_REPORT_DOUBLECLICK /* only report the release of 'slow' single clicks */ - if (R->MEvent.button != AnyButton - && (ev->button != R->MEvent.button - || (ev->time - R->MEvent.time + if (MEvent.button != AnyButton + && (ev->button != MEvent.button + || (ev->time - MEvent.time > MULTICLICK_TIME / 2))) { - R->MEvent.clicks = 0; - R->MEvent.button = AnyButton; - rxvt_mouse_report(aR_ ev); + MEvent.clicks = 0; + MEvent.button = AnyButton; + mouse_report (ev); } #else /* MOUSE_REPORT_DOUBLECLICK */ - R->MEvent.button = AnyButton; - rxvt_mouse_report(aR_ ev); + MEvent.button = AnyButton; + mouse_report (ev); #endif /* MOUSE_REPORT_DOUBLECLICK */ return; } @@ -1827,18 +1812,18 @@ rxvt_button_release(pR_ XButtonEvent *ev) * dumb hack to compensate for the failure of click-and-drag * when overriding mouse reporting */ - if (R->PrivateModes & PrivMode_mouse_report - && R->bypass_keystate - && ev->button == Button1 && R->MEvent.clicks <= 1) - R->selection_extend (ev->x, ev->y, 0); + 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: - rxvt_selection_make(aR_ ev->time); + selection_make (ev->time); break; case Button2: - rxvt_selection_request(aR_ ev->time, ev->x, ev->y); + selection_request (ev->time, ev->x, ev->y); break; #ifdef MOUSE_WHEEL case Button4: @@ -1850,27 +1835,27 @@ rxvt_button_release(pR_ XButtonEvent *ev) v = (ev->button == Button4) ? UP : DN; if (ev->state & ShiftMask) i = 1; - else if ((R->Options & Opt_mouseWheelScrollPage)) - i = R->TermWin.nrow - 1; + else if ((Options & Opt_mouseWheelScrollPage)) + i = TermWin.nrow - 1; else i = 5; # ifdef MOUSE_SLIP_WHEELING if (ev->state & ControlMask) { - R->mouse_slip_wheel_speed += (v ? -1 : 1); - R->mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; + mouse_slip_wheel_speed += (v ? -1 : 1); + mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; } # endif # ifdef JUMP_MOUSE_WHEEL - rxvt_scr_page(aR_ v, i); - R->scr_refresh (SMOOTH_REFRESH); - rxvt_scrollbar_show(aR_ 1); + scr_page (v, i); + scr_refresh (SMOOTH_REFRESH); + scrollbar_show (1); # else while (i--) { - rxvt_scr_page(aR_ v, 1); - R->scr_refresh (SMOOTH_REFRESH); - rxvt_scrollbar_show(aR_ 1); + scr_page (v, 1); + scr_refresh (SMOOTH_REFRESH); + scrollbar_show (1); } # endif } @@ -1881,7 +1866,7 @@ rxvt_button_release(pR_ XButtonEvent *ev) } #ifdef MENUBAR else if (isMenuBarWindow(ev->window)) - rxvt_menubar_control(aR_ ev); + menubar_control (ev); #endif } @@ -1891,9 +1876,8 @@ rxvt_button_release(pR_ XButtonEvent *ev) * Check our parents are still who we think they are. * Do transparency updates if required */ -/* EXTPROTO */ int -rxvt_check_our_parents(pR) +rxvt_term::check_our_parents () { int i, pchanged, aformat, have_pixmap, rootdepth; unsigned long nitems, bytes_after; @@ -1905,33 +1889,33 @@ rxvt_check_our_parents(pR) pchanged = 0; - if (!(R->Options & Opt_transparent)) + if (!(Options & Opt_transparent)) return pchanged; /* Don't try any more */ - XGetWindowAttributes(R->Xdisplay, Xroot, &wrootattr); + XGetWindowAttributes(Xdisplay, Xroot, &wrootattr); rootdepth = wrootattr.depth; - XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[0], &wattr); + XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr); if (rootdepth != wattr.depth) { - if (R->am_transparent) { + if (am_transparent) { pchanged = 1; - XSetWindowBackground(R->Xdisplay, R->TermWin.vt, - R->PixColors[Color_bg]); - R->am_transparent = R->am_pixmap_trans = 0; + XSetWindowBackground(Xdisplay, TermWin.vt, + PixColors[Color_bg]); + am_transparent = am_pixmap_trans = 0; } return pchanged; /* Don't try any more */ } /* Get all X ops out of the queue so that our information is up-to-date. */ - XSync(R->Xdisplay, False); + XSync(Xdisplay, False); /* * Make the frame window set by the window manager have * the root background. Some window managers put multiple nested frame * windows for each client, so we have to take care about that. */ - i = (R->xa[XA_XROOTPMAPID] != 0 - && (XGetWindowProperty(R->Xdisplay, Xroot, R->xa[XA_XROOTPMAPID], + i = (xa[XA_XROOTPMAPID] != 0 + && (XGetWindowProperty(Xdisplay, Xroot, xa[XA_XROOTPMAPID], 0L, 1L, False, XA_PIXMAP, &atype, &aformat, &nitems, &bytes_after, &prop) == Success)); if (!i || prop == NULL) @@ -1952,10 +1936,10 @@ rxvt_check_our_parents(pR) GC gc; XGCValues gcvalue; - XTranslateCoordinates(R->Xdisplay, R->TermWin.parent[0], Xroot, + XTranslateCoordinates(Xdisplay, TermWin.parent[0], Xroot, 0, 0, &sx, &sy, &cr); - nw = (unsigned int)R->szHint.width; - nh = (unsigned int)R->szHint.height; + nw = (unsigned int)szHint.width; + nh = (unsigned int)szHint.height; nx = ny = 0; if (sx < 0) { nw += sx; @@ -1969,81 +1953,81 @@ rxvt_check_our_parents(pR) } MIN_IT(nw, (unsigned int)(wrootattr.width - sx)); MIN_IT(nh, (unsigned int)(wrootattr.height - sy)); - R->allowedxerror = -1; - image = XGetImage(R->Xdisplay, rootpixmap, sx, sy, nw, nh, AllPlanes, + allowedxerror = -1; + image = XGetImage(Xdisplay, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); /* XXX: handle BadMatch - usually because we're outside the pixmap */ /* XXX: may need a delay here? */ - R->allowedxerror = 0; + allowedxerror = 0; if (image == NULL) { - if (R->am_transparent && R->am_pixmap_trans) { + if (am_transparent && am_pixmap_trans) { pchanged = 1; - if (R->TermWin.pixmap != None) { - XFreePixmap(R->Xdisplay, R->TermWin.pixmap); - R->TermWin.pixmap = None; + if (TermWin.pixmap != None) { + XFreePixmap(Xdisplay, TermWin.pixmap); + TermWin.pixmap = None; } } - R->am_pixmap_trans = 0; + am_pixmap_trans = 0; } else { - if (R->TermWin.pixmap != None) - XFreePixmap(R->Xdisplay, R->TermWin.pixmap); - R->TermWin.pixmap = XCreatePixmap(R->Xdisplay, R->TermWin.vt, - (unsigned int)R->szHint.width, - (unsigned int)R->szHint.height, + if (TermWin.pixmap != None) + XFreePixmap(Xdisplay, TermWin.pixmap); + TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt, + (unsigned int)szHint.width, + (unsigned int)szHint.height, (unsigned int)image->depth); - gc = XCreateGC(R->Xdisplay, R->TermWin.vt, 0UL, &gcvalue); - XPutImage(R->Xdisplay, R->TermWin.pixmap, gc, image, 0, 0, + gc = XCreateGC(Xdisplay, TermWin.vt, 0UL, &gcvalue); + XPutImage(Xdisplay, TermWin.pixmap, gc, image, 0, 0, nx, ny, (unsigned int)image->width, (unsigned int)image->height); - XFreeGC(R->Xdisplay, gc); + XFreeGC(Xdisplay, gc); XDestroyImage(image); - XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.vt, - R->TermWin.pixmap); - if (!R->am_transparent || !R->am_pixmap_trans) + XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt, + TermWin.pixmap); + if (!am_transparent || !am_pixmap_trans) pchanged = 1; - R->am_transparent = R->am_pixmap_trans = 1; + am_transparent = am_pixmap_trans = 1; } } - if (!R->am_pixmap_trans) { + if (!am_pixmap_trans) { unsigned int n; /* * InheritPixmap transparency */ D_X((stderr, "InheritPixmap Seeking to %08lx", Xroot)); - for (i = 1; i < (int)(sizeof(R->TermWin.parent) / sizeof(Window)); + for (i = 1; i < (int)(sizeof(TermWin.parent) / sizeof(Window)); i++) { - oldp = R->TermWin.parent[i]; - XQueryTree(R->Xdisplay, R->TermWin.parent[i - 1], &root, - &R->TermWin.parent[i], &list, &n); + oldp = TermWin.parent[i]; + XQueryTree(Xdisplay, TermWin.parent[i - 1], &root, + &TermWin.parent[i], &list, &n); XFree(list); - D_X((stderr, "InheritPixmap Parent[%d] = %08lx", i, R->TermWin.parent[i])); - if (R->TermWin.parent[i] == Xroot) { + D_X((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i])); + if (TermWin.parent[i] == Xroot) { if (oldp != None) pchanged = 1; break; } - if (oldp != R->TermWin.parent[i]) + if (oldp != TermWin.parent[i]) pchanged = 1; } n = 0; if (pchanged) { for (; n < (unsigned int)i; n++) { - XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[n], &wattr); + XGetWindowAttributes(Xdisplay, 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(R->TermWin.parent) / sizeof(Window)) + 1; + n = (int)(sizeof(TermWin.parent) / sizeof(Window)) + 1; break; } } } - if (n > (int)(sizeof(R->TermWin.parent) - / sizeof(R->TermWin.parent[0]))) { + if (n > (int)(sizeof(TermWin.parent) + / sizeof(TermWin.parent[0]))) { D_X((stderr, "InheritPixmap Turning off")); - XSetWindowBackground(R->Xdisplay, R->TermWin.parent[0], - R->PixColors[Color_fg]); - XSetWindowBackground(R->Xdisplay, R->TermWin.vt, - R->PixColors[Color_bg]); - R->am_transparent = 0; + XSetWindowBackground(Xdisplay, TermWin.parent[0], + PixColors[Color_fg]); + XSetWindowBackground(Xdisplay, TermWin.vt, + PixColors[Color_bg]); + am_transparent = 0; /* XXX: also turn off Opt_transparent? */ } else { /* wait (an arbitrary period) for the WM to do its thing @@ -2059,14 +2043,14 @@ rxvt_check_our_parents(pR) # endif D_X((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); for (n = 0; n < (unsigned int)i; n++) - XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.parent[n], + XSetWindowBackgroundPixmap(Xdisplay, TermWin.parent[n], ParentRelative); - XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.vt, + XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt, ParentRelative); - R->am_transparent = 1; + am_transparent = 1; } - for (; i < (int)(sizeof(R->TermWin.parent) / sizeof(Window)); i++) - R->TermWin.parent[i] = None; + for (; i < (int)(sizeof(TermWin.parent) / sizeof(Window)); i++) + TermWin.parent[i] = None; } return pchanged; } @@ -2077,20 +2061,18 @@ rxvt_check_our_parents(pR) /*{{{ print pipe */ /*----------------------------------------------------------------------*/ #ifdef PRINTPIPE -/* EXTPROTO */ -FILE * -rxvt_popen_printer(pR) +FILE * +rxvt_term::popen_printer () { - FILE *stream = popen(R->rs[Rs_print_pipe], "w"); + FILE *stream = popen(rs[Rs_print_pipe], "w"); if (stream == NULL) rxvt_print_error("can't open printer pipe"); return stream; } -/* EXTPROTO */ int -rxvt_pclose_printer (FILE *stream) +rxvt_term::pclose_printer (FILE *stream) { fflush (stream); /* pclose() reported not to work on SunOS 4.1.3 */ @@ -2105,14 +2087,13 @@ rxvt_pclose_printer (FILE *stream) /* * simulate attached vt100 printer */ -/* INTPROTO */ void -rxvt_process_print_pipe(pR) +rxvt_term::process_print_pipe () { int done; FILE *fd; - if ((fd = rxvt_popen_printer(aR)) == NULL) + if ((fd = popen_printer ()) == NULL) return; /* @@ -2124,20 +2105,20 @@ rxvt_process_print_pipe(pR) unsigned char ch; unsigned int i, len; - if ((ch = rxvt_cmd_getc(aR)) != C0_ESC) { + if ((ch = cmd_getc ()) != C0_ESC) { if (putc(ch, fd) == EOF) break; /* done = 1 */ } else { len = 0; buf[len++] = ch; - if ((buf[len++] = rxvt_cmd_getc(aR)) == '[') { - if ((ch = rxvt_cmd_getc(aR)) == '?') { + if ((buf[len++] = cmd_getc ()) == '[') { + if ((ch = cmd_getc ()) == '?') { buf[len++] = '?'; - ch = rxvt_cmd_getc(aR); + ch = cmd_getc (); } if ((buf[len++] = ch) == '4') { - if ((buf[len++] = rxvt_cmd_getc(aR)) == 'i') + if ((buf[len++] = cmd_getc ()) == 'i') break; /* done = 1 */ } } @@ -2148,7 +2129,7 @@ rxvt_process_print_pipe(pR) } } } - rxvt_pclose_printer(fd); + pclose_printer (fd); } #endif /* PRINTPIPE */ /*}}} */ @@ -2164,42 +2145,41 @@ enum { /* *INDENT-ON* */ /*{{{ process non-printing single characters */ -/* INTPROTO */ void -rxvt_process_nonprinting(pR_ unsigned char ch) +rxvt_term::process_nonprinting (unsigned char ch) { switch (ch) { case C0_ENQ: /* terminal Status */ - if (R->rs[Rs_answerbackstring]) - R->tt_write( - (const unsigned char *)R->rs[Rs_answerbackstring], - (unsigned int)STRLEN(R->rs[Rs_answerbackstring])); + if (rs[Rs_answerbackstring]) + tt_write( + (const unsigned char *)rs[Rs_answerbackstring], + (unsigned int)STRLEN(rs[Rs_answerbackstring])); else - R->tt_write((unsigned char *)VT100_ANS, + tt_write((unsigned char *)VT100_ANS, (unsigned int)STRLEN(VT100_ANS)); break; case C0_BEL: /* bell */ - rxvt_scr_bell(aR); + scr_bell (); break; case C0_BS: /* backspace */ - rxvt_scr_backspace(aR); + scr_backspace (); break; case C0_HT: /* tab */ - rxvt_scr_tab(aR_ 1); + scr_tab (1); break; case C0_CR: /* carriage return */ - rxvt_scr_gotorc(aR_ 0, 0, R_RELATIVE); + scr_gotorc (0, 0, R_RELATIVE); break; case C0_VT: /* vertical tab, form feed */ case C0_FF: case C0_LF: /* line feed */ - rxvt_scr_index(aR_ UP); + scr_index (UP); break; case C0_SO: /* shift out - acs */ - rxvt_scr_charset_choose(aR_ 1); + scr_charset_choose (1); break; case C0_SI: /* shift in - acs */ - rxvt_scr_charset_choose(aR_ 0); + scr_charset_choose (0); break; } } @@ -2207,48 +2187,47 @@ rxvt_process_nonprinting(pR_ unsigned char ch) /*{{{ process VT52 escape sequences */ -/* INTPROTO */ void -rxvt_process_escape_vt52(pR_ unsigned char ch) +rxvt_term::process_escape_vt52 (unsigned char ch) { int row, col; switch (ch) { case 'A': /* cursor up */ - rxvt_scr_gotorc(aR_ -1, 0, R_RELATIVE | C_RELATIVE); + scr_gotorc (-1, 0, R_RELATIVE | C_RELATIVE); break; case 'B': /* cursor down */ - rxvt_scr_gotorc(aR_ 1, 0, R_RELATIVE | C_RELATIVE); + scr_gotorc (1, 0, R_RELATIVE | C_RELATIVE); break; case 'C': /* cursor right */ - rxvt_scr_gotorc(aR_ 0, 1, R_RELATIVE | C_RELATIVE); + scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); break; case 'D': /* cursor left */ - rxvt_scr_gotorc(aR_ 0, -1, R_RELATIVE | C_RELATIVE); + scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); break; case 'H': /* cursor home */ - rxvt_scr_gotorc(aR_ 0, 0, 0); + scr_gotorc (0, 0, 0); break; case 'I': /* cursor up and scroll down if needed */ - rxvt_scr_index(aR_ DN); + scr_index (DN); break; case 'J': /* erase to end of screen */ - R->scr_erase_screen (0); + scr_erase_screen (0); break; case 'K': /* erase to end of line */ - rxvt_scr_erase_line(aR_ 0); + scr_erase_line (0); break; case 'Y': /* move to specified row and col */ /* full command is 'ESC Y row col' where row and col * are encoded by adding 32 and sending the ascii * character. eg. SPACE = 0, '+' = 13, '0' = 18, * etc. */ - row = rxvt_cmd_getc(aR) - ' '; - col = rxvt_cmd_getc(aR) - ' '; - rxvt_scr_gotorc(aR_ row, col, 0); + row = cmd_getc () - ' '; + col = cmd_getc () - ' '; + scr_gotorc (row, col, 0); break; case 'Z': /* identify the terminal type */ - R->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); @@ -2267,54 +2246,53 @@ rxvt_process_escape_vt52(pR_ unsigned char ch) /*{{{ process escape sequences */ -/* INTPROTO */ void -rxvt_process_escape_seq(pR) +rxvt_term::process_escape_seq () { - unsigned char ch = rxvt_cmd_getc(aR); + unsigned char ch = cmd_getc (); - if (R->PrivateModes & PrivMode_vt52) { - rxvt_process_escape_vt52(aR_ ch); + if (PrivateModes & PrivMode_vt52) { + process_escape_vt52 (ch); return; } switch (ch) { /* case 1: do_tek_mode (); break; */ case '#': - if (rxvt_cmd_getc(aR) == '8') - rxvt_scr_E(aR); + if (cmd_getc () == '8') + scr_E (); break; case '(': - rxvt_scr_charset_set(aR_ 0, (unsigned int)rxvt_cmd_getc(aR)); + scr_charset_set (0, (unsigned int)cmd_getc ()); break; case ')': - rxvt_scr_charset_set(aR_ 1, (unsigned int)rxvt_cmd_getc(aR)); + scr_charset_set (1, (unsigned int)cmd_getc ()); break; case '*': - rxvt_scr_charset_set(aR_ 2, (unsigned int)rxvt_cmd_getc(aR)); + scr_charset_set (2, (unsigned int)cmd_getc ()); break; case '+': - rxvt_scr_charset_set(aR_ 3, (unsigned int)rxvt_cmd_getc(aR)); + scr_charset_set (3, (unsigned int)cmd_getc ()); break; #ifdef MULTICHAR_SET case '$': - rxvt_scr_charset_set(aR_ -2, (unsigned int)rxvt_cmd_getc(aR)); + scr_charset_set (-2, (unsigned int)cmd_getc ()); break; #endif #ifndef NO_FRILLS case '6': - rxvt_scr_backindex(aR); + scr_backindex (); break; #endif case '7': - rxvt_scr_cursor(aR_ SAVE); + scr_cursor (SAVE); break; case '8': - rxvt_scr_cursor(aR_ RESTORE); + scr_cursor (RESTORE); break; #ifndef NO_FRILLS case '9': - rxvt_scr_forwardindex(aR); + scr_forwardindex (); break; #endif case '=': @@ -2323,33 +2301,33 @@ rxvt_process_escape_seq(pR) break; case C1_40: - rxvt_cmd_getc(aR); + cmd_getc (); break; case C1_44: - rxvt_scr_index(aR_ UP); + scr_index (UP); break; /* 8.3.87: NEXT LINE */ case C1_NEL: /* ESC E */ { uint32_t nlcr[] = { '\n', '\r' }; - rxvt_scr_add_lines(aR_ nlcr, 1, 2); + scr_add_lines (nlcr, 1, 2); } break; /* kidnapped escape sequence: Should be 8.3.48 */ case C1_ESA: /* ESC G */ - rxvt_process_graphics(aR); + process_graphics (); break; /* 8.3.63: CHARACTER TABULATION SET */ case C1_HTS: /* ESC H */ - rxvt_scr_set_tab(aR_ 1); + scr_set_tab (1); break; /* 8.3.105: REVERSE LINE FEED */ case C1_RI: /* ESC M */ - rxvt_scr_index(aR_ DN); + scr_index (DN); break; /* 8.3.142: SINGLE-SHIFT TWO */ @@ -2360,39 +2338,39 @@ rxvt_process_escape_seq(pR) /* 8.3.27: DEVICE CONTROL STRING */ case C1_DCS: /* ESC P */ - rxvt_process_dcs_seq(aR); + process_dcs_seq (); break; /* 8.3.110: SINGLE CHARACTER INTRODUCER */ case C1_SCI: /* ESC Z */ - R->tt_write((const unsigned char *)ESCZ_ANSWER, + tt_write((const unsigned char *)ESCZ_ANSWER, (unsigned int)(sizeof(ESCZ_ANSWER) - 1)); break; /* steal obsolete ESC [ c */ /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ case C1_CSI: /* ESC [ */ - rxvt_process_csi_seq(aR); + process_csi_seq (); break; /* 8.3.90: OPERATING SYSTEM COMMAND */ case C1_OSC: /* ESC ] */ - rxvt_process_osc_seq(aR); + process_osc_seq (); break; /* 8.3.106: RESET TO INITIAL STATE */ case 'c': - rxvt_scr_poweron(aR); - rxvt_scrollbar_show(aR_ 1); + scr_poweron (); + scrollbar_show (1); break; /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ case 'n': - rxvt_scr_charset_choose(aR_ 2); + scr_charset_choose (2); break; /* 8.3.81: LOCKING-SHIFT THREE (see ISO2022) */ case 'o': - rxvt_scr_charset_choose(aR_ 3); + scr_charset_choose (3); break; } } @@ -2430,9 +2408,8 @@ const unsigned char csi_defaults[] = { }; /* *INDENT-ON* */ -/* INTPROTO */ void -rxvt_process_csi_seq(pR) +rxvt_term::process_csi_seq () { unsigned char ch, priv, i; unsigned int nargs, p; @@ -2443,10 +2420,10 @@ rxvt_process_csi_seq(pR) arg[--nargs] = 0; priv = 0; - ch = rxvt_cmd_getc(aR); + ch = cmd_getc (); if (ch >= '<' && ch <= '?') { /* '<' '=' '>' '?' */ priv = ch; - ch = rxvt_cmd_getc(aR); + ch = cmd_getc (); } /* read any numerical arguments */ for (n = -1; ch < CSI_ICH; ) { @@ -2460,14 +2437,14 @@ rxvt_process_csi_seq(pR) arg[nargs++] = n; n = -1; } else if (ch == '\b') { - rxvt_scr_backspace(aR); + scr_backspace (); } else if (ch == C0_ESC) { - rxvt_process_escape_seq(aR); + process_escape_seq (); return; } else if (ch < ' ') { - rxvt_process_nonprinting(aR_ ch); + process_nonprinting (ch); } - ch = rxvt_cmd_getc(aR); + ch = cmd_getc (); } if (ch > CSI_7F) @@ -2496,11 +2473,11 @@ rxvt_process_csi_seq(pR) switch (priv) { case '>': if (ch == CSI_DA) /* secondary device attributes */ - R->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') - rxvt_process_terminal_mode(aR_ ch, priv, nargs, arg); + process_terminal_mode (ch, priv, nargs, arg); break; } return; @@ -2514,10 +2491,10 @@ rxvt_process_csi_seq(pR) case CSI_MC: /* 8.3.83: (0) MEDIA COPY */ switch (arg[0]) { case 0: /* initiate transfer to primary aux device */ - rxvt_scr_printscreen(aR_ 0); + scr_printscreen (0); break; case 5: /* start relay to primary aux device */ - rxvt_process_print_pipe(aR); + process_print_pipe (); break; } break; @@ -2529,7 +2506,7 @@ rxvt_process_csi_seq(pR) /* FALLTHROUGH */ case CSI_CUD: /* 8.3.19: (1) CURSOR DOWN */ case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */ - rxvt_scr_gotorc(aR_ arg[0], 0, RELATIVE); + scr_gotorc (arg[0], 0, RELATIVE); break; case CSI_CUB: /* 8.3.18: (1) CURSOR LEFT */ @@ -2543,9 +2520,9 @@ rxvt_process_csi_seq(pR) case CSI_CUF: /* 8.3.20: (1) CURSOR RIGHT */ case CSI_HPR: /* 8.3.60: (1) CHARACTER POSITION FORWARD */ #ifdef ISO6429 - rxvt_scr_gotorc(aR_ 0, arg[0], RELATIVE); + scr_gotorc (0, arg[0], RELATIVE); #else /* emulate common DEC VTs */ - rxvt_scr_gotorc(aR_ 0, arg[0] ? arg[0] : 1, RELATIVE); + scr_gotorc (0, arg[0] ? arg[0] : 1, RELATIVE); #endif break; @@ -2553,89 +2530,89 @@ rxvt_process_csi_seq(pR) arg[0] = -arg[0]; /* FALLTHROUGH */ case CSI_CNL: /* 8.3.12: (1) CURSOR NEXT LINE */ - rxvt_scr_gotorc(aR_ arg[0], 0, R_RELATIVE); + scr_gotorc (arg[0], 0, R_RELATIVE); break; case CSI_CHA: /* 8.3.9: (1) CURSOR CHARACTER ABSOLUTE */ case CSI_HPA: /* 8.3.58: (1) CURSOR POSITION ABSOLUTE */ - rxvt_scr_gotorc(aR_ 0, arg[0] - 1, R_RELATIVE); + scr_gotorc (0, arg[0] - 1, R_RELATIVE); break; case CSI_VPA: /* 8.3.159: (1) LINE POSITION ABSOLUTE */ - rxvt_scr_gotorc(aR_ arg[0] - 1, 0, C_RELATIVE); + scr_gotorc (arg[0] - 1, 0, C_RELATIVE); break; case CSI_CUP: /* 8.3.21: (1,1) CURSOR POSITION */ case CSI_HVP: /* 8.3.64: (1,1) CHARACTER AND LINE POSITION */ - rxvt_scr_gotorc(aR_ arg[0] - 1, nargs < 2 ? 0 : (arg[1] - 1), 0); + scr_gotorc (arg[0] - 1, nargs < 2 ? 0 : (arg[1] - 1), 0); break; case CSI_CBT: /* 8.3.7: (1) CURSOR BACKWARD TABULATION */ arg[0] = -arg[0]; /* FALLTHROUGH */ case CSI_CHT: /* 8.3.10: (1) CURSOR FORWARD TABULATION */ - rxvt_scr_tab(aR_ arg[0]); + scr_tab (arg[0]); break; case CSI_ED: /* 8.3.40: (0) ERASE IN PAGE */ - R->scr_erase_screen (arg[0]); + scr_erase_screen (arg[0]); break; case CSI_EL: /* 8.3.42: (0) ERASE IN LINE */ - rxvt_scr_erase_line(aR_ arg[0]); + scr_erase_line (arg[0]); break; case CSI_ICH: /* 8.3.65: (1) INSERT CHARACTER */ - rxvt_scr_insdel_chars(aR_ arg[0], INSERT); + scr_insdel_chars (arg[0], INSERT); break; case CSI_IL: /* 8.3.68: (1) INSERT LINE */ - rxvt_scr_insdel_lines(aR_ arg[0], INSERT); + scr_insdel_lines (arg[0], INSERT); break; case CSI_DL: /* 8.3.33: (1) DELETE LINE */ - rxvt_scr_insdel_lines(aR_ arg[0], DELETE); + scr_insdel_lines (arg[0], DELETE); break; case CSI_ECH: /* 8.3.39: (1) ERASE CHARACTER */ - rxvt_scr_insdel_chars(aR_ arg[0], ERASE); + scr_insdel_chars (arg[0], ERASE); break; case CSI_DCH: /* 8.3.26: (1) DELETE CHARACTER */ - rxvt_scr_insdel_chars(aR_ arg[0], DELETE); + scr_insdel_chars (arg[0], DELETE); break; case CSI_SD: /* 8.3.114: (1) SCROLL DOWN */ arg[0] = -arg[0]; /* FALLTHROUGH */ case CSI_SU: /* 8.3.148: (1) SCROLL UP */ - R->scr_scroll_text (R->screen.tscroll, R->screen.bscroll, arg[0], 0); + scr_scroll_text (screen.tscroll, screen.bscroll, arg[0], 0); break; case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ - R->tt_write((const unsigned char *)VT100_ANS, + tt_write((const unsigned char *)VT100_ANS, (unsigned int)(sizeof(VT100_ANS) - 1)); break; case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ - rxvt_process_sgr_mode(aR_ nargs, arg); + process_sgr_mode (nargs, arg); break; case CSI_DSR: /* 8.3.36: (0) DEVICE STATUS REPORT */ switch (arg[0]) { case 5: /* DSR requested */ - R->tt_printf("\033[0n"); + tt_printf("\033[0n"); break; case 6: /* CPR requested */ - rxvt_scr_report_position(aR); + scr_report_position (); break; #if defined (ENABLE_DISPLAY_ANSWER) case 7: /* unofficial extension */ - R->tt_printf("%-.250s\n", R->rs[Rs_display_name]); + tt_printf("%-.250s\n", rs[Rs_display_name]); break; #endif case 8: /* unofficial extension */ - rxvt_xterm_seq(aR_ XTerm_title, APL_NAME "-" VERSION, CHAR_ST); + xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); break; } break; @@ -2643,14 +2620,14 @@ rxvt_process_csi_seq(pR) case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ switch (arg[0]) { case 0: /* char tab stop cleared at active position */ - rxvt_scr_set_tab(aR_ 0); + scr_set_tab (0); break; /* case 1: */ /* line tab stop cleared in active line */ /* case 2: */ /* char tab stops cleared in active line */ case 3: /* all char tab stops are cleared */ /* case 4: */ /* all line tab stops are cleared */ case 5: /* all tab stops are cleared */ - rxvt_scr_set_tab(aR_ -1); + scr_set_tab (-1); break; } break; @@ -2658,16 +2635,16 @@ rxvt_process_csi_seq(pR) case CSI_CTC: /* 8.3.17: (0) CURSOR TABULATION CONTROL */ switch (arg[0]) { case 0: /* char tab stop set at active position */ - rxvt_scr_set_tab(aR_ 1); + scr_set_tab (1); break; /* = ESC H */ /* case 1: */ /* line tab stop set at active line */ case 2: /* char tab stop cleared at active position */ - rxvt_scr_set_tab(aR_ 0); + scr_set_tab (0); break; /* = ESC [ 0 g */ /* case 3: */ /* line tab stop cleared at active line */ /* case 4: */ /* char tab stops cleared at active line */ case 5: /* all char tab stops are cleared */ - rxvt_scr_set_tab(aR_ -1); + scr_set_tab (-1); break; /* = ESC [ 3 g */ /* case 6: */ /* all line tab stops are cleared */ } @@ -2675,12 +2652,12 @@ rxvt_process_csi_seq(pR) case CSI_RM: /* 8.3.107: RESET MODE */ if (arg[0] == 4) - rxvt_scr_insert_mode(aR_ 0); + scr_insert_mode (0); break; case CSI_SM: /* 8.3.126: SET MODE */ if (arg[0] == 4) - rxvt_scr_insert_mode(aR_ 1); + scr_insert_mode (1); break; /* @@ -2688,29 +2665,29 @@ rxvt_process_csi_seq(pR) */ case CSI_72: /* DECSTBM: set top and bottom margins */ if (nargs == 1) - rxvt_scr_scroll_region(aR_ arg[0] - 1, MAX_ROWS - 1); + scr_scroll_region (arg[0] - 1, MAX_ROWS - 1); else if (nargs == 0 || arg[0] >= arg[1]) - rxvt_scr_scroll_region(aR_ 0, MAX_ROWS - 1); + scr_scroll_region (0, MAX_ROWS - 1); else - rxvt_scr_scroll_region(aR_ arg[0] - 1, arg[1] - 1); + scr_scroll_region (arg[0] - 1, arg[1] - 1); break; case CSI_73: - rxvt_scr_cursor(aR_ SAVE); + scr_cursor (SAVE); break; case CSI_75: - rxvt_scr_cursor(aR_ RESTORE); + scr_cursor (RESTORE); break; #ifndef NO_FRILLS case CSI_74: - rxvt_process_window_ops(aR_ arg, nargs); + process_window_ops (arg, nargs); break; #endif case CSI_78: /* DECREQTPARM */ if (arg[0] == 0 || arg[0] == 1) - R->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: @@ -2721,9 +2698,8 @@ rxvt_process_csi_seq(pR) #ifndef NO_FRILLS /* ARGSUSED */ -/* INTPROTO */ void -rxvt_process_window_ops(pR_ const int *args, unsigned int nargs) +rxvt_term::process_window_ops (const int *args, unsigned int nargs) { int x, y; #if 0 @@ -2739,65 +2715,65 @@ rxvt_process_window_ops(pR_ const int *args, unsigned int nargs) * commands */ case 1: /* deiconify window */ - XMapWindow(R->Xdisplay, R->TermWin.parent[0]); + XMapWindow(Xdisplay, TermWin.parent[0]); break; case 2: /* iconify window */ - XIconifyWindow(R->Xdisplay, R->TermWin.parent[0], - DefaultScreen(R->Xdisplay)); + XIconifyWindow(Xdisplay, TermWin.parent[0], + DefaultScreen(Xdisplay)); break; case 3: /* set position (pixels) */ - XMoveWindow(R->Xdisplay, R->TermWin.parent[0], args[1], args[2]); + XMoveWindow(Xdisplay, TermWin.parent[0], args[1], args[2]); break; case 4: /* set size (pixels) */ - rxvt_set_widthheight(aR_ (unsigned int)args[2], (unsigned int)args[1]); + set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); break; case 5: /* raise window */ - XRaiseWindow(R->Xdisplay, R->TermWin.parent[0]); + XRaiseWindow(Xdisplay, TermWin.parent[0]); break; case 6: /* lower window */ - XLowerWindow(R->Xdisplay, R->TermWin.parent[0]); + XLowerWindow(Xdisplay, TermWin.parent[0]); break; case 7: /* refresh window */ - R->scr_touch (true); + scr_touch (true); break; case 8: /* set size (chars) */ - rxvt_set_widthheight(aR_ (unsigned int)(args[2] * R->TermWin.fwidth), - (unsigned int)(args[1] * R->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) */ - rxvt_set_widthheight(aR_ (unsigned int)R->TermWin.width, - (unsigned int)(args[1] * R->TermWin.fheight)); + set_widthheight ((unsigned int)TermWin.width, + (unsigned int)(args[1] * TermWin.fheight)); break; /* * reports - some output format copied from XTerm */ case 11: /* report window state */ - XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[0], &wattr); - R->tt_printf("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); + XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr); + tt_printf("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); break; case 13: /* report window position */ - XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[0], &wattr); - XTranslateCoordinates(R->Xdisplay, R->TermWin.parent[0], wattr.root, + XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr); + XTranslateCoordinates(Xdisplay, TermWin.parent[0], wattr.root, -wattr.border_width, -wattr.border_width, &x, &y, &wdummy); - R->tt_printf("\033[3;%d;%dt", x, y); + tt_printf("\033[3;%d;%dt", x, y); break; case 14: /* report window size (pixels) */ - XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[0], &wattr); - R->tt_printf("\033[4;%d;%dt", wattr.height, wattr.width); + XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr); + tt_printf("\033[4;%d;%dt", wattr.height, wattr.width); break; case 18: /* report window size (chars) */ - R->tt_printf("\033[8;%d;%dt", R->TermWin.nrow, R->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(R->Xdisplay, R->TermWin.parent[0], &s); - R->tt_printf("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ + XGetIconName(Xdisplay, TermWin.parent[0], &s); + tt_printf("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ break; case 21: /* report window title */ - XFetchName(R->Xdisplay, R->TermWin.parent[0], &s); - R->tt_printf("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ + XFetchName(Xdisplay, TermWin.parent[0], &s); + tt_printf("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ break; #endif } @@ -2809,16 +2785,15 @@ rxvt_process_window_ops(pR_ const int *args, unsigned int nargs) * get input up until STRING TERMINATOR (or BEL) * ends_how is terminator used. returned input must be free()d */ -/* INTPROTO */ unsigned char * -rxvt_get_to_st(pR_ unsigned char *ends_how) +rxvt_term::get_to_st (unsigned char *ends_how) { int seen_esc = 0; /* seen escape? */ unsigned int n = 0; unsigned char *s; unsigned char ch, string[STRING_MAX]; - for (; (ch = rxvt_cmd_getc(aR));) { + for (; (ch = cmd_getc ());) { if (ch == C0_BEL || ch == CHAR_ST || (ch == 0x5c && seen_esc)) /* 7bit ST */ @@ -2846,15 +2821,14 @@ rxvt_get_to_st(pR_ unsigned char *ends_how) /* * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' */ -/* INTPROTO */ void -rxvt_process_dcs_seq(pR) +rxvt_term::process_dcs_seq () { unsigned char eh, *s; /* * Not handled yet */ - s = rxvt_get_to_st(aR_ &eh); + s = get_to_st (&eh); if (s) free(s); return; @@ -2864,19 +2838,18 @@ rxvt_process_dcs_seq(pR) /* * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' */ -/* INTPROTO */ void -rxvt_process_osc_seq(pR) +rxvt_term::process_osc_seq () { unsigned char ch, eh, *s; int arg; - ch = rxvt_cmd_getc(aR); - for (arg = 0; isdigit(ch); ch = rxvt_cmd_getc(aR)) + ch = cmd_getc (); + for (arg = 0; isdigit(ch); ch = cmd_getc ()) arg = arg * 10 + (ch - '0'); if (ch == ';') { - s = rxvt_get_to_st(aR_ &eh); + s = get_to_st (&eh); if (s) { /* * rxvt_menubar_dispatch() violates the constness of the string, @@ -2884,12 +2857,12 @@ rxvt_process_osc_seq(pR) */ if (arg == XTerm_Menu) #if 0 /* XXX: currently disabled due to security concerns */ - rxvt_menubar_dispatch(aR_ (char *)s); + menubar_dispatch ((char *)s); #else - 0; + (void)0; #endif else - rxvt_xterm_seq(aR_ arg, (char *)s, eh); + xterm_seq (arg, (char *)s, eh); free(s); } } @@ -2915,9 +2888,8 @@ rxvt_process_osc_seq(pR) * 49 = change default bg color * 55 = dump scrollback buffer and all of screen */ -/* EXTPROTO */ void -rxvt_xterm_seq(pR_ 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; @@ -2926,13 +2898,13 @@ rxvt_xterm_seq(pR_ int op, const char *str, unsigned char resp __attribute__((un assert(str != NULL); switch (op) { case XTerm_name: - rxvt_set_title(aR_ str); + set_title (str); /* FALLTHROUGH */ case XTerm_iconName: - rxvt_set_iconName(aR_ str); + set_iconName (str); break; case XTerm_title: - rxvt_set_title(aR_ str); + set_title (str); break; case XTerm_Color: for (buf = (char *)str; buf && *buf;) { @@ -2944,26 +2916,26 @@ rxvt_xterm_seq(pR_ int op, const char *str, unsigned char resp __attribute__((un break; if ((buf = STRCHR(name, ';')) != NULL) *buf++ = '\0'; - rxvt_set_window_color(aR_ color + minCOLOR, name); + set_window_color (color + minCOLOR, name); } break; #ifndef NO_CURSORCOLOR case XTerm_Color_cursor: - rxvt_set_window_color(aR_ Color_cursor, str); + set_window_color (Color_cursor, str); break; #endif case XTerm_Color_pointer: - rxvt_set_window_color(aR_ Color_pointer, str); + set_window_color (Color_pointer, str); break; #ifndef NO_BOLD_UNDERLINE_REVERSE case XTerm_Color_BD: - rxvt_set_window_color(aR_ Color_BD, str); + set_window_color (Color_BD, str); break; case XTerm_Color_UL: - rxvt_set_window_color(aR_ Color_UL, str); + set_window_color (Color_UL, str); break; case XTerm_Color_RV: - rxvt_set_window_color(aR_ Color_RV, str); + set_window_color (Color_RV, str); break; #endif @@ -2976,42 +2948,42 @@ rxvt_xterm_seq(pR_ int op, const char *str, unsigned char resp __attribute__((un case XTerm_Pixmap: if (*str != ';') { #if XPM_BACKGROUND - rxvt_scale_pixmap(aR_ ""); /* reset to default scaling */ - rxvt_set_bgPixmap(aR_ str); /* change pixmap */ + scale_pixmap (""); /* reset to default scaling */ + set_bgPixmap (str); /* change pixmap */ #endif - R->scr_touch (true); + scr_touch (true); } while ((str = STRCHR(str, ';')) != NULL) { str++; #if XPM_BACKGROUND - changed += rxvt_scale_pixmap(aR_ str); + changed += scale_pixmap (str); #endif } if (changed) { #ifdef XPM_BACKGROUND - rxvt_resize_pixmap(aR); + resize_pixmap (); #endif - R->scr_touch (true); + scr_touch (true); } break; case XTerm_restoreFG: - rxvt_set_window_color(aR_ Color_fg, str); + set_window_color (Color_fg, str); break; case XTerm_restoreBG: - rxvt_set_window_color(aR_ Color_bg, str); + set_window_color (Color_bg, str); break; case XTerm_logfile: break; case XTerm_font: - rxvt_change_font(aR_ 0, str); + change_font (0, str); break; #if 0 case XTerm_dumpscreen: /* no error notices */ { int fd; if ((fd = open(str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) { - rxvt_scr_dump(aR_ fd); + scr_dump (fd); close(fd); } } @@ -3031,29 +3003,27 @@ rxvt_xterm_seq(pR_ int op, const char *str, unsigned char resp __attribute__((un * 't' = toggle * so no need for fancy checking */ -/* INTPROTO */ int -rxvt_privcases(pR_ int mode, unsigned long bit) +rxvt_term::privcases (int mode, unsigned long bit) { int state; if (mode == 's') { - R->SavedModes |= (R->PrivateModes & bit); + SavedModes |= (PrivateModes & bit); return -1; } else { if (mode == 'r') - state = (R->SavedModes & bit) ? 1 : 0; /* no overlapping */ + state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ else - state = (mode == 't') ? !(R->PrivateModes & bit) : mode; + state = (mode == 't') ? !(PrivateModes & bit) : mode; PrivMode(state, bit); } return state; } /* we're not using priv _yet_ */ -/* INTPROTO */ void -rxvt_process_terminal_mode(pR_ 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; @@ -3105,7 +3075,7 @@ rxvt_process_terminal_mode(pR_ int mode, int priv __attribute__((unused)), unsig /* basic handling */ for (j = 0; j < (sizeof(argtopriv)/sizeof(argtopriv[0])); j++) if (argtopriv[j].argval == arg[i]) { - state = rxvt_privcases(aR_ mode, argtopriv[j].bit); + state = privcases (mode, argtopriv[j].bit); break; } @@ -3114,9 +3084,9 @@ rxvt_process_terminal_mode(pR_ int mode, int priv __attribute__((unused)), unsig switch (arg[i]) { case 1048: /* alternative cursor save */ if (mode == 0) - rxvt_scr_cursor(aR_ RESTORE); + scr_cursor (RESTORE); else if (mode == 1) - rxvt_scr_cursor(aR_ SAVE); + scr_cursor (SAVE); /* FALLTHROUGH */ default: continue; /* for(;i;) */ @@ -3133,59 +3103,58 @@ rxvt_process_terminal_mode(pR_ int mode, int priv __attribute__((unused)), unsig PrivMode(1, PrivMode_vt52); break; case 3: /* 80/132 */ - if (R->PrivateModes & PrivMode_132OK) - rxvt_set_widthheight(aR_ - (unsigned int)((state ? 132 : 80) * R->TermWin.fwidth), - (unsigned int)R->TermWin.height); + if (PrivateModes & PrivMode_132OK) + set_widthheight ( (unsigned int)((state ? 132 : 80) * TermWin.fwidth), + (unsigned int)TermWin.height); break; case 4: /* smooth scrolling */ if (state) - R->Options &= ~Opt_jumpScroll; + Options &= ~Opt_jumpScroll; else - R->Options |= Opt_jumpScroll; + Options |= Opt_jumpScroll; break; case 5: /* reverse video */ - rxvt_scr_rvideo_mode(aR_ state); + scr_rvideo_mode (state); break; case 6: /* relative/absolute origins */ - rxvt_scr_relative_origin(aR_ state); + scr_relative_origin (state); break; case 7: /* autowrap */ - rxvt_scr_autowrap(aR_ state); + scr_autowrap (state); break; /* case 8: - auto repeat, can't do on a per window basis */ case 9: /* X10 mouse reporting */ if (state) /* orthogonal */ - R->PrivateModes &= ~(PrivMode_MouseX11); + PrivateModes &= ~(PrivMode_MouseX11); break; #ifdef menuBar_esc case menuBar_esc: #ifdef MENUBAR - rxvt_map_menuBar(aR_ state); + map_menuBar (state); #endif break; #endif #ifdef scrollBar_esc case scrollBar_esc: - if (rxvt_scrollbar_mapping(aR_ state)) { - R->resize_all_windows (0, 0, 0); - R->scr_touch (true); + if (scrollbar_mapping (state)) { + resize_all_windows (0, 0, 0); + scr_touch (true); } break; #endif case 25: /* visible/invisible cursor */ - rxvt_scr_cursor_visible(aR_ state); + scr_cursor_visible (state); break; /* case 35: - shift keys */ /* case 40: - 80 <--> 132 mode */ case 47: /* secondary screen */ - rxvt_scr_change_screen(aR_ state); + scr_change_screen (state); break; /* case 66: - application key pad */ /* case 67: - backspace key */ case 1000: /* X11 mouse reporting */ if (state) /* orthogonal */ - R->PrivateModes &= ~(PrivMode_MouseX10); + PrivateModes &= ~(PrivMode_MouseX10); break; #if 0 case 1001: @@ -3193,21 +3162,21 @@ rxvt_process_terminal_mode(pR_ int mode, int priv __attribute__((unused)), unsig #endif case 1010: /* scroll to bottom on TTY output inhibit */ if (state) - R->Options &= ~Opt_scrollTtyOutput; + Options &= ~Opt_scrollTtyOutput; else - R->Options |= Opt_scrollTtyOutput; + Options |= Opt_scrollTtyOutput; break; case 1011: /* scroll to bottom on key press */ if (state) - R->Options |= Opt_scrollTtyKeypress; + Options |= Opt_scrollTtyKeypress; else - R->Options &= ~Opt_scrollTtyKeypress; + Options &= ~Opt_scrollTtyKeypress; break; case 1047: /* secondary screen w/ clearing */ case 1049: /* better secondary screen w/ clearing, but not fully implemented */ - if (R->current_screen != PRIMARY) - R->scr_erase_screen (2); - rxvt_scr_change_screen(aR_ state); + if (current_screen != PRIMARY) + scr_erase_screen (2); + scr_change_screen (state); /* FALLTHROUGH */ default: break; @@ -3217,16 +3186,15 @@ rxvt_process_terminal_mode(pR_ int mode, int priv __attribute__((unused)), unsig /*}}} */ /*{{{ process sgr sequences */ -/* INTPROTO */ void -rxvt_process_sgr_mode(pR_ unsigned int nargs, const int *arg) +rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) { unsigned int i; short rendset; int rendstyle; if (nargs == 0) { - rxvt_scr_rendition(aR_ 0, ~RS_None); + scr_rendition (0, ~RS_None); return; } for (i = 0; i < nargs; i++) { @@ -3261,7 +3229,7 @@ rxvt_process_sgr_mode(pR_ unsigned int nargs, const int *arg) break; } if (rendset != -1) { - rxvt_scr_rendition(aR_ rendset, rendstyle); + scr_rendition (rendset, rendstyle); continue; /* for(;i;) */ } @@ -3274,20 +3242,20 @@ rxvt_process_sgr_mode(pR_ unsigned int nargs, const int *arg) case 35: case 36: case 37: - rxvt_scr_color(aR_ (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) { - rxvt_scr_color(aR_ (unsigned int)(minCOLOR + arg[i + 2]), + scr_color ((unsigned int)(minCOLOR + arg[i + 2]), Color_fg); i += 2; } break; #endif case 39: /* default fg */ - rxvt_scr_color(aR_ Color_fg, Color_fg); + scr_color (Color_fg, Color_fg); break; case 40: @@ -3298,20 +3266,20 @@ rxvt_process_sgr_mode(pR_ unsigned int nargs, const int *arg) case 45: case 46: case 47: - rxvt_scr_color(aR_ (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) { - rxvt_scr_color(aR_ (unsigned int)(minCOLOR + arg[i + 2]), + scr_color ((unsigned int)(minCOLOR + arg[i + 2]), Color_bg); i += 2; } break; #endif case 49: /* default bg */ - rxvt_scr_color(aR_ Color_bg, Color_bg); + scr_color (Color_bg, Color_bg); break; #ifndef NO_BRIGHTCOLOR @@ -3323,7 +3291,7 @@ rxvt_process_sgr_mode(pR_ unsigned int nargs, const int *arg) case 95: case 96: case 97: - rxvt_scr_color(aR_ (unsigned int)(minBrightCOLOR + (arg[i] - 90)), + scr_color ((unsigned int)(minBrightCOLOR + (arg[i] - 90)), Color_fg); break; case 100: @@ -3334,7 +3302,7 @@ rxvt_process_sgr_mode(pR_ unsigned int nargs, const int *arg) case 105: case 106: case 107: - rxvt_scr_color(aR_ (unsigned int)(minBrightCOLOR + (arg[i] - 100)), + scr_color ((unsigned int)(minBrightCOLOR + (arg[i] - 100)), Color_bg); break; #endif @@ -3344,20 +3312,19 @@ rxvt_process_sgr_mode(pR_ unsigned int nargs, const int *arg) /*}}} */ /*{{{ process Rob Nation's own graphics mode sequences */ -/* INTPROTO */ void -rxvt_process_graphics(pR) +rxvt_term::process_graphics () { - unsigned char ch, cmd = rxvt_cmd_getc(aR); + unsigned char ch, cmd = cmd_getc (); #ifndef RXVT_GRAPHICS if (cmd == 'Q') { /* query graphics */ - R->tt_printf("\033G0\n"); /* no graphics */ + tt_printf("\033G0\n"); /* no graphics */ return; } /* swallow other graphics sequences until terminating ':' */ do - ch = rxvt_cmd_getc(aR); + ch = cmd_getc (); while (ch != ':'); #else unsigned int nargs; @@ -3365,18 +3332,18 @@ rxvt_process_graphics(pR) unsigned char *text = NULL; if (cmd == 'Q') { /* query graphics */ - R->tt_printf("\033G1\n"); /* yes, graphics (color) */ + tt_printf("\033G1\n"); /* yes, graphics (color) */ return; } for (nargs = 0; nargs < (sizeof(args) / sizeof(args[0])) - 1;) { int neg; - ch = rxvt_cmd_getc(aR); + ch = cmd_getc (); neg = (ch == '-'); if (neg || ch == '+') - ch = rxvt_cmd_getc(aR); + ch = cmd_getc (); - for (args[nargs] = 0; isdigit(ch); ch = rxvt_cmd_getc(aR)) + for (args[nargs] = 0; isdigit(ch); ch = cmd_getc ()) args[nargs] = args[nargs] * 10 + (ch - '0'); if (neg) args[nargs] = -args[nargs]; @@ -3394,11 +3361,11 @@ rxvt_process_graphics(pR) if (text != NULL) { for (i = 0; i < len; i++) - text[i] = rxvt_cmd_getc(aR); + text[i] = cmd_getc (); text[len] = '\0'; } } - rxvt_Gr_do_graphics(aR_ cmd, nargs, args, text); + Gr_do_graphics (cmd, nargs, args, text); #endif } /*}}} */ @@ -3434,8 +3401,9 @@ rxvt_term::tt_write (const unsigned char *data, unsigned int len) { if (v_buflen == 0) { - int written = write (cmd_fd, data, min (MAX_PTY_WRITE, len)); - if (written == len) + ssize_t written = write (cmd_fd, data, min (MAX_PTY_WRITE, len)); + + if ((unsigned int)written == len) return; data += written; diff --git a/src/defaultfont.C b/src/defaultfont.C index 5710c3b1..1edcfae8 100644 --- a/src/defaultfont.C +++ b/src/defaultfont.C @@ -105,7 +105,7 @@ static void *enc_buf; static uint32_t enc_len; static inline void * -get_enc_buf (int len) +get_enc_buf (uint32_t len) { if (len > enc_len) { @@ -117,7 +117,7 @@ get_enc_buf (int len) } static const char * -enc_char (const text_t *text, int len, codeset cs, bool &zero) +enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero) { uint8_t *buf = (uint8_t *)get_enc_buf (len); @@ -138,7 +138,7 @@ enc_char (const text_t *text, int len, codeset cs, bool &zero) } static const XChar2b * -enc_xchar2b (const text_t *text, int len, codeset cs, bool &zero) +enc_xchar2b (const text_t *text, uint32_t len, codeset cs, bool &zero) { XChar2b *buf = (XChar2b *)get_enc_buf (len * sizeof (XChar2b)); @@ -517,8 +517,6 @@ rxvt_font_x11::load (const rxvt_fontprop &prop) if (!f) return false; - unsigned long value; - const char *registry = get_property (f, "CHARSET_REGISTRY", 0); const char *encoding = get_property (f, "CHARSET_ENCODING", 0); @@ -614,8 +612,8 @@ rxvt_font_x11::has_codepoint (uint32_t unicode) if (encm) { - int byte1 = ch >> 8; - int byte2 = ch & 255; + unsigned char byte1 = ch >> 8; + unsigned char byte2 = ch & 255; if (byte1 < f->min_byte1 || byte1 > f->max_byte1 || byte2 < f->min_char_or_byte2 || byte2 > f->max_char_or_byte2) @@ -895,10 +893,7 @@ rxvt_font_xft::draw (int x, int y, int fg, int bg) { if (!d) - { - dR; - d = XftDrawCreate (DISPLAY, DRAWABLE, XVISUAL, XCMAP); - } + d = XftDrawCreate (DISPLAY, DRAWABLE, r->Xvisual, r->Xcmap); if (bg >= 0 && bg != Color_bg) XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); @@ -949,9 +944,7 @@ rxvt_font_xft::draw (int x, int y, ///////////////////////////////////////////////////////////////////////////// rxvt_fontset::rxvt_fontset (rxvt_t r) -#ifdef EXPLICIT_CONTEXT : r(r) -#endif { clear (); } @@ -1028,7 +1021,7 @@ rxvt_fontset::add_fonts (const char *desc) { fprintf (stderr, "extra font parameters not yet supported, skipping.\n"); - const char *extra = desc++; + //const char *extra = desc++; // not yet used desc = strchr (desc, ']'); @@ -1091,14 +1084,14 @@ rxvt_fontset::populate (const char *desc) base_id = 1; // we currently need a base-font, no matter what - if (fonts.size () <= base_id || !realize_font (base_id)) + if ((int)fonts.size () <= base_id || !realize_font (base_id)) { puts ("unable to load specified font(s), falling back to 'fixed'\n"); add_fonts ("fixed"); base_id = fonts.size () - 1; } - if (fonts.size () <= base_id || !realize_font (base_id)) + if ((int)fonts.size () <= base_id || !realize_font (base_id)) { fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n"); exit (1); @@ -1110,7 +1103,7 @@ rxvt_fontset::populate (const char *desc) int rxvt_fontset::find_font (uint32_t unicode) { - for (int i = 0; i < fonts.size (); i++) + for (unsigned int i = 0; i < fonts.size (); i++) { rxvt_font *f = fonts[i]; diff --git a/src/defaultfont.h b/src/defaultfont.h index ec45cc20..ea0be955 100644 --- a/src/defaultfont.h +++ b/src/defaultfont.h @@ -49,7 +49,7 @@ struct rxvt_font { } rxvt_font () { name = 0; } - ~rxvt_font () { free (name); clear (); }; + ~rxvt_font () { clear (); free (name); }; void clear_rect (int x, int y, int w, int h, int color); diff --git a/src/grkelot.C b/src/grkelot.C index 50a274a6..1cc3c677 100644 --- a/src/grkelot.C +++ b/src/grkelot.C @@ -1,7 +1,7 @@ /*---------------------------------*C*--------------------------------------* * File: grkelot.c *--------------------------------------------------------------------------* - * $Id: grkelot.C,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: grkelot.C,v 1.3 2004-01-31 00:20:21 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1994,1995 Angelo Haritsis. All rights reserved. @@ -164,7 +164,6 @@ static void kstate_add_switcher(char *str); static void kstate_set_life(char *str); /* --- Functions ------------- */ -/* INTPROTO */ void kstate_setcurr(int stateno) { @@ -180,7 +179,6 @@ kstate_setcurr(int stateno) pStateNow->prev_state = prev_state; } -/* INTPROTO */ void kstate_init(void) { @@ -188,7 +186,6 @@ kstate_init(void) pStateNow->xlat = NULL; } -/* INTPROTO */ void kstate_end(void) { @@ -204,7 +201,6 @@ kstate_end(void) * Hard coded ELOT-928 translations. Could read these from an rc-type file * to support other remappers. */ -/* INTPROTO */ void kstate_init_all(int greek_mode) { @@ -240,7 +236,6 @@ kstate_init_all(int greek_mode) kstate_set_life("L1"); } -/* INTPROTO */ void kstate_end_all(void) { @@ -256,14 +251,12 @@ kstate_end_all(void) /* * reset FSM */ -/* INTPROTO */ void kstate_reset(void) { kstate_setcurr(0); } -/* INTPROTO */ void kstate_add_xlat(char *str) { @@ -297,7 +290,6 @@ kstate_add_xlat(char *str) /* * Ascii only for this implementation */ -/* INTPROTO */ void kstate_add_switcher(char *str) { @@ -319,14 +311,12 @@ kstate_add_switcher(char *str) } /* L1 or L0 */ -/* INTPROTO */ void kstate_set_life(char *str) { pStateNow->life = atoi(&str[1]); } -/* INTPROTO */ unsigned int kstate_cxlat(unsigned int c) { @@ -353,35 +343,30 @@ kstate_cxlat(unsigned int c) } #ifdef RXVT -/* EXTPROTO */ void greek_init(void) { kstate_init_all(GreekMode); } -/* EXTPROTO */ void greek_end(void) { kstate_end_all(); } -/* EXTPROTO */ void greek_reset(void) { kstate_reset(); } -/* EXTPROTO */ void greek_setmode(int greek_mode) { GreekMode = greek_mode; } -/* EXTPROTO */ int greek_getmode(void) { @@ -391,7 +376,6 @@ greek_getmode(void) /* * xlate a given string in-place - return new string length */ -/* EXTPROTO */ int greek_xlat(char *s, int num_chars) { diff --git a/src/init.C b/src/init.C index b55c0fca..86d191af 100644 --- a/src/init.C +++ b/src/init.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: init.c *----------------------------------------------------------------------* - * $Id: init.C,v 1.19 2004-01-28 23:40:50 pcg Exp $ + * $Id: init.C,v 1.20 2004-01-31 00:20:21 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -527,7 +527,7 @@ rxvt_term::init_resources (int argc, const char *const *argv) if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) rs[Rs_display_name] = ":0"; - rxvt_get_options (this, r_argc, r_argv); + get_options (r_argc, r_argv); free (r_argv); #ifdef LOCAL_X_IS_UNIX @@ -548,7 +548,7 @@ rxvt_term::init_resources (int argc, const char *const *argv) exit (EXIT_FAILURE); } - rxvt_extract_resources (this, Xdisplay, rs[Rs_name]); + extract_resources (Xdisplay, rs[Rs_name]); /* * set any defaults not already set @@ -663,7 +663,7 @@ rxvt_term::init_resources (int argc, const char *const *argv) } #ifdef HAVE_SCROLLBARS - rxvt_setup_scrollbar (this, rs[Rs_scrollBar_align], rs[Rs_scrollstyle], + setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], rs[Rs_scrollBar_thickness]); #endif @@ -802,7 +802,7 @@ rxvt_term::set_locale (const char *locale) { #if HAVE_XSETLOCALE || HAVE_SETLOCALE free (this->locale); - this->locale = strdup (setlocale (LC_CTYPE, "")); + this->locale = rxvt_strdup (setlocale (LC_CTYPE, "")); #endif #if HAVE_NL_LANGINFO free (codeset); @@ -872,7 +872,7 @@ rxvt_term::init_command(const char *const *argv) meta_char = (Options & Opt_meta8 ? 0x80 : C0_ESC); #endif - rxvt_get_ourmods (this); + get_ourmods (); if (!(Options & Opt_scrollTtyOutput)) PrivateModes |= PrivMode_TtyOutputInh; @@ -887,12 +887,12 @@ rxvt_term::init_command(const char *const *argv) #endif /* add value for scrollBar */ - if (scrollbar_visible (this)) + if (scrollbar_visible ()) { PrivateModes |= PrivMode_scrollBar; SavedModes |= PrivMode_scrollBar; } - if (menubar_visible (this)) + if (menubar_visible ()) { PrivateModes |= PrivMode_menuBar; SavedModes |= PrivMode_menuBar; @@ -918,9 +918,8 @@ rxvt_term::init_command(const char *const *argv) } /*----------------------------------------------------------------------*/ -/* INTPROTO */ void -rxvt_Get_Colours (pR) +rxvt_term::Get_Colours () { int i; @@ -928,24 +927,24 @@ rxvt_Get_Colours (pR) { rxvt_color xcol; - if (!R->rs[Rs_color + i]) + if (!rs[Rs_color + i]) continue; - if (!rxvt_rXParseAllocColor(aR_ &xcol, R->rs[Rs_color + i])) + if (!rXParseAllocColor (&xcol, rs[Rs_color + i])) { #ifndef XTERM_REVERSE_VIDEO - if (i < 2 && (R->Options & Opt_reverseVideo)) + if (i < 2 && (Options & Opt_reverseVideo)) { - R->rs[Rs_color + i] = def_colorName[!i]; + rs[Rs_color + i] = def_colorName[!i]; } else #endif - R->rs[Rs_color + i] = def_colorName[i]; + rs[Rs_color + i] = def_colorName[i]; - if (!R->rs[Rs_color + i]) + if (!rs[Rs_color + i]) continue; - if (!rxvt_rXParseAllocColor(aR_ &xcol, R->rs[Rs_color + i])) + if (!rXParseAllocColor (&xcol, rs[Rs_color + i])) { switch (i) { @@ -958,27 +957,27 @@ rxvt_Get_Colours (pR) break; #ifndef NO_CURSORCOLOR case Color_cursor2: - xcol = R->PixColors[Color_fg]; + xcol = PixColors[Color_fg]; break; #endif /* ! NO_CURSORCOLOR */ case Color_pointer: - xcol = R->PixColors[Color_fg]; + xcol = PixColors[Color_fg]; break; default: - xcol = R->PixColors[Color_bg]; /* None */ + xcol = PixColors[Color_bg]; /* None */ break; } } } - R->PixColors[i] = xcol; - SET_PIXCOLOR (R, i); + PixColors[i] = xcol; + SET_PIXCOLOR (i); } - if (XDEPTH <= 2 || !R->rs[Rs_color + Color_pointer]) - R->PixColors[Color_pointer] = R->PixColors[Color_fg]; - if (XDEPTH <= 2 || !R->rs[Rs_color + Color_border]) - R->PixColors[Color_border] = R->PixColors[Color_fg]; + if (XDEPTH <= 2 || !rs[Rs_color + Color_pointer]) + PixColors[Color_pointer] = PixColors[Color_fg]; + if (XDEPTH <= 2 || !rs[Rs_color + Color_border]) + PixColors[Color_border] = PixColors[Color_fg]; /* * get scrollBar/menuBar shadow colors @@ -990,9 +989,9 @@ rxvt_Get_Colours (pR) if (XDEPTH <= 2) { /* Monochrome */ - R->PixColors[Color_scroll] = R->PixColors[Color_fg]; - R->PixColors[Color_topShadow] = R->PixColors[Color_bg]; - R->PixColors[Color_bottomShadow] = R->PixColors[Color_bg]; + PixColors[Color_scroll] = PixColors[Color_fg]; + PixColors[Color_topShadow] = PixColors[Color_bg]; + PixColors[Color_bottomShadow] = PixColors[Color_bg]; } else { @@ -1001,12 +1000,12 @@ rxvt_Get_Colours (pR) * xcol[1] == top shadow * xcol[2] == bot shadow */ - xcol[1] = R->PixColors[Color_scroll]; + xcol[1] = PixColors[Color_scroll]; # ifdef PREFER_24BIT xcol[0].set (R, 65535, 65535, 65535); - /* XFreeColors(R->Xdisplay, XCMAP, &(xcol[0].pixel), 1, ~0); */ + /* XFreeColors(Xdisplay, XCMAP, &(xcol[0].pixel), 1, ~0); */ # else - xcol[0].set (WhitePixel(R->Xdisplay, Xscreen)); + xcol[0].set (WhitePixel(Xdisplay, Xscreen)); # endif unsigned short pr1, pg1, pb1, pr0, pg0, pb0; @@ -1015,19 +1014,18 @@ rxvt_Get_Colours (pR) xcol[1].get (R, pr1, pg1, pb1); /* bottomShadowColor */ - if (!xcol[2].set (aR_ pr1 / 2, pg1 / 2, pb1 / 2)) - xcol[2] = R->PixColors[Color_Black]; + if (!xcol[2].set (pr1 / 2, pg1 / 2, pb1 / 2)) + xcol[2] = PixColors[Color_Black]; - R->PixColors[Color_bottomShadow] = xcol[2]; + PixColors[Color_bottomShadow] = xcol[2]; /* topShadowColor */ - if (!xcol[1].set (aR_ - min (pr0, max (pr0 / 5, pr1) * 7 / 5), + if (!xcol[1].set ( min (pr0, max (pr0 / 5, pr1) * 7 / 5), min (pg0, max (pg0 / 5, pg1) * 7 / 5), min (pb0, max (pb0 / 5, pb1) * 7 / 5))) - xcol[1] = R->PixColors[Color_White]; + xcol[1] = PixColors[Color_White]; - R->PixColors[Color_topShadow] = xcol[1]; + PixColors[Color_topShadow] = xcol[1]; } #endif /* KEEP_SCROLLCOLOR */ } @@ -1060,9 +1058,8 @@ rxvt_term::color_aliases(int idx) * Probe the modifier keymap to get the Meta (Alt) and Num_Lock settings * Use resource ``modifier'' to override the Meta modifier */ -/* INTPROTO */ void -rxvt_get_ourmods(pR) +rxvt_term::get_ourmods () { int i, j, k; int requestedmeta, realmeta, realalt; @@ -1075,12 +1072,12 @@ rxvt_get_ourmods(pR) }; requestedmeta = realmeta = realalt = 0; - rsmod = R->rs[Rs_modifier]; + rsmod = rs[Rs_modifier]; if (rsmod && STRCASECMP(rsmod, "mod1") >= 0 && STRCASECMP(rsmod, "mod5") <= 0) requestedmeta = rsmod[3] - '0'; - map = XGetModifierMapping(R->Xdisplay); + map = XGetModifierMapping(Xdisplay); kc = map->modifiermap; for (i = 1; i < 6; i++) { @@ -1089,10 +1086,10 @@ rxvt_get_ourmods(pR) { if (kc[k] == 0) break; - switch (XKeycodeToKeysym(R->Xdisplay, kc[k], 0)) + switch (XKeycodeToKeysym(Xdisplay, kc[k], 0)) { case XK_Num_Lock: - R->ModNumLockMask = modmasks[i - 1]; + ModNumLockMask = modmasks[i - 1]; /* FALLTHROUGH */ default: continue; /* for(;;) */ @@ -1124,7 +1121,7 @@ rxvt_get_ourmods(pR) : (realmeta ? realmeta : (realalt ? realalt : 0))); if (i) - R->ModMetaMask = modmasks[i - 1]; + ModMetaMask = modmasks[i - 1]; } /*----------------------------------------------------------------------*/ @@ -1137,7 +1134,6 @@ rxvt_term::create_windows (int argc, const char *const *argv) XGCValues gcvalue; long vt_emask; - XSetWindowAttributes attributes; XWindowAttributes gattr; Xcmap = DefaultColormap (Xdisplay, Xscreen); @@ -1173,9 +1169,9 @@ rxvt_term::create_windows (int argc, const char *const *argv) } /* grab colors before netscape does */ - rxvt_Get_Colours (this); + Get_Colours (); - rxvt_change_font (this, 1, NULL); + change_font (1, NULL); window_calc (0, 0); old_width = szHint.width; old_height = szHint.height; @@ -1185,6 +1181,8 @@ rxvt_term::create_windows (int argc, const char *const *argv) */ #ifdef PREFER_24BIT + XSetWindowAttributes attributes; + attributes.background_pixel = PixColors[Color_fg]; attributes.border_pixel = PixColors[Color_border]; attributes.colormap = Xcmap; @@ -1206,8 +1204,8 @@ rxvt_term::create_windows (int argc, const char *const *argv) PixColors[Color_fg]); #endif - rxvt_xterm_seq (this, XTerm_title, rs[Rs_title], CHAR_ST); - rxvt_xterm_seq (this, XTerm_iconName, rs[Rs_iconName], CHAR_ST); + xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); + xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); classHint.res_name = (char *)rs[Rs_name]; classHint.res_class = (char *)APL_CLASS; @@ -1307,10 +1305,10 @@ rxvt_term::create_windows (int argc, const char *const *argv) if ((p = STRCHR(p, ';')) != NULL) { p++; - rxvt_scale_pixmap (this, p); + scale_pixmap (p); } - rxvt_set_bgPixmap (this, rs[Rs_backgroundPixmap]); - rxvt_scr_touch (this, True); + set_bgPixmap (rs[Rs_backgroundPixmap]); + scr_touch (True); } #endif @@ -1370,7 +1368,7 @@ rxvt_term::run_command (const char *const *argv) if (tty_fd < 0) { #ifndef NO_SETOWNER_TTYDEV - rxvt_privileged_ttydev (aR_ SAVE); + privileged_ttydev (SAVE); #endif if ((tty_fd = rxvt_get_tty (ttydev)) < 0) @@ -1428,7 +1426,7 @@ rxvt_term::run_command (const char *const *argv) #endif #ifdef UTMP_SUPPORT - rxvt_privileged_utmp (this, SAVE); + privileged_utmp (SAVE); #endif #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) @@ -1603,7 +1601,7 @@ rxvt_term::run_child (const char *const *argv) * GET TTY CURRENT STATE * * ------------------------------------------------------------------------- */ /* rxvt_get_ttymode() */ -/* INTPROTO */ +/* EXTPROTO */ void rxvt_get_ttymode(ttymode_t *tio, int erase) { diff --git a/src/logging.C b/src/logging.C index 192f6ed8..7273e207 100644 --- a/src/logging.C +++ b/src/logging.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: logging.c *----------------------------------------------------------------------* - * $Id: logging.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ + * $Id: logging.C,v 1.4 2004-01-31 00:20:21 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey @@ -56,15 +56,14 @@ /* * make and write utmp and wtmp entries */ -/* EXTPROTO */ void -rxvt_makeutent(pR_ const char *pty, const char *hostname) +rxvt_term::makeutent (const char *pty, const char *hostname) { #ifdef HAVE_STRUCT_UTMP - struct utmp *ut = &(R->ut); + struct utmp *ut = &(this->ut); #endif #ifdef HAVE_STRUCT_UTMPX - struct utmpx *utx = &(R->utx); + struct utmpx *utx = &(this->utx); #endif #ifdef HAVE_UTMP_PID int i; @@ -94,7 +93,7 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id)); ut->ut_type = DEAD_PROCESS; getutid(ut); /* position to entry in utmp file */ - STRNCPY(R->ut_id, ut_id, sizeof(R->ut_id)); + STRNCPY(ut_id, ut_id, sizeof(ut_id)); # endif #endif @@ -104,7 +103,7 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id)); utx->ut_type = DEAD_PROCESS; getutxid(utx); /* position to entry in utmp file */ - STRNCPY(R->ut_id, ut_id, sizeof(R->ut_id)); + STRNCPY(ut_id, ut_id, sizeof(ut_id)); #endif #ifdef HAVE_STRUCT_UTMP @@ -115,14 +114,14 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) sizeof(ut->ut_user)); STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id)); ut->ut_time = time(NULL); - ut->ut_pid = R->cmd_pid; + ut->ut_pid = cmd_pid; # ifdef HAVE_UTMP_HOST STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host)); # endif ut->ut_type = USER_PROCESS; pututline(ut); endutent(); /* close the file */ - R->utmp_pos = 0; + utmp_pos = 0; # else STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?", sizeof(ut->ut_name)); @@ -140,7 +139,7 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) utx->ut_session = getsid(0); utx->ut_tv.tv_sec = time(NULL); utx->ut_tv.tv_usec = 0; - utx->ut_pid = R->cmd_pid; + utx->ut_pid = cmd_pid; # ifdef HAVE_UTMPX_HOST STRNCPY(utx->ut_host, hostname, sizeof(utx->ut_host)); # if 0 @@ -155,7 +154,7 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) utx->ut_type = USER_PROCESS; pututxline(utx); endutxent(); /* close the file */ - R->utmp_pos = 0; + utmp_pos = 0; #endif #if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID) @@ -164,7 +163,7 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) # ifdef HAVE_TTYSLOT i = ttyslot(); if (rxvt_write_bsd_utmp(i, ut)) - R->utmp_pos = i; + utmp_pos = i; # else FILE *fd0; @@ -178,7 +177,7 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) if (!STRCMP(ut->ut_line, name)) { if (!rxvt_write_bsd_utmp(i, ut)) i = 0; - R->utmp_pos = i; + utmp_pos = i; fclose(fd0); break; } @@ -192,7 +191,7 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) #ifdef WTMP_SUPPORT # ifdef WTMP_ONLY_ON_LOGIN - if (R->Options & Opt_loginShell) + if (Options & Opt_loginShell) # endif { # ifdef HAVE_STRUCT_UTMP @@ -208,7 +207,7 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) } #endif #if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) - if (R->Options & Opt_loginShell) + if (Options & Opt_loginShell) rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname); #endif } @@ -217,22 +216,21 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) /* * remove utmp and wtmp entries */ -/* EXTPROTO */ void -rxvt_cleanutent(pR) +rxvt_term::cleanutent () { #ifdef HAVE_STRUCT_UTMP - struct utmp *ut = &(R->ut); + struct utmp *ut = &(this->ut); #endif #ifdef HAVE_STRUCT_UTMPX - struct utmpx *tmputx, *utx = &(R->utx); + struct utmpx *tmputx, *utx = &(this->utx); #endif #ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UTMP_PID MEMSET(ut, 0, sizeof(struct utmp)); setutent(); - STRNCPY(ut->ut_id, R->ut_id, sizeof(ut->ut_id)); + STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id)); ut->ut_type = USER_PROCESS; { struct utmp *tmput = getutid(ut); @@ -253,7 +251,7 @@ rxvt_cleanutent(pR) #ifdef HAVE_STRUCT_UTMPX MEMSET(utx, 0, sizeof(struct utmpx)); setutxent(); - STRNCPY(utx->ut_id, R->ut_id, sizeof(utx->ut_id)); + STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id)); utx->ut_type = USER_PROCESS; if ((tmputx = getutxid(utx))) /* position to entry in utmp file */ utx = tmputx; @@ -268,7 +266,7 @@ rxvt_cleanutent(pR) */ #ifdef WTMP_SUPPORT # ifdef WTMP_ONLY_ON_LOGIN - if (R->Options & Opt_loginShell) + if (Options & Opt_loginShell) # endif { # ifdef HAVE_STRUCT_UTMP @@ -289,16 +287,16 @@ rxvt_cleanutent(pR) */ #ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UTMP_PID - if (ut->ut_pid == R->cmd_pid) + if (ut->ut_pid == cmd_pid) pututline(ut); endutent(); # else MEMSET(ut, 0, sizeof(struct utmp)); - rxvt_write_bsd_utmp(R->utmp_pos, ut); + rxvt_write_bsd_utmp(utmp_pos, ut); # endif #endif #ifdef HAVE_STRUCT_UTMPX - if (utx->ut_pid == R->cmd_pid) + if (utx->ut_pid == cmd_pid) pututxline(utx); endutxent(); #endif diff --git a/src/main.C b/src/main.C index e3ae841c..e1f2821d 100644 --- a/src/main.C +++ b/src/main.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: main.c *----------------------------------------------------------------------* - * $Id: main.C,v 1.21 2004-01-29 23:26:01 pcg Exp $ + * $Id: main.C,v 1.22 2004-01-31 00:20:21 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -74,7 +74,7 @@ rxvt_term::operator delete (void *p, size_t s) } rxvt_term::rxvt_term () -: destroy_ev (this, &rxvt_term::destroy_cb), +: #ifdef CURSOR_BLINK cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), #endif @@ -84,10 +84,11 @@ rxvt_term::rxvt_term () #ifdef POINTER_BLANK pointer_ev (this, &rxvt_term::pointer_cb), #endif - x_ev (this, &rxvt_term::x_cb), - check_ev (this, &rxvt_term::check_cb), - incr_ev (this, &rxvt_term::incr_cb), - pty_ev (this, &rxvt_term::pty_cb) + check_ev (this, &rxvt_term::check_cb), + destroy_ev (this, &rxvt_term::destroy_cb), + pty_ev (this, &rxvt_term::pty_cb), + x_ev (this, &rxvt_term::x_cb), + incr_ev (this, &rxvt_term::incr_cb) { cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; } @@ -100,10 +101,10 @@ rxvt_term::~rxvt_term () free (codeset); #ifndef NO_SETOWNER_TTYDEV - rxvt_privileged_ttydev (this, RESTORE); + privileged_ttydev (RESTORE); #endif #ifdef UTMP_SUPPORT - rxvt_privileged_utmp (this, RESTORE); + privileged_utmp (RESTORE); #endif #ifdef USE_XIM if (Input_Context != NULL) @@ -156,18 +157,16 @@ rxvt_t rxvt_init (int argc, const char *const *argv) { SET_R (new rxvt_term); - dR; - if (!R->init_vars () || !R->init (argc, argv)) + if (!GET_R->init_vars () || !GET_R->init (argc, argv)) { - delete R; - return NULL; + delete GET_R; + SET_R (0); } - return R; + return GET_R; } -/* EXTPROTO */ void rxvt_init_signals () { @@ -207,8 +206,8 @@ rxvt_term::init (int argc, const char *const *argv) * 1. write utmp entries on some systems * 2. chown tty on some systems */ - rxvt_privileges (this, SAVE); - rxvt_privileges (this, IGNORE); + privileges (SAVE); + privileges (IGNORE); init_secondary (); @@ -217,7 +216,7 @@ rxvt_term::init (int argc, const char *const *argv) set_locale (""); #if (MENUBAR_MAX) - rxvt_menubar_read (this, rs[Rs_menu]); + menubar_read (rs[Rs_menu]); #endif #ifdef HAVE_SCROLLBARS if (Options & Opt_scrollBar) @@ -230,7 +229,7 @@ rxvt_term::init (int argc, const char *const *argv) scr_reset (); /* initialize screen */ #ifdef RXVT_GRAPHICS - rxvt_Gr_reset (this); /* reset graphics */ + Gr_reset (); /* reset graphics */ #endif #if 0 @@ -251,7 +250,7 @@ rxvt_term::init (int argc, const char *const *argv) if (Options & Opt_transparent) { XSelectInput (Xdisplay, Xroot, PropertyChangeMask); - rxvt_check_our_parents (this); + check_our_parents (); } #endif XMapWindow (Xdisplay, TermWin.vt); @@ -287,7 +286,7 @@ rxvt_Child_signal(int sig __attribute__ ((unused))) errno = save_errno; #if 0 - if (pid == R->cmd_pid) + if (pid == cmd_pid) exit (EXIT_SUCCESS); #endif } @@ -308,22 +307,20 @@ rxvt_Exit_signal(int sig) } /* ARGSUSED */ -/* INTPROTO */ +/* EXTPROTO */ int rxvt_xerror_handler(const Display * display __attribute__ ((unused)), const XErrorEvent * event) { - dR; - - if (R->allowedxerror == -1) - R->allowedxerror = event->error_code; + if (GET_R->allowedxerror == -1) + GET_R->allowedxerror = event->error_code; else { rxvt_print_error("XError: Request: %d . %d, Error: %d", event->request_code, event->minor_code, event->error_code); - R->destroy (); + GET_R->destroy (); } return 0; @@ -338,9 +335,7 @@ rxvt_xerror_handler(const Display * display void rxvt_clean_exit () { - dR; - - R->destroy (); + GET_R->destroy (); } /* ------------------------------------------------------------------------- * @@ -401,9 +396,8 @@ rxvt_realloc(void *ptr, size_t size) * PRIVILEGED OPERATIONS * * ------------------------------------------------------------------------- */ /* take care of suid/sgid super-user (root) privileges */ -/* INTPROTO */ void -rxvt_privileges(pR_ int mode) +rxvt_term::privileges (int mode) { #if ! defined(__CYGWIN32__) # if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) @@ -423,12 +417,12 @@ rxvt_privileges(pR_ int mode) setegid(getgid()); break; case SAVE: - R->euid = geteuid(); - R->egid = getegid(); + euid = geteuid(); + egid = getegid(); break; case RESTORE: - seteuid(R->euid); - setegid(R->egid); + seteuid(euid); + setegid(egid); break; } # else @@ -447,79 +441,77 @@ rxvt_privileges(pR_ int mode) } #ifdef UTMP_SUPPORT -/* EXTPROTO */ void -rxvt_privileged_utmp(pR_ char action) +rxvt_term::privileged_utmp (char action) { D_MAIN((stderr, "rxvt_privileged_utmp(%c); waiting for: %c (pid: %d)", - action, R->next_utmp_action, getpid())); - if (R->next_utmp_action != action || (action != SAVE && action != RESTORE) - || (R->Options & Opt_utmpInhibit) - || R->ttydev == NULL || *R->ttydev == '\0') + action, next_utmp_action, getpid())); + if (next_utmp_action != action || (action != SAVE && action != RESTORE) + || (Options & Opt_utmpInhibit) + || ttydev == NULL || *ttydev == '\0') return; - rxvt_privileges(aR_ RESTORE); + privileges (RESTORE); if (action == SAVE) { - R->next_utmp_action = RESTORE; - rxvt_makeutent(aR_ R->ttydev, R->rs[Rs_display_name]); + next_utmp_action = RESTORE; + makeutent (ttydev, rs[Rs_display_name]); } else { /* action == RESTORE */ - R->next_utmp_action = IGNORE; - rxvt_cleanutent(aR); + next_utmp_action = IGNORE; + cleanutent (); } - rxvt_privileges(aR_ IGNORE); + privileges (IGNORE); } #endif #ifndef NO_SETOWNER_TTYDEV -/* EXTPROTO */ void -rxvt_privileged_ttydev(pR_ char action) +rxvt_term::privileged_ttydev (char action) { D_MAIN((stderr, - "rxvt_privileged_ttydev(aR_ %c); waiting for: %c (pid: %d)", - action, R->next_tty_action, getpid())); - if (R->next_tty_action != action || (action != SAVE && action != RESTORE) - || R->ttydev == NULL || *R->ttydev == '\0') + "privileged_ttydev (%c); waiting for: %c (pid: %d)", + action, next_tty_action, getpid())); + if (next_tty_action != action || (action != SAVE && action != RESTORE) + || ttydev == NULL || *ttydev == '\0') return; - rxvt_privileges(aR_ RESTORE); + privileges (RESTORE); if (action == SAVE) { - R->next_tty_action = RESTORE; + next_tty_action = RESTORE; # ifndef RESET_TTY_TO_COMMON_DEFAULTS /* store original tty status for restoration rxvt_clean_exit() -- rgg 04/12/95 */ - if (lstat(R->ttydev, &R->ttyfd_stat) < 0) /* you lose out */ - R->next_tty_action = IGNORE; + if (lstat(ttydev, &ttyfd_stat) < 0) /* you lose out */ + next_tty_action = IGNORE; else # endif { - chown(R->ttydev, getuid(), R->ttygid); /* fail silently */ - chmod(R->ttydev, R->ttymode); + chown(ttydev, getuid(), ttygid); /* fail silently */ + chmod(ttydev, ttymode); # ifdef HAVE_REVOKE - revoke(R->ttydev); + revoke(ttydev); # endif } } else { /* action == RESTORE */ - R->next_tty_action = IGNORE; + next_tty_action = IGNORE; # ifndef RESET_TTY_TO_COMMON_DEFAULTS - chmod(R->ttydev, R->ttyfd_stat.st_mode); - chown(R->ttydev, R->ttyfd_stat.st_uid, R->ttyfd_stat.st_gid); + chmod(ttydev, ttyfd_stat.st_mode); + chown(ttydev, ttyfd_stat.st_uid, ttyfd_stat.st_gid); # else - chmod(R->ttydev, + chmod(ttydev, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); - chown(R->ttydev, 0, 0); + chown(ttydev, 0, 0); # endif } - rxvt_privileges(aR_ IGNORE); + privileges (IGNORE); # ifndef RESET_TTY_TO_COMMON_DEFAULTS D_MAIN((stderr, "%s \"%s\": mode %03o, uid %d, gid %d", action == RESTORE ? "Restoring" : (action == SAVE ? "Saving" : - "UNKNOWN ERROR for"), R->ttydev, - R->ttyfd_stat.st_mode, R->ttyfd_stat.st_uid, - R->ttyfd_stat.st_gid)); + "UNKNOWN ERROR for"), ttydev, + ttyfd_stat.st_mode, ttyfd_stat.st_uid, + ttyfd_stat.st_gid)); # endif } #endif @@ -588,13 +580,13 @@ rxvt_term::window_calc (unsigned int width, unsigned int height) sb_w = mb_h = 0; window_vt_x = window_vt_y = 0; - if (scrollbar_visible (this)) { + if (scrollbar_visible ()) { sb_w = scrollbar_TotalWidth(); szHint.base_width += sb_w; if (!(Options & Opt_scrollBar_right)) window_vt_x = sb_w; } - if (menubar_visible (this)) { + if (menubar_visible ()) { mb_h = menuBar_TotalHeight(); szHint.base_height += mb_h; window_vt_y = mb_h; @@ -618,7 +610,7 @@ rxvt_term::window_calc (unsigned int width, unsigned int height) MIN_IT(TermWin.height, max_height); szHint.height = szHint.base_height + TermWin.height; } - if (scrollbar_visible (this) && (Options & Opt_scrollBar_right)) + if (scrollbar_visible () && (Options & Opt_scrollBar_right)) window_sb_x = szHint.width - sb_w; if (recalc_x) @@ -672,61 +664,56 @@ rxvt_term::tt_winch () * fontname == FONT_UP - switch to bigger font * fontname == FONT_DN - switch to smaller font */ -/* EXTPROTO */ void -rxvt_change_font(pR_ int init, const char *fontname) +rxvt_term::change_font (int init, const char *fontname) { } -/* INTPROTO */ void -rxvt_font_up_down(pR_ int n, int direction) +rxvt_term::font_up_down (int n, int direction) { } /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ /* xterm sequences - title, iconName, color (exptl) */ -/* EXTPROTO */ void -rxvt_set_title(pR_ const char *str) +rxvt_term::set_title (const char *str) { #ifndef SMART_WINDOW_TITLE - XStoreName(R->Xdisplay, R->TermWin.parent[0], str); + XStoreName(Xdisplay, TermWin.parent[0], str); #else char *name; - if (XFetchName(R->Xdisplay, R->TermWin.parent[0], &name) == 0) + if (XFetchName(Xdisplay, TermWin.parent[0], &name) == 0) name = NULL; if (name == NULL || STRCMP(name, str)) - XStoreName(R->Xdisplay, R->TermWin.parent[0], str); + XStoreName(Xdisplay, TermWin.parent[0], str); if (name) XFree(name); #endif } -/* EXTPROTO */ void -rxvt_set_iconName(pR_ const char *str) +rxvt_term::set_iconName (const char *str) { #ifndef SMART_WINDOW_TITLE - XSetIconName(R->Xdisplay, R->TermWin.parent[0], str); + XSetIconName(Xdisplay, TermWin.parent[0], str); #else char *name; - if (XGetIconName(R->Xdisplay, R->TermWin.parent[0], &name)) + if (XGetIconName(Xdisplay, TermWin.parent[0], &name)) name = NULL; if (name == NULL || STRCMP(name, str)) - XSetIconName(R->Xdisplay, R->TermWin.parent[0], str); + XSetIconName(Xdisplay, TermWin.parent[0], str); if (name) XFree(name); #endif } #ifdef XTERM_COLOR_CHANGE -/* EXTPROTO */ void -rxvt_set_window_color(pR_ int idx, const char *color) +rxvt_term::set_window_color (int idx, const char *color) { rxvt_color xcol; int i; @@ -740,20 +727,20 @@ rxvt_set_window_color(pR_ int idx, const char *color) if (i >= 8 && i <= 15) { /* bright colors */ i -= 8; # ifndef NO_BRIGHTCOLOR - R->PixColors[idx] = R->PixColors[minBrightCOLOR + i]; - SET_PIXCOLOR(R, idx); + PixColors[idx] = PixColors[minBrightCOLOR + i]; + SET_PIXCOLOR(idx); goto Done; # endif } if (i >= 0 && i <= 7) { /* normal colors */ - R->PixColors[idx] = R->PixColors[minCOLOR + i]; - SET_PIXCOLOR(R, idx); + PixColors[idx] = PixColors[minCOLOR + i]; + SET_PIXCOLOR(idx); goto Done; } } - if (!rxvt_rXParseAllocColor(aR_ & xcol, color)) + if (!rXParseAllocColor (& xcol, color)) return; -/* XStoreColor (R->Xdisplay, XCMAP, XColor*); */ +/* XStoreColor (Xdisplay, XCMAP, XColor*); */ /* * FIXME: should free colors here, but no idea how to do it so instead, @@ -761,35 +748,35 @@ rxvt_set_window_color(pR_ int idx, const char *color) */ # if 0 for (i = Color_Black; i <= Color_White; i++) - if (R->PixColors[idx] == R->PixColors[i]) + if (PixColors[idx] == PixColors[i]) break; if (i > Color_White) { - /* fprintf (stderr, "XFreeColors: R->PixColors [%d] = %lu\n", idx, R->PixColors [idx]); */ - XFreeColors(R->Xdisplay, XCMAP, (R->PixColors + idx), 1, - DisplayPlanes(R->Xdisplay, Xscreen)); + /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */ + XFreeColors(Xdisplay, XCMAP, (PixColors + idx), 1, + DisplayPlanes(Xdisplay, Xscreen)); } # endif - R->PixColors[idx] = xcol; - SET_PIXCOLOR(R, idx); + PixColors[idx] = xcol; + SET_PIXCOLOR(idx); /* XSetWindowAttributes attr; */ /* Cursor cursor; */ Done: - if (idx == Color_bg && !(R->Options & Opt_transparent)) - XSetWindowBackground(R->Xdisplay, R->TermWin.vt, - R->PixColors[Color_bg]); + if (idx == Color_bg && !(Options & Opt_transparent)) + XSetWindowBackground(Xdisplay, TermWin.vt, + PixColors[Color_bg]); /* handle Color_BD, scrollbar background, etc. */ - rxvt_set_colorfgbg (aR); - R->recolour_cursor (); + set_colorfgbg (); + recolour_cursor (); /* the only reasonable way to enforce a clean update */ - rxvt_scr_poweron (aR); + scr_poweron (); } #else -# define rxvt_set_window_color(aR_ idx,color) ((void)0) +# define set_window_color (idx,color) ((void)0) #endif /* XTERM_COLOR_CHANGE */ void @@ -809,41 +796,40 @@ rxvt_term::recolour_cursor () /* * find if fg/bg matches any of the normal (low-intensity) colors */ -/* INTPROTO */ void -rxvt_set_colorfgbg(pR) +rxvt_term::set_colorfgbg () { unsigned int i; const char *xpmb = "\0"; char fstr[sizeof("default") + 1], bstr[sizeof("default") + 1]; - R->env_colorfgbg = + env_colorfgbg = (char *)rxvt_malloc(sizeof("COLORFGBG=default;default;bg") + 1); STRCPY(fstr, "default"); STRCPY(bstr, "default"); for (i = Color_Black; i <= Color_White; i++) - if (R->PixColors[Color_fg] == R->PixColors[i]) { + if (PixColors[Color_fg] == PixColors[i]) { sprintf(fstr, "%d", (i - Color_Black)); break; } for (i = Color_Black; i <= Color_White; i++) - if (R->PixColors[Color_bg] == R->PixColors[i]) { + if (PixColors[Color_bg] == PixColors[i]) { sprintf(bstr, "%d", (i - Color_Black)); #ifdef XPM_BACKGROUND xpmb = "default;"; #endif break; } - sprintf(R->env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); - putenv(R->env_colorfgbg); + sprintf(env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); + putenv(env_colorfgbg); #ifndef NO_BRIGHTCOLOR - R->colorfgbg = DEFAULT_RSTYLE; + colorfgbg = DEFAULT_RSTYLE; for (i = minCOLOR; i <= maxCOLOR; i++) { - if (R->PixColors[Color_fg] == R->PixColors[i]) - R->colorfgbg = SET_FGCOLOR(R->colorfgbg, i); - if (R->PixColors[Color_bg] == R->PixColors[i]) - R->colorfgbg = SET_BGCOLOR(R->colorfgbg, i); + if (PixColors[Color_fg] == PixColors[i]) + colorfgbg = SET_FGCOLOR(colorfgbg, i); + if (PixColors[Color_bg] == PixColors[i]) + colorfgbg = SET_BGCOLOR(colorfgbg, i); } #endif } @@ -854,13 +840,10 @@ rxvt_set_colorfgbg(pR) * Hans de Goede */ -/* EXTPROTO */ int -rxvt_rXParseAllocColor(pR_ rxvt_color * screen_in_out, const char *colour) +rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) { - screen_in_out->set(aR_ colour); - - if (!screen_in_out->set(aR_ colour)) { + if (!screen_in_out->set (this, colour)) { rxvt_print_error("can't allocate colour: %s", colour); return false; } @@ -935,14 +918,14 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno if (fix_screen || width != old_width || height != old_height) { - if (scrollbar_visible (this)) + if (scrollbar_visible ()) { XMoveResizeWindow (Xdisplay, scrollBar.win, window_sb_x, 0, scrollbar_TotalWidth (), szHint.height); resize_scrollbar (); } - if (menubar_visible (this)) + if (menubar_visible ()) XMoveResizeWindow (Xdisplay, menuBar.win, window_vt_x, 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); @@ -951,12 +934,12 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno TermWin_TotalHeight ()); #ifdef RXVT_GRAPHICS if (old_height) - rxvt_Gr_Resize (this, old_width - szHint.base_width, + Gr_Resize (old_width - szHint.base_width, old_height - szHint.base_height); #endif scr_clear (); #ifdef XPM_BACKGROUND - rxvt_resize_pixmap (this); + resize_pixmap (); #endif } @@ -970,7 +953,7 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno { unsigned int ncol = TermWin.ncol; TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this - curr_screen = rxvt_scr_change_screen (this, PRIMARY); + curr_screen = scr_change_screen (PRIMARY); TermWin.ncol = ncol; } @@ -978,8 +961,8 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno if (curr_screen >= 0) /* this is not the first time through */ { - rxvt_scr_change_screen (this, curr_screen); - rxvt_selection_check (this, old_ncol != TermWin.ncol ? 4 : 0); + scr_change_screen (curr_screen); + selection_check (old_ncol != TermWin.ncol ? 4 : 0); } } @@ -987,7 +970,7 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno old_height = szHint.height; #ifdef USE_XIM - rxvt_IMSetStatusPosition (this); + IMSetStatusPosition (); #endif } @@ -995,23 +978,22 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno * Set the width/height of the vt window in characters. Units are pixels. * good for toggling 80/132 columns */ -/* EXTPROTO */ void -rxvt_set_widthheight(pR_ unsigned int width, unsigned int height) +rxvt_term::set_widthheight (unsigned int width, unsigned int height) { XWindowAttributes wattr; if (width == 0 || height == 0) { - XGetWindowAttributes(R->Xdisplay, Xroot, &wattr); + XGetWindowAttributes(Xdisplay, Xroot, &wattr); if (width == 0) - width = wattr.width - R->szHint.base_width; + width = wattr.width - szHint.base_width; if (height == 0) - height = wattr.height - R->szHint.base_height; + height = wattr.height - szHint.base_height; } - if (width != R->TermWin.width || height != R->TermWin.height) { - width += R->szHint.base_width; - height += R->szHint.base_height; - R->resize_all_windows (width, height, 0); + if (width != TermWin.width || height != TermWin.height) { + width += szHint.base_width; + height += szHint.base_height; + resize_all_windows (width, height, 0); } } @@ -1036,9 +1018,8 @@ rxvt_term::set_color (unsigned long *fg, unsigned long *bg) } /* Checking whether input method is running. */ -/* INTPROTO */ -Bool -rxvt_IMisRunning(pR) +bool +rxvt_term::IMisRunning () { char *p; Atom atom; @@ -1052,35 +1033,34 @@ rxvt_IMisRunning(pR) if ((p = STRCHR(server + 1, '@')) != NULL) /* first one only */ *p = '\0'; - atom = XInternAtom(R->Xdisplay, server, False); - win = XGetSelectionOwner(R->Xdisplay, atom); + atom = XInternAtom(Xdisplay, server, False); + win = XGetSelectionOwner(Xdisplay, atom); if (win != None) return True; } return False; } -/* EXTPROTO */ void -rxvt_IMSendSpot(pR) +rxvt_term::IMSendSpot () { XPoint spot; XVaNestedList preedit_attr; - if (R->Input_Context == NULL - || !R->TermWin.focus || !(R->input_style & XIMPreeditPosition) - || !(R->event_type == KeyPress - || R->event_type == Expose - || R->event_type == NoExpose - || R->event_type == SelectionNotify - || R->event_type == ButtonRelease || R->event_type == FocusIn) - || !rxvt_IMisRunning(aR)) + if (Input_Context == NULL + || !TermWin.focus || !(input_style & XIMPreeditPosition) + || !(event_type == KeyPress + || event_type == Expose + || event_type == NoExpose + || event_type == SelectionNotify + || event_type == ButtonRelease || event_type == FocusIn) + || !IMisRunning ()) return; - R->set_position (&spot); + set_position (&spot); preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); - XSetICValues(R->Input_Context, XNPreeditAttributes, preedit_attr, NULL); + XSetICValues(Input_Context, XNPreeditAttributes, preedit_attr, NULL); XFree(preedit_attr); } @@ -1090,10 +1070,10 @@ rxvt_term::set_preedit_area (XRectangle * preedit_rect, XRectangle * status_rect { int mbh, vtx = 0; - if (scrollbar_visible (this) && !(Options & Opt_scrollBar_right)) + if (scrollbar_visible () && !(Options & Opt_scrollBar_right)) vtx = scrollbar_TotalWidth(); - mbh = menubar_visible (this) ? menuBar_TotalHeight() : 0; + mbh = menubar_visible () ? menuBar_TotalHeight() : 0; mbh -= TermWin.lineSpace; preedit_rect->x = needed_rect->width + vtx; @@ -1110,18 +1090,16 @@ rxvt_term::set_preedit_area (XRectangle * preedit_rect, XRectangle * status_rect } /* ARGSUSED */ -/* INTPROTO */ +/* EXTPROTO */ void rxvt_IMDestroyCallback(XIM xim __attribute__ ((unused)), XPointer client_data __attribute__ ((unused)), XPointer call_data __attribute__ ((unused))) { - dR; - - R->Input_Context = NULL; + GET_R->Input_Context = NULL; /* To avoid Segmentation Fault in C locale: Solaris only? */ - if (STRCMP(R->locale, "C")) - XRegisterIMInstantiateCallback(R->Xdisplay, NULL, NULL, NULL, + if (STRCMP (GET_R->locale, "C")) + XRegisterIMInstantiateCallback(GET_R->Xdisplay, NULL, NULL, NULL, rxvt_IMInstantiateCallback, NULL); } @@ -1129,8 +1107,8 @@ rxvt_IMDestroyCallback(XIM xim __attribute__ ((unused)), XPointer client_data * Try to open a XIM with the current modifiers, then see if we can * open a suitable preedit type */ -static Bool -rxvt_IM_get_IC (pR) +bool +rxvt_term::IM_get_IC () { int i, j, found; XIM xim; @@ -1144,7 +1122,7 @@ rxvt_IM_get_IC (pR) XIMCallback ximcallback; D_MAIN((stderr, "rxvt_IM_get_IC()")); - xim = XOpenIM (R->Xdisplay, NULL, NULL, NULL); + xim = XOpenIM (Xdisplay, NULL, NULL, NULL); if (xim == NULL) return False; @@ -1155,19 +1133,19 @@ rxvt_IM_get_IC (pR) return False; } - p = R->rs[Rs_preeditType] ? R->rs[Rs_preeditType] + p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root"; s = rxvt_splitcommastring(p); for (i = found = 0; !found && s[i]; i++) { if (!STRCMP(s[i], "OverTheSpot")) - R->input_style = (XIMPreeditPosition | XIMStatusNothing); + input_style = (XIMPreeditPosition | XIMStatusNothing); else if (!STRCMP(s[i], "OffTheSpot")) - R->input_style = (XIMPreeditArea | XIMStatusArea); + input_style = (XIMPreeditArea | XIMStatusArea); else if (!STRCMP(s[i], "Root")) - R->input_style = (XIMPreeditNothing | XIMStatusNothing); + input_style = (XIMPreeditNothing | XIMStatusNothing); for (j = 0; j < xim_styles->count_styles; j++) - if (R->input_style == xim_styles->supported_styles[j]) { + if (input_style == xim_styles->supported_styles[j]) { found = 1; break; } @@ -1189,18 +1167,18 @@ rxvt_IM_get_IC (pR) preedit_attr = status_attr = NULL; - if (R->input_style & XIMPreeditPosition) { - R->set_size (&rect); - R->set_position (&spot); - R->set_color (&fg, &bg); + if (input_style & XIMPreeditPosition) { + set_size (&rect); + set_position (&spot); + set_color (&fg, &bg); preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNSpotLocation, &spot, XNForeground, fg, XNBackground, bg, - //XNFontSet, R->TermWin.fontset, + //XNFontSet, TermWin.fontset, NULL); - } else if (R->input_style & XIMPreeditArea) { - R->set_color (&fg, &bg); + } else if (input_style & XIMPreeditArea) { + set_color (&fg, &bg); /* * The necessary width of preedit area is unknown @@ -1208,20 +1186,20 @@ rxvt_IM_get_IC (pR) */ needed_rect.width = 0; - R->set_preedit_area(&rect, &status_rect, &needed_rect); + set_preedit_area(&rect, &status_rect, &needed_rect); preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNForeground, fg, XNBackground, bg, - //XNFontSet, R->TermWin.fontset, + //XNFontSet, TermWin.fontset, NULL); status_attr = XVaCreateNestedList(0, XNArea, &status_rect, XNForeground, fg, XNBackground, bg, - //XNFontSet, R->TermWin.fontset, + //XNFontSet, TermWin.fontset, NULL); } - R->Input_Context = XCreateIC(xim, XNInputStyle, R->input_style, - XNClientWindow, R->TermWin.parent[0], - XNFocusWindow, R->TermWin.parent[0], + Input_Context = XCreateIC(xim, XNInputStyle, input_style, + XNClientWindow, TermWin.parent[0], + XNFocusWindow, TermWin.parent[0], XNDestroyCallback, &ximcallback, preedit_attr ? XNPreeditAttributes : NULL, preedit_attr, @@ -1231,13 +1209,13 @@ rxvt_IM_get_IC (pR) XFree(preedit_attr); if (status_attr) XFree(status_attr); - if (R->Input_Context == NULL) { + if (Input_Context == NULL) { rxvt_print_error("failed to create input context"); XCloseIM(xim); return False; } - if (R->input_style & XIMPreeditArea) - rxvt_IMSetStatusPosition(aR); + if (input_style & XIMPreeditArea) + IMSetStatusPosition (); D_MAIN((stderr, "rxvt_IM_get_IC() - successful connection")); return True; } @@ -1256,22 +1234,21 @@ rxvt_IMInstantiateCallback(Display * unused __attribute__ ((unused)), XPointer call_data __attribute__ ((unused))) { - dR; int i, found, had_im; const char *p; char **s; char buf[IMBUFSIZ]; D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); - if (R->Input_Context) + if (GET_R->Input_Context) return; #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) - if (R->rs[Rs_imLocale]) - setlocale (LC_CTYPE, R->rs[Rs_imLocale]); + if (GET_R->rs[Rs_imLocale]) + setlocale (LC_CTYPE, GET_R->rs[Rs_imLocale]); #endif - p = R->rs[Rs_inputMethod]; + p = GET_R->rs[Rs_inputMethod]; if (p && *p) { bool found = false; @@ -1283,8 +1260,7 @@ rxvt_IMInstantiateCallback(Display * unused { STRCPY (buf, "@im="); STRNCAT (buf, s[i], IMBUFSIZ - 5); - if ((p = XSetLocaleModifiers (buf)) && *p - && rxvt_IM_get_IC (aR)) + if ((p = XSetLocaleModifiers (buf)) && *p && GET_R->IM_get_IC ()) { found = true; break; @@ -1301,44 +1277,43 @@ rxvt_IMInstantiateCallback(Display * unused /* try with XMODIFIERS env. var. */ if ((p = XSetLocaleModifiers ("")) && *p - && rxvt_IM_get_IC (aR)) + && GET_R->IM_get_IC ()) goto done; /* try with no modifiers base IF the user didn't specify an IM */ if ((p = XSetLocaleModifiers ("@im=none")) && *p - && rxvt_IM_get_IC (aR) == True) + && GET_R->IM_get_IC () == True) goto done; done: #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) - if (R->rs[Rs_imLocale]) - setlocale (LC_CTYPE, R->locale); + if (GET_R->rs[Rs_imLocale]) + setlocale (LC_CTYPE, GET_R->locale); #endif } -/* EXTPROTO */ void -rxvt_IMSetStatusPosition(pR) +rxvt_term::IMSetStatusPosition () { XRectangle preedit_rect, status_rect, *needed_rect; XVaNestedList preedit_attr, status_attr; - if (R->Input_Context == NULL - || !R->TermWin.focus || !(R->input_style & XIMPreeditArea) - || !rxvt_IMisRunning(aR)) + if (Input_Context == NULL + || !TermWin.focus || !(input_style & XIMPreeditArea) + || !IMisRunning ()) return; /* Getting the necessary width of preedit area */ status_attr = XVaCreateNestedList(0, XNAreaNeeded, &needed_rect, NULL); - XGetICValues(R->Input_Context, XNStatusAttributes, status_attr, NULL); + XGetICValues(Input_Context, XNStatusAttributes, status_attr, NULL); XFree(status_attr); - R->set_preedit_area(&preedit_rect, &status_rect, needed_rect); + set_preedit_area(&preedit_rect, &status_rect, needed_rect); preedit_attr = XVaCreateNestedList(0, XNArea, &preedit_rect, NULL); status_attr = XVaCreateNestedList(0, XNArea, &status_rect, NULL); - XSetICValues(R->Input_Context, + XSetICValues(Input_Context, XNPreeditAttributes, preedit_attr, XNStatusAttributes, status_attr, NULL); diff --git a/src/menubar.C b/src/menubar.C index c557fb23..8f7b3028 100644 --- a/src/menubar.C +++ b/src/menubar.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: menubar.c *----------------------------------------------------------------------* - * $Id: menubar.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ + * $Id: menubar.C,v 1.4 2004-01-31 00:20:21 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * @@ -48,7 +48,6 @@ static const struct { /* * find an item called NAME in MENU */ -/* INTPROTO */ menuitem_t * rxvt_menuitem_find(const menu_t *menu, const char *name) { @@ -74,9 +73,8 @@ rxvt_menuitem_find(const menu_t *menu, const char *name) /* * unlink ITEM from its MENU and free its memory */ -/* INTPROTO */ void -rxvt_menuitem_free(pR_ menu_t *menu, menuitem_t *item) +rxvt_term::menuitem_free (menu_t *menu, menuitem_t *item) { /* disconnect */ menuitem_t *prev, *next; @@ -104,7 +102,7 @@ rxvt_menuitem_free(pR_ menu_t *menu, menuitem_t *item) free(item->entry.action.str); break; case MenuSubMenu: - rxvt_menu_delete(aR_ item->entry.submenu.menu); + menu_delete (item->entry.submenu.menu); break; } if (item->name != NULL) @@ -118,7 +116,6 @@ rxvt_menuitem_free(pR_ menu_t *menu, menuitem_t *item) * sort command vs. terminal actions and * remove the first character of STR if it's '\0' */ -/* INTPROTO */ int rxvt_action_type(action_t *action, unsigned char *str) { @@ -155,17 +152,16 @@ rxvt_action_type(action_t *action, unsigned char *str) return 0; } -/* INTPROTO */ int -rxvt_action_dispatch(pR_ action_t *action) +rxvt_term::action_dispatch (action_t *action) { switch (action->type) { case MenuTerminalAction: - rxvt_cmd_write(aR_ action->str, action->len); + cmd_write (action->str, action->len); break; case MenuAction: - rxvt_tt_write(aR_ action->str, action->len); + tt_write (action->str, action->len); break; default: @@ -176,7 +172,6 @@ rxvt_action_dispatch(pR_ action_t *action) } /* return the arrow index corresponding to NAME */ -/* INTPROTO */ int rxvt_menuarrow_find(char name) { @@ -189,16 +184,15 @@ rxvt_menuarrow_find(char name) } /* free the memory associated with arrow NAME of the current menubar */ -/* INTPROTO */ void -rxvt_menuarrow_free(pR_ char name) +rxvt_term::menuarrow_free (char name) { int i; if (name) { i = rxvt_menuarrow_find(name); if (i >= 0) { - action_t *act = &(R->CurrentBar->arrows[i]); + action_t *act = &(CurrentBar->arrows[i]); switch (act->type) { case MenuAction: @@ -212,13 +206,12 @@ rxvt_menuarrow_free(pR_ char name) } } else { for (i = 0; i < NARROWS; i++) - rxvt_menuarrow_free(aR_ Arrows[i].name); + menuarrow_free (Arrows[i].name); } } -/* INTPROTO */ void -rxvt_menuarrow_add(pR_ char *string) +rxvt_term::menuarrow_add (char *string) { int i; unsigned xtra_len; @@ -302,7 +295,7 @@ rxvt_menuarrow_add(pR_ char *string) xtra_len = (beg.len + end.len); for (i = 0; i < NARROWS; i++) { if (xtra_len || parse[i].len) - rxvt_menuarrow_free(aR_ Arrows[i].name); + menuarrow_free (Arrows[i].name); } for (i = 0; i < NARROWS; i++) { @@ -331,12 +324,11 @@ rxvt_menuarrow_add(pR_ char *string) #ifdef DEBUG_MENUARROWS fprintf(stderr, "<%c>(len %d) = %s\n", Arrows[i].name, len, str); #endif - if (rxvt_action_type(&(R->CurrentBar->arrows[i]), str) < 0) + if (rxvt_action_type(&(CurrentBar->arrows[i]), str) < 0) free(str); } } -/* INTPROTO */ menuitem_t * rxvt_menuitem_add(menu_t *menu, const char *name, const char *name2, const char *action) { @@ -440,16 +432,15 @@ rxvt_menuitem_add(menu_t *menu, const char *name, const char *name2, const char * search for the base starting menu for NAME. * return a pointer to the portion of NAME that remains */ -/* INTPROTO */ char * -rxvt_menu_find_base(pR_ menu_t **menu, char *path) +rxvt_term::menu_find_base (menu_t **menu, char *path) { menu_t *m = NULL; menuitem_t *item; #ifdef DEBUG_STRICT assert(menu != NULL); - assert(R->CurrentBar != NULL); + assert(CurrentBar != NULL); #endif if (path[0] == '\0') @@ -477,7 +468,7 @@ rxvt_menu_find_base(pR_ menu_t **menu, char *path) if (*menu != NULL) *menu = (*menu)->parent; } else { - path = rxvt_menu_find_base(aR_ menu, path); + path = menu_find_base (menu, path); if (path[0] != '\0') { /* not found */ p[0] = '/'; /* fix-up name again */ return path; @@ -495,7 +486,7 @@ rxvt_menu_find_base(pR_ menu_t **menu, char *path) } /* find this menu */ if (*menu == NULL) { - for (m = R->CurrentBar->tail; m != NULL; m = m->prev) { + for (m = CurrentBar->tail; m != NULL; m = m->prev) { if (!STRCMP(path, m->name)) break; } @@ -519,13 +510,12 @@ rxvt_menu_find_base(pR_ menu_t **menu, char *path) /* * delete this entire menu */ -/* INTPROTO */ menu_t * -rxvt_menu_delete(pR_ menu_t *menu) +rxvt_term::menu_delete (menu_t *menu) { menu_t *parent = NULL, *prev, *next; menuitem_t *item; - bar_t *CurrentBar = R->CurrentBar; + bar_t *CurrentBar = CurrentBar; #ifdef DEBUG_STRICT assert(CurrentBar != NULL); @@ -561,7 +551,7 @@ rxvt_menu_delete(pR_ menu_t *menu) if (item->entry.type == MenuSubMenu && item->entry.submenu.menu == menu) { item->entry.submenu.menu = NULL; - rxvt_menuitem_free(aR_ menu->parent, item); + menuitem_free (menu->parent, item); break; } } @@ -571,7 +561,7 @@ rxvt_menu_delete(pR_ menu_t *menu) while (item != NULL) { menuitem_t *p = item->prev; - rxvt_menuitem_free(aR_ menu, item); + menuitem_free (menu, item); item = p; } @@ -582,12 +572,11 @@ rxvt_menu_delete(pR_ menu_t *menu) return parent; } -/* INTPROTO */ menu_t * -rxvt_menu_add(pR_ menu_t *parent, char *path) +rxvt_term::menu_add (menu_t *parent, char *path) { menu_t *menu; - bar_t *CurrentBar = R->CurrentBar; + bar_t *CurrentBar = CurrentBar; #ifdef DEBUG_STRICT assert(CurrentBar != NULL); @@ -606,7 +595,7 @@ rxvt_menu_add(pR_ menu_t *parent, char *path) if (path[0] == '\0') return NULL; - parent = rxvt_menu_add(aR_ parent, path); + parent = menu_add (parent, path); path = (p + 1); } } @@ -661,17 +650,16 @@ rxvt_menu_add(pR_ menu_t *parent, char *path) return menu; } -/* INTPROTO */ void -rxvt_drawbox_menubar(pR_ int x, int len, int state) +rxvt_term::drawbox_menubar (int x, int len, int state) { GC top, bot; x = Width2Pixel(x); len = Width2Pixel(len + HSPACE); - if (x >= R->TermWin.width) + if (x >= TermWin.width) return; - else if (x + len >= R->TermWin.width) + else if (x + len >= TermWin.width) len = (TermWin_TotalWidth() - x); #ifdef MENUBAR_SHADOW_IN @@ -679,25 +667,24 @@ rxvt_drawbox_menubar(pR_ int x, int len, int state) #endif switch (state) { case +1: - top = R->topShadowGC; - bot = R->botShadowGC; + top = topShadowGC; + bot = botShadowGC; break; /* SHADOW_OUT */ case -1: - top = R->botShadowGC; - bot = R->topShadowGC; + top = botShadowGC; + bot = topShadowGC; break; /* SHADOW_IN */ default: - top = bot = R->scrollbarGC; + top = bot = scrollbarGC; break; /* neutral */ } - rxvt_Draw_Shadow(R->Xdisplay, R->menuBar.win, top, bot, + rxvt_Draw_Shadow(Xdisplay, menuBar.win, top, bot, x, 0, len, menuBar_TotalHeight()); } -/* INTPROTO */ void -rxvt_drawtriangle(pR_ int x, int y, int state) +rxvt_term::drawtriangle (int x, int y, int state) { GC top, bot; int w; @@ -707,15 +694,15 @@ rxvt_drawtriangle(pR_ int x, int y, int state) #endif switch (state) { case +1: - top = R->topShadowGC; - bot = R->botShadowGC; + top = topShadowGC; + bot = botShadowGC; break; /* SHADOW_OUT */ case -1: - top = R->botShadowGC; - bot = R->topShadowGC; + top = botShadowGC; + bot = topShadowGC; break; /* SHADOW_IN */ default: - top = bot = R->scrollbarGC; + top = bot = scrollbarGC; break; /* neutral */ } @@ -724,13 +711,12 @@ rxvt_drawtriangle(pR_ int x, int y, int state) x -= SHADOW + (3 * w / 2); y += SHADOW * 3; - rxvt_Draw_Triangle(R->Xdisplay, R->ActiveMenu->win, top, bot, x, y, w, + rxvt_Draw_Triangle(Xdisplay, ActiveMenu->win, top, bot, x, y, w, 'r'); } -/* INTPROTO */ void -rxvt_drawbox_menuitem(pR_ int y, int state) +rxvt_term::drawbox_menuitem (int y, int state) { GC top, bot; @@ -739,27 +725,26 @@ rxvt_drawbox_menuitem(pR_ int y, int state) #endif switch (state) { case +1: - top = R->topShadowGC; - bot = R->botShadowGC; + top = topShadowGC; + bot = botShadowGC; break; /* SHADOW_OUT */ case -1: - top = R->botShadowGC; - bot = R->topShadowGC; + top = botShadowGC; + bot = topShadowGC; break; /* SHADOW_IN */ default: - top = bot = R->scrollbarGC; + top = bot = scrollbarGC; break; /* neutral */ } - rxvt_Draw_Shadow(R->Xdisplay, R->ActiveMenu->win, top, bot, + rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, top, bot, SHADOW + 0, SHADOW + y, - R->ActiveMenu->w - 2 * (SHADOW), + ActiveMenu->w - 2 * (SHADOW), HEIGHT_TEXT + 2 * SHADOW); - XFlush(R->Xdisplay); + XFlush(Xdisplay); } #ifdef DEBUG_MENU_LAYOUT -/* INTPROTO */ void rxvt_print_menu_ancestors(menu_t *menu) { @@ -786,7 +771,6 @@ rxvt_print_menu_ancestors(menu_t *menu) rxvt_print_menu_ancestors(menu->parent); } -/* INTPROTO */ void rxvt_print_menu_descendants(menu_t *menu) { @@ -827,12 +811,11 @@ rxvt_print_menu_descendants(menu_t *menu) #endif /* pop up/down the current menu and redraw the menuBar button */ -/* INTPROTO */ void -rxvt_menu_show(pR) +rxvt_term::menu_show () { int x, y, xright; - menu_t *ActiveMenu = R->ActiveMenu; + menu_t *ActiveMenu = ActiveMenu; menuitem_t *item; if (ActiveMenu == NULL) @@ -842,13 +825,13 @@ rxvt_menu_show(pR) if (ActiveMenu->parent == NULL) { register int h; - rxvt_drawbox_menubar(aR_ x, ActiveMenu->len, -1); + drawbox_menubar (x, ActiveMenu->len, -1); x = Width2Pixel(x); ActiveMenu->y = 1; ActiveMenu->w = Menu_PixelWidth(ActiveMenu); - if ((x + ActiveMenu->w) >= R->TermWin.width) + if ((x + ActiveMenu->w) >= TermWin.width) x = (TermWin_TotalWidth() - ActiveMenu->w); /* find the height */ @@ -858,16 +841,16 @@ rxvt_menu_show(pR) ActiveMenu->h = h + 2 * SHADOW; } if (ActiveMenu->win == None) { - ActiveMenu->win = XCreateSimpleWindow(R->Xdisplay, R->TermWin.vt, + ActiveMenu->win = XCreateSimpleWindow(Xdisplay, TermWin.vt, x, ActiveMenu->y, ActiveMenu->w, ActiveMenu->h, 0, - R->PixColors[Color_fg], - R->PixColors[Color_scroll]); - XMapWindow(R->Xdisplay, ActiveMenu->win); + PixColors[Color_fg], + PixColors[Color_scroll]); + XMapWindow(Xdisplay, ActiveMenu->win); } - rxvt_Draw_Shadow(R->Xdisplay, ActiveMenu->win, - R->topShadowGC, R->botShadowGC, + rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, + topShadowGC, botShadowGC, 0, 0, ActiveMenu->w, ActiveMenu->h); /* determine the correct right-alignment */ @@ -878,11 +861,11 @@ rxvt_menu_show(pR) for (y = 0, item = ActiveMenu->head; item != NULL; item = item->next) { const int xoff = (SHADOW + Width2Pixel(HSPACE) / 2); register int h; - GC gc = R->menubarGC; + GC gc = menubarGC; if (isSeparator(item->name)) { - rxvt_Draw_Shadow(R->Xdisplay, ActiveMenu->win, - R->topShadowGC, R->botShadowGC, + rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, + topShadowGC, botShadowGC, SHADOW, y + SHADOW + 1, ActiveMenu->w - 2 * SHADOW, 0); h = HEIGHT_SEPARATOR; @@ -891,13 +874,13 @@ rxvt_menu_show(pR) int len = item->len; if (item->entry.type == MenuLabel) { - gc = R->botShadowGC; + gc = botShadowGC; } else if (item->entry.type == MenuSubMenu) { int x1, y1; menuitem_t *it; menu_t *menu = item->entry.submenu.menu; - rxvt_drawtriangle(aR_ ActiveMenu->w, y, +1); + drawtriangle (ActiveMenu->w, y, +1); name = menu->name; len = menu->len; @@ -919,10 +902,10 @@ rxvt_menu_show(pR) menu->h = h + 2 * SHADOW; /* ensure menu is in window limits */ - if ((x1 + menu->w) >= R->TermWin.width) + if ((x1 + menu->w) >= TermWin.width) x1 = (TermWin_TotalWidth() - menu->w); - if ((y1 + menu->h) >= R->TermWin.height) + if ((y1 + menu->h) >= TermWin.height) y1 = (TermWin_TotalHeight() - menu->h); menu->x = (x1 < 0 ? 0 : x1); @@ -932,16 +915,16 @@ rxvt_menu_show(pR) if (len && name) { #ifdef USE_XIM - if (R->TermWin.fontset) - XmbDrawString(R->Xdisplay, - ActiveMenu->win, R->TermWin.fontset, + if (TermWin.fontset) + XmbDrawString(Xdisplay, + ActiveMenu->win, TermWin.fontset, gc, xoff, - 2 * SHADOW + y + R->TermWin.font->ascent + 1, + 2 * SHADOW + y + TermWin.font->ascent + 1, name, len); else #endif - XDrawString(R->Xdisplay, ActiveMenu->win, gc, xoff, - 2 * SHADOW + y + R->TermWin.font->ascent + 1, + XDrawString(Xdisplay, ActiveMenu->win, gc, xoff, + 2 * SHADOW + y + TermWin.font->ascent + 1, name, len); } @@ -949,18 +932,18 @@ rxvt_menu_show(pR) name = item->name2; if (len && name) { #ifdef USE_XIM - if (R->TermWin.fontset) - XmbDrawString(R->Xdisplay, - ActiveMenu->win, R->TermWin.fontset, + if (TermWin.fontset) + XmbDrawString(Xdisplay, + ActiveMenu->win, TermWin.fontset, gc, ActiveMenu->w - (xoff + Width2Pixel(xright)), - 2 * SHADOW + y + R->TermWin.font->ascent + 1, + 2 * SHADOW + y + TermWin.font->ascent + 1, name, len); else #endif - XDrawString(R->Xdisplay, ActiveMenu->win, gc, + XDrawString(Xdisplay, ActiveMenu->win, gc, ActiveMenu->w - (xoff + Width2Pixel(xright)), - 2 * SHADOW + y + R->TermWin.font->ascent + 1, + 2 * SHADOW + y + TermWin.font->ascent + 1, name, len); } h = HEIGHT_TEXT + 2 * SHADOW; @@ -969,48 +952,44 @@ rxvt_menu_show(pR) } } -/* INTPROTO */ void -rxvt_menu_display(pR_ void (*update)(rxvt_t *)) +rxvt_term::menu_display (void (*update)(rxvt_t *)) { - menu_t *ActiveMenu = R->ActiveMenu; + menu_t *ActiveMenu = ActiveMenu; if (ActiveMenu == NULL) return; if (ActiveMenu->win != None) - XDestroyWindow(R->Xdisplay, ActiveMenu->win); + XDestroyWindow(Xdisplay, ActiveMenu->win); ActiveMenu->win = None; ActiveMenu->item = NULL; if (ActiveMenu->parent == NULL) - rxvt_drawbox_menubar(aR_ ActiveMenu->x, ActiveMenu->len, +1); - R->ActiveMenu = ActiveMenu->parent; + drawbox_menubar (ActiveMenu->x, ActiveMenu->len, +1); + ActiveMenu = ActiveMenu->parent; update(r); } -/* INTPROTO */ void -rxvt_menu_hide_all(pR) +rxvt_term::menu_hide_all () { - rxvt_menu_display(aR_ rxvt_menu_hide_all); + menu_display (rxvt_menu_hide_all); } -/* INTPROTO */ void -rxvt_menu_hide(pR) +rxvt_term::menu_hide () { - rxvt_menu_display(aR_ rxvt_menu_show); + menu_display (rxvt_menu_show); } -/* INTPROTO */ void -rxvt_menu_clear(pR_ menu_t *menu) +rxvt_term::menu_clear (menu_t *menu) { if (menu != NULL) { menuitem_t *item = menu->tail; while (item != NULL) { - rxvt_menuitem_free(aR_ menu, item); + menuitem_free (menu, item); /* it didn't get freed ... why? */ if (item == menu->tail) return; @@ -1020,11 +999,10 @@ rxvt_menu_clear(pR_ menu_t *menu) } } -/* INTPROTO */ void -rxvt_menubar_clear(pR) +rxvt_term::menubar_clear () { - bar_t *CurrentBar = R->CurrentBar; + bar_t *CurrentBar = CurrentBar; if (CurrentBar != NULL) { menu_t *menu = CurrentBar->tail; @@ -1032,7 +1010,7 @@ rxvt_menubar_clear(pR) while (menu != NULL) { menu_t *prev = menu->prev; - rxvt_menu_delete(aR_ menu); + menu_delete (menu); menu = prev; } CurrentBar->head = CurrentBar->tail = NULL; @@ -1041,18 +1019,17 @@ rxvt_menubar_clear(pR) free(CurrentBar->title); CurrentBar->title = NULL; } - rxvt_menuarrow_free(aR_ 0); /* remove all arrow functions */ + menuarrow_free (0); /* remove all arrow functions */ } - R->ActiveMenu = NULL; + ActiveMenu = NULL; } #if (MENUBAR_MAX > 1) /* find if menu already exists */ -/* INTPROTO */ bar_t * -rxvt_menubar_find(pR_ const char *name) +rxvt_term::menubar_find (const char *name) { - bar_t *bar = R->CurrentBar; + bar_t *bar = CurrentBar; #ifdef DEBUG_MENUBAR_STACKING fprintf(stderr, "looking for [menu:%s] ...", name ? name : "(nil)"); @@ -1070,7 +1047,7 @@ rxvt_menubar_find(pR_ const char *name) } bar = bar->next; } - while (bar != R->CurrentBar); + while (bar != CurrentBar); bar = NULL; } #ifdef DEBUG_MENUBAR_STACKING @@ -1080,14 +1057,13 @@ rxvt_menubar_find(pR_ const char *name) return bar; } -/* INTPROTO */ int -rxvt_menubar_push(pR_ const char *name) +rxvt_term::menubar_push (const char *name) { int ret = 1; bar_t *bar; - if (R->CurrentBar == NULL) { + if (CurrentBar == NULL) { /* allocate first one */ bar = (bar_t *) rxvt_malloc(sizeof(bar_t)); @@ -1096,91 +1072,89 @@ rxvt_menubar_push(pR_ const char *name) bar->next = bar->prev = bar; bar->head = bar->tail = NULL; bar->title = NULL; - R->CurrentBar = bar; - R->Nbars++; + CurrentBar = bar; + Nbars++; - rxvt_menubar_clear(aR); + menubar_clear (); } else { /* find if menu already exists */ - bar = rxvt_menubar_find(aR_ name); + bar = menubar_find (name); if (bar != NULL) { /* found it, use it */ - R->CurrentBar = bar; + CurrentBar = bar; } else { /* create if needed, or reuse the existing empty menubar */ - if (R->CurrentBar->head != NULL) { + if (CurrentBar->head != NULL) { /* need to malloc another one */ - if (R->Nbars < MENUBAR_MAX) + if (Nbars < MENUBAR_MAX) bar = (bar_t *) rxvt_malloc(sizeof(bar_t)); else bar = NULL; /* malloc failed or too many menubars, reuse another */ if (bar == NULL) { - bar = R->CurrentBar->next; + bar = CurrentBar->next; ret = -1; } else { bar->head = bar->tail = NULL; bar->title = NULL; - bar->next = R->CurrentBar->next; - R->CurrentBar->next = bar; - bar->prev = R->CurrentBar; + bar->next = CurrentBar->next; + CurrentBar->next = bar; + bar->prev = CurrentBar; bar->next->prev = bar; - R->Nbars++; + Nbars++; } - R->CurrentBar = bar; + CurrentBar = bar; } - rxvt_menubar_clear(aR); + menubar_clear (); } } /* give menubar this name */ - STRNCPY(R->CurrentBar->name, name, MAXNAME); - R->CurrentBar->name[MAXNAME - 1] = '\0'; + STRNCPY(CurrentBar->name, name, MAXNAME); + CurrentBar->name[MAXNAME - 1] = '\0'; return ret; } /* switch to a menu called NAME and remove it */ -/* INTPROTO */ void -rxvt_menubar_remove(pR_ const char *name) +rxvt_term::menubar_remove (const char *name) { bar_t *bar; - if ((bar = rxvt_menubar_find(aR_ name)) == NULL) + if ((bar = menubar_find (name)) == NULL) return; - R->CurrentBar = bar; + CurrentBar = bar; do { - rxvt_menubar_clear(aR); + menubar_clear (); /* * pop a menubar, clean it up first */ - if (R->CurrentBar != NULL) { - bar_t *prev = R->CurrentBar->prev; - bar_t *next = R->CurrentBar->next; + if (CurrentBar != NULL) { + bar_t *prev = CurrentBar->prev; + bar_t *next = CurrentBar->next; - if (prev == next && prev == R->CurrentBar) { /* only 1 left */ + if (prev == next && prev == CurrentBar) { /* only 1 left */ prev = NULL; - R->Nbars = 0; /* safety */ + Nbars = 0; /* safety */ } else { next->prev = prev; prev->next = next; - R->Nbars--; + Nbars--; } - free(R->CurrentBar); - R->CurrentBar = prev; + free(CurrentBar); + CurrentBar = prev; } } - while (R->CurrentBar && !STRCMP(name, "*")); + while (CurrentBar && !STRCMP(name, "*")); } -/* INTPROTO */ void rxvt_action_decode(FILE *fp, action_t *act) { @@ -1252,7 +1226,6 @@ rxvt_action_decode(FILE *fp, action_t *act) fprintf(fp, "\n"); } -/* INTPROTO */ void rxvt_menu_dump(FILE *fp, menu_t *menu) { @@ -1288,11 +1261,10 @@ rxvt_menu_dump(FILE *fp, menu_t *menu) fprintf(fp, (menu->parent ? "../\n" : "/\n\n")); } -/* INTPROTO */ void -rxvt_menubar_dump(pR_ FILE *fp) +rxvt_term::menubar_dump (FILE *fp) { - bar_t *bar = R->CurrentBar; + bar_t *bar = CurrentBar; time_t t; if (bar == NULL || fp == NULL) @@ -1301,10 +1273,10 @@ rxvt_menubar_dump(pR_ FILE *fp) fprintf(fp, "# " APL_SUBCLASS " (%s) Pid: %u\n# Date: %s\n\n", - R->rs[Rs_name], (unsigned int)getpid(), ctime(&t)); + rs[Rs_name], (unsigned int)getpid(), ctime(&t)); /* dump in reverse order */ - bar = R->CurrentBar->prev; + bar = CurrentBar->prev; do { menu_t *menu; int i; @@ -1331,7 +1303,7 @@ rxvt_menubar_dump(pR_ FILE *fp) fprintf(fp, "\n[done:%s]\n\n", bar->name); bar = bar->prev; } - while (bar != R->CurrentBar->prev); + while (bar != CurrentBar->prev); } #endif /* (MENUBAR_MAX > 1) */ @@ -1350,16 +1322,15 @@ rxvt_menubar_dump(pR_ FILE *fp) * FILENAME = "file;tag" * read `file' starting with [menu:tag] */ -/* EXTPROTO */ void -rxvt_menubar_read(pR_ const char *filename) +rxvt_term::menubar_read (const char *filename) { /* read in a menu from a file */ FILE *fp; char buffer[256]; char *p, *file, *tag = NULL; - file = (char *)rxvt_File_find(filename, ".menu", R->rs[Rs_path]); + file = (char *)rxvt_File_find(filename, ".menu", rs[Rs_path]); if (file == NULL) return; fp = fopen(file, "rb"); @@ -1413,12 +1384,12 @@ rxvt_menubar_read(pR_ const char *filename) /* looking for [done:tag] or [done:] */ if ((n = rxvt_Str_match(p, "[done")) != 0) { if (p[n] == ']') { - R->menu_readonly = 1; + menu_readonly = 1; break; } else if (p[n] == ':') { n++; if (p[n] == ']') { - R->menu_readonly = 1; + menu_readonly = 1; break; } else if (tag) { n += rxvt_Str_match(p + n, tag); @@ -1426,7 +1397,7 @@ rxvt_menubar_read(pR_ const char *filename) #ifdef DEBUG_MENU fprintf(stderr, "[done:%s]\n", tag); #endif - R->menu_readonly = 1; + menu_readonly = 1; break; } } else { @@ -1442,8 +1413,8 @@ rxvt_menubar_read(pR_ const char *filename) */ rxvt_Str_trim(p); if (*p && *p != '#') { - R->menu_readonly = 0; /* if case we read another file */ - rxvt_menubar_dispatch(aR_ p); + menu_readonly = 0; /* if case we read another file */ + menubar_dispatch (p); } /* get another line */ p = fgets(buffer, sizeof(buffer), fp); @@ -1455,17 +1426,16 @@ rxvt_menubar_read(pR_ const char *filename) /* * user interface for building/deleting and otherwise managing menus */ -/* EXTPROTO */ void -rxvt_menubar_dispatch(pR_ char *str) +rxvt_term::menubar_dispatch (char *str) { int n, cmd; char *path, *name, *name2; - if (menubar_visible(r) && R->ActiveMenu != NULL) - rxvt_menubar_expose(aR); + if (menubar_visible(r) && ActiveMenu != NULL) + menubar_expose (); else - R->ActiveMenu = NULL; + ActiveMenu = NULL; cmd = *str; switch (cmd) { @@ -1483,11 +1453,11 @@ rxvt_menubar_dispatch(pR_ char *str) case '<': #if (MENUBAR_MAX > 1) - if (R->CurrentBar == NULL) + if (CurrentBar == NULL) break; #endif /* (MENUBAR_MAX > 1) */ if (str[1] && str[2] == '>') /* arrow commands */ - rxvt_menuarrow_add(aR_ str); + menuarrow_add (str); break; case '[': /* extended command */ @@ -1516,45 +1486,45 @@ rxvt_menubar_dispatch(pR_ char *str) int saved; /* try and dispatch it, regardless of read/write status */ - saved = R->menu_readonly; - R->menu_readonly = 0; - rxvt_menubar_dispatch(aR_ str + 1); - R->menu_readonly = saved; + saved = menu_readonly; + menu_readonly = 0; + menubar_dispatch (str + 1); + menu_readonly = saved; } /* these ones don't require menu stacking */ else if (!STRCMP(str, "clear")) { - rxvt_menubar_clear(aR); + menubar_clear (); } else if (!STRCMP(str, "done") || rxvt_Str_match(str, "done:")) { - R->menu_readonly = 1; + menu_readonly = 1; } else if (!STRCMP(str, "show")) { - rxvt_map_menuBar(aR_ 1); - R->menu_readonly = 1; + map_menuBar (1); + menu_readonly = 1; } else if (!STRCMP(str, "hide")) { - rxvt_map_menuBar(aR_ 0); - R->menu_readonly = 1; + map_menuBar (0); + menu_readonly = 1; } else if ((n = rxvt_Str_match(str, "read:")) != 0) { /* read in a menu from a file */ str += n; - rxvt_menubar_read(aR_ str); + menubar_read (str); } else if ((n = rxvt_Str_match(str, "title:")) != 0) { str += n; - if (R->CurrentBar != NULL && !R->menu_readonly) { + if (CurrentBar != NULL && !menu_readonly) { if (*str) { - name = rxvt_realloc(R->CurrentBar->title, + name = rxvt_realloc(CurrentBar->title, STRLEN(str) + 1); if (name != NULL) { STRCPY(name, str); - R->CurrentBar->title = name; + CurrentBar->title = name; } - rxvt_menubar_expose(aR); + menubar_expose (); } else { - free(R->CurrentBar->title); - R->CurrentBar->title = NULL; + free(CurrentBar->title); + CurrentBar->title = NULL; } } } else if ((n = rxvt_Str_match(str, "pixmap:")) != 0) { str += n; - rxvt_xterm_seq(aR_ XTerm_Pixmap, str, CHAR_ST); + xterm_seq (XTerm_Pixmap, str, CHAR_ST); } #if (MENUBAR_MAX > 1) else if ((n = rxvt_Str_match(str, "rm")) != 0) { @@ -1566,10 +1536,10 @@ rxvt_menubar_dispatch(pR_ char *str) case '\0': /* FALLTHROUGH */ case '*': - rxvt_menubar_remove(aR_ str); + menubar_remove (str); break; } - R->menu_readonly = 1; + menu_readonly = 1; } else if ((n = rxvt_Str_match(str, "menu")) != 0) { str += n; switch (str[0]) { @@ -1577,16 +1547,16 @@ rxvt_menubar_dispatch(pR_ char *str) str++; /* add/access menuBar */ if (*str != '\0' && *str != '*') - rxvt_menubar_push(aR_ str); + menubar_push (str); break; default: - if (R->CurrentBar == NULL) { - rxvt_menubar_push(aR_ "default"); + if (CurrentBar == NULL) { + menubar_push ("default"); } } - if (R->CurrentBar != NULL) - R->menu_readonly = 0; /* allow menu build commands */ + if (CurrentBar != NULL) + menu_readonly = 0; /* allow menu build commands */ } else if (!STRCMP(str, "dump")) { /* dump current menubars to a file */ FILE *fp; @@ -1598,47 +1568,47 @@ rxvt_menubar_dispatch(pR_ char *str) (unsigned int)getpid()); if ((fp = fopen(buffer, "wb")) != NULL) { - rxvt_xterm_seq(aR_ XTerm_title, buffer, CHAR_ST); - rxvt_menubar_dump(aR_ fp); + xterm_seq (XTerm_title, buffer, CHAR_ST); + menubar_dump (fp); fclose(fp); } } else if (!STRCMP(str, "next")) { - if (R->CurrentBar) { - R->CurrentBar = R->CurrentBar->next; - R->menu_readonly = 1; + if (CurrentBar) { + CurrentBar = CurrentBar->next; + menu_readonly = 1; } } else if (!STRCMP(str, "prev")) { - if (R->CurrentBar) { - R->CurrentBar = R->CurrentBar->prev; - R->menu_readonly = 1; + if (CurrentBar) { + CurrentBar = CurrentBar->prev; + menu_readonly = 1; } } else if (!STRCMP(str, "swap")) { /* swap the top 2 menus */ - if (R->CurrentBar) { - bar_t *cbprev = R->CurrentBar->prev; - bar_t *cbnext = R->CurrentBar->next; + if (CurrentBar) { + bar_t *cbprev = CurrentBar->prev; + bar_t *cbnext = CurrentBar->next; cbprev->next = cbnext; cbnext->prev = cbprev; - R->CurrentBar->next = cbprev; - R->CurrentBar->prev = cbprev->prev; + CurrentBar->next = cbprev; + CurrentBar->prev = cbprev->prev; - cbprev->prev->next = R->CurrentBar; - cbprev->prev = R->CurrentBar; + cbprev->prev->next = CurrentBar; + cbprev->prev = CurrentBar; - R->CurrentBar = cbprev; - R->menu_readonly = 1; + CurrentBar = cbprev; + menu_readonly = 1; } } #endif /* (MENUBAR_MAX > 1) */ str = next; - R->BuildMenu = R->ActiveMenu = NULL; - rxvt_menubar_expose(aR); + BuildMenu = ActiveMenu = NULL; + menubar_expose (); #ifdef DEBUG_MENUBAR_STACKING fprintf(stderr, "menus are read%s\n", - R->menu_readonly ? "only" : "/write"); + menu_readonly ? "only" : "/write"); #endif } return; @@ -1646,12 +1616,12 @@ rxvt_menubar_dispatch(pR_ char *str) } #if (MENUBAR_MAX > 1) - if (R->CurrentBar == NULL) + if (CurrentBar == NULL) return; - if (R->menu_readonly) { + if (menu_readonly) { #ifdef DEBUG_MENUBAR_STACKING fprintf(stderr, "menus are read%s\n", - R->menu_readonly ? "only" : "/write"); + menu_readonly ? "only" : "/write"); #endif return; } @@ -1706,63 +1676,63 @@ rxvt_menubar_dispatch(pR_ char *str) if (path[0] != '\0') { int len; - path = rxvt_menu_find_base(aR_ &(R->BuildMenu), path); + path = menu_find_base (&(BuildMenu), path); len = STRLEN(path); /* don't allow menus called `*' */ if (path[0] == '*') { - rxvt_menu_clear(aR_ R->BuildMenu); + menu_clear (BuildMenu); break; } else if (len >= 2 && !STRCMP((path + len - 2), "/*")) { path[len - 2] = '\0'; } if (path[0] != '\0') - R->BuildMenu = rxvt_menu_add(aR_ R->BuildMenu, path); + BuildMenu = menu_add (BuildMenu, path); } if (name != NULL && name[0] != '\0') - rxvt_menuitem_add(R->BuildMenu, + rxvt_menuitem_add(BuildMenu, (STRCMP(name, SEPARATOR_NAME) ? name : ""), name2, str); break; case '-': /* delete menu entry */ if (!STRCMP(path, "/*") && (name == NULL || name[0] == '\0')) { - rxvt_menubar_clear(aR); - R->BuildMenu = NULL; - rxvt_menubar_expose(aR); + menubar_clear (); + BuildMenu = NULL; + menubar_expose (); break; } else if (path[0] != '\0') { int len; - menu_t *menu = R->BuildMenu; + menu_t *menu = BuildMenu; - path = rxvt_menu_find_base(aR_ &menu, path); + path = menu_find_base (&menu, path); len = STRLEN(path); /* submenu called `*' clears all menu items */ if (path[0] == '*') { - rxvt_menu_clear(aR_ menu); + menu_clear (menu); break; /* done */ } else if (len >= 2 && !STRCMP(&path[len - 2], "/*")) { /* done */ break; } else if (path[0] != '\0') { - R->BuildMenu = NULL; + BuildMenu = NULL; break; } else - R->BuildMenu = menu; + BuildMenu = menu; } - if (R->BuildMenu != NULL) { + if (BuildMenu != NULL) { if (name == NULL || name[0] == '\0') - R->BuildMenu = rxvt_menu_delete(aR_ R->BuildMenu); + BuildMenu = menu_delete (BuildMenu); else { const char *n1; menuitem_t *item; - menu_t *BuildMenu = R->BuildMenu; + menu_t *BuildMenu = BuildMenu; n1 = STRCMP(name, SEPARATOR_NAME) ? name : ""; item = rxvt_menuitem_find(BuildMenu, n1); if (item != NULL && item->entry.type != MenuSubMenu) { - rxvt_menuitem_free(aR_ BuildMenu, item); + menuitem_free (BuildMenu, item); /* fix up the width */ BuildMenu->width = 0; @@ -1774,7 +1744,7 @@ rxvt_menubar_dispatch(pR_ char *str) } } } - rxvt_menubar_expose(aR); + menubar_expose (); } break; } @@ -1782,9 +1752,8 @@ rxvt_menubar_dispatch(pR_ char *str) } } -/* INTPROTO */ void -rxvt_draw_Arrows(pR_ int name, int state) +rxvt_term::draw_Arrows (int name, int state) { GC top, bot; @@ -1795,65 +1764,64 @@ rxvt_draw_Arrows(pR_ int name, int state) #endif switch (state) { case +1: - top = R->topShadowGC; - bot = R->botShadowGC; + top = topShadowGC; + bot = botShadowGC; break; /* SHADOW_OUT */ case -1: - top = R->botShadowGC; - bot = R->topShadowGC; + top = botShadowGC; + bot = topShadowGC; break; /* SHADOW_IN */ default: - top = bot = R->scrollbarGC; + top = bot = scrollbarGC; break; /* neutral */ } - if (!R->Arrows_x) + if (!Arrows_x) return; for (i = 0; i < NARROWS; i++) { const int w = Width2Pixel(1); const int y = (menuBar_TotalHeight() - w) / 2; - int x = R->Arrows_x + (5 * Width2Pixel(i)) / 4; + int x = Arrows_x + (5 * Width2Pixel(i)) / 4; if (!name || name == Arrows[i].name) - rxvt_Draw_Triangle(R->Xdisplay, R->menuBar.win, top, bot, x, y, w, + rxvt_Draw_Triangle(Xdisplay, menuBar.win, top, bot, x, y, w, Arrows[i].name); } - XFlush(R->Xdisplay); + XFlush(Xdisplay); } -/* EXTPROTO */ void -rxvt_menubar_expose(pR) +rxvt_term::menubar_expose () { menu_t *menu; int x; - if (!menubar_visible(r) || R->menuBar.win == 0) + if (!menubar_visible(r) || menuBar.win == 0) return; - if (R->menubarGC == None) { + if (menubarGC == None) { /* Create the graphics context */ XGCValues gcvalue; - gcvalue.font = R->TermWin.font->fid; + gcvalue.font = TermWin.font->fid; - gcvalue.foreground = (XDEPTH <= 2 ? R->PixColors[Color_fg] - : R->PixColors[Color_Black]); - R->menubarGC = XCreateGC(R->Xdisplay, R->menuBar.win, + gcvalue.foreground = (XDEPTH <= 2 ? PixColors[Color_fg] + : PixColors[Color_Black]); + menubarGC = XCreateGC(Xdisplay, menuBar.win, GCForeground | GCFont, &gcvalue); } /* make sure the font is correct */ - XSetFont(R->Xdisplay, R->menubarGC, R->TermWin.font->fid); - XSetFont(R->Xdisplay, R->botShadowGC, R->TermWin.font->fid); - XClearWindow(R->Xdisplay, R->menuBar.win); + XSetFont(Xdisplay, menubarGC, TermWin.font->fid); + XSetFont(Xdisplay, botShadowGC, TermWin.font->fid); + XClearWindow(Xdisplay, menuBar.win); - rxvt_menu_hide_all(aR); + menu_hide_all (); x = 0; - if (R->CurrentBar != NULL) { - for (menu = R->CurrentBar->head; menu != NULL; menu = menu->next) { + if (CurrentBar != NULL) { + for (menu = CurrentBar->head; menu != NULL; menu = menu->next) { int len = menu->len; x = (menu->x + menu->len + HSPACE); @@ -1862,46 +1830,46 @@ rxvt_menubar_expose(pR) rxvt_print_menu_descendants(menu); #endif - if (x >= R->TermWin.ncol) - len = (R->TermWin.ncol - (menu->x + HSPACE)); + if (x >= TermWin.ncol) + len = (TermWin.ncol - (menu->x + HSPACE)); - rxvt_drawbox_menubar(aR_ menu->x, len, +1); + drawbox_menubar (menu->x, len, +1); #ifdef USE_XIM - if (R->TermWin.fontset) - XmbDrawString(R->Xdisplay, - R->menuBar.win, R->TermWin.fontset, - R->menubarGC, + if (TermWin.fontset) + XmbDrawString(Xdisplay, + menuBar.win, TermWin.fontset, + menubarGC, (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2), menuBar_height() - SHADOW, menu->name, len); else #endif - XDrawString(R->Xdisplay, R->menuBar.win, R->menubarGC, + XDrawString(Xdisplay, menuBar.win, menubarGC, (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2), menuBar_height() - SHADOW, menu->name, len); - if (x >= R->TermWin.ncol) + if (x >= TermWin.ncol) break; } } - rxvt_drawbox_menubar(aR_ x, R->TermWin.ncol, (R->CurrentBar ? +1 : -1)); + drawbox_menubar (x, TermWin.ncol, (CurrentBar ? +1 : -1)); /* add the menuBar title, if it exists and there's plenty of room */ - R->Arrows_x = 0; - if (x < R->TermWin.ncol) { + Arrows_x = 0; + if (x < TermWin.ncol) { const char *str; int ncol; unsigned int len; char title[256]; - ncol = (int)R->TermWin.ncol; + ncol = (int)TermWin.ncol; if (x < (ncol - (NARROWS + 1))) { ncol -= (NARROWS + 1); - R->Arrows_x = Width2Pixel(ncol); + Arrows_x = Width2Pixel(ncol); } - rxvt_draw_Arrows(aR_ 0, +1); + draw_Arrows (0, +1); - str = (R->CurrentBar - && R->CurrentBar->title) ? R->CurrentBar->title : "%n-%v"; + str = (CurrentBar + && CurrentBar->title) ? CurrentBar->title : "%n-%v"; for (len = 0; str[0] && len < sizeof(title) - 1; str++) { const char *s = NULL; @@ -1910,7 +1878,7 @@ rxvt_menubar_expose(pR) str++; switch (str[0]) { case 'n': - s = R->rs[Rs_name]; + s = rs[Rs_name]; break; /* resource name */ case 'v': s = VERSION; @@ -1934,51 +1902,49 @@ rxvt_menubar_expose(pR) ncol -= (x + len + HSPACE); if (len > 0 && ncol >= 0) { #ifdef USE_XIM - if (R->TermWin.fontset) - XmbDrawString(R->Xdisplay, - R->menuBar.win, R->TermWin.fontset, - R->menubarGC, + if (TermWin.fontset) + XmbDrawString(Xdisplay, + menuBar.win, TermWin.fontset, + menubarGC, Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2, menuBar_height() - SHADOW, title, len); else #endif - XDrawString(R->Xdisplay, R->menuBar.win, R->menubarGC, + XDrawString(Xdisplay, menuBar.win, menubarGC, Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2, menuBar_height() - SHADOW, title, len); } } } -/* INTPROTO */ int -rxvt_menubar_mapping(pR_ int map) +rxvt_term::menubar_mapping (int map) { int change = 0; if (map && !menubar_visible(r)) { - R->menuBar.state = 1; - if (R->menuBar.win == 0) + menuBar.state = 1; + if (menuBar.win == 0) return 0; - XMapWindow(R->Xdisplay, R->menuBar.win); + XMapWindow(Xdisplay, menuBar.win); change = 1; } else if (!map && menubar_visible(r)) { - rxvt_menubar_expose(aR); - R->menuBar.state = 0; - XUnmapWindow(R->Xdisplay, R->menuBar.win); + menubar_expose (); + menuBar.state = 0; + XUnmapWindow(Xdisplay, menuBar.win); change = 1; } else - rxvt_menubar_expose(aR); + menubar_expose (); return change; } -/* INTPROTO */ int -rxvt_menu_select(pR_ XButtonEvent *ev) +rxvt_term::menu_select (XButtonEvent *ev) { menuitem_t *thisitem, *item = NULL; int this_y, y; - menu_t *ActiveMenu = R->ActiveMenu; + menu_t *ActiveMenu = ActiveMenu; Window unused_root, unused_child; int unused_root_x, unused_root_y; @@ -1987,13 +1953,13 @@ rxvt_menu_select(pR_ XButtonEvent *ev) if (ActiveMenu == NULL) return 0; - XQueryPointer(R->Xdisplay, ActiveMenu->win, + XQueryPointer(Xdisplay, ActiveMenu->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->x), &(ev->y), &unused_mask); if (ActiveMenu->parent != NULL && (ev->x < 0 || ev->y < 0)) { - rxvt_menu_hide(aR); + menu_hide (); return 1; } /* determine the menu item corresponding to the Y index */ @@ -2010,7 +1976,7 @@ rxvt_menu_select(pR_ XButtonEvent *ev) } } if (item == NULL && ev->type == ButtonRelease) { - rxvt_menu_hide_all(aR); + menu_hide_all (); return 0; } thisitem = item; @@ -2027,9 +1993,9 @@ rxvt_menu_select(pR_ XButtonEvent *ev) h = HEIGHT_SEPARATOR; else if (item == ActiveMenu->item) { /* erase old menuitem */ - rxvt_drawbox_menuitem(aR_ y, 0); /* No Shadow */ + drawbox_menuitem (y, 0); /* No Shadow */ if (item->entry.type == MenuSubMenu) - rxvt_drawtriangle(aR_ ActiveMenu->w, y, +1); + drawtriangle (ActiveMenu->w, y, +1); break; } else h = HEIGHT_TEXT + 2 * SHADOW; @@ -2041,12 +2007,12 @@ rxvt_menu_select(pR_ XButtonEvent *ev) switch (item->entry.type) { case MenuLabel: case MenuSubMenu: - rxvt_menu_hide_all(aR); + menu_hide_all (); break; case MenuAction: case MenuTerminalAction: - rxvt_drawbox_menuitem(aR_ this_y, -1); + drawbox_menuitem (_y, -1); { #ifdef HAVE_NANOSLEEP struct timespec rqt; @@ -2064,9 +2030,9 @@ rxvt_menu_select(pR_ XButtonEvent *ev) #endif } /* remove menu before sending keys to the application */ - rxvt_menu_hide_all(aR); + menu_hide_all (); #ifndef DEBUG_MENU - rxvt_action_dispatch(aR_ &(item->entry.action)); + action_dispatch (&(item->entry.action)); #else /* DEBUG_MENU */ fprintf(stderr, "%s: %s\n", item->name, item->entry.action.str); @@ -2086,22 +2052,22 @@ rxvt_menu_select(pR_ XButtonEvent *ev) DoMenu: ActiveMenu->item = thisitem; y = this_y; - if (thisitem != NULL) { + if (item != NULL) { item = ActiveMenu->item; if (item->entry.type != MenuLabel) - rxvt_drawbox_menuitem(aR_ y, +1); + drawbox_menuitem (y, +1); if (item->entry.type == MenuSubMenu) { int x; - rxvt_drawtriangle(aR_ ActiveMenu->w, y, -1); + drawtriangle (ActiveMenu->w, y, -1); x = ev->x + (ActiveMenu->parent ? ActiveMenu->x : Width2Pixel(ActiveMenu->x)); if (x >= item->entry.submenu.menu->x) { - R->ActiveMenu = item->entry.submenu.menu; - rxvt_menu_show(aR); + ActiveMenu = item->entry.submenu.menu; + menu_show (); return 1; } } @@ -2109,15 +2075,14 @@ rxvt_menu_select(pR_ XButtonEvent *ev) return 0; } -/* INTPROTO */ void -rxvt_menubar_select(pR_ XButtonEvent *ev) +rxvt_term::menubar_select (XButtonEvent *ev) { menu_t *menu = NULL; /* determine the pulldown menu corresponding to the X index */ - if (ev->y >= 0 && ev->y <= menuBar_height() && R->CurrentBar != NULL) { - for (menu = R->CurrentBar->head; menu != NULL; menu = menu->next) { + if (ev->y >= 0 && ev->y <= menuBar_height() && CurrentBar != NULL) { + for (menu = CurrentBar->head; menu != NULL; menu = menu->next) { int x = Width2Pixel(menu->x); int w = Width2Pixel(menu->len + HSPACE); @@ -2127,18 +2092,18 @@ rxvt_menubar_select(pR_ XButtonEvent *ev) } switch (ev->type) { case ButtonRelease: - rxvt_menu_hide_all(aR); + menu_hide_all (); break; case ButtonPress: - if (menu == NULL && R->Arrows_x && ev->x >= R->Arrows_x) { + if (menu == NULL && Arrows_x && ev->x >= Arrows_x) { int i; for (i = 0; i < NARROWS; i++) { - if (ev->x >= (R->Arrows_x + (Width2Pixel(4 * i + i)) / 4) - && ev->x < (R->Arrows_x + if (ev->x >= (Arrows_x + (Width2Pixel(4 * i + i)) / 4) + && ev->x < (Arrows_x + (Width2Pixel(4 * i + i + 4)) / 4)) { - rxvt_draw_Arrows(aR_ Arrows[i].name, -1); + draw_Arrows (Arrows[i].name, -1); { #ifdef HAVE_NANOSLEEP struct timespec rqt; @@ -2155,28 +2120,28 @@ rxvt_menubar_select(pR_ XButtonEvent *ev) select(0, NULL, NULL, NULL, &tv); #endif } - rxvt_draw_Arrows(aR_ Arrows[i].name, +1); + draw_Arrows (Arrows[i].name, +1); #ifdef DEBUG_MENUARROWS fprintf(stderr, "'%c': ", Arrows[i].name); - if (R->CurrentBar == NULL - || (R->CurrentBar->arrows[i].type != MenuAction - && R->CurrentBar->arrows[i].type != + if (CurrentBar == NULL + || (CurrentBar->arrows[i].type != MenuAction + && CurrentBar->arrows[i].type != MenuTerminalAction)) { if (Arrows[i].str != NULL && Arrows[i].str[0]) fprintf(stderr, "(default) \\033%s\n", &(Arrows[i].str[2])); } else { fprintf(stderr, "%s\n", - R->CurrentBar->arrows[i].str); + CurrentBar->arrows[i].str); } #else /* DEBUG_MENUARROWS */ - if (R->CurrentBar == NULL + if (CurrentBar == NULL || rxvt_action_dispatch(r, - &(R->CurrentBar->arrows[i])) + &(CurrentBar->arrows[i])) ) { if (Arrows[i].str != NULL && Arrows[i].str[0] != 0) - rxvt_tt_write(aR_ (Arrows[i].str + 1), + tt_write ((Arrows[i].str + 1), Arrows[i].str[0]); } #endif /* DEBUG_MENUARROWS */ @@ -2190,10 +2155,10 @@ rxvt_menubar_select(pR_ XButtonEvent *ev) /* * press menubar or move to a new entry */ - if (menu != NULL && menu != R->ActiveMenu) { - rxvt_menu_hide_all(aR); /* pop down old menu */ - R->ActiveMenu = menu; - rxvt_menu_show(aR); /* pop up new menu */ + if (menu != NULL && menu != ActiveMenu) { + menu_hide_all (); /* pop down old menu */ + ActiveMenu = menu; + menu_show (); /* pop up new menu */ } break; } @@ -2203,27 +2168,26 @@ rxvt_menubar_select(pR_ XButtonEvent *ev) * general dispatch routine, * it would be nice to have `sticky' menus */ -/* EXTPROTO */ void -rxvt_menubar_control(pR_ XButtonEvent *ev) +rxvt_term::menubar_control (XButtonEvent *ev) { switch (ev->type) { case ButtonPress: if (ev->button == Button1) - rxvt_menubar_select(aR_ ev); + menubar_select (ev); break; case ButtonRelease: if (ev->button == Button1) - rxvt_menu_select(aR_ ev); + menu_select (ev); break; case MotionNotify: - while (XCheckTypedWindowEvent(R->Xdisplay, R->TermWin.parent[0], + while (XCheckTypedWindowEvent(Xdisplay, TermWin.parent[0], MotionNotify, (XEvent *) ev)) ; - if (R->ActiveMenu) - while (rxvt_menu_select(aR_ ev)) ; + if (ActiveMenu) + while (menu_select (ev)) ; else ev->y = -1; if (ev->y < 0) { @@ -2231,22 +2195,21 @@ rxvt_menubar_control(pR_ XButtonEvent *ev) int unused_root_x, unused_root_y; unsigned int unused_mask; - XQueryPointer(R->Xdisplay, R->menuBar.win, + XQueryPointer(Xdisplay, menuBar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->x), &(ev->y), &unused_mask); - rxvt_menubar_select(aR_ ev); + menubar_select (ev); } break; } } -/* EXTPROTO */ void -rxvt_map_menuBar(pR_ int map) +rxvt_term::map_menuBar (int map) { - if (rxvt_menubar_mapping(aR_ map)) - rxvt_resize_all_windows(aR_ 0, 0, 0); + if (menubar_mapping (map)) + resize_all_windows (0, 0, 0); } #endif /*----------------------- end-of-file (C source) -----------------------*/ diff --git a/src/misc.C b/src/misc.C index 293b00f4..b7953496 100644 --- a/src/misc.C +++ b/src/misc.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: misc.c *----------------------------------------------------------------------* - * $Id: misc.C,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: misc.C,v 1.3 2004-01-31 00:20:21 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1996 mj olesen Queen's Univ at Kingston @@ -27,6 +27,13 @@ #include "rxvt.h" /* NECESSARY */ #include "misc.intpro" /* PROTOS for internal routines */ +/* EXTPROTO */ +char * +rxvt_strdup (const char *str) +{ + return str ? strdup (str) : 0; +} + /* EXTPROTO */ char * rxvt_r_basename(const char *str) diff --git a/src/netdisp.C b/src/netdisp.C index 6323541b..05eef949 100644 --- a/src/netdisp.C +++ b/src/netdisp.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: netdisp.c *----------------------------------------------------------------------* - * $Id: netdisp.C,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: netdisp.C,v 1.3 2004-01-31 00:20:21 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1996 Chuck Blake @@ -40,7 +40,6 @@ /*----------------------------------------------------------------------*/ /* return NULL a pointer to buffer which may be freed */ -/* EXTPROTO */ char * rxvt_network_display(const char *display) { diff --git a/src/rxvt.C b/src/rxvt.C index 1c0b815f..c74cb1d0 100644 --- a/src/rxvt.C +++ b/src/rxvt.C @@ -3,7 +3,6 @@ /*----------------------------------------------------------------------*/ /* main() */ -/* INTPROTO */ int main(int argc, const char *const *argv) { diff --git a/src/rxvt.h b/src/rxvt.h index 15d6d4b7..748b922b 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -594,9 +594,9 @@ enum { #define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11) #define PrivMode(test,bit) \ if (test) \ - R->PrivateModes |= (bit); \ + PrivateModes |= (bit); \ else \ - R->PrivateModes &= ~(bit) + PrivateModes &= ~(bit) #ifdef ALLOW_132_MODE # define PrivMode_Default \ @@ -606,9 +606,9 @@ enum { (PrivMode_Autowrap|PrivMode_aplKP|PrivMode_ShiftKeys|PrivMode_VisibleCursor) #endif -#define XDEPTH R->Xdepth -#define XCMAP R->Xcmap -#define XVISUAL R->Xvisual +#define XDEPTH Xdepth +#define XCMAP Xcmap +#define XVISUAL Xvisual #define IMBUFSIZ 128 /* input modifier buffer sizes */ #ifndef BUFSIZ @@ -650,7 +650,7 @@ enum { #define TermWin_TotalWidth() ((int32_t)TermWin.width + 2 * (int32_t)TermWin.int_bwidth) #define TermWin_TotalHeight() ((int32_t)TermWin.height + 2 * (int32_t)TermWin.int_bwidth) -#define Xroot DefaultRootWindow(R->Xdisplay) +#define Xroot DefaultRootWindow(Xdisplay) /* how to build & extract colors and attributes */ #define GET_BASEFG(x) (((x) & RS_fgMask)) @@ -685,44 +685,44 @@ enum { #define SET_BGCOLOR(x,bg) (((x) & ~RS_bgMask) | ((bg)<pixcolor_set[(x) / NPIXCLR_BITS] |= (1 << ((x) % NPIXCLR_BITS))) -#define ISSET_PIXCOLOR(h, x) ((h)->pixcolor_set[(x) / NPIXCLR_BITS] & (1 << ((x) % NPIXCLR_BITS))) +#define SET_PIXCOLOR(x) (pixcolor_set[(x) / NPIXCLR_BITS] |= (1 << ((x) % NPIXCLR_BITS))) +#define ISSET_PIXCOLOR(x) (pixcolor_set[(x) / NPIXCLR_BITS] & (1 << ((x) % NPIXCLR_BITS))) #ifdef HAVE_SCROLLBARS # define scrollbar_TotalWidth() (scrollBar.width + sb_shadow * 2) #else # define scrollbar_TotalWidth() (0) #endif -#define scrollbar_isMotion() (R->scrollBar.state == 'm') -#define scrollbar_isUp() (R->scrollBar.state == 'U') -#define scrollbar_isDn() (R->scrollBar.state == 'D') -#define scrollbar_isUpDn() isupper (R->scrollBar.state) -#define isScrollbarWindow(w) (R->scrollBar.state && (w) == R->scrollBar.win) +#define scrollbar_isMotion() (scrollBar.state == 'm') +#define scrollbar_isUp() (scrollBar.state == 'U') +#define scrollbar_isDn() (scrollBar.state == 'D') +#define scrollbar_isUpDn() isupper (scrollBar.state) +#define isScrollbarWindow(w) (scrollBar.state && (w) == scrollBar.win) -#define scrollbarnext_dnval() (R->scrollBar.end + (R->scrollBar.width + 1)) -#define scrollbarnext_upButton(y) ((y) > R->scrollBar.end \ +#define scrollbarnext_dnval() (scrollBar.end + (scrollBar.width + 1)) +#define scrollbarnext_upButton(y) ((y) > scrollBar.end \ && (y) <= scrollbarnext_dnval()) #define scrollbarnext_dnButton(y) ((y) > scrollbarnext_dnval()) #define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT -#define scrollbarrxvt_upButton(y) ((y) < R->scrollBar.beg) -#define scrollbarrxvt_dnButton(y) ((y) > R->scrollBar.end) +#define scrollbarrxvt_upButton(y) ((y) < scrollBar.beg) +#define scrollbarrxvt_dnButton(y) ((y) > scrollBar.end) #define SCROLLRXVT_MINHEIGHT 10 #define SCROLLXTERM_MINHEIGHT 10 -#define scrollbar_minheight() (R->scrollBar.style == R_SB_NEXT \ +#define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \ ? SCROLLNEXT_MINHEIGHT \ : SCROLLRXVT_MINHEIGHT) -#define scrollbar_above_slider(y) ((y) < R->scrollBar.top) -#define scrollbar_below_slider(y) ((y) > R->scrollBar.bot) -#define scrollbar_position(y) ((y) - R->scrollBar.beg) -#define scrollbar_size() (R->scrollBar.end - R->scrollBar.beg \ +#define scrollbar_above_slider(y) ((y) < scrollBar.top) +#define scrollbar_below_slider(y) ((y) > scrollBar.bot) +#define scrollbar_position(y) ((y) - scrollBar.beg) +#define scrollbar_size() (scrollBar.end - scrollBar.beg \ - scrollbar_minheight()) #if (MENUBAR_MAX > 1) /* rendition style flags */ # define menuBar_height() (TermWin.fheight + SHADOW) # define menuBar_TotalHeight() (menuBar_height() + SHADOW + menuBar_margin) -# define isMenuBarWindow(w) ((w) == R->menuBar.win) +# define isMenuBarWindow(w) ((w) == menuBar.win) #else # define menuBar_height() (0) # define menuBar_TotalHeight() (0) @@ -808,6 +808,16 @@ enum { #define BLINK_INTERVAL 0.5 #define TEXT_BLINK_INTERVAL 0.5 +#ifndef __attribute__ +# ifdef __GNUC__ +# if (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (__GNUC__ < 2) +# define __attribute__(x) +# endif +# endif +# define __attribute__(x) +#endif + +// primivite wrapper around mbstate_t to ensure initialisation struct mbstate { mbstate_t mbs; @@ -1144,20 +1154,181 @@ struct rxvt_term : rxvt_vars { void scr_erase_screen (int mode); void scr_touch (bool refresh); void scr_expose (int x, int y, int width, int height, bool refresh); + + /* autoconvert */ + + // command.C + void lookup_key (XKeyEvent *ev); + unsigned int cmd_write (const unsigned char *str, unsigned int count); + uint32_t cmd_getc (); + void mouse_report (const XButtonEvent *ev); + void process_x_event (XEvent *ev); + void button_press (XButtonEvent *ev); + void button_release (XButtonEvent *ev); + int check_our_parents (); +#ifdef PRINTPIPE + FILE * popen_printer (); + int pclose_printer (FILE *stream); +#endif + void process_print_pipe (); + void process_nonprinting (unsigned char ch); + void process_escape_vt52 (unsigned char ch); + void process_escape_seq (); + void process_csi_seq (); + void process_window_ops (const int *args, unsigned int nargs); + unsigned char * get_to_st (unsigned char *ends_how); + void process_dcs_seq (); + void process_osc_seq (); + void xterm_seq (int op, const char *str, unsigned char resp __attribute__((unused))); + int privcases (int mode, unsigned long bit); + void process_terminal_mode (int mode, int priv, unsigned int nargs, const int *arg); + void process_sgr_mode (unsigned int nargs, const int *arg); + void process_graphics (); + // init.C + void Get_Colours (); + void get_ourmods (); + // logging.C + void makeutent (const char *pty, const char *hostname); + void cleanutent (); + // main.C; + void privileges (int mode); + void privileged_utmp (char action); + void privileged_ttydev (char action); + void change_font (int init, const char *fontname); + void font_up_down (int n, int direction); + void set_title (const char *str); + void set_iconName (const char *str); + void set_window_color (int idx, const char *color); + void set_colorfgbg (); + int rXParseAllocColor (rxvt_color * screen_in_out, const char *colour); + void set_widthheight (unsigned int width, unsigned int height); + bool IMisRunning (); + void IMSendSpot (); + bool IM_get_IC (); + void IMSetStatusPosition (); + +#ifdef MENUBAR + // menubar.C + void menuitem_free (menu_t *menu, menuitem_t *item); + int action_dispatch (action_t *action); + void menuarrow_free (char name); + void menuarrow_add (char *string); + char * menu_find_base (menu_t **menu, char *path); + menu_t * menu_delete (menu_t *menu); + menu_t * menu_add (menu_t *parent, char *path); + void drawbox_menubar (int x, int len, int state); + void drawtriangle (int x, int y, int state); + void drawbox_menuitem (int y, int state); + void menu_show (); + void menu_display (void (*update)(rxvt_t *)); + void menu_hide_all (); + void menu_hide (); + void menu_clear (menu_t *menu); + void menubar_clear (); + bar_t * menubar_find (const char *name); + int menubar_push (const char *name); + void menubar_remove (const char *name); + void menubar_dump (FILE *fp); + void menubar_read (const char *filename); + void menubar_dispatch (char *str); + void draw_Arrows (int name, int state); + void menubar_expose (); + int menubar_mapping (int map); + int menu_select (XButtonEvent *ev); + void menubar_select (XButtonEvent *ev); + void menubar_control (XButtonEvent *ev); + void map_menuBar (int map); +#endif + + // screen.C + void scr_poweron (); + void scr_cursor (int mode); + int scr_change_screen (int scrn); + void scr_color (unsigned int color, int fgbg); + void scr_rendition (int set, int style); + void scr_add_lines (const uint32_t *str, int nlines, int len); + void scr_backspace (); + void scr_tab (int count); + void scr_backindex (); + void scr_forwardindex (); + void scr_gotorc (int row, int col, int relative); + void scr_index (enum page_dirn direction); + void scr_erase_line (int mode); + void scr_E (); + void scr_insdel_lines (int count, int insdel); + void scr_insdel_chars (int count, int insdel); + void scr_scroll_region (int top, int bot); + void scr_cursor_visible (int mode); + void scr_autowrap (int mode); + void scr_relative_origin (int mode); + void scr_insert_mode (int mode); + void scr_set_tab (int mode); + void scr_rvideo_mode (int mode); + void scr_report_position (); + void set_font_style (); + void scr_charset_choose (int set); + void scr_charset_set (int set, unsigned int ch); + int scr_move_to (int y, int len); + int scr_page (enum page_dirn direction, int nlines); + int scr_changeview (uint16_t oldviewstart); + void scr_bell (); + void scr_printscreen (int fullhist); + void scr_reverse_selection (); + void scr_dump (int fd); + void selection_check (int check_more); + int selection_paste (Window win, Atom prop, bool delete_prop); + void selection_property (Window win, Atom prop); + void selection_request (Time tm, int x, int y); + int selection_request_other (Atom target, int selnum); + void selection_clear (); + void selection_make (Time tm); + void selection_start_colrow (int col, int row); + void selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret); + void selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange); + void selection_remove_trailing_spaces (); + void selection_send (const XSelectionRequestEvent *rq); + +#if defined(NEXT_SCROLLBAR) + // scrollbar-next.C + Pixmap renderPixmap (const char *const *data, int width, int height); + void init_scrollbar_stuff (); + void drawBevel (Drawable d, int x1, int y1, int w, int h); + int scrollbar_show_next (int update, int last_top, int last_bot, int scrollbar_len); +# define scrollbar_update scrollbar_show_next // HACK +#endif + +#if defined(RXVT_SCROLLBAR) + // scrollbar-rxvt.C + void Draw_button (int x, int y, int state, int dirn); + int scrollbar_show_rxvt (int update, int last_top, int last_bot, int scrollbar_len); +# define scrollbar_update scrollbar_show_rxvt // HACK +#endif + +#if defined(XTERM_SCROLLBAR) + // scrollbar-xterm.C + int scrollbar_show_xterm (int update, int last_top, int last_bot, int scrollbar_len); +# define scrollbar_update scrollbar_show_xterm // HACK +#endif + + // scrollbar.C + int scrollbar_mapping (int map); + int scrollbar_show (int update); + void setup_scrollbar (const char *scrollalign, const char *scrollstyle, const char *thickness); + + // xdefaults.C + void get_options (int argc, const char *const *argv); + int parse_keysym (const char *str, const char *arg); + void get_xdefaults (FILE *stream, const char *name); + void extract_resources (Display *display, const char *name); + // xpm.C + int scale_pixmap (const char *geom); + void resize_pixmap (); + Pixmap set_bgPixmap (const char *file); }; #define SET_LOCALE(locale) rxvt_set_locale (locale) extern void rxvt_set_locale (const char *locale); -#ifndef __attribute__ -# ifdef __GNUC__ -# if (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (__GNUC__ < 2) -# define __attribute__(x) -# endif -# endif -# define __attribute__(x) -#endif - /* ***************************************************************************** * PROTOTYPES diff --git a/src/rxvtcolor.C b/src/rxvtcolor.C index df3d51b8..217535c0 100644 --- a/src/rxvtcolor.C +++ b/src/rxvtcolor.C @@ -4,13 +4,13 @@ // TODO: free colors again bool -rxvt_color::set (pR_ Pixel p) +rxvt_color::set (rxvt_term *t, Pixel p) { #if XFT XColor xc; xc.pixel = p; - if (!XQueryColor (R->Xdisplay, R->Xcmap, &xc)) + if (!XQueryColor (t->Xdisplay, t->Xcmap, &xc)) return false; XRenderColor d; @@ -21,9 +21,9 @@ rxvt_color::set (pR_ Pixel p) d.alpha = 0xffff; return - XftColorAllocValue (R->Xdisplay, - R->Xvisual, - R->Xcmap, + XftColorAllocValue (t->Xdisplay, + t->Xvisual, + t->Xcmap, &d, &c); #else @@ -34,18 +34,18 @@ rxvt_color::set (pR_ Pixel p) } bool -rxvt_color::set (pR_ const char *name) +rxvt_color::set (rxvt_term *t, const char *name) { XColor xc; - if (XParseColor (R->Xdisplay, R->Xcmap, name, &xc)) - return set (aR_ xc.red, xc.green, xc.blue); + if (XParseColor (t->Xdisplay, t->Xcmap, name, &xc)) + return set (t, xc.red, xc.green, xc.blue); return false; } bool -rxvt_color::set (pR_ unsigned short cr, unsigned short cg, unsigned short cb) +rxvt_color::set (rxvt_term *t, unsigned short cr, unsigned short cg, unsigned short cb) { XColor xc; @@ -54,14 +54,14 @@ rxvt_color::set (pR_ unsigned short cr, unsigned short cg, unsigned short cb) xc.blue = cb; xc.flags = DoRed | DoGreen | DoBlue; - if (XAllocColor (R->Xdisplay, R->Xcmap, &xc)) - return set (aR_ xc.pixel); + if (XAllocColor (t->Xdisplay, t->Xcmap, &xc)) + return set (t, xc.pixel); return false; } void -rxvt_color::get (pR_ unsigned short &cr, unsigned short &cg, unsigned short &cb) +rxvt_color::get (rxvt_term *t, unsigned short &cr, unsigned short &cg, unsigned short &cb) { #if XFT cr = c.color.red; @@ -71,7 +71,7 @@ rxvt_color::get (pR_ unsigned short &cr, unsigned short &cg, unsigned short &cb) XColor c; c.pixel = p; - XQueryColor (R->Xdisplay, R->Xcmap, &c); + XQueryColor (t->Xdisplay, t->Xcmap, &c); cr = c.red; cg = c.green; diff --git a/src/rxvtcolor.h b/src/rxvtcolor.h index fa93a120..55a9741b 100644 --- a/src/rxvtcolor.h +++ b/src/rxvtcolor.h @@ -25,11 +25,11 @@ struct rxvt_color { bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); } bool operator != (const rxvt_color &b) const { return Pixel(*this) != Pixel(b); } - void get (pR_ unsigned short &cr, unsigned short &cg, unsigned short &cb); + void get (rxvt_term *t, unsigned short &cr, unsigned short &cg, unsigned short &cb); - bool set (pR_ Pixel p); - bool set (pR_ const char *name); - bool set (pR_ unsigned short cr, unsigned short cg, unsigned short cb); + bool set (rxvt_term *t, Pixel p); + bool set (rxvt_term *t, const char *name); + bool set (rxvt_term *t, unsigned short cr, unsigned short cg, unsigned short cb); }; #endif diff --git a/src/rxvtlib.h.in b/src/rxvtlib.h.in index a6765184..baeffc50 100644 --- a/src/rxvtlib.h.in +++ b/src/rxvtlib.h.in @@ -1,7 +1,3 @@ -/* - * $Id: rxvtlib.h.in,v 1.8 2004-01-19 17:26:43 pcg Exp $ - */ - #ifndef _RXVTLIB_H_ /* include once only */ #define _RXVTLIB_H_ @@ -76,38 +72,11 @@ typedef struct rxvt_term *rxvt_t; extern rxvt_t rxvt_current_term; -#define EXPLICIT_CONTEXT 1 - -#if EXPLICIT_CONTEXT - -# define pR rxvt_t rxvt_term -# define aR rxvt_term -# define pR_ pR, -# define aR_ aR, - -# define R rxvt_term - # define SET_R(r) rxvt_current_term = (r) # define GET_R rxvt_current_term -#else - -# define pR -# define pR_ -# define aR -# define aR_ - -# define R rxvt_current_term - -# define SET_R(r) rxvt_current_term = (r) -# define GET_R R - -#endif - -#define dR rxvt_t rxvt_term = GET_R - -#define scrollbar_visible(rxvtvars) ((rxvtvars)->scrollBar.state) -#define menubar_visible(rxvtvars) ((rxvtvars)->menuBar.state) +#define scrollbar_visible() scrollBar.state +#define menubar_visible() menuBar.state typedef struct { int32_t row; @@ -280,7 +249,7 @@ typedef struct { short style; /* style: rxvt, xterm, next */ short width; /* scrollbar width */ Window win; - int (*update)(pR_ int, int, int, int); + //int (*update)(int, int, int, int); void setIdle() { state = 1 ; } void setMotion() { state = 'm'; } diff --git a/src/rxvtstl.h b/src/rxvtstl.h index 5b52c3b1..933203b5 100644 --- a/src/rxvtstl.h +++ b/src/rxvtstl.h @@ -1,8 +1,8 @@ #ifndef RXVT_STL_H #define RXVT_STL_H -template static inline T min (T a, long b) { return a < b ? a : b; } -template static inline T max (T a, long b) { return a > b ? a : b; } +template static inline T min (T a, U b) { return a < b ? a : b; } +template static inline T max (T a, U b) { return a > b ? a : b; } #include "simplevec.h" diff --git a/src/salloc.C b/src/salloc.C index c718a8a5..eb132602 100644 --- a/src/salloc.C +++ b/src/salloc.C @@ -2,7 +2,7 @@ #define SALLOC_BLOCK 65536 // size of basic block to allocate -rxvt_salloc::rxvt_salloc (int size) +rxvt_salloc::rxvt_salloc (unsigned int size) { this->size = size < sizeof (chain) ? sizeof (chain) : size; firstline = 0; diff --git a/src/salloc.h b/src/salloc.h index a6639ac2..d66a3c59 100644 --- a/src/salloc.h +++ b/src/salloc.h @@ -12,10 +12,10 @@ struct rxvt_salloc { chain *firstblock; chain *firstline; - int firstfree; - int size; + unsigned int firstfree; + unsigned int size; - rxvt_salloc (int size); + rxvt_salloc (unsigned int size); ~rxvt_salloc (); void *alloc (); diff --git a/src/screen.C b/src/screen.C index 1a59dd4b..62daade0 100644 --- a/src/screen.C +++ b/src/screen.C @@ -47,16 +47,16 @@ inline void fill_text (text_t *start, text_t value, int len) /* ------------------------------------------------------------------------- * * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * * ------------------------------------------------------------------------- */ -#define ZERO_SCROLLBACK(R) \ - if (((R)->Options & Opt_scrollTtyOutput) == Opt_scrollTtyOutput) \ - (R)->TermWin.view_start = 0 -#define CLEAR_SELECTION(R) \ - (R)->selection.beg.row = (R)->selection.beg.col \ - = (R)->selection.end.row = (R)->selection.end.col = 0 -#define CLEAR_ALL_SELECTION(R) \ - (R)->selection.beg.row = (R)->selection.beg.col \ - = (R)->selection.mark.row = (R)->selection.mark.col \ - = (R)->selection.end.row = (R)->selection.end.col = 0 +#define ZERO_SCROLLBACK() \ + if ((Options & Opt_scrollTtyOutput) == Opt_scrollTtyOutput) \ + TermWin.view_start = 0 +#define CLEAR_SELECTION() \ + selection.beg.row = selection.beg.col \ + = selection.end.row = selection.end.col = 0 +#define CLEAR_ALL_SELECTION() \ + selection.beg.row = selection.beg.col \ + = selection.mark.row = selection.mark.col \ + = selection.end.row = selection.end.col = 0 #define ROW_AND_COL_IS_AFTER(A, B, C, D) \ (((A) > (C)) || (((A) == (C)) && ((B) > (D)))) @@ -221,14 +221,14 @@ rxvt_term::scr_reset () screen.cur.row = screen.cur.col = 0; screen.charset = 0; current_screen = PRIMARY; - rxvt_scr_cursor (this, SAVE); + scr_cursor (SAVE); #if NSCREENS swap.flags = Screen_DefaultFlags; swap.cur.row = swap.cur.col = 0; swap.charset = 0; current_screen = SECONDARY; - rxvt_scr_cursor (this, SAVE); + scr_cursor (SAVE); current_screen = PRIMARY; #endif @@ -237,7 +237,7 @@ rxvt_term::scr_reset () selection.op = SELECTION_CLEAR; selection.screen = PRIMARY; selection.clicks = 0; - CLEAR_ALL_SELECTION (this); + CLEAR_ALL_SELECTION (); rvideo = 0; } else @@ -476,20 +476,19 @@ rxvt_term::scr_release() /* * Hard reset */ -/* EXTPROTO */ void -rxvt_scr_poweron(pR) +rxvt_term::scr_poweron () { D_SCREEN((stderr, "rxvt_scr_poweron()")); - R->scr_release (); - R->prev_nrow = R->prev_ncol = 0; - R->scr_reset (); + scr_release (); + prev_nrow = prev_ncol = 0; + scr_reset (); - R->scr_clear (); - R->scr_refresh (SLOW_REFRESH); + scr_clear (); + scr_refresh (SLOW_REFRESH); #ifdef RXVT_GRAPHICS - rxvt_Gr_reset (aR); + Gr_reset (); #endif } @@ -501,42 +500,41 @@ rxvt_scr_poweron(pR) * XTERM_SEQ: Save cursor : ESC 7 * XTERM_SEQ: Restore cursor: ESC 8 */ -/* EXTPROTO */ void -rxvt_scr_cursor(pR_ int mode) +rxvt_term::scr_cursor (int mode) { screen_t *s; D_SCREEN((stderr, "rxvt_scr_cursor(%c)", mode)); #if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) - if (R->current_screen == SECONDARY) - s = &(R->swap); + if (current_screen == SECONDARY) + s = &(swap); else #endif - s = &(R->screen); + s = &(screen); switch (mode) { case SAVE: s->s_cur.row = s->cur.row; s->s_cur.col = s->cur.col; - s->s_rstyle = R->rstyle; + s->s_rstyle = rstyle; s->s_charset = s->charset; - s->s_charset_char = R->charsets[s->charset]; + s->s_charset_char = charsets[s->charset]; break; case RESTORE: - R->want_refresh = 1; + want_refresh = 1; s->cur.row = s->s_cur.row; s->cur.col = s->s_cur.col; s->flags &= ~Screen_WrapNext; - R->rstyle = s->s_rstyle; + rstyle = s->s_rstyle; s->charset = s->s_charset; - R->charsets[s->charset] = s->s_charset_char; - rxvt_set_font_style(aR); + charsets[s->charset] = s->s_charset_char; + set_font_style (); break; } /* boundary check in case screen size changed between SAVE and RESTORE */ - MIN_IT(s->cur.row, R->TermWin.nrow - 1); - MIN_IT(s->cur.col, R->TermWin.ncol - 1); + MIN_IT(s->cur.row, TermWin.nrow - 1); + MIN_IT(s->cur.col, TermWin.ncol - 1); #ifdef DEBUG_STRICT assert(s->cur.row >= 0); assert(s->cur.col >= 0); @@ -552,70 +550,69 @@ rxvt_scr_cursor(pR_ int mode) * XTERM_SEQ: Primary screen : ESC [ ? 4 7 h * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l */ -/* EXTPROTO */ int -rxvt_scr_change_screen(pR_ int scrn) +rxvt_term::scr_change_screen (int scrn) { int i; #if NSCREENS int offset; #endif - R->want_refresh = 1; + want_refresh = 1; D_SCREEN((stderr, "rxvt_scr_change_screen(%d)", scrn)); - R->TermWin.view_start = 0; + TermWin.view_start = 0; - if (R->current_screen == scrn) - return R->current_screen; + if (current_screen == scrn) + return current_screen; - rxvt_selection_check(aR_ 2); /* check for boundary cross */ + selection_check (2); /* check for boundary cross */ - SWAP_IT(R->current_screen, scrn, int); + SWAP_IT(current_screen, scrn, int); #if NSCREENS - R->num_scr = 0; - offset = R->TermWin.saveLines; - for (i = R->prev_nrow; i--;) { - SWAP_IT(R->screen.text[i + offset], R->swap.text[i], text_t *); - SWAP_IT(R->screen.tlen[i + offset], R->swap.tlen[i], int16_t); - SWAP_IT(R->screen.rend[i + offset], R->swap.rend[i], rend_t *); - } - SWAP_IT(R->screen.cur.row, R->swap.cur.row, int16_t); - SWAP_IT(R->screen.cur.col, R->swap.cur.col, int16_t); + num_scr = 0; + offset = TermWin.saveLines; + for (i = prev_nrow; i--;) { + SWAP_IT(screen.text[i + offset], swap.text[i], text_t *); + SWAP_IT(screen.tlen[i + offset], swap.tlen[i], int16_t); + SWAP_IT(screen.rend[i + offset], swap.rend[i], rend_t *); + } + SWAP_IT(screen.cur.row, swap.cur.row, int16_t); + SWAP_IT(screen.cur.col, swap.cur.col, int16_t); # ifdef DEBUG_STRICT - assert((R->screen.cur.row >= 0) && (R->screen.cur.row < R->prev_nrow)); - assert((R->screen.cur.col >= 0) && (R->screen.cur.col < R->prev_ncol)); + assert((screen.cur.row >= 0) && (screen.cur.row < prev_nrow)); + assert((screen.cur.col >= 0) && (screen.cur.col < prev_ncol)); # else /* drive with your eyes closed */ - MAX_IT(R->screen.cur.row, 0); - MIN_IT(R->screen.cur.row, (int32_t)R->prev_nrow - 1); - MAX_IT(R->screen.cur.col, 0); - MIN_IT(R->screen.cur.col, (int32_t)R->prev_ncol - 1); + MAX_IT(screen.cur.row, 0); + MIN_IT(screen.cur.row, (int32_t)prev_nrow - 1); + MAX_IT(screen.cur.col, 0); + MIN_IT(screen.cur.col, (int32_t)prev_ncol - 1); # endif - SWAP_IT(R->screen.charset, R->swap.charset, int16_t); - SWAP_IT(R->screen.flags, R->swap.flags, int); - R->screen.flags |= Screen_VisibleCursor; - R->swap.flags |= Screen_VisibleCursor; + SWAP_IT(screen.charset, swap.charset, int16_t); + SWAP_IT(screen.flags, swap.flags, int); + screen.flags |= Screen_VisibleCursor; + swap.flags |= Screen_VisibleCursor; # ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed(aR)) { - rxvt_Gr_scroll(aR_ 0); - rxvt_Gr_ChangeScreen(aR); + if (Gr_Displayed ()) { + Gr_scroll (0); + Gr_ChangeScreen (); } # endif #else # ifdef SCROLL_ON_NO_SECONDARY # ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed(aR)) - rxvt_Gr_ClearScreen(aR); + if (Gr_Displayed ()) + Gr_ClearScreen (); # endif - if (R->current_screen == PRIMARY + if (current_screen == PRIMARY # ifdef RXVT_GRAPHICS - && !rxvt_Gr_Displayed(aR) + && !Gr_Displayed () # endif ) - R->scr_scroll_text(0, (R->prev_nrow - 1), R->prev_nrow, 0); + scr_scroll_text(0, (prev_nrow - 1), prev_nrow, 0); # endif #endif return scrn; @@ -625,31 +622,29 @@ rxvt_scr_change_screen(pR_ int scrn) /* * Change the colour for following text */ -/* EXTPROTO */ void -rxvt_scr_color(pR_ unsigned int color, int fgbg) +rxvt_term::scr_color (unsigned int color, int fgbg) { color &= RS_fgMask; if (fgbg == Color_fg) - R->rstyle = SET_FGCOLOR(R->rstyle, color); + rstyle = SET_FGCOLOR(rstyle, color); else - R->rstyle = SET_BGCOLOR(R->rstyle, color); + rstyle = SET_BGCOLOR(rstyle, color); } /* ------------------------------------------------------------------------- */ /* * Change the rendition style for following text */ -/* EXTPROTO */ void -rxvt_scr_rendition(pR_ int set, int style) +rxvt_term::scr_rendition (int set, int style) { if (set) - R->rstyle |= style; + rstyle |= style; else if (style == ~RS_None) - R->rstyle = DEFAULT_RSTYLE; + rstyle = DEFAULT_RSTYLE; else - R->rstyle &= ~style; + rstyle &= ~style; } /* ------------------------------------------------------------------------- */ @@ -683,7 +678,7 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) if ((Options & Opt_scrollWithBuffer) && TermWin.view_start != 0 && TermWin.view_start != TermWin.saveLines) - rxvt_scr_page (this, UP, count); + scr_page (UP, count); } else if (!spec) row1 += TermWin.saveLines; @@ -701,7 +696,7 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) || (j - count < row1 && j >= row1) || (j - count > row2 && j <= row2)) { - CLEAR_ALL_SELECTION (this); + CLEAR_ALL_SELECTION (); selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ } else if (j >= row1 && j <= row2) @@ -713,7 +708,7 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) } } - rxvt_selection_check (this, 0); /* _after_ TermWin.nscrolled update */ + selection_check (0); /* _after_ TermWin.nscrolled update */ num_scr += count; j = count; @@ -777,8 +772,8 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) } #ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed (this)) - rxvt_Gr_scroll(this, count); + if (Gr_Displayed ()) + Gr_scroll (count); #endif return count; @@ -788,9 +783,8 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) /* * Add text given in of length to screen struct */ -/* EXTPROTO */ void -rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) +rxvt_term::scr_add_lines (const uint32_t *str, int nlines, int len) { unsigned char checksel, clearsel; uint32_t c; @@ -801,61 +795,61 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) if (len <= 0) /* sanity */ return; - R->want_refresh = 1; - last_col = R->TermWin.ncol; + want_refresh = 1; + last_col = TermWin.ncol; D_SCREEN((stderr, "rxvt_scr_add_lines(%d,%d)", nlines, len)); - ZERO_SCROLLBACK(R); + ZERO_SCROLLBACK(); if (nlines > 0) { - nlines += (R->screen.cur.row - R->screen.bscroll); + nlines += (screen.cur.row - screen.bscroll); if ((nlines > 0) - && (R->screen.tscroll == 0) - && (R->screen.bscroll == (R->TermWin.nrow - 1))) { + && (screen.tscroll == 0) + && (screen.bscroll == (TermWin.nrow - 1))) { /* _at least_ this many lines need to be scrolled */ - R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, nlines, 0); - R->screen.cur.row -= nlines; + scr_scroll_text(screen.tscroll, screen.bscroll, nlines, 0); + screen.cur.row -= nlines; } } #ifdef DEBUG_STRICT - assert(R->screen.cur.col < last_col); - assert((R->screen.cur.row < R->TermWin.nrow) - && (R->screen.cur.row >= -(int32_t)R->TermWin.nscrolled)); + assert(screen.cur.col < last_col); + assert((screen.cur.row < TermWin.nrow) + && (screen.cur.row >= -(int32_t)TermWin.nscrolled)); #else /* drive with your eyes closed */ - MIN_IT(R->screen.cur.col, last_col - 1); - MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1); - MAX_IT(R->screen.cur.row, -(int32_t)R->TermWin.nscrolled); + MIN_IT(screen.cur.col, last_col - 1); + MIN_IT(screen.cur.row, (int32_t)TermWin.nrow - 1); + MAX_IT(screen.cur.row, -(int32_t)TermWin.nscrolled); #endif - row = R->screen.cur.row + R->TermWin.saveLines; + row = screen.cur.row + TermWin.saveLines; - checksel = (R->selection.op - && R->current_screen == R->selection.screen) ? 1 : 0; + checksel = (selection.op + && current_screen == selection.screen) ? 1 : 0; clearsel = 0; - stp = R->screen.text[row]; - srp = R->screen.rend[row]; + stp = screen.text[row]; + srp = screen.rend[row]; for (i = 0; i < len;) { c = str[i++]; switch (c) { case '\t': - rxvt_scr_tab (aR_ 1); + scr_tab (1); continue; case '\n': - if (R->screen.tlen[row] != -1) /* XXX: think about this */ - MAX_IT(R->screen.tlen[row], R->screen.cur.col); - R->screen.flags &= ~Screen_WrapNext; - if (R->screen.cur.row == R->screen.bscroll) - R->scr_scroll_text (R->screen.tscroll, R->screen.bscroll, 1, 0); - else if (R->screen.cur.row < (R->TermWin.nrow - 1)) - row = (++R->screen.cur.row) + R->TermWin.saveLines; - stp = R->screen.text[row]; /* _must_ refresh */ - srp = R->screen.rend[row]; /* _must_ refresh */ + if (screen.tlen[row] != -1) /* XXX: think about this */ + MAX_IT(screen.tlen[row], screen.cur.col); + screen.flags &= ~Screen_WrapNext; + if (screen.cur.row == screen.bscroll) + scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); + else if (screen.cur.row < (TermWin.nrow - 1)) + row = (++screen.cur.row) + TermWin.saveLines; + stp = screen.text[row]; /* _must_ refresh */ + srp = screen.rend[row]; /* _must_ refresh */ continue; case '\r': - if (R->screen.tlen[row] != -1) /* XXX: think about this */ - MAX_IT(R->screen.tlen[row], R->screen.cur.col); - R->screen.flags &= ~Screen_WrapNext; - R->screen.cur.col = 0; + if (screen.tlen[row] != -1) /* XXX: think about this */ + MAX_IT(screen.tlen[row], screen.cur.col); + screen.flags &= ~Screen_WrapNext; + screen.cur.col = 0; continue; default: if (c == 127) @@ -864,26 +858,26 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) } if (checksel /* see if we're writing within selection */ - && !ROWCOL_IS_BEFORE(R->screen.cur, R->selection.beg) - && ROWCOL_IS_BEFORE(R->screen.cur, R->selection.end)) { + && !ROWCOL_IS_BEFORE(screen.cur, selection.beg) + && ROWCOL_IS_BEFORE(screen.cur, selection.end)) { checksel = 0; clearsel = 1; } - if (R->screen.flags & Screen_WrapNext) { - R->screen.tlen[row] = -1; - if (R->screen.cur.row == R->screen.bscroll) - R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, 1, 0); - else if (R->screen.cur.row < (R->TermWin.nrow - 1)) - row = (++R->screen.cur.row) + R->TermWin.saveLines; - stp = R->screen.text[row]; /* _must_ refresh */ - srp = R->screen.rend[row]; /* _must_ refresh */ - R->screen.cur.col = 0; - R->screen.flags &= ~Screen_WrapNext; + if (screen.flags & Screen_WrapNext) { + screen.tlen[row] = -1; + if (screen.cur.row == screen.bscroll) + scr_scroll_text(screen.tscroll, screen.bscroll, 1, 0); + else if (screen.cur.row < (TermWin.nrow - 1)) + row = (++screen.cur.row) + TermWin.saveLines; + stp = screen.text[row]; /* _must_ refresh */ + srp = screen.rend[row]; /* _must_ refresh */ + screen.cur.col = 0; + screen.flags &= ~Screen_WrapNext; } - if (R->screen.flags & Screen_Insert) - rxvt_scr_insdel_chars(aR_ 1, INSERT); + if (screen.flags & Screen_Insert) + scr_insdel_chars (1, INSERT); - if (R->charsets[R->screen.charset] == '0') // DEC SPECIAL + if (charsets[screen.charset] == '0') // DEC SPECIAL switch (c) { case '+': c = 0x2192; break; case ',': c = 0x2190; break; case '-': c = 0x2191; break; @@ -899,7 +893,7 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; } - rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); + rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c)); // rely on wcwidth to tell us the character width, at least for non-ascii int width = c <= 128 ? 1 : wcwidth (c); @@ -907,16 +901,16 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) if (width > 0) do { - stp[R->screen.cur.col] = c; - srp[R->screen.cur.col] = rend; + stp[screen.cur.col] = c; + srp[screen.cur.col] = rend; - if (R->screen.cur.col < last_col - 1) - R->screen.cur.col++; + if (screen.cur.col < last_col - 1) + screen.cur.col++; else { - R->screen.tlen[row] = last_col; - if (R->screen.flags & Screen_Autowrap) - R->screen.flags |= Screen_WrapNext; + screen.tlen[row] = last_col; + if (screen.flags & Screen_Autowrap) + screen.flags |= Screen_WrapNext; break; } @@ -924,11 +918,11 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) } while (--width > 0); else - 1; /* handle combining character etc. here. */ + (void)0; /* handle combining character etc. here. */ } - if (R->screen.tlen[row] != -1) /* XXX: think about this */ - MAX_IT(R->screen.tlen[row], R->screen.cur.col); + if (screen.tlen[row] != -1) /* XXX: think about this */ + MAX_IT(screen.tlen[row], screen.cur.col); /* * If we wrote anywhere in the selected area, kill the selection @@ -936,12 +930,12 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) * should be a similar check. */ if (clearsel) - CLEAR_SELECTION(R); + CLEAR_SELECTION(); #ifdef DEBUG_STRICT - assert(R->screen.cur.row >= 0); + assert(screen.cur.row >= 0); #else /* drive with your eyes closed */ - MAX_IT(R->screen.cur.row, 0); + MAX_IT(screen.cur.row, 0); #endif } @@ -950,22 +944,21 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) * Process Backspace. Move back the cursor back a position, wrap if have to * XTERM_SEQ: CTRL-H */ -/* EXTPROTO */ void -rxvt_scr_backspace(pR) +rxvt_term::scr_backspace () { - R->want_refresh = 1; - if (R->screen.cur.col == 0) { - if (R->screen.cur.row > 0) { + want_refresh = 1; + if (screen.cur.col == 0) { + if (screen.cur.row > 0) { #ifdef TERMCAP_HAS_BW - R->screen.cur.col = R->TermWin.ncol - 1; - R->screen.cur.row--; + screen.cur.col = TermWin.ncol - 1; + screen.cur.row--; return; #endif } - } else if ((R->screen.flags & Screen_WrapNext) == 0) - rxvt_scr_gotorc(aR_ 0, -1, RELATIVE); - R->screen.flags &= ~Screen_WrapNext; + } else if ((screen.flags & Screen_WrapNext) == 0) + scr_gotorc (0, -1, RELATIVE); + screen.flags &= ~Screen_WrapNext; } /* ------------------------------------------------------------------------- */ @@ -974,29 +967,28 @@ rxvt_scr_backspace(pR) * count: +ve = forward; -ve = backwards * XTERM_SEQ: CTRL-I */ -/* EXTPROTO */ void -rxvt_scr_tab(pR_ int count) +rxvt_term::scr_tab (int count) { int i, x; D_SCREEN((stderr, "rxvt_scr_tab(%d)", count)); - R->want_refresh = 1; - i = x = R->screen.cur.col; + want_refresh = 1; + i = x = screen.cur.col; if (count == 0) return; else if (count > 0) { - for (; ++i < R->TermWin.ncol; ) - if (R->tabs[i]) { + for (; ++i < TermWin.ncol; ) + if (tabs[i]) { x = i; if (!--count) break; } if (count) - x = R->TermWin.ncol - 1; + x = TermWin.ncol - 1; } else /* if (count < 0) */ { for (; --i >= 0; ) - if (R->tabs[i]) { + if (tabs[i]) { x = i; if (!++count) break; @@ -1004,8 +996,8 @@ rxvt_scr_tab(pR_ int count) if (count) x = 0; } - if (x != R->screen.cur.col) - rxvt_scr_gotorc(aR_ 0, x, R_RELATIVE); + if (x != screen.cur.col) + scr_gotorc (0, x, R_RELATIVE); } /* ------------------------------------------------------------------------- */ @@ -1016,16 +1008,15 @@ rxvt_scr_tab(pR_ int count) * in that row right. Clear left column. */ #ifndef NO_FRILLS -/* EXTPROTO */ void -rxvt_scr_backindex(pR) +rxvt_term::scr_backindex () { - if (R->screen.cur.col > 0) - rxvt_scr_gotorc(aR_ 0, -1, R_RELATIVE | C_RELATIVE); + if (screen.cur.col > 0) + scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); else { - if (R->screen.tlen[R->screen.cur.row + R->TermWin.saveLines] == 0) + if (screen.tlen[screen.cur.row + TermWin.saveLines] == 0) return; /* um, yeah? */ - rxvt_scr_insdel_chars(aR_ 1, INSERT); + scr_insdel_chars (1, INSERT); } } #endif @@ -1037,23 +1028,22 @@ rxvt_scr_backindex(pR) * in that row left. Clear right column. */ #ifndef NO_FRILLS -/* EXTPROTO */ void -rxvt_scr_forwardindex(pR) +rxvt_term::scr_forwardindex () { int row; - if (R->screen.cur.col < R->TermWin.ncol - 1) - rxvt_scr_gotorc(aR_ 0, 1, R_RELATIVE | C_RELATIVE); + if (screen.cur.col < TermWin.ncol - 1) + scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); else { - row = R->screen.cur.row + R->TermWin.saveLines; - if (R->screen.tlen[row] == 0) + row = screen.cur.row + TermWin.saveLines; + if (screen.tlen[row] == 0) return; /* um, yeah? */ - else if (R->screen.tlen[row] == -1) - R->screen.tlen[row] = R->TermWin.ncol; - rxvt_scr_gotorc(aR_ 0, 0, R_RELATIVE); - rxvt_scr_insdel_chars(aR_ 1, DELETE); - rxvt_scr_gotorc(aR_ 0, R->TermWin.ncol - 1, R_RELATIVE); + else if (screen.tlen[row] == -1) + screen.tlen[row] = TermWin.ncol; + scr_gotorc (0, 0, R_RELATIVE); + scr_insdel_chars (1, DELETE); + scr_gotorc (0, TermWin.ncol - 1, R_RELATIVE); } } #endif @@ -1062,80 +1052,78 @@ rxvt_scr_forwardindex(pR) /* * Goto Row/Column */ -/* EXTPROTO */ void -rxvt_scr_gotorc(pR_ int row, int col, int relative) +rxvt_term::scr_gotorc (int row, int col, int relative) { - R->want_refresh = 1; - ZERO_SCROLLBACK(R); + want_refresh = 1; + ZERO_SCROLLBACK(); #ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed(aR)) - rxvt_Gr_scroll(aR_ 0); + if (Gr_Displayed ()) + Gr_scroll (0); #endif - D_SCREEN((stderr, "rxvt_scr_gotorc(r:%s%d,c:%s%d): from (r:%d,c:%d)", (relative & R_RELATIVE ? "+" : ""), row, (relative & C_RELATIVE ? "+" : ""), col, R->screen.cur.row, R->screen.cur.col)); + D_SCREEN((stderr, "rxvt_scr_gotorc(r:%s%d,c:%s%d): from (r:%d,c:%d)", (relative & R_RELATIVE ? "+" : ""), row, (relative & C_RELATIVE ? "+" : ""), col, screen.cur.row, screen.cur.col)); - R->screen.cur.col = ((relative & C_RELATIVE) ? (R->screen.cur.col + col) + screen.cur.col = ((relative & C_RELATIVE) ? (screen.cur.col + col) : col); - MAX_IT(R->screen.cur.col, 0); - MIN_IT(R->screen.cur.col, (int32_t)R->TermWin.ncol - 1); + MAX_IT(screen.cur.col, 0); + MIN_IT(screen.cur.col, (int32_t)TermWin.ncol - 1); - R->screen.flags &= ~Screen_WrapNext; + screen.flags &= ~Screen_WrapNext; if (relative & R_RELATIVE) { if (row > 0) { - if (R->screen.cur.row <= R->screen.bscroll - && (R->screen.cur.row + row) > R->screen.bscroll) - R->screen.cur.row = R->screen.bscroll; + if (screen.cur.row <= screen.bscroll + && (screen.cur.row + row) > screen.bscroll) + screen.cur.row = screen.bscroll; else - R->screen.cur.row += row; + screen.cur.row += row; } else if (row < 0) { - if (R->screen.cur.row >= R->screen.tscroll - && (R->screen.cur.row + row) < R->screen.tscroll) - R->screen.cur.row = R->screen.tscroll; + if (screen.cur.row >= screen.tscroll + && (screen.cur.row + row) < screen.tscroll) + screen.cur.row = screen.tscroll; else - R->screen.cur.row += row; + screen.cur.row += row; } } else { - if (R->screen.flags & Screen_Relative) { /* relative origin mode */ - R->screen.cur.row = row + R->screen.tscroll; - MIN_IT(R->screen.cur.row, R->screen.bscroll); + if (screen.flags & Screen_Relative) { /* relative origin mode */ + screen.cur.row = row + screen.tscroll; + MIN_IT(screen.cur.row, screen.bscroll); } else - R->screen.cur.row = row; + screen.cur.row = row; } - MAX_IT(R->screen.cur.row, 0); - MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1); + MAX_IT(screen.cur.row, 0); + MIN_IT(screen.cur.row, (int32_t)TermWin.nrow - 1); } /* ------------------------------------------------------------------------- */ /* * direction should be UP or DN */ -/* EXTPROTO */ void -rxvt_scr_index(pR_ enum page_dirn direction) +rxvt_term::scr_index (enum page_dirn direction) { int dirn; - R->want_refresh = 1; + want_refresh = 1; dirn = ((direction == UP) ? 1 : -1); D_SCREEN((stderr, "rxvt_scr_index(%d)", dirn)); - ZERO_SCROLLBACK(R); + ZERO_SCROLLBACK(); #ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed(aR)) - rxvt_Gr_scroll(aR_ 0); + if (Gr_Displayed ()) + Gr_scroll (0); #endif - R->screen.flags &= ~Screen_WrapNext; - if ((R->screen.cur.row == R->screen.bscroll && direction == UP) - || (R->screen.cur.row == R->screen.tscroll && direction == DN)) - R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, dirn, 0); + screen.flags &= ~Screen_WrapNext; + if ((screen.cur.row == screen.bscroll && direction == UP) + || (screen.cur.row == screen.tscroll && direction == DN)) + scr_scroll_text(screen.tscroll, screen.bscroll, dirn, 0); else - R->screen.cur.row += dirn; - MAX_IT(R->screen.cur.row, 0); - MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1); - rxvt_selection_check(aR_ 0); + screen.cur.row += dirn; + MAX_IT(screen.cur.row, 0); + MIN_IT(screen.cur.row, (int32_t)TermWin.nrow - 1); + selection_check (0); } /* ------------------------------------------------------------------------- */ @@ -1145,60 +1133,59 @@ rxvt_scr_index(pR_ enum page_dirn direction) * XTERM_SEQ: Clear line to left : ESC [ 1 K * XTERM_SEQ: Clear whole line : ESC [ 2 K */ -/* EXTPROTO */ void -rxvt_scr_erase_line(pR_ int mode) +rxvt_term::scr_erase_line (int mode) { unsigned int row, col, num; - R->want_refresh = 1; - D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); - ZERO_SCROLLBACK (R); + want_refresh = 1; + D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, screen.cur.row)); + ZERO_SCROLLBACK (); #ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed (aR)) - rxvt_Gr_scroll (aR_ 0); + if (Gr_Displayed ()) + Gr_scroll (0); #endif - rxvt_selection_check (aR_ 1); + selection_check (1); - R->screen.flags &= ~Screen_WrapNext; + screen.flags &= ~Screen_WrapNext; - row = R->TermWin.saveLines + R->screen.cur.row; + row = TermWin.saveLines + screen.cur.row; switch (mode) { case 0: /* erase to end of line */ - col = R->screen.cur.col; - num = R->TermWin.ncol - col; - MIN_IT(R->screen.tlen[row], (int16_t)col); - if (ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur) - || ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.end, R->screen.cur)) - CLEAR_SELECTION(R); + col = screen.cur.col; + num = TermWin.ncol - col; + MIN_IT(screen.tlen[row], (int16_t)col); + if (ROWCOL_IN_ROW_AT_OR_AFTER(selection.beg, screen.cur) + || ROWCOL_IN_ROW_AT_OR_AFTER(selection.end, screen.cur)) + CLEAR_SELECTION(); break; case 1: /* erase to beginning of line */ col = 0; - num = R->screen.cur.col + 1; - if (ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.beg, R->screen.cur) - || ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.end, R->screen.cur)) - CLEAR_SELECTION(R); + num = screen.cur.col + 1; + if (ROWCOL_IN_ROW_AT_OR_BEFORE(selection.beg, screen.cur) + || ROWCOL_IN_ROW_AT_OR_BEFORE(selection.end, screen.cur)) + CLEAR_SELECTION(); break; case 2: /* erase whole line */ col = 0; - num = R->TermWin.ncol; - R->screen.tlen[row] = 0; - if (R->selection.beg.row <= R->screen.cur.row - && R->selection.end.row >= R->screen.cur.row) - CLEAR_SELECTION(R); + num = TermWin.ncol; + screen.tlen[row] = 0; + if (selection.beg.row <= screen.cur.row + && selection.end.row >= screen.cur.row) + CLEAR_SELECTION(); break; default: return; } - if (R->screen.text[row]) - R->scr_blank_line (&(R->screen.text[row][col]), - &(R->screen.rend[row][col]), num, R->rstyle); + if (screen.text[row]) + scr_blank_line (&(screen.text[row][col]), + &(screen.rend[row][col]), num, rstyle); else - R->scr_blank_screen_mem (R->screen.text, R->screen.rend, row, R->rstyle); + scr_blank_screen_mem (screen.text, screen.rend, row, rstyle); } /* ------------------------------------------------------------------------- */ @@ -1218,26 +1205,26 @@ rxvt_term::scr_erase_screen (int mode) want_refresh = 1; D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, screen.cur.row)); - ZERO_SCROLLBACK(this); + ZERO_SCROLLBACK (); row_offset = (int32_t)TermWin.saveLines; switch (mode) { case 0: /* erase to end of screen */ - rxvt_selection_check(this,1); - rxvt_scr_erase_line(this,0); + selection_check (1); + scr_erase_line (0); row = screen.cur.row + 1; /* possible OOB */ num = TermWin.nrow - row; break; case 1: /* erase to beginning of screen */ - rxvt_selection_check(this,3); - rxvt_scr_erase_line(this,1); + selection_check (3); + scr_erase_line (1); row = 0; num = screen.cur.row; break; case 2: /* erase whole screen */ - rxvt_selection_check (this, 3); + selection_check (3); #ifdef RXVT_GRAPHICS - rxvt_Gr_ClearScreen (this); + Gr_ClearScreen (); #endif row = 0; num = TermWin.nrow; @@ -1250,7 +1237,7 @@ rxvt_term::scr_erase_screen (int mode) && ((selection.beg.row >= row && selection.beg.row <= row + num) || (selection.end.row >= row && selection.end.row <= row + num))) - CLEAR_SELECTION (this); + CLEAR_SELECTION (); if (row >= TermWin.nrow) /* Out Of Bounds */ return; MIN_IT(num, (TermWin.nrow - row)); @@ -1281,23 +1268,22 @@ rxvt_term::scr_erase_screen (int mode) * Fill the screen with `E's * XTERM_SEQ: Screen Alignment Test: ESC # 8 */ -/* EXTPROTO */ void -rxvt_scr_E(pR) +rxvt_term::scr_E () { int i, j, k; rend_t *r1, fs; - R->want_refresh = 1; - R->num_scr_allow = 0; - ZERO_SCROLLBACK(R); - rxvt_selection_check(aR_ 3); - - fs = SET_FONT (R->rstyle, R->TermWin.fontset->find_font ('E')); - for (k = R->TermWin.saveLines, i = R->TermWin.nrow; i--; k++) { - R->screen.tlen[k] = R->TermWin.ncol; /* make the `E's selectable */ - fill_text (R->screen.text[k], 'E', R->TermWin.ncol); - for (r1 = R->screen.rend[k], j = R->TermWin.ncol; j--; ) + want_refresh = 1; + num_scr_allow = 0; + ZERO_SCROLLBACK(); + selection_check (3); + + fs = SET_FONT (rstyle, TermWin.fontset->find_font ('E')); + for (k = TermWin.saveLines, i = TermWin.nrow; i--; k++) { + screen.tlen[k] = TermWin.ncol; /* make the `E's selectable */ + fill_text (screen.text[k], 'E', TermWin.ncol); + for (r1 = screen.rend[k], j = TermWin.ncol; j--; ) *r1++ = fs; } } @@ -1306,43 +1292,41 @@ rxvt_scr_E(pR) /* * Insert/Delete lines */ -/* EXTPROTO */ void -rxvt_scr_insdel_lines(pR_ int count, int insdel) +rxvt_term::scr_insdel_lines (int count, int insdel) { int end; - ZERO_SCROLLBACK(R); + ZERO_SCROLLBACK(); #ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed(aR)) - rxvt_Gr_scroll(aR_ 0); + if (Gr_Displayed ()) + Gr_scroll (0); #endif - rxvt_selection_check(aR_ 1); + selection_check (1); - if (R->screen.cur.row > R->screen.bscroll) + if (screen.cur.row > screen.bscroll) return; - end = R->screen.bscroll - R->screen.cur.row + 1; + end = screen.bscroll - screen.cur.row + 1; if (count > end) { if (insdel == DELETE) return; else if (insdel == INSERT) count = end; } - R->screen.flags &= ~Screen_WrapNext; + screen.flags &= ~Screen_WrapNext; - R->scr_scroll_text(R->screen.cur.row, R->screen.bscroll, insdel * count, 0); + scr_scroll_text(screen.cur.row, screen.bscroll, insdel * count, 0); } /* ------------------------------------------------------------------------- */ /* * Insert/Delete characters from the current position */ -/* EXTPROTO */ void -rxvt_scr_insdel_chars(pR_ int count, int insdel) +rxvt_term::scr_insdel_chars (int count, int insdel) { int col, row; rend_t tr; @@ -1350,83 +1334,83 @@ rxvt_scr_insdel_chars(pR_ int count, int insdel) rend_t *srp; int16_t *slp; - R->want_refresh = 1; - ZERO_SCROLLBACK(R); + want_refresh = 1; + ZERO_SCROLLBACK(); #ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed(aR)) - rxvt_Gr_scroll(aR_ 0); + if (Gr_Displayed ()) + Gr_scroll (0); #endif if (count <= 0) return; - rxvt_selection_check(aR_ 1); - MIN_IT(count, (R->TermWin.ncol - R->screen.cur.col)); + selection_check (1); + MIN_IT(count, (TermWin.ncol - screen.cur.col)); - row = R->screen.cur.row + R->TermWin.saveLines; - R->screen.flags &= ~Screen_WrapNext; + row = screen.cur.row + TermWin.saveLines; + screen.flags &= ~Screen_WrapNext; - stp = R->screen.text[row]; - srp = R->screen.rend[row]; - slp = &(R->screen.tlen[row]); + stp = screen.text[row]; + srp = screen.rend[row]; + slp = &(screen.tlen[row]); switch (insdel) { case INSERT: - for (col = R->TermWin.ncol - 1; (col - count) >= R->screen.cur.col; + for (col = TermWin.ncol - 1; (col - count) >= screen.cur.col; col--) { stp[col] = stp[col - count]; srp[col] = srp[col - count]; } if (*slp != -1) { *slp += count; - MIN_IT(*slp, R->TermWin.ncol); + MIN_IT(*slp, TermWin.ncol); } - if (R->selection.op && R->current_screen == R->selection.screen - && ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur)) { - if (R->selection.end.row != R->screen.cur.row - || (R->selection.end.col + count >= R->TermWin.ncol)) - CLEAR_SELECTION(R); + if (selection.op && current_screen == selection.screen + && ROWCOL_IN_ROW_AT_OR_AFTER(selection.beg, screen.cur)) { + if (selection.end.row != screen.cur.row + || (selection.end.col + count >= TermWin.ncol)) + CLEAR_SELECTION(); else { /* shift selection */ - R->selection.beg.col += count; - R->selection.mark.col += count; /* XXX: yes? */ - R->selection.end.col += count; + selection.beg.col += count; + selection.mark.col += count; /* XXX: yes? */ + selection.end.col += count; } } - R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), - (unsigned int)count, R->rstyle); + scr_blank_line (&(stp[screen.cur.col]), &(srp[screen.cur.col]), + (unsigned int)count, rstyle); break; case ERASE: - R->screen.cur.col += count; /* don't worry if > R->TermWin.ncol */ - rxvt_selection_check(aR_ 1); - R->screen.cur.col -= count; - R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), - (unsigned int)count, R->rstyle); + screen.cur.col += count; /* don't worry if > TermWin.ncol */ + selection_check (1); + screen.cur.col -= count; + scr_blank_line (&(stp[screen.cur.col]), &(srp[screen.cur.col]), + (unsigned int)count, rstyle); break; case DELETE: - tr = srp[R->TermWin.ncol - 1] + tr = srp[TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); - for (col = R->screen.cur.col; (col + count) < R->TermWin.ncol; col++) { + for (col = screen.cur.col; (col + count) < TermWin.ncol; col++) { stp[col] = stp[col + count]; srp[col] = srp[col + count]; } - R->scr_blank_line (&(stp[R->TermWin.ncol - count]), - &(srp[R->TermWin.ncol - count]), + scr_blank_line (&(stp[TermWin.ncol - count]), + &(srp[TermWin.ncol - count]), (unsigned int)count, tr); if (*slp == -1) /* break line continuation */ - *slp = R->TermWin.ncol; + *slp = TermWin.ncol; *slp -= count; MAX_IT(*slp, 0); - if (R->selection.op && R->current_screen == R->selection.screen - && ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur)) { - if (R->selection.end.row != R->screen.cur.row - || (R->screen.cur.col >= R->selection.beg.col - count) - || R->selection.end.col >= R->TermWin.ncol) - CLEAR_SELECTION(R); + if (selection.op && current_screen == selection.screen + && ROWCOL_IN_ROW_AT_OR_AFTER(selection.beg, screen.cur)) { + if (selection.end.row != screen.cur.row + || (screen.cur.col >= selection.beg.col - count) + || selection.end.col >= TermWin.ncol) + CLEAR_SELECTION(); else { /* shift selection */ - R->selection.beg.col -= count; - R->selection.mark.col -= count; /* XXX: yes? */ - R->selection.end.col -= count; + selection.beg.col -= count; + selection.mark.col -= count; /* XXX: yes? */ + selection.end.col -= count; } } break; @@ -1438,17 +1422,16 @@ rxvt_scr_insdel_chars(pR_ int count, int insdel) * Set the scrolling region * XTERM_SEQ: Set region - inclusive: ESC [ ; r */ -/* EXTPROTO */ void -rxvt_scr_scroll_region(pR_ int top, int bot) +rxvt_term::scr_scroll_region (int top, int bot) { MAX_IT(top, 0); - MIN_IT(bot, (int)R->TermWin.nrow - 1); + MIN_IT(bot, (int)TermWin.nrow - 1); if (top > bot) return; - R->screen.tscroll = top; - R->screen.bscroll = bot; - rxvt_scr_gotorc(aR_ 0, 0, 0); + screen.tscroll = top; + screen.bscroll = bot; + scr_gotorc (0, 0, 0); } /* ------------------------------------------------------------------------- */ @@ -1457,15 +1440,14 @@ rxvt_scr_scroll_region(pR_ int top, int bot) * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l */ -/* EXTPROTO */ void -rxvt_scr_cursor_visible(pR_ int mode) +rxvt_term::scr_cursor_visible (int mode) { - R->want_refresh = 1; + want_refresh = 1; if (mode) - R->screen.flags |= Screen_VisibleCursor; + screen.flags |= Screen_VisibleCursor; else - R->screen.flags &= ~Screen_VisibleCursor; + screen.flags &= ~Screen_VisibleCursor; } /* ------------------------------------------------------------------------- */ @@ -1474,14 +1456,13 @@ rxvt_scr_cursor_visible(pR_ int mode) * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l */ -/* EXTPROTO */ void -rxvt_scr_autowrap(pR_ int mode) +rxvt_term::scr_autowrap (int mode) { if (mode) - R->screen.flags |= Screen_Autowrap; + screen.flags |= Screen_Autowrap; else - R->screen.flags &= ~(Screen_Autowrap | Screen_WrapNext); + screen.flags &= ~(Screen_Autowrap | Screen_WrapNext); } /* ------------------------------------------------------------------------- */ @@ -1494,15 +1475,14 @@ rxvt_scr_autowrap(pR_ int mode) * XTERM_SEQ: Set Absolute: ESC [ ? 6 h * XTERM_SEQ: Set Relative: ESC [ ? 6 l */ -/* EXTPROTO */ void -rxvt_scr_relative_origin(pR_ int mode) +rxvt_term::scr_relative_origin (int mode) { if (mode) - R->screen.flags |= Screen_Relative; + screen.flags |= Screen_Relative; else - R->screen.flags &= ~Screen_Relative; - rxvt_scr_gotorc(aR_ 0, 0, 0); + screen.flags &= ~Screen_Relative; + scr_gotorc (0, 0, 0); } /* ------------------------------------------------------------------------- */ @@ -1511,14 +1491,13 @@ rxvt_scr_relative_origin(pR_ int mode) * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l */ -/* EXTPROTO */ void -rxvt_scr_insert_mode(pR_ int mode) +rxvt_term::scr_insert_mode (int mode) { if (mode) - R->screen.flags |= Screen_Insert; + screen.flags |= Screen_Insert; else - R->screen.flags &= ~Screen_Insert; + screen.flags &= ~Screen_Insert; } /* ------------------------------------------------------------------------- */ @@ -1528,14 +1507,13 @@ rxvt_scr_insert_mode(pR_ int mode) * XTERM_SEQ: Clear tab at current column: ESC [ 0 g * XTERM_SEQ: Clear all tabs : ESC [ 3 g */ -/* EXTPROTO */ void -rxvt_scr_set_tab(pR_ int mode) +rxvt_term::scr_set_tab (int mode) { if (mode < 0) - MEMSET(R->tabs, 0, R->TermWin.ncol * sizeof(char)); - else if (R->screen.cur.col < R->TermWin.ncol) - R->tabs[R->screen.cur.col] = (mode ? 1 : 0); + MEMSET(tabs, 0, TermWin.ncol * sizeof(char)); + else if (screen.cur.col < TermWin.ncol) + tabs[screen.cur.col] = (mode ? 1 : 0); } /* ------------------------------------------------------------------------- */ @@ -1544,30 +1522,29 @@ rxvt_scr_set_tab(pR_ int mode) * XTERM_SEQ: Reverse video: ESC [ ? 5 h * XTERM_SEQ: Normal video : ESC [ ? 5 l */ -/* EXTPROTO */ void -rxvt_scr_rvideo_mode(pR_ int mode) +rxvt_term::scr_rvideo_mode (int mode) { XGCValues gcvalue; - if (R->rvideo != mode) { - R->rvideo = mode; - SWAP_IT(R->PixColors[Color_fg], R->PixColors[Color_bg], rxvt_color); + if (rvideo != mode) { + rvideo = mode; + SWAP_IT(PixColors[Color_fg], PixColors[Color_bg], rxvt_color); #if defined(XPM_BACKGROUND) - if (R->bgPixmap.pixmap == None) + if (bgPixmap.pixmap == None) #endif #if defined(TRANSPARENT) - if (!(R->Options & Opt_transparent) || R->am_transparent == 0) + if (!(Options & Opt_transparent) || am_transparent == 0) #endif - XSetWindowBackground(R->Xdisplay, R->TermWin.vt, - R->PixColors[Color_bg]); + XSetWindowBackground(Xdisplay, TermWin.vt, + PixColors[Color_bg]); - gcvalue.foreground = R->PixColors[Color_fg]; - gcvalue.background = R->PixColors[Color_bg]; - XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, + gcvalue.foreground = PixColors[Color_fg]; + gcvalue.background = PixColors[Color_bg]; + XChangeGC(Xdisplay, TermWin.gc, GCBackground | GCForeground, &gcvalue); - R->scr_clear (); - R->scr_touch (true); + scr_clear (); + scr_touch (true); } } @@ -1576,11 +1553,10 @@ rxvt_scr_rvideo_mode(pR_ int mode) * Report current cursor position * XTERM_SEQ: Report position: ESC [ 6 n */ -/* EXTPROTO */ void -rxvt_scr_report_position(pR) +rxvt_term::scr_report_position () { - R->tt_printf("\033[%d;%dR", R->screen.cur.row + 1, R->screen.cur.col + 1); + tt_printf("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1); } /* ------------------------------------------------------------------------- * @@ -1590,11 +1566,10 @@ rxvt_scr_report_position(pR) /* * Set font style */ -/* INTPROTO */ void -rxvt_set_font_style(pR) +rxvt_term::set_font_style () { - switch (R->charsets[R->screen.charset]) { + switch (charsets[screen.charset]) { case '0': /* DEC Special Character & Line Drawing Set */ break; case 'A': /* United Kingdom (UK) */ @@ -1620,12 +1595,11 @@ rxvt_set_font_style(pR) * XTERM_SEQ: Invoke G2 character set: ESC N * XTERM_SEQ: Invoke G3 character set: ESC O */ -/* EXTPROTO */ void -rxvt_scr_charset_choose(pR_ int set) +rxvt_term::scr_charset_choose (int set) { - R->screen.charset = set; - rxvt_set_font_style(aR); + screen.charset = set; + set_font_style (); } /* ------------------------------------------------------------------------- */ @@ -1637,12 +1611,11 @@ rxvt_scr_charset_choose(pR_ int set) * XTERM_SEQ: Set G3 character set: ESC + * See set_font_style for possible values for */ -/* EXTPROTO */ void -rxvt_scr_charset_set(pR_ int set, unsigned int ch) +rxvt_term::scr_charset_set (int set, unsigned int ch) { - R->charsets[set] = (unsigned char)ch; - rxvt_set_font_style(aR); + charsets[set] = (unsigned char)ch; + set_font_style (); } @@ -1738,23 +1711,22 @@ rxvt_term::scr_touch (bool refresh) * Move the display so that the line represented by scrollbar value Y is at * the top of the screen */ -/* EXTPROTO */ int -rxvt_scr_move_to(pR_ int y, int len) +rxvt_term::scr_move_to (int y, int len) { long p = 0; uint16_t oldviewstart; - oldviewstart = R->TermWin.view_start; + oldviewstart = TermWin.view_start; if (y < len) { - p = (R->TermWin.nrow + R->TermWin.nscrolled) * (len - y) / len; - p -= (long)(R->TermWin.nrow - 1); + p = (TermWin.nrow + TermWin.nscrolled) * (len - y) / len; + p -= (long)(TermWin.nrow - 1); p = max(p, 0); } - R->TermWin.view_start = (uint16_t)min(p, R->TermWin.nscrolled); - D_SCREEN((stderr, "rxvt_scr_move_to(%d, %d) view_start:%d", y, len, R->TermWin.view_start)); + TermWin.view_start = (uint16_t)min(p, TermWin.nscrolled); + D_SCREEN((stderr, "rxvt_scr_move_to(%d, %d) view_start:%d", y, len, TermWin.view_start)); - return rxvt_scr_changeview(aR_ oldviewstart); + return scr_changeview (oldviewstart); } /* ------------------------------------------------------------------------- */ @@ -1762,101 +1734,97 @@ rxvt_scr_move_to(pR_ int y, int len) * Page the screen up/down nlines * direction should be UP or DN */ -/* EXTPROTO */ int -rxvt_scr_page(pR_ enum page_dirn direction, int nlines) +rxvt_term::scr_page (enum page_dirn direction, int nlines) { int n; uint16_t oldviewstart; - D_SCREEN((stderr, "rxvt_scr_page(%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, R->TermWin.view_start)); + D_SCREEN((stderr, "rxvt_scr_page(%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start)); #ifdef DEBUG_STRICT - assert((nlines >= 0) && (nlines <= R->TermWin.nrow)); + assert((nlines >= 0) && (nlines <= TermWin.nrow)); #endif - oldviewstart = R->TermWin.view_start; + oldviewstart = TermWin.view_start; if (direction == UP) { - n = R->TermWin.view_start + nlines; - R->TermWin.view_start = min(n, R->TermWin.nscrolled); + n = TermWin.view_start + nlines; + TermWin.view_start = min(n, TermWin.nscrolled); } else { - n = R->TermWin.view_start - nlines; - R->TermWin.view_start = max(n, 0); + n = TermWin.view_start - nlines; + TermWin.view_start = max(n, 0); } - return rxvt_scr_changeview(aR_ oldviewstart); + return scr_changeview (oldviewstart); } -/* INTPROTO */ int -rxvt_scr_changeview(pR_ uint16_t oldviewstart) +rxvt_term::scr_changeview (uint16_t oldviewstart) { - if (R->TermWin.view_start != oldviewstart) { - R->want_refresh = 1; + if (TermWin.view_start != oldviewstart) { + want_refresh = 1; #ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed(aR)) - rxvt_Gr_scroll(aR_ 0); + if (Gr_Displayed ()) + Gr_scroll (0); #endif - R->num_scr -= (R->TermWin.view_start - oldviewstart); + num_scr -= (TermWin.view_start - oldviewstart); } - return (int)(R->TermWin.view_start - oldviewstart); + return (int)(TermWin.view_start - oldviewstart); } /* ------------------------------------------------------------------------- */ -/* EXTPROTO */ void -rxvt_scr_bell(pR) +rxvt_term::scr_bell () { #ifndef NO_BELL # ifndef NO_MAPALERT # ifdef MAPALERT_OPTION - if (R->Options & Opt_mapAlert) + if (Options & Opt_mapAlert) # endif - XMapWindow(R->Xdisplay, R->TermWin.parent[0]); + XMapWindow(Xdisplay, TermWin.parent[0]); # endif - if (R->Options & Opt_visualBell) { - rxvt_scr_rvideo_mode(aR_ !R->rvideo); /* refresh also done */ - rxvt_scr_rvideo_mode(aR_ !R->rvideo); /* refresh also done */ + if (Options & Opt_visualBell) { + scr_rvideo_mode (!rvideo); /* refresh also done */ + scr_rvideo_mode (!rvideo); /* refresh also done */ } else - XBell(R->Xdisplay, 0); + XBell(Xdisplay, 0); #endif } /* ------------------------------------------------------------------------- */ /* ARGSUSED */ -/* EXTPROTO */ void -rxvt_scr_printscreen(pR_ int fullhist) +rxvt_term::scr_printscreen (int fullhist) { #ifdef PRINTPIPE int i, r1, nrows, row_offset; text_t *t; FILE *fd; - if ((fd = rxvt_popen_printer(aR)) == NULL) + if ((fd = popen_printer ()) == NULL) return; - nrows = R->TermWin.nrow; - row_offset = R->TermWin.saveLines; + nrows = TermWin.nrow; + row_offset = TermWin.saveLines; if (!fullhist) - row_offset -= R->TermWin.view_start; + row_offset -= TermWin.view_start; else { - nrows += R->TermWin.nscrolled; - row_offset -= R->TermWin.nscrolled; + nrows += TermWin.nscrolled; + row_offset -= TermWin.nscrolled; } for (r1 = 0; r1 < nrows; r1++) { - t = R->screen.text[r1 + row_offset]; - for (i = R->TermWin.ncol - 1; i >= 0; i--) + t = screen.text[r1 + row_offset]; + for (i = TermWin.ncol - 1; i >= 0; i--) if (!isspace(t[i])) break; fprintf(fd, "%.*s\n", (i + 1), t); } - rxvt_pclose_printer(fd); + pclose_printer (fd); #endif } /* ------------------------------------------------------------------------- */ /* * Refresh the screen - * R->drawn_text/R->drawn_rend contain the screen information before the update. - * R->screen.text/R->screen.rend contain what the screen will change to. + * drawn_text/drawn_rend contain the screen information before the update. + * screen.text/screen.rend contain what the screen will change to. */ #define FONT_WIDTH(X, Y) \ @@ -1883,7 +1851,6 @@ rxvt_term::scr_refresh (unsigned char refresh_type) row_offset; /* basic offset in screen structure */ #ifndef NO_CURSORCOLOR rend_t cc1; /* store colours at cursor position(s) */ - rend_t cc2; /* store colours at cursor position(s) */ #endif rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ @@ -1917,7 +1884,7 @@ rxvt_term::scr_refresh (unsigned char refresh_type) /* * B: reverse any characters which are selected */ - rxvt_scr_reverse_selection (this); + scr_reverse_selection (); /* * C: set the cursor character(s) @@ -1948,7 +1915,7 @@ rxvt_term::scr_refresh (unsigned char refresh_type) *srp ^= RS_RVid; #ifndef NO_CURSORCOLOR cc1 = *srp & (RS_fgMask | RS_bgMask); - if (ISSET_PIXCOLOR (this, Color_cursor)) + if (ISSET_PIXCOLOR (Color_cursor)) ccol1 = Color_cursor; else #ifdef CURSOR_COLOR_IS_RENDITION_COLOR @@ -1956,7 +1923,7 @@ rxvt_term::scr_refresh (unsigned char refresh_type) #else ccol1 = Color_fg; #endif - if (ISSET_PIXCOLOR (this, Color_cursor2)) + if (ISSET_PIXCOLOR (Color_cursor2)) ccol2 = Color_cursor2; else #ifdef CURSOR_COLOR_IS_RENDITION_COLOR @@ -2169,9 +2136,9 @@ rxvt_term::scr_refresh (unsigned char refresh_type) SWAP_IT(fore, back, int); #ifndef NO_BOLD_UNDERLINE_REVERSE - if (ISSET_PIXCOLOR (this, Color_RV) + if (ISSET_PIXCOLOR (Color_RV) # ifndef NO_CURSORCOLOR - && !ISSET_PIXCOLOR (this, Color_cursor) + && !ISSET_PIXCOLOR (Color_cursor) # endif ) back = Color_RV; @@ -2180,14 +2147,14 @@ rxvt_term::scr_refresh (unsigned char refresh_type) #ifndef NO_BOLD_UNDERLINE_REVERSE else if (rend & RS_Bold) { - if (ISSET_PIXCOLOR (this, Color_BD)) + if (ISSET_PIXCOLOR (Color_BD)) fore = Color_BD; else if (fore == Color_fg) fore = Color_White; } else if (rend & RS_Uline) { - if (ISSET_PIXCOLOR (this, Color_UL)) + if (ISSET_PIXCOLOR (Color_UL)) fore = Color_UL; } #endif @@ -2237,9 +2204,7 @@ nodraw: ; #endif } else if (oldcursor.row >= 0) { #ifndef NO_CURSORCOLOR - unsigned long gcmask; /* Graphics Context mask */ - - if (ISSET_PIXCOLOR (this, Color_cursor)) + if (ISSET_PIXCOLOR (Color_cursor)) XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]); #endif XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, @@ -2253,7 +2218,7 @@ nodraw: ; /* * H: cleanup selection */ - rxvt_scr_reverse_selection (this); + scr_reverse_selection (); /* * I: other general cleanup @@ -2312,29 +2277,28 @@ rxvt_term::scr_clear() } /* ------------------------------------------------------------------------- */ -/* INTPROTO */ void -rxvt_scr_reverse_selection(pR) +rxvt_term::scr_reverse_selection () { int i, col, row, end_row; rend_t *srp; - if (R->selection.op && R->current_screen == R->selection.screen) { - end_row = R->TermWin.saveLines - R->TermWin.view_start; - i = R->selection.beg.row + R->TermWin.saveLines; - row = R->selection.end.row + R->TermWin.saveLines; + if (selection.op && current_screen == selection.screen) { + end_row = TermWin.saveLines - TermWin.view_start; + i = selection.beg.row + TermWin.saveLines; + row = selection.end.row + TermWin.saveLines; if (i >= end_row) - col = R->selection.beg.col; + col = selection.beg.col; else { col = 0; i = end_row; } - end_row += R->TermWin.nrow; + end_row += TermWin.nrow; for (; i < row && i < end_row; i++, col = 0) - for (srp = R->screen.rend[i]; col < R->TermWin.ncol; col++) + for (srp = screen.rend[i]; col < TermWin.ncol; col++) srp[col] ^= RS_RVid; if (i == row && i < end_row) - for (srp = R->screen.rend[i]; col < R->selection.end.col; col++) + for (srp = screen.rend[i]; col < selection.end.col; col++) srp[col] ^= RS_RVid; } } @@ -2345,25 +2309,24 @@ rxvt_scr_reverse_selection(pR) * invoking routine must close the fd. */ #if 0 -/* EXTPROTO */ void -rxvt_scr_dump(pR_ int fd) +rxvt_term::scr_dump (int fd) { int row, wrote; unsigned int width, towrite; char r1[] = "\n"; - for (row = R->TermWin.saveLines - R->TermWin.nscrolled; - row < R->TermWin.saveLines + R->TermWin.nrow - 1; row++) { - width = R->screen.tlen[row] >= 0 ? R->screen.tlen[row] - : R->TermWin.ncol; + for (row = TermWin.saveLines - TermWin.nscrolled; + row < TermWin.saveLines + TermWin.nrow - 1; row++) { + width = screen.tlen[row] >= 0 ? screen.tlen[row] + : TermWin.ncol; for (towrite = width; towrite; towrite -= wrote) { - wrote = write(fd, &(R->screen.text[row][width - towrite]), + wrote = write(fd, &(screen.text[row][width - towrite]), towrite); if (wrote < 0) return; /* XXX: death, no report */ } - if (R->screen.tlen[row] >= 0) + if (screen.tlen[row] >= 0) if (write(fd, r1, 1) <= 0) return; /* XXX: death, no report */ } @@ -2375,37 +2338,36 @@ rxvt_scr_dump(pR_ int fd) * ------------------------------------------------------------------------- */ /* - * -R->TermWin.nscrolled <= (selection row) <= R->TermWin.nrow - 1 + * -TermWin.nscrolled <= (selection row) <= TermWin.nrow - 1 */ -/* EXTPROTO */ void -rxvt_selection_check(pR_ int check_more) +rxvt_term::selection_check (int check_more) { row_col_t pos; - if (!R->selection.op) + if (!selection.op) return; pos.row = pos.col = 0; - if ((R->selection.beg.row < -(int32_t)R->TermWin.nscrolled) - || (R->selection.beg.row >= R->TermWin.nrow) - || (R->selection.mark.row < -(int32_t)R->TermWin.nscrolled) - || (R->selection.mark.row >= R->TermWin.nrow) - || (R->selection.end.row < -(int32_t)R->TermWin.nscrolled) - || (R->selection.end.row >= R->TermWin.nrow) + if ((selection.beg.row < -(int32_t)TermWin.nscrolled) + || (selection.beg.row >= TermWin.nrow) + || (selection.mark.row < -(int32_t)TermWin.nscrolled) + || (selection.mark.row >= TermWin.nrow) + || (selection.end.row < -(int32_t)TermWin.nscrolled) + || (selection.end.row >= TermWin.nrow) || (check_more == 1 - && R->current_screen == R->selection.screen - && !ROWCOL_IS_BEFORE(R->screen.cur, R->selection.beg) - && ROWCOL_IS_BEFORE(R->screen.cur, R->selection.end)) + && current_screen == selection.screen + && !ROWCOL_IS_BEFORE(screen.cur, selection.beg) + && ROWCOL_IS_BEFORE(screen.cur, selection.end)) || (check_more == 2 - && ROWCOL_IS_BEFORE(R->selection.beg, pos) - && ROWCOL_IS_AFTER(R->selection.end, pos)) + && ROWCOL_IS_BEFORE(selection.beg, pos) + && ROWCOL_IS_AFTER(selection.end, pos)) || (check_more == 3 - && ROWCOL_IS_AFTER(R->selection.end, pos)) + && ROWCOL_IS_AFTER(selection.end, pos)) || (check_more == 4 /* screen width change */ - && (R->selection.beg.row != R->selection.end.row - || R->selection.end.col > R->TermWin.ncol))) - CLEAR_SELECTION(R); + && (selection.beg.row != selection.end.row + || selection.end.col > TermWin.ncol))) + CLEAR_SELECTION(); } /* ------------------------------------------------------------------------- */ @@ -2444,36 +2406,35 @@ rxvt_term::paste (const unsigned char *data, unsigned int len) * Respond to a notification that a primary selection has been sent * EXT: SelectionNotify */ -/* EXTPROTO */ int -rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) +rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) { long nread = 0; unsigned long bytes_after; XTextProperty ct; - D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); + D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, selection_wait)); if (prop == None) /* check for failed XConvertSelection */ { - if ((R->selection_type & Sel_CompoundText)) + if ((selection_type & Sel_CompoundText)) { - int selnum = R->selection_type & Sel_whereMask; + int selnum = selection_type & Sel_whereMask; - R->selection_type = 0; + selection_type = 0; if (selnum != Sel_direct) - rxvt_selection_request_other(aR_ XA_STRING, selnum); + selection_request_other (XA_STRING, selnum); } - if ((R->selection_type & Sel_UTF8String)) + if ((selection_type & Sel_UTF8String)) { - int selnum = R->selection_type & Sel_whereMask; + int selnum = selection_type & Sel_whereMask; - R->selection_type = Sel_CompoundText; + selection_type = Sel_CompoundText; if (selnum != Sel_direct) - rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], selnum); + selection_request_other (xa[XA_COMPOUND_TEXT], selnum); else - R->selection_type = 0; + selection_type = 0; } return 0; @@ -2481,7 +2442,7 @@ rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) for (;;) { - if (XGetWindowProperty(R->Xdisplay, win, prop, (long)(nread / 4), + if (XGetWindowProperty(Xdisplay, win, prop, (long)(nread / 4), (long)(PROP_SIZE / 4), delete_prop, AnyPropertyType, &ct.encoding, &ct.format, &ct.nitems, &bytes_after, @@ -2503,14 +2464,14 @@ rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) if (ct.nitems == 0) { D_SELECT((stderr, "rxvt_selection_paste: property empty - also INCR end")); - if (R->selection_wait == Sel_normal && nread == 0) + if (selection_wait == Sel_normal && nread == 0) { /* * pass through again trying CUT_BUFFER0 if we've come from * XConvertSelection() but nothing was presented */ D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); - rxvt_selection_paste (aR_ Xroot, XA_CUT_BUFFER0, False); + selection_paste (Xroot, XA_CUT_BUFFER0, False); } nread = -1; /* discount any previous stuff */ @@ -2521,16 +2482,16 @@ rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) char **cl; int cr; - if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, + if (XmbTextPropertyToTextList (Xdisplay, &ct, &cl, &cr) >= 0 && cl) { for (int i = 0; i < cr; i++) - R->paste ((unsigned char *)cl[i], STRLEN (cl[i])); + paste ((unsigned char *)cl[i], STRLEN (cl[i])); XFreeStringList (cl); } else - R->paste (ct.value, ct.nitems); + paste (ct.value, ct.nitems); if (bytes_after == 0) break; @@ -2541,8 +2502,8 @@ rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) if (ct.value) XFree (ct.value); - if (R->selection_wait == Sel_normal) - R->selection_wait = Sel_none; + if (selection_wait == Sel_normal) + selection_wait = Sel_none; D_SELECT((stderr, "rxvt_selection_paste: bytes written: %ld", nread)); return (int)nread; @@ -2559,47 +2520,46 @@ rxvt_term::incr_cb (time_watcher &w) /* * INCR support originally provided by Paul Sheer */ -/* EXTPROTO */ void -rxvt_selection_property(pR_ Window win, Atom prop) +rxvt_term::selection_property (Window win, Atom prop) { int reget_time = 0; if (prop == None) return; D_SELECT((stderr, "rxvt_selection_property(%08lx, %lu)", win, (unsigned long)prop)); - if (R->selection_wait == Sel_normal) { + if (selection_wait == Sel_normal) { int a, afmt; Atom atype; unsigned long bytes_after, nitems; unsigned char *s = NULL; - a = XGetWindowProperty(R->Xdisplay, win, prop, 0L, 1L, False, - R->xa[XA_INCR], &atype, &afmt, &nitems, + a = XGetWindowProperty(Xdisplay, win, prop, 0L, 1L, False, + xa[XA_INCR], &atype, &afmt, &nitems, &bytes_after, &s); if (s) XFree(s); if (a != Success) return; #ifndef __CYGWIN32__ - if (atype == R->xa[XA_INCR]) { /* start an INCR transfer */ + if (atype == xa[XA_INCR]) { /* start an INCR transfer */ D_SELECT((stderr, "rxvt_selection_property: INCR: starting transfer")); - XDeleteProperty(R->Xdisplay, win, prop); - XFlush(R->Xdisplay); + XDeleteProperty(Xdisplay, win, prop); + XFlush(Xdisplay); reget_time = 1; - R->selection_wait = Sel_incr; + selection_wait = Sel_incr; } #endif - } else if (R->selection_wait == Sel_incr) { + } else if (selection_wait == Sel_incr) { reget_time = 1; - if (rxvt_selection_paste(aR_ win, prop, True) == -1) { + if (selection_paste (win, prop, True) == -1) { D_SELECT((stderr, "rxvt_selection_property: INCR: clean end")); - R->selection_wait = Sel_none; - R->incr_ev.stop (); + selection_wait = Sel_none; + incr_ev.stop (); } } if (reget_time) /* received more data so reget time */ - R->incr_ev.start (NOW + 10); + incr_ev.start (NOW + 10); } /* ------------------------------------------------------------------------- */ /* @@ -2611,60 +2571,58 @@ rxvt_selection_property(pR_ Window win, Atom prop) * will auto fallback to CUT_BUFFER0 * EXT: button 2 release */ -/* EXTPROTO */ void -rxvt_selection_request(pR_ Time tm, int x, int y) +rxvt_term::selection_request (Time tm, int x, int y) { D_SELECT((stderr, "rxvt_selection_request(%lu, %d, %d)", tm, x, y)); - if (x < 0 || x >= R->TermWin.width || y < 0 || y >= R->TermWin.height) + if (x < 0 || x >= TermWin.width || y < 0 || y >= TermWin.height) return; /* outside window */ - if (R->selection.text != NULL) { /* internal selection */ + if (selection.text != NULL) { /* internal selection */ D_SELECT((stderr, "rxvt_selection_request: pasting internal")); - R->paste (R->selection.text, R->selection.len); + paste (selection.text, selection.len); return; } else { int i; - R->selection_request_time = tm; - R->selection_wait = Sel_normal; + selection_request_time = tm; + selection_wait = Sel_normal; for (i = Sel_Primary; i <= Sel_Clipboard; i++) { #if X_HAVE_UTF8_STRING - R->selection_type = Sel_UTF8String; - if (rxvt_selection_request_other(aR_ R->xa[XA_UTF8_STRING], i)) + selection_type = Sel_UTF8String; + if (selection_request_other (xa[XA_UTF8_STRING], i)) return; #else - R->selection_type = Sel_CompoundText; - if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) + selection_type = Sel_CompoundText; + if (selection_request_other (xa[XA_COMPOUND_TEXT], i)) return; #endif } } - R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ + selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); - rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); + selection_paste (Xroot, XA_CUT_BUFFER0, False); } -/* INTPROTO */ int -rxvt_selection_request_other(pR_ Atom target, int selnum) +rxvt_term::selection_request_other (Atom target, int selnum) { Atom sel; #ifdef DEBUG_SELECT char *debug_xa_names[] = { "PRIMARY", "SECONDARY", "CLIPBOARD" }; #endif - R->selection_type |= selnum; + selection_type |= selnum; if (selnum == Sel_Primary) sel = XA_PRIMARY; else if (selnum == Sel_Secondary) sel = XA_SECONDARY; else - sel = R->xa[XA_CLIPBOARD]; - if (XGetSelectionOwner(R->Xdisplay, sel) != None) { + sel = xa[XA_CLIPBOARD]; + if (XGetSelectionOwner(Xdisplay, sel) != None) { D_SELECT((stderr, "rxvt_selection_request_other: pasting %s", debug_xa_names[selnum])); - XConvertSelection(R->Xdisplay, sel, target, R->xa[XA_VT_SELECTION], - R->TermWin.vt, R->selection_request_time); + XConvertSelection(Xdisplay, sel, target, xa[XA_VT_SELECTION], + TermWin.vt, selection_request_time); return 1; } return 0; @@ -2675,18 +2633,17 @@ rxvt_selection_request_other(pR_ Atom target, int selnum) * Clear all selected text * EXT: SelectionClear */ -/* EXTPROTO */ void -rxvt_selection_clear(pR) +rxvt_term::selection_clear () { D_SELECT((stderr, "rxvt_selection_clear()")); - R->want_refresh = 1; - if (R->selection.text) - free(R->selection.text); - R->selection.text = NULL; - R->selection.len = 0; - CLEAR_SELECTION(R); + want_refresh = 1; + if (selection.text) + free(selection.text); + selection.text = NULL; + selection.len = 0; + CLEAR_SELECTION(); } /* ------------------------------------------------------------------------- */ @@ -2694,9 +2651,8 @@ rxvt_selection_clear(pR) * Copy a selection into the cut buffer * EXT: button 1 or 3 release */ -/* EXTPROTO */ void -rxvt_selection_make(pR_ Time tm) +rxvt_term::selection_make (Time tm) { int i, col, end_col, row, end_row; unsigned char *new_selection_text; @@ -2706,45 +2662,45 @@ rxvt_selection_make(pR_ Time tm) rend_t *re; #endif - D_SELECT((stderr, "rxvt_selection_make(): R->selection.op=%d, R->selection.clicks=%d", R->selection.op, R->selection.clicks)); - switch (R->selection.op) { + D_SELECT((stderr, "rxvt_selection_make(): selection.op=%d, selection.clicks=%d", selection.op, selection.clicks)); + switch (selection.op) { case SELECTION_CONT: break; case SELECTION_INIT: - CLEAR_SELECTION(R); + CLEAR_SELECTION(); /* FALLTHROUGH */ case SELECTION_BEGIN: - R->selection.op = SELECTION_DONE; + selection.op = SELECTION_DONE; /* FALLTHROUGH */ default: return; } - R->selection.op = SELECTION_DONE; + selection.op = SELECTION_DONE; - if (R->selection.clicks == 4) + if (selection.clicks == 4) return; /* nothing selected, go away */ - i = (R->selection.end.row - R->selection.beg.row + 1) * (R->TermWin.ncol + 1) + 1; + i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1) + 1; str = (char *)rxvt_malloc(i * MB_CUR_MAX + 1); new_selection_text = (unsigned char *)str; - col = R->selection.beg.col; + col = selection.beg.col; MAX_IT(col, 0); - row = R->selection.beg.row + R->TermWin.saveLines; - end_row = R->selection.end.row + R->TermWin.saveLines; + row = selection.beg.row + TermWin.saveLines; + end_row = selection.end.row + TermWin.saveLines; for (; row <= end_row; row++, col = 0) { - t = &(R->screen.text[row][col]); + t = &(screen.text[row][col]); - end_col = R->screen.tlen[row]; + end_col = screen.tlen[row]; if (end_col == -1) - end_col = R->TermWin.ncol; + end_col = TermWin.ncol; if (row == end_row) - MIN_IT (end_col, R->selection.end.col); + MIN_IT (end_col, selection.end.col); for (; col < end_col; col++) if (*t == NOCHAR) @@ -2756,18 +2712,18 @@ rxvt_selection_make(pR_ Time tm) str += len; } - if (R->screen.tlen[row] != -1 && row != end_row) + if (screen.tlen[row] != -1 && row != end_row) *str++ = '\n'; } #ifndef NO_OLD_SELECTION - if (R->selection_style == OLD_SELECT) - if (end_col == R->TermWin.ncol) + if (selection_style == OLD_SELECT) + if (end_col == TermWin.ncol) *str++ = '\n'; #endif #ifndef NO_NEW_SELECTION - if (R->selection_style != OLD_SELECT) - if (end_col != R->selection.end.col) + if (selection_style != OLD_SELECT) + if (end_col != selection.end.col) *str++ = '\n'; #endif *str = '\0'; @@ -2783,35 +2739,35 @@ rxvt_selection_make(pR_ Time tm) if (str - (char *)new_selection_text > 1024) new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1); - R->selection.len = i; + selection.len = i; - if (R->selection.text) - free (R->selection.text); + if (selection.text) + free (selection.text); - R->selection.text = new_selection_text; + selection.text = new_selection_text; - XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm); - if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt) + XSetSelectionOwner(Xdisplay, XA_PRIMARY, TermWin.vt, tm); + if (XGetSelectionOwner(Xdisplay, XA_PRIMARY) != TermWin.vt) rxvt_print_error("can't get primary selection"); { XTextProperty ct; - char *cl = (char *)R->selection.text; + char *cl = (char *)selection.text; - if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, XStringStyle, &ct) >= 0) + if (XmbTextListToTextProperty(Xdisplay, &cl, 1, XStringStyle, &ct) >= 0) { - XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, + XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, ct.value, ct.nitems); XFree (ct.value); } else - XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, - PropModeReplace, R->selection.text, (int)R->selection.len); + XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, + PropModeReplace, selection.text, (int)selection.len); } - R->selection_time = tm; - D_SELECT((stderr, "rxvt_selection_make(): R->selection.len=%d", R->selection.len)); + selection_time = tm; + D_SELECT((stderr, "rxvt_selection_make(): selection.len=%d", selection.len)); } /* ------------------------------------------------------------------------- */ @@ -2827,10 +2783,10 @@ rxvt_term::selection_click (int clicks, int x, int y) clicks = ((clicks - 1) % 3) + 1; selection.clicks = clicks; /* save clicks so extend will work */ - rxvt_selection_start_colrow (this, Pixel2Col(x), Pixel2Row(y)); + selection_start_colrow (Pixel2Col(x), Pixel2Row(y)); if (clicks == 2 || clicks == 3) - rxvt_selection_extend_colrow (this, selection.mark.col, + selection_extend_colrow (selection.mark.col, selection.mark.row + TermWin.view_start, 0, /* button 3 */ 1, /* button press */ @@ -2841,24 +2797,23 @@ rxvt_term::selection_click (int clicks, int x, int y) /* * Mark a selection at the specified col/row */ -/* INTPROTO */ void -rxvt_selection_start_colrow(pR_ int col, int row) +rxvt_term::selection_start_colrow (int col, int row) { - R->want_refresh = 1; - R->selection.mark.col = col; - R->selection.mark.row = row - R->TermWin.view_start; - MAX_IT(R->selection.mark.row, -(int32_t)R->TermWin.nscrolled); - MIN_IT(R->selection.mark.row, (int32_t)R->TermWin.nrow - 1); - MAX_IT(R->selection.mark.col, 0); - MIN_IT(R->selection.mark.col, (int32_t)R->TermWin.ncol - 1); + want_refresh = 1; + selection.mark.col = col; + selection.mark.row = row - TermWin.view_start; + MAX_IT(selection.mark.row, -(int32_t)TermWin.nscrolled); + MIN_IT(selection.mark.row, (int32_t)TermWin.nrow - 1); + MAX_IT(selection.mark.col, 0); + MIN_IT(selection.mark.col, (int32_t)TermWin.ncol - 1); - if (R->selection.op) { /* clear the old selection */ - R->selection.beg.row = R->selection.end.row = R->selection.mark.row; - R->selection.beg.col = R->selection.end.col = R->selection.mark.col; + if (selection.op) { /* clear the old selection */ + selection.beg.row = selection.end.row = selection.mark.row; + selection.beg.col = selection.end.col = selection.mark.col; } - R->selection.op = SELECTION_INIT; - R->selection.screen = R->current_screen; + selection.op = SELECTION_INIT; + selection.screen = current_screen; } /* ------------------------------------------------------------------------- */ @@ -2869,12 +2824,11 @@ rxvt_selection_start_colrow(pR_ int col, int row) /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ #define DELIMIT_TEXT(x) \ - (((x) == ' ' || (x) == '\t') ? 2 : (STRCHR(R->rs[Rs_cutchars], (x)) != NULL)) + (((x) == ' ' || (x) == '\t') ? 2 : (STRCHR(rs[Rs_cutchars], (x)) != NULL)) #define DELIMIT_REND(x) 1 -/* INTPROTO */ void -rxvt_selection_delimit_word(pR_ enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) +rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) { int col, row, dirnadd, tcol, trow, w1, w2; row_col_t bound; @@ -2882,22 +2836,22 @@ rxvt_selection_delimit_word(pR_ enum page_dirn dirn, const row_col_t *mark, row_ rend_t *srp; if (dirn == UP) { - bound.row = R->TermWin.saveLines - R->TermWin.nscrolled - 1; + bound.row = TermWin.saveLines - TermWin.nscrolled - 1; bound.col = 0; dirnadd = -1; } else { - bound.row = R->TermWin.saveLines + R->TermWin.nrow; - bound.col = R->TermWin.ncol - 1; + bound.row = TermWin.saveLines + TermWin.nrow; + bound.col = TermWin.ncol - 1; dirnadd = 1; } - row = mark->row + R->TermWin.saveLines; + row = mark->row + TermWin.saveLines; col = mark->col; MAX_IT(col, 0); /* find the edge of a word */ - stp = &(R->screen.text[row][col]); + stp = &(screen.text[row][col]); w1 = DELIMIT_TEXT(*stp); - if (R->selection_style != NEW_SELECT) { + if (selection_style != NEW_SELECT) { if (w1 == 1) { stp += dirnadd; if (DELIMIT_TEXT(*stp) == 1) @@ -2906,7 +2860,7 @@ rxvt_selection_delimit_word(pR_ enum page_dirn dirn, const row_col_t *mark, row_ } w1 = 0; } - srp = (&R->screen.rend[row][col]); + srp = (&screen.rend[row][col]); w2 = DELIMIT_REND(*srp); for (;;) { @@ -2919,13 +2873,13 @@ rxvt_selection_delimit_word(pR_ enum page_dirn dirn, const row_col_t *mark, row_ break; } if ((col == bound.col) && (row != bound.row)) { - if (R->screen.tlen[(row - (dirn == UP ? 1 : 0))] == -1) { + if (screen.tlen[(row - (dirn == UP ? 1 : 0))] == -1) { trow = row + dirnadd; - tcol = dirn == UP ? R->TermWin.ncol - 1 : 0; - if (R->screen.text[trow] == NULL) + tcol = dirn == UP ? TermWin.ncol - 1 : 0; + if (screen.text[trow] == NULL) break; - stp = &(R->screen.text[trow][tcol]); - srp = &(R->screen.rend[trow][tcol]); + stp = &(screen.text[trow][tcol]); + srp = &(screen.rend[trow][tcol]); if (DELIMIT_TEXT(*stp) != w1 || DELIMIT_REND(*srp) != w2) break; row = trow; @@ -2936,13 +2890,13 @@ rxvt_selection_delimit_word(pR_ enum page_dirn dirn, const row_col_t *mark, row_ break; } Old_Word_Selection_You_Die: - D_SELECT((stderr, "rxvt_selection_delimit_word(%s,...) @ (r:%3d, c:%3d) has boundary (r:%3d, c:%3d)", (dirn == UP ? "up " : "down"), mark->row, mark->col, row - R->TermWin.saveLines, col)); + D_SELECT((stderr, "rxvt_selection_delimit_word(%s,...) @ (r:%3d, c:%3d) has boundary (r:%3d, c:%3d)", (dirn == UP ? "up " : "down"), mark->row, mark->col, row - TermWin.saveLines, col)); if (dirn == DN) col++; /* put us on one past the end */ /* Poke the values back in */ - ret->row = row - R->TermWin.saveLines; + ret->row = row - TermWin.saveLines; ret->col = col; } @@ -2992,7 +2946,7 @@ rxvt_term::selection_extend (int x, int y, int flag) if (selection.clicks == 4) selection.clicks = 1; - rxvt_selection_extend_colrow (this, col, row, !!flag, /* ? button 3 */ + selection_extend_colrow (col, row, !!flag, /* ? button 3 */ flag == 1 ? 1 : 0, /* ? button press */ 0); /* no click change */ } @@ -3001,55 +2955,54 @@ rxvt_term::selection_extend (int x, int y, int flag) /* * Extend the selection to the specified col/row */ -/* INTPROTO */ void -rxvt_selection_extend_colrow(pR_ int32_t col, int32_t row, int button3, int buttonpress, int clickchange) +rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) { - int16_t ncol = R->TermWin.ncol; + int16_t ncol = TermWin.ncol; int end_col; row_col_t pos; enum { LEFT, RIGHT } closeto = RIGHT; - D_SELECT((stderr, "rxvt_selection_extend_colrow(c:%d, r:%d, %d, %d) clicks:%d, op:%d", col, row, button3, buttonpress, R->selection.clicks, R->selection.op)); - D_SELECT((stderr, "rxvt_selection_extend_colrow() ENT b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", R->selection.beg.row, R->selection.beg.col, R->selection.mark.row, R->selection.mark.col, R->selection.end.row, R->selection.end.col)); + D_SELECT((stderr, "rxvt_selection_extend_colrow(c:%d, r:%d, %d, %d) clicks:%d, op:%d", col, row, button3, buttonpress, selection.clicks, selection.op)); + D_SELECT((stderr, "rxvt_selection_extend_colrow() ENT b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col)); - R->want_refresh = 1; - switch (R->selection.op) { + want_refresh = 1; + switch (selection.op) { case SELECTION_INIT: - CLEAR_SELECTION(R); - R->selection.op = SELECTION_BEGIN; + CLEAR_SELECTION(); + selection.op = SELECTION_BEGIN; /* FALLTHROUGH */ case SELECTION_BEGIN: - if (row != R->selection.mark.row || col != R->selection.mark.col + if (row != selection.mark.row || col != selection.mark.col || (!button3 && buttonpress)) - R->selection.op = SELECTION_CONT; + selection.op = SELECTION_CONT; break; case SELECTION_DONE: - R->selection.op = SELECTION_CONT; + selection.op = SELECTION_CONT; /* FALLTHROUGH */ case SELECTION_CONT: break; case SELECTION_CLEAR: - rxvt_selection_start_colrow(aR_ col, row); + selection_start_colrow (col, row); /* FALLTHROUGH */ default: return; } - if (R->selection.beg.col == R->selection.end.col - && R->selection.beg.col != R->selection.mark.col - && R->selection.beg.row == R->selection.end.row - && R->selection.beg.row != R->selection.mark.row) { - R->selection.beg.col = R->selection.end.col = R->selection.mark.col; - R->selection.beg.row = R->selection.end.row = R->selection.mark.row; - D_SELECT((stderr, "rxvt_selection_extend_colrow() ENT2 b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", R->selection.beg.row, R->selection.beg.col, R->selection.mark.row, R->selection.mark.col, R->selection.end.row, R->selection.end.col)); + if (selection.beg.col == selection.end.col + && selection.beg.col != selection.mark.col + && selection.beg.row == selection.end.row + && selection.beg.row != selection.mark.row) { + selection.beg.col = selection.end.col = selection.mark.col; + selection.beg.row = selection.end.row = selection.mark.row; + D_SELECT((stderr, "rxvt_selection_extend_colrow() ENT2 b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col)); } pos.col = col; pos.row = row; - pos.row -= R->TermWin.view_start; /* adjust for scroll */ + pos.row -= TermWin.view_start; /* adjust for scroll */ #ifndef NO_OLD_SELECTION /* @@ -3058,42 +3011,42 @@ rxvt_selection_extend_colrow(pR_ int32_t col, int32_t row, int button3, int butt * Note: button3 drag is always available, c.f. v2.20 * Selection always terminates (left or right as appropriate) at the mark. */ - if (R->selection_style == OLD_SELECT) { - if (R->selection.clicks == 1 || button3) { - if (R->hate_those_clicks) { - R->hate_those_clicks = 0; - if (R->selection.clicks == 1) { - R->selection.beg.row = R->selection.mark.row; - R->selection.beg.col = R->selection.mark.col; + if (selection_style == OLD_SELECT) { + if (selection.clicks == 1 || button3) { + if (hate_those_clicks) { + hate_those_clicks = 0; + if (selection.clicks == 1) { + selection.beg.row = selection.mark.row; + selection.beg.col = selection.mark.col; } else { - R->selection.mark.row = R->selection.beg.row; - R->selection.mark.col = R->selection.beg.col; + selection.mark.row = selection.beg.row; + selection.mark.col = selection.beg.col; } } - if (ROWCOL_IS_BEFORE(pos, R->selection.mark)) { - R->selection.end.row = R->selection.mark.row; - R->selection.end.col = R->selection.mark.col + 1; - R->selection.beg.row = pos.row; - R->selection.beg.col = pos.col; + if (ROWCOL_IS_BEFORE(pos, selection.mark)) { + selection.end.row = selection.mark.row; + selection.end.col = selection.mark.col + 1; + selection.beg.row = pos.row; + selection.beg.col = pos.col; } else { - R->selection.beg.row = R->selection.mark.row; - R->selection.beg.col = R->selection.mark.col; - R->selection.end.row = pos.row; - R->selection.end.col = pos.col + 1; + selection.beg.row = selection.mark.row; + selection.beg.col = selection.mark.col; + selection.end.row = pos.row; + selection.end.col = pos.col + 1; } - } else if (R->selection.clicks == 2) { - rxvt_selection_delimit_word(aR_ UP, &(R->selection.mark), - &(R->selection.beg)); - rxvt_selection_delimit_word(aR_ DN, &(R->selection.mark), - &(R->selection.end)); - R->hate_those_clicks = 1; - } else if (R->selection.clicks == 3) { - R->selection.beg.row = R->selection.end.row = R->selection.mark.row; - R->selection.beg.col = 0; - R->selection.end.col = ncol; - R->hate_those_clicks = 1; + } else if (selection.clicks == 2) { + selection_delimit_word (UP, &(selection.mark), + &(selection.beg)); + selection_delimit_word (DN, &(selection.mark), + &(selection.end)); + hate_those_clicks = 1; + } else if (selection.clicks == 3) { + selection.beg.row = selection.end.row = selection.mark.row; + selection.beg.col = 0; + selection.end.col = ncol; + hate_those_clicks = 1; } - D_SELECT((stderr, "rxvt_selection_extend_colrow() EXIT b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", R->selection.beg.row, R->selection.beg.col, R->selection.mark.row, R->selection.mark.col, R->selection.end.row, R->selection.end.col)); + D_SELECT((stderr, "rxvt_selection_extend_colrow() EXIT b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col)); return; } #endif /* ! NO_OLD_SELECTION */ @@ -3104,7 +3057,7 @@ rxvt_selection_extend_colrow(pR_ int32_t col, int32_t row, int button3, int butt * in the way button3 drag extension works. * We're either doing: button1 drag; button3 press; or button3 drag * a) button1 drag : select around a midpoint/word/line - that point/word/line - * is always at the left/right edge of the R->selection. + * is always at the left/right edge of the selection. * b) button3 press: extend/contract character/word/line at whichever edge of * the selection we are closest to. * c) button3 drag : extend/contract character/word/line - we select around @@ -3116,140 +3069,139 @@ rxvt_selection_extend_colrow(pR_ int32_t col, int32_t row, int button3, int butt /* * first determine which edge of the selection we are closest to */ - if (ROWCOL_IS_BEFORE(pos, R->selection.beg) - || (!ROWCOL_IS_AFTER(pos, R->selection.end) - && (((pos.col - R->selection.beg.col) - + ((pos.row - R->selection.beg.row) * ncol)) - < ((R->selection.end.col - pos.col) - + ((R->selection.end.row - pos.row) * ncol))))) + if (ROWCOL_IS_BEFORE(pos, selection.beg) + || (!ROWCOL_IS_AFTER(pos, selection.end) + && (((pos.col - selection.beg.col) + + ((pos.row - selection.beg.row) * ncol)) + < ((selection.end.col - pos.col) + + ((selection.end.row - pos.row) * ncol))))) closeto = LEFT; if (closeto == LEFT) { - R->selection.beg.row = pos.row; - R->selection.beg.col = pos.col; - R->selection.mark.row = R->selection.end.row; - R->selection.mark.col = R->selection.end.col - - (R->selection.clicks == 2); + selection.beg.row = pos.row; + selection.beg.col = pos.col; + selection.mark.row = selection.end.row; + selection.mark.col = selection.end.col + - (selection.clicks == 2); } else { - R->selection.end.row = pos.row; - R->selection.end.col = pos.col; - R->selection.mark.row = R->selection.beg.row; - R->selection.mark.col = R->selection.beg.col; + selection.end.row = pos.row; + selection.end.col = pos.col; + selection.mark.row = selection.beg.row; + selection.mark.col = selection.beg.col; } } else { /* button1 drag or button3 drag */ - if (ROWCOL_IS_AFTER(R->selection.mark, pos)) { - if ((R->selection.mark.row == R->selection.end.row) - && (R->selection.mark.col == R->selection.end.col) - && clickchange && R->selection.clicks == 2) - R->selection.mark.col--; - R->selection.beg.row = pos.row; - R->selection.beg.col = pos.col; - R->selection.end.row = R->selection.mark.row; - R->selection.end.col = R->selection.mark.col - + (R->selection.clicks == 2); + if (ROWCOL_IS_AFTER(selection.mark, pos)) { + if ((selection.mark.row == selection.end.row) + && (selection.mark.col == selection.end.col) + && clickchange && selection.clicks == 2) + selection.mark.col--; + selection.beg.row = pos.row; + selection.beg.col = pos.col; + selection.end.row = selection.mark.row; + selection.end.col = selection.mark.col + + (selection.clicks == 2); } else { - R->selection.beg.row = R->selection.mark.row; - R->selection.beg.col = R->selection.mark.col; - R->selection.end.row = pos.row; - R->selection.end.col = pos.col; + selection.beg.row = selection.mark.row; + selection.beg.col = selection.mark.col; + selection.end.row = pos.row; + selection.end.col = pos.col; } } - if (R->selection.clicks == 1) { - end_col = R->screen.tlen[R->selection.beg.row + R->TermWin.saveLines]; - if (end_col != -1 && R->selection.beg.col > end_col) { + if (selection.clicks == 1) { + end_col = screen.tlen[selection.beg.row + TermWin.saveLines]; + if (end_col != -1 && selection.beg.col > end_col) { #if 1 - R->selection.beg.col = ncol; + selection.beg.col = ncol; #else - if (R->selection.beg.row != R->selection.end.row) - R->selection.beg.col = ncol; + if (selection.beg.row != selection.end.row) + selection.beg.col = ncol; else - R->selection.beg.col = R->selection.mark.col; + selection.beg.col = selection.mark.col; #endif } - end_col = R->screen.tlen[R->selection.end.row + R->TermWin.saveLines]; - if (end_col != -1 && R->selection.end.col > end_col) - R->selection.end.col = ncol; - - } else if (R->selection.clicks == 2) { - if (ROWCOL_IS_AFTER(R->selection.end, R->selection.beg)) - R->selection.end.col--; - rxvt_selection_delimit_word(aR_ UP, &(R->selection.beg), - &(R->selection.beg)); - rxvt_selection_delimit_word(aR_ DN, &(R->selection.end), - &(R->selection.end)); - } else if (R->selection.clicks == 3) { + end_col = screen.tlen[selection.end.row + TermWin.saveLines]; + if (end_col != -1 && selection.end.col > end_col) + selection.end.col = ncol; + + } else if (selection.clicks == 2) { + if (ROWCOL_IS_AFTER(selection.end, selection.beg)) + selection.end.col--; + selection_delimit_word (UP, &(selection.beg), + &(selection.beg)); + selection_delimit_word (DN, &(selection.end), + &(selection.end)); + } else if (selection.clicks == 3) { #ifndef NO_FRILLS - if ((R->Options & Opt_tripleclickwords)) { + if ((Options & Opt_tripleclickwords)) { int end_row; - rxvt_selection_delimit_word(aR_ UP, &(R->selection.beg), - &(R->selection.beg)); - end_row = R->screen.tlen[R->selection.mark.row - + R->TermWin.saveLines]; - for (end_row = R->selection.mark.row; end_row < R->TermWin.nrow; + selection_delimit_word (UP, &(selection.beg), + &(selection.beg)); + end_row = screen.tlen[selection.mark.row + + TermWin.saveLines]; + for (end_row = selection.mark.row; end_row < TermWin.nrow; end_row++) { - end_col = R->screen.tlen[end_row + R->TermWin.saveLines]; + end_col = screen.tlen[end_row + TermWin.saveLines]; if (end_col != -1) { - R->selection.end.row = end_row; - R->selection.end.col = end_col; - rxvt_selection_remove_trailing_spaces(aR); + selection.end.row = end_row; + selection.end.col = end_col; + selection_remove_trailing_spaces (); break; } } } else #endif { - if (ROWCOL_IS_AFTER(R->selection.mark, R->selection.beg)) - R->selection.mark.col++; - R->selection.beg.col = 0; - R->selection.end.col = ncol; + if (ROWCOL_IS_AFTER(selection.mark, selection.beg)) + selection.mark.col++; + selection.beg.col = 0; + selection.end.col = ncol; } } if (button3 && buttonpress) { /* mark may need to be changed */ if (closeto == LEFT) { - R->selection.mark.row = R->selection.end.row; - R->selection.mark.col = R->selection.end.col - - (R->selection.clicks == 2); + selection.mark.row = selection.end.row; + selection.mark.col = selection.end.col + - (selection.clicks == 2); } else { - R->selection.mark.row = R->selection.beg.row; - R->selection.mark.col = R->selection.beg.col; + selection.mark.row = selection.beg.row; + selection.mark.col = selection.beg.col; } } - D_SELECT((stderr, "rxvt_selection_extend_colrow() EXIT b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", R->selection.beg.row, R->selection.beg.col, R->selection.mark.row, R->selection.mark.col, R->selection.end.row, R->selection.end.col)); + D_SELECT((stderr, "rxvt_selection_extend_colrow() EXIT b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col)); #endif /* ! NO_NEW_SELECTION */ } #ifndef NO_FRILLS -/* INTPROTO */ void -rxvt_selection_remove_trailing_spaces(pR) +rxvt_term::selection_remove_trailing_spaces () { int32_t end_col, end_row; text_t *stp; - end_col = R->selection.end.col; - end_row = R->selection.end.row; - for ( ; end_row >= R->selection.beg.row; ) { - stp = R->screen.text[end_row + R->TermWin.saveLines]; + end_col = selection.end.col; + end_row = selection.end.row; + for ( ; end_row >= selection.beg.row; ) { + stp = screen.text[end_row + TermWin.saveLines]; while (--end_col >= 0) { if (stp[end_col] != ' ' && stp[end_col] != '\t') break; } if (end_col >= 0 - || R->screen.tlen[end_row - 1 + R->TermWin.saveLines] != -1) { - R->selection.end.col = end_col + 1; - R->selection.end.row = end_row; + || screen.tlen[end_row - 1 + TermWin.saveLines] != -1) { + selection.end.col = end_col + 1; + selection.end.row = end_row; break; } end_row--; - end_col = R->TermWin.ncol; + end_col = TermWin.ncol; } - if (R->selection.mark.row > R->selection.end.row) { - R->selection.mark.row = R->selection.end.row; - R->selection.mark.col = R->selection.end.col; - } else if (R->selection.mark.row == R->selection.end.row - && R->selection.mark.col > R->selection.end.col) - R->selection.mark.col = R->selection.end.col; + if (selection.mark.row > selection.end.row) { + selection.mark.row = selection.end.row; + selection.mark.col = selection.end.col; + } else if (selection.mark.row == selection.end.row + && selection.mark.col > selection.end.col) + selection.mark.col = selection.end.col; } #endif @@ -3262,7 +3214,7 @@ void rxvt_term::selection_rotate (int x, int y) { selection.clicks = selection.clicks % 3 + 1; - rxvt_selection_extend_colrow (this, Pixel2Col(x), Pixel2Row(y), 1, 0, 1); + selection_extend_colrow (Pixel2Col(x), Pixel2Row(y), 1, 0, 1); } /* ------------------------------------------------------------------------- */ @@ -3278,9 +3230,8 @@ typedef CARD32 Atom32; * Respond to a request for our current selection * EXT: SelectionRequest */ -/* EXTPROTO */ void -rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) +rxvt_term::selection_send (const XSelectionRequestEvent *rq) { XSelectionEvent ev; XTextProperty ct; @@ -3295,33 +3246,33 @@ rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) ev.target = rq->target; ev.time = rq->time; - if (rq->target == R->xa[XA_TARGETS]) { + if (rq->target == xa[XA_TARGETS]) { Atom32 target_list[5]; Atom32 *target = target_list; - *target++ = (Atom32) R->xa[XA_TARGETS]; + *target++ = (Atom32) xa[XA_TARGETS]; *target++ = (Atom32) XA_STRING; - *target++ = (Atom32) R->xa[XA_TEXT]; - *target++ = (Atom32) R->xa[XA_COMPOUND_TEXT]; + *target++ = (Atom32) xa[XA_TEXT]; + *target++ = (Atom32) xa[XA_COMPOUND_TEXT]; #if X_HAVE_UTF8_STRING - *target++ = (Atom32) R->xa[XA_UTF8_STRING]; + *target++ = (Atom32) xa[XA_UTF8_STRING]; #endif - XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, + XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_ATOM, (8 * sizeof(target_list[0])), PropModeReplace, (unsigned char *)target_list, target - target_list); ev.property = rq->property; - } else if (rq->target == R->xa[XA_MULTIPLE]) { + } else if (rq->target == xa[XA_MULTIPLE]) { /* TODO: Handle MULTIPLE */ - } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { - XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, + } else if (rq->target == xa[XA_TIMESTAMP] && selection.text) { + XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_INTEGER, (8 * sizeof(Time)), PropModeReplace, - (unsigned char *)&R->selection_time, 1); + (unsigned char *)&selection_time, 1); ev.property = rq->property; } else if (rq->target == XA_STRING - || rq->target == R->xa[XA_TEXT] - || rq->target == R->xa[XA_COMPOUND_TEXT] - || rq->target == R->xa[XA_UTF8_STRING] + || rq->target == xa[XA_TEXT] + || rq->target == xa[XA_COMPOUND_TEXT] + || rq->target == xa[XA_UTF8_STRING] ) { short freect = 0; int selectlen; @@ -3333,29 +3284,29 @@ rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) // we actually don't do XA_STRING, but who cares, as i18n clients // will ask for another format anyways. style = XStringStyle; - else if (target == R->xa[XA_TEXT]) + else if (target == xa[XA_TEXT]) style = XTextStyle; - else if (target == R->xa[XA_COMPOUND_TEXT]) + else if (target == xa[XA_COMPOUND_TEXT]) style = XCompoundTextStyle; #if X_HAVE_UTF8_STRING - else if (target == R->xa[XA_UTF8_STRING]) + else if (target == xa[XA_UTF8_STRING]) style = XUTF8StringStyle; #endif else { - target = R->xa[XA_COMPOUND_TEXT]; + target = xa[XA_COMPOUND_TEXT]; style = XCompoundTextStyle; } - if (R->selection.text) { - cl = (char *)R->selection.text; - selectlen = R->selection.len; + if (selection.text) { + cl = (char *)selection.text; + selectlen = selection.len; } else { cl = ""; selectlen = 0; } - if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, style, &ct) >= 0) + if (XmbTextListToTextProperty(Xdisplay, &cl, 1, style, &ct) >= 0) freect = 1; else { @@ -3364,7 +3315,7 @@ rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) ct.nitems = selectlen; } - XChangeProperty(R->Xdisplay, rq->requestor, rq->property, + XChangeProperty(Xdisplay, rq->requestor, rq->property, target, 8, PropModeReplace, ct.value, (int)ct.nitems); ev.property = rq->property; @@ -3372,7 +3323,7 @@ rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) if (freect) XFree (ct.value); } - XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); + XSendEvent(Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); } /* ------------------------------------------------------------------------- * @@ -3386,9 +3337,9 @@ void rxvt_term::pixel_position (int *x, int *y) { *x = Pixel2Col(*x); - /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ + /* MAX_IT(*x, 0); MIN_IT(*x, (int)TermWin.ncol - 1); */ *y = Pixel2Row(*y); - /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ + /* MAX_IT(*y, 0); MIN_IT(*y, (int)TermWin.nrow - 1); */ } /* ------------------------------------------------------------------------- */ @@ -3410,7 +3361,6 @@ rxvt_term::set_position (XPoint *pos) * DEBUG ROUTINES * * ------------------------------------------------------------------------- */ #if 0 -/* INTPROTO */ void rxvt_debug_colors(void) { @@ -3421,17 +3371,17 @@ rxvt_debug_colors(void) }; fprintf(stderr, "Color ( "); - if (R->rstyle & RS_RVid) + if (rstyle & RS_RVid) fprintf(stderr, "rvid "); - if (R->rstyle & RS_Bold) + if (rstyle & RS_Bold) fprintf(stderr, "bold "); - if (R->rstyle & RS_Blink) + if (rstyle & RS_Blink) fprintf(stderr, "blink "); - if (R->rstyle & RS_Uline) + if (rstyle & RS_Uline) fprintf(stderr, "uline "); fprintf(stderr, "): "); - color = GET_FGCOLOR(R->rstyle); + color = GET_FGCOLOR(rstyle); #ifndef NO_BRIGHTCOLOR if (color >= minBrightCOLOR && color <= maxBrightCOLOR) { color -= (minBrightCOLOR - minCOLOR); @@ -3440,7 +3390,7 @@ rxvt_debug_colors(void) #endif fprintf(stderr, "%s on ", name[color]); - color = GET_BGCOLOR(R->rstyle); + color = GET_BGCOLOR(rstyle); #ifndef NO_BRIGHTCOLOR if (color >= minBrightCOLOR && color <= maxBrightCOLOR) { color -= (minBrightCOLOR - minCOLOR); diff --git a/src/scrollbar-next.C b/src/scrollbar-next.C index 851aaed6..d112299d 100644 --- a/src/scrollbar-next.C +++ b/src/scrollbar-next.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: scrollbar-next.c *----------------------------------------------------------------------* - * $Id: scrollbar-next.C,v 1.4 2003-12-18 02:07:12 pcg Exp $ + * $Id: scrollbar-next.C,v 1.5 2004-01-31 00:20:21 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1998 Alfredo K. Kojima @@ -111,36 +111,34 @@ const char *const HI_SCROLLER_ARROW_DOWN[] = { " " }; -/* INTPROTO */ Pixmap -rxvt_renderPixmap(pR_ const char *const *data, int width, int height) +rxvt_term::renderPixmap (const char *const *data, int width, int height) { char a; int x, y; Pixmap d; GC pointcolour; - d = XCreatePixmap(R->Xdisplay, R->scrollBar.win, width, height, XDEPTH); + d = XCreatePixmap(Xdisplay, scrollBar.win, width, height, XDEPTH); for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if ((a = data[y][x]) == ' ' || a == 'w') - pointcolour = R->whiteGC; + pointcolour = whiteGC; else if (a == '.' || a == 'l') - pointcolour = R->grayGC; + pointcolour = grayGC; else if (a == '%' || a == 'd') - pointcolour = R->darkGC; + pointcolour = darkGC; else /* if (a == '#' || a == 'b' || a) */ - pointcolour = R->blackGC; - XDrawPoint(R->Xdisplay, d, pointcolour, x, y); + pointcolour = blackGC; + XDrawPoint(Xdisplay, d, pointcolour, x, y); } } return d; } -/* INTPROTO */ void -rxvt_init_scrollbar_stuff(pR) +rxvt_term::init_scrollbar_stuff () { XGCValues gcvalue; XColor xcol; @@ -149,33 +147,33 @@ rxvt_init_scrollbar_stuff(pR) gcvalue.graphics_exposures = False; - gcvalue.foreground = R->PixColors[Color_Black]; - R->blackGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + gcvalue.foreground = PixColors[Color_Black]; + blackGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); - gcvalue.foreground = R->PixColors[Color_White]; - R->whiteGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + gcvalue.foreground = PixColors[Color_White]; + whiteGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); xcol.red = 0xaeba; xcol.green = 0xaaaa; xcol.blue = 0xaeba; - //if (!rxvt_rXAllocColor(aR_ &xcol, "light gray"))//TODO//D// - xcol.pixel = R->PixColors[Color_AntiqueWhite]; + //if (!rXAllocColor (&xcol, "light gray"))//TODO//D// + xcol.pixel = PixColors[Color_AntiqueWhite]; light = gcvalue.foreground = xcol.pixel; - R->grayGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + grayGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); xcol.red = 0x51aa; xcol.green = 0x5555; xcol.blue = 0x5144; - //if (!rxvt_rXAllocColor(aR_ &xcol, "dark gray"))//TODO//D// - xcol.pixel = R->PixColors[Color_Grey25]; + //if (!rXAllocColor (&xcol, "dark gray"))//TODO//D// + xcol.pixel = PixColors[Color_Grey25]; dark = gcvalue.foreground = xcol.pixel; - R->darkGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + darkGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); - stipple = XCreateBitmapFromData(R->Xdisplay, R->scrollBar.win, + stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win, (char *)n_stp_bits, n_stp_width, n_stp_height); @@ -184,102 +182,100 @@ rxvt_init_scrollbar_stuff(pR) gcvalue.fill_style = FillOpaqueStippled; gcvalue.stipple = stipple; -/* XSetWindowBackground(R->Xdisplay, R->scrollBar.win, R->PixColors[Color_Red]); */ +/* XSetWindowBackground(Xdisplay, scrollBar.win, PixColors[Color_Red]); */ - R->stippleGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + stippleGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground | GCBackground | GCStipple | GCFillStyle | GCGraphicsExposures, &gcvalue); - R->dimple = rxvt_renderPixmap(aR_ SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH, + dimple = renderPixmap (SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT); - R->upArrow = rxvt_renderPixmap(aR_ SCROLLER_ARROW_UP, ARROW_WIDTH, + upArrow = renderPixmap (SCROLLER_ARROW_UP, ARROW_WIDTH, ARROW_HEIGHT); - R->downArrow = rxvt_renderPixmap(aR_ SCROLLER_ARROW_DOWN, ARROW_WIDTH, + downArrow = renderPixmap (SCROLLER_ARROW_DOWN, ARROW_WIDTH, ARROW_HEIGHT); - R->upArrowHi = rxvt_renderPixmap(aR_ HI_SCROLLER_ARROW_UP, ARROW_WIDTH, + upArrowHi = renderPixmap (HI_SCROLLER_ARROW_UP, ARROW_WIDTH, ARROW_HEIGHT); - R->downArrowHi = rxvt_renderPixmap(aR_ HI_SCROLLER_ARROW_DOWN, + downArrowHi = renderPixmap (HI_SCROLLER_ARROW_DOWN, ARROW_WIDTH, ARROW_HEIGHT); } /* Draw bevel & arrows */ -/* INTPROTO */ void -rxvt_drawBevel(pR_ Drawable d, int x1, int y1, int w, int h) +rxvt_term::drawBevel (Drawable d, int x1, int y1, int w, int h) { int x2, y2; x2 = x1 + w - 1; /* right point */ y2 = y1 + h - 1; /* bottom point */ /* white top and left */ - XDrawLine(R->Xdisplay, d, R->whiteGC, x1, y1, x2, y1); - XDrawLine(R->Xdisplay, d, R->whiteGC, x1, y1, x1, y2); + XDrawLine(Xdisplay, d, whiteGC, x1, y1, x2, y1); + XDrawLine(Xdisplay, d, whiteGC, x1, y1, x1, y2); /* black bottom and right */ - XDrawLine(R->Xdisplay, d, R->blackGC, x1, y2, x2, y2); - XDrawLine(R->Xdisplay, d, R->blackGC, x2, y1, x2, y2); + XDrawLine(Xdisplay, d, blackGC, x1, y2, x2, y2); + XDrawLine(Xdisplay, d, blackGC, x2, y1, x2, y2); /* dark inside bottom and right */ x1++, y1++, x2--, y2--; /* move in one point */ - XDrawLine(R->Xdisplay, d, R->darkGC, x1, y2, x2, y2); - XDrawLine(R->Xdisplay, d, R->darkGC, x2, y1, x2, y2); + XDrawLine(Xdisplay, d, darkGC, x1, y2, x2, y2); + XDrawLine(Xdisplay, d, darkGC, x2, y1, x2, y2); } -/* EXTPROTO */ int -rxvt_scrollbar_show_next(pR_ int update, int last_top, int last_bot, int scrollbar_len) +rxvt_term::scrollbar_show_next (int update, int last_top, int last_bot, int scrollbar_len) { - int height = R->scrollBar.end + SB_BUTTON_TOTAL_HEIGHT + SB_PADDING; + int height = scrollBar.end + SB_BUTTON_TOTAL_HEIGHT + SB_PADDING; Drawable s; - if ((R->scrollBar.init & R_SB_NEXT) == 0) { - R->scrollBar.init |= R_SB_NEXT; - rxvt_init_scrollbar_stuff(aR); + if ((scrollBar.init & R_SB_NEXT) == 0) { + scrollBar.init |= R_SB_NEXT; + init_scrollbar_stuff (); } - if (R->TermWin.nscrolled == 0 || !update) { - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->grayGC, 0, 0, + if (TermWin.nscrolled == 0 || !update) { + XFillRectangle(Xdisplay, scrollBar.win, grayGC, 0, 0, SB_WIDTH_NEXT + 1, height); - XDrawRectangle(R->Xdisplay, R->scrollBar.win, R->blackGC, 0, + XDrawRectangle(Xdisplay, scrollBar.win, blackGC, 0, -SB_BORDER_WIDTH, SB_WIDTH_NEXT, height + SB_BORDER_WIDTH); - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->stippleGC, + XFillRectangle(Xdisplay, scrollBar.win, stippleGC, SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height); } - if (R->TermWin.nscrolled) { - if (last_top < R->scrollBar.top || !update) - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->stippleGC, + if (TermWin.nscrolled) { + if (last_top < scrollBar.top || !update) + XFillRectangle(Xdisplay, scrollBar.win, stippleGC, SB_LEFT_PADDING, SB_PADDING + last_top, - SB_BUTTON_WIDTH, R->scrollBar.top - last_top); - if (R->scrollBar.bot < last_bot || !update) - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->stippleGC, - SB_LEFT_PADDING, R->scrollBar.bot + SB_PADDING, - SB_BUTTON_WIDTH, (last_bot - R->scrollBar.bot)); - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->grayGC, - SB_LEFT_PADDING, R->scrollBar.top + SB_PADDING, + SB_BUTTON_WIDTH, scrollBar.top - last_top); + if (scrollBar.bot < last_bot || !update) + XFillRectangle(Xdisplay, scrollBar.win, stippleGC, + SB_LEFT_PADDING, scrollBar.bot + SB_PADDING, + SB_BUTTON_WIDTH, (last_bot - scrollBar.bot)); + XFillRectangle(Xdisplay, scrollBar.win, grayGC, + SB_LEFT_PADDING, scrollBar.top + SB_PADDING, SB_BUTTON_WIDTH, scrollbar_len); - XCopyArea(R->Xdisplay, R->dimple, R->scrollBar.win, R->whiteGC, 0, 0, + XCopyArea(Xdisplay, dimple, scrollBar.win, whiteGC, 0, 0, SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT, (SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2, - R->scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT + + scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT + (scrollbar_len - SCROLLER_DIMPLE_HEIGHT) / 2); - rxvt_drawBevel(aR_ R->scrollBar.win, SB_BUTTON_BEVEL_X, - R->scrollBar.top + SB_PADDING, SB_BUTTON_WIDTH, + drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X, + scrollBar.top + SB_PADDING, SB_BUTTON_WIDTH, scrollbar_len); - rxvt_drawBevel(aR_ R->scrollBar.win, SB_BUTTON_BEVEL_X, + drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X, height - SB_BUTTON_BOTH_HEIGHT, SB_BUTTON_WIDTH, SB_BUTTON_HEIGHT); - rxvt_drawBevel(aR_ R->scrollBar.win, SB_BUTTON_BEVEL_X, + drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X, height - SB_BUTTON_SINGLE_HEIGHT, SB_BUTTON_WIDTH, SB_BUTTON_HEIGHT); - s = (scrollbar_isUp()) ? R->upArrowHi : R->upArrow; - XCopyArea(R->Xdisplay, s, R->scrollBar.win, R->whiteGC, 0, 0, + s = (scrollbar_isUp()) ? upArrowHi : upArrow; + XCopyArea(Xdisplay, s, scrollBar.win, whiteGC, 0, 0, ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X, height - SB_BUTTON_BOTH_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT); - s = (scrollbar_isDn()) ? R->downArrowHi : R->downArrow; - XCopyArea(R->Xdisplay, s, R->scrollBar.win, R->whiteGC, 0, 0, + s = (scrollbar_isDn()) ? downArrowHi : downArrow; + XCopyArea(Xdisplay, s, scrollBar.win, whiteGC, 0, 0, ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X, height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT); } diff --git a/src/scrollbar-rxvt.C b/src/scrollbar-rxvt.C index 88bc9ac5..197f2dd4 100644 --- a/src/scrollbar-rxvt.C +++ b/src/scrollbar-rxvt.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: scrollbar-rxvt.c *----------------------------------------------------------------------* - * $Id: scrollbar-rxvt.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ + * $Id: scrollbar-rxvt.C,v 1.4 2004-01-31 00:20:21 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1999-2001 Geoff Wing @@ -29,27 +29,26 @@ #if defined(RXVT_SCROLLBAR) /* draw triangular button with a shadow of SHADOW (1 or 2) pixels */ -/* INTPROTO */ void -rxvt_Draw_button(pR_ int x, int y, int state, int dirn) +rxvt_term::Draw_button (int x, int y, int state, int dirn) { unsigned int sz, sz2; XPoint pt[3]; GC top, bot; - sz = R->scrollBar.width; + sz = scrollBar.width; sz2 = sz / 2; switch (state) { case +1: - top = R->topShadowGC; - bot = R->botShadowGC; + top = topShadowGC; + bot = botShadowGC; break; case -1: - top = R->botShadowGC; - bot = R->topShadowGC; + top = botShadowGC; + bot = topShadowGC; break; default: - top = bot = R->scrollbarGC; + top = bot = scrollbarGC; break; } @@ -64,17 +63,17 @@ rxvt_Draw_button(pR_ int x, int y, int state, int dirn) pt[0].y = pt[1].y = y; pt[2].y = y + sz - 1; } - XFillPolygon(R->Xdisplay, R->scrollBar.win, R->scrollbarGC, + XFillPolygon(Xdisplay, scrollBar.win, scrollbarGC, pt, 3, Convex, CoordModeOrigin); /* draw base */ - XDrawLine(R->Xdisplay, R->scrollBar.win, (dirn == UP ? bot : top), + XDrawLine(Xdisplay, scrollBar.win, (dirn == UP ? bot : top), pt[0].x, pt[0].y, pt[1].x, pt[1].y); /* draw shadow on left */ pt[1].x = x + sz2 - 1; pt[1].y = y + (dirn == UP ? 0 : sz - 1); - XDrawLine(R->Xdisplay, R->scrollBar.win, top, + XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); #if (SHADOW > 1) @@ -87,7 +86,7 @@ rxvt_Draw_button(pR_ int x, int y, int state, int dirn) pt[0].y++; pt[1].y--; } - XDrawLine(R->Xdisplay, R->scrollBar.win, top, + XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); #endif /* draw shadow on right */ @@ -95,7 +94,7 @@ rxvt_Draw_button(pR_ int x, int y, int state, int dirn) /* pt[2].x = x + sz2; */ pt[1].y = y + (dirn == UP ? sz - 1 : 0); pt[2].y = y + (dirn == UP ? 0 : sz - 1); - XDrawLine(R->Xdisplay, R->scrollBar.win, bot, + XDrawLine(Xdisplay, scrollBar.win, bot, pt[2].x, pt[2].y, pt[1].x, pt[1].y); #if (SHADOW > 1) /* doubled */ @@ -107,40 +106,39 @@ rxvt_Draw_button(pR_ int x, int y, int state, int dirn) pt[2].y--; pt[1].y++; } - XDrawLine(R->Xdisplay, R->scrollBar.win, bot, + XDrawLine(Xdisplay, scrollBar.win, bot, pt[2].x, pt[2].y, pt[1].x, pt[1].y); #endif } -/* EXTPROTO */ int -rxvt_scrollbar_show_rxvt(pR_ int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len) +rxvt_term::scrollbar_show_rxvt (int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len) { - int sbshadow = R->sb_shadow; - int sbwidth = (int)R->scrollBar.width; + int sbshadow = sb_shadow; + int sbwidth = (int)scrollBar.width; - if ((R->scrollBar.init & R_SB_RXVT) == 0) { + if ((scrollBar.init & R_SB_RXVT) == 0) { XGCValues gcvalue; - R->scrollBar.init |= R_SB_RXVT; - gcvalue.foreground = R->PixColors[Color_trough]; + scrollBar.init |= R_SB_RXVT; + gcvalue.foreground = PixColors[Color_trough]; if (sbshadow) { - XSetWindowBackground(R->Xdisplay, R->scrollBar.win, + XSetWindowBackground(Xdisplay, scrollBar.win, gcvalue.foreground); - XClearWindow(R->Xdisplay, R->scrollBar.win); + XClearWindow(Xdisplay, scrollBar.win); } } else { -/* instead of XClearWindow (R->Xdisplay, R->scrollBar.win); */ - if (last_top < R->scrollBar.top) - XClearArea(R->Xdisplay, R->scrollBar.win, +/* instead of XClearWindow (Xdisplay, scrollBar.win); */ + if (last_top < scrollBar.top) + XClearArea(Xdisplay, scrollBar.win, sbshadow, last_top, - sbwidth, (R->scrollBar.top - last_top), + sbwidth, (scrollBar.top - last_top), False); - if (R->scrollBar.bot < last_bot) - XClearArea(R->Xdisplay, R->scrollBar.win, - sbshadow, R->scrollBar.bot, - sbwidth, (last_bot - R->scrollBar.bot), + if (scrollBar.bot < last_bot) + XClearArea(Xdisplay, scrollBar.win, + sbshadow, scrollBar.bot, + sbwidth, (last_bot - scrollBar.bot), False); } @@ -149,38 +147,38 @@ rxvt_scrollbar_show_rxvt(pR_ int update __attribute__((unused)), int last_top, i { int xofs; - if (R->Options & Opt_scrollBar_right) + if (Options & Opt_scrollBar_right) xofs = 0; else xofs = sbshadow ? sbwidth : sbwidth - 1; - XDrawLine(R->Xdisplay, R->scrollBar.win, R->botShadowGC, - xofs, 0, xofs, R->scrollBar.end + sbwidth); + XDrawLine(Xdisplay, scrollBar.win, botShadowGC, + xofs, 0, xofs, scrollBar.end + sbwidth); } #endif - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->scrollbarGC, - sbshadow, R->scrollBar.top, sbwidth, + XFillRectangle(Xdisplay, scrollBar.win, scrollbarGC, + sbshadow, scrollBar.top, sbwidth, scrollbar_len); if (sbshadow) /* trough shadow */ - rxvt_Draw_Shadow(R->Xdisplay, R->scrollBar.win, - R->botShadowGC, R->topShadowGC, + rxvt_Draw_Shadow(Xdisplay, scrollBar.win, + botShadowGC, topShadowGC, 0, 0, sbwidth + 2 * sbshadow, /* scrollbar_TotalWidth() */ - R->scrollBar.end + (sbwidth + 1) + sbshadow); + scrollBar.end + (sbwidth + 1) + sbshadow); /* shadow for scrollbar slider */ - rxvt_Draw_Shadow(R->Xdisplay, R->scrollBar.win, - R->topShadowGC, R->botShadowGC, - sbshadow, R->scrollBar.top, sbwidth, + rxvt_Draw_Shadow(Xdisplay, scrollBar.win, + topShadowGC, botShadowGC, + sbshadow, scrollBar.top, sbwidth, scrollbar_len); /* * Redraw scrollbar arrows */ - rxvt_Draw_button(aR_ sbshadow, sbshadow, + Draw_button (sbshadow, sbshadow, (scrollbar_isUp() ? -1 : +1), UP); - rxvt_Draw_button(aR_ sbshadow, (R->scrollBar.end + 1), + Draw_button (sbshadow, (scrollBar.end + 1), (scrollbar_isDn() ? -1 : +1), DN); return 1; } diff --git a/src/scrollbar-xterm.C b/src/scrollbar-xterm.C index ddf7ecd0..2e5d590a 100644 --- a/src/scrollbar-xterm.C +++ b/src/scrollbar-xterm.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: scrollbar-xterm.c *----------------------------------------------------------------------* - * $Id: scrollbar-xterm.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ + * $Id: scrollbar-xterm.C,v 1.4 2004-01-31 00:20:21 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1999-2001 Geoff Wing @@ -32,18 +32,17 @@ #define x_stp_height 2 const unsigned char x_stp_bits[] = { 0xff, 0xff }; -/* EXTPROTO */ int -rxvt_scrollbar_show_xterm(pR_ int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len) +rxvt_term::scrollbar_show_xterm (int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len) { int xsb = 0; - int sbwidth = R->scrollBar.width - 1; + int sbwidth = scrollBar.width - 1; - if ((R->scrollBar.init & R_SB_XTERM) == 0) { + if ((scrollBar.init & R_SB_XTERM) == 0) { XGCValues gcvalue; - R->scrollBar.init |= R_SB_XTERM; - gcvalue.stipple = XCreateBitmapFromData(R->Xdisplay, R->scrollBar.win, + scrollBar.init |= R_SB_XTERM; + gcvalue.stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win, (char *)x_stp_bits, x_stp_width, x_stp_height); if (!gcvalue.stipple) { @@ -51,35 +50,35 @@ rxvt_scrollbar_show_xterm(pR_ int update __attribute__((unused)), int last_top, exit(EXIT_FAILURE); } gcvalue.fill_style = FillOpaqueStippled; - gcvalue.foreground = R->PixColors[Color_fg]; - gcvalue.background = R->PixColors[Color_bg]; + gcvalue.foreground = PixColors[Color_fg]; + gcvalue.background = PixColors[Color_bg]; - R->xscrollbarGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + xscrollbarGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground | GCBackground | GCFillStyle | GCStipple, &gcvalue); - gcvalue.foreground = R->PixColors[Color_border]; - R->ShadowGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground, + gcvalue.foreground = PixColors[Color_border]; + ShadowGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground, &gcvalue); } -/* instead of XClearWindow (R->Xdisplay, R->scrollBar.win); */ - xsb = (R->Options & Opt_scrollBar_right) ? 1 : 0; - if (last_top < R->scrollBar.top) - XClearArea(R->Xdisplay, R->scrollBar.win, - R->sb_shadow + xsb, last_top, - sbwidth + 1, (R->scrollBar.top - last_top), False); +/* instead of XClearWindow (Xdisplay, scrollBar.win); */ + xsb = (Options & Opt_scrollBar_right) ? 1 : 0; + if (last_top < scrollBar.top) + XClearArea(Xdisplay, scrollBar.win, + sb_shadow + xsb, last_top, + sbwidth + 1, (scrollBar.top - last_top), False); - if (R->scrollBar.bot < last_bot) - XClearArea(R->Xdisplay, R->scrollBar.win, - R->sb_shadow + xsb, R->scrollBar.bot, - sbwidth + 1, (last_bot - R->scrollBar.bot), False); + if (scrollBar.bot < last_bot) + XClearArea(Xdisplay, scrollBar.win, + sb_shadow + xsb, scrollBar.bot, + sbwidth + 1, (last_bot - scrollBar.bot), False); /* scrollbar slider */ - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->xscrollbarGC, - xsb + 1, R->scrollBar.top, sbwidth, scrollbar_len); + XFillRectangle(Xdisplay, scrollBar.win, xscrollbarGC, + xsb + 1, scrollBar.top, sbwidth, scrollbar_len); - /*XDrawLine(R->Xdisplay, R->scrollBar.win, R->ShadowGC, - xsb ? 0 : sbwidth, R->scrollBar.beg, - xsb ? 0 : sbwidth, R->scrollBar.end);*/ + /*XDrawLine(Xdisplay, scrollBar.win, ShadowGC, + xsb ? 0 : sbwidth, scrollBar.beg, + xsb ? 0 : sbwidth, scrollBar.end);*/ return 1; } #endif /* XTERM_SCROLLBAR */ diff --git a/src/scrollbar.C b/src/scrollbar.C index eb57e20b..33431523 100644 --- a/src/scrollbar.C +++ b/src/scrollbar.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: scrollbar.c *----------------------------------------------------------------------* - * $Id: scrollbar.C,v 1.7 2003-12-18 14:11:47 pcg Exp $ + * $Id: scrollbar.C,v 1.8 2004-01-31 00:20:21 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1998 Alfredo K. Kojima @@ -32,24 +32,23 @@ /* * Map or unmap a scrollbar. Returns non-zero upon change of state */ -/* EXTPROTO */ int -rxvt_scrollbar_mapping(pR_ int map) +rxvt_term::scrollbar_mapping (int map) { int change = 0; #ifdef HAVE_SCROLLBARS - if (map && !scrollbar_visible(R)) { - R->scrollBar.setIdle (); - if (!R->scrollBar.win) - R->resize_scrollbar (); - if (R->scrollBar.win) { - XMapWindow(R->Xdisplay, R->scrollBar.win); + if (map && !scrollbar_visible()) { + scrollBar.setIdle (); + if (!scrollBar.win) + resize_scrollbar (); + if (scrollBar.win) { + XMapWindow(Xdisplay, scrollBar.win); change = 1; } - } else if (!map && scrollbar_visible(R)) { - R->scrollBar.state = 0; - XUnmapWindow(R->Xdisplay, R->scrollBar.win); + } else if (!map && scrollbar_visible()) { + scrollBar.state = 0; + XUnmapWindow(Xdisplay, scrollBar.win); change = 1; } #endif @@ -75,21 +74,21 @@ rxvt_term::resize_scrollbar () if (scrollBar.style == R_SB_XTERM) { scrollBar.beg = R_SCROLLBEG_XTERM; scrollBar.end = R_SCROLLEND_XTERM; - scrollBar.update = rxvt_scrollbar_show_xterm; + //scrollBar.update = rxvt_scrollbar_show_xterm; } #endif #if defined(NEXT_SCROLLBAR) if (scrollBar.style == R_SB_NEXT) { scrollBar.beg = R_SCROLLBEG_NEXT; scrollBar.end = R_SCROLLEND_NEXT; - scrollBar.update = rxvt_scrollbar_show_next; + //scrollBar.update = rxvt_scrollbar_show_next; } #endif #if defined(RXVT_SCROLLBAR) if (scrollBar.style == R_SB_RXVT) { scrollBar.beg = R_SCROLLBEG_RXVT; scrollBar.end = R_SCROLLEND_RXVT; - scrollBar.update = rxvt_scrollbar_show_rxvt; + //scrollBar.update = rxvt_scrollbar_show_rxvt; } #endif @@ -113,7 +112,7 @@ rxvt_term::resize_scrollbar () | Button3MotionMask)); delayed_init = 1; } - rxvt_scrollbar_show (this, 1); + scrollbar_show (1); if (delayed_init) XMapWindow (Xdisplay, scrollBar.win); #endif @@ -122,48 +121,45 @@ rxvt_term::resize_scrollbar () /* * Update current scrollbar view w.r.t. slider heights, etc. */ -/* EXTPROTO */ int -rxvt_scrollbar_show(pR_ int update) +rxvt_term::scrollbar_show (int update) { int ret = 0; #ifdef HAVE_SCROLLBARS int top, bot, len, adj; - if (!scrollbar_visible(R)) + if (!scrollbar_visible()) return 0; if (update) { - top = (R->TermWin.nscrolled - R->TermWin.view_start); - bot = top + (R->TermWin.nrow - 1); - len = max((R->TermWin.nscrolled + (R->TermWin.nrow - 1)), 1); + top = (TermWin.nscrolled - TermWin.view_start); + bot = top + (TermWin.nrow - 1); + len = max((TermWin.nscrolled + (TermWin.nrow - 1)), 1); adj = (((bot - top) * scrollbar_size()) % len) > 0 ? 1 : 0; - R->scrollBar.top = (R->scrollBar.beg + (top * scrollbar_size()) / len); - R->scrollbar_len = ((bot - top) * scrollbar_size()) / len + + scrollBar.top = (scrollBar.beg + (top * scrollbar_size()) / len); + scrollbar_len = ((bot - top) * scrollbar_size()) / len + scrollbar_minheight() + adj; - R->scrollBar.bot = (R->scrollBar.top + R->scrollbar_len); + scrollBar.bot = (scrollBar.top + scrollbar_len); /* no change */ - if (R->scrollBar.top == R->last_top - && R->scrollBar.bot == R->last_bot - && (R->scrollBar.state == R->last_state || !scrollbar_isUpDn())) + if (scrollBar.top == last_top + && scrollBar.bot == last_bot + && (scrollBar.state == last_state || !scrollbar_isUpDn())) return 0; } - ret = R->scrollBar.update(aR_ update, R->last_top, R->last_bot, - R->scrollbar_len); + ret = scrollbar_update (update, last_top, last_bot, scrollbar_len); - R->last_top = R->scrollBar.top; - R->last_bot = R->scrollBar.bot; - R->last_state = R->scrollBar.state; + last_top = scrollBar.top; + last_bot = scrollBar.bot; + last_state = scrollBar.state; #endif return ret; } -/* EXTPROTO */ void -rxvt_setup_scrollbar(pR_ const char *scrollalign, const char *scrollstyle, const char *thickness) +rxvt_term::setup_scrollbar (const char *scrollalign, const char *scrollstyle, const char *thickness) { #ifdef HAVE_SCROLLBARS int i; @@ -203,19 +199,19 @@ rxvt_setup_scrollbar(pR_ const char *scrollalign, const char *scrollstyle, const width = min(i, SB_WIDTH_MAXIMUM); # if defined(RXVT_SCROLLBAR) - if (!(R->Options & Opt_scrollBar_floating) && style == R_SB_RXVT) - R->sb_shadow = SHADOW; + if (!(Options & Opt_scrollBar_floating) && style == R_SB_RXVT) + sb_shadow = SHADOW; # endif - R->scrollBar.style = style; - R->scrollBar.width = width; + scrollBar.style = style; + scrollBar.width = width; - /* R->scrollbar_align = R_SB_ALIGN_CENTRE; */ + /* scrollbar_align = R_SB_ALIGN_CENTRE; */ if (scrollalign) { if (STRNCASECMP(scrollalign, "top", 3) == 0) - R->scrollbar_align = R_SB_ALIGN_TOP; + scrollbar_align = R_SB_ALIGN_TOP; else if (STRNCASECMP(scrollalign, "bottom", 6) == 0) - R->scrollbar_align = R_SB_ALIGN_BOTTOM; + scrollbar_align = R_SB_ALIGN_BOTTOM; } #endif } diff --git a/src/simplevec.h b/src/simplevec.h index 95ee5379..edf5b833 100644 --- a/src/simplevec.h +++ b/src/simplevec.h @@ -78,7 +78,7 @@ private: if (_last + n <= _size) { memmove (where+n, where, (end()-where)*sizeof(T)); } else { - long sz = _last+n; + size_type sz = _last+n; sz = (_size == 0) ? max(sz, 5) : max(sz, 2*_size); T *nbuf = alloc (sz); if (_buf) { diff --git a/src/strings.C b/src/strings.C index 10d2bbab..c30426ee 100644 --- a/src/strings.C +++ b/src/strings.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: strings.c *----------------------------------------------------------------------* - * $Id: strings.C,v 1.2 2003-11-24 17:31:28 pcg Exp $ + * $Id: strings.C,v 1.3 2004-01-31 00:20:21 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1997-2001 Geoff Wing @@ -31,7 +31,6 @@ * a replacement for strcasecmp() to avoid linking an entire library. * Mark Olesen added this in 2.15 but for which OS & library? - Geoff Wing */ -/* EXTPROTO */ int strcasecmp(const char *s1, const char *s2) { @@ -41,7 +40,6 @@ strcasecmp(const char *s1, const char *s2) return (int)(tolower(*s1) - tolower(*s2)); } -/* EXTPROTO */ int strncasecmp(const char *s1, const char *s2, size_t n) { @@ -53,7 +51,6 @@ strncasecmp(const char *s1, const char *s2, size_t n) return (int)(tolower(*s1) - tolower(*s2)); } -/* EXTPROTO */ char * strcpy(char *d, const char *s) { @@ -63,7 +60,6 @@ strcpy(char *d, const char *s) return d; } -/* EXTPROTO */ char * strncpy(char *d, const char *s, size_t len) { @@ -79,7 +75,6 @@ strncpy(char *d, const char *s, size_t len) return d; } -/* EXTPROTO */ int strcmp(const char *s1, const char *s2) { @@ -89,7 +84,6 @@ strcmp(const char *s1, const char *s2) return (int) ((unsigned char) *s1 - (unsigned char) *--s2); } -/* EXTPROTO */ int strncmp(const char *s1, const char *s2, size_t len) { @@ -101,7 +95,6 @@ strncmp(const char *s1, const char *s2, size_t len) return 0; } -/* EXTPROTO */ char * strcat(char *s1, const char *s2) { @@ -114,7 +107,6 @@ strcat(char *s1, const char *s2) return s1; } -/* EXTPROTO */ char * strncat(char *s1, const char *s2, size_t len) { @@ -128,7 +120,6 @@ strncat(char *s1, const char *s2, size_t len) return s1; } -/* EXTPROTO */ size_t strlen(const char *s) { @@ -138,7 +129,6 @@ strlen(const char *s) return len; } -/* EXTPROTO */ char * strdup(const char *s) { @@ -150,14 +140,12 @@ strdup(const char *s) return c; } -/* EXTPROTO */ char * index(const char *s, int c) { return STRCHR(s, c); } -/* EXTPROTO */ char * strchr(const char *s, int c) { @@ -175,14 +163,12 @@ strchr(const char *s, int c) } -/* EXTPROTO */ char * rindex(const char *s, int c) { return STRRCHR(s, c); } -/* EXTPROTO */ char * strrchr(const char *s, int c) { @@ -197,7 +183,6 @@ strrchr(const char *s, int c) return p; } -/* EXTPROTO */ void * memcpy(void *s1, const void *s2, size_t len) { @@ -208,7 +193,6 @@ memcpy(void *s1, const void *s2, size_t len) /*--------------------------------------------------------------------------* * Possibly faster memmove() by Geoff Wing *--------------------------------------------------------------------------*/ -/* EXTPROTO */ void * memmove(void *d, const void *s, size_t len) { @@ -259,14 +243,12 @@ memmove(void *d, const void *s, size_t len) * 2) SIZEOF_INT_P == power of 2 *--------------------------------------------------------------------------*/ -/* EXTPROTO */ void bzero(void *b, size_t len) { MEMSET(b, 0, len); } -/* EXTPROTO */ void * memset(void *p, int c1, size_t len) { diff --git a/src/xdefaults.C b/src/xdefaults.C index 3cb7b24b..62e88e2c 100644 --- a/src/xdefaults.C +++ b/src/xdefaults.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: xdefaults.c *----------------------------------------------------------------------* - * $Id: xdefaults.C,v 1.7 2004-01-16 22:26:18 pcg Exp $ + * $Id: xdefaults.C,v 1.8 2004-01-31 00:20:21 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1994 Robert Nation @@ -356,8 +356,7 @@ static const char optionsstring[] = "Options: " /*{{{ usage: */ /*----------------------------------------------------------------------*/ -/* EXTPROTO */ -void +static void rxvt_usage(int type) { unsigned int i, col; @@ -442,9 +441,8 @@ rxvt_usage(int type) /*}}} */ /*{{{ get command-line options before getting resources */ -/* EXTPROTO */ void -rxvt_get_options(pR_ int argc, const char *const *argv) +rxvt_term::get_options (int argc, const char *const *argv) { int i, bad_option = 0; static const char On[3] = "ON", Off[4] = "OFF"; @@ -498,7 +496,7 @@ rxvt_get_options(pR_ int argc, const char *const *argv) #ifdef DEBUG_RESOURCES fprintf(stderr, "\"%s\"\n", str); #endif - R->rs[optList[entry].doff] = str; + rs[optList[entry].doff] = str; /* * special cases are handled in main.c:main() to allow * X resources to set these values before we settle for @@ -515,12 +513,12 @@ rxvt_get_options(pR_ int argc, const char *const *argv) optList[entry].opt, optList[entry].kw, flag); #endif if (flag == On) - R->Options |= (optList[entry].flag); + Options |= (optList[entry].flag); else - R->Options &= ~(optList[entry].flag); + Options &= ~(optList[entry].flag); if (optList[entry].doff != -1) - R->rs[optList[entry].doff] = flag; + rs[optList[entry].doff] = flag; } } else #ifdef KEYSYM_RESOURCE @@ -529,7 +527,7 @@ rxvt_get_options(pR_ int argc, const char *const *argv) const char *str = argv[++i]; if (str != NULL) - rxvt_parse_keysym(aR_ opt + sizeof("keysym.") - 1, str); + parse_keysym (opt + sizeof("keysym.") - 1, str); } else #endif bad_option = 1; @@ -552,17 +550,15 @@ rxvt_get_options(pR_ int argc, const char *const *argv) * value will be a string */ /* ARGSUSED */ -/* INTPROTO */ -Bool +bool rxvt_define_key(XrmDatabase *database __attribute__((unused)), XrmBindingList bindings __attribute__((unused)), XrmQuarkList quarks, XrmRepresentation *type __attribute__((unused)), XrmValue *value, XPointer closure __attribute__((unused))) { - dR; int last; for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ ; last--; - rxvt_parse_keysym(aR_ XrmQuarkToString(quarks[last]), (char *)value->addr); + GET_R->parse_keysym (XrmQuarkToString(quarks[last]), (char *)value->addr);//D//TODO return False; } @@ -575,9 +571,8 @@ rxvt_define_key(XrmDatabase *database __attribute__((unused)), XrmBindingList bi * non-NULL for command-line options (need to allocate) */ #define NEWARGLIM 500 /* `reasonable' size */ -/* INTPROTO */ int -rxvt_parse_keysym(pR_ const char *str, const char *arg) +rxvt_term::parse_keysym (const char *str, const char *arg) { int n, sym; char *key_string, *newarg = NULL; @@ -622,7 +617,7 @@ rxvt_parse_keysym(pR_ const char *str, const char *arg) if (sym < 0xFF00 || sym > 0xFFFF) /* we only do extended keys */ return -1; sym &= 0xFF; - if (R->Keysym_map[sym] != NULL) /* already set ? */ + if (Keysym_map[sym] != NULL) /* already set ? */ return -1; if (newarg == NULL) { @@ -638,7 +633,7 @@ rxvt_parse_keysym(pR_ const char *str, const char *arg) key_string[0] = n; STRNCPY(key_string + 1, newarg, n); - R->Keysym_map[sym] = (unsigned char *)key_string; + Keysym_map[sym] = (unsigned char *)key_string; return 1; } @@ -650,9 +645,8 @@ rxvt_parse_keysym(pR_ const char *str, const char *arg) /* * the matching algorithm used for memory-save fake resources */ -/* INTPROTO */ void -rxvt_get_xdefaults(pR_ FILE *stream, const char *name) +rxvt_term::get_xdefaults (FILE *stream, const char *name) { unsigned int len; char *str, buffer[256]; @@ -672,7 +666,7 @@ rxvt_get_xdefaults(pR_ FILE *stream, const char *name) str += (len + 1); /* skip `name*' or `name.' */ # ifdef KEYSYM_RESOURCE - if (!rxvt_parse_keysym(aR_ str, NULL)) + if (!parse_keysym (str, NULL)) # endif /* KEYSYM_RESOURCE */ for (entry = 0; entry < optList_size(); entry++) { const char *kw = optList[entry].kw; @@ -685,13 +679,13 @@ rxvt_get_xdefaults(pR_ FILE *stream, const char *name) str += (n + 1); rxvt_Str_trim(str); n = STRLEN(str); - if (n && R->rs[optList[entry].doff] == NULL) { + if (n && rs[optList[entry].doff] == NULL) { /* not already set */ int s; char *p = (char *)rxvt_malloc((n + 1) * sizeof(char)); STRCPY(p, str); - R->rs[optList[entry].doff] = p; + rs[optList[entry].doff] = p; if (optList_isBool(entry)) { s = STRCASECMP(str, "TRUE") == 0 || STRCASECMP(str, "YES") == 0 @@ -700,9 +694,9 @@ rxvt_get_xdefaults(pR_ FILE *stream, const char *name) if (optList_isReverse(entry)) s = !s; if (s) - R->Options |= (optList[entry].flag); + Options |= (optList[entry].flag); else - R->Options &= ~(optList[entry].flag); + Options &= ~(optList[entry].flag); } } break; @@ -721,9 +715,8 @@ rxvt_get_xdefaults(pR_ FILE *stream, const char *name) * using XGetDefault() or the hand-rolled replacement */ /* ARGSUSED */ -/* EXTPROTO */ void -rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char *name) +rxvt_term::extract_resources (Display *display __attribute__((unused)), const char *name) { #ifndef NO_RESOURCES @@ -732,11 +725,11 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char /* Compute the path of the possibly available localized Rxvt file */ char *localepath = NULL; - if (R->locale != NULL) { /* XXX: must limit length of string */ + if (locale != NULL) { /* XXX: must limit length of string */ localepath = (char *)rxvt_malloc(256); sprintf(localepath, XAPPLOADDIRLOCALE "/" APL_SUBCLASS, (int)(258 - sizeof(XAPPLOADDIRLOCALE) - sizeof(APL_SUBCLASS)), - R->locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ + locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ } { @@ -820,7 +813,7 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char char *p, *p0; const char *kw = optList[entry].kw; - if (kw == NULL || R->rs[optList[entry].doff] != NULL) + if (kw == NULL || rs[optList[entry].doff] != NULL) continue; /* previously set */ p = XGetDefault(display, name, kw); @@ -833,7 +826,7 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char if (p == NULL && p0) p = p0; if (p) { - R->rs[optList[entry].doff] = p; + rs[optList[entry].doff] = p; if (optList_isBool(entry)) { s = STRCASECMP(p, "TRUE") == 0 @@ -843,9 +836,9 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char if (optList_isReverse(entry)) s = !s; if (s) - R->Options |= (optList[entry].flag); + Options |= (optList[entry].flag); else - R->Options &= ~(optList[entry].flag); + Options &= ~(optList[entry].flag); } } } @@ -915,8 +908,8 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char * "XTerm" and "Rxvt" as class names. */ - rxvt_get_xdefaults(aR_ fd, name); - rxvt_get_xdefaults(aR_ fd, APL_SUBCLASS); + get_xdefaults (fd, name); + get_xdefaults (fd, APL_SUBCLASS); # if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR) { @@ -927,15 +920,15 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char # endif ad = fopen(XAPPLOADDIR "/" APL_SUBCLASS, "r"); if (ad != NULL) { - rxvt_get_xdefaults(aR_ ad, APL_SUBCLASS); - rxvt_get_xdefaults(aR_ ad, ""); + get_xdefaults (ad, APL_SUBCLASS); + get_xdefaults (ad, ""); fclose(ad); } } # endif /* XAPPLOADDIR */ - rxvt_get_xdefaults(aR_ fd, APL_CLASS); - rxvt_get_xdefaults(aR_ fd, ""); /* partial match */ + get_xdefaults (fd, APL_CLASS); + get_xdefaults (fd, ""); /* partial match */ if (fd != NULL) fclose(fd); # endif /* USE_XGETDEFAULT */ @@ -956,23 +949,23 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char * options and command-line long options */ #ifdef MULTICHAR_SET - rxvt_set_multichar_encoding(aR_ R->rs[Rs_multichar_encoding]); + set_multichar_encoding (rs[Rs_multichar_encoding]); #endif #ifdef GREEK_SUPPORT /* this could be a function in grkelot.c */ /* void set_greek_keyboard (const char * str); */ - if (R->rs[Rs_greek_keyboard]) { - if (!STRCMP(R->rs[Rs_greek_keyboard], "iso")) + if (rs[Rs_greek_keyboard]) { + if (!STRCMP(rs[Rs_greek_keyboard], "iso")) greek_setmode(GREEK_ELOT928); /* former -grk9 */ - else if (!STRCMP(R->rs[Rs_greek_keyboard], "ibm")) + else if (!STRCMP(rs[Rs_greek_keyboard], "ibm")) greek_setmode(GREEK_IBM437); /* former -grk4 */ } { KeySym sym; - if (R->rs[Rs_greektoggle_key] - && ((sym = XStringToKeysym(R->rs[Rs_greektoggle_key])) != 0)) - R->ks_greekmodeswith = sym; + if (rs[Rs_greektoggle_key] + && ((sym = XStringToKeysym(rs[Rs_greektoggle_key])) != 0)) + ks_greekmodeswith = sym; } #endif /* GREEK_SUPPORT */ @@ -980,12 +973,12 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char { KeySym sym; - if (R->rs[Rs_bigfont_key] - && ((sym = XStringToKeysym(R->rs[Rs_bigfont_key])) != 0)) - R->ks_bigfont = sym; - if (R->rs[Rs_smallfont_key] - && ((sym = XStringToKeysym(R->rs[Rs_smallfont_key])) != 0)) - R->ks_smallfont = sym; + if (rs[Rs_bigfont_key] + && ((sym = XStringToKeysym(rs[Rs_bigfont_key])) != 0)) + ks_bigfont = sym; + if (rs[Rs_smallfont_key] + && ((sym = XStringToKeysym(rs[Rs_smallfont_key])) != 0)) + ks_smallfont = sym; } #endif } diff --git a/src/xpm.C b/src/xpm.C index fbb985c7..cd5b6f32 100644 --- a/src/xpm.C +++ b/src/xpm.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: xpm.c *----------------------------------------------------------------------* - * $Id: xpm.C,v 1.4 2003-12-18 02:07:12 pcg Exp $ + * $Id: xpm.C,v 1.5 2004-01-31 00:20:21 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1997 Carsten Haitzler @@ -49,16 +49,15 @@ * And this GEOM string is for querying current scale/position: * @ `?' */ -/* EXTPROTO */ int -rxvt_scale_pixmap(pR_ const char *geom) +rxvt_term::scale_pixmap (const char *geom) { int flags, changed = 0; int x = 0, y = 0; unsigned int w = 0, h = 0; unsigned int n; char *p, *str; - bgPixmap_t *bgpixmap = &(R->bgPixmap); + bgPixmap_t *bgpixmap = &(bgPixmap); #define MAXLEN_GEOM sizeof("[1000x1000+1000+1000]") @@ -69,7 +68,7 @@ rxvt_scale_pixmap(pR_ const char *geom) sprintf(str, "[%dx%d+%d+%d]", /* can't presume snprintf() ! */ min(bgpixmap->w, 9999), min(bgpixmap->h, 9999), min(bgpixmap->x, 9999), min(bgpixmap->y, 9999)); - rxvt_xterm_seq(aR_ XTerm_title, str, CHAR_ST); + xterm_seq (XTerm_title, str, CHAR_ST); free(str); return 0; } @@ -143,34 +142,33 @@ rxvt_scale_pixmap(pR_ const char *geom) return changed; } -/* EXTPROTO */ void -rxvt_resize_pixmap(pR) +rxvt_term::resize_pixmap () { XGCValues gcvalue; GC gc; unsigned int width = TermWin_TotalWidth(); unsigned int height = TermWin_TotalHeight(); - if (R->TermWin.pixmap != None) - XFreePixmap(R->Xdisplay, R->TermWin.pixmap); + if (TermWin.pixmap != None) + XFreePixmap(Xdisplay, TermWin.pixmap); - if (R->bgPixmap.pixmap == None) { /* So be it: I'm not using pixmaps */ - R->TermWin.pixmap = None; - if (!(R->Options & Opt_transparent) || R->am_transparent == 0) - XSetWindowBackground(R->Xdisplay, R->TermWin.vt, - R->PixColors[Color_bg]); + if (bgPixmap.pixmap == None) { /* So be it: I'm not using pixmaps */ + TermWin.pixmap = None; + if (!(Options & Opt_transparent) || am_transparent == 0) + XSetWindowBackground(Xdisplay, TermWin.vt, + PixColors[Color_bg]); return; } - gcvalue.foreground = R->PixColors[Color_bg]; - gc = XCreateGC(R->Xdisplay, R->TermWin.vt, GCForeground, &gcvalue); + gcvalue.foreground = PixColors[Color_bg]; + gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground, &gcvalue); - if (R->bgPixmap.pixmap != None) { /* we have a specified pixmap */ - unsigned int w = R->bgPixmap.w, h = R->bgPixmap.h, - x = R->bgPixmap.x, y = R->bgPixmap.y; - unsigned int xpmh = R->xpmAttr.height, - xpmw = R->xpmAttr.width; + if (bgPixmap.pixmap != None) { /* we have a specified pixmap */ + unsigned int w = bgPixmap.w, h = bgPixmap.h, + x = bgPixmap.x, y = bgPixmap.y; + unsigned int xpmh = xpmAttr.height, + xpmw = xpmAttr.width; /* * don't zoom pixmap too much nor expand really small pixmaps @@ -183,16 +181,16 @@ rxvt_resize_pixmap(pR) if (w == 0) { /* basic X tiling - let the X server do it */ - R->TermWin.pixmap = XCreatePixmap(R->Xdisplay, R->TermWin.vt, + TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt, xpmw, xpmh, (unsigned int)XDEPTH); - XCopyArea(R->Xdisplay, R->bgPixmap.pixmap, R->TermWin.pixmap, gc, + XCopyArea(Xdisplay, bgPixmap.pixmap, TermWin.pixmap, gc, 0, 0, xpmw, xpmh, 0, 0); } else { float incr, p; Pixmap tmp; - R->TermWin.pixmap = XCreatePixmap(R->Xdisplay, R->TermWin.vt, + TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt, width, height, (unsigned int)XDEPTH); /* @@ -200,16 +198,16 @@ rxvt_resize_pixmap(pR) */ rxvt_pixmap_incr(&w, &x, &incr, &p, width, xpmw); - tmp = XCreatePixmap(R->Xdisplay, R->TermWin.vt, + tmp = XCreatePixmap(Xdisplay, TermWin.vt, width, xpmh, (unsigned int)XDEPTH); - XFillRectangle(R->Xdisplay, tmp, gc, 0, 0, width, + XFillRectangle(Xdisplay, tmp, gc, 0, 0, width, xpmh); for ( /*nil */ ; x < w; x++, p += incr) { if (p >= xpmw) p = 0; /* copy one column from the original pixmap to the tmp pixmap */ - XCopyArea(R->Xdisplay, R->bgPixmap.pixmap, tmp, gc, + XCopyArea(Xdisplay, bgPixmap.pixmap, tmp, gc, (int)p, 0, 1, xpmh, (int)x, 0); } @@ -219,35 +217,34 @@ rxvt_resize_pixmap(pR) rxvt_pixmap_incr(&h, &y, &incr, &p, height, xpmh); if (y > 0) - XFillRectangle(R->Xdisplay, R->TermWin.pixmap, gc, 0, 0, width, + XFillRectangle(Xdisplay, TermWin.pixmap, gc, 0, 0, width, y); if (h < height) - XFillRectangle(R->Xdisplay, R->TermWin.pixmap, gc, 0, (int)h, + XFillRectangle(Xdisplay, TermWin.pixmap, gc, 0, (int)h, width, height - h + 1); for ( /*nil */ ; y < h; y++, p += incr) { if (p >= xpmh) p = 0; /* copy one row from the tmp pixmap to the main pixmap */ - XCopyArea(R->Xdisplay, tmp, R->TermWin.pixmap, gc, + XCopyArea(Xdisplay, tmp, TermWin.pixmap, gc, 0, (int)p, width, 1, 0, (int)y); } - XFreePixmap(R->Xdisplay, tmp); + XFreePixmap(Xdisplay, tmp); } } - XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.vt, R->TermWin.pixmap); - XFreeGC(R->Xdisplay, gc); - R->am_transparent = 0; + XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt, TermWin.pixmap); + XFreeGC(Xdisplay, gc); + am_transparent = 0; - XClearWindow(R->Xdisplay, R->TermWin.vt); + XClearWindow(Xdisplay, TermWin.vt); - XSync(R->Xdisplay, False); + XSync(Xdisplay, False); } /* * Calculate tiling sizes and increments * At start, p == 0, incr == xpmwidthheight */ -/* INTPROTO */ void rxvt_pixmap_incr(unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight) { @@ -308,19 +305,18 @@ rxvt_pixmap_incr(unsigned int *wh, unsigned int *xy, float *incr, float *p, unsi *p = cp; } -/* EXTPROTO */ Pixmap -rxvt_set_bgPixmap(pR_ const char *file) +rxvt_term::set_bgPixmap (const char *file) { char *f; assert(file != NULL); - if (R->bgPixmap.pixmap != None) { - XFreePixmap(R->Xdisplay, R->bgPixmap.pixmap); - R->bgPixmap.pixmap = None; + if (bgPixmap.pixmap != None) { + XFreePixmap(Xdisplay, bgPixmap.pixmap); + bgPixmap.pixmap = None; } - XSetWindowBackground(R->Xdisplay, R->TermWin.vt, R->PixColors[Color_bg]); + XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[Color_bg]); if (*file != '\0') { /* XWindowAttributes attr; */ @@ -328,21 +324,21 @@ rxvt_set_bgPixmap(pR_ const char *file) /* * we already have the required attributes */ -/* XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &attr); */ +/* XGetWindowAttributes(Xdisplay, TermWin.vt, &attr); */ - R->xpmAttr.closeness = 30000; - R->xpmAttr.colormap = XCMAP; - R->xpmAttr.visual = XVISUAL; - R->xpmAttr.depth = XDEPTH; - R->xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual | + xpmAttr.closeness = 30000; + xpmAttr.colormap = XCMAP; + xpmAttr.visual = XVISUAL; + xpmAttr.depth = XDEPTH; + xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual | XpmDepth | XpmSize | XpmReturnPixels); /* search environment variables here too */ - f = (char *)rxvt_File_find(file, ".xpm", R->rs[Rs_path]); + f = (char *)rxvt_File_find(file, ".xpm", rs[Rs_path]); if (f == NULL - || XpmReadFileToPixmap(R->Xdisplay, Xroot, f, - &R->bgPixmap.pixmap, NULL, - &R->xpmAttr)) { + || XpmReadFileToPixmap(Xdisplay, Xroot, f, + &bgPixmap.pixmap, NULL, + &xpmAttr)) { char *p; /* semi-colon delimited */ @@ -354,8 +350,8 @@ rxvt_set_bgPixmap(pR_ const char *file) } free(f); } - rxvt_resize_pixmap(aR); - return R->bgPixmap.pixmap; + resize_pixmap (); + return bgPixmap.pixmap; } #endif /* XPM_BACKGROUND */