--- rxvt-unicode/src/rxvt.h 2006/01/11 02:13:56 1.196 +++ rxvt-unicode/src/rxvt.h 2006/01/17 10:14:26 1.216 @@ -5,6 +5,23 @@ #include "feature.h" +#if defined (ISO_14755) || defined (ENABLE_PERL) +# define ENABLE_OVERLAY 1 +#endif + +#if ENABLE_PERL +# define ENABLE_FRILLS 1 +# define ENABLE_COMBINING 1 +#endif + +#if ENABLE_FRILLS +# define ENABLE_XEMBED 1 +# define ENABLE_EWMH 1 +# define CURSOR_BLINK 1 +#else +# define ENABLE_MINIMAL 1 +#endif + #include #include @@ -23,10 +40,13 @@ #include "rxvtperl.h" -#if ENABLE_FRILLS -# define ENABLE_XEMBED 1 -# define ENABLE_EWMH 1 -# define CURSOR_BLINK 1 +// try to avoid some macros to decrease code size, on some systems +#if ENABLE_MINIMAL +# define strcmp(a,b) (strcmp)(a,b) +# define strlen(a) (strlen)(a) +# define strcpy(a,b) (strcpy)(a,b) +# define memset(a,c,l) (memset)(a,c,l) +# define memcpy(a,b,l) (memcpy)(a,b,l) #endif /* @@ -45,7 +65,7 @@ #endif #ifndef HAVE_XPOINTER -typedef char *XPointer; +typedef char *XPointer; #endif #ifdef HAVE_TERMIOS_H @@ -111,10 +131,26 @@ char ** rxvt_splitcommastring (const char *cs); void rxvt_freecommastring (char **cs); 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); +///////////////////////////////////////////////////////////////////////////// + +// temporarily replace the process environment +extern char **environ; +extern char **rxvt_environ; // the original environ pointer + +inline void set_environ (stringvec *envv) +{ + if (envv) + environ = (char **)envv->begin (); +} + +inline void set_environ (char **envv) +{ + if (envv) + environ = envv; +} + /* ***************************************************************************** * STRUCTURES AND TYPEDEFS @@ -122,18 +158,10 @@ */ struct grwin_t; -/* Sanitize menubar info */ -#ifndef MENUBAR -# undef MENUBAR_MAX -#endif -#ifndef MENUBAR_MAX -# define MENUBAR_MAX 0 -#endif - -/* If we're using either the rxvt scrollbar or menu bars, keep the +/* If we're using either the rxvt scrollbar, keep the * scrollColor resource. */ -#if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(MENUBAR) || defined(PLAIN_SCROLLBAR) +#if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(PLAIN_SCROLLBAR) # define KEEP_SCROLLCOLOR 1 #else # undef KEEP_SCROLLCOLOR @@ -213,10 +241,6 @@ # define NO_MOUSE_REPORT_SCROLLBAR 1 #endif -#if defined (ISO_14755) || defined (ENABLE_PERL) -# define ENABLE_OVERLAY 1 -#endif - /* now look for other badly set stuff */ #if !defined (EACCESS) && defined(EAGAIN) @@ -228,21 +252,12 @@ # define EXIT_FAILURE 1 /* exit function failure */ #endif -#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) || defined(PLAIN_SCROLLBAR) # define HAVE_SCROLLBARS 1 #endif -/* width of scrollBar, menuBar shadow, must be 1 or 2 */ -#ifdef HALFSHADOW -# define MENU_SHADOW 1 -#else -# define MENU_SHADOW 2 -#endif - #define R_SB_ALIGN_CENTRE 0 #define R_SB_ALIGN_TOP 1 #define R_SB_ALIGN_BOTTOM 2 @@ -323,10 +338,9 @@ */ enum { - NO_REFRESH = 0 , /* Window not visible at all! */ - FAST_REFRESH = 1<<0, /* Fully exposed window */ - SLOW_REFRESH = 1<<1, /* Partially exposed window */ - SMOOTH_REFRESH = 1<<2, /* Do sync'ing to make it smooth */ + NO_REFRESH = 0, /* Window not visible at all! */ + FAST_REFRESH = 1, /* Fully exposed window */ + SLOW_REFRESH = 2, /* Partially exposed window */ }; #ifdef NO_SECONDARY_SCREEN @@ -436,10 +450,10 @@ XTerm_Color00 = 10, // not implemented, CLASH! XTerm_Color01 = 11, // not implemented XTerm_Color_cursor = 12, // change actual 'Cursor' color - XTerm_Color_pointer_fg = 13, // change actual 'Pointer' color - XTerm_Color_pointer_bg = 14, // not implemented - XTerm_Color05 = 15, // not implemented - XTerm_Color06 = 16, // not implemented + XTerm_Color_pointer_fg = 13, // change actual 'Pointer' fg color + 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_logfile = 46, // not implemented XTerm_font = 50, @@ -449,18 +463,21 @@ XTerm_emacs51 = 51, // reserved for emacs shell /* * rxvt extensions of XTerm OSCs: ESC ] Ps;Pt (ST|BEL) + * at least Rxvt_Color_BD and Rxvt_Color_UL clash with xterm */ - XTerm_Color_BD = 18, // change actual 'Bold' color - XTerm_Color_UL = 19, // change actual 'Underline' color - XTerm_Pixmap = 20, // new bg pixmap - XTerm_restoreFG = 39, // change default fg color - XTerm_restoreBG = 49, // change default bg color - XTerm_dumpscreen = 55, // dump scrollback and all of screen + Rxvt_Color_BD = 18, // change actual 'Bold' color + Rxvt_Color_UL = 19, // change actual 'Underline' color + Rxvt_Pixmap = 20, // new bg pixmap + Rxvt_restoreFG = 39, // change default fg color + Rxvt_restoreBG = 49, // change default bg color + Rxvt_dumpscreen = 55, // dump scrollback and all of screen 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_Color_BD = 706, + URxvt_Color_UL = 707, URxvt_font = 710, URxvt_boldFont = 711, @@ -621,14 +638,13 @@ #define PrivMode_MouseX10 (1UL<<12) #define PrivMode_MouseX11 (1UL<<13) #define PrivMode_scrollBar (1UL<<14) -#define PrivMode_menuBar (1UL<<15) -#define PrivMode_TtyOutputInh (1UL<<16) -#define PrivMode_Keypress (1UL<<17) -#define PrivMode_smoothScroll (1UL<<18) -#define PrivMode_vt52 (1UL<<19) -#define PrivMode_LFNL (1UL<<20) +#define PrivMode_TtyOutputInh (1UL<<15) +#define PrivMode_Keypress (1UL<<16) +#define PrivMode_smoothScroll (1UL<<17) +#define PrivMode_vt52 (1UL<<18) +#define PrivMode_LFNL (1UL<<19) /* too annoying to implement X11 highlight tracking */ -/* #define PrivMode_MouseX11Track (1LU<<21) */ +/* #define PrivMode_MouseX11Track (1LU<<20) */ #define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11) #define PrivMode(test,bit) \ @@ -685,7 +701,8 @@ * MACRO DEFINES ***************************************************************************** */ -#define dDisp Display *disp = display->display +#define dLocal(type,name) type const name = this->name +#define dDisp Display *disp = this->display->display /* convert pixel dimensions to row/column values. Everything as int32_t */ #define Pixel2Col(x) Pixel2Width((int32_t)(x)) @@ -697,8 +714,6 @@ #define Width2Pixel(n) ((int32_t)(n) * (int32_t)fwidth) #define Height2Pixel(n) ((int32_t)(n) * (int32_t)fheight) -#define TEMP_ENV temp_environ temp_environ (envv) - #define OPTION(opt) (options & (opt)) #define DEFAULT_OPTIONS (Opt_scrollBar | Opt_scrollTtyOutput \ | Opt_jumpScroll | Opt_secondaryScreen \ @@ -770,41 +785,12 @@ #define scrollbar_size() (scrollBar.end - scrollBar.beg \ - scrollbar_minheight ()) -#if (MENUBAR_MAX > 1) -/* rendition style flags */ -# define menuBar_height() (fheight + MENU_SHADOW) -# define menuBar_TotalHeight() (menuBar_height() + MENU_SHADOW + menuBar_margin) -# define isMenuBarWindow(w) ((w) == menuBar.win) -#else -# 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)) #else # define XPMClearArea(a, b, c, d, e, f, g) #endif -#ifdef UTMP_SUPPORT -# if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) -# undef HAVE_UTMPX_H -# undef HAVE_STRUCT_UTMPX -# endif -# if !defined(RXVT_UTMP_FILE) || !defined(HAVE_STRUCT_UTMP) -# undef HAVE_UTMP_H -# undef HAVE_STRUCT_UTMP -# endif - -# ifdef HAVE_UTMPX_H -# include -# endif -# ifdef HAVE_UTMP_H -# include -# endif -#endif - #ifdef DEBUG_CMD # define D_CMD(x) fprintf x ; fputc('\n', stderr) #else @@ -844,10 +830,6 @@ /****************************************************************************/ -#ifdef MENUBAR -# include "menubar.h" -#endif - #define BLINK_INTERVAL 0.5 #define TEXT_BLINK_INTERVAL 0.5 @@ -1040,13 +1022,6 @@ last_top, /* scrollbar last top position */ last_state, /* scrollbar last state */ scrollbar_len, -#ifdef MENUBAR - menu_readonly, /* okay to alter menu? */ - Arrows_x, -#endif -#if MENUBAR_MAX > 1 - Nbars, -#endif window_vt_x, window_vt_y, window_sb_x, @@ -1065,10 +1040,7 @@ /* ---------- */ Atom xa[NUM_XA]; /* ---------- */ -#ifdef MENUBAR - GC menubarGC; -#endif -#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) +#ifdef RXVT_SCROLLBAR GC scrollbarGC, topShadowGC, botShadowGC; @@ -1110,31 +1082,11 @@ struct mouse_event MEvent; XComposeStatus compose; ttymode_t tio; -#ifdef UTMP_SUPPORT -# ifdef HAVE_STRUCT_UTMP - struct utmp ut; -# endif -# ifdef HAVE_STRUCT_UTMPX - struct utmpx utx; -# endif -# if (defined(HAVE_STRUCT_UTMP) && defined(HAVE_UTMP_PID)) || defined(HAVE_STRUCT_UTMPX) - char ut_id[5]; -# endif - int utmp_pos; -#endif row_col_t oldcursor; #ifdef XPM_BACKGROUND bgPixmap_t bgPixmap; XpmAttributes xpmAttr; /* originally loaded pixmap and its scaling */ #endif -#ifdef MENUBAR - 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) */ -#endif #if ENABLE_OVERLAY int ov_x, ov_y, ov_w, ov_h; // overlay dimensions @@ -1172,6 +1124,8 @@ char *cmdbuf_ptr, *cmdbuf_endp; char cmdbuf_base[CBUFSIZ]; + rxvt_ptytty pty; + rxvt_salloc *talloc; // text line allocator rxvt_salloc *ralloc; // rend line allocator @@ -1191,7 +1145,12 @@ // modifies first argument(!) void paste (char *data, unsigned int len); - void flush (); + long vt_emask, vt_emask_perl; + + void vt_select_input () const + { + XSelectInput (display->display, vt, vt_emask | vt_emask_perl); + } #if TRANSPARENT void rootwin_cb (XEvent &xev); @@ -1199,14 +1158,12 @@ #endif void x_cb (XEvent &xev); + void flush (); xevent_watcher termwin_ev; xevent_watcher vt_ev; #ifdef HAVE_SCROLLBARS xevent_watcher scrollbar_ev; #endif -#ifdef MENUBAR - xevent_watcher menubar_ev; -#endif void check_cb (check_watcher &w); check_watcher check_ev; void destroy_cb (time_watcher &w); time_watcher destroy_ev; @@ -1256,6 +1213,13 @@ bool pty_fill (); + void make_current () const // make this the "currently active" urxvt instance + { + SET_R (this); + rxvt_set_locale (locale); + set_environ (envv); + } + void init_secondary (); const char **init_resources (int argc, const char *const *argv); const char *x_resource (const char *name); @@ -1339,9 +1303,6 @@ // init.C void Get_Colours (); void get_ourmods (); - // logging.C - void makeutent (const char *pty, const char *hostname); - void cleanutent (); // main.C void privileged_utmp (rxvt_privaction action); bool set_fonts (); @@ -1354,42 +1315,9 @@ int rXParseAllocColor (rxvt_color * screen_in_out, const char *colour); void set_widthheight (unsigned int newwidth, unsigned int newheight); -#ifdef MENUBAR - // menubar.C - void menuitem_free (menu_t *menu, menuitem_t *item); - int action_dispatch (action_t *action); - void menuarrow_free (char name); - void menuarrow_add (char *string); - char *menu_find_base (menu_t **menu, char *path); - menu_t *menu_delete (menu_t *menu); - menu_t *menu_add (menu_t *parent, char *path); - void drawbox_menubar (int x, int len, int state); - void drawtriangle (int x, int y, int state); - void drawbox_menuitem (int y, int state); - void menu_show (); - void menu_display (void (rxvt_term::*update) ()); - void menu_hide_all (); - void menu_hide (); - void menu_clear (menu_t *menu); - void menubar_clear (); - bar_t *menubar_find (const char *name); - int menubar_push (const char *name); - void menubar_remove (const char *name); - void menubar_dump (FILE *fp); - void menubar_read (const char *filename); - void menubar_dispatch (char *str); - void draw_Arrows (int name, int state); - void menubar_expose (); - int menubar_mapping (int map); - int menu_select (XButtonEvent &ev); - void menubar_select (XButtonEvent &ev); - void menubar_control (XButtonEvent &ev); - void map_menuBar (int map); -#endif - // screen.C - void lalloc (line_t &l) + void lalloc (line_t &l) const { l.t = (text_t *)talloc->alloc (); l.r = (rend_t *)ralloc->alloc (); @@ -1403,7 +1331,7 @@ } #endif - void lresize (line_t &l) + void lresize (line_t &l) const { if (!l.t) return; @@ -1417,7 +1345,7 @@ scr_blank_line (l, prev_ncol, ncol - prev_ncol, DEFAULT_RSTYLE); } - int fgcolor_of (rend_t r) + int fgcolor_of (rend_t r) const { int base = GET_BASEFG (r); #ifndef NO_BRIGHTCOLOR @@ -1431,7 +1359,7 @@ return base; } - int bgcolor_of (rend_t r) + int bgcolor_of (rend_t r) const { int base = GET_BASEBG (r); #ifndef NO_BRIGHTCOLOR @@ -1445,7 +1373,7 @@ return base; } - bool option (uint32_t opt) + bool option (uint32_t opt) const { return OPTION (opt); } @@ -1458,13 +1386,13 @@ options &= ~opt; } - 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); + void scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const; + void scr_blank_screen_mem (line_t &l, rend_t efs) const; int scr_scroll_text (int row1, int row2, int count); void scr_reset (); void scr_release (); void scr_clear (bool really = false); - void scr_refresh (unsigned char refresh_type); + void scr_refresh (); bool scr_refresh_rend (rend_t mask, rend_t value); void scr_erase_screen (int mode); #if ENABLE_FRILLS @@ -1505,9 +1433,9 @@ void set_font_style (); void scr_charset_choose (int set); void scr_charset_set (int set, unsigned int ch); - int scr_move_to (int y, int len); - int scr_page (enum page_dirn direction, int nlines); - int scr_changeview (unsigned int oldviewstart); + void scr_move_to (int y, int len); + bool scr_page (enum page_dirn direction, int nlines); + bool scr_changeview (int new_view_start); void scr_bell (); void scr_printscreen (int fullhist); void scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2); @@ -1538,7 +1466,6 @@ #if defined(RXVT_SCROLLBAR) // scrollbar-rxvt.C - void Draw_button (int x, int y, int state, int dirn); int scrollbar_show_rxvt (int update, int last_top, int last_bot, int scrollbar_len); #endif