--- rxvt-unicode/src/rxvt.h 2006/01/20 22:49:34 1.230 +++ rxvt-unicode/src/rxvt.h 2006/12/07 03:30:01 1.265 @@ -10,14 +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 CURSOR_BLINK 1 +# define ENABLE_XEMBED 1 +# define ENABLE_EWMH 1 +# define ENABLE_XIM_ONTHESPOT 1 +# define CURSOR_BLINK 1 +# define OPTION_HC 1 #else # define ENABLE_MINIMAL 1 #endif @@ -33,10 +35,12 @@ #endif #include "encoding.h" +#include "rxvtutil.h" #include "rxvtfont.h" #include "rxvttoolkit.h" #include "iom.h" #include "salloc.h" +#include "libptytty.h" #include "rxvtperl.h" @@ -98,27 +102,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 { }; @@ -143,6 +126,7 @@ 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) @@ -160,7 +144,6 @@ 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; -void rxvt_usleep (int usecs) NOTHROW; ///////////////////////////////////////////////////////////////////////////// @@ -170,13 +153,21 @@ inline void set_environ (stringvec *envv) { +#if ENABLE_PERL + assert (envv); +#else if (envv) +#endif environ = (char **)envv->begin (); } inline void set_environ (char **envv) { +#if ENABLE_PERL + assert (envv); +#else if (envv) +#endif environ = envv; } @@ -203,32 +194,6 @@ } bgPixmap_t; #endif -struct rxvt_ptytty { - int pty; // pty file descriptor; connected to rxvt - int tty; // tty file descriptor; connected to child - - rxvt_ptytty () - : pty(-1), tty(-1) - { - } - - virtual ~rxvt_ptytty () - { - } - - virtual bool get () = 0; -#if UTMP_SUPPORT - virtual void login (int cmd_pid, bool login_shell, const char *hostname) = 0; -#endif - - void close_tty (); - bool make_controlling_tty (); - void set_utf8_mode (bool on); -}; - -rxvt_ptytty *rxvt_new_ptytty (); // create a new pty object -void rxvt_ptytty_server (); // start the ptytty server process - /* * the 'essential' information for reporting Mouse Events * pared down from XButtonEvent @@ -450,6 +415,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 @@ -528,6 +496,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 @@ -553,6 +522,8 @@ */ enum colour_list { + Color_none = -2, + Color_transparent = -1, Color_fg = 0, Color_bg, minCOLOR, /* 2 */ @@ -622,9 +593,6 @@ #define Color_Bits 7 // 0 .. maxTermCOLOR -#define NPIXCLR_SETS ((TOTAL_COLORS + 31) / 32) -#define NPIXCLR_BITS 32 - /* * Resource list */ @@ -637,42 +605,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) @@ -753,7 +685,10 @@ ***************************************************************************** */ #define dLocal(type,name) type const name = this->name -#define dDisp Display *disp = this->display->display + +// 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)) @@ -766,9 +701,13 @@ #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) +#define DEFAULT_OPTIONS (Opt_scrollBar \ + | Opt_scrollTtyOutput \ + | Opt_jumpScroll \ + | Opt_secondaryScreen \ + | Opt_secondaryScroll \ + | Opt_pastableTabs \ + | Opt_intensityStyles) // for m >= -n, ensure remainder lies between 0..n-1 #define MOD(m,n) (((m) + (n)) % (n)) @@ -797,8 +736,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)] @@ -842,29 +781,8 @@ # define XPMClearArea(a, b, c, d, e, f, g) #endif -#ifdef DEBUG_CMD -# 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) -#else -# define D_INIT(x) -#endif -#ifdef DEBUG_MAIN -# define D_MAIN(x) fprintf x ; fputc('\n', stderr) -#else -# define D_MAIN(x) -#endif -#ifdef DEBUG_SIZE -# define D_SIZE(x) fprintf x ; fputc('\n', stderr) -#else -# define D_SIZE(x) -#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; @@ -876,6 +794,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 @@ -939,7 +859,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 @@ -978,11 +898,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; @@ -1022,15 +948,16 @@ selection_wait, selection_type; /* ---------- */ - short rvideo; + bool rvideo_state, rvideo_mode; +#ifndef NO_BELL + bool rvideo_bell; +#endif int num_scr; /* screen: number lines scrolled */ int prev_ncol, /* screen: previous number of columns */ prev_nrow; /* screen: previous number of rows */ /* ---------- */ rend_t rstyle; /* ---------- */ - uint32_t pixcolor_set[NPIXCLR_SETS]; -/* ---------- */ #ifdef SELECTION_SCROLLING int scroll_selection_lines; enum page_dirn scroll_selection_dir; @@ -1066,7 +993,7 @@ unsigned long priv_modes, SavedModes; /* ---------- */ - Atom xa[NUM_XA]; + Atom *xa; /* ---------- */ #ifdef RXVT_SCROLLBAR GC scrollbarGC, @@ -1133,15 +1060,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; @@ -1152,7 +1080,7 @@ char *cmdbuf_ptr, *cmdbuf_endp; char cmdbuf_base[CBUFSIZ]; - rxvt_ptytty *pty; + ptytty *pty; rxvt_salloc *talloc; // text line allocator rxvt_salloc *ralloc; // rend line allocator @@ -1173,14 +1101,14 @@ // modifies first argument(!) void paste (char *data, unsigned int len) NOTHROW; - long vt_emask, vt_emask_perl; + long vt_emask, vt_emask_perl, vt_emask_xim; void vt_select_input () const NOTHROW { - XSelectInput (display->display, vt, vt_emask | vt_emask_perl); + XSelectInput (dpy, vt, vt_emask | vt_emask_perl | vt_emask_xim); } -#if TRANSPARENT +#if TRANSPARENT || ENABLE_PERL void rootwin_cb (XEvent &xev); xevent_watcher rootwin_ev; #endif @@ -1197,9 +1125,7 @@ void check_cb (check_watcher &w); check_watcher check_ev; void destroy_cb (time_watcher &w); time_watcher destroy_ev; void flush_cb (time_watcher &w); time_watcher flush_ev; - void pty_cb (io_watcher &w, short revents); io_watcher pty_ev; - void incr_cb (time_watcher &w) NOTHROW; time_watcher incr_ev; #ifdef CURSOR_BLINK @@ -1208,6 +1134,9 @@ #ifdef TEXT_BLINK void text_blink_cb (time_watcher &w); time_watcher text_blink_ev; #endif +#ifndef NO_BELL + void bell_cb (time_watcher &w); time_watcher bell_ev; +#endif #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING void cont_scroll_cb (time_watcher &w); time_watcher cont_scroll_ev; @@ -1236,7 +1165,14 @@ void destroy (); void emergency_cleanup (); - bool init (int argc, const char *const *argv); + bool init (int argc, const char *const *argv, stringvec *envv); + + bool init (stringvec *argv, stringvec *envv) + { + this->argv = argv; + return init (argv->size (), argv->begin (), envv); + } + bool init_vars (); bool pty_fill (); @@ -1244,8 +1180,8 @@ 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 (); @@ -1265,10 +1201,10 @@ void window_calc (unsigned int newwidth, unsigned int newheight); #if USE_XIM - rxvt_xim *input_method; - XIC Input_Context; - XIMStyle input_style; - XPoint spot; // most recently sent spot position + rxvt_xim *input_method; + XIC Input_Context; + XIMStyle input_style; + XPoint spot; // most recently sent spot position void im_destroy (); void im_cb (); im_watcher im_ev; @@ -1280,13 +1216,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; @@ -1300,6 +1237,7 @@ void button_release (XButtonEvent &ev); void focus_in (); void focus_out (); + void update_fade_color (unsigned int idx); int check_our_parents (); #ifdef PRINTPIPE FILE *popen_printer (); @@ -1331,12 +1269,13 @@ 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); // screen.C - void lalloc (line_t &l) const NOTHROW + void lalloc (line_t &l) const { l.t = (text_t *)talloc->alloc (); l.r = (rend_t *)ralloc->alloc (); @@ -1350,7 +1289,7 @@ } #endif - void lresize (line_t &l) const NOTHROW + void lresize (line_t &l) const { if (!l.t) return; @@ -1428,10 +1367,11 @@ enum cursor_mode { SAVE, RESTORE }; - void scr_poweron () NOTHROW; + void scr_poweron (); void scr_cursor (cursor_mode mode) NOTHROW; void scr_do_wrap () NOTHROW; - int scr_change_screen (int scrn) NOTHROW; + void scr_swap_screen () NOTHROW; + void scr_change_screen (int scrn); void scr_color (unsigned int color, int fgbg) NOTHROW; void scr_rendition (int set, int style) NOTHROW; void scr_add_lines (const wchar_t *str, int len, int minlines = 0) NOTHROW; @@ -1449,7 +1389,7 @@ void scr_relative_origin (int mode) NOTHROW; void scr_insert_mode (int mode) NOTHROW; void scr_set_tab (int mode) NOTHROW; - void scr_rvideo_mode (int mode) NOTHROW; + void scr_rvideo_mode (bool on) NOTHROW; void scr_report_position () NOTHROW; void set_font_style () NOTHROW; void scr_charset_choose (int set) NOTHROW; @@ -1533,9 +1473,5 @@ # define __PROTO(p) () #endif -#ifdef DEBUG_malloc -# include "dmalloc.h" /* This comes last */ -#endif - #endif /* _RXVT_H_ */