--- rxvt-unicode/src/rxvt.h 2004/02/24 16:25:45 1.42 +++ rxvt-unicode/src/rxvt.h 2004/07/26 18:01:19 1.78 @@ -5,18 +5,19 @@ #include "feature.h" +#include + #include #include #include #include +#include "encoding.h" #include "defaultfont.h" #include "rxvtcolor.h" #include "iom.h" #include "salloc.h" -#include - /* ***************************************************************************** * SYSTEM HACKS @@ -32,7 +33,6 @@ # define __sun__ #endif - #ifndef HAVE_XPOINTER typedef char *XPointer; #endif @@ -139,14 +139,6 @@ ***************************************************************************** */ -#if defined (NO_OLD_SELECTION) && defined(NO_NEW_SELECTION) -# error if you disable both selection styles, how can you select, silly? -#endif - -#define APL_CLASS "XTerm" /* class name */ -#define APL_SUBCLASS "Rxvt" /* also check resources under this name */ -#define APL_NAME "rxvt" /* normal name */ - /* COLORTERM, TERM environment variables */ #define COLORTERMENV "rxvt" #ifdef XPM_BACKGROUND @@ -155,7 +147,7 @@ # define COLORTERMENVFULL COLORTERMENV #endif #ifndef TERMENV -# define TERMENV "xterm" +# define TERMENV "rxvt" #endif #if defined (NO_MOUSE_REPORT) && !defined (NO_MOUSE_REPORT_SCROLLBAR) @@ -276,7 +268,10 @@ 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 */ +#if 0 REFRESH_BOUNDS = 1<<3 +#endif + REFRESH_BOUNDS = 0 /* only required for old int_bwidth code. */ //TODO: remove this and all depending code }; #ifdef NO_SECONDARY_SCREEN @@ -364,33 +359,34 @@ XTerm_name = 0, XTerm_iconName = 1, XTerm_title = 2, - XTerm_property = 3, /* change X property, not yet implemented */ - XTerm_Color = 4, /* change colors */ - XTerm_Color00 = 10, /* not implemented, CLASH! */ - XTerm_Color01 = 11, /* not implemented */ - XTerm_Color_cursor = 12, /* change actual 'Cursor' color */ - XTerm_Color_pointer = 13, /* change actual 'Pointer' color */ - XTerm_Color04 = 14, /* not implemented */ - XTerm_Color05 = 15, /* not implemented */ - XTerm_Color06 = 16, /* not implemented */ - XTerm_Color_RV = 17, /* change actual 'Highlight' color */ - XTerm_logfile = 46, /* not implemented */ + XTerm_property = 3, // change X property + XTerm_Color = 4, // change colors + 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_RV = 17, // change actual 'Highlight' color + XTerm_logfile = 46, // not implemented XTerm_font = 50, - XTerm_konsole30 = 30, /* reserved for konsole */ - XTerm_konsole31 = 31, /* reserved for konsole */ - XTerm_emacs51 = 51, /* reserved for emacs shell */ + XTerm_konsole30 = 30, // reserved for konsole + XTerm_konsole31 = 31, // reserved for konsole + XTerm_emacs51 = 51, // reserved for emacs shell /* * rxvt extensions of XTerm OSCs: ESC ] Ps;Pt (ST|BEL) */ - XTerm_locale = 9, /* change locale */ - XTerm_Menu = 10, /* set menu item */ - 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 */ + 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 + XTerm_locale = 701, // change locale + XTerm_findfont = 702, // find font of given character (in decimal) + XTerm_Menu = 703, // set menu item }; /* Words starting with `Color_' are colours. Others are counts */ @@ -437,7 +433,8 @@ Color_cursor, Color_cursor2, #endif - Color_pointer, + Color_pointer_fg, + Color_pointer_bg, Color_border, #ifndef NO_BOLD_UNDERLINE_REVERSE Color_BD, @@ -451,6 +448,9 @@ Color_scroll, Color_trough, #endif +#if TINTING + Color_tint, +#endif NRS_COLORS, /* */ #ifdef KEEP_SCROLLCOLOR Color_topShadow = NRS_COLORS, @@ -528,10 +528,6 @@ Rs_preeditType, Rs_inputMethod, #endif -#if defined (HOTKEY_CTRL) || defined (HOTKEY_META) - Rs_bigfont_key, - Rs_smallfont_key, -#endif #ifdef TRANSPARENT Rs_transparent, Rs_transparent_all, @@ -545,16 +541,21 @@ Rs_lineSpace, #endif Rs_cutchars, -#ifdef ACS_ASCII - Rs_acs_chars, -#endif Rs_modifier, Rs_answerbackstring, Rs_tripleclickwords, + Rs_insecure, Rs_cursorBlink, Rs_pointerBlank, Rs_pointerBlankDelay, Rs_imLocale, +#ifndef NO_SECONDARY_SCREEN + Rs_secondaryScreen, + Rs_secondaryScroll, +#endif +#ifndef NO_BOLD_UNDERLINE_REVERSE + Rs_realBold, +#endif NUM_RESOURCES }; @@ -571,6 +572,7 @@ XA_WMDELETEWINDOW, #ifdef TRANSPARENT XA_XROOTPMAPID, + XA_XSETROOTID, #endif #ifdef OFFIX_DND /* OffiX Dnd (drag 'n' drop) support */ XA_DNDPROTOCOL, @@ -602,32 +604,33 @@ #define PrivMode_smoothScroll (1LU<<18) #define PrivMode_vt52 (1LU<<19) /* too annoying to implement X11 highlight tracking */ -/* #define PrivMode_MouseX11Track (1LU<<18) */ +/* #define PrivMode_MouseX11Track (1LU<<20) */ #define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11) #define PrivMode(test,bit) \ if (test) \ PrivateModes |= (bit); \ else \ - PrivateModes &= ~ (bit) + PrivateModes &= ~(bit) #ifdef ALLOW_132_MODE -# define PrivMode_Default \ -(PrivMode_Autowrap|PrivMode_aplKP|PrivMode_ShiftKeys|PrivMode_VisibleCursor|PrivMode_132OK) +# define PrivMode_Default (PrivMode_Autowrap|PrivMode_aplKP|PrivMode_ShiftKeys|PrivMode_VisibleCursor|PrivMode_132OK) #else -# define PrivMode_Default \ -(PrivMode_Autowrap|PrivMode_aplKP|PrivMode_ShiftKeys|PrivMode_VisibleCursor) +# define PrivMode_Default (PrivMode_Autowrap|PrivMode_aplKP|PrivMode_ShiftKeys|PrivMode_VisibleCursor) #endif #define XDEPTH display->depth #define XCMAP display->cmap #define XVISUAL display->visual -#define IMBUFSIZ 128 /* input modifier buffer sizes */ -#ifndef BUFSIZ -# define BUFSIZ 4096 +#define IMBUFSIZ 128 // input modifier buffer sizes +#define KBUFSZ 512 // size of keyboard mapping buffer +#define CBUFSIZ 4096 // size of command buffer +#define UBUFSIZ 4096 // character buffer + +#ifndef PATH_MAX +# define PATH_MAX 16384 #endif -#define KBUFSZ 512 /* size of keyboard mapping buffer */ /* ***************************************************************************** @@ -651,17 +654,17 @@ #define STRRCHR(x, y) strrchr((const char *)(x), (int)(y)) /* convert pixel dimensions to row/column values. Everything as int32_t */ -#define Pixel2Col(x) Pixel2Width((int32_t)(x) - (int32_t)TermWin.int_bwidth) -#define Pixel2Row(y) Pixel2Height((int32_t)(y) - (int32_t)TermWin.int_bwidth) +#define Pixel2Col(x) Pixel2Width((int32_t)(x)) +#define Pixel2Row(y) Pixel2Height((int32_t)(y)) #define Pixel2Width(x) ((int32_t)(x) / (int32_t)TermWin.fwidth) #define Pixel2Height(y) ((int32_t)(y) / (int32_t)TermWin.fheight) -#define Col2Pixel(col) ((int32_t)Width2Pixel(col) + (int32_t)TermWin.int_bwidth) -#define Row2Pixel(row) ((int32_t)Height2Pixel(row) + (int32_t)TermWin.int_bwidth) +#define Col2Pixel(col) ((int32_t)Width2Pixel(col)) +#define Row2Pixel(row) ((int32_t)Height2Pixel(row)) #define Width2Pixel(n) ((int32_t)(n) * (int32_t)TermWin.fwidth) #define Height2Pixel(n) ((int32_t)(n) * (int32_t)TermWin.fheight) -#define TermWin_TotalWidth() ((int32_t)TermWin.width + 2 * (int32_t)TermWin.int_bwidth) -#define TermWin_TotalHeight() ((int32_t)TermWin.height + 2 * (int32_t)TermWin.int_bwidth) +#define TermWin_TotalWidth() ((int32_t)TermWin.width) +#define TermWin_TotalHeight() ((int32_t)TermWin.height) /* how to build & extract colors and attributes */ #define GET_BASEFG(x) (((x) & RS_fgMask)) @@ -807,6 +810,19 @@ # define D_X(x) #endif +extern class rxvt_failure_exception { } rxvt_failure_exception; + +typedef callback1 log_callback; + +extern void rxvt_vlog (const char *fmt, va_list arg_ptr); +extern void rxvt_log (const char *fmt, ...); +extern void rxvt_warn (const char *fmt, ...); +extern void rxvt_fatal (const char *fmt, ...) __attribute__ ((noreturn)); +extern void rxvt_exit_failure () __attribute__ ((noreturn)); + +#define SET_LOCALE(locale) rxvt_set_locale (locale) +extern bool rxvt_set_locale (const char *locale); + /* ***************************************************************************** * VARIABLES @@ -837,8 +853,48 @@ mbstate () { reset (); } }; +#if UNICODE3 +# define COMPOSE_LO 0x40000000UL +# define COMPOSE_HI 0x400fffffUL +# define IS_COMPOSE(n) ((int32_t)(n) >= COMPOSE_LO) +#else +# define COMPOSE_LO 0xd800UL +# define COMPOSE_HI 0xf8ffUL // dfff should be safer, but... +# define IS_COMPOSE(n) (COMPOSE_LO <= (n) && (n) <= COMPOSE_HI) +#endif + +#if ENABLE_COMBINING +// compose chars are used to represent composite characters +// that are not representable in unicode, as well as characters +// not fitting in the BMP. +struct compose_char { + unicode_t c1, c2; // any chars != NOCHAR are valid + compose_char (unicode_t c1, unicode_t c2) + : c1(c1), c2(c2) + { } +}; + +class rxvt_composite_vec { + vector v; +public: + text_t compose (unicode_t c1, unicode_t c2 = NOCHAR); + int expand (unicode_t c, wchar_t *r); + compose_char *operator [](text_t c) + { + return c >= COMPOSE_LO && c < COMPOSE_LO + v.size () + ? &v[c - COMPOSE_LO] + : 0; + } +}; + +extern class rxvt_composite_vec rxvt_composite; +#endif + + struct rxvt_term : rxvt_vars { - struct mbstate mbstate; + log_callback *log_hook; // log error messages through this hook, if != 0 + + struct mbstate mbstate; // current input multibyte state unsigned char want_refresh:1, #ifdef TRANSPARENT @@ -861,9 +917,8 @@ #ifdef POINTER_BLANK hidden_pointer:1, #endif - parsed_geometry:1, - seen_input:1, /* wether any input has been seen so far */ - enc_utf8:1; /* wether terminal reads/writes utf-8 */ +// enc_utf8:1, /* wether terminal reads/writes utf-8 */ + parsed_geometry:1; unsigned char refresh_type, #ifdef UTMP_SUPPORT @@ -873,38 +928,32 @@ next_tty_action, #endif #ifdef META8_OPTION - meta_char, /* Alt-key prefix */ + meta_char, /* Alt-key prefix */ #endif scrollbar_align, selection_wait, selection_type; /* ---------- */ short rvideo; - int16_t num_scr; /* screen: number lines scrolled */ - unsigned int prev_ncol, /* screen: previous number of columns */ - prev_nrow; /* screen: previous number of rows */ + int16_t num_scr; /* screen: number lines scrolled */ + unsigned 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_delay, - scroll_selection_lines; + int scroll_selection_lines; enum page_dirn scroll_selection_dir; int selection_save_x, selection_save_y, - selection_save_state, - pending_scroll_selection; + selection_save_state; #endif /* ---------- */ int csrO, /* Hops - csr offset in thumb/slider to */ /* give proper Scroll behaviour */ -#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - scroll_arrow_delay, -#endif #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) - mouse_slip_wheel_delay, mouse_slip_wheel_speed, #endif refresh_count, @@ -991,9 +1040,6 @@ #ifndef NO_DELETE_KEY const char *key_delete; #endif -#if defined (HOTKEY_CTRL) || defined (HOTKEY_META) - KeySym ks_bigfont, ks_smallfont; -#endif #ifdef USE_XIM rxvt_xim *input_method; XIC Input_Context; @@ -1038,28 +1084,32 @@ struct timeval lastmotion; #endif -/* these three don't need to be kept but do so to placate some mem checkers */ + vector allocated; // free these memory blocks with free() + char *env_windowid; /* environmental variable WINDOWID */ char *env_display; /* environmental variable DISPLAY */ char *env_term; /* environmental variable TERM */ char *env_colorfgbg; char *locale; +#if 0 char *codeset; +#endif char charsets[4]; - unsigned char *v_buffer; /* pointer to physical buffer */ - unsigned int v_buflen; /* size of area to write */ - char *newfont[MAX_NFONTS]; - stringvec *argv, *envv; /* if != 0, will be freed on destroy time */ + unsigned 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 */ #ifdef KEYSYM_RESOURCE const unsigned char *Keysym_map[256]; #endif const char *rs[NUM_RESOURCES]; -/* command input buffering */ + /* command input buffering */ unsigned char *cmdbuf_ptr, *cmdbuf_endp; - unsigned char cmdbuf_base[BUFSIZ]; + unsigned char cmdbuf_base[CBUFSIZ]; + + rxvt_salloc *talloc; // text line allocator + rxvt_salloc *ralloc; // rend line allocator - rxvt_salloc *ralloc; - rxvt_salloc *talloc; + static vector termlist; // a vector of all running rxvt_term's void paste (const unsigned char *data, unsigned int len); @@ -1092,6 +1142,16 @@ void text_blink_cb (time_watcher &w); time_watcher text_blink_ev; #endif +#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING + void cont_scroll_cb (time_watcher &w); time_watcher cont_scroll_ev; +#endif +#ifdef SELECTION_SCROLLING + void sel_scroll_cb (time_watcher &w); time_watcher sel_scroll_ev; +#endif +#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) + void slip_wheel_cb (time_watcher &w); time_watcher slip_wheel_ev; +#endif + #ifdef POINTER_BLANK void pointer_cb (time_watcher &w); time_watcher pointer_ev; void pointer_blank (); @@ -1110,8 +1170,6 @@ bool init (int argc, const char *const *argv); bool init_vars (); - uint32_t next_char (); - bool pty_fill (); void *operator new (size_t s); @@ -1125,6 +1183,7 @@ void init_command (const char *const *argv); int run_command (const char *const *argv); int run_child (const char *const *argv); + static void child_exited (int pid); void color_aliases (int idx); void recolour_cursor (); @@ -1161,7 +1220,7 @@ void scr_reset (); void scr_reset_realloc (); void scr_release (); - void scr_clear (); + void scr_clear (bool really = false); void scr_refresh (unsigned char refresh_type); bool scr_refresh_rend (rend_t mask, rend_t value); void scr_erase_screen (int mode); @@ -1175,7 +1234,12 @@ // command.C void lookup_key (XKeyEvent &ev); unsigned int cmd_write (const unsigned char *str, unsigned int count); - uint32_t cmd_getc (); + + unicode_t next_char (); + unicode_t cmd_getc (); + unicode_t next_octet (); + unicode_t cmd_get8 (); + bool cmd_parse (); void mouse_report (XButtonEvent &ev); void button_press (XButtonEvent &ev); @@ -1186,15 +1250,16 @@ int pclose_printer (FILE *stream); #endif void process_print_pipe (); - void process_nonprinting (unsigned char ch); - void process_escape_vt52 (unsigned char ch); + void process_nonprinting (unicode_t ch); + void process_escape_vt52 (unicode_t ch); void process_escape_seq (); void process_csi_seq (); void process_window_ops (const int *args, unsigned int nargs); - unsigned char * get_to_st (unsigned char *ends_how); + unsigned char *get_to_st (unicode_t &ends_how); void process_dcs_seq (); void process_osc_seq (); - void xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))); + void process_color_seq (int report, int color, const char *str, unsigned char resp); + void process_xterm_seq (int op, const char *str, unsigned char resp); int privcases (int mode, unsigned long bit); void process_terminal_mode (int mode, int priv, unsigned int nargs, const int *arg); void process_sgr_mode (unsigned int nargs, const int *arg); @@ -1212,7 +1277,7 @@ bool change_font (const char *fontname); bool font_up_down (int n, int direction); void set_title (const char *str); - void set_iconName (const char *str); + 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); @@ -1257,7 +1322,7 @@ int scr_change_screen (int scrn); void scr_color (unsigned int color, int fgbg); void scr_rendition (int set, int style); - void scr_add_lines (const uint32_t *str, int nlines, int len); + void scr_add_lines (const unicode_t *str, int nlines, int len); void scr_backspace (); void scr_tab (int count); void scr_backindex (); @@ -1339,9 +1404,6 @@ Pixmap set_bgPixmap (const char *file); }; -#define SET_LOCALE(locale) rxvt_set_locale (locale) -extern void rxvt_set_locale (const char *locale); - /* ***************************************************************************** * PROTOTYPES