--- rxvt-unicode/src/rxvt.h 2010/04/01 00:58:38 1.396 +++ rxvt-unicode/src/rxvt.h 2011/01/20 17:39:29 1.428 @@ -30,6 +30,8 @@ using namespace std; +// we assume that Xlib.h defines XPointer, and it does since at least 1994... + extern "C" { #include #include @@ -100,10 +102,6 @@ ***************************************************************************** */ -#ifndef HAVE_XPOINTER -typedef char *XPointer; -#endif - #include #include "background.h" @@ -157,8 +155,14 @@ void rxvt_exit_failure () THROW ((class rxvt_failure_exception)) NORETURN; char * rxvt_strtrim (char *str) NOTHROW; -char ** rxvt_splitcommastring (const char *cs) NOTHROW; -void rxvt_freecommastring (char **cs) NOTHROW; +char ** rxvt_strsplit (char delim, const char *str) NOTHROW; + +static inline void +rxvt_free_strsplit (char **ptr) NOTHROW +{ + free (ptr[0]); + free (ptr); +} void * rxvt_malloc (size_t size); void * rxvt_calloc (size_t number, size_t size); @@ -192,6 +196,22 @@ environ = envv; } +struct localise_env +{ + char **orig_env; + + localise_env (char **new_env) + { + orig_env = environ; + environ = new_env; + } + + ~localise_env () + { + environ = orig_env; + } +}; + /* ***************************************************************************** * STRUCTURES AND TYPEDEFS @@ -249,7 +269,11 @@ # define COLORTERMENVFULL COLORTERMENV #endif #ifndef TERMENV -# define TERMENV "rxvt-unicode" +# if USE_256_COLORS +# define TERMENV "rxvt-unicode-256color" +# else +# define TERMENV "rxvt-unicode" +# endif #endif #if defined (NO_MOUSE_REPORT) && !defined (NO_MOUSE_REPORT_SCROLLBAR) @@ -306,6 +330,9 @@ SECONDARY, }; +// define various rendition bits and masks. the rendition word +// is 32 bits in size, and we should use it as efficiently as possible + #define RS_None 0 // GET_BGATTR depends on RS_fgShift > RS_bgShift @@ -315,31 +342,34 @@ #define RS_bgMask (RS_colorMask << RS_bgShift) #define RS_fgMask (RS_colorMask << RS_fgShift) -// font styles -#define RS_Bold 0x08000000UL // value 1 -#define RS_Italic 0x10000000UL // value 2 +// must have space for rxvt_fontset::fontCount * 2 + 2 values +#define RS_fontShift (RS_fgShift + Color_Bits) +#define RS_Careful (1UL << RS_fontShift) /* be careful when drawing these */ +#define RS_fontCount rxvt_fontset::fontCount +#define RS_fontMask ((RS_fontCount << (RS_fontShift + 1)) | RS_Careful) // includes RS_Careful -#define RS_styleCount 4 -#define RS_styleMask (RS_Bold | RS_Italic) -#define RS_styleShift 27 +// toggle this to force redraw, must be != RS_Careful and otherwise "pretty neutral" +#define RS_redraw (2UL << RS_fontShift) -// fake styles -#define RS_Blink 0x20000000UL // blink -#define RS_RVid 0x40000000UL // reverse video -#define RS_Uline 0x80000000UL // underline +#define RS_Sel (1UL << 22) -// 5 custom bits for extensions +// 4 custom bits for extensions #define RS_customCount 16UL #define RS_customShift 23 #define RS_customMask ((RS_customCount - 1UL) << RS_customShift) -// must have space for rxvt_fontset::fontCount * 2 + 2 values -#define RS_fontShift (RS_fgShift + Color_Bits) -#define RS_Careful (1UL << RS_fontShift) /* be careful when drawing these */ -#define RS_fontMask ((rxvt_fontset::fontCount << (RS_fontShift + 1)) | RS_Careful) // includes RS_Careful +// font styles +#define RS_Bold (1UL << RS_styleShift) +#define RS_Italic (2UL << RS_styleShift) -// toggle this to force redraw, must be != RS_Careful and otherwise "pretty neutral" -#define RS_redraw (2UL << RS_fontShift) +#define RS_styleCount 4 +#define RS_styleShift 27 +#define RS_styleMask (RS_Bold | RS_Italic) + +// fake styles +#define RS_Blink (1UL << 29) +#define RS_RVid (1UL << 30) // reverse video +#define RS_Uline (1UL << 31) // underline #define RS_baseattrMask (RS_Italic | RS_Bold | RS_Blink | RS_RVid | RS_Uline) #define RS_attrMask (RS_baseattrMask | RS_fontMask) @@ -384,7 +414,8 @@ XTerm_Color_pointer_bg = 14, // change actual 'Pointer' bg color XTerm_Color05 = 15, // not implemented (tektronix fg) XTerm_Color06 = 16, // not implemented (tektronix bg) - XTerm_Color_RV = 17, // change actual 'Highlight' color + XTerm_Color_HC = 17, // change actual 'Highlight' bg color + XTerm_Color_HTC = 19, // change actual 'Highlight' fg color XTerm_logfile = 46, // not implemented XTerm_font = 50, @@ -396,8 +427,6 @@ */ // deprecated - Rxvt_Color_BD = 18, - Rxvt_Color_UL = 19, Rxvt_restoreFG = 39, Rxvt_restoreBG = 49, @@ -461,10 +490,10 @@ Color_White = maxCOLOR, #endif minTermCOLOR = Color_White + 1, -#ifndef USE_256_COLORS - maxTermCOLOR = Color_White + 72, -#else +#if USE_256_COLORS maxTermCOLOR = Color_White + 240, +#else + maxTermCOLOR = Color_White + 72, #endif #ifndef NO_CURSORCOLOR Color_cursor, @@ -484,6 +513,7 @@ #endif #ifdef OPTION_HC Color_HC, + Color_HTC, #endif Color_scroll, #ifdef RXVT_SCROLLBAR @@ -505,10 +535,10 @@ #endif }; -#ifndef USE_256_COLORS -#define Color_Bits 7 // 0 .. maxTermCOLOR +#if USE_256_COLORS +# define Color_Bits 9 // 0 .. maxTermCOLOR #else -#define Color_Bits 9 // 0 .. maxTermCOLOR +# define Color_Bits 7 // 0 .. maxTermCOLOR #endif /* @@ -547,6 +577,8 @@ #define PrivMode_MouseBtnEvent (1UL<<20) #define PrivMode_MouseAnyEvent (1UL<<21) #define PrivMode_BracketPaste (1UL<<22) +#define PrivMode_ExtModeMouse (1UL<<23) // xterm pseudo-utf-8 hack +#define PrivMode_ExtMouseRight (1UL<<24) // xterm pseudo-utf-8, but works in non-utf-8-locales #define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent) @@ -607,6 +639,8 @@ * MACRO DEFINES ***************************************************************************** */ + +// speed hack, copy some member variable into a local variable of the same name #define dLocal(type,name) type const name = this->name // for speed reasons, we assume that all codepoints 32 to 126 are @@ -797,7 +831,7 @@ text_t **text; rend_t **rend; - // while tempting to add swap() etc. here, it effetcively only increases code size + // while tempting to add swap() etc. here, it effectively only increases code size }; /* ------------------------------------------------------------------------- */ @@ -939,12 +973,13 @@ /* rxvt_vars.options */ enum { -# define def(name,idx) Opt_ ## name = idx, -# define nodef(name) Opt_ ## name = 0, +# define def(name) Opt_ ## name, +# define nodef(name) Opt_prev_ ## name, Opt_ ## name = 0, Opt_next_ ## name = Opt_prev_ ## name - 1, + Opt_0, # include "optinc.h" # undef nodef # undef def -Opt_count + Opt_count }; /* ------------------------------------------------------------------------- */ @@ -956,7 +991,6 @@ XSizeHints szHint; rxvt_color *pix_colors; Cursor TermWin_cursor; /* cursor for vt window */ - int numlock_state; line_t *row_buf; // all lines, scrollback + terminal, circular, followed by temp_buf line_t *drawn_buf; // text on screen line_t *swap_buf; // lines for swap buffer @@ -1065,7 +1099,7 @@ /* ---------- */ struct mouse_event MEvent; XComposeStatus compose; - struct termios tio; + static struct termios def_tio; row_col_t oldcursor; #ifdef HAVE_BG_PIXMAP bgPixmap_t bgPixmap; @@ -1149,10 +1183,6 @@ #endif #ifdef HAVE_BG_PIXMAP void update_background (); -#if TRACE_PIXMAPS - void trace_update_background (const char *file, int line); -# define update_background() trace_update_background (__FILE__, __LINE__) -#endif void update_background_cb (ev::timer &w, int revents); ev::timer update_background_ev; #endif @@ -1288,6 +1318,7 @@ void create_windows (int argc, const char *const *argv); void get_colours (); void get_ourmods (); + void set_icon (const char *file); // main.C void tt_winch (); rxvt_term (); @@ -1299,6 +1330,7 @@ void window_calc (unsigned int newwidth, unsigned int newheight); bool set_fonts (); void set_string_property (Atom prop, const char *str, int len = -1); + void set_mbstring_property (Atom prop, const char *str, int len = -1); void set_utf8_property (Atom prop, const char *str, int len = -1); void set_title (const char *str); void set_icon_name (const char *str); @@ -1308,7 +1340,7 @@ void alias_color (int dst, int src); void set_widthheight (unsigned int newwidth, unsigned int newheight); void get_window_origin (int &x, int &y); - Pixmap get_pixmap_property (int prop_id); + Pixmap get_pixmap_property (Atom property); // screen.C @@ -1370,24 +1402,10 @@ bool option (uint8_t opt) const NOTHROW { - if (!opt) - return 0; - - --opt; return options[opt >> 3] & (1 << (opt & 7)); } - void set_option (uint8_t opt, bool set = true) NOTHROW - { - if (!opt) - return; - - --opt; - if (set) - options[opt >> 3] |= (1 << (opt & 7)); - else - options[opt >> 3] &= ~(1 << (opt & 7)); - } + void set_option (uint8_t opt, bool set = true) NOTHROW; void set_privmode (unsigned bit, int set) NOTHROW { @@ -1398,6 +1416,7 @@ } // modifies first argument(!) + void tt_paste (char *data, unsigned int len) NOTHROW; void paste (char *data, unsigned int len) NOTHROW; void scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW; void scr_blank_screen_mem (line_t &l, rend_t efs) const NOTHROW; @@ -1416,7 +1435,7 @@ #endif void scr_touch (bool refresh) NOTHROW; void scr_expose (int x, int y, int width, int height, bool refresh) NOTHROW; - void scr_recolour () NOTHROW; + void scr_recolour (bool refresh = true) NOTHROW; void scr_remap_chars () NOTHROW; void scr_remap_chars (line_t &l) NOTHROW; @@ -1466,7 +1485,6 @@ void selection_request (Time tm, int selnum = Sel_Primary) NOTHROW; int selection_request_other (Atom target, int selnum) NOTHROW; void selection_clear (bool clipboard = false) NOTHROW; - void clipboard_copy (Time tm); void selection_make (Time tm); bool selection_grab (Time tm, bool clipboard = false) NOTHROW; void selection_start_colrow (int col, int row) NOTHROW;