--- rxvt-unicode/src/rxvt.h 2006/01/13 05:13:09 1.202 +++ rxvt-unicode/src/rxvt.h 2006/01/19 16:22:13 1.223 @@ -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,18 +40,13 @@ #include "rxvtperl.h" -#if defined (ISO_14755) || defined (ENABLE_PERL) -# define ENABLE_OVERLAY 1 -#endif - -#if ENABLE_PERL -# define ENABLE_FRILLS -#endif - -#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 /* @@ -84,6 +96,8 @@ # define STDERR_FILENO 2 #endif +enum rxvt_privaction { IGNORE = 'i', SAVE = 's', RESTORE = 'r' };//TODO + /* ***************************************************************************** * PROTOTYPES @@ -119,8 +133,6 @@ 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); ///////////////////////////////////////////////////////////////////////////// @@ -148,18 +160,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 @@ -172,6 +176,28 @@ } bgPixmap_t; #endif +struct rxvt_ptytty { + int pty; // pty file descriptor; connected to rxvt + int tty; // tty file descriptor; connected to child + + 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 @@ -250,21 +276,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 @@ -345,10 +362,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 @@ -481,7 +497,7 @@ 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, @@ -646,14 +662,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) \ @@ -710,7 +725,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)) @@ -793,41 +809,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 @@ -867,10 +854,6 @@ /****************************************************************************/ -#ifdef MENUBAR -# include "menubar.h" -#endif - #define BLINK_INTERVAL 0.5 #define TEXT_BLINK_INTERVAL 0.5 @@ -1063,13 +1046,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, @@ -1088,10 +1064,7 @@ /* ---------- */ Atom xa[NUM_XA]; /* ---------- */ -#ifdef MENUBAR - GC menubarGC; -#endif -#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) +#ifdef RXVT_SCROLLBAR GC scrollbarGC, topShadowGC, botShadowGC; @@ -1133,31 +1106,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 @@ -1195,6 +1148,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 @@ -1216,7 +1171,7 @@ long vt_emask, vt_emask_perl; - void vt_select_input () + void vt_select_input () const { XSelectInput (display->display, vt, vt_emask | vt_emask_perl); } @@ -1233,10 +1188,8 @@ #ifdef HAVE_SCROLLBARS xevent_watcher scrollbar_ev; #endif -#ifdef MENUBAR - xevent_watcher menubar_ev; -#endif + void child_cb (child_watcher &w, int status); child_watcher child_ev; 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; @@ -1276,7 +1229,6 @@ rxvt_term (); ~rxvt_term (); - void child_exit (); // child has exited, usually destroys void destroy (); void emergency_cleanup (); @@ -1285,6 +1237,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); @@ -1368,9 +1327,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 (); @@ -1383,42 +1339,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 (); @@ -1432,7 +1355,7 @@ } #endif - void lresize (line_t &l) + void lresize (line_t &l) const { if (!l.t) return; @@ -1446,7 +1369,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 @@ -1460,7 +1383,7 @@ return base; } - int bgcolor_of (rend_t r) + int bgcolor_of (rend_t r) const { int base = GET_BASEBG (r); #ifndef NO_BRIGHTCOLOR @@ -1474,7 +1397,7 @@ return base; } - bool option (uint32_t opt) + bool option (uint32_t opt) const { return OPTION (opt); } @@ -1487,13 +1410,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 @@ -1534,9 +1457,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); @@ -1546,7 +1469,7 @@ void selection_check (int check_more); void selection_paste (Window win, Atom prop, bool delete_prop); void selection_property (Window win, Atom prop); - void selection_request (Time tm, int x, int y); + void selection_request (Time tm); int selection_request_other (Atom target, int selnum); void selection_clear (); void selection_make (Time tm); @@ -1567,7 +1490,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