--- rxvt-unicode/src/rxvt.h 2011/04/26 16:19:45 1.440 +++ rxvt-unicode/src/rxvt.h 2012/06/01 15:49:49 1.494 @@ -1,17 +1,17 @@ #ifndef RXVT_H_ /* include once only */ #define RXVT_H_ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef HAVE_STDINT_H #include #endif #include #include -#include +#include #include #ifdef HAVE_SYS_IOCTL_H #include @@ -20,16 +20,12 @@ #include #endif -#if HAVE_CWCHAR -# include -#elif HAVE_WCHAR_H +#if HAVE_WCHAR_H # include #else // stdlib.h might provide it #endif -using namespace std; - // we assume that Xlib.h defines XPointer, and it does since at least 1994... extern "C" { @@ -76,12 +72,6 @@ #include #include -#ifdef HAVE_AFTERIMAGE -# include -# undef min -# undef max -#endif - #ifdef HAVE_PIXBUF # include #endif @@ -90,13 +80,13 @@ # define HAVE_BG_PIXMAP 1 #endif +#include #include "encoding.h" #include "rxvtutil.h" #include "rxvtfont.h" #include "rxvttoolkit.h" #include "scrollbar.h" #include "ev_cpp.h" -#include "salloc.h" #include "libptytty.h" #include "rxvtperl.h" @@ -129,10 +119,6 @@ # define EXIT_FAILURE 1 /* exit function failure */ #endif -#ifndef PATH_MAX -# define PATH_MAX 16384 -#endif - /****************************************************************************/ // exception thrown on fatal (per-instance) errors @@ -163,8 +149,8 @@ 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; +void rxvt_fatal (const char *fmt, ...) THROW ((class rxvt_failure_exception)) ecb_noreturn ecb_cold; +void rxvt_exit_failure () THROW ((class rxvt_failure_exception)) ecb_noreturn ecb_cold; char * rxvt_strtrim (char *str) NOTHROW; char ** rxvt_strsplit (char delim, const char *str) NOTHROW; @@ -224,6 +210,97 @@ } }; +#ifdef HAVE_BG_PIXMAP +struct image_effects +{ + bool tint_set; + rxvt_color tint; + int shade; + int h_blurRadius, v_blurRadius; + + image_effects () + { + tint_set = + h_blurRadius = + v_blurRadius = 0; + shade = 100; + } + + bool need_tint () + { + return shade != 100 || tint_set; + } + + bool need_blur () + { + return h_blurRadius && v_blurRadius; + } + + bool set_tint (const rxvt_color &new_tint); + bool set_shade (const char *shade_str); + bool set_blur (const char *geom); +}; + +# ifdef BG_IMAGE_FROM_FILE +enum { + IM_IS_SET = 1 << 0, + IM_IS_SIZE_SENSITIVE = 1 << 1, + IM_KEEP_ASPECT = 1 << 2, + IM_ROOT_ALIGN = 1 << 3, + IM_TILE = 1 << 4, + IM_GEOMETRY_FLAGS = IM_KEEP_ASPECT | IM_ROOT_ALIGN | IM_TILE, +}; + +enum { + noScale = 0, + windowScale = 100, + defaultScale = windowScale, + centerAlign = 50, + defaultAlign = centerAlign, +}; + +struct rxvt_image : image_effects +{ + unsigned short alpha; + uint8_t flags; + unsigned int h_scale, v_scale; /* percents of the window size */ + int h_align, v_align; /* percents of the window size: + 0 - left align, 50 - center, 100 - right */ + + bool is_size_sensitive () + { + return (!(flags & IM_TILE) + || h_scale || v_scale + || (!(flags & IM_ROOT_ALIGN) && (h_align || v_align))); + } + +# ifdef HAVE_PIXBUF + GdkPixbuf *pixbuf; + + void destroy () + { + if (pixbuf) + g_object_unref (pixbuf); + } + + int width () + { + return gdk_pixbuf_get_width (pixbuf); + } + int height () + { + return gdk_pixbuf_get_height (pixbuf); + } +# endif + + rxvt_image (); + bool set_file_geometry (const char *file); + bool set_file (const char *file); + bool set_geometry (const char *geom, bool update = false); +}; +# endif +#endif + /* ***************************************************************************** * STRUCTURES AND TYPEDEFS @@ -310,11 +387,6 @@ # define NSCREENS 1 #endif -/* special (internal) prefix for font commands */ -#define FONT_CMD '#' -#define FONT_DN "#-" -#define FONT_UP "#+" - /* flags for rxvt_term::scr_gotorc () */ enum { C_RELATIVE = 1, /* col movement is relative */ @@ -678,7 +750,7 @@ // return attributes defining the background, encoding doesn't matter // depends on RS_fgShift > RS_bgShift #define GET_BGATTR(x) \ - (expect_false ((x) & RS_RVid) \ + (ecb_unlikely ((x) & RS_RVid) \ ? (((x) & (RS_attrMask & ~RS_RVid)) \ | (((x) & RS_fgMask) >> (RS_fgShift - RS_bgShift))) \ : ((x) & (RS_attrMask | RS_bgMask))) @@ -717,6 +789,16 @@ tlen_t_ l; // length of each text line uint32_t f; // flags + bool valid () + { + return l >= 0; + } + + void alloc () + { + l = 0; + } + bool is_longer () { return f & LINE_LONGER; @@ -790,6 +872,9 @@ struct compose_char { unicode_t c1, c2; // any chars != NOCHAR are valid + #if __cplusplus >= 201103L || ECB_GCC_VERSION(4,4) + compose_char () = default; + #endif compose_char (unicode_t c1, unicode_t c2) : c1(c1), c2(c2) { } @@ -881,6 +966,8 @@ struct TermWin_t { + int vt_width; /* actual window width [pixels] */ + int vt_height; /* actual window height [pixels] */ int width; /* window width [pixels] */ int height; /* window height [pixels] */ int fwidth; /* font width [pixels] */ @@ -902,7 +989,6 @@ Window parent; /* parent identifier */ Window vt; /* vt100 window */ GC gc; /* GC for drawing */ - Pixmap pixmap; rxvt_drawable *drawable; rxvt_fontset *fontset[4]; }; @@ -992,7 +1078,8 @@ XSizeHints szHint; rxvt_color *pix_colors; Cursor TermWin_cursor; /* cursor for vt window */ - line_t *row_buf; // all lines, scrollback + terminal, circular, followed by temp_buf + + line_t *row_buf; // all lines, scrollback + terminal, circular line_t *drawn_buf; // text on screen line_t *swap_buf; // lines for swap buffer char *tabs; /* per location: 1 == tab-stop */ @@ -1039,6 +1126,7 @@ enc_utf8:1, /* whether locale uses utf-8 */ seen_input:1, /* whether we have seen some program output yet */ seen_resize:1, /* whether we had a resize event */ + init_done:1, parsed_geometry:1; unsigned char refresh_type, @@ -1082,8 +1170,6 @@ unsigned int ModLevel3Mask, ModMetaMask, ModNumLockMask; - int old_width, /* last used width in screen resize */ - old_height; /* last used height in screen resize */ unsigned long priv_modes, SavedModes; /* ---------- */ @@ -1103,77 +1189,45 @@ void bg_destroy (); enum { - //subset returned by make_transparency_pixmap - BG_IS_VALID = 1 << 0, - BG_NEEDS_TINT = 1 << 1, - BG_NEEDS_BLUR = 1 << 2, - - BG_EFFECTS_FLAGS = BG_NEEDS_TINT | BG_NEEDS_BLUR, - - BG_PROP_SCALE = 1 << 3, - BG_ROOT_ALIGN = 1 << 4, - BG_GEOMETRY_FLAGS = BG_PROP_SCALE | BG_ROOT_ALIGN, - - BG_TINT_SET = 1 << 5, - BG_TINT_BITAND = 1 << 6, - BG_TINT_FLAGS = BG_NEEDS_TINT | BG_TINT_BITAND, - - BG_HAS_RENDER = 1 << 7, - BG_HAS_RENDER_CONV = 1 << 8, - BG_CLIENT_RENDER = 1 << 9, - - BG_IS_TRANSPARENT = 1 << 10, - BG_NEEDS_REFRESH = 1 << 11, - BG_IS_SIZE_SENSITIVE = 1 << 12, - BG_IS_FROM_FILE = 1 << 13, - }; - - unsigned int bg_flags; + BG_IS_VALID = 1 << 0, -# ifdef BG_IMAGE_FROM_FILE - void get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y); - bool render_image (unsigned long tr_flags); + BG_IS_TRANSPARENT = 1 << 1, + BG_NEEDS_REFRESH = 1 << 2, - enum { - noScale = 0, - windowScale = 100, - defaultScale = windowScale, - centerAlign = 50, - defaultAlign = centerAlign, + BG_HAS_RENDER = 1 << 3, + BG_HAS_RENDER_CONV = 1 << 4, }; - unsigned int h_scale, v_scale; /* percents of the window size */ - int h_align, v_align; /* percents of the window size: - 0 - left align, 50 - center, 100 - right */ + uint8_t bg_flags; - bool bg_set_geometry (const char *geom, bool update = false); - void bg_set_default_geometry () +# ifdef BG_IMAGE_FROM_FILE + vector image_vec; + rxvt_image *new_image () { - h_scale = v_scale = defaultScale; - h_align = v_align = defaultAlign; + image_vec.resize (image_vec.size () + 1); + return &image_vec.back (); } - - bool bg_set_file (const char *file); + void get_image_geometry (rxvt_image &image, int &w, int &h, int &x, int &y); + bool render_image (rxvt_image &image); + void parse_image (int id, const char *type, const char *arg); # endif # ifdef ENABLE_TRANSPARENCY - Pixmap root_pixmap; /* current root pixmap set */ - rxvt_color tint; - int shade; - int h_blurRadius, v_blurRadius; + Pixmap root_pixmap; /* current root pixmap set */ + image_effects root_effects; - bool bg_set_transparent (); + void bg_set_transparent () + { + bg_flags |= BG_IS_TRANSPARENT; + } void bg_set_root_pixmap (); - void set_tint_shade_flags (); - bool bg_set_tint (rxvt_color &new_tint); - bool bg_set_shade (const char *shade_str); - bool bg_set_blur (const char *geom); - - bool blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height); - bool tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height); - unsigned long make_transparency_pixmap (); + bool render_root_image (); # endif + bool blur_pixmap (Pixmap pixmap, int width, int height, bool argb, int h_blurRadius, int v_blurRadius); + bool tint_pixmap (Pixmap pixmap, int width, int height, bool argb, rxvt_color &tint, bool tint_set, int shade); + void tint_ximage (XImage *ximage, rxvt_color &tint, bool tint_set, int shade); + ev_tstamp bg_valid_since; Pixmap bg_pixmap; @@ -1191,22 +1245,10 @@ bg_flags &= ~BG_IS_VALID; } #endif -#ifdef HAVE_AFTERIMAGE - ASImage *original_asim; - ASVisual *asv; - ASImageManager *asimman; - - void init_asv () - { - if (!asv) - asv = create_asvisual_for_id (dpy, display->screen, depth, XVisualIDFromVisual (visual), cmap, NULL); - } -#endif #ifdef HAVE_PIXBUF - GdkPixbuf *pixbuf; bool pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, int src_x, int src_y, int dst_x, int dst_y, - unsigned int width, unsigned int height); + unsigned int width, unsigned int height, bool argb); #endif #if ENABLE_OVERLAY @@ -1224,11 +1266,6 @@ vector allocated; // free these memory blocks with free() - 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 *locale; char charsets[4]; char *v_buffer; /* pointer to physical buffer */ @@ -1249,8 +1286,10 @@ ptytty *pty; - rxvt_salloc *talloc; // text line allocator - rxvt_salloc *ralloc; // rend line allocator + // chunk contains all line_t's as well as rend_t and text_t buffers + // for drawn_buf, swap_buf and row_buf, in this order + void *chunk; + size_t chunk_size; static vector termlist; // a vector of all running rxvt_term's @@ -1297,6 +1336,7 @@ void pty_cb (ev::io &w, int revents); ev::io pty_ev; #ifdef CURSOR_BLINK + void cursor_blink_reset (); void cursor_blink_cb (ev::timer &w, int revents); ev::timer cursor_blink_ev; #endif #ifdef TEXT_BLINK @@ -1326,12 +1366,6 @@ void tt_write (const char *data, unsigned int len); void pty_write (); - void init (stringvec *argv, stringvec *envv) - { - this->argv = argv; - init (argv->size (), argv->begin (), envv); - } - void make_current () const // make this the "currently active" urxvt instance { SET_R (this); @@ -1352,10 +1386,10 @@ void im_set_color (unsigned long &fg, unsigned long &bg); void im_set_preedit_area (XRectangle &preedit_rect, XRectangle &status_rect, const XRectangle &needed_rect); - bool IMisRunning (); - void IMSendSpot (); - bool IM_get_IC (const char *modifiers); - void IMSetPosition (); + bool im_is_running (); + void im_send_spot (); + bool im_get_ic (const char *modifiers); + void im_set_position (); #endif // command.C @@ -1398,9 +1432,11 @@ void process_terminal_mode (int mode, int priv, unsigned int nargs, const int *arg); void process_sgr_mode (unsigned int nargs, const int *arg); // init.C + void init (stringvec *argv, stringvec *envv); + void init (int argc, const char *const *argv, const char *const *envv); + void init2 (int argc, const char *const *argv); void init_vars (); const char **init_resources (int argc, const char *const *argv); - void init (int argc, const char *const *argv, stringvec *envv); void init_env (); void set_locale (const char *locale); void init_xlocale (); @@ -1428,7 +1464,7 @@ void set_title (const char *str); void set_icon_name (const char *str); void set_window_color (int idx, const char *color); - void set_colorfgbg (); + char *get_colorfgbg (); 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); @@ -1437,34 +1473,6 @@ // screen.C - void lalloc (line_t &l) const - { - l.t = (text_t *)talloc->alloc (); - l.r = (rend_t *)ralloc->alloc (); - } - -#if 0 - void lfree (line_t &l) - { - talloc->free (l.t); - ralloc->free (l.r); - } -#endif - - void lresize (line_t &l) const - { - if (!l.t) - return; - - l.t = (text_t *)talloc->alloc (l.t, prev_ncol * sizeof (text_t)); - l.r = (rend_t *)ralloc->alloc (l.r, prev_ncol * sizeof (rend_t)); - - l.l = min (l.l, ncol); - - if (ncol > prev_ncol) - scr_blank_line (l, prev_ncol, ncol - prev_ncol, DEFAULT_RSTYLE); - } - int fgcolor_of (rend_t r) const NOTHROW { int base = GET_BASEFG (r); @@ -1473,7 +1481,7 @@ # if ENABLE_STYLES && option (Opt_intensityStyles) # endif - && IN_RANGE_INC (base, minCOLOR, minBrightCOLOR)) + && IN_RANGE_EXC (base, minCOLOR, minBrightCOLOR)) base += minBrightCOLOR - minCOLOR; #endif return base; @@ -1487,7 +1495,7 @@ # if ENABLE_STYLES && option (Opt_intensityStyles) # endif - && IN_RANGE_INC (base, minCOLOR, minBrightCOLOR)) + && IN_RANGE_EXC (base, minCOLOR, minBrightCOLOR)) base += minBrightCOLOR - minCOLOR; #endif return base; @@ -1500,17 +1508,10 @@ void set_option (uint8_t opt, bool set = true) NOTHROW; - void set_privmode (unsigned bit, int set) NOTHROW - { - if (set) - priv_modes |= bit; - else - priv_modes &= ~bit; - } - // modifies first argument(!) void tt_paste (char *data, unsigned int len) NOTHROW; void paste (char *data, unsigned int len) NOTHROW; + void scr_alloc () NOTHROW; void scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW; void scr_blank_screen_mem (line_t &l, rend_t efs) const NOTHROW; void scr_kill_char (line_t &l, int col) const NOTHROW; @@ -1587,10 +1588,20 @@ void selection_rotate (int x, int y) NOTHROW; // xdefaults.C - void get_options (int argc, const char *const *argv); + const char **get_options (int argc, const char *const *argv); int parse_keysym (const char *str, const char *arg); const char *x_resource (const char *name); void extract_resources (); + void extract_keysym_resources (); + void find_resources (const char *n_prefix, const char *c_prefix, int mode, + Bool (*proc)(XrmDatabase *, XrmBindingList, XrmQuarkList, XrmRepresentation *, XrmValue *, XPointer)); + bool parse_bool_resource (const char *str) + { + return (!strcasecmp (str, "TRUE") + || !strcasecmp (str, "YES") + || !strcasecmp (str, "ON") + || !strcasecmp (str, "1")); + } }; #endif /* _RXVT_H_ */