--- rxvt-unicode/src/rxvt.h 2005/02/20 00:09:25 1.151 +++ rxvt-unicode/src/rxvt.h 2006/01/02 15:10:18 1.179 @@ -23,6 +23,8 @@ #if ENABLE_FRILLS # define ENABLE_XEMBED 1 +# define ENABLE_EWMH 1 +# define CURSOR_BLINK 1 #endif /* @@ -72,15 +74,6 @@ # define STDERR_FILENO 2 #endif -#if defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT) -# if defined(PTYS_ARE_GETPT) || defined(PTYS_ARE_PTMX) -# define NO_SETOWNER_TTYDEV 1 -# endif -#endif -#if defined(__CYGWIN32__) || defined(PTYS_ARE_OPENPTY) -# define NO_SETOWNER_TTYDEV 1 -#endif - /* ***************************************************************************** * PROTOTYPES @@ -118,6 +111,7 @@ char * rxvt_File_find (const char *file, const char *ext, const char *path); void rxvt_Draw_Shadow (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int h); void rxvt_Draw_Triangle (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int type); +void rxvt_usleep (int usecs); /* ***************************************************************************** @@ -137,7 +131,7 @@ /* If we're using either the rxvt scrollbar or menu bars, keep the * scrollColor resource. */ -#if defined(RXVT_SCROLLBAR) || defined(MENUBAR) || defined(PLAIN_SCROLLBAR) +#if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(MENUBAR) || defined(PLAIN_SCROLLBAR) # define KEEP_SCROLLCOLOR 1 #else # undef KEEP_SCROLLCOLOR @@ -161,18 +155,6 @@ unsigned int button; /* detail */ }; -#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))) - #if ENABLE_FRILLS typedef struct _mwmhints { CARD32 flags; @@ -267,10 +249,10 @@ #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_PLAIN 4 +#define R_SB_RXVT 8 #define SB_WIDTH_NEXT 19 #define SB_WIDTH_XTERM 15 @@ -362,9 +344,9 @@ /* flags for rxvt_scr_gotorc () */ enum { - C_RELATIVE = 1 , /* col movement is relative */ - R_RELATIVE = 2, /* row movement is relative */ - RELATIVE = 1 | 2, + C_RELATIVE = 1, /* col movement is relative */ + R_RELATIVE = 2, /* row movement is relative */ + RELATIVE = C_RELATIVE | R_RELATIVE, }; /* modes for rxvt_scr_insdel_chars (), rxvt_scr_insdel_lines () */ @@ -387,21 +369,24 @@ SECONDARY, }; -#define RS_None 0 /* Normal */ +#define RS_None 0 -#define RS_fgMask 0x0000007fUL /* 128 colors */ -#define RS_bgMask 0x00003f80UL /* 128 colors */ +#define RS_fgMask 0x0000007fUL // 128 colors +#define RS_bgMask 0x00003f80UL // 128 colors // font styles #define RS_Bold 0x00004000UL // value 1 #define RS_Italic 0x00008000UL // value 2 // fake styles -#define RS_Blink 0x00010000UL /* blink */ -#define RS_RVid 0x00020000UL /* reverse video */ -#define RS_Uline 0x00040000UL /* underline */ - -// 5 bits still to go +#define RS_Blink 0x00010000UL // blink +#define RS_RVid 0x00020000UL // reverse video +#define RS_Uline 0x00040000UL // underline + +// 5 custom bits for extensions +#define RS_customCount 32 +#define RS_customMask 0x00f80000UL +#define RS_customShift 19 // other flags #define RS_Careful 0x80000000UL /* be careful when drawing these */ @@ -473,22 +458,24 @@ XTerm_restoreFG = 39, // change default fg color XTerm_restoreBG = 49, // change default bg color XTerm_dumpscreen = 55, // dump scrollback and all of screen - XTerm_locale = 701, // change locale - XTerm_Menu = 703, // set menu item - XTerm_Color_IT = 704, // change actual 'Italic' colour - XTerm_Color_tint = 705, // change actual tint colour + + URxvt_locale = 701, // change locale + URxvt_Menu = 703, // set menu item + URxvt_Color_IT = 704, // change actual 'Italic' colour + URxvt_Color_tint = 705, // change actual tint colour URxvt_font = 710, URxvt_boldFont = 711, URxvt_italicFont = 712, URxvt_boldItalicFont = 713, + + URxvt_view_up = 720, + URxvt_view_down = 721, }; /* Words starting with `Color_' are colours. Others are counts */ /* - * The following comment is mostly obsolete since pixcolor_set was expanded: - * We're currently upto 29 colours. Only 3 more available. The - * PixColor and rendition colour usage should probably be decoupled + * The PixColor and rendition colour usage should probably be decoupled * on the unnecessary items, e.g. Color_pointer, but won't bother * until we need to. Also, be aware of usage in pixcolor_set */ @@ -548,6 +535,9 @@ #if TINTING Color_tint, #endif +#if OFF_FOCUS_FADING + Color_fade, +#endif NRS_COLORS, /* */ #ifdef KEEP_SCROLLCOLOR Color_topShadow = NRS_COLORS, @@ -579,6 +569,7 @@ Rs_boldFont, Rs_italicFont, Rs_boldItalicFont, + Rs_intensityStyles, #endif Rs_name, Rs_title, @@ -635,11 +626,16 @@ Rs_transparent_all, #endif #if ENABLE_FRILLS + Rs_pty_fd, + Rs_hold, Rs_ext_bwidth, Rs_int_bwidth, Rs_borderLess, Rs_lineSpace, - Rs_pty_fd, + Rs_cursorUnderline, +#endif +#if CURSOR_BLINK + Rs_cursorBlink, #endif #if ENABLE_XEMBED Rs_embed, @@ -649,7 +645,6 @@ Rs_answerbackstring, Rs_tripleclickwords, Rs_insecure, - Rs_cursorBlink, Rs_pointerBlank, Rs_pointerBlankDelay, Rs_imLocale, @@ -682,10 +677,13 @@ XA_WM_DELETE_WINDOW, XA_CLIPBOARD, #if ENABLE_FRILLS - XA_NET_WM_PID, XA_MOTIF_WM_HINTS, +#endif +#if ENABLE_EWMH + XA_NET_WM_PID, XA_NET_WM_NAME, XA_NET_WM_ICON_NAME, + XA_NET_WM_PING, #endif #if USE_XIM XA_WM_LOCALE_NAME, @@ -746,8 +744,8 @@ // do not change these constants lightly, there are many interdependencies #define IMBUFSIZ 128 // input modifier buffer sizes #define KBUFSZ 512 // size of keyboard mapping buffer -#define CBUFSIZ 4096 // size of command buffer -#define UBUFSIZ 4096 // character buffer +#define CBUFSIZ 2048 // size of command buffer +#define UBUFSIZ 2048 // character buffer #ifndef PATH_MAX # define PATH_MAX 16384 @@ -806,36 +804,25 @@ /* convert pixel dimensions to row/column values. Everything as int32_t */ #define Pixel2Col(x) Pixel2Width((int32_t)(x)) #define Pixel2Row(y) Pixel2Height((int32_t)(y)) -#define Pixel2Width(x) ((int32_t)(x) / (int32_t)TermWin.fwidth) -#define Pixel2Height(y) ((int32_t)(y) / (int32_t)TermWin.fheight) +#define Pixel2Width(x) ((int32_t)(x) / (int32_t)fwidth) +#define Pixel2Height(y) ((int32_t)(y) / (int32_t)fheight) #define Col2Pixel(col) ((int32_t)Width2Pixel(col)) #define Row2Pixel(row) ((int32_t)Height2Pixel(row)) -#define Width2Pixel(n) ((int32_t)(n) * (int32_t)TermWin.fwidth) -#define Height2Pixel(n) ((int32_t)(n) * (int32_t)TermWin.fheight) +#define Width2Pixel(n) ((int32_t)(n) * (int32_t)fwidth) +#define Height2Pixel(n) ((int32_t)(n) * (int32_t)fheight) + +#define TermWin_TotalWidth() ((int32_t)this->width) +#define TermWin_TotalHeight() ((int32_t)this->height) -#define TermWin_TotalWidth() ((int32_t)TermWin.width) -#define TermWin_TotalHeight() ((int32_t)TermWin.height) +// for m >= -n, ensure remainder lies between 0..n-1 +#define MOD(m,n) (((m) + (n)) % (n)) + +#define LINENO(n) MOD (term_start + int(n), total_rows) +#define ROW(n) row_buf [LINENO (n)] /* how to build & extract colors and attributes */ #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) \ - : (GET_BASEFG (x) + (minBrightCOLOR - minCOLOR))) -# 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) -#endif #define GET_FONT(x) (((x) & RS_fontMask) >> RS_fontShift) #define SET_FONT(x,fid) (((x) & ~RS_fontMask) | ((fid) << RS_fontShift)) @@ -858,9 +845,9 @@ #define ISSET_PIXCOLOR(x) (pixcolor_set[(x) / NPIXCLR_BITS] & (1 << ((x) % NPIXCLR_BITS))) #if ENABLE_STYLES -# define FONTSET(style) TermWin.fontset[GET_STYLE (style)] +# define FONTSET(style) fontset[GET_STYLE (style)] #else -# define FONTSET(style) TermWin.fontset[0] +# define FONTSET(style) fontset[0] #endif #ifdef HAVE_SCROLLBARS @@ -895,7 +882,7 @@ #if (MENUBAR_MAX > 1) /* rendition style flags */ -# define menuBar_height() (TermWin.fheight + SHADOW) +# define menuBar_height() (fheight + SHADOW) # define menuBar_TotalHeight() (menuBar_height() + SHADOW + menuBar_margin) # define isMenuBarWindow(w) ((w) == menuBar.win) #else @@ -952,6 +939,7 @@ extern class rxvt_failure_exception { } rxvt_failure_exception; typedef callback1 log_callback; +typedef callback1 getfd_callback; extern void rxvt_vlog (const char *fmt, va_list arg_ptr); extern void rxvt_log (const char *fmt, ...); @@ -1038,6 +1026,7 @@ struct rxvt_term : zero_initialized, rxvt_vars { log_callback *log_hook; // log error messages through this hook, if != 0 + getfd_callback *getfd_hook; // convert remote to local fd, if != 0 struct mbstate mbstate; // current input multibyte state @@ -1217,6 +1206,7 @@ text_t text, rend_t rend = OVERLAY_RSTYLE); void scr_overlay_set (int x, int y, const char *s); + void scr_overlay_set (int x, int y, const wchar_t *s); #endif vector allocated; // free these memory blocks with free() @@ -1251,7 +1241,7 @@ void commit_iso14755 (); int hex_keyval (XKeyEvent &ev); # if ISO_14755 - void iso14755_51 (unicode_t ch, rend_t r = DEFAULT_RSTYLE); + void iso14755_51 (unicode_t ch, rend_t r = DEFAULT_RSTYLE, int x = 0, int y = -1); void iso14755_54 (int x, int y); # endif #endif @@ -1266,10 +1256,6 @@ xevent_watcher rootwin_ev; #endif - - void sig_term (sig_watcher &w); sig_watcher sw_term, sw_int; - void sig_chld (sig_watcher &w); sig_watcher sw_chld; - void x_cb (XEvent &xev); xevent_watcher termwin_ev; xevent_watcher vt_ev; @@ -1319,6 +1305,7 @@ rxvt_term (); ~rxvt_term (); + void child_exit (); // child has exited, usually destroys void destroy (); void emergency_cleanup (); @@ -1339,8 +1326,8 @@ void color_aliases (int idx); void recolour_cursor (); void create_windows (int argc, const char *const *argv); - void resize_all_windows (unsigned int width, unsigned int height, int ignoreparent); - void window_calc (unsigned int width, unsigned int height); + void resize_all_windows (unsigned int newwidth, unsigned int newheight, int ignoreparent); + void window_calc (unsigned int newwidth, unsigned int newheight); #if USE_XIM rxvt_xim *input_method; @@ -1422,7 +1409,7 @@ void set_window_color (int idx, const char *color); void set_colorfgbg (); int rXParseAllocColor (rxvt_color * screen_in_out, const char *colour); - void set_widthheight (unsigned int width, unsigned int height); + void set_widthheight (unsigned int newwidth, unsigned int newheight); #ifdef MENUBAR // menubar.C @@ -1458,22 +1445,83 @@ #endif // screen.C - void scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs); - void scr_blank_screen_mem (text_t **tp, rend_t **rp, unsigned int row, rend_t efs); - int scr_scroll_text (int row1, int row2, int count, int spec); + + void lalloc (line_t &l) + { + l.t = (text_t *)talloc->alloc (); + l.r = (rend_t *)ralloc->alloc (); + } + +#if 0 + void lfree (line_t &l) + { + talloc->free (l.t); + ralloc->free (l.r); + } +#endif + + void lresize (line_t &l) + { + if (!l.t) + return; + + l.t = (text_t *)talloc->alloc (l.t, prev_ncol * sizeof (text_t)); + l.r = (rend_t *)ralloc->alloc (l.r, prev_ncol * sizeof (rend_t)); + + l.l = min (l.l, ncol); + + if (ncol > prev_ncol) + scr_blank_line (l, prev_ncol, ncol - prev_ncol, DEFAULT_RSTYLE); + } + + int fgcolor_of (rend_t r) + { + int base = GET_BASEFG (r); +#ifndef NO_BRIGHTCOLOR + if (r & RS_Bold +# if ENABLE_STYLES + && OPTION (Opt_intensityStyles) +# endif + && IN_RANGE_INC (base, minCOLOR, minBrightCOLOR)) + base += minBrightCOLOR - minCOLOR; +#endif + return base; + } + + int bgcolor_of (rend_t r) + { + int base = GET_BASEBG (r); +#ifndef NO_BRIGHTCOLOR + if (r & RS_Blink +# if ENABLE_STYLES + && OPTION (Opt_intensityStyles) +# endif + && IN_RANGE_INC (base, minCOLOR, minBrightCOLOR)) + base += minBrightCOLOR - minCOLOR; +#endif + return base; + } + + void scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs); + void scr_blank_screen_mem (line_t &l, rend_t efs); + int scr_scroll_text (int row1, int row2, int count); void scr_reset (); - void scr_reset_realloc (); void scr_release (); void scr_clear (bool really = false); void scr_refresh (unsigned char refresh_type); bool scr_refresh_rend (rend_t mask, rend_t value); void scr_erase_screen (int mode); +#if ENABLE_FRILLS + void scr_erase_savelines (); + void scr_backindex (); + void scr_forwardindex (); +#endif void scr_touch (bool refresh); void scr_expose (int x, int y, int width, int height, bool refresh); rxvt_fontset *scr_find_fontset (rend_t r = DEFAULT_RSTYLE); void scr_recolour (); void scr_remap_chars (); - void scr_remap_chars (text_t *tp, rend_t *rp); + void scr_remap_chars (const line_t &l); void scr_poweron (); void scr_cursor (int mode); @@ -1484,8 +1532,6 @@ void scr_add_lines (const unicode_t *str, int nlines, int len); void scr_backspace (); void scr_tab (int count, bool ht = false); - void scr_backindex (); - void scr_forwardindex (); void scr_gotorc (int row, int col, int relative); void scr_index (enum page_dirn direction); void scr_erase_line (int mode);