From df078dd65211108ad4dcb3cc57eb81e8082dbdc0 Mon Sep 17 00:00:00 2001 From: Michael Jennings Date: Mon, 3 Mar 2003 04:53:35 +0000 Subject: Sun Mar 2 23:40:39 2003 Michael Jennings (mej) Fixed a bug with foreground/background color change pointed out by Thomas . Also added support for all the other OSC color change sequences (at least those for the colors that Eterm uses). The sequences are of the form "\e];n;color[;color[...]]\a", where n is between 10 and 19. You can specify up to (20 - n) semicolon-separated colors representing the following attributes in order: foreground, background, cursor, mouse pointer, mouse pointer background (*), Tek foreground (*), Tek background (*), highlight color (*), bold color, and underline color. Attributes marked with a (*) are ignored by Eterm and may be left empty, but their trailing semicolons must be present for xterm compatibility. For example, to set a white foreground, black background, yellow text cursor, green mouse cursor, #ffaa00 for bold, and cyan for underline, you could use either of the following: echo -e "\e]10;white;black;yellow;green;;;;;#ffaa00;cyan\007" or echo -e "\e]10;white\007" echo -e "\e]11;black\007" echo -e "\e]12;yellow\007" echo -e "\e]13;green\007" echo -e "\e]18;#ffaa00\007" echo -e "\e]19;cyan\007" Note that the setting of bold and underline colors using 18 and 19 are Eterm extensions. SVN revision: 6739 --- src/windows.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'src/windows.c') diff --git a/src/windows.c b/src/windows.c index 634251e..0b5646a 100644 --- a/src/windows.c +++ b/src/windows.c @@ -331,6 +331,26 @@ process_colors(void) stored_palette(SAVE); } +void +set_pointer_colors(const char *fg_name, const char *bg_name) +{ + XColor fg, bg; + + if (fg_name != NULL) { + fg.pixel = get_color_by_name(fg_name, COLOR_NAME(pointerColor)); + } else { + fg.pixel = PixColors[pointerColor]; + } + XQueryColor(Xdisplay, cmap, &fg); + if (bg_name != NULL) { + bg.pixel = get_color_by_name(bg_name, COLOR_NAME(bgColor)); + } else { + bg.pixel = PixColors[bgColor]; + } + XQueryColor(Xdisplay, cmap, &bg); + XRecolorCursor(Xdisplay, TermWin_cursor, &fg, &bg); +} + /* Create_Windows() - Open and map the window */ void Create_Windows(int argc, char *argv[]) @@ -409,8 +429,8 @@ Create_Windows(int argc, char *argv[]) #endif CWBackPixel | CWBorderPixel | CWColormap | CWOverrideRedirect, &Attributes); - xterm_seq(XTerm_title, rs_title); - xterm_seq(XTerm_iconName, rs_iconName); + xterm_seq(ESCSEQ_XTERM_TITLE, rs_title); + xterm_seq(ESCSEQ_XTERM_ICONNAME, rs_iconName); classHint.res_name = (char *) rs_name; classHint.res_class = APL_NAME; wmHint.window_group = TermWin.parent; @@ -431,16 +451,7 @@ Create_Windows(int argc, char *argv[]) } /* vt cursor: Black-on-White is standard, but this is more popular */ TermWin_cursor = XCreateFontCursor(Xdisplay, XC_xterm); - { - - XColor fg, bg; - - fg.pixel = PixColors[pointerColor]; - XQueryColor(Xdisplay, cmap, &fg); - bg.pixel = PixColors[bgColor]; - XQueryColor(Xdisplay, cmap, &bg); - XRecolorCursor(Xdisplay, TermWin_cursor, &fg, &bg); - } + set_pointer_colors(NULL, NULL); /* cursor (menu/scrollbar): Black-on-White */ cursor = XCreateFontCursor(Xdisplay, XC_left_ptr); @@ -704,10 +715,10 @@ set_window_color(int idx, const char *color) print_warning("Unable to resolve \"%s\" as a color name.\n", color); return; } - redraw_image(image_bg); set_colorfgbg(); scr_touch(); scr_refresh(DEFAULT_REFRESH); + redraw_image(image_bg); } #endif /* XTERM_COLOR_CHANGE */ -- cgit v1.2.1