--- rxvt-unicode/src/rxvt.h 2006/01/25 00:42:20 1.241 +++ rxvt-unicode/src/rxvt.h 2007/10/11 16:01:26 1.307 @@ -10,15 +10,16 @@ #endif #if ENABLE_PERL -# define ENABLE_FRILLS 1 +# define ENABLE_FRILLS 1 # define ENABLE_COMBINING 1 #endif #if ENABLE_FRILLS -# define ENABLE_XEMBED 1 -# define ENABLE_EWMH 1 +# define ENABLE_XEMBED 1 +# define ENABLE_EWMH 1 # define ENABLE_XIM_ONTHESPOT 1 -# define CURSOR_BLINK 1 +# define CURSOR_BLINK 1 +# define OPTION_HC 1 #else # define ENABLE_MINIMAL 1 #endif @@ -34,6 +35,7 @@ #endif #include "encoding.h" +#include "rxvtutil.h" #include "rxvtfont.h" #include "rxvttoolkit.h" #include "iom.h" @@ -70,28 +72,17 @@ typedef char *XPointer; #endif -#ifdef HAVE_TERMIOS_H -# include +#include typedef struct termios ttymode_t; -#else -# include -typedef struct { - struct sgttyb sg; - struct tchars tc; - struct ltchars lc; - int line; - int local; -} ttymode_t; -#endif -#ifdef XPM_BACKGROUND -# ifdef XPM_INC_X11 -# include -# else -# include -# endif +#ifdef HAVE_AFTERIMAGE +# include +#undef min +#undef max #endif +#include "background.h" + #ifndef STDIN_FILENO # define STDIN_FILENO 0 # define STDOUT_FILENO 1 @@ -100,27 +91,6 @@ /****************************************************************************/ -#ifndef __attribute__ -# if __GNUC__ -# if (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (__GNUC__ < 2) -# define __attribute__(x) -# endif -# endif -# define __attribute__(x) -#endif - -#define NORETURN __attribute__ ((noreturn)) -#define UNUSED __attribute__ ((unused)) - -// increases code size unless -fno-enforce-eh-specs -#if __GNUC__ -# define NOTHROW -# define THROW(x) -#else -# define NOTHROW throw() -# define THROW(x) throw x -#endif - // exception thrown on fatal (per-instance) errors class rxvt_failure_exception { }; @@ -133,9 +103,6 @@ ***************************************************************************** */ // main.C -RETSIGTYPE rxvt_Child_signal (int sig) NOTHROW; -RETSIGTYPE rxvt_Exit_signal (int sig) NOTHROW; -void rxvt_clean_exit () NOTHROW; void * rxvt_malloc (size_t size); void * rxvt_calloc (size_t number, size_t size); void * rxvt_realloc (void *ptr, size_t size); @@ -145,24 +112,19 @@ wchar_t * rxvt_mbstowcs (const char *str, int len = -1); char * rxvt_wcstoutf8 (const wchar_t *str, int len = -1); wchar_t * rxvt_utf8towcs (const char *str, int len = -1); -char * rxvt_strdup_cpp (const char *str); #define rxvt_strdup(s) ((s) ? strdup(s) : 0) -char * rxvt_r_basename (const char *str) NOTHROW; +char * rxvt_basename (const char *str) NOTHROW; void rxvt_vlog (const char *fmt, va_list arg_ptr) NOTHROW; void rxvt_log (const char *fmt,...) NOTHROW; void rxvt_warn (const char *fmt,...) NOTHROW; void rxvt_fatal (const char *fmt, ...) THROW ((class rxvt_failure_exception)) NORETURN; void rxvt_exit_failure () THROW ((class rxvt_failure_exception)) NORETURN; -int rxvt_Str_match (const char *s1, const char *s2) NOTHROW; -const char * rxvt_Str_skip_space (const char *str) NOTHROW; -char * rxvt_Str_trim (char *str) NOTHROW; -int rxvt_Str_escaped (char *str) NOTHROW; +char * rxvt_strtrim (char *str) NOTHROW; char ** rxvt_splitcommastring (const char *cs) NOTHROW; void rxvt_freecommastring (char **cs) NOTHROW; -char * rxvt_File_find (const char *file, const char *ext, const char *path) NOTHROW; ///////////////////////////////////////////////////////////////////////////// @@ -170,7 +132,7 @@ extern char **environ; extern char **rxvt_environ; // the original environ pointer -inline void set_environ (stringvec *envv) +static inline void set_environ (stringvec *envv) { #if ENABLE_PERL assert (envv); @@ -180,7 +142,7 @@ environ = (char **)envv->begin (); } -inline void set_environ (char **envv) +static inline void set_environ (char **envv) { #if ENABLE_PERL assert (envv); @@ -206,13 +168,6 @@ # undef KEEP_SCROLLCOLOR #endif -#ifdef XPM_BACKGROUND -typedef struct { - short w, h, x, y; - Pixmap pixmap; -} bgPixmap_t; -#endif - /* * the 'essential' information for reporting Mouse Events * pared down from XButtonEvent @@ -267,7 +222,7 @@ /* COLORTERM, TERM environment variables */ #define COLORTERMENV "rxvt" -#ifdef XPM_BACKGROUND +#ifdef BG_IMAGE_FROM_FILE # define COLORTERMENVFULL COLORTERMENV "-xpm" #else # define COLORTERMENVFULL COLORTERMENV @@ -434,6 +389,9 @@ #define RS_RVid 0x00020000UL // reverse video #define RS_Uline 0x00040000UL // underline +// toggle this to force redraw, must be != RS_Careful +#define RS_redraw 0x01000000UL + // 5 custom bits for extensions #define RS_customCount 32 #define RS_customMask 0x00f80000UL @@ -512,6 +470,7 @@ Rxvt_dumpscreen = 55, // dump scrollback and all of screen URxvt_locale = 701, // change locale + URxvt_version = 702, // request version URxvt_Color_IT = 704, // change actual 'Italic' colour URxvt_Color_tint = 705, // change actual tint colour @@ -537,6 +496,8 @@ */ enum colour_list { + Color_none = -2, + Color_transparent = -1, Color_fg = 0, Color_bg, minCOLOR, /* 2 */ @@ -588,7 +549,7 @@ Color_scroll, Color_trough, #endif -#if TINTING +#if ENABLE_TRANSPARENCY Color_tint, #endif #if OFF_FOCUS_FADING @@ -606,9 +567,6 @@ #define Color_Bits 7 // 0 .. maxTermCOLOR -#define NPIXCLR_SETS ((TOTAL_COLORS + 31) / 32) -#define NPIXCLR_BITS 32 - /* * Resource list */ @@ -621,42 +579,6 @@ NUM_RESOURCES }; -// see init.C:xa_names, which must be kept in sync -enum { - XA_TEXT = 0, - XA_COMPOUND_TEXT, - XA_UTF8_STRING, - XA_MULTIPLE, - XA_TARGETS, - XA_TIMESTAMP, - XA_VT_SELECTION, - XA_INCR, - XA_WM_PROTOCOLS, - XA_WM_DELETE_WINDOW, - XA_CLIPBOARD, -#if ENABLE_FRILLS - 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, -#endif -#if TRANSPARENT - XA_XROOTPMAP_ID, - XA_ESETROOT_PMAP_ID, -#endif -#if ENABLE_XEMBED - XA_XEMBED, - XA_XEMBED_INFO, -#endif - NUM_XA -}; - /* DEC private modes */ #define PrivMode_132 (1UL<<0) #define PrivMode_132OK (1UL<<1) @@ -682,11 +604,6 @@ /* #define PrivMode_MouseX11Track (1LU<<20) */ #define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11) -#define PrivMode(test,bit) \ - if (test) \ - priv_modes |= (bit); \ - else \ - priv_modes &= ~(bit) #ifdef ALLOW_132_MODE # define PrivMode_Default (PrivMode_Autowrap|PrivMode_ShiftKeys|PrivMode_VisibleCursor|PrivMode_132OK) @@ -737,12 +654,10 @@ ***************************************************************************** */ #define dLocal(type,name) type const name = this->name -#define dDisp Display *disp = this->display->display -// for speed reasons, we assume that all latin1 characters -// are single-width (the first unicdoe combining character -// is actually 0x300, but ascii is what matters most). -#define WCWIDTH(c) ((c) < 0x100 ? 1 : wcwidth (c)) +// for speed reasons, we assume that all codepoints 32 to 126 are +// single-width. +#define WCWIDTH(c) (IN_RANGE_INC (c, 0x20, 0x7e) ? 1 : wcwidth (c)) /* convert pixel dimensions to row/column values. Everything as int32_t */ #define Pixel2Col(x) Pixel2Width((int32_t)(x)) @@ -754,11 +669,6 @@ #define Width2Pixel(n) ((int32_t)(n) * (int32_t)fwidth) #define Height2Pixel(n) ((int32_t)(n) * (int32_t)fheight) -#define OPTION(opt) (options & (opt)) -#define DEFAULT_OPTIONS (Opt_scrollBar | Opt_scrollTtyOutput \ - | Opt_jumpScroll | Opt_secondaryScreen \ - | Opt_pastableTabs | Opt_intensityStyles) - // for m >= -n, ensure remainder lies between 0..n-1 #define MOD(m,n) (((m) + (n)) % (n)) @@ -786,8 +696,8 @@ #define RS_SAME(a,b) (!(((a) ^ (b)) & ~RS_Careful)) -#define SET_PIXCOLOR(x) (pixcolor_set[(x) / NPIXCLR_BITS] |= (1 << ((x) % NPIXCLR_BITS))) -#define ISSET_PIXCOLOR(x) (pixcolor_set[(x) / NPIXCLR_BITS] & (1 << ((x) % NPIXCLR_BITS))) +#define PIXCOLOR_NAME(idx) rs[Rs_color + (idx)] +#define ISSET_PIXCOLOR(idx) (!!rs[Rs_color + (idx)]) #if ENABLE_STYLES # define FONTSET(style) fontset[GET_STYLE (style)] @@ -825,14 +735,8 @@ #define scrollbar_size() (scrollBar.end - scrollBar.beg \ - scrollbar_minheight ()) -#ifdef XPM_BACKGROUND -# 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 - -typedef callback1 log_callback; -typedef callback1 getfd_callback; +typedef callback log_callback; +typedef callback getfd_callback; #define SET_LOCALE(locale) rxvt_set_locale (locale) extern bool rxvt_set_locale (const char *locale) NOTHROW; @@ -844,6 +748,8 @@ #define LINE_LONGER 0x0001 // line is continued on the next row #define LINE_FILTERED 0x0002 // line has been filtered #define LINE_COMPRESSED 0x0004 // line has been compressed (NYI) +#define LINE_FILTER 0x0008 // line needs to be filtered before display (NYI) +#define LINE_BIDI 0x0010 // line needs bidi (NYI) struct line_t { text_t *t; // terminal the text @@ -907,7 +813,7 @@ # define IS_COMPOSE(n) ((int32_t)(n) >= COMPOSE_LO) #else # if ENABLE_PERL -# define COMPOSE_LO 0xe000UL // our _own_ routiens don't like (illegal) surrogates +# define COMPOSE_LO 0xe000UL // our _own_ functions don't like (illegal) surrogates # define COMPOSE_HI 0xf8ffUL // in utf-8, so use private use area only # else # define COMPOSE_LO 0xd800UL @@ -946,11 +852,17 @@ /****************************************************************************/ #ifdef KEYSYM_RESOURCE - class keyboard_manager; +class keyboard_manager; #endif -struct rxvt_term : zero_initialized, rxvt_vars { - log_callback *log_hook; // log error messages through this hook, if != 0 +struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen { + + // special markers with magic addresses + static const char resval_undef []; // options specifically unset + static const char resval_on []; // boolean options switched on + static const char resval_off []; // or off + + log_callback *log_hook; // log error messages through this hook, if != 0 getfd_callback *getfd_hook; // convert remote to local fd, if != 0 #if ENABLE_PERL rxvt_perl_term perl; @@ -958,13 +870,6 @@ struct mbstate mbstate; // current input multibyte state unsigned char want_refresh:1, -#ifdef TRANSPARENT - want_full_refresh:1, /* awaiting full screen refresh */ -#endif -#if defined(XPM_BACKGROUND) || defined(TRANSPARENT) - am_transparent:1, /* is a transparent term */ - am_pixmap_trans:1, /* transparency w/known root pixmap */ -#endif current_screen:1, /* primary or secondary */ num_scr_allow:1, bypass_keystate:1, @@ -1000,8 +905,6 @@ /* ---------- */ rend_t rstyle; /* ---------- */ - uint32_t pixcolor_set[NPIXCLR_SETS]; -/* ---------- */ #ifdef SELECTION_SCROLLING int scroll_selection_lines; enum page_dirn scroll_selection_dir; @@ -1016,7 +919,6 @@ mouse_slip_wheel_speed, #endif refresh_count, - refresh_limit, last_bot, /* scrollbar last bottom position */ last_top, /* scrollbar last top position */ last_state, /* scrollbar last state */ @@ -1037,7 +939,7 @@ unsigned long priv_modes, SavedModes; /* ---------- */ - Atom xa[NUM_XA]; + Atom *xa; /* ---------- */ #ifdef RXVT_SCROLLBAR GC scrollbarGC, @@ -1072,19 +974,16 @@ /* ---------- */ Cursor leftptr_cursor; /* ---------- */ -#ifndef NO_BACKSPACE_KEY - const char *key_backspace; -#endif -#ifndef NO_DELETE_KEY - const char *key_delete; -#endif struct mouse_event MEvent; XComposeStatus compose; ttymode_t tio; row_col_t oldcursor; -#ifdef XPM_BACKGROUND +#ifdef HAVE_BG_PIXMAP bgPixmap_t bgPixmap; - XpmAttributes xpmAttr; /* originally loaded pixmap and its scaling */ +#endif +#ifdef HAVE_AFTERIMAGE + ASVisual *asv; + ASImageManager *asimman; #endif #if ENABLE_OVERLAY @@ -1104,15 +1003,16 @@ vector allocated; // free these memory blocks with free() - char *env_windowid; /* environmental variable WINDOWID */ + char env_windowid[21]; /* environmental variable WINDOWID */ + char env_colorfgbg[sizeof ("COLORFGBG=default;default;bg") + 1]; char *env_display; /* environmental variable DISPLAY */ char *env_term; /* environmental variable TERM */ - char *env_colorfgbg; + char *locale; char charsets[4]; char *v_buffer; /* pointer to physical buffer */ unsigned int v_buflen; /* size of area to write */ - stringvec *argv, *envv; /* if != 0, will be freed on destroy time */ + stringvec *argv, *envv; /* if != 0, will be freed at destroy time */ #ifdef KEYSYM_RESOURCE keyboard_manager *keyboard; @@ -1148,13 +1048,18 @@ void vt_select_input () const NOTHROW { - XSelectInput (display->display, vt, vt_emask | vt_emask_perl | vt_emask_xim); + XSelectInput (dpy, vt, vt_emask | vt_emask_perl | vt_emask_xim); } -#if TRANSPARENT +#if ENABLE_TRANSPARENCY || ENABLE_PERL void rootwin_cb (XEvent &xev); xevent_watcher rootwin_ev; #endif +#ifdef HAVE_BG_PIXMAP + int update_background (); + void update_background_cb (time_watcher &w); + time_watcher update_background_ev; +#endif void x_cb (XEvent &xev); void flush (); @@ -1223,13 +1128,12 @@ void make_current () const // make this the "currently active" urxvt instance { SET_R (this); - rxvt_set_locale (locale); set_environ (envv); + rxvt_set_locale (locale); } void init_secondary (); const char **init_resources (int argc, const char *const *argv); - const char *x_resource (const char *name); void init_env (); void set_locale (const char *locale); void init_xlocale (); @@ -1259,13 +1163,14 @@ bool IMisRunning (); void IMSendSpot (); bool IM_get_IC (const char *modifiers); - void IMSetStatusPosition (); + void IMSetPosition (); #endif void resize_scrollbar (); // command.C - void lookup_key (XKeyEvent &ev); + void key_press (XKeyEvent &ev); + void key_release (XKeyEvent &ev); unsigned int cmd_write (const char *str, unsigned int count); wchar_t next_char () NOTHROW; @@ -1279,7 +1184,7 @@ void button_release (XButtonEvent &ev); void focus_in (); void focus_out (); - int check_our_parents (); + void update_fade_color (unsigned int idx); #ifdef PRINTPIPE FILE *popen_printer (); int pclose_printer (FILE *stream); @@ -1310,8 +1215,11 @@ void set_icon_name (const char *str); void set_window_color (int idx, const char *color); void set_colorfgbg (); - int rXParseAllocColor (rxvt_color * screen_in_out, const char *colour); + bool set_color (rxvt_color &color, const char *name); + 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); // screen.C @@ -1349,7 +1257,7 @@ #ifndef NO_BRIGHTCOLOR if (r & RS_Bold # if ENABLE_STYLES - && OPTION (Opt_intensityStyles) + && option (Opt_intensityStyles) # endif && IN_RANGE_INC (base, minCOLOR, minBrightCOLOR)) base += minBrightCOLOR - minCOLOR; @@ -1363,7 +1271,7 @@ #ifndef NO_BRIGHTCOLOR if (r & RS_Blink # if ENABLE_STYLES - && OPTION (Opt_intensityStyles) + && option (Opt_intensityStyles) # endif && IN_RANGE_INC (base, minCOLOR, minBrightCOLOR)) base += minBrightCOLOR - minCOLOR; @@ -1371,17 +1279,25 @@ return base; } - bool option (uint32_t opt) const NOTHROW + bool option (uint8_t opt) const NOTHROW { - return OPTION (opt); + return options[opt >> 3] & (1 << (opt & 7)); } - void set_option (uint32_t opt, bool set) NOTHROW + void set_option (uint8_t opt, bool set = true) NOTHROW { if (set) - options |= opt; + options[opt >> 3] |= (1 << (opt & 7)); else - options &= ~opt; + options[opt >> 3] &= ~(1 << (opt & 7)); + } + + void PrivMode (int set, unsigned bit) NOTHROW + { + if (set) + priv_modes |= bit; + else + priv_modes &= ~bit; } void scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW; @@ -1496,22 +1412,7 @@ int parse_keysym (const char *str, const char *arg); void get_xdefaults (FILE *stream, const char *name); void extract_resources (); - // xpm.C - int scale_pixmap (const char *geom); - void resize_pixmap (); - Pixmap set_bgPixmap (const char *file); }; -/* - ***************************************************************************** - * PROTOTYPES - ***************************************************************************** - */ -#ifdef PROTOTYPES -# define __PROTO(p) p -#else -# define __PROTO(p) () -#endif - #endif /* _RXVT_H_ */