From: pcg Date: Tue, 25 Nov 2003 11:52:42 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=8b699778c17b0b483749ad7b8cd95e1f75321bb4;p=dana%2Furxvt.git *** empty log message *** --- diff --git a/reconf b/reconf index 98e8c5df..116eb235 100755 --- a/reconf +++ b/reconf @@ -1,6 +1,6 @@ ./configure --prefix=/opt/rxvt --enable-utmp \ --enable-wtmp --enable-lastlog --enable-xim --disable-strings --enable-xterm-scroll \ --with-term=xterm --enable-keepscrolling --enable-xft \ - --enable-cursor-blink --enable-frills --disable-swapscreen \ + --enable-frills --disable-swapscreen \ --with-codesets=eu,jp - #--enable-pointer-blank + #--enable-pointer-blank --enable-cursor-blink diff --git a/src/Makefile.in b/src/Makefile.in index 04c30b94..660c5eb9 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.2 2003-11-24 17:31:27 pcg Exp $ +# $Id: Makefile.in,v 1.3 2003-11-25 11:52:42 pcg Exp $ @MCOMMON@ LINT = lint -DNARROWPROTO=1 $(XINC) -chapbxz @@ -27,23 +27,24 @@ dummy: LIBSRCS = command.C defaultfont.C graphics.C grkelot.C init.C logging.C \ main.C menubar.C misc.C netdisp.C ptytty.C screen.C scrollbar.C \ scrollbar-rxvt.C scrollbar-next.C scrollbar-xterm.C strings.C \ - xdefaults.C xpm.C encoding.C rxvtcolor.C rxvtvec.C + xdefaults.C xpm.C encoding.C rxvtcolor.C rxvtvec.C iom.C SRCS = rxvt.C $(LIBSRCS) HDRS = command.h defaultfont.h feature.h grkelot.h init.h logging.h \ - menubar.h netdisp.h protos.h rxvt.h rxvtgrx.h version.h encoding.h rxvtvec.h + menubar.h netdisp.h protos.h rxvt.h rxvtgrx.h version.h encoding.h \ + rxvtvec.h iom.h EXTRAHDRS = rxvtlib.h rxvtdaemon.h OBJS = command.o defaultfont.o init.o graphics.o grkelot.o logging.o \ main.o menubar.o misc.o netdisp.o ptytty.o screen.o \ scrollbar.o scrollbar-next.o scrollbar-rxvt.o scrollbar-xterm.o \ - strings.o xdefaults.o xpm.o rxvt.o encoding.o rxvtcolor.o rxvtvec.o + strings.o xdefaults.o xpm.o rxvt.o encoding.o rxvtcolor.o rxvtvec.o iom.o LIBOBJS = command.lo defaultfont.lo init.lo graphics.lo grkelot.lo logging.lo \ main.lo menubar.lo misc.lo netdisp.lo ptytty.lo screen.lo \ scrollbar.lo scrollbar-next.lo scrollbar-rxvt.lo scrollbar-xterm.lo \ - strings.lo xdefaults.lo xpm.lo encoding.lo rxvt.lo rxvtcolor.lo rxvtvec.lo + strings.lo xdefaults.lo xpm.lo encoding.lo rxvt.lo rxvtcolor.lo rxvtvec.lo iom.lo LIBVERSION = @LIBVERSION@ INSTALL_LIBRXVT = @INSTALL_LIBRXVT@ @@ -107,8 +108,8 @@ all: allbin rxvt: version.h rxvt.o librxvt.la $(LIBTOOL) --mode=link $(LINK) rxvt.o librxvt.la $(LIBS) $(XLIB) $(DLIB) $(SUPLIB) -o $@ -rxvtd: version.h rxvtd.o librxvt.la iom.o rxvtdaemon.o - $(LIBTOOL) --mode=link $(LINK) rxvtd.o rxvtdaemon.o iom.o librxvt.la $(LIBS) $(XLIB) $(DLIB) $(SUPLIB) -o $@ +rxvtd: version.h rxvtd.o librxvt.la rxvtdaemon.o + $(LIBTOOL) --mode=link $(LINK) rxvtd.o rxvtdaemon.o librxvt.la $(LIBS) $(XLIB) $(DLIB) $(SUPLIB) -o $@ rxvtc: version.h rxvtc.o rxvtdaemon.o $(LIBTOOL) --mode=link $(LINK) rxvtc.o rxvtdaemon.o $(LIBS) $(DLIB) $(SUPLIB) -o $@ @@ -182,6 +183,10 @@ distcopy: .protos $(INTPROS) defaultfont.h: encoding.h rxvtvec.h rxvtlib.h: rxvtcolor.h defaultfont.h +iom.o: iom.C iom.h +rxvtdaemon.o: rxvtdaemon.C rxvtdaemon.h +rxvtd.o: rxvtd.C $(DEPS) rxvtdaemon.h rxvtvec.h +rxvtc.o: rxvtc.C $(DEPS) rxvtdaemon.h rxvtvec.h command.o: command.C $(DEPS) command.intpro command.h version.h defaultfont.o: defaultfont.C $(DEPS) defaultfont.intpro defaultfont.h @@ -195,7 +200,6 @@ misc.o: misc.C $(DEPS) misc.intpro netdisp.o: netdisp.C $(DEPS) netdisp.intpro netdisp.h ptytty.o: ptytty.C $(DEPS) ptytty.intpro rxvt.o: rxvt.C $(DEPS) -rxvtd.o: rxvtd.C $(DEPS) rxvtdaemon.h screen.o: screen.C $(DEPS) screen.intpro defaultfont.h scrollbar.o: scrollbar.C $(DEPS) scrollbar.intpro scrollbar-rxvt.o: scrollbar-rxvt.C $(DEPS) scrollbar-rxvt.intpro @@ -230,6 +234,4 @@ xpm.lo: xpm.C $(DEPS) xpm.intpro encoding.lo: encoding.C $(DEPS) encoding.h rxvtcolor.lo: rxvtcolor.C $(DEPS) -iom.o: iom.C iom.h -rxvtdaemon.o: rxvtdaemon.C rxvtdaemon.h diff --git a/src/command.C b/src/command.C index 1e96082a..fe6a55a1 100644 --- a/src/command.C +++ b/src/command.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: command.c *----------------------------------------------------------------------* - * $Id: command.C,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: command.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -66,7 +66,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) #ifdef USE_XIM int valid_keysym; #endif - unsigned char *kbuf = R->h->kbuf; + unsigned char *kbuf = R->kbuf; /* * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an @@ -76,33 +76,33 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) */ shft = (ev->state & ShiftMask); ctrl = (ev->state & ControlMask); - meta = (ev->state & R->h->ModMetaMask); - if (R->numlock_state || (ev->state & R->h->ModNumLockMask)) { - R->numlock_state = (ev->state & R->h->ModNumLockMask); + meta = (ev->state & R->ModMetaMask); + if (R->numlock_state || (ev->state & R->ModNumLockMask)) { + R->numlock_state = (ev->state & R->ModNumLockMask); PrivMode((!R->numlock_state), PrivMode_aplKP); } #ifdef USE_XIM - if (R->h->Input_Context != NULL) { + if (R->Input_Context != NULL) { Status status_return; kbuf[0] = '\0'; #ifdef X_HAVE_UTF8_STRING - len = Xutf8LookupString(R->h->Input_Context, ev, (char *)kbuf, + len = Xutf8LookupString(R->Input_Context, ev, (char *)kbuf, KBUFSZ, &keysym, &status_return); #else - len = XmbLookupString(R->h->Input_Context, ev, (char *)kbuf, + len = XmbLookupString(R->Input_Context, ev, (char *)kbuf, KBUFSZ, &keysym, &status_return); #endif valid_keysym = ((status_return == XLookupKeySym) || (status_return == XLookupBoth)); } else { len = XLookupString(ev, (char *)kbuf, KBUFSZ, &keysym, - &R->h->compose); + &R->compose); valid_keysym = 1; } #else /* USE_XIM */ len = XLookupString(ev, (char *)kbuf, KBUFSZ, &keysym, - &R->h->compose); + &R->compose); /* * map unmapped Latin[2-4]/Katakana/Arabic/Cyrillic/Greek entries -> Latin1 * good for installations with correct fonts, but without XLOCALE @@ -128,10 +128,10 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) # else if (meta) { # endif - if (keysym == R->h->ks_bigfont) { + if (keysym == R->ks_bigfont) { rxvt_change_font(aR_ 0, FONT_UP); return; - } else if (keysym == R->h->ks_smallfont) { + } else if (keysym == R->ks_smallfont) { rxvt_change_font(aR_ 0, FONT_DN); return; } @@ -188,7 +188,7 @@ 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->h->PrivateModes & PrivMode_ShiftKeys)) { + } else if (!ctrl && !meta && (R->PrivateModes & PrivMode_ShiftKeys)) { switch (keysym) { /* normal XTerm key bindings */ case XK_Insert: /* Shift+Insert = paste mouse selection */ @@ -211,9 +211,9 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) } #endif #ifdef GREEK_SUPPORT - if (keysym == R->h->ks_greekmodeswith) { - R->h->greek_mode = !R->h->greek_mode; - if (R->h->greek_mode) { + if (keysym == R->ks_greekmodeswith) { + R->greek_mode = !R->greek_mode; + if (R->greek_mode) { rxvt_xterm_seq(aR_ XTerm_title, (greek_getmode() == GREEK_ELOT928 ? "[Greek: iso]" : "[Greek: ibm]"), CHAR_ST); @@ -226,18 +226,18 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) if (keysym >= 0xFF00 && keysym <= 0xFFFF) { #ifdef KEYSYM_RESOURCE - if (!(shft | ctrl) && R->h->Keysym_map[keysym & 0xFF] != NULL) { + if (!(shft | ctrl) && R->Keysym_map[keysym & 0xFF] != NULL) { unsigned int l; const unsigned char *kbuf0; const unsigned char ch = C0_ESC; - kbuf0 = (R->h->Keysym_map[keysym & 0xFF]); + kbuf0 = (R->Keysym_map[keysym & 0xFF]); l = (unsigned int)*kbuf0++; /* escape prefix */ if (meta) # ifdef META8_OPTION - if (R->h->meta_char == C0_ESC) + if (R->meta_char == C0_ESC) # endif rxvt_tt_write(aR_ &ch, 1); rxvt_tt_write(aR_ kbuf0, l); @@ -249,12 +249,12 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) switch (keysym) { #ifndef NO_BACKSPACE_KEY case XK_BackSpace: - if (R->h->PrivateModes & PrivMode_HaveBackSpace) { - kbuf[0] = (!!(R->h->PrivateModes & PrivMode_BackSpace) + if (R->PrivateModes & PrivMode_HaveBackSpace) { + kbuf[0] = (!!(R->PrivateModes & PrivMode_BackSpace) ^ !!ctrl) ? '\b' : '\177'; kbuf[1] = '\0'; } else - STRCPY(kbuf, R->h->key_backspace); + STRCPY(kbuf, R->key_backspace); # ifdef MULTICHAR_SET if ((R->Options & Opt_mc_hack) && R->screen.cur.col > 0) { int col, row; @@ -270,7 +270,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) #endif #ifndef NO_DELETE_KEY case XK_Delete: - STRCPY(kbuf, R->h->key_delete); + STRCPY(kbuf, R->key_delete); # ifdef MULTICHAR_SET if (R->Options & Opt_mc_hack) { int col, row; @@ -306,7 +306,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->h->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033OZ"); kbuf[2] = ("txvr"[keysym - XK_KP_Left]); break; @@ -327,7 +327,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) else if (ctrl) { kbuf[1] = 'O'; kbuf[2] = ("dacb"[keysym - XK_Left]); - } else if (R->h->PrivateModes & PrivMode_aplCUR) + } else if (R->PrivateModes & PrivMode_aplCUR) kbuf[1] = 'O'; #ifdef MULTICHAR_SET //TODO: ?? @@ -365,7 +365,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) # ifdef XK_KP_Prior case XK_KP_Prior: /* allow shift to override */ - if ((R->h->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033Oy"); break; } @@ -377,7 +377,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) # ifdef XK_KP_Next case XK_KP_Next: /* allow shift to override */ - if ((R->h->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033Os"); break; } @@ -389,7 +389,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) #endif case XK_KP_Enter: /* allow shift to override */ - if ((R->h->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033OM"); } else { kbuf[0] = '\r'; @@ -435,7 +435,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->h->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033Oj"); kbuf[2] += (keysym - XK_KP_Multiply); } else { @@ -463,7 +463,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) #ifdef XK_KP_End case XK_KP_End: /* allow shift to override */ - if ((R->h->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033Oq"); break; } @@ -475,7 +475,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) #ifdef XK_KP_Home case XK_KP_Home: /* allow shift to override */ - if ((R->h->PrivateModes & PrivMode_aplKP) ? !shft : shft) { + if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { STRCPY(kbuf, "\033Ow"); break; } @@ -551,7 +551,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) * Pass meta for all function keys, if 'meta' option set */ #ifdef META8_OPTION - if (meta && (R->h->meta_char == 0x80) && len > 0) + if (meta && (R->meta_char == 0x80) && len > 0) kbuf[len - 1] |= 0x80; #endif } else if (ctrl && keysym == XK_minus) { @@ -560,7 +560,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) } else { #ifdef META8_OPTION /* set 8-bit on */ - if (meta && (R->h->meta_char == 0x80)) { + if (meta && (R->meta_char == 0x80)) { unsigned char *ch; for (ch = kbuf; ch < kbuf + len; ch++) @@ -569,7 +569,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) } #endif #ifdef GREEK_SUPPORT - if (R->h->greek_mode) + if (R->greek_mode) len = greek_xlat(kbuf, len); #endif /* nil */ ; @@ -582,7 +582,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) if (R->Options & Opt_scrollTtyKeypress) if (R->TermWin.view_start) { R->TermWin.view_start = 0; - R->h->want_refresh = 1; + R->want_refresh = 1; } /* @@ -602,7 +602,7 @@ rxvt_lookup_key(pR_ XKeyEvent *ev) /* escape prefix */ if (meta #ifdef META8_OPTION - && (R->h->meta_char == C0_ESC) + && (R->meta_char == C0_ESC) #endif ) { const unsigned char ch = C0_ESC; @@ -632,9 +632,9 @@ unsigned int rxvt_cmd_write(pR_ const unsigned char *str, unsigned int count) { unsigned int n, s; - unsigned char *cmdbuf_base = R->h->cmdbuf_base, - *cmdbuf_endp = R->h->cmdbuf_endp, - *cmdbuf_ptr = R->h->cmdbuf_ptr; + 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; @@ -651,34 +651,81 @@ rxvt_cmd_write(pR_ const unsigned char *str, unsigned int count) } for (; count--;) *cmdbuf_endp++ = *str++; - R->h->cmdbuf_ptr = cmdbuf_ptr; - R->h->cmdbuf_endp = cmdbuf_endp; + R->cmdbuf_ptr = cmdbuf_ptr; + R->cmdbuf_endp = cmdbuf_endp; return 0; } #endif /* MENUBAR_MAX */ +void +rxvt_term::process_x_events () +{ + do + { + XEvent xev; + + XNextEvent (Xdisplay, &xev); +#if defined(CURSOR_BLINK) + if ((Options & Opt_cursorBlink) + && xev.type == KeyPress) { + if (hidden_cursor) { + hidden_cursor = 0; + want_refresh = 1; + } + want_keypress_time = 1; + } +#endif + +#if defined(POINTER_BLANK) + if ((Options & Opt_pointerBlank) + && (pointerBlankDelay > 0)) { + if (xev.type == MotionNotify + || xev.type == ButtonPress + || xev.type == ButtonRelease) { + if (hidden_pointer) + rxvt_pointer_unblank(aR); + want_motion_time = 1; + } + if (xev.type == KeyPress && hidden_pointer == 0) + rxvt_pointer_blank (this); + } +#endif + +#ifdef USE_XIM + if (!XFilterEvent (&xev, xev.xany.window)) +#endif + rxvt_process_x_event (this, &xev); + } + while (XPending (Xdisplay)); +} + +void +rxvt_term::x_cb (io_watcher &w, short revents) +{ + process_x_events (); +} + // read the next character, currently handles UTF-8 // will probably handle all sorts of other stuff in the future static uint32_t next_char (pR) { - rxvt_hidden *h = R->h; - mbstate &s = h->mbstate; + mbstate &s = R->mbstate; - while (h->cmdbuf_ptr < h->cmdbuf_endp) + while (R->cmdbuf_ptr < R->cmdbuf_endp) { - uint8_t ch = *h->cmdbuf_ptr; + uint8_t ch = *R->cmdbuf_ptr; if (s.cnt) { if ((ch & 0xc0) == 0x80) { - h->cmdbuf_ptr++; + R->cmdbuf_ptr++; /* continuation */ s.reg = (s.reg << 6) | (ch & 0x7f); - if (--s.cnt == 0 && s.reg >= 128) /* if !inrange then corruption or hacking */ + if (--s.cnt == 0 && s.reg >= 128) /* if !inrange then corruption or Racking */ return s.reg; continue; @@ -692,7 +739,7 @@ next_char (pR) if ((ch & 0xc0) == 0xc0) { - h->cmdbuf_ptr++; + R->cmdbuf_ptr++; /* first byte */ s.orig = ch; /* for broken encodings */ @@ -705,7 +752,7 @@ next_char (pR) } else { - h->cmdbuf_ptr++; /* _occasional_ non-utf8 may slip through... */ + R->cmdbuf_ptr++; /* _occasional_ non-utf8 may slip through... */ return ch; } } @@ -713,6 +760,42 @@ next_char (pR) return NOCHAR; } +void +rxvt_term::pty_cb (io_watcher &w, short revents) +{ + int n; + unsigned int count; + + if (count = (cmdbuf_endp - cmdbuf_ptr)) + { + memmove (cmdbuf_base, cmdbuf_ptr, count); + cmdbuf_ptr = cmdbuf_base; + cmdbuf_endp = cmdbuf_ptr + count; + } + + + for (count = BUFSIZ - count; count; count -= n, cmdbuf_endp += n) + if ((n = read(cmd_fd, cmdbuf_endp, count)) > 0) + continue; + else if (n == 0 || (n < 0 && errno == EAGAIN)) + break; + else + { + rxvt_clean_exit(); + exit(EXIT_FAILURE); /* bad order of events? */ + } + + if (count != BUFSIZ) /* some characters read in */ + { + uint32_t c = next_char (this); + +#if 0 + if (c != NOCHAR) + return c; +#endif + } +} + /* rxvt_cmd_getc() - Return next input character */ /* * Return the next input character after first passing any keyboard input @@ -730,7 +813,6 @@ rxvt_cmd_getc(pR) #if defined(POINTER_BLANK) || defined(CURSOR_BLINK) struct timeval tp; #endif - struct rxvt_hidden *h = R->h; uint32_t c = next_char (aR); if (c != NOCHAR) @@ -739,7 +821,7 @@ rxvt_cmd_getc(pR) for (;;) { /* loop until we can return something */ - if (h->v_bufstr < h->v_bufptr) /* output any pending chars */ + if (R->v_bufstr < R->v_bufptr) /* output any pending chars */ rxvt_tt_write(aR_ NULL, 0); #if defined(POINTER_BLANK) || defined(CURSOR_BLINK) @@ -752,59 +834,28 @@ rxvt_cmd_getc(pR) want_motion_time = 0; #endif - while (XPending(R->Xdisplay)) { /* process pending X events */ - XEvent xev; + if (XPending (R->Xdisplay)) + { + R->process_x_events (); - XNextEvent(R->Xdisplay, &xev); -#if defined(CURSOR_BLINK) - if ((R->Options & Opt_cursorBlink) - && xev.type == KeyPress) { - if (h->hidden_cursor) { - h->hidden_cursor = 0; - h->want_refresh = 1; - } - want_keypress_time = 1; - } -#endif -#if defined(POINTER_BLANK) - if ((R->Options & Opt_pointerBlank) - && (h->pointerBlankDelay > 0)) { - if (xev.type == MotionNotify - || xev.type == ButtonPress - || xev.type == ButtonRelease) { - if (R->h->hidden_pointer) - rxvt_pointer_unblank(aR); - want_motion_time = 1; - } - if (xev.type == KeyPress && R->h->hidden_pointer == 0) - rxvt_pointer_blank(aR); - } -#endif -#ifdef USE_XIM - if (!XFilterEvent(&xev, xev.xany.window)) - rxvt_process_x_event(aR_ &xev); - h->event_type = xev.type; -#else - rxvt_process_x_event(aR_ &xev); -#endif - /* in case button actions pushed chars to cmdbuf */ - if (h->cmdbuf_ptr < h->cmdbuf_endp) - return *h->cmdbuf_ptr++; - } + /* in case button actions pushed chars to cmdbuf */ + if (R->cmdbuf_ptr < R->cmdbuf_endp) + return *R->cmdbuf_ptr++; + } #if defined(CURSOR_BLINK) if (want_keypress_time) { (void)gettimeofday(&tp, NULL); - h->lastcursorchange.tv_sec = tp.tv_sec; - h->lastcursorchange.tv_usec = tp.tv_usec; + R->lastcursorchange.tv_sec = tp.tv_sec; + R->lastcursorchange.tv_usec = tp.tv_usec; } #endif #if defined(POINTER_BLANK) if (want_motion_time) { if (!tp.tv_sec) (void)gettimeofday(&tp, NULL); - h->lastmotion.tv_sec = tp.tv_sec; - h->lastmotion.tv_usec = tp.tv_usec; + R->lastmotion.tv_sec = tp.tv_sec; + R->lastmotion.tv_usec = tp.tv_usec; } #endif @@ -814,39 +865,39 @@ rxvt_cmd_getc(pR) quick_timeout = 0; #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) - if (h->mouse_slip_wheel_speed) { + if (R->mouse_slip_wheel_speed) { quick_timeout = 1; - if (!h->mouse_slip_wheel_delay-- - && rxvt_scr_page(aR_ h->mouse_slip_wheel_speed > 0 ? UP : DN, - abs(h->mouse_slip_wheel_speed))) { - h->mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; - h->refresh_type |= SMOOTH_REFRESH; - h->want_refresh = 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; } } #endif /* MOUSE_WHEEL && MOUSE_SLIP_WHEELING */ #ifdef SELECTION_SCROLLING - if (h->pending_scroll_selection) { + if (R->pending_scroll_selection) { quick_timeout = 1; - if (!h->scroll_selection_delay-- - && rxvt_scr_page(aR_ h->scroll_selection_dir, - h->scroll_selection_lines)) { - rxvt_selection_extend(aR_ h->selection_save_x, - h->selection_save_y, h->selection_save_state); - h->scroll_selection_delay = SCROLLBAR_CONTINUOUS_DELAY; - h->refresh_type |= SMOOTH_REFRESH; - h->want_refresh = 1; + if (!R->scroll_selection_delay-- + && rxvt_scr_page(aR_ R->scroll_selection_dir, + R->scroll_selection_lines)) { + rxvt_selection_extend(aR_ 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; } } #endif #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING if (scrollbar_isUp() || scrollbar_isDn()) { quick_timeout = 1; - if (!h->scroll_arrow_delay-- + if (!R->scroll_arrow_delay-- && rxvt_scr_page(aR_ scrollbar_isUp() ? UP : DN, 1)) { - h->scroll_arrow_delay = SCROLLBAR_CONTINUOUS_DELAY; - h->refresh_type |= SMOOTH_REFRESH; - h->want_refresh = 1; + R->scroll_arrow_delay = SCROLLBAR_CONTINUOUS_DELAY; + R->refresh_type |= SMOOTH_REFRESH; + R->want_refresh = 1; } } #endif /* NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING */ @@ -860,9 +911,9 @@ rxvt_cmd_getc(pR) if (!R->TermWin.mapped) quick_timeout = 0; else { - quick_timeout |= h->want_refresh; + quick_timeout |= R->want_refresh; #ifdef TRANSPARENT - quick_timeout |= h->want_full_refresh; + quick_timeout |= R->want_full_refresh; #endif } @@ -878,12 +929,12 @@ rxvt_cmd_getc(pR) if (!tp.tv_sec) /* didn't get it before so get it now */ (void)gettimeofday(&tp, NULL); - csdiff = (tp.tv_sec - h->lastcursorchange.tv_sec) * 1000000L - + tp.tv_usec - h->lastcursorchange.tv_usec; + csdiff = (tp.tv_sec - R->lastcursorchange.tv_sec) * 1000000L + + tp.tv_usec - R->lastcursorchange.tv_usec; if (csdiff > BLINK_TIME) { /* XXX: settable blink times */ - h->lastcursorchange.tv_sec = tp.tv_sec; - h->lastcursorchange.tv_usec = tp.tv_usec; - h->hidden_cursor = !h->hidden_cursor; + R->lastcursorchange.tv_sec = tp.tv_sec; + R->lastcursorchange.tv_usec = tp.tv_usec; + R->hidden_cursor = !R->hidden_cursor; csdiff = 0; } else csdiff = BLINK_TIME - csdiff; @@ -895,15 +946,15 @@ rxvt_cmd_getc(pR) * If we haven't moved the pointer for a while */ if ((R->Options & Opt_pointerBlank) - && (h->pointerBlankDelay > 0) - && (h->hidden_pointer == 0)) { + && (R->pointerBlankDelay > 0) + && (R->hidden_pointer == 0)) { long pdelay; if (!tp.tv_sec) /* didn't get it before so get it now */ (void)gettimeofday(&tp, NULL); - psdiff = (tp.tv_sec - h->lastmotion.tv_sec) * 1000000L - + tp.tv_usec - h->lastmotion.tv_usec; - pdelay = h->pointerBlankDelay * 1000000L; + psdiff = (tp.tv_sec - R->lastmotion.tv_sec) * 1000000L + + tp.tv_usec - R->lastmotion.tv_usec; + pdelay = R->pointerBlankDelay * 1000000L; if (psdiff >= pdelay) rxvt_pointer_blank(aR); else { @@ -924,11 +975,11 @@ rxvt_cmd_getc(pR) if ((select_res = select(R->num_fds, &readfds, NULL, NULL, (quick_timeout ? &value : NULL))) == 0) { /* select statement timed out - we're not hard and fast scrolling */ - h->refresh_limit = 1; + R->refresh_limit = 1; } #if defined(CURSOR_BLINK) if (R->Options & Opt_cursorBlink) - h->want_refresh = 1; + R->want_refresh = 1; #endif /* See if we can read new data from the application */ @@ -936,9 +987,9 @@ rxvt_cmd_getc(pR) int n; unsigned int count; - h->cmdbuf_ptr = h->cmdbuf_endp = h->cmdbuf_base; - for (count = BUFSIZ; count; count -= n, h->cmdbuf_endp += n) - if ((n = read(R->cmd_fd, h->cmdbuf_endp, count)) > 0) + R->cmdbuf_ptr = R->cmdbuf_endp = R->cmdbuf_base; + for (count = BUFSIZ; count; count -= n, R->cmdbuf_endp += n) + if ((n = read(R->cmd_fd, R->cmdbuf_endp, count)) > 0) continue; else if (n == 0 || (n < 0 && errno == EAGAIN)) break; @@ -955,15 +1006,15 @@ rxvt_cmd_getc(pR) } } #ifdef TRANSPARENT - if (h->want_full_refresh) { - h->want_full_refresh = 0; + if (R->want_full_refresh) { + R->want_full_refresh = 0; rxvt_scr_clear(aR); rxvt_scr_touch(aR_ False); - h->want_refresh = 1; + R->want_refresh = 1; } #endif - if (h->want_refresh) { - rxvt_scr_refresh(aR_ h->refresh_type); + if (R->want_refresh) { + rxvt_scr_refresh(aR_ R->refresh_type); rxvt_scrollbar_show(aR_ 1); #ifdef USE_XIM rxvt_IMSendSpot(aR); @@ -981,13 +1032,13 @@ rxvt_pointer_unblank(pR) XDefineCursor(R->Xdisplay, R->TermWin.vt, R->TermWin_cursor); rxvt_recolour_cursor(aR); #ifdef POINTER_BLANK - R->h->hidden_pointer = 0; - if (R->h->pointerBlankDelay > 0) { + R->hidden_pointer = 0; + if (R->pointerBlankDelay > 0) { struct timeval tp; (void)gettimeofday(&tp, NULL); - R->h->lastmotion.tv_sec = tp.tv_sec; - R->h->lastmotion.tv_usec = tp.tv_usec; + R->lastmotion.tv_sec = tp.tv_sec; + R->lastmotion.tv_usec = tp.tv_usec; } #endif } @@ -997,9 +1048,9 @@ rxvt_pointer_unblank(pR) void rxvt_pointer_blank(pR) { - XDefineCursor(R->Xdisplay, R->TermWin.vt, R->h->pointer_blank); + XDefineCursor(R->Xdisplay, R->TermWin.vt, R->pointer_blank); XFlush(R->Xdisplay); - R->h->hidden_pointer = 1; + R->hidden_pointer = 1; } #endif @@ -1014,16 +1065,16 @@ rxvt_mouse_report(pR_ const XButtonEvent *ev) y = ev->y; rxvt_pixel_position(aR_ &x, &y); - if (R->h->MEvent.button == AnyButton) { + if (R->MEvent.button == AnyButton) { button_number = 3; } else { - button_number = R->h->MEvent.button - Button1; + button_number = R->MEvent.button - Button1; /* add 0x3D for wheel events, like xterm does */ if (button_number >= 3) button_number += (64 - 3); } - if (R->h->PrivateModes & PrivMode_MouseX10) { + if (R->PrivateModes & PrivMode_MouseX10) { /* * do not report ButtonRelease * no state info allowed @@ -1039,11 +1090,11 @@ rxvt_mouse_report(pR_ const XButtonEvent *ev) * plus will add in our own Double-Click reporting * 32 = Double Click */ - key_state = ((R->h->MEvent.state & ShiftMask) ? 4 : 0) - + ((R->h->MEvent.state & R->h->ModMetaMask) ? 8 : 0) - + ((R->h->MEvent.state & ControlMask) ? 16 : 0); + key_state = ((R->MEvent.state & ShiftMask) ? 4 : 0) + + ((R->MEvent.state & R->ModMetaMask) ? 8 : 0) + + ((R->MEvent.state & ControlMask) ? 16 : 0); #ifdef MOUSE_REPORT_DOUBLECLICK - key_state += ((R->h->MEvent.clicks > 1) ? 32 : 0); + key_state += ((R->MEvent.clicks > 1) ? 32 : 0); #endif } @@ -1090,7 +1141,7 @@ rxvt_process_x_event(pR_ XEvent *ev) int unused_root_x, unused_root_y; unsigned int unused_mask; struct timeval tp; - struct rxvt_hidden *h = R->h; + #ifdef DEBUG_X const char *const eventnames[] = { /* mason - this matches my system */ @@ -1138,7 +1189,7 @@ rxvt_process_x_event(pR_ XEvent *ev) */ for (i = NUM_TIMEOUTS; i--; ) - if (h->timeout[i].tv_sec) { + if (R->timeout[i].tv_sec) { want_timeout = 1; break; } @@ -1156,17 +1207,17 @@ rxvt_process_x_event(pR_ XEvent *ev) /* X event timeouts */ if (want_timeout) for (i = NUM_TIMEOUTS; i--; ) { - if (h->timeout[i].tv_sec == 0) + if (R->timeout[i].tv_sec == 0) continue; - if ((tp.tv_sec < h->timeout[i].tv_sec) - || (tp.tv_sec == h->timeout[i].tv_sec - && tp.tv_usec < h->timeout[i].tv_usec)) + if ((tp.tv_sec < R->timeout[i].tv_sec) + || (tp.tv_sec == R->timeout[i].tv_sec + && tp.tv_usec < R->timeout[i].tv_usec)) continue; - h->timeout[i].tv_sec = 0; + R->timeout[i].tv_sec = 0; switch(i) { case TIMEOUT_INCR: rxvt_print_error("data loss: timeout on INCR selection paste"); - h->selection_wait = Sel_none; + R->selection_wait = Sel_none; break; default: break; @@ -1182,13 +1233,13 @@ rxvt_process_x_event(pR_ XEvent *ev) case KeyRelease: { if (!(ev->xkey.state & ControlMask)) - h->mouse_slip_wheel_speed = 0; + R->mouse_slip_wheel_speed = 0; else { KeySym ks; ks = XKeycodeToKeysym(R->Xdisplay, ev->xkey.keycode, 0); if (ks == XK_Control_L || ks == XK_Control_R) - h->mouse_slip_wheel_speed = 0; + R->mouse_slip_wheel_speed = 0; } break; } @@ -1204,11 +1255,11 @@ rxvt_process_x_event(pR_ XEvent *ev) case ClientMessage: if (ev->xclient.format == 32 - && (Atom)ev->xclient.data.l[0] == h->xa[XA_WMDELETEWINDOW]) + && (Atom)ev->xclient.data.l[0] == R->xa[XA_WMDELETEWINDOW]) exit(EXIT_SUCCESS); #ifdef OFFIX_DND /* OffiX Dnd (drag 'n' drop) protocol */ - if (ev->xclient.message_type == h->xa[XA_DNDPROTOCOL] + if (ev->xclient.message_type == R->xa[XA_DNDPROTOCOL] && (ev->xclient.data.l[0] == DndFile || ev->xclient.data.l[0] == DndDir || ev->xclient.data.l[0] == DndLink)) { @@ -1219,7 +1270,7 @@ rxvt_process_x_event(pR_ XEvent *ev) unsigned long Size, RemainingBytes; XGetWindowProperty(R->Xdisplay, Xroot, - R->h->xa[XA_DNDSELECTION], + R->xa[XA_DNDSELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType, &ActualFormat, @@ -1252,13 +1303,13 @@ rxvt_process_x_event(pR_ XEvent *ev) case VisibilityNotify: switch (ev->xvisibility.state) { case VisibilityUnobscured: - h->refresh_type = FAST_REFRESH; + R->refresh_type = FAST_REFRESH; break; case VisibilityPartiallyObscured: - h->refresh_type = SLOW_REFRESH; + R->refresh_type = SLOW_REFRESH; break; default: - h->refresh_type = NO_REFRESH; + R->refresh_type = NO_REFRESH; break; } break; @@ -1266,10 +1317,10 @@ rxvt_process_x_event(pR_ XEvent *ev) case FocusIn: if (!R->TermWin.focus) { R->TermWin.focus = 1; - h->want_refresh = 1; + R->want_refresh = 1; #ifdef USE_XIM - if (h->Input_Context != NULL) - XSetICFocus(h->Input_Context); + if (R->Input_Context != NULL) + XSetICFocus(R->Input_Context); #endif } break; @@ -1277,10 +1328,10 @@ rxvt_process_x_event(pR_ XEvent *ev) case FocusOut: if (R->TermWin.focus) { R->TermWin.focus = 0; - h->want_refresh = 1; + R->want_refresh = 1; #ifdef USE_XIM - if (h->Input_Context != NULL) - XUnsetICFocus(h->Input_Context); + if (R->Input_Context != NULL) + XUnsetICFocus(R->Input_Context); #endif } break; @@ -1308,8 +1359,8 @@ rxvt_process_x_event(pR_ XEvent *ev) #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ if (R->Options & Opt_transparent) { rxvt_check_our_parents(aR); - if (h->am_transparent) - h->want_full_refresh = 1; + if (R->am_transparent) + R->want_full_refresh = 1; } #endif } @@ -1320,7 +1371,7 @@ rxvt_process_x_event(pR_ XEvent *ev) break; case SelectionNotify: - if (h->selection_wait == Sel_normal) + if (R->selection_wait == Sel_normal) rxvt_selection_paste(aR_ ev->xselection.requestor, ev->xselection.property, True); break; @@ -1338,7 +1389,7 @@ rxvt_process_x_event(pR_ XEvent *ev) break; case PropertyNotify: - if (ev->xproperty.atom == h->xa[XA_VT_SELECTION]) { + if (ev->xproperty.atom == R->xa[XA_VT_SELECTION]) { if (ev->xproperty.state == PropertyNewValue) rxvt_selection_property(aR_ ev->xproperty.window, ev->xproperty.atom); @@ -1349,16 +1400,16 @@ 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 (h->xa[XA_XROOTPMAPID] == 0) - h->xa[XA_XROOTPMAPID] = XInternAtom(R->Xdisplay, + if (R->xa[XA_XROOTPMAPID] == 0) + R->xa[XA_XROOTPMAPID] = XInternAtom(R->Xdisplay, "_XROOTPMAP_ID", False); - if (ev->xproperty.atom != h->xa[XA_XROOTPMAPID]) + if (ev->xproperty.atom != R->xa[XA_XROOTPMAPID]) break; /* FALLTHROUGH */ case ReparentNotify: if ((R->Options & Opt_transparent) && rxvt_check_our_parents(aR)) { - if (h->am_transparent) - h->want_full_refresh = 1; + if (R->am_transparent) + R->want_full_refresh = 1; } #endif /* TRANSPARENT */ break; @@ -1376,7 +1427,7 @@ rxvt_process_x_event(pR_ XEvent *ev) //rxvt_scr_expose(aR_ ev->xexpose.x, 0, // ev->xexpose.width, R->TermWin.height, False); #endif - h->want_refresh = 1; + R->want_refresh = 1; } else { XEvent unused_xevent; @@ -1402,7 +1453,7 @@ rxvt_process_x_event(pR_ XEvent *ev) case MotionNotify: #ifdef POINTER_BLANK - if (R->h->hidden_pointer) + if (R->hidden_pointer) rxvt_pointer_unblank(aR); #endif #if MENUBAR @@ -1411,7 +1462,7 @@ rxvt_process_x_event(pR_ XEvent *ev) break; } #endif - if ((h->PrivateModes & PrivMode_mouse_report) && !(h->bypass_keystate)) + if ((R->PrivateModes & PrivMode_mouse_report) && !(R->bypass_keystate)) break; if (ev->xany.window == R->TermWin.vt) { @@ -1425,7 +1476,7 @@ rxvt_process_x_event(pR_ XEvent *ev) &unused_mask); #ifdef MOUSE_THRESHOLD /* deal with a `jumpy' mouse */ - if ((ev->xmotion.time - h->MEvent.time) > MOUSE_THRESHOLD) { + if ((ev->xmotion.time - R->MEvent.time) > MOUSE_THRESHOLD) { #endif rxvt_selection_extend(aR_ (ev->xbutton.x), (ev->xbutton.y), (ev->xbutton.state & Button3Mask) ? 2 : 0); @@ -1434,42 +1485,42 @@ rxvt_process_x_event(pR_ XEvent *ev) Pixel2Row(ev->xbutton.y)>(R->TermWin.nrow-1)) { int dist; - h->pending_scroll_selection=1; + R->pending_scroll_selection=1; /* don't clobber the current delay if we are * already in the middle of scrolling. */ - if (h->scroll_selection_delay<=0) - h->scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY; + if (R->scroll_selection_delay<=0) + R->scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY; /* save the event params so we can highlight * the selection in the pending-scroll loop */ - h->selection_save_x=ev->xbutton.x; - h->selection_save_y=ev->xbutton.y; - h->selection_save_state= + R->selection_save_x=ev->xbutton.x; + R->selection_save_y=ev->xbutton.y; + R->selection_save_state= (ev->xbutton.state & Button3Mask) ? 2 : 0; /* calc number of lines to scroll */ if (ev->xbutton.yTermWin.int_bwidth) { - h->scroll_selection_dir = UP; + R->scroll_selection_dir = UP; dist = R->TermWin.int_bwidth - ev->xbutton.y; } else { - h->scroll_selection_dir = DN; + R->scroll_selection_dir = DN; dist = ev->xbutton.y - (R->TermWin.int_bwidth + R->TermWin.height); } - h->scroll_selection_lines=(Pixel2Height(dist)/ + R->scroll_selection_lines=(Pixel2Height(dist)/ SELECTION_SCROLL_LINE_SPEEDUP)+1; - MIN_IT(h->scroll_selection_lines, + MIN_IT(R->scroll_selection_lines, SELECTION_SCROLL_MAX_LINES); } else { /* we are within the text window, so we * shouldn't be scrolling */ - h->pending_scroll_selection = 0; + R->pending_scroll_selection = 0; } #endif #ifdef MOUSE_THRESHOLD @@ -1484,10 +1535,10 @@ rxvt_process_x_event(pR_ XEvent *ev) &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); - rxvt_scr_move_to(aR_ scrollbar_position(ev->xbutton.y) - h->csrO, + rxvt_scr_move_to(aR_ scrollbar_position(ev->xbutton.y) - R->csrO, scrollbar_size()); - rxvt_scr_refresh(aR_ h->refresh_type); - h->refresh_limit = 0; + rxvt_scr_refresh(aR_ R->refresh_type); + R->refresh_limit = 0; rxvt_scrollbar_show(aR_ 1); } break; @@ -1499,11 +1550,10 @@ void rxvt_button_press(pR_ XButtonEvent *ev) { int reportmode = 0, clickintime; - struct rxvt_hidden *h = R->h; - h->bypass_keystate = ev->state & (h->ModMetaMask | ShiftMask); - if (!h->bypass_keystate) - reportmode = !!(h->PrivateModes & PrivMode_mouse_report); + R->bypass_keystate = ev->state & (R->ModMetaMask | ShiftMask); + if (!R->bypass_keystate) + reportmode = !!(R->PrivateModes & PrivMode_mouse_report); /* * VT window processing of button press */ @@ -1515,65 +1565,65 @@ rxvt_button_press(pR_ XButtonEvent *ev) else #endif { - clickintime = ev->time - h->MEvent.time < MULTICLICK_TIME; + clickintime = ev->time - R->MEvent.time < MULTICLICK_TIME; if (reportmode) { /* mouse report from vt window */ /* save the xbutton state (for ButtonRelease) */ - h->MEvent.state = ev->state; + R->MEvent.state = ev->state; #ifdef MOUSE_REPORT_DOUBLECLICK - if (ev->button == h->MEvent.button && clickintime) + if (ev->button == R->MEvent.button && clickintime) { /* same button, within alloted time */ - h->MEvent.clicks++; - if (h->MEvent.clicks > 1) + R->MEvent.clicks++; + if (R->MEvent.clicks > 1) { /* only report double clicks */ - h->MEvent.clicks = 2; + R->MEvent.clicks = 2; rxvt_mouse_report(aR_ ev); /* don't report the release */ - h->MEvent.clicks = 0; - h->MEvent.button = AnyButton; + R->MEvent.clicks = 0; + R->MEvent.button = AnyButton; } } else { /* different button, or time expired */ - h->MEvent.clicks = 1; - h->MEvent.button = ev->button; + R->MEvent.clicks = 1; + R->MEvent.button = ev->button; rxvt_mouse_report(aR_ ev); } #else - h->MEvent.button = ev->button; + R->MEvent.button = ev->button; rxvt_mouse_report(aR_ ev); #endif /* MOUSE_REPORT_DOUBLECLICK */ } else { - if (ev->button != h->MEvent.button) - h->MEvent.clicks = 0; + if (ev->button != R->MEvent.button) + R->MEvent.clicks = 0; switch (ev->button) { case Button1: - if (h->MEvent.button == Button1 && clickintime) - h->MEvent.clicks++; + if (R->MEvent.button == Button1 && clickintime) + R->MEvent.clicks++; else - h->MEvent.clicks = 1; - rxvt_selection_click(aR_ h->MEvent.clicks, ev->x, ev->y); - h->MEvent.button = Button1; + R->MEvent.clicks = 1; + rxvt_selection_click(aR_ R->MEvent.clicks, ev->x, ev->y); + R->MEvent.button = Button1; break; case Button3: - if (h->MEvent.button == Button3 && clickintime) + if (R->MEvent.button == Button3 && clickintime) rxvt_selection_rotate(aR_ ev->x, ev->y); else rxvt_selection_extend(aR_ ev->x, ev->y, 1); - h->MEvent.button = Button3; + R->MEvent.button = Button3; break; } } - h->MEvent.time = ev->time; + R->MEvent.time = ev->time; return; } } @@ -1642,7 +1692,7 @@ rxvt_button_press(pR_ XButtonEvent *ev) } if (upordown) { #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - h->scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; + R->scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; #endif if (rxvt_scr_page(aR_ upordown < 0 ? UP : DN, 1)) { if (upordown < 0) @@ -1653,29 +1703,29 @@ rxvt_button_press(pR_ XButtonEvent *ev) } else switch (ev->button) { case Button2: - switch (h->scrollbar_align) { + switch (R->scrollbar_align) { case R_SB_ALIGN_TOP: - h->csrO = 0; + R->csrO = 0; break; case R_SB_ALIGN_CENTRE: - h->csrO = (R->scrollBar.bot - R->scrollBar.top) / 2; + R->csrO = (R->scrollBar.bot - R->scrollBar.top) / 2; break; case R_SB_ALIGN_BOTTOM: - h->csrO = R->scrollBar.bot - R->scrollBar.top; + R->csrO = R->scrollBar.bot - R->scrollBar.top; break; } if (R->scrollBar.style == R_SB_XTERM || scrollbar_above_slider(ev->y) || scrollbar_below_slider(ev->y)) rxvt_scr_move_to(aR_ - scrollbar_position(ev->y) - h->csrO, + scrollbar_position(ev->y) - R->csrO, scrollbar_size()); scrollbar_setMotion(); break; case Button1: - if (h->scrollbar_align == R_SB_ALIGN_CENTRE) - h->csrO = ev->y - R->scrollBar.top; + if (R->scrollbar_align == R_SB_ALIGN_CENTRE) + R->csrO = ev->y - R->scrollBar.top; /* FALLTHROUGH */ case Button3: @@ -1720,19 +1770,19 @@ rxvt_button_release(pR_ XButtonEvent *ev) { int reportmode = 0; - R->h->csrO = 0; /* reset csr Offset */ - if (!R->h->bypass_keystate) - reportmode = !!(R->h->PrivateModes & PrivMode_mouse_report); + R->csrO = 0; /* reset csr Offset */ + if (!R->bypass_keystate) + reportmode = !!(R->PrivateModes & PrivMode_mouse_report); if (scrollbar_isUpDn()) { scrollbar_setIdle(); rxvt_scrollbar_show(aR_ 0); #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - R->h->refresh_type &= ~SMOOTH_REFRESH; + R->refresh_type &= ~SMOOTH_REFRESH; #endif } #ifdef SELECTION_SCROLLING - R->h->pending_scroll_selection=0; + R->pending_scroll_selection=0; #endif if (ev->window == R->TermWin.vt) { @@ -1750,17 +1800,17 @@ rxvt_button_release(pR_ XButtonEvent *ev) return; #ifdef MOUSE_REPORT_DOUBLECLICK /* only report the release of 'slow' single clicks */ - if (R->h->MEvent.button != AnyButton - && (ev->button != R->h->MEvent.button - || (ev->time - R->h->MEvent.time + if (R->MEvent.button != AnyButton + && (ev->button != R->MEvent.button + || (ev->time - R->MEvent.time > MULTICLICK_TIME / 2))) { - R->h->MEvent.clicks = 0; - R->h->MEvent.button = AnyButton; + R->MEvent.clicks = 0; + R->MEvent.button = AnyButton; rxvt_mouse_report(aR_ ev); } #else /* MOUSE_REPORT_DOUBLECLICK */ - R->h->MEvent.button = AnyButton; + R->MEvent.button = AnyButton; rxvt_mouse_report(aR_ ev); #endif /* MOUSE_REPORT_DOUBLECLICK */ return; @@ -1769,9 +1819,9 @@ rxvt_button_release(pR_ XButtonEvent *ev) * dumb hack to compensate for the failure of click-and-drag * when overriding mouse reporting */ - if (R->h->PrivateModes & PrivMode_mouse_report - && R->h->bypass_keystate - && ev->button == Button1 && R->h->MEvent.clicks <= 1) + if (R->PrivateModes & PrivMode_mouse_report + && R->bypass_keystate + && ev->button == Button1 && R->MEvent.clicks <= 1) rxvt_selection_extend(aR_ ev->x, ev->y, 0); switch (ev->button) { @@ -1798,8 +1848,8 @@ rxvt_button_release(pR_ XButtonEvent *ev) # ifdef MOUSE_SLIP_WHEELING if (ev->state & ControlMask) { - R->h->mouse_slip_wheel_speed += (v ? -1 : 1); - R->h->mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; + R->mouse_slip_wheel_speed += (v ? -1 : 1); + R->mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; } # endif # ifdef JUMP_MOUSE_WHEEL @@ -1854,11 +1904,11 @@ rxvt_check_our_parents(pR) XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[0], &wattr); if (rootdepth != wattr.depth) { - if (R->h->am_transparent) { + if (R->am_transparent) { pchanged = 1; XSetWindowBackground(R->Xdisplay, R->TermWin.vt, R->PixColors[Color_bg]); - R->h->am_transparent = R->h->am_pixmap_trans = 0; + R->am_transparent = R->am_pixmap_trans = 0; } return pchanged; /* Don't try any more */ } @@ -1871,8 +1921,8 @@ rxvt_check_our_parents(pR) * the root background. Some window managers put multiple nested frame * windows for each client, so we have to take care about that. */ - i = (R->h->xa[XA_XROOTPMAPID] != 0 - && (XGetWindowProperty(R->Xdisplay, Xroot, R->h->xa[XA_XROOTPMAPID], + i = (R->xa[XA_XROOTPMAPID] != 0 + && (XGetWindowProperty(R->Xdisplay, Xroot, R->xa[XA_XROOTPMAPID], 0L, 1L, False, XA_PIXMAP, &atype, &aformat, &nitems, &bytes_after, &prop) == Success)); if (!i || prop == NULL) @@ -1910,21 +1960,21 @@ rxvt_check_our_parents(pR) } MIN_IT(nw, (unsigned int)(wrootattr.width - sx)); MIN_IT(nh, (unsigned int)(wrootattr.height - sy)); - R->h->allowedxerror = -1; + R->allowedxerror = -1; image = XGetImage(R->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->h->allowedxerror = 0; + R->allowedxerror = 0; if (image == NULL) { - if (R->h->am_transparent && R->h->am_pixmap_trans) { + if (R->am_transparent && R->am_pixmap_trans) { pchanged = 1; if (R->TermWin.pixmap != None) { XFreePixmap(R->Xdisplay, R->TermWin.pixmap); R->TermWin.pixmap = None; } } - R->h->am_pixmap_trans = 0; + R->am_pixmap_trans = 0; } else { if (R->TermWin.pixmap != None) XFreePixmap(R->Xdisplay, R->TermWin.pixmap); @@ -1940,12 +1990,12 @@ rxvt_check_our_parents(pR) XDestroyImage(image); XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.vt, R->TermWin.pixmap); - if (!R->h->am_transparent || !R->h->am_pixmap_trans) + if (!R->am_transparent || !R->am_pixmap_trans) pchanged = 1; - R->h->am_transparent = R->h->am_pixmap_trans = 1; + R->am_transparent = R->am_pixmap_trans = 1; } } - if (!R->h->am_pixmap_trans) { + if (!R->am_pixmap_trans) { unsigned int n; /* * InheritPixmap transparency @@ -1984,7 +2034,7 @@ rxvt_check_our_parents(pR) R->PixColors[Color_fg]); XSetWindowBackground(R->Xdisplay, R->TermWin.vt, R->PixColors[Color_bg]); - R->h->am_transparent = 0; + R->am_transparent = 0; /* XXX: also turn off Opt_transparent? */ } else { /* wait (an arbitrary period) for the WM to do its thing @@ -2004,7 +2054,7 @@ rxvt_check_our_parents(pR) ParentRelative); XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.vt, ParentRelative); - R->h->am_transparent = 1; + R->am_transparent = 1; } for (; i < (int)(sizeof(R->TermWin.parent) / sizeof(Window)); i++) R->TermWin.parent[i] = None; @@ -2022,7 +2072,7 @@ rxvt_check_our_parents(pR) FILE * rxvt_popen_printer(pR) { - FILE *stream = popen(R->h->rs[Rs_print_pipe], "w"); + FILE *stream = popen(R->rs[Rs_print_pipe], "w"); if (stream == NULL) rxvt_print_error("can't open printer pipe"); @@ -2111,10 +2161,10 @@ rxvt_process_nonprinting(pR_ unsigned char ch) { switch (ch) { case C0_ENQ: /* terminal Status */ - if (R->h->rs[Rs_answerbackstring]) + if (R->rs[Rs_answerbackstring]) rxvt_tt_write(aR_ - (const unsigned char *)R->h->rs[Rs_answerbackstring], - (unsigned int)STRLEN(R->h->rs[Rs_answerbackstring])); + (const unsigned char *)R->rs[Rs_answerbackstring], + (unsigned int)STRLEN(R->rs[Rs_answerbackstring])); else rxvt_tt_write(aR_ (unsigned char *)VT100_ANS, (unsigned int)STRLEN(VT100_ANS)); @@ -2214,7 +2264,7 @@ rxvt_process_escape_seq(pR) { unsigned char ch = rxvt_cmd_getc(aR); - if (R->h->PrivateModes & PrivMode_vt52) { + if (R->PrivateModes & PrivMode_vt52) { rxvt_process_escape_vt52(aR_ ch); return; } @@ -2572,7 +2622,7 @@ rxvt_process_csi_seq(pR) break; #if defined (ENABLE_DISPLAY_ANSWER) case 7: /* unofficial extension */ - rxvt_tt_printf(aR_ "%-.250s\n", R->h->rs[Rs_display_name]); + rxvt_tt_printf(aR_ "%-.250s\n", R->rs[Rs_display_name]); break; #endif case 8: /* unofficial extension */ @@ -2979,13 +3029,13 @@ rxvt_privcases(pR_ int mode, unsigned long bit) int state; if (mode == 's') { - R->h->SavedModes |= (R->h->PrivateModes & bit); + R->SavedModes |= (R->PrivateModes & bit); return -1; } else { if (mode == 'r') - state = (R->h->SavedModes & bit) ? 1 : 0; /* no overlapping */ + state = (R->SavedModes & bit) ? 1 : 0; /* no overlapping */ else - state = (mode == 't') ? !(R->h->PrivateModes & bit) : mode; + state = (mode == 't') ? !(R->PrivateModes & bit) : mode; PrivMode(state, bit); } return state; @@ -3073,7 +3123,7 @@ rxvt_process_terminal_mode(pR_ int mode, int priv __attribute__((unused)), unsig PrivMode(1, PrivMode_vt52); break; case 3: /* 80/132 */ - if (R->h->PrivateModes & PrivMode_132OK) + if (R->PrivateModes & PrivMode_132OK) rxvt_set_widthheight(aR_ (unsigned int)((state ? 132 : 80) * R->TermWin.fwidth), (unsigned int)R->TermWin.height); @@ -3096,7 +3146,7 @@ rxvt_process_terminal_mode(pR_ int mode, int priv __attribute__((unused)), unsig /* case 8: - auto repeat, can't do on a per window basis */ case 9: /* X10 mouse reporting */ if (state) /* orthogonal */ - R->h->PrivateModes &= ~(PrivMode_MouseX11); + R->PrivateModes &= ~(PrivMode_MouseX11); break; #ifdef menuBar_esc case menuBar_esc: @@ -3125,7 +3175,7 @@ rxvt_process_terminal_mode(pR_ int mode, int priv __attribute__((unused)), unsig /* case 67: - backspace key */ case 1000: /* X11 mouse reporting */ if (state) /* orthogonal */ - R->h->PrivateModes &= ~(PrivMode_MouseX10); + R->PrivateModes &= ~(PrivMode_MouseX10); break; #if 0 case 1001: @@ -3144,7 +3194,7 @@ rxvt_process_terminal_mode(pR_ int mode, int priv __attribute__((unused)), unsig R->Options &= ~Opt_scrollTtyKeypress; break; case 1047: /* secondary screen w/ clearing */ - if (R->h->current_screen != PRIMARY) + if (R->current_screen != PRIMARY) rxvt_scr_erase_screen(aR_ 2); rxvt_scr_change_screen(aR_ state); /* FALLTHROUGH */ @@ -3351,13 +3401,12 @@ rxvt_main_loop(pR) { uint32_t ch, *str, buf[BUFSIZ]; int nlines, refreshnow; - struct rxvt_hidden *h = R->h; - h->cmdbuf_ptr = h->cmdbuf_endp = h->cmdbuf_base; + R->cmdbuf_ptr = R->cmdbuf_endp = R->cmdbuf_base; /* once we know the shell is running, send the screen size. Again! */ ch = rxvt_cmd_getc(aR); /* wait for something */ - rxvt_tt_winsize(R->cmd_fd, R->TermWin.ncol, R->TermWin.nrow, R->h->cmd_pid); + rxvt_tt_winsize(R->cmd_fd, R->TermWin.ncol, R->TermWin.nrow, R->cmd_pid); refreshnow = 0; for (;;) { @@ -3383,9 +3432,9 @@ rxvt_main_loop(pR) if (ch == '\n') { nlines++; - h->refresh_count++; + R->refresh_count++; if (!(R->Options & Opt_jumpScroll) - || (h->refresh_count >= (h->refresh_limit + || (R->refresh_count >= (R->refresh_limit * (R->TermWin.nrow - 1)))) { refreshnow = 1; @@ -3407,7 +3456,7 @@ rxvt_main_loop(pR) /* * If there have been a lot of new lines, then update the screen * What the heck I'll cheat and only refresh less than every page-full. - * the number of pages between refreshes is h->refresh_limit, which + * the number of pages between refreshes is R->refresh_limit, which * is incremented here because we must be doing flat-out scrolling. * * refreshing should be correct for small scrolls, because of the @@ -3419,10 +3468,10 @@ rxvt_main_loop(pR) { refreshnow = 0; - if ((R->Options & Opt_jumpScroll) && h->refresh_limit < REFRESH_PERIOD) - h->refresh_limit++; + if ((R->Options & Opt_jumpScroll) && R->refresh_limit < REFRESH_PERIOD) + R->refresh_limit++; - rxvt_scr_refresh(aR_ h->refresh_type); + rxvt_scr_refresh(aR_ R->refresh_type); } } @@ -3482,15 +3531,15 @@ rxvt_tt_write(pR_ const unsigned char *d, unsigned int len) *v_bufptr, /* end of current buffer pending */ *v_bufend; /* end of physical buffer */ - if (R->h->v_bufstr == NULL && len > 0) { + if (R->v_bufstr == NULL && len > 0) { p = (len / MAX_PTY_WRITE + 1) * MAX_PTY_WRITE; v_buffer = v_bufstr = v_bufptr = (unsigned char *)rxvt_malloc(p); v_bufend = v_buffer + p; } else { - v_buffer = R->h->v_buffer; - v_bufstr = R->h->v_bufstr; - v_bufptr = R->h->v_bufptr; - v_bufend = R->h->v_bufend; + v_buffer = R->v_buffer; + v_bufstr = R->v_bufstr; + v_bufptr = R->v_bufptr; + v_bufend = R->v_bufend; } /* @@ -3574,10 +3623,10 @@ rxvt_tt_write(pR_ const unsigned char *d, unsigned int len) v_buffer = v_bufstr - start; /* restore clobbered pointer */ } } - R->h->v_buffer = v_buffer; - R->h->v_bufstr = v_bufstr; - R->h->v_bufptr = v_bufptr; - R->h->v_bufend = v_bufend; + R->v_buffer = v_buffer; + R->v_bufstr = v_bufstr; + R->v_bufptr = v_bufptr; + R->v_bufend = v_bufend; } /*----------------------- end-of-file (C source) -----------------------*/ diff --git a/src/defaultfont.h b/src/defaultfont.h index da83ecef..5754e849 100644 --- a/src/defaultfont.h +++ b/src/defaultfont.h @@ -1,5 +1,5 @@ /* - * $Id: defaultfont.h,v 1.3 2003-11-25 09:29:11 pcg Exp $ + * $Id: defaultfont.h,v 1.4 2003-11-25 11:52:42 pcg Exp $ */ #ifndef _DEFAULTFONT_H_ @@ -23,12 +23,10 @@ #include "encoding.h" #include "rxvtvec.h" -typedef struct rxvt_vars rxvt_t; - struct rxvt_font { // managed by the fontset #if EXPLICIT_CONTEXT - rxvt_t *rxvt_term; + rxvt_t rxvt_term; void set_term (pR) { this->rxvt_term = R; } #else void set_term (pR) { } @@ -90,7 +88,7 @@ struct rxvt_fontset { private: #ifdef EXPLICIT_CONTEXT - rxvt_t *rxvt_term; + rxvt_t rxvt_term; #endif simplevec fonts; const rxvt_fallback_font *fallback; diff --git a/src/graphics.C b/src/graphics.C index 710db436..492a8480 100644 --- a/src/graphics.C +++ b/src/graphics.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: graphics.c *----------------------------------------------------------------------* - * $Id: graphics.C,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: graphics.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1994 Rob Nation @@ -106,12 +106,12 @@ rxvt_Gr_NewWindow(pR_ int nargs, int args[]) grwin->h = h; grwin->screen = 0; grwin->prev = NULL; - grwin->next = R->h->gr_root; + grwin->next = R->gr_root; if (grwin->next) grwin->next->prev = grwin; - R->h->gr_root = grwin; + R->gr_root = grwin; grwin->graphics = NULL; - R->h->graphics_up++; + R->graphics_up++; rxvt_tt_printf(aR_ "\033W%ld\n", (long)grwin->win); } @@ -223,10 +223,10 @@ rxvt_Gr_DestroyWindow(pR_ grwin_t *grwin) if (grwin->prev != NULL) grwin->prev->next = grwin->next; else - R->h->gr_root = grwin->next; + R->gr_root = grwin->next; free(grwin); - R->h->graphics_up--; + R->graphics_up--; } /* ARGSUSED */ @@ -327,7 +327,7 @@ rxvt_Gr_ButtonReport(pR_ int but, int x, int y) { grwin_t *grwin; - for (grwin = R->h->gr_root; grwin != NULL; grwin = grwin->next) + for (grwin = R->gr_root; grwin != NULL; grwin = grwin->next) if ((x > grwin->x) && (y > grwin->y) && ((unsigned int)x < grwin->x + grwin->w) @@ -362,13 +362,13 @@ rxvt_Gr_do_graphics(pR_ int cmd, unsigned int nargs, int args[], unsigned char * rxvt_Gr_Geometry(aR_ NULL, NULL); return; } - if ((win_id == None) && (R->h->gr_last_id != None)) - win_id = R->h->gr_last_id; + if ((win_id == None) && (R->gr_last_id != None)) + win_id = R->gr_last_id; if (win_id == None) return; - grwin = R->h->gr_root; + grwin = R->gr_root; while ((grwin != NULL) && (grwin->win != win_id)) grwin = grwin->next; @@ -436,12 +436,12 @@ rxvt_Gr_scroll(pR_ int count) { grwin_t *grwin, *next; - if ((count == 0) && (R->h->gr_prev_start == R->TermWin.view_start)) + if ((count == 0) && (R->gr_prev_start == R->TermWin.view_start)) return; - R->h->gr_prev_start = R->TermWin.view_start; + R->gr_prev_start = R->TermWin.view_start; - for (grwin = R->h->gr_root; grwin != NULL; grwin = next) { + for (grwin = R->gr_root; grwin != NULL; grwin = next) { next = grwin->next; grwin->y -= (count * R->TermWin.fheight); if ((long)(grwin->y + grwin->h) @@ -460,7 +460,7 @@ rxvt_Gr_ClearScreen(pR) { grwin_t *grwin, *next; - for (grwin = R->h->gr_root; grwin != NULL; grwin = next) { + for (grwin = R->gr_root; grwin != NULL; grwin = next) { next = grwin->next; if ((grwin->screen == 0) && (grwin->y + grwin->h > 0)) { if (grwin->y >= 0) @@ -478,7 +478,7 @@ rxvt_Gr_ChangeScreen(pR) { grwin_t *grwin, *next; - for (grwin = R->h->gr_root; grwin != NULL; grwin = next) { + for (grwin = R->gr_root; grwin != NULL; grwin = next) { next = grwin->next; if (grwin->y + grwin->h > 0) { if (grwin->screen == 1) { @@ -499,7 +499,7 @@ rxvt_Gr_expose(pR_ Window win) { grwin_t *grwin; - for (grwin = R->h->gr_root; grwin != NULL; grwin = grwin->next) { + for (grwin = R->gr_root; grwin != NULL; grwin = grwin->next) { if (grwin->win == win) { rxvt_Gr_Redraw(aR_ grwin); break; @@ -514,7 +514,7 @@ rxvt_Gr_Resize(pR_ int w __attribute__((unused)), int h) { grwin_t *grwin; - for (grwin = R->h->gr_root; grwin != NULL; grwin = grwin->next) { + for (grwin = R->gr_root; grwin != NULL; grwin = grwin->next) { if (R->TermWin.height != h) { grwin->y += (R->TermWin.height - h); XMoveWindow(R->Xdisplay, grwin->win, @@ -531,19 +531,19 @@ rxvt_Gr_reset(pR) { grwin_t *grwin, *next; - for (grwin = R->h->gr_root; grwin != NULL; grwin = next) { + for (grwin = R->gr_root; grwin != NULL; grwin = next) { next = grwin->next; rxvt_Gr_DestroyWindow(aR_ grwin); } - R->h->graphics_up = 0; + R->graphics_up = 0; } /* EXTPROTO */ int rxvt_Gr_Displayed(pR) { - return R->h->graphics_up; + return R->graphics_up; } #endif /*----------------------- end-of-file (C source) -----------------------*/ diff --git a/src/init.C b/src/init.C index 90d7fbf2..e0f383db 100644 --- a/src/init.C +++ b/src/init.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: init.c *----------------------------------------------------------------------* - * $Id: init.C,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: init.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -367,33 +367,26 @@ rxvt_getdtablesize(void) int rxvt_init_vars(pR) { - struct rxvt_hidden *h; - -#ifndef NULLS_ARE_NOT_ZEROS - MEMSET(R, 0, sizeof(rxvt_t)); -#endif - h = R->h = (struct rxvt_hidden *)rxvt_calloc(1, sizeof(struct rxvt_hidden)); - R->PixColors = (rxvt_color *)rxvt_malloc(sizeof(rxvt_color) * TOTAL_COLORS); - if (R->h == NULL || R->PixColors == NULL) + if (R->PixColors == NULL) return -1; #if defined(XPM_BACKGROUND) || defined(TRANSPARENT) R->TermWin.pixmap = None; #endif #ifdef UTMP_SUPPORT - h->next_utmp_action = SAVE; + R->next_utmp_action = SAVE; #endif #ifndef NO_SETOWNER_TTYDEV - h->next_tty_action = SAVE; + R->next_tty_action = SAVE; #endif - h->MEvent.time = CurrentTime; - h->MEvent.button = AnyButton; + R->MEvent.time = CurrentTime; + R->MEvent.button = AnyButton; R->Options = DEFAULT_OPTIONS; - h->want_refresh = 1; - h->cmd_pid = -1; + R->want_refresh = 1; + R->cmd_pid = -1; R->cmd_fd = R->tty_fd = R->Xfd = -1; - h->PrivateModes = h->SavedModes = PrivMode_Default; + R->PrivateModes = R->SavedModes = PrivMode_Default; R->TermWin.focus = 1; R->TermWin.ncol = 80; R->TermWin.nrow = 24; @@ -408,35 +401,35 @@ rxvt_init_vars(pR) R->selection_style = OLD_SELECT; #endif #ifndef NO_BRIGHTCOLOR - h->colorfgbg = DEFAULT_RSTYLE; + R->colorfgbg = DEFAULT_RSTYLE; #endif #if defined (HOTKEY_CTRL) || defined (HOTKEY_META) - h->ks_bigfont = XK_greater; - h->ks_smallfont = XK_less; + R->ks_bigfont = XK_greater; + R->ks_smallfont = XK_less; #endif #ifdef GREEK_SUPPORT - h->ks_greekmodeswith = GREEK_KEYBOARD_MODESWITCH; + R->ks_greekmodeswith = GREEK_KEYBOARD_MODESWITCH; #endif - h->refresh_limit = 1; - h->refresh_type = SLOW_REFRESH; - h->prev_nrow = h->prev_ncol = 0; + R->refresh_limit = 1; + R->refresh_type = SLOW_REFRESH; + R->prev_nrow = R->prev_ncol = 0; #ifdef MULTICHAR_SET # ifdef MULTICHAR_ENCODING R->encoding_method = MULTICHAR_ENCODING; # endif - h->multichar_decode = rxvt_euc2jis; + R->multichar_decode = rxvt_euc2jis; #endif - h->oldcursor.row = h->oldcursor.col = -1; + R->oldcursor.row = R->oldcursor.col = -1; #ifdef XPM_BACKGROUND -/* h->bgPixmap.w = h->bgPixmap.h = 0; */ - h->bgPixmap.x = h->bgPixmap.y = 50; - h->bgPixmap.pixmap = None; +/* R->bgPixmap.w = R->bgPixmap.h = 0; */ + R->bgPixmap.x = R->bgPixmap.y = 50; + R->bgPixmap.pixmap = None; #endif - h->last_bot = h->last_state = -1; + R->last_bot = R->last_state = -1; #ifdef MENUBAR - h->menu_readonly = 1; + R->menu_readonly = 1; # if !(MENUBAR_MAX > 1) - h->CurrentBar = &(h->BarList); + R->CurrentBar = &(R->BarList); # endif /* (MENUBAR_MAX > 1) */ #endif return 0; @@ -451,16 +444,16 @@ rxvt_init_secondary(pR) struct group *gr = getgrnam("tty"); if (gr) { /* change group ownership of tty to "tty" */ - R->h->ttymode = S_IRUSR | S_IWUSR | S_IWGRP; - R->h->ttygid = gr->gr_gid; + R->ttymode = S_IRUSR | S_IWUSR | S_IWGRP; + R->ttygid = gr->gr_gid; } else #endif /* TTY_GID_SUPPORT */ { - R->h->ttymode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; - R->h->ttygid = getgid(); + R->ttymode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; + R->ttygid = getgid(); } #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) - R->h->locale = setlocale(LC_CTYPE, ""); + R->locale = setlocale(LC_CTYPE, ""); #endif /* get number of available file descriptors */ @@ -523,7 +516,7 @@ rxvt_init_resources(pR_ int argc, const char *const *argv) } /* clear all resources */ - rs = R->h->rs; + rs = R->rs; for (i = 0; i < NUM_RESOURCES;) rs[i++] = NULL; @@ -584,9 +577,9 @@ rxvt_init_resources(pR_ int argc, const char *const *argv) #ifdef POINTER_BLANK if (rs[Rs_pointerBlankDelay] && (i = atoi(rs[Rs_pointerBlankDelay])) >= 0) - R->h->pointerBlankDelay = i; + R->pointerBlankDelay = i; else - R->h->pointerBlankDelay = 2; + R->pointerBlankDelay = 2; #endif /* no point having a scrollbar without having any scrollback! */ @@ -612,29 +605,29 @@ rxvt_init_resources(pR_ int argc, const char *const *argv) #ifndef NO_BACKSPACE_KEY if (!rs[Rs_backspace_key]) # ifdef DEFAULT_BACKSPACE - R->h->key_backspace = DEFAULT_BACKSPACE; + R->key_backspace = DEFAULT_BACKSPACE; # else - R->h->key_backspace = "DEC"; /* can toggle between \010 or \177 */ + R->key_backspace = "DEC"; /* can toggle between \010 or \177 */ # endif else { val = STRDUP(rs[Rs_backspace_key]); rxvt_Str_trim(val); rxvt_Str_escaped(val); - R->h->key_backspace = val; + R->key_backspace = val; } #endif #ifndef NO_DELETE_KEY if (!rs[Rs_delete_key]) # ifdef DEFAULT_DELETE - R->h->key_delete = DEFAULT_DELETE; + R->key_delete = DEFAULT_DELETE; # else - R->h->key_delete = "\033[3~"; + R->key_delete = "\033[3~"; # endif else { val = STRDUP(rs[Rs_delete_key]); rxvt_Str_trim(val); rxvt_Str_escaped(val); - R->h->key_delete = val; + R->key_delete = val; } #endif if (rs[Rs_answerbackstring]) { @@ -720,26 +713,26 @@ rxvt_init_env(pR) * * Giving out the display_name also affords a potential security hole */ - val = rxvt_network_display(R->h->rs[Rs_display_name]); - R->h->rs[Rs_display_name] = (const char *)val; + val = rxvt_network_display(R->rs[Rs_display_name]); + R->rs[Rs_display_name] = (const char *)val; if (val == NULL) #endif /* DISPLAY_IS_IP */ val = XDisplayString(R->Xdisplay); - if (R->h->rs[Rs_display_name] == NULL) - R->h->rs[Rs_display_name] = val; /* use broken `:0' value */ + if (R->rs[Rs_display_name] == NULL) + R->rs[Rs_display_name] = val; /* use broken `:0' value */ i = STRLEN(val); - R->h->env_display = (char *)rxvt_malloc((i + 9) * sizeof(char)); + R->env_display = (char *)rxvt_malloc((i + 9) * sizeof(char)); - sprintf(R->h->env_display, "DISPLAY=%s", val); + sprintf(R->env_display, "DISPLAY=%s", val); /* avoiding the math library: * i = (int)(ceil(log10((unsigned int)R->TermWin.parent[0]))) */ for (i = 0, u = (unsigned int)R->TermWin.parent[0]; u; u /= 10, i++) ; MAX_IT(i, 1); - R->h->env_windowid = (char *)rxvt_malloc((i + 10) * sizeof(char)); + R->env_windowid = (char *)rxvt_malloc((i + 10) * sizeof(char)); - sprintf(R->h->env_windowid, "WINDOWID=%u", + sprintf(R->env_windowid, "WINDOWID=%u", (unsigned int)R->TermWin.parent[0]); /* add entries to the environment: @@ -749,8 +742,8 @@ rxvt_init_env(pR) * @ TERM: terminal name * @ TERMINFO: path to terminfo directory */ - putenv(R->h->env_display); - putenv(R->h->env_windowid); + putenv(R->env_display); + putenv(R->env_windowid); #ifdef RXVT_TERMINFO putenv("TERMINFO=" RXVT_TERMINFO); #endif @@ -758,10 +751,10 @@ rxvt_init_env(pR) putenv("COLORTERM=" COLORTERMENV "-mono"); else putenv("COLORTERM=" COLORTERMENVFULL); - if (R->h->rs[Rs_term_name] != NULL) { - R->h->env_term = (char *)rxvt_malloc((STRLEN(R->h->rs[Rs_term_name]) + 6) * sizeof(char)); - sprintf(R->h->env_term, "TERM=%s", R->h->rs[Rs_term_name]); - putenv(R->h->env_term); + if (R->rs[Rs_term_name] != NULL) { + R->env_term = (char *)rxvt_malloc((STRLEN(R->rs[Rs_term_name]) + 6) * sizeof(char)); + sprintf(R->env_term, "TERM=%s", R->rs[Rs_term_name]); + putenv(R->env_term); } else putenv("TERM=" TERMENV); @@ -783,7 +776,7 @@ void rxvt_init_xlocale(pR) { #ifdef USE_XIM - if (R->h->locale == NULL) + if (R->locale == NULL) rxvt_print_error("Setting locale failed."); else { Atom wmlocale; @@ -791,7 +784,7 @@ rxvt_init_xlocale(pR) wmlocale = XInternAtom(R->Xdisplay, "WM_LOCALE_NAME", False); XChangeProperty(R->Xdisplay, R->TermWin.parent[0], wmlocale, XA_STRING, 8, PropModeReplace, - (unsigned char *)R->h->locale, STRLEN(R->h->locale)); + (unsigned char *)R->locale, STRLEN(R->locale)); if (XSupportsLocale() != True) { rxvt_print_error("The locale is not supported by Xlib"); @@ -803,7 +796,7 @@ rxvt_init_xlocale(pR) rxvt_IMInstantiateCallback(R->Xdisplay, NULL, NULL); /* To avoid Segmentation Fault in C locale: Solaris only? */ - if (STRCMP(R->h->locale, "C")) + if (STRCMP(R->locale, "C")) XRegisterIMInstantiateCallback(R->Xdisplay, NULL, NULL, NULL, rxvt_IMInstantiateCallback, NULL); } @@ -822,11 +815,11 @@ rxvt_init_command(pR_ const char *const *argv) int i; for (i = 0; i < NUM_XA; i++) - R->h->xa[i] = XInternAtom(R->Xdisplay, xa_names[i], False); + R->xa[i] = XInternAtom(R->Xdisplay, xa_names[i], False); /* Enable delete window protocol */ XSetWMProtocols(R->Xdisplay, R->TermWin.parent[0], - &(R->h->xa[XA_WMDELETEWINDOW]), 1); + &(R->xa[XA_WMDELETEWINDOW]), 1); #ifdef USING_W11LIB /* enable W11 callbacks */ @@ -834,27 +827,27 @@ rxvt_init_command(pR_ const char *const *argv) #endif #ifdef META8_OPTION - R->h->meta_char = (R->Options & Opt_meta8 ? 0x80 : C0_ESC); + R->meta_char = (R->Options & Opt_meta8 ? 0x80 : C0_ESC); #endif rxvt_get_ourmods(aR); if (!(R->Options & Opt_scrollTtyOutput)) - R->h->PrivateModes |= PrivMode_TtyOutputInh; + R->PrivateModes |= PrivMode_TtyOutputInh; if (R->Options & Opt_scrollTtyKeypress) - R->h->PrivateModes |= PrivMode_Keypress; + R->PrivateModes |= PrivMode_Keypress; if (!(R->Options & Opt_jumpScroll)) - R->h->PrivateModes |= PrivMode_smoothScroll; + R->PrivateModes |= PrivMode_smoothScroll; #ifndef NO_BACKSPACE_KEY - if (STRCMP(R->h->key_backspace, "DEC") == 0) - R->h->PrivateModes |= PrivMode_HaveBackSpace; + if (STRCMP(R->key_backspace, "DEC") == 0) + R->PrivateModes |= PrivMode_HaveBackSpace; #endif /* add value for scrollBar */ if (scrollbar_visible(R)) { - R->h->PrivateModes |= PrivMode_scrollBar; - R->h->SavedModes |= PrivMode_scrollBar; + R->PrivateModes |= PrivMode_scrollBar; + R->SavedModes |= PrivMode_scrollBar; } if (menubar_visible(R)) { - R->h->PrivateModes |= PrivMode_menuBar; - R->h->SavedModes |= PrivMode_menuBar; + R->PrivateModes |= PrivMode_menuBar; + R->SavedModes |= PrivMode_menuBar; } #ifdef GREEK_SUPPORT greek_init(); @@ -864,7 +857,7 @@ rxvt_init_command(pR_ const char *const *argv) #ifdef CURSOR_BLINK if (R->Options & Opt_cursorBlink) - (void)gettimeofday(&R->h->lastcursorchange, NULL); + (void)gettimeofday(&R->lastcursorchange, NULL); #endif if ((R->cmd_fd = rxvt_run_command(aR_ argv)) < 0) { @@ -883,19 +876,19 @@ rxvt_Get_Colours(pR) for (i = 0; i < (XDEPTH <= 2 ? 2 : NRS_COLORS); i++) { rxvt_color xcol; - if (!R->h->rs[Rs_color + i]) + if (!R->rs[Rs_color + i]) continue; - if (!rxvt_rXParseAllocColor(aR_ &xcol, R->h->rs[Rs_color + i])) { + if (!rxvt_rXParseAllocColor(aR_ &xcol, R->rs[Rs_color + i])) { #ifndef XTERM_REVERSE_VIDEO if (i < 2 && (R->Options & Opt_reverseVideo)) { - R->h->rs[Rs_color + i] = def_colorName[!i]; + R->rs[Rs_color + i] = def_colorName[!i]; } else #endif - R->h->rs[Rs_color + i] = def_colorName[i]; - if (!R->h->rs[Rs_color + i]) + R->rs[Rs_color + i] = def_colorName[i]; + if (!R->rs[Rs_color + i]) continue; - if (!rxvt_rXParseAllocColor(aR_ &xcol, R->h->rs[Rs_color + i])) { + if (!rxvt_rXParseAllocColor(aR_ &xcol, R->rs[Rs_color + i])) { switch (i) { case Color_fg: case Color_bg: @@ -919,12 +912,12 @@ rxvt_Get_Colours(pR) } } R->PixColors[i] = xcol; - SET_PIXCOLOR(R->h, i); + SET_PIXCOLOR(R, i); } - if (XDEPTH <= 2 || !R->h->rs[Rs_color + Color_pointer]) + if (XDEPTH <= 2 || !R->rs[Rs_color + Color_pointer]) R->PixColors[Color_pointer] = R->PixColors[Color_fg]; - if (XDEPTH <= 2 || !R->h->rs[Rs_color + Color_border]) + if (XDEPTH <= 2 || !R->rs[Rs_color + Color_border]) R->PixColors[Color_border] = R->PixColors[Color_fg]; /* @@ -981,18 +974,18 @@ rxvt_Get_Colours(pR) void rxvt_color_aliases(pR_ int idx) { - if (R->h->rs[Rs_color + idx] && isdigit(*(R->h->rs[Rs_color + idx]))) { - int i = atoi(R->h->rs[Rs_color + idx]); + if (R->rs[Rs_color + idx] && isdigit(*(R->rs[Rs_color + idx]))) { + int i = atoi(R->rs[Rs_color + idx]); if (i >= 8 && i <= 15) { /* bright colors */ i -= 8; #ifndef NO_BRIGHTCOLOR - R->h->rs[Rs_color + idx] = R->h->rs[Rs_color + minBrightCOLOR + i]; + R->rs[Rs_color + idx] = R->rs[Rs_color + minBrightCOLOR + i]; return; #endif } if (i >= 0 && i <= 7) /* normal colors */ - R->h->rs[Rs_color + idx] = R->h->rs[Rs_color + minCOLOR + i]; + R->rs[Rs_color + idx] = R->rs[Rs_color + minCOLOR + i]; } } @@ -1014,7 +1007,7 @@ rxvt_get_ourmods(pR) { Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask }; requestedmeta = realmeta = realalt = 0; - rsmod = R->h->rs[Rs_modifier]; + rsmod = R->rs[Rs_modifier]; if (rsmod && STRCASECMP(rsmod, "mod1") >= 0 && STRCASECMP(rsmod, "mod5") <= 0) requestedmeta = rsmod[3] - '0'; @@ -1028,7 +1021,7 @@ rxvt_get_ourmods(pR) break; switch (XKeycodeToKeysym(R->Xdisplay, kc[k], 0)) { case XK_Num_Lock: - R->h->ModNumLockMask = modmasks[i - 1]; + R->ModNumLockMask = modmasks[i - 1]; /* FALLTHROUGH */ default: continue; /* for(;;) */ @@ -1060,7 +1053,7 @@ rxvt_get_ourmods(pR) : (realmeta ? realmeta : (realalt ? realalt : 0))); if (i) - R->h->ModMetaMask = modmasks[i - 1]; + R->ModMetaMask = modmasks[i - 1]; } /*----------------------------------------------------------------------*/ @@ -1113,8 +1106,8 @@ rxvt_Create_Windows(pR_ int argc, const char *const *argv) rxvt_change_font(aR_ 1, NULL); rxvt_window_calc(aR_ 0, 0); - R->h->old_width = R->szHint.width; - R->h->old_height = R->szHint.height; + R->old_width = R->szHint.width; + R->old_height = R->szHint.height; /* parent window - reverse video so we can see placement errors * sub-window placement & size in rxvt_resize_subwindows() @@ -1141,10 +1134,10 @@ rxvt_Create_Windows(pR_ int argc, const char *const *argv) R->PixColors[Color_border], R->PixColors[Color_fg]); #endif - rxvt_xterm_seq(aR_ XTerm_title, R->h->rs[Rs_title], CHAR_ST); - rxvt_xterm_seq(aR_ XTerm_iconName, R->h->rs[Rs_iconName], CHAR_ST); + rxvt_xterm_seq(aR_ XTerm_title, R->rs[Rs_title], CHAR_ST); + rxvt_xterm_seq(aR_ XTerm_iconName, R->rs[Rs_iconName], CHAR_ST); - classHint.res_name = (char *)R->h->rs[Rs_name]; + classHint.res_name = (char *)R->rs[Rs_name]; classHint.res_class = (char *)APL_CLASS; wmHint.flags = (InputHint | StateHint | WindowGroupHint); @@ -1168,18 +1161,18 @@ rxvt_Create_Windows(pR_ int argc, const char *const *argv) #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) /* cursor (menuBar/scrollBar): Black-on-White */ - R->h->pointer_leftptr = XCreateFontCursor(R->Xdisplay, XC_left_ptr); + R->pointer_leftptr = XCreateFontCursor(R->Xdisplay, XC_left_ptr); #endif #ifdef POINTER_BLANK - R->h->pointer_blank = XCreateGlyphCursor(R->Xdisplay, R->TermWin.font->fid, + R->pointer_blank = XCreateGlyphCursor(R->Xdisplay, R->TermWin.font->fid, R->TermWin.font->fid, ' ', ' ', &blackcolour, &blackcolour); #endif /* the vt window */ R->TermWin.vt = XCreateSimpleWindow(R->Xdisplay, R->TermWin.parent[0], - R->h->window_vt_x, R->h->window_vt_y, + R->window_vt_x, R->window_vt_y, TermWin_TotalWidth(), TermWin_TotalHeight(), 0, @@ -1202,7 +1195,7 @@ rxvt_Create_Windows(pR_ int argc, const char *const *argv) #if defined(MENUBAR) && (MENUBAR_MAX > 1) if (menuBar_height()) { R->menuBar.win = XCreateSimpleWindow(R->Xdisplay, R->TermWin.parent[0], - R->h->window_vt_x, 0, + R->window_vt_x, 0, TermWin_TotalWidth(), menuBar_TotalHeight(), 0, @@ -1211,22 +1204,22 @@ rxvt_Create_Windows(pR_ int argc, const char *const *argv) #ifdef DEBUG_X XStoreName(R->Xdisplay, R->menuBar.win, "menubar"); #endif - XDefineCursor(R->Xdisplay, R->menuBar.win, R->h->pointer_leftptr); + XDefineCursor(R->Xdisplay, R->menuBar.win, R->pointer_leftptr); XSelectInput(R->Xdisplay, R->menuBar.win, (ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask)); } #endif #ifdef XPM_BACKGROUND - if (R->h->rs[Rs_backgroundPixmap] != NULL + if (R->rs[Rs_backgroundPixmap] != NULL && !(R->Options & Opt_transparent)) { - const char *p = R->h->rs[Rs_backgroundPixmap]; + const char *p = R->rs[Rs_backgroundPixmap]; if ((p = STRCHR(p, ';')) != NULL) { p++; rxvt_scale_pixmap(aR_ p); } - rxvt_set_bgPixmap(aR_ R->h->rs[Rs_backgroundPixmap]); + rxvt_set_bgPixmap(aR_ R->rs[Rs_backgroundPixmap]); rxvt_scr_touch(aR_ True); } #endif @@ -1241,14 +1234,14 @@ rxvt_Create_Windows(pR_ int argc, const char *const *argv) #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) gcvalue.foreground = R->PixColors[Color_topShadow]; - R->h->topShadowGC = XCreateGC(R->Xdisplay, R->TermWin.vt, + R->topShadowGC = XCreateGC(R->Xdisplay, R->TermWin.vt, GCForeground, &gcvalue); gcvalue.foreground = R->PixColors[Color_bottomShadow]; - R->h->botShadowGC = XCreateGC(R->Xdisplay, R->TermWin.vt, + R->botShadowGC = XCreateGC(R->Xdisplay, R->TermWin.vt, GCForeground, &gcvalue); gcvalue.foreground = R->PixColors[(XDEPTH <= 2 ? Color_fg : Color_scroll)]; - R->h->scrollbarGC = XCreateGC(R->Xdisplay, R->TermWin.vt, + R->scrollbarGC = XCreateGC(R->Xdisplay, R->TermWin.vt, GCForeground, &gcvalue); #endif } @@ -1266,7 +1259,7 @@ rxvt_run_command(pR_ const char *const *argv) int cfd, er; /* get master (pty) */ - if ((cfd = rxvt_get_pty(&(R->tty_fd), &(R->h->ttydev))) < 0) { + if ((cfd = rxvt_get_pty(&(R->tty_fd), &(R->ttydev))) < 0) { rxvt_print_error("can't open pseudo-tty"); return -1; } @@ -1284,21 +1277,21 @@ rxvt_run_command(pR_ const char *const *argv) #ifndef NO_SETOWNER_TTYDEV rxvt_privileged_ttydev(aR_ SAVE); #endif - if ((R->tty_fd = rxvt_get_tty(R->h->ttydev)) < 0) { + if ((R->tty_fd = rxvt_get_tty(R->ttydev)) < 0) { close(cfd); - rxvt_print_error("can't open slave tty %s", R->h->ttydev); + rxvt_print_error("can't open slave tty %s", R->ttydev); return -1; } } #ifndef NO_BACKSPACE_KEY - if (R->h->key_backspace[0] && !R->h->key_backspace[1]) - er = R->h->key_backspace[0]; - else if (STRCMP(R->h->key_backspace, "DEC") == 0) + if (R->key_backspace[0] && !R->key_backspace[1]) + er = R->key_backspace[0]; + else if (STRCMP(R->key_backspace, "DEC") == 0) er = '\177'; /* the initial state anyway */ else #endif er = -1; - rxvt_get_ttymode(&(R->h->tio), er); + rxvt_get_ttymode(&(R->tio), er); /* install exit handler for cleanup */ #ifdef HAVE_ATEXIT @@ -1322,14 +1315,14 @@ rxvt_run_command(pR_ const char *const *argv) #ifndef __QNX__ /* spin off the command interpreter */ - switch (R->h->cmd_pid = fork()) { + switch (R->cmd_pid = fork()) { case -1: rxvt_print_error("can't fork"); return -1; case 0: close(cfd); /* only keep R->tty_fd and STDERR open */ close(R->Xfd); - if (rxvt_control_tty(R->tty_fd, R->h->ttydev) < 0) + if (rxvt_control_tty(R->tty_fd, R->ttydev) < 0) rxvt_print_error("could not obtain control of tty"); else { /* Reopen stdin, stdout and stderr over the tty file descriptor */ @@ -1393,7 +1386,7 @@ rxvt_run_child(pR_ const char *const *argv) { char *login; - SET_TTYMODE(STDIN_FILENO, &(R->h->tio)); /* init terminal attributes */ + SET_TTYMODE(STDIN_FILENO, &(R->tio)); /* init terminal attributes */ if (R->Options & Opt_console) { /* be virtual console, fail silently */ #ifdef TIOCCONS @@ -1489,7 +1482,7 @@ rxvt_run_child(pR_ const char *const *argv) arg_v = arg_a; } iov_a[0] = iov_a[1] = iov_a[2] = R->tty_fd; - R->h->cmd_pid = qnx_spawn(0, 0, 0, -1, -1, + R->cmd_pid = qnx_spawn(0, 0, 0, -1, -1, _SPAWN_SETSID | _SPAWN_TCSETPGRP, command, arg_v, environ, iov_a, 0); if (login) diff --git a/src/logging.C b/src/logging.C index 219bb659..192f6ed8 100644 --- a/src/logging.C +++ b/src/logging.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: logging.c *----------------------------------------------------------------------* - * $Id: logging.C,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: logging.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey @@ -61,10 +61,10 @@ void rxvt_makeutent(pR_ const char *pty, const char *hostname) { #ifdef HAVE_STRUCT_UTMP - struct utmp *ut = &(R->h->ut); + struct utmp *ut = &(R->ut); #endif #ifdef HAVE_STRUCT_UTMPX - struct utmpx *utx = &(R->h->utx); + struct utmpx *utx = &(R->utx); #endif #ifdef HAVE_UTMP_PID int i; @@ -94,7 +94,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->h->ut_id, ut_id, sizeof(R->h->ut_id)); + STRNCPY(R->ut_id, ut_id, sizeof(R->ut_id)); # endif #endif @@ -104,7 +104,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->h->ut_id, ut_id, sizeof(R->h->ut_id)); + STRNCPY(R->ut_id, ut_id, sizeof(R->ut_id)); #endif #ifdef HAVE_STRUCT_UTMP @@ -115,14 +115,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->h->cmd_pid; + ut->ut_pid = R->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->h->utmp_pos = 0; + R->utmp_pos = 0; # else STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?", sizeof(ut->ut_name)); @@ -140,7 +140,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->h->cmd_pid; + utx->ut_pid = R->cmd_pid; # ifdef HAVE_UTMPX_HOST STRNCPY(utx->ut_host, hostname, sizeof(utx->ut_host)); # if 0 @@ -155,7 +155,7 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) utx->ut_type = USER_PROCESS; pututxline(utx); endutxent(); /* close the file */ - R->h->utmp_pos = 0; + R->utmp_pos = 0; #endif #if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID) @@ -164,7 +164,7 @@ rxvt_makeutent(pR_ const char *pty, const char *hostname) # ifdef HAVE_TTYSLOT i = ttyslot(); if (rxvt_write_bsd_utmp(i, ut)) - R->h->utmp_pos = i; + R->utmp_pos = i; # else FILE *fd0; @@ -178,7 +178,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->h->utmp_pos = i; + R->utmp_pos = i; fclose(fd0); break; } @@ -222,17 +222,17 @@ void rxvt_cleanutent(pR) { #ifdef HAVE_STRUCT_UTMP - struct utmp *ut = &(R->h->ut); + struct utmp *ut = &(R->ut); #endif #ifdef HAVE_STRUCT_UTMPX - struct utmpx *tmputx, *utx = &(R->h->utx); + struct utmpx *tmputx, *utx = &(R->utx); #endif #ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UTMP_PID MEMSET(ut, 0, sizeof(struct utmp)); setutent(); - STRNCPY(ut->ut_id, R->h->ut_id, sizeof(ut->ut_id)); + STRNCPY(ut->ut_id, R->ut_id, sizeof(ut->ut_id)); ut->ut_type = USER_PROCESS; { struct utmp *tmput = getutid(ut); @@ -253,7 +253,7 @@ rxvt_cleanutent(pR) #ifdef HAVE_STRUCT_UTMPX MEMSET(utx, 0, sizeof(struct utmpx)); setutxent(); - STRNCPY(utx->ut_id, R->h->ut_id, sizeof(utx->ut_id)); + STRNCPY(utx->ut_id, R->ut_id, sizeof(utx->ut_id)); utx->ut_type = USER_PROCESS; if ((tmputx = getutxid(utx))) /* position to entry in utmp file */ utx = tmputx; @@ -289,16 +289,16 @@ rxvt_cleanutent(pR) */ #ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UTMP_PID - if (ut->ut_pid == R->h->cmd_pid) + if (ut->ut_pid == R->cmd_pid) pututline(ut); endutent(); # else MEMSET(ut, 0, sizeof(struct utmp)); - rxvt_write_bsd_utmp(R->h->utmp_pos, ut); + rxvt_write_bsd_utmp(R->utmp_pos, ut); # endif #endif #ifdef HAVE_STRUCT_UTMPX - if (utx->ut_pid == R->h->cmd_pid) + if (utx->ut_pid == R->cmd_pid) pututxline(utx); endutxent(); #endif diff --git a/src/main.C b/src/main.C index b37baba5..f8e1f0a6 100644 --- a/src/main.C +++ b/src/main.C @@ -1,19 +1,19 @@ /*--------------------------------*-C-*---------------------------------* - * File: main.c + * File: main.c *----------------------------------------------------------------------* - * $Id: main.C,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: main.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury - * - original version + * - original version * Copyright (c) 1994 Robert Nation - * - extensive modifications + * - extensive modifications * Copyright (c) 1995 Garrett D'Amore * Copyright (c) 1997 mj olesen - * - extensive modifications + * - extensive modifications * Copyright (c) 1997,1998 Oezguer Kesim * Copyright (c) 1998-2001 Geoff Wing - * - extensive modifications + * - extensive modifications * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,9 +30,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------*/ -#include "../config.h" /* NECESSARY */ -#include "rxvt.h" /* NECESSARY */ -#include "main.intpro" /* PROTOS for internal routines */ +#include "../config.h" /* NECESSARY */ +#include "rxvt.h" /* NECESSARY */ +#include "main.intpro" /* PROTOS for internal routines */ #include @@ -44,20 +44,43 @@ # include #endif +rxvt_term::rxvt_term() +: pty_ev(this, &rxvt_term::pty_cb), + x_ev (this, &rxvt_term::x_cb) +{ + cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; +} + +void * +rxvt_term::operator new (size_t s) +{ + void *p = malloc (s); + + MEMSET (p, 0, s); + return p; +} + +void +rxvt_term::operator delete (void *p, size_t s) +{ + free (p); +} + /*----------------------------------------------------------------------*/ /* rxvt_init() */ /* LIBPROTO */ -rxvt_t * +rxvt_t rxvt_init(int argc, const char *const *argv) { - const char **cmd_argv; + const char **cmd_argv; - SET_R ((rxvt_t *)rxvt_calloc(1, sizeof(rxvt_t))); + SET_R(new rxvt_term); + dR; - dR; - if (rxvt_init_vars(aR) < 0) { - free(R); - return NULL; + if (rxvt_init_vars(aR) < 0) + { + free(R); + return NULL; } /* @@ -74,21 +97,23 @@ rxvt_init(int argc, const char *const *argv) cmd_argv = rxvt_init_resources(aR_ argc, argv); + R->x_ev.start (ConnectionNumber (R->Xdisplay), EVENT_READ); + #if (MENUBAR_MAX) - rxvt_menubar_read(aR_ R->h->rs[Rs_menu]); + rxvt_menubar_read(aR_ R->rs[Rs_menu]); #endif #ifdef HAVE_SCROLLBARS if (R->Options & Opt_scrollBar) - scrollbar_setIdle(); /* set existence for size calculations */ + scrollbar_setIdle(); /* set existence for size calculations */ #endif rxvt_Create_Windows(aR_ argc, argv); rxvt_init_xlocale(aR); - rxvt_scr_reset(aR); /* initialize screen */ + rxvt_scr_reset(aR); /* initialize screen */ #ifdef RXVT_GRAPHICS - rxvt_Gr_reset(aR); /* reset graphics */ + rxvt_Gr_reset(aR); /* reset graphics */ #endif #if 0 @@ -102,17 +127,18 @@ rxvt_init(int argc, const char *const *argv) #ifdef HAVE_SCROLLBARS if (R->Options & Opt_scrollBar) - rxvt_Resize_scrollBar(aR); /* create and map scrollbar */ + rxvt_Resize_scrollBar(aR); /* create and map scrollbar */ #endif #if (MENUBAR_MAX) if (menubar_visible(r)) - XMapWindow(R->Xdisplay, R->menuBar.win); + XMapWindow(R->Xdisplay, R->menuBar.win); #endif #ifdef TRANSPARENT - if (R->Options & Opt_transparent) { - XSelectInput(R->Xdisplay, Xroot, PropertyChangeMask); - rxvt_check_our_parents(aR); - } + if (R->Options & Opt_transparent) + { + XSelectInput(R->Xdisplay, Xroot, PropertyChangeMask); + rxvt_check_our_parents(aR); + } #endif XMapWindow(R->Xdisplay, R->TermWin.vt); XMapWindow(R->Xdisplay, R->TermWin.parent[0]); @@ -120,6 +146,8 @@ rxvt_init(int argc, const char *const *argv) rxvt_init_env(aR); rxvt_init_command(aR_ cmd_argv); + R->pty_ev.start (R->cmd_fd, EVENT_READ); + return R; } @@ -132,17 +160,17 @@ rxvt_init(int argc, const char *const *argv) /* ARGSUSED */ /* EXTPROTO */ RETSIGTYPE -rxvt_Child_signal(int sig __attribute__((unused))) +rxvt_Child_signal(int sig __attribute__ ((unused))) { dR; int pid, save_errno = errno; do { - errno = 0; + errno = 0; } while ((pid = waitpid(-1, NULL, WNOHANG)) == -1 && errno == EINTR); - if (pid == R->h->cmd_pid) - exit(EXIT_SUCCESS); + if (pid == R->cmd_pid) + exit(EXIT_SUCCESS); errno = save_errno; signal(SIGCHLD, rxvt_Child_signal); @@ -166,20 +194,21 @@ rxvt_Exit_signal(int sig) /* ARGSUSED */ /* INTPROTO */ int -rxvt_xerror_handler(const Display *display __attribute__((unused)), const XErrorEvent *event) +rxvt_xerror_handler(const Display * display + __attribute__ ((unused)), const XErrorEvent * event) { dR; - if (R->h->allowedxerror == -1) { - R->h->allowedxerror = event->error_code; - return 0; /* ignored anyway */ + if (R->allowedxerror == -1) { + R->allowedxerror = event->error_code; + return 0; /* ignored anyway */ } rxvt_print_error("XError: Request: %d . %d, Error: %d", - event->request_code, event->minor_code, - event->error_code); - /* XXX: probably should call rxvt_clean_exit() bypassing X routines */ + event->request_code, event->minor_code, + event->error_code); +/* XXX: probably should call rxvt_clean_exit() bypassing X routines */ exit(EXIT_FAILURE); - /* NOTREACHED */ +/* NOTREACHED */ } /*----------------------------------------------------------------------*/ @@ -203,9 +232,9 @@ rxvt_clean_exit(void) rxvt_privileged_utmp(aR_ RESTORE); #endif #ifdef USE_XIM - if (R->h->Input_Context != NULL) { - XDestroyIC(R->h->Input_Context); - R->h->Input_Context = NULL; + if (R->Input_Context != NULL) { + XDestroyIC(R->Input_Context); + R->Input_Context = NULL; } #endif } @@ -217,52 +246,53 @@ rxvt_clean_exit(void) void * rxvt_malloc(size_t size) { - void *p; + void *p; - p = malloc(size); - if (p) - return p; + p = malloc(size); + if (p) + return p; - fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); - rxvt_clean_exit(); - exit(EXIT_FAILURE); - /* NOTREACHED */ + fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); + rxvt_clean_exit(); + exit(EXIT_FAILURE); +/* NOTREACHED */ } /* EXTPROTO */ void * rxvt_calloc(size_t number, size_t size) { - void *p; + void *p; - p = calloc(number, size); - if (p) - return p; + p = calloc(number, size); + if (p) + return p; - fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); - rxvt_clean_exit(); - exit(EXIT_FAILURE); - /* NOTREACHED */ + fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); + rxvt_clean_exit(); + exit(EXIT_FAILURE); +/* NOTREACHED */ } /* EXTPROTO */ void * rxvt_realloc(void *ptr, size_t size) { - void *p; - - if (ptr) - p = realloc(ptr, size); - else - p = malloc(size); - if (p) - return p; - - fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); - rxvt_clean_exit(); - exit(EXIT_FAILURE); - /* NOTREACHED */ + void *p; + + if (ptr) + p = realloc(ptr, size); + else + p = malloc(size); + if (p) + return p; + + fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); + rxvt_clean_exit(); + exit(EXIT_FAILURE); +/* NOTREACHED */ } + /* ------------------------------------------------------------------------- * * PRIVILEGED OPERATIONS * * ------------------------------------------------------------------------- */ @@ -274,39 +304,39 @@ rxvt_privileges(pR_ int mode) #if ! defined(__CYGWIN32__) # if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) /* setreuid() is the poor man's setuid(), seteuid() */ -# define seteuid(a) setreuid(-1, (a)) -# define setegid(a) setregid(-1, (a)) +# define seteuid(a) setreuid(-1, (a)) +# define setegid(a) setregid(-1, (a)) # define HAVE_SETEUID # endif # ifdef HAVE_SETEUID switch (mode) { case IGNORE: - /* - * change effective uid/gid - not real uid/gid - so we can switch - * back to root later, as required - */ - seteuid(getuid()); - setegid(getgid()); - break; + /* + * change effective uid/gid - not real uid/gid - so we can switch + * back to root later, as required + */ + seteuid(getuid()); + setegid(getgid()); + break; case SAVE: - R->h->euid = geteuid(); - R->h->egid = getegid(); - break; + R->euid = geteuid(); + R->egid = getegid(); + break; case RESTORE: - seteuid(R->h->euid); - setegid(R->h->egid); - break; + seteuid(R->euid); + setegid(R->egid); + break; } # else switch (mode) { case IGNORE: - setuid(getuid()); - setgid(getgid()); + setuid(getuid()); + setgid(getgid()); /* FALLTHROUGH */ case SAVE: /* FALLTHROUGH */ case RESTORE: - break; + break; } # endif #endif @@ -317,23 +347,20 @@ rxvt_privileges(pR_ int mode) void rxvt_privileged_utmp(pR_ char action) { - struct rxvt_hidden *h = R->h; - - D_MAIN((stderr, "rxvt_privileged_utmp(%c); waiting for: %c (pid: %d)", action, h->next_utmp_action, getpid())); - if (h->next_utmp_action != action - || (action != SAVE && action != RESTORE) - || (R->Options & Opt_utmpInhibit) - || h->ttydev == NULL - || *h->ttydev == '\0') - return; + 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') + return; rxvt_privileges(aR_ RESTORE); if (action == SAVE) { - h->next_utmp_action = RESTORE; - rxvt_makeutent(aR_ h->ttydev, h->rs[Rs_display_name]); - } else { /* action == RESTORE */ - h->next_utmp_action = IGNORE; - rxvt_cleanutent(aR); + R->next_utmp_action = RESTORE; + rxvt_makeutent(aR_ R->ttydev, R->rs[Rs_display_name]); + } else { /* action == RESTORE */ + R->next_utmp_action = IGNORE; + rxvt_cleanutent(aR); } rxvt_privileges(aR_ IGNORE); } @@ -344,48 +371,51 @@ rxvt_privileged_utmp(pR_ char action) void rxvt_privileged_ttydev(pR_ char action) { - struct rxvt_hidden *h = R->h; - - D_MAIN((stderr, "rxvt_privileged_ttydev(aR_ %c); waiting for: %c (pid: %d)", action, h->next_tty_action, getpid())); - if (h->next_tty_action != action - || (action != SAVE && action != RESTORE) - || h->ttydev == NULL - || *h->ttydev == '\0') - return; + 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') + return; rxvt_privileges(aR_ RESTORE); if (action == SAVE) { - h->next_tty_action = RESTORE; + R->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(h->ttydev, &h->ttyfd_stat) < 0) /* you lose out */ - h->next_tty_action = IGNORE; - else + if (lstat(R->ttydev, &R->ttyfd_stat) < 0) /* you lose out */ + R->next_tty_action = IGNORE; + else # endif - { - chown(h->ttydev, getuid(), h->ttygid); /* fail silently */ - chmod(h->ttydev, h->ttymode); + { + chown(R->ttydev, getuid(), R->ttygid); /* fail silently */ + chmod(R->ttydev, R->ttymode); # ifdef HAVE_REVOKE - revoke(h->ttydev); + revoke(R->ttydev); # endif - } - } else { /* action == RESTORE */ - h->next_tty_action = IGNORE; + } + } else { /* action == RESTORE */ + R->next_tty_action = IGNORE; # ifndef RESET_TTY_TO_COMMON_DEFAULTS - chmod(h->ttydev, h->ttyfd_stat.st_mode); - chown(h->ttydev, h->ttyfd_stat.st_uid, h->ttyfd_stat.st_gid); + chmod(R->ttydev, R->ttyfd_stat.st_mode); + chown(R->ttydev, R->ttyfd_stat.st_uid, R->ttyfd_stat.st_gid); # else - chmod(h->ttydev, - (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); - chown(h->ttydev, 0, 0); + chmod(R->ttydev, + (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); + chown(R->ttydev, 0, 0); # endif } rxvt_privileges(aR_ 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"), h->ttydev, h->ttyfd_stat.st_mode, h->ttyfd_stat.st_uid, h->ttyfd_stat.st_gid)); + 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)); # endif } #endif @@ -404,44 +434,46 @@ rxvt_window_calc(pR_ unsigned int width, unsigned int height) unsigned int w, h; unsigned int max_width, max_height; - D_SIZE((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", R->TermWin.ncol, R->TermWin.nrow, R->szHint.width, R->szHint.height)); + D_SIZE((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", + R->TermWin.ncol, R->TermWin.nrow, R->szHint.width, + R->szHint.height)); R->szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; R->szHint.win_gravity = NorthWestGravity; - /* R->szHint.min_aspect.x = R->szHint.min_aspect.y = 1; */ +/* R->szHint.min_aspect.x = R->szHint.min_aspect.y = 1; */ recalc_x = recalc_y = 0; flags = 0; - if (!R->h->parsed_geometry) { - R->h->parsed_geometry = 1; - if (R->h->rs[Rs_geometry]) - flags = XParseGeometry(R->h->rs[Rs_geometry], &x, &y, &w, &h); - if (flags & WidthValue) { - R->TermWin.ncol = BOUND_POSITIVE_INT16(w); - R->szHint.flags |= USSize; - } - if (flags & HeightValue) { - R->TermWin.nrow = BOUND_POSITIVE_INT16(h); - R->szHint.flags |= USSize; - } - if (flags & XValue) { - R->szHint.x = x; - R->szHint.flags |= USPosition; - if (flags & XNegative) { - recalc_x = 1; - R->szHint.win_gravity = NorthEastGravity; - } - } - if (flags & YValue) { - R->szHint.y = y; - R->szHint.flags |= USPosition; - if (flags & YNegative) { - recalc_y = 1; - if (R->szHint.win_gravity == NorthEastGravity) - R->szHint.win_gravity = SouthEastGravity; - else - R->szHint.win_gravity = SouthWestGravity; - } - } + if (!R->parsed_geometry) { + R->parsed_geometry = 1; + if (R->rs[Rs_geometry]) + flags = XParseGeometry(R->rs[Rs_geometry], &x, &y, &w, &h); + if (flags & WidthValue) { + R->TermWin.ncol = BOUND_POSITIVE_INT16(w); + R->szHint.flags |= USSize; + } + if (flags & HeightValue) { + R->TermWin.nrow = BOUND_POSITIVE_INT16(h); + R->szHint.flags |= USSize; + } + if (flags & XValue) { + R->szHint.x = x; + R->szHint.flags |= USPosition; + if (flags & XNegative) { + recalc_x = 1; + R->szHint.win_gravity = NorthEastGravity; + } + } + if (flags & YValue) { + R->szHint.y = y; + R->szHint.flags |= USPosition; + if (flags & YNegative) { + recalc_y = 1; + if (R->szHint.win_gravity == NorthEastGravity) + R->szHint.win_gravity = SouthEastGravity; + else + R->szHint.win_gravity = SouthWestGravity; + } + } } /* TODO: BOUNDS */ R->TermWin.width = R->TermWin.ncol * R->TermWin.fwidth; @@ -452,17 +484,17 @@ rxvt_window_calc(pR_ unsigned int width, unsigned int height) R->szHint.base_width = R->szHint.base_height = 2 * R->TermWin.int_bwidth; sb_w = mb_h = 0; - R->h->window_vt_x = R->h->window_vt_y = 0; + R->window_vt_x = R->window_vt_y = 0; if (scrollbar_visible(R)) { - sb_w = scrollbar_TotalWidth(); - R->szHint.base_width += sb_w; - if (!(R->Options & Opt_scrollBar_right)) - R->h->window_vt_x = sb_w; + sb_w = scrollbar_TotalWidth(); + R->szHint.base_width += sb_w; + if (!(R->Options & Opt_scrollBar_right)) + R->window_vt_x = sb_w; } if (menubar_visible(R)) { - mb_h = menuBar_TotalHeight(); - R->szHint.base_height += mb_h; - R->h->window_vt_y = mb_h; + mb_h = menuBar_TotalHeight(); + R->szHint.base_height += mb_h; + R->window_vt_y = mb_h; } R->szHint.width_inc = R->TermWin.fwidth; R->szHint.height_inc = R->TermWin.fheight; @@ -470,32 +502,34 @@ rxvt_window_calc(pR_ unsigned int width, unsigned int height) R->szHint.min_height = R->szHint.base_height + R->szHint.height_inc; if (width && width - R->szHint.base_width < max_width) { - R->szHint.width = width; - R->TermWin.width = width - R->szHint.base_width; + R->szHint.width = width; + R->TermWin.width = width - R->szHint.base_width; } else { - MIN_IT(R->TermWin.width, max_width); - R->szHint.width = R->szHint.base_width + R->TermWin.width; + MIN_IT(R->TermWin.width, max_width); + R->szHint.width = R->szHint.base_width + R->TermWin.width; } if (height && height - R->szHint.base_height < max_height) { - R->szHint.height = height; - R->TermWin.height = height - R->szHint.base_height; + R->szHint.height = height; + R->TermWin.height = height - R->szHint.base_height; } else { - MIN_IT(R->TermWin.height, max_height); - R->szHint.height = R->szHint.base_height + R->TermWin.height; + MIN_IT(R->TermWin.height, max_height); + R->szHint.height = R->szHint.base_height + R->TermWin.height; } if (scrollbar_visible(R) && (R->Options & Opt_scrollBar_right)) - R->h->window_sb_x = R->szHint.width - sb_w; + R->window_sb_x = R->szHint.width - sb_w; if (recalc_x) - R->szHint.x += (DisplayWidth(R->Xdisplay, Xscreen) - - R->szHint.width - 2 * R->TermWin.ext_bwidth); + R->szHint.x += (DisplayWidth(R->Xdisplay, Xscreen) + - R->szHint.width - 2 * R->TermWin.ext_bwidth); if (recalc_y) - R->szHint.y += (DisplayHeight(R->Xdisplay, Xscreen) - - R->szHint.height - 2 * R->TermWin.ext_bwidth); + R->szHint.y += (DisplayHeight(R->Xdisplay, Xscreen) + - R->szHint.height - 2 * R->TermWin.ext_bwidth); R->TermWin.ncol = R->TermWin.width / R->TermWin.fwidth; R->TermWin.nrow = R->TermWin.height / R->TermWin.fheight; - D_SIZE((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", R->TermWin.ncol, R->TermWin.nrow, R->szHint.width, R->szHint.height)); + D_SIZE((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", + R->TermWin.ncol, R->TermWin.nrow, R->szHint.width, + R->szHint.height)); return; } @@ -511,7 +545,7 @@ rxvt_tt_winsize(int fd, unsigned short col, unsigned short row, int pid) struct winsize ws; if (fd < 0) - return; + return; ws.ws_col = col; ws.ws_row = row; ws.ws_xpixel = ws.ws_ypixel = 0; @@ -519,11 +553,11 @@ rxvt_tt_winsize(int fd, unsigned short col, unsigned short row, int pid) (void)ioctl(fd, TIOCSWINSZ, &ws); #else if (ioctl(fd, TIOCSWINSZ, &ws) < 0) { - D_SIZE((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); + D_SIZE((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); } # ifdef SIGWINCH - else if (pid) /* force through to the command */ - kill(pid, SIGWINCH); + else if (pid) /* force through to the command */ + kill(pid, SIGWINCH); # endif #endif } @@ -561,11 +595,11 @@ rxvt_set_title(pR_ const char *str) char *name; if (XFetchName(R->Xdisplay, R->TermWin.parent[0], &name) == 0) - name = NULL; + name = NULL; if (name == NULL || STRCMP(name, str)) - XStoreName(R->Xdisplay, R->TermWin.parent[0], str); + XStoreName(R->Xdisplay, R->TermWin.parent[0], str); if (name) - XFree(name); + XFree(name); #endif } @@ -579,11 +613,11 @@ rxvt_set_iconName(pR_ const char *str) char *name; if (XGetIconName(R->Xdisplay, R->TermWin.parent[0], &name)) - name = NULL; + name = NULL; if (name == NULL || STRCMP(name, str)) - XSetIconName(R->Xdisplay, R->TermWin.parent[0], str); + XSetIconName(R->Xdisplay, R->TermWin.parent[0], str); if (name) - XFree(name); + XFree(name); #endif } @@ -596,27 +630,27 @@ rxvt_set_window_color(pR_ int idx, const char *color) int i; if (color == NULL || *color == '\0') - return; + return; /* handle color aliases */ if (isdigit(*color)) { - i = atoi(color); - if (i >= 8 && i <= 15) { /* bright colors */ - i -= 8; + i = atoi(color); + if (i >= 8 && i <= 15) { /* bright colors */ + i -= 8; # ifndef NO_BRIGHTCOLOR - R->PixColors[idx] = R->PixColors[minBrightCOLOR + i]; - SET_PIXCOLOR(R->h, idx); - goto Done; + R->PixColors[idx] = R->PixColors[minBrightCOLOR + i]; + SET_PIXCOLOR(R, idx); + goto Done; # endif - } - if (i >= 0 && i <= 7) { /* normal colors */ - R->PixColors[idx] = R->PixColors[minCOLOR + i]; - SET_PIXCOLOR(R->h, idx); - goto Done; - } + } + if (i >= 0 && i <= 7) { /* normal colors */ + R->PixColors[idx] = R->PixColors[minCOLOR + i]; + SET_PIXCOLOR(R, idx); + goto Done; + } } - if (!rxvt_rXParseAllocColor(aR_ &xcol, color)) - return; + if (!rxvt_rXParseAllocColor(aR_ & xcol, color)) + return; /* XStoreColor (R->Xdisplay, XCMAP, XColor*); */ /* @@ -625,24 +659,24 @@ 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]) - break; + if (R->PixColors[idx] == R->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: R->PixColors [%d] = %lu\n", idx, R->PixColors [idx]); */ + XFreeColors(R->Xdisplay, XCMAP, (R->PixColors + idx), 1, + DisplayPlanes(R->Xdisplay, Xscreen)); } # endif R->PixColors[idx] = xcol; - SET_PIXCOLOR(R->h, idx); + SET_PIXCOLOR(R, idx); /* XSetWindowAttributes attr; */ /* Cursor cursor; */ Done: if (idx == Color_bg && !(R->Options & Opt_transparent)) - XSetWindowBackground(R->Xdisplay, R->TermWin.vt, - R->PixColors[Color_bg]); + XSetWindowBackground(R->Xdisplay, R->TermWin.vt, + R->PixColors[Color_bg]); /* handle Color_BD, scrollbar background, etc. */ @@ -653,8 +687,8 @@ rxvt_set_window_color(pR_ int idx, const char *color) } #else -# define rxvt_set_window_color(aR_ idx,color) ((void)0) -#endif /* XTERM_COLOR_CHANGE */ +# define rxvt_set_window_color(aR_ idx,color) ((void)0) +#endif /* XTERM_COLOR_CHANGE */ /* EXTPROTO */ void @@ -682,32 +716,33 @@ rxvt_set_colorfgbg(pR) const char *xpmb = "\0"; char fstr[sizeof("default") + 1], bstr[sizeof("default") + 1]; - R->h->env_colorfgbg = (char *)rxvt_malloc(sizeof("COLORFGBG=default;default;bg") + 1); + R->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]) { - sprintf(fstr, "%d", (i - Color_Black)); - break; - } + if (R->PixColors[Color_fg] == R->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]) { - sprintf(bstr, "%d", (i - Color_Black)); + if (R->PixColors[Color_bg] == R->PixColors[i]) { + sprintf(bstr, "%d", (i - Color_Black)); #ifdef XPM_BACKGROUND - xpmb = "default;"; + xpmb = "default;"; #endif - break; - } - sprintf(R->h->env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); - putenv(R->h->env_colorfgbg); + break; + } + sprintf(R->env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); + putenv(R->env_colorfgbg); #ifndef NO_BRIGHTCOLOR - R->h->colorfgbg = DEFAULT_RSTYLE; + R->colorfgbg = DEFAULT_RSTYLE; for (i = minCOLOR; i <= maxCOLOR; i++) { - if (R->PixColors[Color_fg] == R->PixColors[i]) - R->h->colorfgbg = SET_FGCOLOR(R->h->colorfgbg, i); - if (R->PixColors[Color_bg] == R->PixColors[i]) - R->h->colorfgbg = SET_BGCOLOR(R->h->colorfgbg, 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); } #endif } @@ -720,15 +755,14 @@ rxvt_set_colorfgbg(pR) /* EXTPROTO */ int -rxvt_rXParseAllocColor(pR_ rxvt_color *screen_in_out, const char *colour) +rxvt_rXParseAllocColor(pR_ rxvt_color * screen_in_out, const char *colour) { - screen_in_out->set (aR_ colour); + screen_in_out->set(aR_ colour); - if (!screen_in_out->set (aR_ colour)) - { - rxvt_print_error("can't allocate colour: %s", colour); + if (!screen_in_out->set(aR_ colour)) { + rxvt_print_error("can't allocate colour: %s", colour); return false; - } + } return true; } @@ -738,104 +772,105 @@ rxvt_rXParseAllocColor(pR_ rxvt_color *screen_in_out, const char *colour) * -------------------------------------------------------------------- */ /* EXTPROTO */ void -rxvt_resize_all_windows(pR_ unsigned int width, unsigned int height, int ignoreparent) +rxvt_resize_all_windows(pR_ unsigned int width, unsigned int height, + int ignoreparent) { int fix_screen; -#ifdef SMART_RESIZE - int old_width = R->szHint.width, - old_height = R->szHint.height; + +#ifdef SMART_RESIZE + int old_width = R->szHint.width, old_height = R->szHint.height; #endif rxvt_window_calc(aR_ width, height); XSetWMNormalHints(R->Xdisplay, R->TermWin.parent[0], &R->szHint); if (!ignoreparent) { -#ifdef SMART_RESIZE +#ifdef SMART_RESIZE /* * resize by Marius Gedminas * reposition window on resize depending on placement on screen */ - int x, y, x1, y1; - int dx, dy; - unsigned int unused_w1, unused_h1, unused_b1, unused_d1; - Window unused_cr; - - XTranslateCoordinates(R->Xdisplay, R->TermWin.parent[0], Xroot, - 0, 0, &x, &y, &unused_cr); - XGetGeometry(R->Xdisplay, R->TermWin.parent[0], &unused_cr, &x1, &y1, - &unused_w1, &unused_h1, &unused_b1, &unused_d1); - /* - * if Xroot isn't the parent window, a WM will probably have offset - * our position for handles and decorations. Counter it - */ - if (x1 != x || y1 != y) { - x -= x1; - y -= y1; - } - - x1 = (DisplayWidth(R->Xdisplay, Xscreen) - old_width) / 2; - y1 = (DisplayHeight(R->Xdisplay, Xscreen) - old_height) / 2; - dx = old_width - R->szHint.width; - dy = old_height - R->szHint.height; - - /* Check position of the center of the window */ - if (x < x1) /* left half */ - dx = 0; - else if (x == x1) /* exact center */ - dx /= 2; - if (y < y1) /* top half */ - dy = 0; - else if (y == y1) /* exact center */ - dy /= 2; - - XMoveResizeWindow(R->Xdisplay, R->TermWin.parent[0], x + dx, y + dy, - R->szHint.width, R->szHint.height); + int x, y, x1, y1; + int dx, dy; + unsigned int unused_w1, unused_h1, unused_b1, unused_d1; + Window unused_cr; + + XTranslateCoordinates(R->Xdisplay, R->TermWin.parent[0], Xroot, + 0, 0, &x, &y, &unused_cr); + XGetGeometry(R->Xdisplay, R->TermWin.parent[0], &unused_cr, &x1, &y1, + &unused_w1, &unused_h1, &unused_b1, &unused_d1); + /* + * if Xroot isn't the parent window, a WM will probably have offset + * our position for handles and decorations. Counter it + */ + if (x1 != x || y1 != y) { + x -= x1; + y -= y1; + } + + x1 = (DisplayWidth(R->Xdisplay, Xscreen) - old_width) / 2; + y1 = (DisplayHeight(R->Xdisplay, Xscreen) - old_height) / 2; + dx = old_width - R->szHint.width; + dy = old_height - R->szHint.height; + + /* Check position of the center of the window */ + if (x < x1) /* left half */ + dx = 0; + else if (x == x1) /* exact center */ + dx /= 2; + if (y < y1) /* top half */ + dy = 0; + else if (y == y1) /* exact center */ + dy /= 2; + + XMoveResizeWindow(R->Xdisplay, R->TermWin.parent[0], x + dx, y + dy, + R->szHint.width, R->szHint.height); #else - XResizeWindow(R->Xdisplay, R->TermWin.parent[0], R->szHint.width, - R->szHint.height); + XResizeWindow(R->Xdisplay, R->TermWin.parent[0], R->szHint.width, + R->szHint.height); #endif } - fix_screen = (R->TermWin.ncol != R->h->prev_ncol - || R->TermWin.nrow != R->h->prev_nrow); - if (fix_screen || width != R->h->old_width || height != R->h->old_height) { - if (scrollbar_visible(R)) { - XMoveResizeWindow(R->Xdisplay, R->scrollBar.win, R->h->window_sb_x, - 0, scrollbar_TotalWidth(), R->szHint.height); - rxvt_Resize_scrollBar(aR); - } - if (menubar_visible(R)) - XMoveResizeWindow(R->Xdisplay, R->menuBar.win, R->h->window_vt_x, - 0, TermWin_TotalWidth(), menuBar_TotalHeight()); - XMoveResizeWindow(R->Xdisplay, R->TermWin.vt, R->h->window_vt_x, - R->h->window_vt_y, TermWin_TotalWidth(), - TermWin_TotalHeight()); + fix_screen = (R->TermWin.ncol != R->prev_ncol + || R->TermWin.nrow != R->prev_nrow); + if (fix_screen || width != R->old_width || height != R->old_height) { + if (scrollbar_visible(R)) { + XMoveResizeWindow(R->Xdisplay, R->scrollBar.win, R->window_sb_x, + 0, scrollbar_TotalWidth(), R->szHint.height); + rxvt_Resize_scrollBar(aR); + } + if (menubar_visible(R)) + XMoveResizeWindow(R->Xdisplay, R->menuBar.win, R->window_vt_x, + 0, TermWin_TotalWidth(), menuBar_TotalHeight()); + XMoveResizeWindow(R->Xdisplay, R->TermWin.vt, R->window_vt_x, + R->window_vt_y, TermWin_TotalWidth(), + TermWin_TotalHeight()); #ifdef RXVT_GRAPHICS - if (R->h->old_height) - rxvt_Gr_Resize(aR_ R->h->old_width - R->szHint.base_width, - R->h->old_height - R->szHint.base_height); + if (R->old_height) + rxvt_Gr_Resize(aR_ R->old_width - R->szHint.base_width, + R->old_height - R->szHint.base_height); #endif - rxvt_scr_clear(aR); + rxvt_scr_clear(aR); #ifdef XPM_BACKGROUND - rxvt_resize_pixmap(aR); + rxvt_resize_pixmap(aR); #endif } - if (fix_screen || R->h->old_height == 0) { - int curr_screen = -1; - uint16_t old_ncol = R->h->prev_ncol; - - /* scr_reset only works on the primary screen */ - if (R->h->old_height) /* this is not the first time through */ - curr_screen = rxvt_scr_change_screen(aR_ PRIMARY); - rxvt_scr_reset(aR); - if (curr_screen >= 0) { /* this is not the first time through */ - rxvt_scr_change_screen(aR_ curr_screen); - rxvt_selection_check(aR_ (old_ncol != R->TermWin.ncol ? 4 : 0)); - } + if (fix_screen || R->old_height == 0) { + int curr_screen = -1; + uint16_t old_ncol = R->prev_ncol; + + /* scr_reset only works on the primary screen */ + if (R->old_height) /* this is not the first time through */ + curr_screen = rxvt_scr_change_screen(aR_ PRIMARY); + rxvt_scr_reset(aR); + if (curr_screen >= 0) { /* this is not the first time through */ + rxvt_scr_change_screen(aR_ curr_screen); + rxvt_selection_check(aR_(old_ncol != R->TermWin.ncol ? 4 : 0)); + } } - R->h->old_width = R->szHint.width; - R->h->old_height = R->szHint.height; + R->old_width = R->szHint.width; + R->old_height = R->szHint.height; #ifdef USE_XIM rxvt_IMSetStatusPosition(aR); @@ -853,16 +888,16 @@ rxvt_set_widthheight(pR_ unsigned int width, unsigned int height) XWindowAttributes wattr; if (width == 0 || height == 0) { - XGetWindowAttributes(R->Xdisplay, Xroot, &wattr); - if (width == 0) - width = wattr.width - R->szHint.base_width; - if (height == 0) - height = wattr.height - R->szHint.base_height; + XGetWindowAttributes(R->Xdisplay, Xroot, &wattr); + if (width == 0) + width = wattr.width - R->szHint.base_width; + if (height == 0) + height = wattr.height - R->szHint.base_height; } if (width != R->TermWin.width || height != R->TermWin.height) { - width += R->szHint.base_width; - height += R->szHint.base_height; - rxvt_resize_all_windows(aR_ width, height, 0); + width += R->szHint.base_width; + height += R->szHint.base_height; + rxvt_resize_all_windows(aR_ width, height, 0); } } @@ -872,7 +907,7 @@ rxvt_set_widthheight(pR_ unsigned int width, unsigned int height) #ifdef USE_XIM /* INTPROTO */ void -rxvt_setSize(pR_ XRectangle *size) +rxvt_setSize(pR_ XRectangle * size) { size->x = R->TermWin.int_bwidth; size->y = R->TermWin.int_bwidth; @@ -898,17 +933,17 @@ rxvt_IMisRunning(pR) Window win; char server[IMBUFSIZ]; - /* get current locale modifier */ +/* get current locale modifier */ if ((p = XSetLocaleModifiers(NULL)) != NULL) { - STRCPY(server, "@server="); - STRNCAT(server, &(p[4]), IMBUFSIZ - 9); /* skip "@im=" */ - if ((p = STRCHR(server + 1, '@')) != NULL) /* first one only */ - *p = '\0'; - - atom = XInternAtom(R->Xdisplay, server, False); - win = XGetSelectionOwner(R->Xdisplay, atom); - if (win != None) - return True; + STRCPY(server, "@server="); + STRNCAT(server, &(p[4]), IMBUFSIZ - 9); /* skip "@im=" */ + if ((p = STRCHR(server + 1, '@')) != NULL) /* first one only */ + *p = '\0'; + + atom = XInternAtom(R->Xdisplay, server, False); + win = XGetSelectionOwner(R->Xdisplay, atom); + if (win != None) + return True; } return False; } @@ -920,22 +955,20 @@ rxvt_IMSendSpot(pR) XPoint spot; XVaNestedList preedit_attr; - if (R->h->Input_Context == NULL - || !R->TermWin.focus - || !(R->h->input_style & XIMPreeditPosition) - || !(R->h->event_type == KeyPress - || R->h->event_type == Expose - || R->h->event_type == NoExpose - || R->h->event_type == SelectionNotify - || R->h->event_type == ButtonRelease - || R->h->event_type == FocusIn) - || !rxvt_IMisRunning(aR)) - return; + 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)) + return; - rxvt_setPosition(aR_ &spot); + rxvt_setPosition(aR_ & spot); preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); - XSetICValues(R->h->Input_Context, XNPreeditAttributes, preedit_attr, NULL); + XSetICValues(R->Input_Context, XNPreeditAttributes, preedit_attr, NULL); XFree(preedit_attr); } @@ -948,17 +981,18 @@ rxvt_setTermFontSet(pR_ int idx) int success = 0; if (idx < 0 || idx >= MAX_NFONTS) - return; + return; } /* INTPROTO */ void -rxvt_setPreeditArea(pR_ XRectangle *preedit_rect, XRectangle *status_rect, XRectangle *needed_rect) +rxvt_setPreeditArea(pR_ XRectangle * preedit_rect, XRectangle * status_rect, + XRectangle * needed_rect) { int mbh, vtx = 0; if (scrollbar_visible(R) && !(R->Options & Opt_scrollBar_right)) - vtx = scrollbar_TotalWidth(); + vtx = scrollbar_TotalWidth(); mbh = menubar_visible(R) ? menuBar_TotalHeight() : 0; mbh -= R->TermWin.lineSpace; @@ -966,29 +1000,31 @@ rxvt_setPreeditArea(pR_ XRectangle *preedit_rect, XRectangle *status_rect, XRect preedit_rect->y = Height2Pixel(R->TermWin.nrow - 1) + mbh; preedit_rect->width = Width2Pixel(R->TermWin.ncol + 1) - needed_rect->width - + vtx; + + vtx; preedit_rect->height = Height2Pixel(1); status_rect->x = vtx; status_rect->y = Height2Pixel(R->TermWin.nrow - 1) + mbh; status_rect->width = needed_rect->width ? needed_rect->width - : Width2Pixel(R->TermWin.ncol + 1); + : Width2Pixel(R->TermWin.ncol + 1); status_rect->height = Height2Pixel(1); } /* ARGSUSED */ /* INTPROTO */ void -rxvt_IMDestroyCallback(XIM xim __attribute__((unused)), XPointer client_data __attribute__((unused)), XPointer call_data __attribute__((unused))) +rxvt_IMDestroyCallback(XIM xim __attribute__ ((unused)), XPointer client_data + __attribute__ ((unused)), XPointer call_data + __attribute__ ((unused))) { dR; - R->h->Input_Context = NULL; - /* To avoid Segmentation Fault in C locale: Solaris only? */ - if (STRCMP(R->h->locale, "C")) - XRegisterIMInstantiateCallback(R->Xdisplay, NULL, NULL, NULL, - rxvt_IMInstantiateCallback, NULL); + R->Input_Context = NULL; +/* To avoid Segmentation Fault in C locale: Solaris only? */ + if (STRCMP(R->locale, "C")) + XRegisterIMInstantiateCallback(R->Xdisplay, NULL, NULL, NULL, + rxvt_IMInstantiateCallback, NULL); } /* @@ -1000,7 +1036,10 @@ rxvt_IMDestroyCallback(XIM xim __attribute__((unused)), XPointer client_data __a /* ARGSUSED */ /* EXTPROTO */ void -rxvt_IMInstantiateCallback(Display *unused __attribute__((unused)), XPointer client_data __attribute__((unused)), XPointer call_data __attribute__((unused))) +rxvt_IMInstantiateCallback(Display * unused + __attribute__ ((unused)), XPointer client_data + __attribute__ ((unused)), XPointer call_data + __attribute__ ((unused))) { dR; int i, found, had_im; @@ -1009,42 +1048,42 @@ rxvt_IMInstantiateCallback(Display *unused __attribute__((unused)), XPointer cli char buf[IMBUFSIZ]; D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); - if (R->h->Input_Context) - return; + if (R->Input_Context) + return; found = had_im = 0; - p = R->h->rs[Rs_inputMethod]; + p = R->rs[Rs_inputMethod]; if (p && *p) { - had_im = 1; - s = rxvt_splitcommastring(p); - for (i = 0; s[i]; i++) { - if (*s[i]) { - STRCPY(buf, "@im="); - STRNCAT(buf, s[i], IMBUFSIZ - 5); - if ((p = XSetLocaleModifiers(buf)) != NULL && *p - && (rxvt_IM_get_IC(aR) == True)) { - found = 1; - break; - } - } - } - for (i = 0; s[i]; i++) - free(s[i]); - free(s); + had_im = 1; + s = rxvt_splitcommastring(p); + for (i = 0; s[i]; i++) { + if (*s[i]) { + STRCPY(buf, "@im="); + STRNCAT(buf, s[i], IMBUFSIZ - 5); + if ((p = XSetLocaleModifiers(buf)) != NULL && *p + && (rxvt_IM_get_IC(aR) == True)) { + found = 1; + break; + } + } + } + for (i = 0; s[i]; i++) + free(s[i]); + free(s); } if (found) - return; + return; /* try with XMODIFIERS env. var. */ if ((p = XSetLocaleModifiers("")) != NULL && *p) { - rxvt_IM_get_IC(aR); - return; + rxvt_IM_get_IC(aR); + return; } /* try with no modifiers base IF the user didn't specify an IM */ if (!had_im && (p = XSetLocaleModifiers("@im=none")) != NULL && *p - && rxvt_IM_get_IC(aR) == True) - return; + && rxvt_IM_get_IC(aR) == True) + return; } /* @@ -1065,106 +1104,102 @@ rxvt_IM_get_IC(pR) XIMStyles *xim_styles; XVaNestedList preedit_attr, status_attr; XIMCallback ximcallback; - struct rxvt_hidden *h = R->h; D_MAIN((stderr, "rxvt_IM_get_IC()")); xim = XOpenIM(R->Xdisplay, NULL, NULL, NULL); if (xim == NULL) - return False; + return False; xim_styles = NULL; if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) - || !xim_styles || !xim_styles->count_styles) { - XCloseIM(xim); - return False; + || !xim_styles || !xim_styles->count_styles) { + XCloseIM(xim); + return False; } - p = h->rs[Rs_preeditType] ? h->rs[Rs_preeditType] - : "OverTheSpot,OffTheSpot,Root"; + p = R->rs[Rs_preeditType] ? R->rs[Rs_preeditType] + : "OverTheSpot,OffTheSpot,Root"; s = rxvt_splitcommastring(p); for (i = found = 0; !found && s[i]; i++) { - if (!STRCMP(s[i], "OverTheSpot")) - h->input_style = (XIMPreeditPosition | XIMStatusNothing); - else if (!STRCMP(s[i], "OffTheSpot")) - h->input_style = (XIMPreeditArea | XIMStatusArea); - else if (!STRCMP(s[i], "Root")) - h->input_style = (XIMPreeditNothing | XIMStatusNothing); - - for (j = 0; j < xim_styles->count_styles; j++) - if (h->input_style == xim_styles->supported_styles[j]) { - found = 1; - break; - } + if (!STRCMP(s[i], "OverTheSpot")) + R->input_style = (XIMPreeditPosition | XIMStatusNothing); + else if (!STRCMP(s[i], "OffTheSpot")) + R->input_style = (XIMPreeditArea | XIMStatusArea); + else if (!STRCMP(s[i], "Root")) + R->input_style = (XIMPreeditNothing | XIMStatusNothing); + + for (j = 0; j < xim_styles->count_styles; j++) + if (R->input_style == xim_styles->supported_styles[j]) { + found = 1; + break; + } } for (i = 0; s[i]; i++) - free(s[i]); + free(s[i]); free(s); XFree(xim_styles); if (!found) { - XCloseIM(xim); - return False; + XCloseIM(xim); + return False; } ximcallback.callback = rxvt_IMDestroyCallback; - /* XXX: not sure why we need this (as well as IC one below) */ +/* XXX: not sure why we need this (as well as IC one below) */ XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL); preedit_attr = status_attr = NULL; - if (h->input_style & XIMPreeditPosition) { - rxvt_setSize(aR_ &rect); - rxvt_setPosition(aR_ &spot); - rxvt_setColor(aR_ &fg, &bg); - - preedit_attr = XVaCreateNestedList(0, XNArea, &rect, - XNSpotLocation, &spot, - XNForeground, fg, - XNBackground, bg, - //XNFontSet, R->TermWin.fontset, - NULL); - } else if (h->input_style & XIMPreeditArea) { - rxvt_setColor(aR_ &fg, &bg); - - /* - * The necessary width of preedit area is unknown - * until create input context. - */ - needed_rect.width = 0; - - rxvt_setPreeditArea(aR_ &rect, &status_rect, &needed_rect); - - preedit_attr = XVaCreateNestedList(0, XNArea, &rect, - XNForeground, fg, - XNBackground, bg, - //XNFontSet, R->TermWin.fontset, - NULL); - status_attr = XVaCreateNestedList(0, XNArea, &status_rect, - XNForeground, fg, - XNBackground, bg, - //XNFontSet, R->TermWin.fontset, + if (R->input_style & XIMPreeditPosition) { + rxvt_setSize(aR_ & rect); + rxvt_setPosition(aR_ & spot); + rxvt_setColor(aR_ & fg, &bg); + + preedit_attr = XVaCreateNestedList(0, XNArea, &rect, + XNSpotLocation, &spot, + XNForeground, fg, XNBackground, bg, + //XNFontSet, R->TermWin.fontset, + NULL); + } else if (R->input_style & XIMPreeditArea) { + rxvt_setColor(aR_ & fg, &bg); + + /* + * The necessary width of preedit area is unknown + * until create input context. + */ + needed_rect.width = 0; + + rxvt_setPreeditArea(aR_ & rect, &status_rect, &needed_rect); + + preedit_attr = XVaCreateNestedList(0, XNArea, &rect, + XNForeground, fg, XNBackground, bg, + //XNFontSet, R->TermWin.fontset, + NULL); + status_attr = XVaCreateNestedList(0, XNArea, &status_rect, + XNForeground, fg, XNBackground, bg, + //XNFontSet, R->TermWin.fontset, NULL); } - h->Input_Context = XCreateIC(xim, XNInputStyle, h->input_style, - XNClientWindow, R->TermWin.parent[0], - XNFocusWindow, R->TermWin.parent[0], - XNDestroyCallback, &ximcallback, - preedit_attr ? XNPreeditAttributes : NULL, - preedit_attr, - status_attr ? XNStatusAttributes : NULL, - status_attr, NULL); + R->Input_Context = XCreateIC(xim, XNInputStyle, R->input_style, + XNClientWindow, R->TermWin.parent[0], + XNFocusWindow, R->TermWin.parent[0], + XNDestroyCallback, &ximcallback, + preedit_attr ? XNPreeditAttributes : NULL, + preedit_attr, + status_attr ? XNStatusAttributes : NULL, + status_attr, NULL); if (preedit_attr) - XFree(preedit_attr); + XFree(preedit_attr); if (status_attr) - XFree(status_attr); - if (h->Input_Context == NULL) { - rxvt_print_error("failed to create input context"); - XCloseIM(xim); - return False; + XFree(status_attr); + if (R->Input_Context == NULL) { + rxvt_print_error("failed to create input context"); + XCloseIM(xim); + return False; } - if (h->input_style & XIMPreeditArea) - rxvt_IMSetStatusPosition(aR); + if (R->input_style & XIMPreeditArea) + rxvt_IMSetStatusPosition(aR); D_MAIN((stderr, "rxvt_IM_get_IC() - successful connection")); return True; } @@ -1176,32 +1211,31 @@ rxvt_IMSetStatusPosition(pR) XRectangle preedit_rect, status_rect, *needed_rect; XVaNestedList preedit_attr, status_attr; - if (R->h->Input_Context == NULL - || !R->TermWin.focus - || !(R->h->input_style & XIMPreeditArea) - || !rxvt_IMisRunning(aR)) - return; + if (R->Input_Context == NULL + || !R->TermWin.focus || !(R->input_style & XIMPreeditArea) + || !rxvt_IMisRunning(aR)) + return; - /* Getting the necessary width of preedit area */ +/* Getting the necessary width of preedit area */ status_attr = XVaCreateNestedList(0, XNAreaNeeded, &needed_rect, NULL); - XGetICValues(R->h->Input_Context, XNStatusAttributes, status_attr, NULL); + XGetICValues(R->Input_Context, XNStatusAttributes, status_attr, NULL); XFree(status_attr); - rxvt_setPreeditArea(aR_ &preedit_rect, &status_rect, needed_rect); + rxvt_setPreeditArea(aR_ & preedit_rect, &status_rect, needed_rect); preedit_attr = XVaCreateNestedList(0, XNArea, &preedit_rect, NULL); status_attr = XVaCreateNestedList(0, XNArea, &status_rect, NULL); - XSetICValues(R->h->Input_Context, - XNPreeditAttributes, preedit_attr, - XNStatusAttributes, status_attr, NULL); + XSetICValues(R->Input_Context, + XNPreeditAttributes, preedit_attr, + XNStatusAttributes, status_attr, NULL); XFree(preedit_attr); XFree(status_attr); } -#endif /* USE_XIM */ +#endif /* USE_XIM */ /*----------------------------------------------------------------------*/ -rxvt_t *rxvt_current_term; +rxvt_t rxvt_current_term; /*----------------------- end-of-file (C source) -----------------------*/ diff --git a/src/menubar.C b/src/menubar.C index 02894ef1..c557fb23 100644 --- a/src/menubar.C +++ b/src/menubar.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: menubar.c *----------------------------------------------------------------------* - * $Id: menubar.C,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: menubar.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * @@ -198,7 +198,7 @@ rxvt_menuarrow_free(pR_ char name) if (name) { i = rxvt_menuarrow_find(name); if (i >= 0) { - action_t *act = &(R->h->CurrentBar->arrows[i]); + action_t *act = &(R->CurrentBar->arrows[i]); switch (act->type) { case MenuAction: @@ -331,7 +331,7 @@ 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->h->CurrentBar->arrows[i]), str) < 0) + if (rxvt_action_type(&(R->CurrentBar->arrows[i]), str) < 0) free(str); } } @@ -449,7 +449,7 @@ rxvt_menu_find_base(pR_ menu_t **menu, char *path) #ifdef DEBUG_STRICT assert(menu != NULL); - assert(R->h->CurrentBar != NULL); + assert(R->CurrentBar != NULL); #endif if (path[0] == '\0') @@ -495,7 +495,7 @@ rxvt_menu_find_base(pR_ menu_t **menu, char *path) } /* find this menu */ if (*menu == NULL) { - for (m = R->h->CurrentBar->tail; m != NULL; m = m->prev) { + for (m = R->CurrentBar->tail; m != NULL; m = m->prev) { if (!STRCMP(path, m->name)) break; } @@ -525,7 +525,7 @@ rxvt_menu_delete(pR_ menu_t *menu) { menu_t *parent = NULL, *prev, *next; menuitem_t *item; - bar_t *CurrentBar = R->h->CurrentBar; + bar_t *CurrentBar = R->CurrentBar; #ifdef DEBUG_STRICT assert(CurrentBar != NULL); @@ -587,7 +587,7 @@ menu_t * rxvt_menu_add(pR_ menu_t *parent, char *path) { menu_t *menu; - bar_t *CurrentBar = R->h->CurrentBar; + bar_t *CurrentBar = R->CurrentBar; #ifdef DEBUG_STRICT assert(CurrentBar != NULL); @@ -679,15 +679,15 @@ rxvt_drawbox_menubar(pR_ int x, int len, int state) #endif switch (state) { case +1: - top = R->h->topShadowGC; - bot = R->h->botShadowGC; + top = R->topShadowGC; + bot = R->botShadowGC; break; /* SHADOW_OUT */ case -1: - top = R->h->botShadowGC; - bot = R->h->topShadowGC; + top = R->botShadowGC; + bot = R->topShadowGC; break; /* SHADOW_IN */ default: - top = bot = R->h->scrollbarGC; + top = bot = R->scrollbarGC; break; /* neutral */ } @@ -707,15 +707,15 @@ rxvt_drawtriangle(pR_ int x, int y, int state) #endif switch (state) { case +1: - top = R->h->topShadowGC; - bot = R->h->botShadowGC; + top = R->topShadowGC; + bot = R->botShadowGC; break; /* SHADOW_OUT */ case -1: - top = R->h->botShadowGC; - bot = R->h->topShadowGC; + top = R->botShadowGC; + bot = R->topShadowGC; break; /* SHADOW_IN */ default: - top = bot = R->h->scrollbarGC; + top = bot = R->scrollbarGC; break; /* neutral */ } @@ -724,7 +724,7 @@ rxvt_drawtriangle(pR_ int x, int y, int state) x -= SHADOW + (3 * w / 2); y += SHADOW * 3; - rxvt_Draw_Triangle(R->Xdisplay, R->h->ActiveMenu->win, top, bot, x, y, w, + rxvt_Draw_Triangle(R->Xdisplay, R->ActiveMenu->win, top, bot, x, y, w, 'r'); } @@ -739,21 +739,21 @@ rxvt_drawbox_menuitem(pR_ int y, int state) #endif switch (state) { case +1: - top = R->h->topShadowGC; - bot = R->h->botShadowGC; + top = R->topShadowGC; + bot = R->botShadowGC; break; /* SHADOW_OUT */ case -1: - top = R->h->botShadowGC; - bot = R->h->topShadowGC; + top = R->botShadowGC; + bot = R->topShadowGC; break; /* SHADOW_IN */ default: - top = bot = R->h->scrollbarGC; + top = bot = R->scrollbarGC; break; /* neutral */ } - rxvt_Draw_Shadow(R->Xdisplay, R->h->ActiveMenu->win, top, bot, + rxvt_Draw_Shadow(R->Xdisplay, R->ActiveMenu->win, top, bot, SHADOW + 0, SHADOW + y, - R->h->ActiveMenu->w - 2 * (SHADOW), + R->ActiveMenu->w - 2 * (SHADOW), HEIGHT_TEXT + 2 * SHADOW); XFlush(R->Xdisplay); } @@ -832,7 +832,7 @@ void rxvt_menu_show(pR) { int x, y, xright; - menu_t *ActiveMenu = R->h->ActiveMenu; + menu_t *ActiveMenu = R->ActiveMenu; menuitem_t *item; if (ActiveMenu == NULL) @@ -867,7 +867,7 @@ rxvt_menu_show(pR) XMapWindow(R->Xdisplay, ActiveMenu->win); } rxvt_Draw_Shadow(R->Xdisplay, ActiveMenu->win, - R->h->topShadowGC, R->h->botShadowGC, + R->topShadowGC, R->botShadowGC, 0, 0, ActiveMenu->w, ActiveMenu->h); /* determine the correct right-alignment */ @@ -878,11 +878,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->h->menubarGC; + GC gc = R->menubarGC; if (isSeparator(item->name)) { rxvt_Draw_Shadow(R->Xdisplay, ActiveMenu->win, - R->h->topShadowGC, R->h->botShadowGC, + R->topShadowGC, R->botShadowGC, SHADOW, y + SHADOW + 1, ActiveMenu->w - 2 * SHADOW, 0); h = HEIGHT_SEPARATOR; @@ -891,7 +891,7 @@ rxvt_menu_show(pR) int len = item->len; if (item->entry.type == MenuLabel) { - gc = R->h->botShadowGC; + gc = R->botShadowGC; } else if (item->entry.type == MenuSubMenu) { int x1, y1; menuitem_t *it; @@ -973,7 +973,7 @@ rxvt_menu_show(pR) void rxvt_menu_display(pR_ void (*update)(rxvt_t *)) { - menu_t *ActiveMenu = R->h->ActiveMenu; + menu_t *ActiveMenu = R->ActiveMenu; if (ActiveMenu == NULL) return; @@ -984,7 +984,7 @@ rxvt_menu_display(pR_ void (*update)(rxvt_t *)) if (ActiveMenu->parent == NULL) rxvt_drawbox_menubar(aR_ ActiveMenu->x, ActiveMenu->len, +1); - R->h->ActiveMenu = ActiveMenu->parent; + R->ActiveMenu = ActiveMenu->parent; update(r); } @@ -1024,7 +1024,7 @@ rxvt_menu_clear(pR_ menu_t *menu) void rxvt_menubar_clear(pR) { - bar_t *CurrentBar = R->h->CurrentBar; + bar_t *CurrentBar = R->CurrentBar; if (CurrentBar != NULL) { menu_t *menu = CurrentBar->tail; @@ -1043,7 +1043,7 @@ rxvt_menubar_clear(pR) } rxvt_menuarrow_free(aR_ 0); /* remove all arrow functions */ } - R->h->ActiveMenu = NULL; + R->ActiveMenu = NULL; } #if (MENUBAR_MAX > 1) @@ -1052,7 +1052,7 @@ rxvt_menubar_clear(pR) bar_t * rxvt_menubar_find(pR_ const char *name) { - bar_t *bar = R->h->CurrentBar; + bar_t *bar = R->CurrentBar; #ifdef DEBUG_MENUBAR_STACKING fprintf(stderr, "looking for [menu:%s] ...", name ? name : "(nil)"); @@ -1070,7 +1070,7 @@ rxvt_menubar_find(pR_ const char *name) } bar = bar->next; } - while (bar != R->h->CurrentBar); + while (bar != R->CurrentBar); bar = NULL; } #ifdef DEBUG_MENUBAR_STACKING @@ -1087,7 +1087,7 @@ rxvt_menubar_push(pR_ const char *name) int ret = 1; bar_t *bar; - if (R->h->CurrentBar == NULL) { + if (R->CurrentBar == NULL) { /* allocate first one */ bar = (bar_t *) rxvt_malloc(sizeof(bar_t)); @@ -1096,8 +1096,8 @@ rxvt_menubar_push(pR_ const char *name) bar->next = bar->prev = bar; bar->head = bar->tail = NULL; bar->title = NULL; - R->h->CurrentBar = bar; - R->h->Nbars++; + R->CurrentBar = bar; + R->Nbars++; rxvt_menubar_clear(aR); } else { @@ -1105,32 +1105,32 @@ rxvt_menubar_push(pR_ const char *name) bar = rxvt_menubar_find(aR_ name); if (bar != NULL) { /* found it, use it */ - R->h->CurrentBar = bar; + R->CurrentBar = bar; } else { /* create if needed, or reuse the existing empty menubar */ - if (R->h->CurrentBar->head != NULL) { + if (R->CurrentBar->head != NULL) { /* need to malloc another one */ - if (R->h->Nbars < MENUBAR_MAX) + if (R->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->h->CurrentBar->next; + bar = R->CurrentBar->next; ret = -1; } else { bar->head = bar->tail = NULL; bar->title = NULL; - bar->next = R->h->CurrentBar->next; - R->h->CurrentBar->next = bar; - bar->prev = R->h->CurrentBar; + bar->next = R->CurrentBar->next; + R->CurrentBar->next = bar; + bar->prev = R->CurrentBar; bar->next->prev = bar; - R->h->Nbars++; + R->Nbars++; } - R->h->CurrentBar = bar; + R->CurrentBar = bar; } rxvt_menubar_clear(aR); @@ -1138,8 +1138,8 @@ rxvt_menubar_push(pR_ const char *name) } /* give menubar this name */ - STRNCPY(R->h->CurrentBar->name, name, MAXNAME); - R->h->CurrentBar->name[MAXNAME - 1] = '\0'; + STRNCPY(R->CurrentBar->name, name, MAXNAME); + R->CurrentBar->name[MAXNAME - 1] = '\0'; return ret; } @@ -1153,31 +1153,31 @@ rxvt_menubar_remove(pR_ const char *name) if ((bar = rxvt_menubar_find(aR_ name)) == NULL) return; - R->h->CurrentBar = bar; + R->CurrentBar = bar; do { rxvt_menubar_clear(aR); /* * pop a menubar, clean it up first */ - if (R->h->CurrentBar != NULL) { - bar_t *prev = R->h->CurrentBar->prev; - bar_t *next = R->h->CurrentBar->next; + if (R->CurrentBar != NULL) { + bar_t *prev = R->CurrentBar->prev; + bar_t *next = R->CurrentBar->next; - if (prev == next && prev == R->h->CurrentBar) { /* only 1 left */ + if (prev == next && prev == R->CurrentBar) { /* only 1 left */ prev = NULL; - R->h->Nbars = 0; /* safety */ + R->Nbars = 0; /* safety */ } else { next->prev = prev; prev->next = next; - R->h->Nbars--; + R->Nbars--; } - free(R->h->CurrentBar); - R->h->CurrentBar = prev; + free(R->CurrentBar); + R->CurrentBar = prev; } } - while (R->h->CurrentBar && !STRCMP(name, "*")); + while (R->CurrentBar && !STRCMP(name, "*")); } /* INTPROTO */ @@ -1292,7 +1292,7 @@ rxvt_menu_dump(FILE *fp, menu_t *menu) void rxvt_menubar_dump(pR_ FILE *fp) { - bar_t *bar = R->h->CurrentBar; + bar_t *bar = R->CurrentBar; time_t t; if (bar == NULL || fp == NULL) @@ -1301,10 +1301,10 @@ rxvt_menubar_dump(pR_ FILE *fp) fprintf(fp, "# " APL_SUBCLASS " (%s) Pid: %u\n# Date: %s\n\n", - R->h->rs[Rs_name], (unsigned int)getpid(), ctime(&t)); + R->rs[Rs_name], (unsigned int)getpid(), ctime(&t)); /* dump in reverse order */ - bar = R->h->CurrentBar->prev; + bar = R->CurrentBar->prev; do { menu_t *menu; int i; @@ -1331,7 +1331,7 @@ rxvt_menubar_dump(pR_ FILE *fp) fprintf(fp, "\n[done:%s]\n\n", bar->name); bar = bar->prev; } - while (bar != R->h->CurrentBar->prev); + while (bar != R->CurrentBar->prev); } #endif /* (MENUBAR_MAX > 1) */ @@ -1359,7 +1359,7 @@ rxvt_menubar_read(pR_ const char *filename) char buffer[256]; char *p, *file, *tag = NULL; - file = (char *)rxvt_File_find(filename, ".menu", R->h->rs[Rs_path]); + file = (char *)rxvt_File_find(filename, ".menu", R->rs[Rs_path]); if (file == NULL) return; fp = fopen(file, "rb"); @@ -1413,12 +1413,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->h->menu_readonly = 1; + R->menu_readonly = 1; break; } else if (p[n] == ':') { n++; if (p[n] == ']') { - R->h->menu_readonly = 1; + R->menu_readonly = 1; break; } else if (tag) { n += rxvt_Str_match(p + n, tag); @@ -1426,7 +1426,7 @@ rxvt_menubar_read(pR_ const char *filename) #ifdef DEBUG_MENU fprintf(stderr, "[done:%s]\n", tag); #endif - R->h->menu_readonly = 1; + R->menu_readonly = 1; break; } } else { @@ -1442,7 +1442,7 @@ rxvt_menubar_read(pR_ const char *filename) */ rxvt_Str_trim(p); if (*p && *p != '#') { - R->h->menu_readonly = 0; /* if case we read another file */ + R->menu_readonly = 0; /* if case we read another file */ rxvt_menubar_dispatch(aR_ p); } /* get another line */ @@ -1462,10 +1462,10 @@ rxvt_menubar_dispatch(pR_ char *str) int n, cmd; char *path, *name, *name2; - if (menubar_visible(r) && R->h->ActiveMenu != NULL) + if (menubar_visible(r) && R->ActiveMenu != NULL) rxvt_menubar_expose(aR); else - R->h->ActiveMenu = NULL; + R->ActiveMenu = NULL; cmd = *str; switch (cmd) { @@ -1483,7 +1483,7 @@ rxvt_menubar_dispatch(pR_ char *str) case '<': #if (MENUBAR_MAX > 1) - if (R->h->CurrentBar == NULL) + if (R->CurrentBar == NULL) break; #endif /* (MENUBAR_MAX > 1) */ if (str[1] && str[2] == '>') /* arrow commands */ @@ -1516,40 +1516,40 @@ rxvt_menubar_dispatch(pR_ char *str) int saved; /* try and dispatch it, regardless of read/write status */ - saved = R->h->menu_readonly; - R->h->menu_readonly = 0; + saved = R->menu_readonly; + R->menu_readonly = 0; rxvt_menubar_dispatch(aR_ str + 1); - R->h->menu_readonly = saved; + R->menu_readonly = saved; } /* these ones don't require menu stacking */ else if (!STRCMP(str, "clear")) { rxvt_menubar_clear(aR); } else if (!STRCMP(str, "done") || rxvt_Str_match(str, "done:")) { - R->h->menu_readonly = 1; + R->menu_readonly = 1; } else if (!STRCMP(str, "show")) { rxvt_map_menuBar(aR_ 1); - R->h->menu_readonly = 1; + R->menu_readonly = 1; } else if (!STRCMP(str, "hide")) { rxvt_map_menuBar(aR_ 0); - R->h->menu_readonly = 1; + R->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); } else if ((n = rxvt_Str_match(str, "title:")) != 0) { str += n; - if (R->h->CurrentBar != NULL && !R->h->menu_readonly) { + if (R->CurrentBar != NULL && !R->menu_readonly) { if (*str) { - name = rxvt_realloc(R->h->CurrentBar->title, + name = rxvt_realloc(R->CurrentBar->title, STRLEN(str) + 1); if (name != NULL) { STRCPY(name, str); - R->h->CurrentBar->title = name; + R->CurrentBar->title = name; } rxvt_menubar_expose(aR); } else { - free(R->h->CurrentBar->title); - R->h->CurrentBar->title = NULL; + free(R->CurrentBar->title); + R->CurrentBar->title = NULL; } } } else if ((n = rxvt_Str_match(str, "pixmap:")) != 0) { @@ -1569,7 +1569,7 @@ rxvt_menubar_dispatch(pR_ char *str) rxvt_menubar_remove(aR_ str); break; } - R->h->menu_readonly = 1; + R->menu_readonly = 1; } else if ((n = rxvt_Str_match(str, "menu")) != 0) { str += n; switch (str[0]) { @@ -1580,13 +1580,13 @@ rxvt_menubar_dispatch(pR_ char *str) rxvt_menubar_push(aR_ str); break; default: - if (R->h->CurrentBar == NULL) { + if (R->CurrentBar == NULL) { rxvt_menubar_push(aR_ "default"); } } - if (R->h->CurrentBar != NULL) - R->h->menu_readonly = 0; /* allow menu build commands */ + if (R->CurrentBar != NULL) + R->menu_readonly = 0; /* allow menu build commands */ } else if (!STRCMP(str, "dump")) { /* dump current menubars to a file */ FILE *fp; @@ -1603,42 +1603,42 @@ rxvt_menubar_dispatch(pR_ char *str) fclose(fp); } } else if (!STRCMP(str, "next")) { - if (R->h->CurrentBar) { - R->h->CurrentBar = R->h->CurrentBar->next; - R->h->menu_readonly = 1; + if (R->CurrentBar) { + R->CurrentBar = R->CurrentBar->next; + R->menu_readonly = 1; } } else if (!STRCMP(str, "prev")) { - if (R->h->CurrentBar) { - R->h->CurrentBar = R->h->CurrentBar->prev; - R->h->menu_readonly = 1; + if (R->CurrentBar) { + R->CurrentBar = R->CurrentBar->prev; + R->menu_readonly = 1; } } else if (!STRCMP(str, "swap")) { /* swap the top 2 menus */ - if (R->h->CurrentBar) { - bar_t *cbprev = R->h->CurrentBar->prev; - bar_t *cbnext = R->h->CurrentBar->next; + if (R->CurrentBar) { + bar_t *cbprev = R->CurrentBar->prev; + bar_t *cbnext = R->CurrentBar->next; cbprev->next = cbnext; cbnext->prev = cbprev; - R->h->CurrentBar->next = cbprev; - R->h->CurrentBar->prev = cbprev->prev; + R->CurrentBar->next = cbprev; + R->CurrentBar->prev = cbprev->prev; - cbprev->prev->next = R->h->CurrentBar; - cbprev->prev = R->h->CurrentBar; + cbprev->prev->next = R->CurrentBar; + cbprev->prev = R->CurrentBar; - R->h->CurrentBar = cbprev; - R->h->menu_readonly = 1; + R->CurrentBar = cbprev; + R->menu_readonly = 1; } } #endif /* (MENUBAR_MAX > 1) */ str = next; - R->h->BuildMenu = R->h->ActiveMenu = NULL; + R->BuildMenu = R->ActiveMenu = NULL; rxvt_menubar_expose(aR); #ifdef DEBUG_MENUBAR_STACKING fprintf(stderr, "menus are read%s\n", - R->h->menu_readonly ? "only" : "/write"); + R->menu_readonly ? "only" : "/write"); #endif } return; @@ -1646,12 +1646,12 @@ rxvt_menubar_dispatch(pR_ char *str) } #if (MENUBAR_MAX > 1) - if (R->h->CurrentBar == NULL) + if (R->CurrentBar == NULL) return; - if (R->h->menu_readonly) { + if (R->menu_readonly) { #ifdef DEBUG_MENUBAR_STACKING fprintf(stderr, "menus are read%s\n", - R->h->menu_readonly ? "only" : "/write"); + R->menu_readonly ? "only" : "/write"); #endif return; } @@ -1706,21 +1706,21 @@ rxvt_menubar_dispatch(pR_ char *str) if (path[0] != '\0') { int len; - path = rxvt_menu_find_base(aR_ &(R->h->BuildMenu), path); + path = rxvt_menu_find_base(aR_ &(R->BuildMenu), path); len = STRLEN(path); /* don't allow menus called `*' */ if (path[0] == '*') { - rxvt_menu_clear(aR_ R->h->BuildMenu); + rxvt_menu_clear(aR_ R->BuildMenu); break; } else if (len >= 2 && !STRCMP((path + len - 2), "/*")) { path[len - 2] = '\0'; } if (path[0] != '\0') - R->h->BuildMenu = rxvt_menu_add(aR_ R->h->BuildMenu, path); + R->BuildMenu = rxvt_menu_add(aR_ R->BuildMenu, path); } if (name != NULL && name[0] != '\0') - rxvt_menuitem_add(R->h->BuildMenu, + rxvt_menuitem_add(R->BuildMenu, (STRCMP(name, SEPARATOR_NAME) ? name : ""), name2, str); break; @@ -1728,12 +1728,12 @@ rxvt_menubar_dispatch(pR_ char *str) case '-': /* delete menu entry */ if (!STRCMP(path, "/*") && (name == NULL || name[0] == '\0')) { rxvt_menubar_clear(aR); - R->h->BuildMenu = NULL; + R->BuildMenu = NULL; rxvt_menubar_expose(aR); break; } else if (path[0] != '\0') { int len; - menu_t *menu = R->h->BuildMenu; + menu_t *menu = R->BuildMenu; path = rxvt_menu_find_base(aR_ &menu, path); len = STRLEN(path); @@ -1746,18 +1746,18 @@ rxvt_menubar_dispatch(pR_ char *str) /* done */ break; } else if (path[0] != '\0') { - R->h->BuildMenu = NULL; + R->BuildMenu = NULL; break; } else - R->h->BuildMenu = menu; + R->BuildMenu = menu; } - if (R->h->BuildMenu != NULL) { + if (R->BuildMenu != NULL) { if (name == NULL || name[0] == '\0') - R->h->BuildMenu = rxvt_menu_delete(aR_ R->h->BuildMenu); + R->BuildMenu = rxvt_menu_delete(aR_ R->BuildMenu); else { const char *n1; menuitem_t *item; - menu_t *BuildMenu = R->h->BuildMenu; + menu_t *BuildMenu = R->BuildMenu; n1 = STRCMP(name, SEPARATOR_NAME) ? name : ""; item = rxvt_menuitem_find(BuildMenu, n1); @@ -1795,25 +1795,25 @@ rxvt_draw_Arrows(pR_ int name, int state) #endif switch (state) { case +1: - top = R->h->topShadowGC; - bot = R->h->botShadowGC; + top = R->topShadowGC; + bot = R->botShadowGC; break; /* SHADOW_OUT */ case -1: - top = R->h->botShadowGC; - bot = R->h->topShadowGC; + top = R->botShadowGC; + bot = R->topShadowGC; break; /* SHADOW_IN */ default: - top = bot = R->h->scrollbarGC; + top = bot = R->scrollbarGC; break; /* neutral */ } - if (!R->h->Arrows_x) + if (!R->Arrows_x) return; for (i = 0; i < NARROWS; i++) { const int w = Width2Pixel(1); const int y = (menuBar_TotalHeight() - w) / 2; - int x = R->h->Arrows_x + (5 * Width2Pixel(i)) / 4; + int x = R->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, @@ -1832,7 +1832,7 @@ rxvt_menubar_expose(pR) if (!menubar_visible(r) || R->menuBar.win == 0) return; - if (R->h->menubarGC == None) { + if (R->menubarGC == None) { /* Create the graphics context */ XGCValues gcvalue; @@ -1840,20 +1840,20 @@ rxvt_menubar_expose(pR) gcvalue.foreground = (XDEPTH <= 2 ? R->PixColors[Color_fg] : R->PixColors[Color_Black]); - R->h->menubarGC = XCreateGC(R->Xdisplay, R->menuBar.win, + R->menubarGC = XCreateGC(R->Xdisplay, R->menuBar.win, GCForeground | GCFont, &gcvalue); } /* make sure the font is correct */ - XSetFont(R->Xdisplay, R->h->menubarGC, R->TermWin.font->fid); - XSetFont(R->Xdisplay, R->h->botShadowGC, R->TermWin.font->fid); + XSetFont(R->Xdisplay, R->menubarGC, R->TermWin.font->fid); + XSetFont(R->Xdisplay, R->botShadowGC, R->TermWin.font->fid); XClearWindow(R->Xdisplay, R->menuBar.win); rxvt_menu_hide_all(aR); x = 0; - if (R->h->CurrentBar != NULL) { - for (menu = R->h->CurrentBar->head; menu != NULL; menu = menu->next) { + if (R->CurrentBar != NULL) { + for (menu = R->CurrentBar->head; menu != NULL; menu = menu->next) { int len = menu->len; x = (menu->x + menu->len + HSPACE); @@ -1870,12 +1870,12 @@ rxvt_menubar_expose(pR) if (R->TermWin.fontset) XmbDrawString(R->Xdisplay, R->menuBar.win, R->TermWin.fontset, - R->h->menubarGC, + R->menubarGC, (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2), menuBar_height() - SHADOW, menu->name, len); else #endif - XDrawString(R->Xdisplay, R->menuBar.win, R->h->menubarGC, + XDrawString(R->Xdisplay, R->menuBar.win, R->menubarGC, (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2), menuBar_height() - SHADOW, menu->name, len); @@ -1883,10 +1883,10 @@ rxvt_menubar_expose(pR) break; } } - rxvt_drawbox_menubar(aR_ x, R->TermWin.ncol, (R->h->CurrentBar ? +1 : -1)); + rxvt_drawbox_menubar(aR_ x, R->TermWin.ncol, (R->CurrentBar ? +1 : -1)); /* add the menuBar title, if it exists and there's plenty of room */ - R->h->Arrows_x = 0; + R->Arrows_x = 0; if (x < R->TermWin.ncol) { const char *str; int ncol; @@ -1896,12 +1896,12 @@ rxvt_menubar_expose(pR) ncol = (int)R->TermWin.ncol; if (x < (ncol - (NARROWS + 1))) { ncol -= (NARROWS + 1); - R->h->Arrows_x = Width2Pixel(ncol); + R->Arrows_x = Width2Pixel(ncol); } rxvt_draw_Arrows(aR_ 0, +1); - str = (R->h->CurrentBar - && R->h->CurrentBar->title) ? R->h->CurrentBar->title : "%n-%v"; + str = (R->CurrentBar + && R->CurrentBar->title) ? R->CurrentBar->title : "%n-%v"; for (len = 0; str[0] && len < sizeof(title) - 1; str++) { const char *s = NULL; @@ -1910,7 +1910,7 @@ rxvt_menubar_expose(pR) str++; switch (str[0]) { case 'n': - s = R->h->rs[Rs_name]; + s = R->rs[Rs_name]; break; /* resource name */ case 'v': s = VERSION; @@ -1937,12 +1937,12 @@ rxvt_menubar_expose(pR) if (R->TermWin.fontset) XmbDrawString(R->Xdisplay, R->menuBar.win, R->TermWin.fontset, - R->h->menubarGC, + R->menubarGC, Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2, menuBar_height() - SHADOW, title, len); else #endif - XDrawString(R->Xdisplay, R->menuBar.win, R->h->menubarGC, + XDrawString(R->Xdisplay, R->menuBar.win, R->menubarGC, Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2, menuBar_height() - SHADOW, title, len); } @@ -1978,7 +1978,7 @@ rxvt_menu_select(pR_ XButtonEvent *ev) { menuitem_t *thisitem, *item = NULL; int this_y, y; - menu_t *ActiveMenu = R->h->ActiveMenu; + menu_t *ActiveMenu = R->ActiveMenu; Window unused_root, unused_child; int unused_root_x, unused_root_y; @@ -2100,7 +2100,7 @@ rxvt_menu_select(pR_ XButtonEvent *ev) : Width2Pixel(ActiveMenu->x)); if (x >= item->entry.submenu.menu->x) { - R->h->ActiveMenu = item->entry.submenu.menu; + R->ActiveMenu = item->entry.submenu.menu; rxvt_menu_show(aR); return 1; } @@ -2116,8 +2116,8 @@ rxvt_menubar_select(pR_ XButtonEvent *ev) menu_t *menu = NULL; /* determine the pulldown menu corresponding to the X index */ - if (ev->y >= 0 && ev->y <= menuBar_height() && R->h->CurrentBar != NULL) { - for (menu = R->h->CurrentBar->head; menu != NULL; menu = menu->next) { + if (ev->y >= 0 && ev->y <= menuBar_height() && R->CurrentBar != NULL) { + for (menu = R->CurrentBar->head; menu != NULL; menu = menu->next) { int x = Width2Pixel(menu->x); int w = Width2Pixel(menu->len + HSPACE); @@ -2131,12 +2131,12 @@ rxvt_menubar_select(pR_ XButtonEvent *ev) break; case ButtonPress: - if (menu == NULL && R->h->Arrows_x && ev->x >= R->h->Arrows_x) { + if (menu == NULL && R->Arrows_x && ev->x >= R->Arrows_x) { int i; for (i = 0; i < NARROWS; i++) { - if (ev->x >= (R->h->Arrows_x + (Width2Pixel(4 * i + i)) / 4) - && ev->x < (R->h->Arrows_x + if (ev->x >= (R->Arrows_x + (Width2Pixel(4 * i + i)) / 4) + && ev->x < (R->Arrows_x + (Width2Pixel(4 * i + i + 4)) / 4)) { rxvt_draw_Arrows(aR_ Arrows[i].name, -1); { @@ -2159,21 +2159,21 @@ rxvt_menubar_select(pR_ XButtonEvent *ev) #ifdef DEBUG_MENUARROWS fprintf(stderr, "'%c': ", Arrows[i].name); - if (R->h->CurrentBar == NULL - || (R->h->CurrentBar->arrows[i].type != MenuAction - && R->h->CurrentBar->arrows[i].type != + if (R->CurrentBar == NULL + || (R->CurrentBar->arrows[i].type != MenuAction + && R->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->h->CurrentBar->arrows[i].str); + R->CurrentBar->arrows[i].str); } #else /* DEBUG_MENUARROWS */ - if (R->h->CurrentBar == NULL + if (R->CurrentBar == NULL || rxvt_action_dispatch(r, - &(R->h->CurrentBar->arrows[i])) + &(R->CurrentBar->arrows[i])) ) { if (Arrows[i].str != NULL && Arrows[i].str[0] != 0) rxvt_tt_write(aR_ (Arrows[i].str + 1), @@ -2190,9 +2190,9 @@ rxvt_menubar_select(pR_ XButtonEvent *ev) /* * press menubar or move to a new entry */ - if (menu != NULL && menu != R->h->ActiveMenu) { + if (menu != NULL && menu != R->ActiveMenu) { rxvt_menu_hide_all(aR); /* pop down old menu */ - R->h->ActiveMenu = menu; + R->ActiveMenu = menu; rxvt_menu_show(aR); /* pop up new menu */ } break; @@ -2222,7 +2222,7 @@ rxvt_menubar_control(pR_ XButtonEvent *ev) while (XCheckTypedWindowEvent(R->Xdisplay, R->TermWin.parent[0], MotionNotify, (XEvent *) ev)) ; - if (R->h->ActiveMenu) + if (R->ActiveMenu) while (rxvt_menu_select(aR_ ev)) ; else ev->y = -1; diff --git a/src/rxvt.C b/src/rxvt.C index 043b6955..9a067476 100644 --- a/src/rxvt.C +++ b/src/rxvt.C @@ -1,4 +1,5 @@ #include "rxvtlib.h" +#include "iom.h" /*----------------------------------------------------------------------*/ /* main() */ @@ -9,7 +10,7 @@ main(int argc, const char *const *argv) if (rxvt_init(argc, argv) == NULL) return EXIT_FAILURE; - dR; - rxvt_main_loop(aR); /* main processing loop */ + iom.loop (); + return EXIT_SUCCESS; } diff --git a/src/rxvt.h b/src/rxvt.h index f36010ba..f551f5d6 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -1,8 +1,8 @@ /* - * $Id: rxvt.h,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: rxvt.h,v 1.3 2003-11-25 11:52:42 pcg Exp $ */ -#ifndef _RXVT_H_ /* include once only */ +#ifndef _RXVT_H_ /* include once only */ #define _RXVT_H_ #include "rxvtlib.h" @@ -16,6 +16,7 @@ #include "defaultfont.h" #include "rxvtcolor.h" +#include "iom.h" /* ***************************************************************************** @@ -43,11 +44,11 @@ typedef struct termios ttymode_t; #else # include typedef struct { - struct sgttyb sg; - struct tchars tc; - struct ltchars lc; - int line; - int local; + struct sgttyb sg; + struct tchars tc; + struct ltchars lc; + int line; + int local; } ttymode_t; #endif @@ -63,9 +64,9 @@ typedef struct { #endif #ifndef STDIN_FILENO -# define STDIN_FILENO 0 -# define STDOUT_FILENO 1 -# define STDERR_FILENO 2 +# define STDIN_FILENO 0 +# define STDOUT_FILENO 1 +# define STDERR_FILENO 2 #endif #if defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT) @@ -82,17 +83,14 @@ typedef struct { * STRUCTURES AND TYPEDEFS ***************************************************************************** */ -struct rxvt_vars; /* Later REDEFINED and typedef'd to rxvt_t */ -struct rxvt_hidden; struct grwin_t; - /* Sanitize menubar info */ #ifndef MENUBAR # undef MENUBAR_MAX #endif #ifndef MENUBAR_MAX -# define MENUBAR_MAX 0 +# define MENUBAR_MAX 0 #endif /* If we're using either the rxvt scrollbar or menu bars, keep the @@ -106,8 +104,8 @@ struct grwin_t; #ifdef XPM_BACKGROUND typedef struct { - short w, h, x, y; - Pixmap pixmap; + short w, h, x, y; + Pixmap pixmap; } bgPixmap_t; #endif @@ -116,28 +114,28 @@ typedef struct { * pared down from XButtonEvent */ struct mouse_event { - int clicks; - Time time; /* milliseconds */ - unsigned int state; /* key or button mask */ - unsigned int button; /* detail */ + int clicks; + Time time; /* milliseconds */ + unsigned int state; /* key or button mask */ + unsigned int button; /* detail */ }; #ifndef min -# define min(a,b) (((a) < (b)) ? (a) : (b)) -# define max(a,b) (((a) > (b)) ? (a) : (b)) +# define min(a,b) (((a) < (b)) ? (a) : (b)) +# define max(a,b) (((a) > (b)) ? (a) : (b)) #endif -#define MAX_IT(current, other) if ((other) > (current)) (current) = (other) -#define MIN_IT(current, other) if ((other) < (current)) (current) = (other) -#define SWAP_IT(one, two, typeof) \ - do { \ - typeof swapittmp; \ - (swapittmp) = (one); (one) = (two); (two) = (swapittmp); \ +#define MAX_IT(current, other) if ((other) > (current)) (current) = (other) +#define MIN_IT(current, other) if ((other) < (current)) (current) = (other) +#define SWAP_IT(one, two, typeof) \ + do { \ + typeof swapittmp; \ + (swapittmp) = (one); (one) = (two); (two) = (swapittmp); \ } while (/* CONSTCOND */ 0) -#define BOUND_POSITIVE_INT16(val) \ - (int16_t)((val) <= 0 \ - ? 0 \ - : min((val), (((uint16_t)-1)>>1))) +#define BOUND_POSITIVE_INT16(val) \ + (int16_t)((val) <= 0 \ + ? 0 \ + : min((val), (((uint16_t)-1)>>1))) /* ***************************************************************************** @@ -149,19 +147,19 @@ struct mouse_event { # error if you disable both selection styles, how can you select, silly? #endif -#define APL_CLASS "XTerm" /* class name */ -#define APL_SUBCLASS "Rxvt" /* also check resources under this name */ -#define APL_NAME "rxvt" /* normal name */ +#define APL_CLASS "XTerm" /* class name */ +#define APL_SUBCLASS "Rxvt" /* also check resources under this name */ +#define APL_NAME "rxvt" /* normal name */ /* COLORTERM, TERM environment variables */ -#define COLORTERMENV "rxvt" +#define COLORTERMENV "rxvt" #ifdef XPM_BACKGROUND # define COLORTERMENVFULL COLORTERMENV "-xpm" #else # define COLORTERMENVFULL COLORTERMENV #endif #ifndef TERMENV -# define TERMENV "xterm" +# define TERMENV "xterm" #endif #if defined (NO_MOUSE_REPORT) && !defined (NO_MOUSE_REPORT_SCROLLBAR) @@ -178,14 +176,14 @@ struct mouse_event { # define EACCESS EAGAIN #endif -#ifndef EXIT_SUCCESS /* missing from */ -# define EXIT_SUCCESS 0 /* exit function success */ -# define EXIT_FAILURE 1 /* exit function failure */ +#ifndef EXIT_SUCCESS /* missing from */ +# define EXIT_SUCCESS 0 /* exit function success */ +# define EXIT_FAILURE 1 /* exit function failure */ #endif -#define menuBar_esc 10 -#define scrollBar_esc 30 -#define menuBar_margin 2 /* margin below text */ +#define menuBar_esc 10 +#define scrollBar_esc 30 +#define menuBar_margin 2 /* margin below text */ #if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) # define HAVE_SCROLLBARS @@ -198,37 +196,37 @@ struct mouse_event { # define SHADOW 2 #endif -#define R_SB_ALIGN_CENTRE 0 -#define R_SB_ALIGN_TOP 1 -#define R_SB_ALIGN_BOTTOM 2 +#define R_SB_ALIGN_CENTRE 0 +#define R_SB_ALIGN_TOP 1 +#define R_SB_ALIGN_BOTTOM 2 -#define R_SB_RXVT 0 -#define R_SB_NEXT 1 -#define R_SB_XTERM 2 +#define R_SB_RXVT 0 +#define R_SB_NEXT 1 +#define R_SB_XTERM 2 -#define SB_WIDTH_NEXT 19 -#define SB_WIDTH_XTERM 7 +#define SB_WIDTH_NEXT 19 +#define SB_WIDTH_XTERM 7 #ifndef SB_WIDTH_RXVT -# define SB_WIDTH_RXVT 10 +# define SB_WIDTH_RXVT 10 #endif /* * NeXT scrollbar defines */ -#define SB_PADDING 1 -#define SB_BORDER_WIDTH 1 -#define SB_BEVEL_WIDTH_UPPER_LEFT 1 -#define SB_BEVEL_WIDTH_LOWER_RIGHT 2 -#define SB_LEFT_PADDING (SB_PADDING + SB_BORDER_WIDTH) -#define SB_MARGIN_SPACE (SB_PADDING * 2) -#define SB_BUTTON_WIDTH (SB_WIDTH_NEXT - SB_MARGIN_SPACE - SB_BORDER_WIDTH) -#define SB_BUTTON_HEIGHT (SB_BUTTON_WIDTH) -#define SB_BUTTON_SINGLE_HEIGHT (SB_BUTTON_HEIGHT + SB_PADDING) -#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2) -#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING) -#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) -#define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT) -#define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) +#define SB_PADDING 1 +#define SB_BORDER_WIDTH 1 +#define SB_BEVEL_WIDTH_UPPER_LEFT 1 +#define SB_BEVEL_WIDTH_LOWER_RIGHT 2 +#define SB_LEFT_PADDING (SB_PADDING + SB_BORDER_WIDTH) +#define SB_MARGIN_SPACE (SB_PADDING * 2) +#define SB_BUTTON_WIDTH (SB_WIDTH_NEXT - SB_MARGIN_SPACE - SB_BORDER_WIDTH) +#define SB_BUTTON_HEIGHT (SB_BUTTON_WIDTH) +#define SB_BUTTON_SINGLE_HEIGHT (SB_BUTTON_HEIGHT + SB_PADDING) +#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2) +#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING) +#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) +#define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT) +#define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) /* * +-------------+ * | | <---< SB_PADDING @@ -275,117 +273,117 @@ struct mouse_event { * +---< SB_WIDTH_NEXT */ -#define NO_REFRESH 0 /* Window not visible at all! */ -#define FAST_REFRESH (1<<0) /* Fully exposed window */ -#define SLOW_REFRESH (1<<1) /* Partially exposed window */ -#define SMOOTH_REFRESH (1<<2) /* Do sync'ing to make it smooth */ -#define REFRESH_BOUNDS (1<<3) +#define NO_REFRESH 0 /* Window not visible at all! */ +#define FAST_REFRESH (1<<0) /* Fully exposed window */ +#define SLOW_REFRESH (1<<1) /* Partially exposed window */ +#define SMOOTH_REFRESH (1<<2) /* Do sync'ing to make it smooth */ +#define REFRESH_BOUNDS (1<<3) #ifdef NO_SECONDARY_SCREEN -# define NSCREENS 0 +# define NSCREENS 0 #else -# define NSCREENS 1 +# define NSCREENS 1 #endif -#define IGNORE 0 -#define SAVE 's' -#define RESTORE 'r' +#define IGNORE 0 +#define SAVE 's' +#define RESTORE 'r' /* special (internal) prefix for font commands */ -#define FONT_CMD '#' -#define FONT_DN "#-" -#define FONT_UP "#+" +#define FONT_CMD '#' +#define FONT_DN "#-" +#define FONT_UP "#+" /* flags for rxvt_scr_gotorc() */ -#define C_RELATIVE 1 /* col movement is relative */ -#define R_RELATIVE 2 /* row movement is relative */ -#define RELATIVE (R_RELATIVE|C_RELATIVE) +#define C_RELATIVE 1 /* col movement is relative */ +#define R_RELATIVE 2 /* row movement is relative */ +#define RELATIVE (R_RELATIVE|C_RELATIVE) /* modes for rxvt_scr_insdel_chars(), rxvt_scr_insdel_lines() */ -#define INSERT -1 /* don't change these values */ -#define DELETE +1 -#define ERASE +2 +#define INSERT -1 /* don't change these values */ +#define DELETE +1 +#define ERASE +2 /* modes for rxvt_scr_page() - scroll page. used by scrollbar window */ enum page_dirn { - UP, - DN, - NO_DIR + UP, + DN, + NO_DIR }; /* arguments for rxvt_scr_change_screen() */ enum { - PRIMARY = 0, - SECONDARY + PRIMARY = 0, + SECONDARY }; enum { - SBYTE = 0, - WBYTE + SBYTE = 0, + WBYTE }; -#define RS_None 0 /* Normal */ +#define RS_None 0 /* Normal */ -#define RS_fgMask 0x000001FFu /* 512 colors */ -#define RS_bgMask 0x0003FE00u /* 512 colors */ -#define RS_Bold 0x00040000u /* bold */ -#define RS_Blink 0x00080000u /* blink */ -#define RS_RVid 0x00100000u /* reverse video */ -#define RS_Uline 0x00200000u /* underline */ +#define RS_fgMask 0x000001FFu /* 512 colors */ +#define RS_bgMask 0x0003FE00u /* 512 colors */ +#define RS_Bold 0x00040000u /* bold */ +#define RS_Blink 0x00080000u /* blink */ +#define RS_RVid 0x00100000u /* reverse video */ +#define RS_Uline 0x00200000u /* underline */ -#define RS_wide 0x00400000u /* only multibyte characters */ -#define IS_WIDE(r) ((r) & RS_wide) +#define RS_wide 0x00400000u /* only multibyte characters */ +#define IS_WIDE(r) ((r) & RS_wide) -#define RS_fontMask 0xff000000u /* plenty(?) of fonts */ -#define RS_fontShift 24 +#define RS_fontMask 0xff000000u /* plenty(?) of fonts */ +#define RS_fontShift 24 -#define RS_baseattrMask (RS_Bold|RS_Blink|RS_RVid|RS_Uline) -#define RS_attrMask (RS_baseattrMask|RS_fontMask|RS_wide) +#define RS_baseattrMask (RS_Bold|RS_Blink|RS_RVid|RS_Uline) +#define RS_attrMask (RS_baseattrMask|RS_fontMask|RS_wide) -#define Sel_none 0 /* Not waiting */ -#define Sel_normal 0x01 /* normal selection */ -#define Sel_incr 0x02 /* incremental selection */ -#define Sel_direct 0x00 -#define Sel_Primary 0x01 -#define Sel_Secondary 0x02 -#define Sel_Clipboard 0x03 -#define Sel_whereMask 0x0f -#define Sel_CompoundText 0x10 /* last request was Compound */ +#define Sel_none 0 /* Not waiting */ +#define Sel_normal 0x01 /* normal selection */ +#define Sel_incr 0x02 /* incremental selection */ +#define Sel_direct 0x00 +#define Sel_Primary 0x01 +#define Sel_Secondary 0x02 +#define Sel_Clipboard 0x03 +#define Sel_whereMask 0x0f +#define Sel_CompoundText 0x10 /* last request was Compound */ enum { - C0_NUL = 0x00, - C0_SOH, C0_STX, C0_ETX, C0_EOT, C0_ENQ, C0_ACK, C0_BEL, - C0_BS , C0_HT , C0_LF , C0_VT , C0_FF , C0_CR , C0_SO , C0_SI , - C0_DLE, C0_DC1, C0_DC2, D0_DC3, C0_DC4, C0_NAK, C0_SYN, C0_ETB, - C0_CAN, C0_EM , C0_SUB, C0_ESC, C0_IS4, C0_IS3, C0_IS2, C0_IS1 + C0_NUL = 0x00, + C0_SOH, C0_STX, C0_ETX, C0_EOT, C0_ENQ, C0_ACK, C0_BEL, + C0_BS , C0_HT , C0_LF , C0_VT , C0_FF , C0_CR , C0_SO , C0_SI , + C0_DLE, C0_DC1, C0_DC2, D0_DC3, C0_DC4, C0_NAK, C0_SYN, C0_ETB, + C0_CAN, C0_EM , C0_SUB, C0_ESC, C0_IS4, C0_IS3, C0_IS2, C0_IS1 }; -#define CHAR_ST 0x9c /* 0234 */ +#define CHAR_ST 0x9c /* 0234 */ /* * XTerm Operating System Commands: ESC ] Ps;Pt (ST|BEL) * colour extensions by Christian W. Zuckschwerdt */ -#define XTerm_name 0 -#define XTerm_iconName 1 -#define XTerm_title 2 -#define XTerm_Color 4 /* change colors */ -#define XTerm_Color_cursor 12 /* change actual 'Cursor' color */ -#define XTerm_Color_pointer 13 /* change actual 'Pointer' color */ -#define XTerm_Color_RV 17 /* change actual 'Highlight' color */ -#define XTerm_Color_BD 18 /* change actual 'Bold' color */ -#define XTerm_Color_UL 19 /* change actual 'Underline' color */ -#define XTerm_logfile 46 /* not implemented */ -#define XTerm_font 50 +#define XTerm_name 0 +#define XTerm_iconName 1 +#define XTerm_title 2 +#define XTerm_Color 4 /* change colors */ +#define XTerm_Color_cursor 12 /* change actual 'Cursor' color */ +#define XTerm_Color_pointer 13 /* change actual 'Pointer' color */ +#define XTerm_Color_RV 17 /* change actual 'Highlight' color */ +#define XTerm_Color_BD 18 /* change actual 'Bold' color */ +#define XTerm_Color_UL 19 /* change actual 'Underline' color */ +#define XTerm_logfile 46 /* not implemented */ +#define XTerm_font 50 /* * rxvt extensions of XTerm OSCs: ESC ] Ps;Pt (ST|BEL) */ -#define XTerm_Menu 10 /* set menu item */ -#define XTerm_Pixmap 20 /* new bg pixmap */ -#define XTerm_restoreFG 39 /* change default fg color */ -#define XTerm_restoreBG 49 /* change default bg color */ -#define XTerm_dumpscreen 55 /* dump scrollback and all of screen */ +#define XTerm_Menu 10 /* set menu item */ +#define XTerm_Pixmap 20 /* new bg pixmap */ +#define XTerm_restoreFG 39 /* change default fg color */ +#define XTerm_restoreBG 49 /* change default bg color */ +#define XTerm_dumpscreen 55 /* dump scrollback and all of screen */ /* Words starting with `Color_' are colours. Others are counts */ /* @@ -397,388 +395,388 @@ enum { */ enum colour_list { - Color_fg = 0, - Color_bg, - minCOLOR, /* 2 */ - Color_Black = minCOLOR, - Color_Red3, - Color_Green3, - Color_Yellow3, - Color_Blue3, - Color_Magenta3, - Color_Cyan3, - maxCOLOR, /* minCOLOR + 7 */ + Color_fg = 0, + Color_bg, + minCOLOR, /* 2 */ + Color_Black = minCOLOR, + Color_Red3, + Color_Green3, + Color_Yellow3, + Color_Blue3, + Color_Magenta3, + Color_Cyan3, + maxCOLOR, /* minCOLOR + 7 */ #ifndef NO_BRIGHTCOLOR - Color_AntiqueWhite = maxCOLOR, - minBrightCOLOR, /* maxCOLOR + 1 */ - Color_Grey25 = minBrightCOLOR, - Color_Red, - Color_Green, - Color_Yellow, - Color_Blue, - Color_Magenta, - Color_Cyan, - maxBrightCOLOR, /* minBrightCOLOR + 7 */ - Color_White = maxBrightCOLOR, + Color_AntiqueWhite = maxCOLOR, + minBrightCOLOR, /* maxCOLOR + 1 */ + Color_Grey25 = minBrightCOLOR, + Color_Red, + Color_Green, + Color_Yellow, + Color_Blue, + Color_Magenta, + Color_Cyan, + maxBrightCOLOR, /* minBrightCOLOR + 7 */ + Color_White = maxBrightCOLOR, #else - Color_White = maxCOLOR, + Color_White = maxCOLOR, #endif #ifdef TTY_256COLOR - min256COLOR = Color_White + 1, - max256COLOR = minCOLOR + 255, + min256COLOR = Color_White + 1, + max256COLOR = minCOLOR + 255, #endif #ifndef NO_CURSORCOLOR - Color_cursor, - Color_cursor2, + Color_cursor, + Color_cursor2, #endif - Color_pointer, - Color_border, + Color_pointer, + Color_border, #ifndef NO_BOLD_UNDERLINE_REVERSE - Color_BD, - Color_UL, - Color_RV, + Color_BD, + Color_UL, + Color_RV, #endif #ifdef OPTION_HC - Color_HC, + Color_HC, #endif #ifdef KEEP_SCROLLCOLOR - Color_scroll, - Color_trough, + Color_scroll, + Color_trough, #endif - NRS_COLORS, /* */ + NRS_COLORS, /* */ #ifdef KEEP_SCROLLCOLOR - Color_topShadow = NRS_COLORS, - Color_bottomShadow, - TOTAL_COLORS /* upto 30 */ + Color_topShadow = NRS_COLORS, + Color_bottomShadow, + TOTAL_COLORS /* upto 30 */ #else - TOTAL_COLORS = NRS_COLORS /* */ + TOTAL_COLORS = NRS_COLORS /* */ #endif }; -#define Color_Bits 9 -#define NPIXCLR_SETS 9 /* (256 + 14) bits / 32 bits */ -#define NPIXCLR_BITS 32 +#define Color_Bits 9 +#define NPIXCLR_SETS 9 /* (256 + 14) bits / 32 bits */ +#define NPIXCLR_BITS 32 -#define DEFAULT_RSTYLE (RS_None | (Color_fg) | (Color_bg<h->PrivateModes |= (bit); \ - else \ - R->h->PrivateModes &= ~(bit) +#define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11) +#define PrivMode(test,bit) \ + if (test) \ + R->PrivateModes |= (bit); \ + else \ + R->PrivateModes &= ~(bit) #ifdef ALLOW_132_MODE -# define PrivMode_Default \ +# define PrivMode_Default \ (PrivMode_Autowrap|PrivMode_aplKP|PrivMode_ShiftKeys|PrivMode_VisibleCursor|PrivMode_132OK) #else -# define PrivMode_Default \ +# define PrivMode_Default \ (PrivMode_Autowrap|PrivMode_aplKP|PrivMode_ShiftKeys|PrivMode_VisibleCursor) #endif #ifdef PREFER_24BIT -# define XDEPTH R->Xdepth -# define XCMAP R->Xcmap -# define XVISUAL R->h->Xvisual +# define XDEPTH R->Xdepth +# define XCMAP R->Xcmap +# define XVISUAL R->Xvisual #else # ifdef DEBUG_DEPTH -# define XDEPTH DEBUG_DEPTH +# define XDEPTH DEBUG_DEPTH # else -# define XDEPTH DefaultDepth(R->Xdisplay,Xscreen) -# define XCMAP DefaultColormap(R->Xdisplay,Xscreen) -# define XVISUAL DefaultVisual(R->Xdisplay,Xscreen) +# define XDEPTH DefaultDepth(R->Xdisplay,Xscreen) +# define XCMAP DefaultColormap(R->Xdisplay,Xscreen) +# define XVISUAL DefaultVisual(R->Xdisplay,Xscreen) # endif #endif -#define IMBUFSIZ 128 /* input modifier buffer sizes */ +#define IMBUFSIZ 128 /* input modifier buffer sizes */ #ifndef BUFSIZ -# define BUFSIZ 4096 +# define BUFSIZ 4096 #endif -#define KBUFSZ 512 /* size of keyboard mapping buffer */ +#define KBUFSZ 512 /* size of keyboard mapping buffer */ /* ***************************************************************************** * MACRO DEFINES ***************************************************************************** */ -#define MEMSET(x, y, z) memset((x), (y), (size_t)(z)) -#define MEMCPY(x, y, z) memcpy((void *)(x), (const void *)(y), (z)) -#define MEMMOVE(x, y, z) memmove((void *)(x), (const void *)(y), (z)) -#define STRCASECMP(x, y) strcasecmp((x), (y)) -#define STRNCASECMP(x, y, z) strncasecmp((x), (y), (z)) -#define STRCPY(x, y) strcpy((char *)(x), (const char *)(y)) -#define STRNCPY(x, y, z) strncpy((char *)(x), (const char *)(y), (z)) -#define STRCMP(x, y) strcmp((const char *)(x), (const char *)(y)) -#define STRNCMP(x, y, z) strncmp((const char *)(x), (const char *)(y), (z)) -#define STRCAT(x, y) strcat((char *)(x), (const char *)(y)) -#define STRNCAT(x, y, z) strncat((char *)(x), (const char *)(y), (z)) -#define STRDUP(x) strdup((const char *)(x)) -#define STRLEN(x) strlen((const char *)(x)) -#define STRCHR(x, y) strchr((const char *)(x), (int)(y)) -#define STRRCHR(x, y) strrchr((const char *)(x), (int)(y)) +#define MEMSET(x, y, z) memset((x), (y), (size_t)(z)) +#define MEMCPY(x, y, z) memcpy((void *)(x), (const void *)(y), (z)) +#define MEMMOVE(x, y, z) memmove((void *)(x), (const void *)(y), (z)) +#define STRCASECMP(x, y) strcasecmp((x), (y)) +#define STRNCASECMP(x, y, z) strncasecmp((x), (y), (z)) +#define STRCPY(x, y) strcpy((char *)(x), (const char *)(y)) +#define STRNCPY(x, y, z) strncpy((char *)(x), (const char *)(y), (z)) +#define STRCMP(x, y) strcmp((const char *)(x), (const char *)(y)) +#define STRNCMP(x, y, z) strncmp((const char *)(x), (const char *)(y), (z)) +#define STRCAT(x, y) strcat((char *)(x), (const char *)(y)) +#define STRNCAT(x, y, z) strncat((char *)(x), (const char *)(y), (z)) +#define STRDUP(x) strdup((const char *)(x)) +#define STRLEN(x) strlen((const char *)(x)) +#define STRCHR(x, y) strchr((const char *)(x), (int)(y)) +#define STRRCHR(x, y) strrchr((const char *)(x), (int)(y)) /* convert pixel dimensions to row/column values. Everything as int32_t */ -#define Pixel2Col(x) Pixel2Width((int32_t)(x) - (int32_t)R->TermWin.int_bwidth) -#define Pixel2Row(y) Pixel2Height((int32_t)(y) - (int32_t)R->TermWin.int_bwidth) -#define Pixel2Width(x) ((int32_t)(x) / (int32_t)R->TermWin.fwidth) -#define Pixel2Height(y) ((int32_t)(y) / (int32_t)R->TermWin.fheight) -#define Col2Pixel(col) ((int32_t)Width2Pixel(col) + (int32_t)R->TermWin.int_bwidth) -#define Row2Pixel(row) ((int32_t)Height2Pixel(row) + (int32_t)R->TermWin.int_bwidth) -#define Width2Pixel(n) ((int32_t)(n) * (int32_t)R->TermWin.fwidth) -#define Height2Pixel(n) ((int32_t)(n) * (int32_t)R->TermWin.fheight) +#define Pixel2Col(x) Pixel2Width((int32_t)(x) - (int32_t)R->TermWin.int_bwidth) +#define Pixel2Row(y) Pixel2Height((int32_t)(y) - (int32_t)R->TermWin.int_bwidth) +#define Pixel2Width(x) ((int32_t)(x) / (int32_t)R->TermWin.fwidth) +#define Pixel2Height(y) ((int32_t)(y) / (int32_t)R->TermWin.fheight) +#define Col2Pixel(col) ((int32_t)Width2Pixel(col) + (int32_t)R->TermWin.int_bwidth) +#define Row2Pixel(row) ((int32_t)Height2Pixel(row) + (int32_t)R->TermWin.int_bwidth) +#define Width2Pixel(n) ((int32_t)(n) * (int32_t)R->TermWin.fwidth) +#define Height2Pixel(n) ((int32_t)(n) * (int32_t)R->TermWin.fheight) -#define TermWin_TotalWidth() ((int32_t)R->TermWin.width + 2 * (int32_t)R->TermWin.int_bwidth) -#define TermWin_TotalHeight() ((int32_t)R->TermWin.height + 2 * (int32_t)R->TermWin.int_bwidth) +#define TermWin_TotalWidth() ((int32_t)R->TermWin.width + 2 * (int32_t)R->TermWin.int_bwidth) +#define TermWin_TotalHeight() ((int32_t)R->TermWin.height + 2 * (int32_t)R->TermWin.int_bwidth) -#define Xscreen DefaultScreen(R->Xdisplay) -#define Xroot DefaultRootWindow(R->Xdisplay) +#define Xscreen DefaultScreen(R->Xdisplay) +#define Xroot DefaultRootWindow(R->Xdisplay) /* how to build & extract colors and attributes */ -#define GET_BASEFG(x) (((x) & RS_fgMask)) -#define GET_BASEBG(x) (((x) & RS_bgMask)>>Color_Bits) +#define GET_BASEFG(x) (((x) & RS_fgMask)) +#define GET_BASEBG(x) (((x) & RS_bgMask)>>Color_Bits) #ifndef NO_BRIGHTCOLOR -# define GET_FGCOLOR(x) \ - ((((x) & RS_Bold) == 0 \ - || GET_BASEFG(x) < minCOLOR \ - || GET_BASEFG(x) >= minBrightCOLOR) \ - ? GET_BASEFG(x) \ +# define GET_FGCOLOR(x) \ + ((((x) & RS_Bold) == 0 \ + || GET_BASEFG(x) < minCOLOR \ + || GET_BASEFG(x) >= minBrightCOLOR) \ + ? GET_BASEFG(x) \ : (GET_BASEFG(x) + (minBrightCOLOR - minCOLOR))) -# define GET_BGCOLOR(x) \ - ((((x) & RS_Blink) == 0 \ - || GET_BASEBG(x) < minCOLOR \ - || GET_BASEBG(x) >= minBrightCOLOR) \ - ? GET_BASEBG(x) \ +# define GET_BGCOLOR(x) \ + ((((x) & RS_Blink) == 0 \ + || GET_BASEBG(x) < minCOLOR \ + || GET_BASEBG(x) >= minBrightCOLOR) \ + ? GET_BASEBG(x) \ : (GET_BASEBG(x) + (minBrightCOLOR - minCOLOR))) #else -# define GET_FGCOLOR(x) GET_BASEFG(x) -# define GET_BGCOLOR(x) GET_BASEBG(x) +# define GET_FGCOLOR(x) GET_BASEFG(x) +# define GET_BGCOLOR(x) GET_BASEBG(x) #endif -#define GET_FONT(x) (((x) & RS_fontMask) >> RS_fontShift) -#define SET_FONT(x,fid) ((x) & ~RS_fontMask) | ((fid) << RS_fontShift) +#define GET_FONT(x) (((x) & RS_fontMask) >> RS_fontShift) +#define SET_FONT(x,fid) ((x) & ~RS_fontMask) | ((fid) << RS_fontShift) -#define GET_ATTR(x) (((x) & RS_attrMask)) -#define GET_BGATTR(x) \ - (((x) & RS_RVid) ? (((x) & (RS_attrMask & ~RS_RVid)) \ - | (((x) & RS_fgMask)<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(h, x) ((h)->pixcolor_set[(x) / NPIXCLR_BITS] |= (1 << ((x) % NPIXCLR_BITS))) +#define ISSET_PIXCOLOR(h, x) ((h)->pixcolor_set[(x) / NPIXCLR_BITS] & (1 << ((x) % NPIXCLR_BITS))) #ifdef HAVE_SCROLLBARS -# define scrollbar_TotalWidth() (R->scrollBar.width + R->sb_shadow * 2) +# define scrollbar_TotalWidth() (R->scrollBar.width + R->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_setIdle() R->scrollBar.state = 1 -#define scrollbar_setMotion() R->scrollBar.state = 'm' -#define scrollbar_setUp() R->scrollBar.state = 'U' -#define scrollbar_setDn() R->scrollBar.state = 'D' - -#define scrollbarnext_dnval() (R->scrollBar.end + (R->scrollBar.width + 1)) -#define scrollbarnext_upButton(y) ((y) > R->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 SCROLLRXVT_MINHEIGHT 10 -#define SCROLLXTERM_MINHEIGHT 10 - -#define scrollbar_minheight() (R->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 \ - - scrollbar_minheight()) +# 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_setIdle() R->scrollBar.state = 1 +#define scrollbar_setMotion() R->scrollBar.state = 'm' +#define scrollbar_setUp() R->scrollBar.state = 'U' +#define scrollbar_setDn() R->scrollBar.state = 'D' + +#define scrollbarnext_dnval() (R->scrollBar.end + (R->scrollBar.width + 1)) +#define scrollbarnext_upButton(y) ((y) > R->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 SCROLLRXVT_MINHEIGHT 10 +#define SCROLLXTERM_MINHEIGHT 10 + +#define scrollbar_minheight() (R->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 \ + - scrollbar_minheight()) #if (MENUBAR_MAX > 1) /* rendition style flags */ -# define menuBar_height() (R->TermWin.fheight + SHADOW) -# define menuBar_TotalHeight() (menuBar_height() + SHADOW + menuBar_margin) -# define isMenuBarWindow(w) ((w) == R->menuBar.win) +# define menuBar_height() (R->TermWin.fheight + SHADOW) +# define menuBar_TotalHeight() (menuBar_height() + SHADOW + menuBar_margin) +# define isMenuBarWindow(w) ((w) == R->menuBar.win) #else -# define menuBar_height() (0) -# define menuBar_TotalHeight() (0) -# define isMenuBarWindow(w) (0) +# define menuBar_height() (0) +# define menuBar_TotalHeight() (0) +# define isMenuBarWindow(w) (0) #endif #ifdef XPM_BACKGROUND -# define XPMClearArea(a, b, c, d, e, f, g) XClearArea((a), (b), (c), (d), (e), (f), (g)) +# define XPMClearArea(a, b, c, d, e, f, g) XClearArea((a), (b), (c), (d), (e), (f), (g)) #else # define XPMClearArea(a, b, c, d, e, f, g) #endif #ifndef STRICT_FONT_CHECKING -# define rxvt_get_fontwidest(font) ((font)->max_bounds.width) +# define rxvt_get_fontwidest(font) ((font)->max_bounds.width) #endif -#define rxvt_Gr_ButtonPress(x,y) rxvt_Gr_ButtonReport (r, 'P',(x),(y)) -#define rxvt_Gr_ButtonRelease(x,y) rxvt_Gr_ButtonReport (r, 'R',(x),(y)) +#define rxvt_Gr_ButtonPress(x,y) rxvt_Gr_ButtonReport (r, 'P',(x),(y)) +#define rxvt_Gr_ButtonRelease(x,y) rxvt_Gr_ButtonReport (r, 'R',(x),(y)) #ifdef UTMP_SUPPORT # if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) @@ -799,37 +797,37 @@ enum { #endif #ifdef DEBUG_CMD -# define D_CMD(x) fprintf x ; fputc('\n', stderr) +# define D_CMD(x) fprintf x ; fputc('\n', stderr) #else # define D_CMD(x) #endif #ifdef DEBUG_INIT -# define D_INIT(x) fprintf x ; fputc('\n', stderr) +# define D_INIT(x) fprintf x ; fputc('\n', stderr) #else # define D_INIT(x) #endif #ifdef DEBUG_MAIN -# define D_MAIN(x) fprintf x ; fputc('\n', stderr) +# define D_MAIN(x) fprintf x ; fputc('\n', stderr) #else # define D_MAIN(x) #endif #ifdef DEBUG_SCREEN -# define D_SCREEN(x) fprintf x ; fputc('\n', stderr) +# define D_SCREEN(x) fprintf x ; fputc('\n', stderr) #else # define D_SCREEN(x) #endif #ifdef DEBUG_SELECT -# define D_SELECT(x) fprintf x ; fputc('\n', stderr) +# define D_SELECT(x) fprintf x ; fputc('\n', stderr) #else # define D_SELECT(x) #endif #ifdef DEBUG_SIZE -# define D_SIZE(x) fprintf x ; fputc('\n', stderr) +# define D_SIZE(x) fprintf x ; fputc('\n', stderr) #else # define D_SIZE(x) #endif #ifdef DEBUG_X -# define D_X(x) fprintf x ; fputc('\n', stderr) +# define D_X(x) fprintf x ; fputc('\n', stderr) #else # define D_X(x) #endif @@ -854,266 +852,277 @@ struct mbstate { } }; -struct rxvt_hidden { - struct mbstate mbstate; +struct rxvt_term : rxvt_vars { + struct mbstate mbstate; #ifdef __GNUC__ - unsigned char want_refresh:1, - want_full_refresh:1, - am_transparent:1, - am_pixmap_trans:1, - current_screen:1, - hate_those_clicks:1, - num_scr_allow:1, - bypass_keystate:1; - unsigned char chstat:1, - lost_multi:1, - multi_byte:1, - hidden_cursor:1, - hidden_pointer:1, - parsed_geometry:1; + unsigned char want_refresh:1, + want_full_refresh:1, + am_transparent:1, + am_pixmap_trans:1, + current_screen:1, + hate_those_clicks:1, + num_scr_allow:1, + bypass_keystate:1; + unsigned char chstat:1, + lost_multi:1, + multi_byte:1, + hidden_cursor:1, + hidden_pointer:1, + parsed_geometry:1; #else - unsigned char want_refresh, + unsigned char want_refresh, # ifdef TRANSPARENT - want_full_refresh, /* awaiting full screen refresh */ + want_full_refresh, /* awaiting full screen refresh */ # endif # if defined(XPM_BACKGROUND) || defined(TRANSPARENT) - am_transparent, /* is a transparent term */ - am_pixmap_trans, /* transparency w/known root pixmap */ + am_transparent, /* is a transparent term */ + am_pixmap_trans, /* transparency w/known root pixmap */ # endif - current_screen, /* primary or secondary */ - hate_those_clicks, /* a.k.a. keep mark position */ - num_scr_allow, - bypass_keystate, + current_screen, /* primary or secondary */ + hate_those_clicks, /* a.k.a. keep mark position */ + num_scr_allow, + bypass_keystate, # ifdef MULTICHAR_SET - chstat, - lost_multi, /* set ==> we only got half a glyph */ - multi_byte, /* set ==> currently using 2 bytes per glyph */ + chstat, + lost_multi, /* set ==> we only got half a glyph */ + multi_byte, /* set ==> currently using 2 bytes per glyph */ # endif # ifdef CURSOR_BLINK - hidden_cursor, + hidden_cursor, # endif # ifdef POINTER_BLANK - hidden_pointer, + hidden_pointer, # endif - parsed_geometry; -#endif /* !__GNUC__ */ + parsed_geometry; +#endif /* !__GNUC__ */ - unsigned char refresh_type, + unsigned char refresh_type, #ifdef UTMP_SUPPORT - next_utmp_action, + next_utmp_action, #endif #ifndef NO_SETOWNER_TTYDEV - next_tty_action, + next_tty_action, #endif #ifdef META8_OPTION - meta_char, /* Alt-key prefix */ + meta_char, /* Alt-key prefix */ #endif - scrollbar_align, - selection_wait, - selection_type; + scrollbar_align, + selection_wait, + selection_type; /* ---------- */ #ifdef GREEK_SUPPORT - short greek_mode; /* greek keyboard mode */ + short greek_mode; /* greek keyboard mode */ #endif - short rvideo; - int16_t num_scr; /* screen: number lines scrolled */ - uint16_t prev_ncol, /* screen: previous number of columns */ - prev_nrow; /* screen: previous number of rows */ + short rvideo; + int16_t num_scr; /* screen: number lines scrolled */ + uint16_t prev_ncol, /* screen: previous number of columns */ + prev_nrow; /* screen: previous number of rows */ #ifdef RXVT_GRAPHICS - uint16_t gr_prev_start; + uint16_t gr_prev_start; #endif /* ---------- */ - rend_t rstyle; + rend_t rstyle; /* ---------- */ - uint32_t pixcolor_set[NPIXCLR_SETS]; + uint32_t pixcolor_set[NPIXCLR_SETS]; /* ---------- */ #ifdef SELECTION_SCROLLING - int scroll_selection_delay, - scroll_selection_lines; - enum page_dirn scroll_selection_dir; - int selection_save_x, - selection_save_y, - selection_save_state, - pending_scroll_selection; + int scroll_selection_delay, + scroll_selection_lines; + enum page_dirn scroll_selection_dir; + int selection_save_x, + selection_save_y, + selection_save_state, + pending_scroll_selection; #endif /* ---------- */ - int csrO, /* Hops - csr offset in thumb/slider to */ - /* give proper Scroll behaviour */ + int csrO, /* Hops - csr offset in thumb/slider to */ + /* give proper Scroll behaviour */ #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - scroll_arrow_delay, + scroll_arrow_delay, #endif #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) - mouse_slip_wheel_delay, - mouse_slip_wheel_speed, -#endif - refresh_count, - refresh_limit, - fnum, /* logical font number */ - last_bot, /* scrollbar last bottom position */ - last_top, /* scrollbar last top position */ - last_state, /* scrollbar last state */ - scrollbar_len, - currmaxcol, + mouse_slip_wheel_delay, + mouse_slip_wheel_speed, +#endif + refresh_count, + refresh_limit, + fnum, /* logical font number */ + last_bot, /* scrollbar last bottom position */ + last_top, /* scrollbar last top position */ + last_state, /* scrollbar last state */ + scrollbar_len, + currmaxcol, #ifdef MENUBAR - menu_readonly, /* okay to alter menu? */ - Arrows_x, + menu_readonly, /* okay to alter menu? */ + Arrows_x, #endif #if (MENUBAR_MAX > 1) - Nbars, + Nbars, #endif - window_vt_x, - window_vt_y, - window_sb_x, + window_vt_x, + window_vt_y, + window_sb_x, # ifdef POINTER_BLANK - pointerBlankDelay, + pointerBlankDelay, # endif - allowedxerror; + allowedxerror; /* ---------- */ - unsigned int ModMetaMask, - ModNumLockMask, - old_width, /* last used width in screen resize */ - old_height, /* last used height in screen resize */ + unsigned int ModMetaMask, + ModNumLockMask, + old_width, /* last used width in screen resize */ + old_height, /* last used height in screen resize */ #ifndef NO_BRIGHTCOLOR - colorfgbg, + colorfgbg, #endif - ttymode; - unsigned long PrivateModes, - SavedModes; + ttymode; + unsigned long PrivateModes, + SavedModes; /* ---------- */ #ifdef PREFER_24BIT - Visual *Xvisual; + Visual *Xvisual; #endif /* ---------- */ - Atom xa[NUM_XA]; + Atom xa[NUM_XA]; /* ---------- */ #ifdef MENUBAR - GC menubarGC; + GC menubarGC; #endif #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) - GC scrollbarGC, - topShadowGC, - botShadowGC; + GC scrollbarGC, + topShadowGC, + botShadowGC; #endif #ifdef XTERM_SCROLLBAR - GC xscrollbarGC, - ShadowGC; + GC xscrollbarGC, + ShadowGC; #endif #ifdef NEXT_SCROLLBAR - GC blackGC, - whiteGC, - grayGC, - darkGC, - stippleGC; - Pixmap dimple, - upArrow, - downArrow, - upArrowHi, - downArrowHi; + GC blackGC, + whiteGC, + grayGC, + darkGC, + stippleGC; + Pixmap dimple, + upArrow, + downArrow, + upArrowHi, + downArrowHi; #endif /* ---------- */ - Time selection_time, - selection_request_time; - pid_t cmd_pid; /* process id of child */ - gid_t ttygid; + Time selection_time, + selection_request_time; + pid_t cmd_pid; /* process id of child */ + gid_t ttygid; #if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__) - uid_t euid; - gid_t egid; + uid_t euid; + gid_t egid; #endif /* ---------- */ - Cursor pointer_leftptr; + Cursor pointer_leftptr; #ifdef POINTER_BLANK - Cursor pointer_blank; + Cursor pointer_blank; #endif /* ---------- */ - const char *ttydev; /* pty/tty name */ + const char *ttydev; /* pty/tty name */ #ifndef NO_BACKSPACE_KEY - const char *key_backspace; + const char *key_backspace; #endif #ifndef NO_DELETE_KEY - const char *key_delete; + const char *key_delete; #endif #if defined (HOTKEY_CTRL) || defined (HOTKEY_META) - KeySym ks_bigfont, ks_smallfont; + KeySym ks_bigfont, ks_smallfont; #endif #ifdef GREEK_SUPPORT - KeySym ks_greekmodeswith; + KeySym ks_greekmodeswith; #endif #ifdef USE_XIM - XIC Input_Context; - XIMStyle input_style; - int event_type; + XIC Input_Context; + XIMStyle input_style; + int event_type; #endif - struct mouse_event MEvent; - XComposeStatus compose; + struct mouse_event MEvent; + XComposeStatus compose; #ifdef RXVT_GRAPHICS - int graphics_up; - struct grwin_t *gr_root; + int graphics_up; + struct grwin_t *gr_root; #endif - ttymode_t tio; + ttymode_t tio; #ifdef UTMP_SUPPORT # ifdef HAVE_STRUCT_UTMP - struct utmp ut; + struct utmp ut; # endif # ifdef HAVE_STRUCT_UTMPX - struct utmpx utx; + struct utmpx utx; # endif # if (defined(HAVE_STRUCT_UTMP) && defined(HAVE_UTMP_PID)) || defined(HAVE_STRUCT_UTMPX) - char ut_id[5]; + char ut_id[5]; # endif - int utmp_pos; + int utmp_pos; #endif - row_col_t oldcursor; + row_col_t oldcursor; #ifdef XPM_BACKGROUND - bgPixmap_t bgPixmap; - XpmAttributes xpmAttr; /* originally loaded pixmap and its scaling */ + bgPixmap_t bgPixmap; + XpmAttributes xpmAttr; /* originally loaded pixmap and its scaling */ #endif #ifdef MULTICHAR_SET - int oldcursormulti; - void (*multichar_decode)(unsigned char *str, int len); + int oldcursormulti; + void (*multichar_decode)(unsigned char *str, int len); #endif #ifndef RESET_TTY_TO_COMMON_DEFAULTS - struct stat ttyfd_stat; /* original status of our tty */ + struct stat ttyfd_stat; /* original status of our tty */ #endif #ifdef MENUBAR - menu_t *ActiveMenu, /* currently active menu */ - *BuildMenu; /* the menu currently being built */ - bar_t *CurrentBar; + menu_t *ActiveMenu, /* currently active menu */ + *BuildMenu; /* the menu currently being built */ + bar_t *CurrentBar; # if !(MENUBAR_MAX > 1) - bar_t BarList; -# endif /* (MENUBAR_MAX > 1) */ + bar_t BarList; +# endif /* (MENUBAR_MAX > 1) */ #endif #ifdef RXVT_GRAPHICS - Window gr_last_id; + Window gr_last_id; #endif #ifdef CURSOR_BLINK - struct timeval lastcursorchange; + struct timeval lastcursorchange; #endif #ifdef POINTER_BLANK - struct timeval lastmotion; + struct timeval lastmotion; #endif - struct timeval timeout[NUM_TIMEOUTS]; + struct timeval timeout[NUM_TIMEOUTS]; /* these three don't need to be kept but do so to placate some mem checkers */ - char *env_windowid; /* environmental variable WINDOWID */ - char *env_display; /* environmental variable DISPLAY */ - char *env_term; /* environmental variable TERM */ - char *env_colorfgbg; - char *buffer; - char *locale; - char charsets[4]; - unsigned char *v_buffer; /* pointer to physical buffer */ - unsigned char *v_bufstr; /* beginning of area to write */ - unsigned char *v_bufptr; /* end of area to write */ - unsigned char *v_bufend; /* end of physical buffer */ - char *newfont[MAX_NFONTS]; + char *env_windowid; /* environmental variable WINDOWID */ + char *env_display; /* environmental variable DISPLAY */ + char *env_term; /* environmental variable TERM */ + char *env_colorfgbg; + char *buffer; + char *locale; + char charsets[4]; + unsigned char *v_buffer; /* pointer to physical buffer */ + unsigned char *v_bufstr; /* beginning of area to write */ + unsigned char *v_bufptr; /* end of area to write */ + unsigned char *v_bufend; /* end of physical buffer */ + char *newfont[MAX_NFONTS]; #ifdef KEYSYM_RESOURCE - const unsigned char *Keysym_map[256]; + const unsigned char *Keysym_map[256]; #endif - const char *rs[NUM_RESOURCES]; + const char *rs[NUM_RESOURCES]; /* command input buffering */ - unsigned char *cmdbuf_ptr, *cmdbuf_endp; - unsigned char cmdbuf_base[BUFSIZ]; - unsigned char kbuf[KBUFSZ]; + unsigned char *cmdbuf_ptr, *cmdbuf_endp; + unsigned char cmdbuf_base[BUFSIZ]; + unsigned char kbuf[KBUFSZ]; + + void pty_cb (io_watcher &w, short revents); io_watcher pty_ev; + void x_cb (io_watcher &w, short revents); io_watcher x_ev; + + rxvt_term (); + ~rxvt_term (); + + void process_x_events (); + + void *operator new (size_t s); + void operator delete (void *p, size_t s); }; #ifndef __attribute__ @@ -1131,14 +1140,14 @@ struct rxvt_hidden { ***************************************************************************** */ #ifdef PROTOTYPES -# define __PROTO(p) p +# define __PROTO(p) p #else -# define __PROTO(p) () +# define __PROTO(p) () #endif #include "protos.h" #ifdef DEBUG_malloc -# include "dmalloc.h" /* This comes last */ +# include "dmalloc.h" /* This comes last */ #endif -#endif /* _RXVT_H_ */ +#endif /* _RXVT_H_ */ diff --git a/src/rxvtc.C b/src/rxvtc.C index 262969ac..51ff1c6b 100644 --- a/src/rxvtc.C +++ b/src/rxvtc.C @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -31,17 +32,28 @@ client::client () } } +extern char **environ; + int main(int argc, const char *const *argv) { client c; char buf[PATH_MAX]; + { + sigset_t ss; + + sigaddset (&ss, SIGHUP); + sigprocmask (SIG_BLOCK, &ss, 0); + } + c.send ("NEW"); - c.send ("DISPLAY"), c.send (getenv ("DISPLAY")); // instead of getcwd we could opendir(".") and pass the fd for fchdir *g* c.send ("CWD"), c.send (getcwd (buf, sizeof (buf))); + for (char **var = environ; *environ; environ++) + c.send ("ENV"), c.send (*environ); + for (int i = 0; i < argc; i++) c.send ("ARG"), c.send (argv[i]); diff --git a/src/rxvtd.C b/src/rxvtd.C index d56acc95..2ae8bdb5 100644 --- a/src/rxvtd.C +++ b/src/rxvtd.C @@ -4,11 +4,17 @@ #include #include +#include +#include #include #include #include +#include + +extern char **environ; + struct server : rxvt_connection { void read_cb (io_watcher &w, short revents); io_watcher read_ev; @@ -19,7 +25,7 @@ struct server : rxvt_connection { read_ev.start (fd, EVENT_READ); } - void err (); + void err (const char *format = 0, ...); }; struct listener { @@ -69,8 +75,20 @@ void listener::accept_cb (io_watcher &w, short revents) new server (fd2); } -void server::err () +void server::err (const char *format, ...) { + if (format) + { + char err[1024]; + + va_list ap; + va_start (ap, format); + vsnprintf (err, 1024, format, ap); + va_end (ap); + + send ("ERR"), send (err); + } + close (fd); delete this; } @@ -83,8 +101,8 @@ void server::read_cb (io_watcher &w, short revents) { if (!strcmp (tok, "NEW")) { - auto_str display, cwd; - simplevec argv; + stringvec argv; + stringvec envv; for (;;) { @@ -93,25 +111,35 @@ void server::read_cb (io_watcher &w, short revents) if (!strcmp (tok, "END")) break; - else if (!strcmp (tok, "DISPLAY") && recv (display)) - ; - else if (!strcmp (tok, "CWD") && recv (cwd)) - ; + else if (!strcmp (tok, "ENV") && recv (tok)) + envv.push_back (tok.get ()); + else if (!strcmp (tok, "CWD") && recv (tok)) + { + if (chdir (tok)) + err ("unable to change to working directory to '%s': %s", + (char *)tok, strerror (errno)); + } else if (!strcmp (tok, "ARG") && recv (tok)) - argv.push_back (tok); + argv.push_back (tok.get ()); else - return err (); + return err ("protocol error: unexpected NEW token"); } - // TODO: no setenv, please - setenv ("DISPLAY", display.get (), 1); + envv.push_back (0); - rxvt_init (argv.size (), reinterpret_cast(argv.begin ())); - dR; - rxvt_main_loop (aR); + { + char **old_environ = environ; + environ = envv.begin (); + + rxvt_init (argv.size (), argv.begin ()); + //dR; + //rxvt_main_loop (aR); + + environ = old_environ; + } } else - return err (); + return err ("protocol error: request '%s' unsupported.", (char *)tok); } else return err (); @@ -121,6 +149,15 @@ int main(int argc, const char *const *argv) { listener l; + + { + sigset_t ss; + + sigaddset (&ss, SIGHUP); + sigprocmask (SIG_BLOCK, &ss, 0); + } + + printf ("rxvtd running.\n"); iom.loop (); #if 0 diff --git a/src/rxvtlib.h.in b/src/rxvtlib.h.in index d7ae8db8..cce8e4d3 100644 --- a/src/rxvtlib.h.in +++ b/src/rxvtlib.h.in @@ -1,8 +1,8 @@ /* - * $Id: rxvtlib.h.in,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: rxvtlib.h.in,v 1.3 2003-11-25 11:52:42 pcg Exp $ */ -#ifndef _RXVTLIB_H_ /* include once only */ +#ifndef _RXVTLIB_H_ /* include once only */ #define _RXVTLIB_H_ /* @@ -45,7 +45,7 @@ #include extern "C" { -#include /* Xlib, Xutil, Xresource, Xfuncproto */ +#include /* Xlib, Xutil, Xresource, Xfuncproto */ } /* @@ -69,14 +69,18 @@ extern "C" { struct rxvt_fontset; struct rxvt_color; -struct rxvt_vars; /* defined later on */ -struct rxvt_hidden; /* not defined here */ +struct rxvt_vars; /* defined later on */ +struct rxvt_term; -extern struct rxvt_vars *rxvt_current_term; +typedef struct rxvt_term *rxvt_t; + +extern rxvt_t rxvt_current_term; + +#define EXPLICIT_CONTEXT 1 #if EXPLICIT_CONTEXT -# define pR struct rxvt_vars *rxvt_term +# define pR rxvt_t rxvt_term # define aR rxvt_term # define pR_ pR, # define aR_ aR, @@ -100,14 +104,14 @@ extern struct rxvt_vars *rxvt_current_term; #endif -#define dR rxvt_t *rxvt_term = GET_R +#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(rxvtvars) ((rxvtvars)->scrollBar.state) +#define menubar_visible(rxvtvars) ((rxvtvars)->menuBar.state) typedef struct { - int32_t row; - int32_t col; + int32_t row; + int32_t col; } row_col_t; #if UNICODE3 @@ -129,27 +133,27 @@ typedef uint32_t rend_t; */ typedef struct { - uint16_t width; /* window width [pixels] */ - uint16_t height; /* window height [pixels] */ - uint16_t fwidth; /* font width [pixels] */ - uint16_t fheight; /* font height [pixels] */ - uint16_t fbase; /* font ascent (baseline) [pixels] */ - uint16_t propfont; /* font proportional flags */ - uint16_t ncol; /* window columns [characters] */ - uint16_t nrow; /* window rows [characters] */ - uint16_t focus; /* window has focus */ - uint16_t mapped; /* window state mapped? */ - uint16_t int_bwidth; /* internal border width */ - uint16_t ext_bwidth; /* external border width */ - uint16_t lineSpace; /* number of extra pixels between rows */ - uint16_t saveLines; /* number of lines that fit in scrollback */ - uint16_t nscrolled; /* number of line actually scrolled */ - uint16_t view_start; /* scrollback view starts here */ - Window parent[6]; /* parent identifiers - we're parent[0] */ - Window vt; /* vt100 window */ - GC gc; /* GC for drawing */ - Pixmap pixmap; - rxvt_fontset *fontset; + uint16_t width; /* window width [pixels] */ + uint16_t height; /* window height [pixels] */ + uint16_t fwidth; /* font width [pixels] */ + uint16_t fheight; /* font height [pixels] */ + uint16_t fbase; /* font ascent (baseline) [pixels] */ + uint16_t propfont; /* font proportional flags */ + uint16_t ncol; /* window columns [characters] */ + uint16_t nrow; /* window rows [characters] */ + uint16_t focus; /* window has focus */ + uint16_t mapped; /* window state mapped? */ + uint16_t int_bwidth; /* internal border width */ + uint16_t ext_bwidth; /* external border width */ + uint16_t lineSpace; /* number of extra pixels between rows */ + uint16_t saveLines; /* number of lines that fit in scrollback */ + uint16_t nscrolled; /* number of line actually scrolled */ + uint16_t view_start; /* scrollback view starts here */ + Window parent[6]; /* parent identifiers - we're parent[0] */ + Window vt; /* vt100 window */ + GC gc; /* GC for drawing */ + Pixmap pixmap; + rxvt_fontset *fontset; } TermWin_t; /* @@ -182,37 +186,37 @@ typedef struct { * normal `unscrolled' screen region */ typedef struct { - text_t **text; /* _all_ the text */ - int16_t *tlen; /* length of each text line */ - rend_t **rend; /* rendition, uses RS_ flags */ - row_col_t cur; /* cursor position on the screen */ - uint16_t tscroll; /* top of settable scroll region */ - uint16_t bscroll; /* bottom of settable scroll region */ - uint16_t charset; /* character set number [0..3] */ - unsigned int flags; /* see below */ - row_col_t s_cur; /* saved cursor position */ - uint16_t s_charset; /* saved character set number [0..3] */ - char s_charset_char; - rend_t s_rstyle; /* saved rendition style */ + text_t **text; /* _all_ the text */ + int16_t *tlen; /* length of each text line */ + rend_t **rend; /* rendition, uses RS_ flags */ + row_col_t cur; /* cursor position on the screen */ + uint16_t tscroll; /* top of settable scroll region */ + uint16_t bscroll; /* bottom of settable scroll region */ + uint16_t charset; /* character set number [0..3] */ + unsigned int flags; /* see below */ + row_col_t s_cur; /* saved cursor position */ + uint16_t s_charset; /* saved character set number [0..3] */ + char s_charset_char; + rend_t s_rstyle; /* saved rendition style */ } screen_t; enum selection_op_t { - SELECTION_CLEAR = 0, /* nothing selected */ - SELECTION_INIT, /* marked a point */ - SELECTION_BEGIN, /* started a selection */ - SELECTION_CONT, /* continued selection */ - SELECTION_DONE /* selection put in CUT_BUFFER0 */ + SELECTION_CLEAR = 0, /* nothing selected */ + SELECTION_INIT, /* marked a point */ + SELECTION_BEGIN, /* started a selection */ + SELECTION_CONT, /* continued selection */ + SELECTION_DONE /* selection put in CUT_BUFFER0 */ }; typedef struct { - unsigned char *text; /* selected text */ - uint32_t len; /* length of selected text */ - short screen; /* screen being used */ - short clicks; /* number of clicks */ - selection_op_t op; /* current operation */ - row_col_t beg; /* beginning of selection <= mark */ - row_col_t mark; /* point of initial click <= end */ - row_col_t end; /* one character past end point */ + unsigned char *text; /* selected text */ + uint32_t len; /* length of selected text */ + short screen; /* screen being used */ + short clicks; /* number of clicks */ + selection_op_t op; /* current operation */ + row_col_t beg; /* beginning of selection <= mark */ + row_col_t mark; /* point of initial click <= end */ + row_col_t end; /* one character past end point */ } selection_t; typedef enum { @@ -222,124 +226,93 @@ typedef enum { /* ------------------------------------------------------------------------- */ /* screen_t flags */ -#define Screen_Relative (1<<0) /* relative origin mode flag */ -#define Screen_VisibleCursor (1<<1) /* cursor visible? */ -#define Screen_Autowrap (1<<2) /* auto-wrap flag */ -#define Screen_Insert (1<<3) /* insert mode (vs. overstrike) */ -#define Screen_WrapNext (1<<4) /* need to wrap for next char? */ -#define Screen_DefaultFlags (Screen_VisibleCursor|Screen_Autowrap) +#define Screen_Relative (1<<0) /* relative origin mode flag */ +#define Screen_VisibleCursor (1<<1) /* cursor visible? */ +#define Screen_Autowrap (1<<2) /* auto-wrap flag */ +#define Screen_Insert (1<<3) /* insert mode (vs. overstrike) */ +#define Screen_WrapNext (1<<4) /* need to wrap for next char? */ +#define Screen_DefaultFlags (Screen_VisibleCursor|Screen_Autowrap) /* rxvt_vars.Options */ -#define Opt_console (1LU<<0) -#define Opt_loginShell (1LU<<1) -#define Opt_iconic (1LU<<2) -#define Opt_visualBell (1LU<<3) -#define Opt_mapAlert (1LU<<4) -#define Opt_reverseVideo (1LU<<5) -#define Opt_utmpInhibit (1LU<<6) -#define Opt_scrollBar (1LU<<7) -#define Opt_scrollBar_right (1LU<<8) -#define Opt_scrollBar_floating (1LU<<9) -#define Opt_meta8 (1LU<<10) -#define Opt_scrollTtyOutput (1LU<<11) -#define Opt_scrollTtyKeypress (1LU<<12) -#define Opt_transparent (1LU<<13) -#define Opt_transparent_all (1LU<<14) -#define Opt_mc_hack (1LU<<15) -#define Opt_tripleclickwords (1LU<<16) -#define Opt_scrollWithBuffer (1LU<<17) -#define Opt_jumpScroll (1LU<<18) +#define Opt_console (1LU<<0) +#define Opt_loginShell (1LU<<1) +#define Opt_iconic (1LU<<2) +#define Opt_visualBell (1LU<<3) +#define Opt_mapAlert (1LU<<4) +#define Opt_reverseVideo (1LU<<5) +#define Opt_utmpInhibit (1LU<<6) +#define Opt_scrollBar (1LU<<7) +#define Opt_scrollBar_right (1LU<<8) +#define Opt_scrollBar_floating (1LU<<9) +#define Opt_meta8 (1LU<<10) +#define Opt_scrollTtyOutput (1LU<<11) +#define Opt_scrollTtyKeypress (1LU<<12) +#define Opt_transparent (1LU<<13) +#define Opt_transparent_all (1LU<<14) +#define Opt_mc_hack (1LU<<15) +#define Opt_tripleclickwords (1LU<<16) +#define Opt_scrollWithBuffer (1LU<<17) +#define Opt_jumpScroll (1LU<<18) #define Opt_mouseWheelScrollPage (1LU<<19) -#define Opt_pointerBlank (1LU<<20) -#define Opt_cursorBlink (1LU<<21) +#define Opt_pointerBlank (1LU<<20) +#define Opt_cursorBlink (1LU<<21) /* place holder used for parsing command-line options */ -#define Opt_Reverse (1LU<<30) -#define Opt_Boolean (1LU<<31) +#define Opt_Reverse (1LU<<30) +#define Opt_Boolean (1LU<<31) -#define DEFAULT_OPTIONS (Opt_scrollBar | Opt_scrollTtyOutput \ - | Opt_jumpScroll) - -#define PROPFONT_NORMAL (1<<0) -#define PROPFONT_BOLD (1<<1) +#define DEFAULT_OPTIONS (Opt_scrollBar | Opt_scrollTtyOutput \ + | Opt_jumpScroll) /* ------------------------------------------------------------------------- */ -typedef enum { - EUCJ, SJIS, /* Japanese KANJI methods */ - BIG5, CNS, /* Chinese BIG5 methods: CNS not implemented */ - GB, /* Chinese GB method */ - KR, /* Korean method */ - NOENC /* no encoding */ -} ENC_METHOD; - -typedef struct { - short method; - void (*func)(unsigned char *, int); - char *name; -} KNOWN_ENCODINGS; - typedef struct { - short state; - Window win; + short state; + Window win; } menuBar_t; typedef struct { - char state; /* scrollbar state */ - char init; /* scrollbar has been initialised */ - short beg; /* slider sub-window begin height */ - short end; /* slider sub-window end height */ - short top; /* slider top position */ - short bot; /* slider bottom position */ - short style; /* style: rxvt, xterm, next */ - short width; /* scrollbar width */ - Window win; - int (*update)(pR_ int, int, int, int); + char state; /* scrollbar state */ + char init; /* scrollbar has been initialised */ + short beg; /* slider sub-window begin height */ + short end; /* slider sub-window end height */ + short top; /* slider top position */ + short bot; /* slider bottom position */ + short style; /* style: rxvt, xterm, next */ + short width; /* scrollbar width */ + Window win; + int (*update)(pR_ int, int, int, int); } scrollBar_t; -typedef struct rxvt_vars { -/* - * These ``hidden'' items are not for public consumption and - * must not be accessed externally - */ - struct rxvt_hidden *h; +struct rxvt_vars { + TermWin_t TermWin; + scrollBar_t scrollBar; + menuBar_t menuBar; + Display *Xdisplay; + unsigned long Options; + XSizeHints szHint; + Colormap Xcmap; + rxvt_color *PixColors; + short numPixColors; + Cursor TermWin_cursor; /* cursor for vt window */ + int Xdepth; + int sb_shadow; /* scrollbar shadow width */ + int Xfd; /* file descriptor of X server connection */ + int cmd_fd; /* pty file descriptor; connected to command */ + int tty_fd; /* tty file descriptor; connected to child */ + int num_fds; /* number of file descriptors being used */ + int numlock_state; + text_t **drawn_text; /* text drawn on screen (characters) */ + rend_t **drawn_rend; /* text drawn on screen (rendition) */ + text_t **buf_text; + rend_t **buf_rend; + char *tabs; /* per location: 1 == tab-stop */ + screen_t screen; + screen_t swap; + selection_t selection; + sstyle_t selection_style; +}; -/* - * Exposed items - * Changes to structure here require library version number change - */ - TermWin_t TermWin; - scrollBar_t scrollBar; - menuBar_t menuBar; - Display *Xdisplay; - unsigned long Options; - XSizeHints szHint; - Colormap Xcmap; - rxvt_color *PixColors; - short numPixColors; - Cursor TermWin_cursor; /* cursor for vt window */ - int Xdepth; - int sb_shadow; /* scrollbar shadow width */ - int Xfd; /* file descriptor of X server connection */ - int cmd_fd; /* pty file descriptor; connected to command */ - int tty_fd; /* tty file descriptor; connected to child */ - int num_fds; /* number of file descriptors being used */ - int numlock_state; - text_t **drawn_text; /* text drawn on screen (characters) */ - rend_t **drawn_rend; /* text drawn on screen (rendition) */ - text_t **buf_text; - rend_t **buf_rend; - char *tabs; /* per location: 1 == tab-stop */ - screen_t screen; - screen_t swap; - selection_t selection; - sstyle_t selection_style; - ENC_METHOD encoding_method; -} rxvt_t; +rxvt_t rxvt_init (int argc, const char *const *argv); -/***************************************************************************** - * PROTOTYPES * - *****************************************************************************/ -void rxvt_main_loop(pR); -rxvt_t *rxvt_init(int, const char *const *); +#endif /* _RXVTLIB_H_ */ -#endif /* _RXVTLIB_H_ */ diff --git a/src/rxvtvec.h b/src/rxvtvec.h index 01d17925..60105289 100644 --- a/src/rxvtvec.h +++ b/src/rxvtvec.h @@ -7,6 +7,8 @@ template static inline T max (T a, long b) { return a > b ? a : b; } #include #include "simplevec.h" +#include + #if 0 template struct rxvt_vec : simplevec { @@ -39,6 +41,12 @@ struct auto_ptr { auto_ptr() : p(0) { } auto_ptr(T *a) : p(a) { } + auto_ptr(auto_ptr &a) + { + p = a.p; + a.p = 0; + } + template auto_ptr(auto_ptr &a) { @@ -46,6 +54,11 @@ struct auto_ptr { a.p = 0; } + ~auto_ptr() + { + delete p; + } + // void because it makes sense in our context void operator =(T *a) { @@ -53,6 +66,12 @@ struct auto_ptr { p = a; } + void operator =(auto_ptr &a) + { + *this = a.p; + a.p = 0; + } + template void operator =(auto_ptr &a) { @@ -75,4 +94,14 @@ struct auto_ptr { typedef auto_ptr auto_str; +struct stringvec : simplevec +{ + ~stringvec () + { + for (char **c = begin(); c != end(); c++) + delete [] *c; + } +}; + #endif + diff --git a/src/screen.C b/src/screen.C index e631f63a..1c3bf153 100644 --- a/src/screen.C +++ b/src/screen.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*--------------------------------------* * File: screen.c *---------------------------------------------------------------------------* - * $Id: screen.C,v 1.2 2003-11-24 17:31:27 pcg Exp $ + * $Id: screen.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * Copyright (c) 1997-2001 Geoff Wing * @@ -166,11 +166,11 @@ rxvt_scr_reset(pR) D_SCREEN((stderr, "rxvt_scr_reset()")); R->TermWin.view_start = 0; - RESET_CHSTAT(R->h); - R->h->num_scr = 0; + RESET_CHSTAT(R); + R->num_scr = 0; - prev_ncol = R->h->prev_ncol; - prev_nrow = R->h->prev_nrow; + prev_ncol = R->prev_ncol; + prev_nrow = R->prev_nrow; if (R->TermWin.ncol == 0) R->TermWin.ncol = 80; if (R->TermWin.nrow == 0) @@ -180,7 +180,7 @@ rxvt_scr_reset(pR) if (ncol == prev_ncol && nrow == prev_nrow) return; - R->h->want_refresh = 1; + R->want_refresh = 1; total_rows = nrow + R->TermWin.saveLines; prev_total_rows = prev_nrow + R->TermWin.saveLines; @@ -216,21 +216,21 @@ rxvt_scr_reset(pR) rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, p, DEFAULT_RSTYLE); } - MEMSET(R->h->charsets, 'B', sizeof(R->h->charsets)); + MEMSET(R->charsets, 'B', sizeof(R->charsets)); R->TermWin.nscrolled = 0; /* no saved lines */ - R->h->rstyle = DEFAULT_RSTYLE; + R->rstyle = DEFAULT_RSTYLE; R->screen.flags = Screen_DefaultFlags; R->screen.cur.row = R->screen.cur.col = 0; R->screen.charset = 0; - R->h->current_screen = PRIMARY; + R->current_screen = PRIMARY; rxvt_scr_cursor(aR_ SAVE); #if NSCREENS R->swap.flags = Screen_DefaultFlags; R->swap.cur.row = R->swap.cur.col = 0; R->swap.charset = 0; - R->h->current_screen = SECONDARY; + R->current_screen = SECONDARY; rxvt_scr_cursor(aR_ SAVE); - R->h->current_screen = PRIMARY; + R->current_screen = PRIMARY; #endif R->selection.text = NULL; R->selection.len = 0; @@ -238,7 +238,7 @@ rxvt_scr_reset(pR) R->selection.screen = PRIMARY; R->selection.clicks = 0; CLEAR_ALL_SELECTION(R); - R->h->rvideo = 0; + R->rvideo = 0; } else { /* @@ -362,10 +362,10 @@ rxvt_scr_reset(pR) for (p = 0; p < ncol; p++) R->tabs[p] = (p % TABSIZE == 0) ? 1 : 0; - R->h->prev_nrow = nrow; - R->h->prev_ncol = ncol; + R->prev_nrow = nrow; + R->prev_ncol = ncol; - rxvt_tt_winsize(R->cmd_fd, R->TermWin.ncol, R->TermWin.nrow, R->h->cmd_pid); + rxvt_tt_winsize(R->cmd_fd, R->TermWin.ncol, R->TermWin.nrow, R->cmd_pid); } /* INTPROTO */ @@ -451,7 +451,7 @@ rxvt_scr_poweron(pR) D_SCREEN((stderr, "rxvt_scr_poweron()")); rxvt_scr_release(aR); - R->h->prev_nrow = R->h->prev_ncol = 0; + R->prev_nrow = R->prev_ncol = 0; rxvt_scr_reset(aR); rxvt_scr_clear(aR); @@ -478,7 +478,7 @@ rxvt_scr_cursor(pR_ int mode) D_SCREEN((stderr, "rxvt_scr_cursor(%c)", mode)); #if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) - if (R->h->current_screen == SECONDARY) + if (R->current_screen == SECONDARY) s = &(R->swap); else #endif @@ -487,18 +487,18 @@ rxvt_scr_cursor(pR_ int mode) case SAVE: s->s_cur.row = s->cur.row; s->s_cur.col = s->cur.col; - s->s_rstyle = R->h->rstyle; + s->s_rstyle = R->rstyle; s->s_charset = s->charset; - s->s_charset_char = R->h->charsets[s->charset]; + s->s_charset_char = R->charsets[s->charset]; break; case RESTORE: - R->h->want_refresh = 1; + R->want_refresh = 1; s->cur.row = s->s_cur.row; s->cur.col = s->s_cur.col; s->flags &= ~Screen_WrapNext; - R->h->rstyle = s->s_rstyle; + R->rstyle = s->s_rstyle; s->charset = s->s_charset; - R->h->charsets[s->charset] = s->s_charset_char; + R->charsets[s->charset] = s->s_charset_char; rxvt_set_font_style(aR); break; } @@ -529,23 +529,23 @@ rxvt_scr_change_screen(pR_ int scrn) int offset; #endif - R->h->want_refresh = 1; + R->want_refresh = 1; D_SCREEN((stderr, "rxvt_scr_change_screen(%d)", scrn)); R->TermWin.view_start = 0; - RESET_CHSTAT(R->h); + RESET_CHSTAT(R); - if (R->h->current_screen == scrn) - return R->h->current_screen; + if (R->current_screen == scrn) + return R->current_screen; rxvt_selection_check(aR_ 2); /* check for boundary cross */ - SWAP_IT(R->h->current_screen, scrn, int); + SWAP_IT(R->current_screen, scrn, int); #if NSCREENS - R->h->num_scr = 0; + R->num_scr = 0; offset = R->TermWin.saveLines; - for (i = R->h->prev_nrow; i--;) { + 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 *); @@ -553,13 +553,13 @@ rxvt_scr_change_screen(pR_ int scrn) SWAP_IT(R->screen.cur.row, R->swap.cur.row, int16_t); SWAP_IT(R->screen.cur.col, R->swap.cur.col, int16_t); # ifdef DEBUG_STRICT - assert((R->screen.cur.row >= 0) && (R->screen.cur.row < R->h->prev_nrow)); - assert((R->screen.cur.col >= 0) && (R->screen.cur.col < R->h->prev_ncol)); + 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)); # else /* drive with your eyes closed */ MAX_IT(R->screen.cur.row, 0); - MIN_IT(R->screen.cur.row, (int32_t)R->h->prev_nrow - 1); + 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->h->prev_ncol - 1); + MIN_IT(R->screen.cur.col, (int32_t)R->prev_ncol - 1); # endif SWAP_IT(R->screen.charset, R->swap.charset, int16_t); SWAP_IT(R->screen.flags, R->swap.flags, int); @@ -579,12 +579,12 @@ rxvt_scr_change_screen(pR_ int scrn) if (rxvt_Gr_Displayed(aR)) rxvt_Gr_ClearScreen(aR); # endif - if (R->h->current_screen == PRIMARY + if (R->current_screen == PRIMARY # ifdef RXVT_GRAPHICS && !rxvt_Gr_Displayed(aR) # endif ) - rxvt_scroll_text(aR_ 0, (R->h->prev_nrow - 1), R->h->prev_nrow, 0); + rxvt_scroll_text(aR_ 0, (R->prev_nrow - 1), R->prev_nrow, 0); # endif #endif return scrn; @@ -600,9 +600,9 @@ rxvt_scr_color(pR_ unsigned int color, int fgbg) { color &= RS_fgMask; if (fgbg == Color_fg) - R->h->rstyle = SET_FGCOLOR(R->h->rstyle, color); + R->rstyle = SET_FGCOLOR(R->rstyle, color); else - R->h->rstyle = SET_BGCOLOR(R->h->rstyle, color); + R->rstyle = SET_BGCOLOR(R->rstyle, color); } /* ------------------------------------------------------------------------- */ @@ -614,11 +614,11 @@ void rxvt_scr_rendition(pR_ int set, int style) { if (set) - R->h->rstyle |= style; + R->rstyle |= style; else if (style == ~RS_None) - R->h->rstyle = DEFAULT_RSTYLE; + R->rstyle = DEFAULT_RSTYLE; else - R->h->rstyle &= ~style; + R->rstyle &= ~style; } /* ------------------------------------------------------------------------- */ @@ -638,10 +638,10 @@ rxvt_scroll_text(pR_ int row1, int row2, int count, int spec) if (count == 0 || (row1 > row2)) return 0; - R->h->want_refresh = 1; - D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (R->h->current_screen == PRIMARY) ? "Primary" : "Secondary")); + R->want_refresh = 1; + D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (R->current_screen == PRIMARY) ? "Primary" : "Secondary")); - if ((count > 0) && (row1 == 0) && (R->h->current_screen == PRIMARY)) { + if ((count > 0) && (row1 == 0) && (R->current_screen == PRIMARY)) { nscrolled = (long)R->TermWin.nscrolled + (long)count;; if (nscrolled > (long)R->TermWin.saveLines) R->TermWin.nscrolled = R->TermWin.saveLines; @@ -655,7 +655,7 @@ rxvt_scroll_text(pR_ int row1, int row2, int count, int spec) row1 += R->TermWin.saveLines; row2 += R->TermWin.saveLines; - if (R->selection.op && R->h->current_screen == R->selection.screen) { + if (R->selection.op && R->current_screen == R->selection.screen) { i = R->selection.beg.row + R->TermWin.saveLines; j = R->selection.end.row + R->TermWin.saveLines; if ((i < row1 && j > row1) @@ -675,7 +675,7 @@ rxvt_scroll_text(pR_ int row1, int row2, int count, int spec) } rxvt_selection_check(aR_ 0); /* _after_ R->TermWin.nscrolled update */ - R->h->num_scr += count; + R->num_scr += count; j = count; if (count < 0) count = -count; @@ -722,7 +722,7 @@ rxvt_scroll_text(pR_ int row1, int row2, int count, int spec) R->screen.rend[j] = R->buf_rend[i]; if (!spec) /* line length may not equal TermWin.ncol */ rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, - (unsigned int)j, R->h->rstyle); + (unsigned int)j, R->rstyle); } #ifdef RXVT_GRAPHICS @@ -745,12 +745,11 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) int i, row, last_col; text_t *stp; rend_t *srp; - struct rxvt_hidden *h = R->h; if (len <= 0) /* sanity */ return; - h->want_refresh = 1; + R->want_refresh = 1; last_col = R->TermWin.ncol; D_SCREEN((stderr, "rxvt_scr_add_lines(%d,%d)", nlines, len)); @@ -778,7 +777,7 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) row = R->screen.cur.row + R->TermWin.saveLines; checksel = (R->selection.op - && h->current_screen == R->selection.screen) ? 1 : 0; + && R->current_screen == R->selection.screen) ? 1 : 0; clearsel = 0; stp = R->screen.text[row]; @@ -800,14 +799,14 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) row = (++R->screen.cur.row) + R->TermWin.saveLines; stp = R->screen.text[row]; /* _must_ refresh */ srp = R->screen.rend[row]; /* _must_ refresh */ - RESET_CHSTAT(h); + RESET_CHSTAT(R); 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; - RESET_CHSTAT(h); + RESET_CHSTAT(R); continue; default: if (c == 127) @@ -835,7 +834,7 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) if (R->screen.flags & Screen_Insert) rxvt_scr_insdel_chars(aR_ 1, INSERT); - if (R->h->charsets[R->screen.charset] == '0') // DEC SPECIAL + if (R->charsets[R->screen.charset] == '0') // DEC SPECIAL switch (c) { case '+': c = 0x2192; break; case ',': c = 0x2190; break; case '-': c = 0x2191; break; @@ -851,7 +850,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 (h->rstyle, R->TermWin.fontset->find_font (c)); + rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); stp[R->screen.cur.col] = c; srp[R->screen.cur.col] = rend; @@ -910,8 +909,8 @@ rxvt_scr_add_lines(pR_ const uint32_t *str, int nlines, int len) void rxvt_scr_backspace(pR) { - RESET_CHSTAT(R->h); - R->h->want_refresh = 1; + RESET_CHSTAT(R); + R->want_refresh = 1; if (R->screen.cur.col == 0) { if (R->screen.cur.row > 0) { #ifdef TERMCAP_HAS_BW @@ -938,8 +937,8 @@ rxvt_scr_tab(pR_ int count) int i, x; D_SCREEN((stderr, "rxvt_scr_tab(%d)", count)); - R->h->want_refresh = 1; - RESET_CHSTAT(R->h); + R->want_refresh = 1; + RESET_CHSTAT(R); i = x = R->screen.cur.col; if (count == 0) return; @@ -1024,9 +1023,9 @@ rxvt_scr_forwardindex(pR) void rxvt_scr_gotorc(pR_ int row, int col, int relative) { - R->h->want_refresh = 1; + R->want_refresh = 1; ZERO_SCROLLBACK(R); - RESET_CHSTAT(R->h); + RESET_CHSTAT(R); #ifdef RXVT_GRAPHICS if (rxvt_Gr_Displayed(aR)) rxvt_Gr_scroll(aR_ 0); @@ -1075,12 +1074,12 @@ rxvt_scr_index(pR_ enum page_dirn direction) { int dirn; - R->h->want_refresh = 1; + R->want_refresh = 1; dirn = ((direction == UP) ? 1 : -1); D_SCREEN((stderr, "rxvt_scr_index(%d)", dirn)); ZERO_SCROLLBACK(R); - RESET_CHSTAT(R->h); + RESET_CHSTAT(R); #ifdef RXVT_GRAPHICS if (rxvt_Gr_Displayed(aR)) @@ -1111,10 +1110,10 @@ rxvt_scr_erase_line(pR_ int mode) { unsigned int row, col, num; - R->h->want_refresh = 1; + R->want_refresh = 1; D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); ZERO_SCROLLBACK(R); - RESET_CHSTAT(R->h); + RESET_CHSTAT(R); #ifdef RXVT_GRAPHICS if (rxvt_Gr_Displayed(aR)) @@ -1156,10 +1155,10 @@ rxvt_scr_erase_line(pR_ int mode) if (R->screen.text[row]) rxvt_blank_line(aR_ &(R->screen.text[row][col]), - &(R->screen.rend[row][col]), num, R->h->rstyle); + &(R->screen.rend[row][col]), num, R->rstyle); else rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, row, - R->h->rstyle); + R->rstyle); } /* ------------------------------------------------------------------------- */ @@ -1178,10 +1177,10 @@ rxvt_scr_erase_screen(pR_ int mode) rend_t ren; XGCValues gcvalue; - R->h->want_refresh = 1; + R->want_refresh = 1; D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); ZERO_SCROLLBACK(R); - RESET_CHSTAT(R->h); + RESET_CHSTAT(R); row_offset = (int32_t)R->TermWin.saveLines; switch (mode) { @@ -1208,8 +1207,8 @@ rxvt_scr_erase_screen(pR_ int mode) default: return; } - R->h->refresh_type |= REFRESH_BOUNDS; - if (R->selection.op && R->h->current_screen == R->selection.screen + R->refresh_type |= REFRESH_BOUNDS; + if (R->selection.op && R->current_screen == R->selection.screen && ((R->selection.beg.row >= row && R->selection.beg.row <= row + num) || (R->selection.end.row >= row && R->selection.end.row <= row + num))) @@ -1217,14 +1216,14 @@ rxvt_scr_erase_screen(pR_ int mode) if (row >= R->TermWin.nrow) /* Out Of Bounds */ return; MIN_IT(num, (R->TermWin.nrow - row)); - if (R->h->rstyle & (RS_RVid | RS_Uline)) + if (R->rstyle & (RS_RVid | RS_Uline)) ren = (rend_t) ~RS_None; - else if (GET_BASEBG(R->h->rstyle) == Color_bg) { + else if (GET_BASEBG(R->rstyle) == Color_bg) { ren = DEFAULT_RSTYLE; CLEAR_ROWS(row, num); } else { - ren = (R->h->rstyle & (RS_fgMask | RS_bgMask)); - gcvalue.foreground = R->PixColors[GET_BGCOLOR(R->h->rstyle)]; + ren = (R->rstyle & (RS_fgMask | RS_bgMask)); + gcvalue.foreground = R->PixColors[GET_BGCOLOR(R->rstyle)]; XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); ERASE_ROWS(row, num); gcvalue.foreground = R->PixColors[Color_fg]; @@ -1232,7 +1231,7 @@ rxvt_scr_erase_screen(pR_ int mode) } for (; num--; row++) { rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, - (unsigned int)(row + row_offset), R->h->rstyle); + (unsigned int)(row + row_offset), R->rstyle); R->screen.tlen[row + row_offset] = 0; rxvt_blank_line(aR_ R->drawn_text[row], R->drawn_rend[row], @@ -1252,13 +1251,13 @@ rxvt_scr_E(pR) int i, j, k; rend_t *r1, fs; - R->h->want_refresh = 1; - R->h->num_scr_allow = 0; + R->want_refresh = 1; + R->num_scr_allow = 0; ZERO_SCROLLBACK(R); - RESET_CHSTAT(R->h); + RESET_CHSTAT(R); rxvt_selection_check(aR_ 3); - fs = SET_FONT (R->h->rstyle, R->TermWin.fontset->find_font ('E')); + 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); @@ -1278,7 +1277,7 @@ rxvt_scr_insdel_lines(pR_ int count, int insdel) int end; ZERO_SCROLLBACK(R); - RESET_CHSTAT(R->h); + RESET_CHSTAT(R); #ifdef RXVT_GRAPHICS if (rxvt_Gr_Displayed(aR)) @@ -1317,10 +1316,10 @@ rxvt_scr_insdel_chars(pR_ int count, int insdel) rend_t *srp; int16_t *slp; - R->h->want_refresh = 1; + R->want_refresh = 1; ZERO_SCROLLBACK(R); #if 0 - RESET_CHSTAT(R->h); + RESET_CHSTAT(R); #endif #ifdef RXVT_GRAPHICS @@ -1351,7 +1350,7 @@ rxvt_scr_insdel_chars(pR_ int count, int insdel) *slp += count; MIN_IT(*slp, R->TermWin.ncol); } - if (R->selection.op && R->h->current_screen == R->selection.screen + 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)) @@ -1363,14 +1362,14 @@ rxvt_scr_insdel_chars(pR_ int count, int insdel) } } rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), - (unsigned int)count, R->h->rstyle); + (unsigned int)count, R->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; rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), - (unsigned int)count, R->h->rstyle); + (unsigned int)count, R->rstyle); break; case DELETE: tr = srp[R->TermWin.ncol - 1] @@ -1387,7 +1386,7 @@ rxvt_scr_insdel_chars(pR_ int count, int insdel) *slp = R->TermWin.ncol; *slp -= count; MAX_IT(*slp, 0); - if (R->selection.op && R->h->current_screen == R->selection.screen + 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) @@ -1432,7 +1431,7 @@ rxvt_scr_scroll_region(pR_ int top, int bot) void rxvt_scr_cursor_visible(pR_ int mode) { - R->h->want_refresh = 1; + R->want_refresh = 1; if (mode) R->screen.flags |= Screen_VisibleCursor; else @@ -1521,14 +1520,14 @@ rxvt_scr_rvideo_mode(pR_ int mode) { XGCValues gcvalue; - if (R->h->rvideo != mode) { - R->h->rvideo = mode; + if (R->rvideo != mode) { + R->rvideo = mode; SWAP_IT(R->PixColors[Color_fg], R->PixColors[Color_bg], rxvt_color); #if defined(XPM_BACKGROUND) - if (R->h->bgPixmap.pixmap == None) + if (R->bgPixmap.pixmap == None) #endif #if defined(TRANSPARENT) - if (!(R->Options & Opt_transparent) || R->h->am_transparent == 0) + if (!(R->Options & Opt_transparent) || R->am_transparent == 0) #endif XSetWindowBackground(R->Xdisplay, R->TermWin.vt, R->PixColors[Color_bg]); @@ -1566,7 +1565,7 @@ rxvt_scr_report_position(pR) void rxvt_set_font_style(pR) { - switch (R->h->charsets[R->screen.charset]) { + switch (R->charsets[R->screen.charset]) { case '0': /* DEC Special Character & Line Drawing Set */ break; case 'A': /* United Kingdom (UK) */ @@ -1613,7 +1612,7 @@ rxvt_scr_charset_choose(pR_ int set) void rxvt_scr_charset_set(pR_ int set, unsigned int ch) { - R->h->charsets[set] = (unsigned char)ch; + R->charsets[set] = (unsigned char)ch; rxvt_set_font_style(aR); } @@ -1627,7 +1626,7 @@ rxvt_scr_charset_set(pR_ int set, unsigned int ch) int rxvt_scr_get_fgcolor(pR) { - return GET_FGCOLOR(R->h->rstyle); + return GET_FGCOLOR(R->rstyle); } /* ------------------------------------------------------------------------- */ @@ -1635,7 +1634,7 @@ rxvt_scr_get_fgcolor(pR) int rxvt_scr_get_bgcolor(pR) { - return GET_BGCOLOR(R->h->rstyle); + return GET_BGCOLOR(R->rstyle); } #endif @@ -1759,12 +1758,12 @@ int rxvt_scr_changeview(pR_ uint16_t oldviewstart) { if (R->TermWin.view_start != oldviewstart) { - R->h->want_refresh = 1; + R->want_refresh = 1; #ifdef RXVT_GRAPHICS if (rxvt_Gr_Displayed(aR)) rxvt_Gr_scroll(aR_ 0); #endif - R->h->num_scr -= (R->TermWin.view_start - oldviewstart); + R->num_scr -= (R->TermWin.view_start - oldviewstart); } return (int)(R->TermWin.view_start - oldviewstart); } @@ -1782,8 +1781,8 @@ rxvt_scr_bell(pR) XMapWindow(R->Xdisplay, R->TermWin.parent[0]); # endif if (R->Options & Opt_visualBell) { - rxvt_scr_rvideo_mode(aR_ !R->h->rvideo); /* refresh also done */ - rxvt_scr_rvideo_mode(aR_ !R->h->rvideo); /* refresh also done */ + rxvt_scr_rvideo_mode(aR_ !R->rvideo); /* refresh also done */ + rxvt_scr_rvideo_mode(aR_ !R->rvideo); /* refresh also done */ } else XBell(R->Xdisplay, 0); #endif @@ -1872,8 +1871,7 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) #endif rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ - char *buffer; /* local copy of R->h->buffer */ - struct rxvt_hidden *h = R->h; + char *buffer; /* local copy of R->buffer */ if (refresh_type == NO_REFRESH || !R->TermWin.mapped) return; @@ -1886,27 +1884,27 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) bfont = 0; #endif - if (h->currmaxcol < R->TermWin.ncol) { - h->currmaxcol = R->TermWin.ncol; - h->buffer = (char *)rxvt_realloc (h->buffer, - sizeof(char) * (h->currmaxcol + 1) * MB_CUR_MAX); + if (R->currmaxcol < R->TermWin.ncol) { + R->currmaxcol = R->TermWin.ncol; + R->buffer = (char *)rxvt_realloc (R->buffer, + sizeof(char) * (R->currmaxcol + 1) * MB_CUR_MAX); } - buffer = h->buffer; - h->refresh_count = 0; + buffer = R->buffer; + R->refresh_count = 0; row_offset = R->TermWin.saveLines - R->TermWin.view_start; if ((refresh_type & REFRESH_BOUNDS)) { clearfirst = clearlast = 1; - h->refresh_type &= ~REFRESH_BOUNDS; + R->refresh_type &= ~REFRESH_BOUNDS; } #if defined(XPM_BACKGROUND) - must_clear |= (h->bgPixmap.pixmap != None); + must_clear |= (R->bgPixmap.pixmap != None); #endif #if defined(TRANSPARENT) - must_clear |= ((R->Options & Opt_transparent) && h->am_transparent); + must_clear |= ((R->Options & Opt_transparent) && R->am_transparent); #endif - ocrow = h->oldcursor.row; /* is there an old outline cursor on screen? */ + ocrow = R->oldcursor.row; /* is there an old outline cursor on screen? */ /* * B: reverse any characters which are selected @@ -1924,7 +1922,7 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) showcursor = (R->screen.flags & Screen_VisibleCursor); cursorwidth = 0; #ifdef CURSOR_BLINK - if (R->h->hidden_cursor) + if (R->hidden_cursor) showcursor = 0; #endif @@ -1942,19 +1940,19 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) *srp ^= RS_RVid; #ifndef NO_CURSORCOLOR cc1 = *srp & (RS_fgMask | RS_bgMask); - if (XDEPTH > 2 && ISSET_PIXCOLOR(h, Color_cursor)) + if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) ccol1 = Color_cursor; else #ifdef CURSOR_COLOR_IS_RENDITION_COLOR - ccol1 = GET_FGCOLOR(h->rstyle); + ccol1 = GET_FGCOLOR(R->rstyle); #else ccol1 = Color_fg; #endif - if (XDEPTH > 2 && ISSET_PIXCOLOR(h, Color_cursor2)) + if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor2)) ccol2 = Color_cursor2; else #ifdef CURSOR_COLOR_IS_RENDITION_COLOR - ccol2 = GET_BGCOLOR(h->rstyle); + ccol2 = GET_BGCOLOR(R->rstyle); #else ccol2 = Color_bg; #endif @@ -1971,13 +1969,13 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) setoldcursor = 0; if (ocrow != -1) { if (R->screen.cur.row + R->TermWin.view_start != ocrow - || R->screen.cur.col != h->oldcursor.col) { + || R->screen.cur.col != R->oldcursor.col) { if (ocrow < R->TermWin.nrow - && h->oldcursor.col < R->TermWin.ncol) { - R->drawn_rend[ocrow][h->oldcursor.col] ^= (RS_RVid | RS_Uline); + && R->oldcursor.col < R->TermWin.ncol) { + R->drawn_rend[ocrow][R->oldcursor.col] ^= (RS_RVid | RS_Uline); } if (R->TermWin.focus || !showcursor) - h->oldcursor.row = -1; + R->oldcursor.row = -1; else setoldcursor = 1; } @@ -1985,10 +1983,10 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) setoldcursor = 1; if (setoldcursor) { if (R->screen.cur.row + R->TermWin.view_start >= R->TermWin.nrow) - h->oldcursor.row = -1; + R->oldcursor.row = -1; else { - h->oldcursor.row = R->screen.cur.row + R->TermWin.view_start; - h->oldcursor.col = R->screen.cur.col; + R->oldcursor.row = R->screen.cur.row + R->TermWin.view_start; + R->oldcursor.col = R->screen.cur.col; } } } @@ -1998,8 +1996,8 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) * D: CopyArea pass - very useful for slower links * This has been deliberately kept simple. */ - i = h->num_scr; - if (refresh_type == FAST_REFRESH && h->num_scr_allow && i + i = R->num_scr; + if (refresh_type == FAST_REFRESH && R->num_scr_allow && i && abs(i) < R->TermWin.nrow && !must_clear) { int16_t nits; int j; @@ -2138,7 +2136,7 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) #ifdef OPTION_HC if (!rvid && (rend & RS_Blink)) { - if (XDEPTH > 2 && ISSET_PIXCOLOR(h, Color_HC)) + if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_HC)) back = Color_HC; else rvid = !rvid; /* fall back */ @@ -2149,9 +2147,9 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) SWAP_IT(fore, back, int); #ifndef NO_BOLD_UNDERLINE_REVERSE - if (XDEPTH > 2 && ISSET_PIXCOLOR(h, Color_RV) + if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_RV) # ifndef NO_CURSORCOLOR - && !ISSET_PIXCOLOR(h, Color_cursor) + && !ISSET_PIXCOLOR(R, Color_cursor) # endif ) back = Color_RV; @@ -2160,7 +2158,7 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) #ifndef NO_BOLD_UNDERLINE_REVERSE else if (rend & RS_Bold) { - if (XDEPTH > 2 && ISSET_PIXCOLOR(h, Color_BD)) + if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_BD)) { fore = Color_BD; # ifndef VERYBOLD @@ -2170,7 +2168,7 @@ rxvt_scr_refresh(pR_ unsigned char refresh_type) } else if (rend & RS_Uline) { - if (XDEPTH > 2 && ISSET_PIXCOLOR(h, Color_UL)) + if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_UL)) { fore = Color_UL; rend &= ~RS_Uline; /* we've taken care of it */ @@ -2218,17 +2216,17 @@ nodraw: ; #ifndef NO_CURSORCOLOR *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; #endif - } else if (h->oldcursor.row >= 0) { + } else if (R->oldcursor.row >= 0) { #ifndef NO_CURSORCOLOR unsigned long gcmask; /* Graphics Context mask */ - if (XDEPTH > 2 && ISSET_PIXCOLOR(h, Color_cursor)) { + if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) { XSetForeground (R->Xdisplay, R->TermWin.gc, R->PixColors[Color_cursor]); } #endif XDrawRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, - Col2Pixel(h->oldcursor.col), - Row2Pixel(h->oldcursor.row), + Col2Pixel(R->oldcursor.col), + Row2Pixel(R->oldcursor.row), (unsigned int)(Width2Pixel(cursorwidth) - 1), (unsigned int)(Height2Pixel(1) - R->TermWin.lineSpace - 1)); } @@ -2261,9 +2259,9 @@ nodraw: ; if (refresh_type & SMOOTH_REFRESH) XSync(R->Xdisplay, False); - h->num_scr = 0; - h->num_scr_allow = 1; - h->want_refresh = 0; /* screen is current */ + R->num_scr = 0; + R->num_scr_allow = 1; + R->want_refresh = 0; /* screen is current */ } /* ------------------------------------------------------------------------- */ @@ -2273,10 +2271,10 @@ rxvt_scr_clear(pR) { if (!R->TermWin.mapped) return; - R->h->num_scr_allow = 0; - R->h->want_refresh = 1; + R->num_scr_allow = 0; + R->want_refresh = 1; #ifdef TRANSPARENT - if ((R->Options & Opt_transparent) && (R->h->am_pixmap_trans == 0)) { + if ((R->Options & Opt_transparent) && (R->am_pixmap_trans == 0)) { int i; if (!(R->Options & Opt_transparent_all)) @@ -2299,7 +2297,7 @@ rxvt_scr_reverse_selection(pR) int i, col, row, end_row; rend_t *srp; - if (R->selection.op && R->h->current_screen == R->selection.screen) { + 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; @@ -2382,7 +2380,7 @@ rxvt_selection_check(pR_ int check_more) || (R->selection.end.row < -(int32_t)R->TermWin.nscrolled) || (R->selection.end.row >= R->TermWin.nrow) || (check_more == 1 - && R->h->current_screen == R->selection.screen + && R->current_screen == R->selection.screen && !ROWCOL_IS_BEFORE(R->screen.cur, R->selection.beg) && ROWCOL_IS_BEFORE(R->screen.cur, R->selection.end)) || (check_more == 2 @@ -2436,14 +2434,14 @@ rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) char **cl; #endif - D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->h->selection_wait)); + D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); if (prop == None) { /* check for failed XConvertSelection */ #ifdef MULTICHAR_SET - if ((R->h->selection_type & Sel_CompoundText)) { - int selnum = R->h->selection_type & Sel_whereMask; + if ((R->selection_type & Sel_CompoundText)) { + int selnum = R->selection_type & Sel_whereMask; - R->h->selection_type = 0; + R->selection_type = 0; if (selnum != Sel_direct) rxvt_selection_request_other(aR_ XA_STRING, selnum); } @@ -2467,7 +2465,7 @@ 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->h->selection_wait == Sel_normal && nread == 0) { + if (R->selection_wait == Sel_normal && nread == 0) { /* * pass through again trying CUT_BUFFER0 if we've come from * XConvertSelection() but nothing was presented @@ -2493,8 +2491,8 @@ rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) } if (ct.value) XFree(ct.value); - if (R->h->selection_wait == Sel_normal) - R->h->selection_wait = Sel_none; + if (R->selection_wait == Sel_normal) + R->selection_wait = Sel_none; D_SELECT((stderr, "rxvt_selection_paste: bytes written: %ld", nread)); return (int)nread; } @@ -2511,39 +2509,39 @@ rxvt_selection_property(pR_ Window win, Atom prop) if (prop == None) return; D_SELECT((stderr, "rxvt_selection_property(%08lx, %lu)", win, (unsigned long)prop)); - if (R->h->selection_wait == Sel_normal) { + if (R->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->h->xa[XA_INCR], &atype, &afmt, &nitems, + R->xa[XA_INCR], &atype, &afmt, &nitems, &bytes_after, &s); if (s) XFree(s); if (a != Success) return; #ifndef __CYGWIN32__ - if (atype == R->h->xa[XA_INCR]) { /* start an INCR transfer */ + if (atype == R->xa[XA_INCR]) { /* start an INCR transfer */ D_SELECT((stderr, "rxvt_selection_property: INCR: starting transfer")); XDeleteProperty(R->Xdisplay, win, prop); XFlush(R->Xdisplay); reget_time = 1; - R->h->selection_wait = Sel_incr; + R->selection_wait = Sel_incr; } #endif - } else if (R->h->selection_wait == Sel_incr) { + } else if (R->selection_wait == Sel_incr) { reget_time = 1; if (rxvt_selection_paste(aR_ win, prop, True) == -1) { D_SELECT((stderr, "rxvt_selection_property: INCR: clean end")); - R->h->selection_wait = Sel_none; - R->h->timeout[TIMEOUT_INCR].tv_sec = 0; /* turn off timer */ + R->selection_wait = Sel_none; + R->timeout[TIMEOUT_INCR].tv_sec = 0; /* turn off timer */ } } if (reget_time) { /* received more data so reget time */ - (void)gettimeofday(&(R->h->timeout[TIMEOUT_INCR]), NULL); - R->h->timeout[TIMEOUT_INCR].tv_sec += 10; /* ten seconds wait */ + (void)gettimeofday(&(R->timeout[TIMEOUT_INCR]), NULL); + R->timeout[TIMEOUT_INCR].tv_sec += 10; /* ten seconds wait */ } } /* ------------------------------------------------------------------------- */ @@ -2571,17 +2569,17 @@ rxvt_selection_request(pR_ Time tm, int x, int y) } else { int i; - R->h->selection_request_time = tm; - R->h->selection_wait = Sel_normal; + R->selection_request_time = tm; + R->selection_wait = Sel_normal; for (i = Sel_Primary; i <= Sel_Clipboard; i++) { #ifdef MULTICHAR_SET - R->h->selection_type = Sel_CompoundText; + R->selection_type = Sel_CompoundText; #else - R->h->selection_type = 0; + R->selection_type = 0; #endif if (rxvt_selection_request_other(aR_ #ifdef MULTICHAR_SET - R->h->xa[XA_COMPOUND_TEXT], + R->xa[XA_COMPOUND_TEXT], #else XA_STRING, #endif @@ -2589,7 +2587,7 @@ rxvt_selection_request(pR_ Time tm, int x, int y) return; } } - R->h->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ + R->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); } @@ -2603,17 +2601,17 @@ rxvt_selection_request_other(pR_ Atom target, int selnum) char *debug_xa_names[] = { "PRIMARY", "SECONDARY", "CLIPBOARD" }; #endif - R->h->selection_type |= selnum; + R->selection_type |= selnum; if (selnum == Sel_Primary) sel = XA_PRIMARY; else if (selnum == Sel_Secondary) sel = XA_SECONDARY; else - sel = R->h->xa[XA_CLIPBOARD]; + sel = R->xa[XA_CLIPBOARD]; if (XGetSelectionOwner(R->Xdisplay, sel) != None) { D_SELECT((stderr, "rxvt_selection_request_other: pasting %s", debug_xa_names[selnum])); - XConvertSelection(R->Xdisplay, sel, target, R->h->xa[XA_VT_SELECTION], - R->TermWin.vt, R->h->selection_request_time); + XConvertSelection(R->Xdisplay, sel, target, R->xa[XA_VT_SELECTION], + R->TermWin.vt, R->selection_request_time); return 1; } return 0; @@ -2630,7 +2628,7 @@ rxvt_selection_clear(pR) { D_SELECT((stderr, "rxvt_selection_clear()")); - R->h->want_refresh = 1; + R->want_refresh = 1; if (R->selection.text) free(R->selection.text); R->selection.text = NULL; @@ -2743,7 +2741,7 @@ rxvt_selection_make(pR_ Time tm) rxvt_print_error("can't get primary selection"); XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, R->selection.text, (int)R->selection.len); - R->h->selection_time = tm; + R->selection_time = tm; D_SELECT((stderr, "rxvt_selection_make(): R->selection.len=%d", R->selection.len)); } @@ -2779,7 +2777,7 @@ rxvt_selection_click(pR_ int clicks, int x, int y) void rxvt_selection_start_colrow(pR_ int col, int row) { - R->h->want_refresh = 1; + 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); @@ -2792,7 +2790,7 @@ rxvt_selection_start_colrow(pR_ int col, int row) R->selection.beg.col = R->selection.end.col = R->selection.mark.col; } R->selection.op = SELECTION_INIT; - R->selection.screen = R->h->current_screen; + R->selection.screen = R->current_screen; } /* ------------------------------------------------------------------------- */ @@ -2803,7 +2801,7 @@ 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->h->rs[Rs_cutchars], (x)) != NULL)) + (((x) == ' ' || (x) == '\t') ? 2 : (STRCHR(R->rs[Rs_cutchars], (x)) != NULL)) #ifdef MULTICHAR_SET # define DELIMIT_REND(x) (((x) & RS_multiMask) ? 1 : 0) #else @@ -2919,7 +2917,7 @@ rxvt_selection_extend(pR_ int x, int y, int flag) R->selection.beg.row = R->selection.end.row = 0; R->selection.beg.col = R->selection.end.col = 0; R->selection.clicks = 4; - R->h->want_refresh = 1; + R->want_refresh = 1; D_SELECT((stderr, "rxvt_selection_extend() R->selection.clicks = 4")); return; } @@ -2950,7 +2948,7 @@ rxvt_selection_extend_colrow(pR_ int32_t col, int32_t row, int button3, int butt 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)); - R->h->want_refresh = 1; + R->want_refresh = 1; switch (R->selection.op) { case SELECTION_INIT: CLEAR_SELECTION(R); @@ -2995,8 +2993,8 @@ rxvt_selection_extend_colrow(pR_ int32_t col, int32_t row, int button3, int butt */ if (R->selection_style == OLD_SELECT) { if (R->selection.clicks == 1 || button3) { - if (R->h->hate_those_clicks) { - R->h->hate_those_clicks = 0; + 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; @@ -3021,12 +3019,12 @@ rxvt_selection_extend_colrow(pR_ int32_t col, int32_t row, int button3, int butt &(R->selection.beg)); rxvt_selection_delimit_word(aR_ DN, &(R->selection.mark), &(R->selection.end)); - R->h->hate_those_clicks = 1; + 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->h->hate_those_clicks = 1; + R->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)); return; @@ -3237,28 +3235,28 @@ rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) ev.target = rq->target; ev.time = rq->time; - if (rq->target == R->h->xa[XA_TARGETS]) { - target_list[0] = (Atom32) R->h->xa[XA_TARGETS]; + if (rq->target == R->xa[XA_TARGETS]) { + target_list[0] = (Atom32) R->xa[XA_TARGETS]; target_list[1] = (Atom32) XA_STRING; - target_list[2] = (Atom32) R->h->xa[XA_TEXT]; + target_list[2] = (Atom32) R->xa[XA_TEXT]; #ifdef USE_XIM - target_list[3] = (Atom32) R->h->xa[XA_COMPOUND_TEXT]; + target_list[3] = (Atom32) R->xa[XA_COMPOUND_TEXT]; #endif XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, (8 * sizeof(target_list[0])), PropModeReplace, (unsigned char *)target_list, (sizeof(target_list) / sizeof(target_list[0]))); ev.property = rq->property; - } else if (rq->target == R->h->xa[XA_MULTIPLE]) { + } else if (rq->target == R->xa[XA_MULTIPLE]) { /* TODO: Handle MULTIPLE */ - } else if (rq->target == R->h->xa[XA_TIMESTAMP] && R->selection.text) { + } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, (8 * sizeof(Time)), PropModeReplace, - (unsigned char *)&R->h->selection_time, 1); + (unsigned char *)&R->selection_time, 1); ev.property = rq->property; } else if (rq->target == XA_STRING - || rq->target == R->h->xa[XA_COMPOUND_TEXT] - || rq->target == R->h->xa[XA_TEXT]) { + || rq->target == R->xa[XA_COMPOUND_TEXT] + || rq->target == R->xa[XA_TEXT]) { #ifdef USE_XIM short freect = 0; #endif @@ -3266,8 +3264,8 @@ rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) #ifdef USE_XIM if (rq->target != XA_STRING) { - target = R->h->xa[XA_COMPOUND_TEXT]; - style = (rq->target == R->h->xa[XA_COMPOUND_TEXT]) + target = R->xa[XA_COMPOUND_TEXT]; + style = (rq->target == R->xa[XA_COMPOUND_TEXT]) ? XCompoundTextStyle : XStdICCTextStyle; } else #endif @@ -3352,17 +3350,17 @@ rxvt_debug_colors(void) }; fprintf(stderr, "Color ( "); - if (R->h->rstyle & RS_RVid) + if (R->rstyle & RS_RVid) fprintf(stderr, "rvid "); - if (R->h->rstyle & RS_Bold) + if (R->rstyle & RS_Bold) fprintf(stderr, "bold "); - if (R->h->rstyle & RS_Blink) + if (R->rstyle & RS_Blink) fprintf(stderr, "blink "); - if (R->h->rstyle & RS_Uline) + if (R->rstyle & RS_Uline) fprintf(stderr, "uline "); fprintf(stderr, "): "); - color = GET_FGCOLOR(R->h->rstyle); + color = GET_FGCOLOR(R->rstyle); #ifndef NO_BRIGHTCOLOR if (color >= minBrightCOLOR && color <= maxBrightCOLOR) { color -= (minBrightCOLOR - minCOLOR); @@ -3371,7 +3369,7 @@ rxvt_debug_colors(void) #endif fprintf(stderr, "%s on ", name[color]); - color = GET_BGCOLOR(R->h->rstyle); + color = GET_BGCOLOR(R->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 f900bf4a..2cf95395 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.2 2003-11-24 17:31:28 pcg Exp $ + * $Id: scrollbar-next.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1998 Alfredo K. Kojima @@ -125,13 +125,13 @@ rxvt_renderPixmap(pR_ const char *const *data, int width, int height) for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if ((a = data[y][x]) == ' ' || a == 'w') - pointcolour = R->h->whiteGC; + pointcolour = R->whiteGC; else if (a == '.' || a == 'l') - pointcolour = R->h->grayGC; + pointcolour = R->grayGC; else if (a == '%' || a == 'd') - pointcolour = R->h->darkGC; + pointcolour = R->darkGC; else /* if (a == '#' || a == 'b' || a) */ - pointcolour = R->h->blackGC; + pointcolour = R->blackGC; XDrawPoint(R->Xdisplay, d, pointcolour, x, y); } } @@ -150,11 +150,11 @@ rxvt_init_scrollbar_stuff(pR) gcvalue.graphics_exposures = False; gcvalue.foreground = R->PixColors[Color_Black]; - R->h->blackGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + R->blackGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); gcvalue.foreground = R->PixColors[Color_White]; - R->h->whiteGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + R->whiteGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); xcol.red = 0xaeba; @@ -163,7 +163,7 @@ rxvt_init_scrollbar_stuff(pR) if (!rxvt_rXAllocColor(aR_ &xcol, "light gray")) xcol.pixel = R->PixColors[Color_AntiqueWhite]; light = gcvalue.foreground = xcol.pixel; - R->h->grayGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + R->grayGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); xcol.red = 0x51aa; @@ -172,7 +172,7 @@ rxvt_init_scrollbar_stuff(pR) if (!rxvt_rXAllocColor(aR_ &xcol, "dark gray")) xcol.pixel = R->PixColors[Color_Grey25]; dark = gcvalue.foreground = xcol.pixel; - R->h->darkGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + R->darkGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); stipple = XCreateBitmapFromData(R->Xdisplay, R->scrollBar.win, @@ -186,20 +186,20 @@ rxvt_init_scrollbar_stuff(pR) /* XSetWindowBackground(R->Xdisplay, R->scrollBar.win, R->PixColors[Color_Red]); */ - R->h->stippleGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + R->stippleGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground | GCBackground | GCStipple | GCFillStyle | GCGraphicsExposures, &gcvalue); - R->h->dimple = rxvt_renderPixmap(aR_ SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH, + R->dimple = rxvt_renderPixmap(aR_ SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT); - R->h->upArrow = rxvt_renderPixmap(aR_ SCROLLER_ARROW_UP, ARROW_WIDTH, + R->upArrow = rxvt_renderPixmap(aR_ SCROLLER_ARROW_UP, ARROW_WIDTH, ARROW_HEIGHT); - R->h->downArrow = rxvt_renderPixmap(aR_ SCROLLER_ARROW_DOWN, ARROW_WIDTH, + R->downArrow = rxvt_renderPixmap(aR_ SCROLLER_ARROW_DOWN, ARROW_WIDTH, ARROW_HEIGHT); - R->h->upArrowHi = rxvt_renderPixmap(aR_ HI_SCROLLER_ARROW_UP, ARROW_WIDTH, + R->upArrowHi = rxvt_renderPixmap(aR_ HI_SCROLLER_ARROW_UP, ARROW_WIDTH, ARROW_HEIGHT); - R->h->downArrowHi = rxvt_renderPixmap(aR_ HI_SCROLLER_ARROW_DOWN, + R->downArrowHi = rxvt_renderPixmap(aR_ HI_SCROLLER_ARROW_DOWN, ARROW_WIDTH, ARROW_HEIGHT); } @@ -213,15 +213,15 @@ rxvt_drawBevel(pR_ Drawable d, int x1, int y1, int w, int h) x2 = x1 + w - 1; /* right point */ y2 = y1 + h - 1; /* bottom point */ /* white top and left */ - XDrawLine(R->Xdisplay, d, R->h->whiteGC, x1, y1, x2, y1); - XDrawLine(R->Xdisplay, d, R->h->whiteGC, x1, y1, x1, y2); + XDrawLine(R->Xdisplay, d, R->whiteGC, x1, y1, x2, y1); + XDrawLine(R->Xdisplay, d, R->whiteGC, x1, y1, x1, y2); /* black bottom and right */ - XDrawLine(R->Xdisplay, d, R->h->blackGC, x1, y2, x2, y2); - XDrawLine(R->Xdisplay, d, R->h->blackGC, x2, y1, x2, y2); + XDrawLine(R->Xdisplay, d, R->blackGC, x1, y2, x2, y2); + XDrawLine(R->Xdisplay, d, R->blackGC, x2, y1, x2, y2); /* dark inside bottom and right */ x1++, y1++, x2--, y2--; /* move in one point */ - XDrawLine(R->Xdisplay, d, R->h->darkGC, x1, y2, x2, y2); - XDrawLine(R->Xdisplay, d, R->h->darkGC, x2, y1, x2, y2); + XDrawLine(R->Xdisplay, d, R->darkGC, x1, y2, x2, y2); + XDrawLine(R->Xdisplay, d, R->darkGC, x2, y1, x2, y2); } /* EXTPROTO */ @@ -237,27 +237,27 @@ rxvt_scrollbar_show_next(pR_ int update, int last_top, int last_bot, int scrollb } if (R->TermWin.nscrolled == 0 || !update) { - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->grayGC, 0, 0, + XFillRectangle(R->Xdisplay, R->scrollBar.win, R->grayGC, 0, 0, SB_WIDTH_NEXT + 1, height); - XDrawRectangle(R->Xdisplay, R->scrollBar.win, R->h->blackGC, 0, + XDrawRectangle(R->Xdisplay, R->scrollBar.win, R->blackGC, 0, -SB_BORDER_WIDTH, SB_WIDTH_NEXT, height + SB_BORDER_WIDTH); - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->stippleGC, + XFillRectangle(R->Xdisplay, R->scrollBar.win, R->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->h->stippleGC, + XFillRectangle(R->Xdisplay, R->scrollBar.win, R->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->h->stippleGC, + 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->h->grayGC, + XFillRectangle(R->Xdisplay, R->scrollBar.win, R->grayGC, SB_LEFT_PADDING, R->scrollBar.top + SB_PADDING, SB_BUTTON_WIDTH, scrollbar_len); - XCopyArea(R->Xdisplay, R->h->dimple, R->scrollBar.win, R->h->whiteGC, 0, 0, + XCopyArea(R->Xdisplay, R->dimple, R->scrollBar.win, R->whiteGC, 0, 0, SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT, (SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2, R->scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT + @@ -273,13 +273,13 @@ rxvt_scrollbar_show_next(pR_ int update, int last_top, int last_bot, int scrollb height - SB_BUTTON_SINGLE_HEIGHT, SB_BUTTON_WIDTH, SB_BUTTON_HEIGHT); - s = (scrollbar_isUp()) ? R->h->upArrowHi : R->h->upArrow; - XCopyArea(R->Xdisplay, s, R->scrollBar.win, R->h->whiteGC, 0, 0, + s = (scrollbar_isUp()) ? R->upArrowHi : R->upArrow; + XCopyArea(R->Xdisplay, s, R->scrollBar.win, R->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->h->downArrowHi : R->h->downArrow; - XCopyArea(R->Xdisplay, s, R->scrollBar.win, R->h->whiteGC, 0, 0, + s = (scrollbar_isDn()) ? R->downArrowHi : R->downArrow; + XCopyArea(R->Xdisplay, s, R->scrollBar.win, R->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 4f1ba62e..88bc9ac5 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.2 2003-11-24 17:31:28 pcg Exp $ + * $Id: scrollbar-rxvt.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1999-2001 Geoff Wing @@ -41,15 +41,15 @@ rxvt_Draw_button(pR_ int x, int y, int state, int dirn) sz2 = sz / 2; switch (state) { case +1: - top = R->h->topShadowGC; - bot = R->h->botShadowGC; + top = R->topShadowGC; + bot = R->botShadowGC; break; case -1: - top = R->h->botShadowGC; - bot = R->h->topShadowGC; + top = R->botShadowGC; + bot = R->topShadowGC; break; default: - top = bot = R->h->scrollbarGC; + top = bot = R->scrollbarGC; break; } @@ -64,7 +64,7 @@ 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->h->scrollbarGC, + XFillPolygon(R->Xdisplay, R->scrollBar.win, R->scrollbarGC, pt, 3, Convex, CoordModeOrigin); /* draw base */ @@ -154,24 +154,24 @@ rxvt_scrollbar_show_rxvt(pR_ int update __attribute__((unused)), int last_top, i else xofs = sbshadow ? sbwidth : sbwidth - 1; - XDrawLine(R->Xdisplay, R->scrollBar.win, R->h->botShadowGC, + XDrawLine(R->Xdisplay, R->scrollBar.win, R->botShadowGC, xofs, 0, xofs, R->scrollBar.end + sbwidth); } #endif - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->scrollbarGC, + XFillRectangle(R->Xdisplay, R->scrollBar.win, R->scrollbarGC, sbshadow, R->scrollBar.top, sbwidth, scrollbar_len); if (sbshadow) /* trough shadow */ rxvt_Draw_Shadow(R->Xdisplay, R->scrollBar.win, - R->h->botShadowGC, R->h->topShadowGC, + R->botShadowGC, R->topShadowGC, 0, 0, sbwidth + 2 * sbshadow, /* scrollbar_TotalWidth() */ R->scrollBar.end + (sbwidth + 1) + sbshadow); /* shadow for scrollbar slider */ rxvt_Draw_Shadow(R->Xdisplay, R->scrollBar.win, - R->h->topShadowGC, R->h->botShadowGC, + R->topShadowGC, R->botShadowGC, sbshadow, R->scrollBar.top, sbwidth, scrollbar_len); diff --git a/src/scrollbar-xterm.C b/src/scrollbar-xterm.C index 9dffcba1..ddf7ecd0 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.2 2003-11-24 17:31:28 pcg Exp $ + * $Id: scrollbar-xterm.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1999-2001 Geoff Wing @@ -54,11 +54,11 @@ rxvt_scrollbar_show_xterm(pR_ int update __attribute__((unused)), int last_top, gcvalue.foreground = R->PixColors[Color_fg]; gcvalue.background = R->PixColors[Color_bg]; - R->h->xscrollbarGC = XCreateGC(R->Xdisplay, R->scrollBar.win, + R->xscrollbarGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground | GCBackground | GCFillStyle | GCStipple, &gcvalue); gcvalue.foreground = R->PixColors[Color_border]; - R->h->ShadowGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground, + R->ShadowGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground, &gcvalue); } /* instead of XClearWindow (R->Xdisplay, R->scrollBar.win); */ @@ -74,10 +74,10 @@ rxvt_scrollbar_show_xterm(pR_ int update __attribute__((unused)), int last_top, sbwidth + 1, (last_bot - R->scrollBar.bot), False); /* scrollbar slider */ - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->xscrollbarGC, + XFillRectangle(R->Xdisplay, R->scrollBar.win, R->xscrollbarGC, xsb + 1, R->scrollBar.top, sbwidth, scrollbar_len); - /*XDrawLine(R->Xdisplay, R->scrollBar.win, R->h->ShadowGC, + /*XDrawLine(R->Xdisplay, R->scrollBar.win, R->ShadowGC, xsb ? 0 : sbwidth, R->scrollBar.beg, xsb ? 0 : sbwidth, R->scrollBar.end);*/ return 1; diff --git a/src/scrollbar.C b/src/scrollbar.C index ed3afe26..d3a916d6 100644 --- a/src/scrollbar.C +++ b/src/scrollbar.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: scrollbar.c *----------------------------------------------------------------------* - * $Id: scrollbar.C,v 1.2 2003-11-24 17:31:28 pcg Exp $ + * $Id: scrollbar.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1998 Alfredo K. Kojima @@ -98,7 +98,7 @@ rxvt_Resize_scrollBar(pR) /* create the scrollbar window */ R->scrollBar.win = XCreateSimpleWindow(R->Xdisplay, R->TermWin.parent[0], - R->h->window_sb_x, 0, + R->window_sb_x, 0, scrollbar_TotalWidth(), R->szHint.height, 0, @@ -107,7 +107,7 @@ rxvt_Resize_scrollBar(pR) #ifdef DEBUG_X XStoreName(R->Xdisplay, R->scrollBar.win, "scrollbar"); #endif - XDefineCursor(R->Xdisplay, R->scrollBar.win, R->h->pointer_leftptr); + XDefineCursor(R->Xdisplay, R->scrollBar.win, R->pointer_leftptr); XSelectInput(R->Xdisplay, R->scrollBar.win, (ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask @@ -141,22 +141,22 @@ rxvt_scrollbar_show(pR_ int update) adj = (((bot - top) * scrollbar_size()) % len) > 0 ? 1 : 0; R->scrollBar.top = (R->scrollBar.beg + (top * scrollbar_size()) / len); - R->h->scrollbar_len = ((bot - top) * scrollbar_size()) / len + + R->scrollbar_len = ((bot - top) * scrollbar_size()) / len + scrollbar_minheight() + adj; - R->scrollBar.bot = (R->scrollBar.top + R->h->scrollbar_len); + R->scrollBar.bot = (R->scrollBar.top + R->scrollbar_len); /* no change */ - if (R->scrollBar.top == R->h->last_top - && R->scrollBar.bot == R->h->last_bot - && (R->scrollBar.state == R->h->last_state || !scrollbar_isUpDn())) + if (R->scrollBar.top == R->last_top + && R->scrollBar.bot == R->last_bot + && (R->scrollBar.state == R->last_state || !scrollbar_isUpDn())) return 0; } - ret = R->scrollBar.update(aR_ update, R->h->last_top, R->h->last_bot, - R->h->scrollbar_len); + ret = R->scrollBar.update(aR_ update, R->last_top, R->last_bot, + R->scrollbar_len); - R->h->last_top = R->scrollBar.top; - R->h->last_bot = R->scrollBar.bot; - R->h->last_state = R->scrollBar.state; + R->last_top = R->scrollBar.top; + R->last_bot = R->scrollBar.bot; + R->last_state = R->scrollBar.state; #endif return ret; @@ -211,12 +211,12 @@ rxvt_setup_scrollbar(pR_ const char *scrollalign, const char *scrollstyle, const R->scrollBar.style = style; R->scrollBar.width = width; - /* R->h->scrollbar_align = R_SB_ALIGN_CENTRE; */ + /* R->scrollbar_align = R_SB_ALIGN_CENTRE; */ if (scrollalign) { if (STRNCASECMP(scrollalign, "top", 3) == 0) - R->h->scrollbar_align = R_SB_ALIGN_TOP; + R->scrollbar_align = R_SB_ALIGN_TOP; else if (STRNCASECMP(scrollalign, "bottom", 6) == 0) - R->h->scrollbar_align = R_SB_ALIGN_BOTTOM; + R->scrollbar_align = R_SB_ALIGN_BOTTOM; } #endif } diff --git a/src/simplevec.h b/src/simplevec.h index 1c924190..95ee5379 100644 --- a/src/simplevec.h +++ b/src/simplevec.h @@ -174,6 +174,12 @@ public: *end() = t; ++_last; } + void push_back (T &t) + { + reserve (_last+1); + *end() = t; + ++_last; + } void pop_back () { //ministl_assert (size() > 0); diff --git a/src/xdefaults.C b/src/xdefaults.C index 3f0ed340..fd31a76c 100644 --- a/src/xdefaults.C +++ b/src/xdefaults.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: xdefaults.c *----------------------------------------------------------------------* - * $Id: xdefaults.C,v 1.2 2003-11-24 17:31:28 pcg Exp $ + * $Id: xdefaults.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1994 Robert Nation @@ -502,7 +502,7 @@ rxvt_get_options(pR_ int argc, const char *const *argv) #ifdef DEBUG_RESOURCES fprintf(stderr, "\"%s\"\n", str); #endif - R->h->rs[optList[entry].doff] = str; + R->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 @@ -524,7 +524,7 @@ rxvt_get_options(pR_ int argc, const char *const *argv) R->Options &= ~(optList[entry].flag); if (optList[entry].doff != -1) - R->h->rs[optList[entry].doff] = flag; + R->rs[optList[entry].doff] = flag; } } else #ifdef KEYSYM_RESOURCE @@ -626,7 +626,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->h->Keysym_map[sym] != NULL) /* already set ? */ + if (R->Keysym_map[sym] != NULL) /* already set ? */ return -1; if (newarg == NULL) { @@ -642,7 +642,7 @@ rxvt_parse_keysym(pR_ const char *str, const char *arg) key_string[0] = n; STRNCPY(key_string + 1, newarg, n); - R->h->Keysym_map[sym] = (unsigned char *)key_string; + R->Keysym_map[sym] = (unsigned char *)key_string; return 1; } @@ -689,13 +689,13 @@ rxvt_get_xdefaults(pR_ FILE *stream, const char *name) str += (n + 1); rxvt_Str_trim(str); n = STRLEN(str); - if (n && R->h->rs[optList[entry].doff] == NULL) { + if (n && R->rs[optList[entry].doff] == NULL) { /* not already set */ int s; char *p = (char *)rxvt_malloc((n + 1) * sizeof(char)); STRCPY(p, str); - R->h->rs[optList[entry].doff] = p; + R->rs[optList[entry].doff] = p; if (optList_isBool(entry)) { s = STRCASECMP(str, "TRUE") == 0 || STRCASECMP(str, "YES") == 0 @@ -736,11 +736,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->h->locale != NULL) { /* XXX: must limit length of string */ + if (R->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->h->locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ + R->locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ } { @@ -824,7 +824,7 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char char *p, *p0; const char *kw = optList[entry].kw; - if (kw == NULL || R->h->rs[optList[entry].doff] != NULL) + if (kw == NULL || R->rs[optList[entry].doff] != NULL) continue; /* previously set */ p = XGetDefault(display, name, kw); @@ -837,7 +837,7 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char if (p == NULL && p0) p = p0; if (p) { - R->h->rs[optList[entry].doff] = p; + R->rs[optList[entry].doff] = p; if (optList_isBool(entry)) { s = STRCASECMP(p, "TRUE") == 0 @@ -960,23 +960,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->h->rs[Rs_multichar_encoding]); + rxvt_set_multichar_encoding(aR_ R->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->h->rs[Rs_greek_keyboard]) { - if (!STRCMP(R->h->rs[Rs_greek_keyboard], "iso")) + if (R->rs[Rs_greek_keyboard]) { + if (!STRCMP(R->rs[Rs_greek_keyboard], "iso")) greek_setmode(GREEK_ELOT928); /* former -grk9 */ - else if (!STRCMP(R->h->rs[Rs_greek_keyboard], "ibm")) + else if (!STRCMP(R->rs[Rs_greek_keyboard], "ibm")) greek_setmode(GREEK_IBM437); /* former -grk4 */ } { KeySym sym; - if (R->h->rs[Rs_greektoggle_key] - && ((sym = XStringToKeysym(R->h->rs[Rs_greektoggle_key])) != 0)) - R->h->ks_greekmodeswith = sym; + if (R->rs[Rs_greektoggle_key] + && ((sym = XStringToKeysym(R->rs[Rs_greektoggle_key])) != 0)) + R->ks_greekmodeswith = sym; } #endif /* GREEK_SUPPORT */ @@ -984,12 +984,12 @@ rxvt_extract_resources(pR_ Display *display __attribute__((unused)), const char { KeySym sym; - if (R->h->rs[Rs_bigfont_key] - && ((sym = XStringToKeysym(R->h->rs[Rs_bigfont_key])) != 0)) - R->h->ks_bigfont = sym; - if (R->h->rs[Rs_smallfont_key] - && ((sym = XStringToKeysym(R->h->rs[Rs_smallfont_key])) != 0)) - R->h->ks_smallfont = 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; } #endif } diff --git a/src/xpm.C b/src/xpm.C index cd91d40a..b2931bf5 100644 --- a/src/xpm.C +++ b/src/xpm.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: xpm.c *----------------------------------------------------------------------* - * $Id: xpm.C,v 1.2 2003-11-24 17:31:28 pcg Exp $ + * $Id: xpm.C,v 1.3 2003-11-25 11:52:42 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1997 Carsten Haitzler @@ -58,7 +58,7 @@ rxvt_scale_pixmap(pR_ const char *geom) unsigned int w = 0, h = 0; unsigned int n; char *p, *str; - bgPixmap_t *bgpixmap = &(R->h->bgPixmap); + bgPixmap_t *bgpixmap = &(R->bgPixmap); #define MAXLEN_GEOM sizeof("[1000x1000+1000+1000]") @@ -155,9 +155,9 @@ rxvt_resize_pixmap(pR) if (R->TermWin.pixmap != None) XFreePixmap(R->Xdisplay, R->TermWin.pixmap); - if (R->h->bgPixmap.pixmap == None) { /* So be it: I'm not using pixmaps */ + if (R->bgPixmap.pixmap == None) { /* So be it: I'm not using pixmaps */ R->TermWin.pixmap = None; - if (!(R->Options & Opt_transparent) || R->h->am_transparent == 0) + if (!(R->Options & Opt_transparent) || R->am_transparent == 0) XSetWindowBackground(R->Xdisplay, R->TermWin.vt, R->PixColors[Color_bg]); return; @@ -166,11 +166,11 @@ rxvt_resize_pixmap(pR) gcvalue.foreground = R->PixColors[Color_bg]; gc = XCreateGC(R->Xdisplay, R->TermWin.vt, GCForeground, &gcvalue); - if (R->h->bgPixmap.pixmap != None) { /* we have a specified pixmap */ - unsigned int w = R->h->bgPixmap.w, h = R->h->bgPixmap.h, - x = R->h->bgPixmap.x, y = R->h->bgPixmap.y; - unsigned int xpmh = R->h->xpmAttr.height, - xpmw = R->h->xpmAttr.width; + 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; /* * don't zoom pixmap too much nor expand really small pixmaps @@ -186,7 +186,7 @@ rxvt_resize_pixmap(pR) R->TermWin.pixmap = XCreatePixmap(R->Xdisplay, R->TermWin.vt, xpmw, xpmh, (unsigned int)XDEPTH); - XCopyArea(R->Xdisplay, R->h->bgPixmap.pixmap, R->TermWin.pixmap, gc, + XCopyArea(R->Xdisplay, R->bgPixmap.pixmap, R->TermWin.pixmap, gc, 0, 0, xpmw, xpmh, 0, 0); } else { float incr, p; @@ -209,7 +209,7 @@ rxvt_resize_pixmap(pR) if (p >= xpmw) p = 0; /* copy one column from the original pixmap to the tmp pixmap */ - XCopyArea(R->Xdisplay, R->h->bgPixmap.pixmap, tmp, gc, + XCopyArea(R->Xdisplay, R->bgPixmap.pixmap, tmp, gc, (int)p, 0, 1, xpmh, (int)x, 0); } @@ -236,7 +236,7 @@ rxvt_resize_pixmap(pR) } XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.vt, R->TermWin.pixmap); XFreeGC(R->Xdisplay, gc); - R->h->am_transparent = 0; + R->am_transparent = 0; XClearWindow(R->Xdisplay, R->TermWin.vt); @@ -316,9 +316,9 @@ rxvt_set_bgPixmap(pR_ const char *file) assert(file != NULL); - if (R->h->bgPixmap.pixmap != None) { - XFreePixmap(R->Xdisplay, R->h->bgPixmap.pixmap); - R->h->bgPixmap.pixmap = None; + if (R->bgPixmap.pixmap != None) { + XFreePixmap(R->Xdisplay, R->bgPixmap.pixmap); + R->bgPixmap.pixmap = None; } XSetWindowBackground(R->Xdisplay, R->TermWin.vt, R->PixColors[Color_bg]); @@ -330,19 +330,19 @@ rxvt_set_bgPixmap(pR_ const char *file) */ /* XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &attr); */ - R->h->xpmAttr.closeness = 30000; - R->h->xpmAttr.colormap = XCMAP; - R->h->xpmAttr.visual = XVISUAL; - R->h->xpmAttr.depth = XDEPTH; - R->h->xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual | + R->xpmAttr.closeness = 30000; + R->xpmAttr.colormap = XCMAP; + R->xpmAttr.visual = XVISUAL; + R->xpmAttr.depth = XDEPTH; + R->xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual | XpmDepth | XpmSize | XpmReturnPixels); /* search environment variables here too */ - f = (char *)rxvt_File_find(file, ".xpm", R->h->rs[Rs_path]); + f = (char *)rxvt_File_find(file, ".xpm", R->rs[Rs_path]); if (f == NULL || XpmReadFileToPixmap(R->Xdisplay, Xroot, f, - &R->h->bgPixmap.pixmap, NULL, - &R->h->xpmAttr)) { + &R->bgPixmap.pixmap, NULL, + &R->xpmAttr)) { char *p; /* semi-colon delimited */ @@ -355,7 +355,7 @@ rxvt_set_bgPixmap(pR_ const char *file) free(f); } rxvt_resize_pixmap(aR); - return R->h->bgPixmap.pixmap; + return R->bgPixmap.pixmap; } #endif /* XPM_BACKGROUND */