mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.0.0755: terminal window does not have colors in the GUI
Problem: Terminal window does not have colors in the GUI. Solution: Lookup the GUI color.
This commit is contained in:
parent
eeac677886
commit
26af85d97b
@ -5606,16 +5606,34 @@ gui_mch_get_color(char_u *name)
|
|||||||
return name != NULL ? gui_get_color_cmn(name) : INVALCOLOR;
|
return name != NULL ? gui_get_color_cmn(name) : INVALCOLOR;
|
||||||
#else
|
#else
|
||||||
guicolor_T color;
|
guicolor_T color;
|
||||||
GdkColor gcolor;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
color = (name != NULL) ? gui_get_color_cmn(name) : INVALCOLOR;
|
color = (name != NULL) ? gui_get_color_cmn(name) : INVALCOLOR;
|
||||||
if (color == INVALCOLOR)
|
if (color == INVALCOLOR)
|
||||||
return INVALCOLOR;
|
return INVALCOLOR;
|
||||||
|
|
||||||
gcolor.red = (guint16)(((color & 0xff0000) >> 16) / 255.0 * 65535 + 0.5);
|
return gui_mch_get_rgb_color(
|
||||||
gcolor.green = (guint16)(((color & 0xff00) >> 8) / 255.0 * 65535 + 0.5);
|
(color & 0xff0000) >> 16,
|
||||||
gcolor.blue = (guint16)((color & 0xff) / 255.0 * 65535 + 0.5);
|
(color & 0xff00) >> 8,
|
||||||
|
color & 0xff);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the Pixel value (color) for the given RGB values.
|
||||||
|
* Return INVALCOLOR for error.
|
||||||
|
*/
|
||||||
|
guicolor_T
|
||||||
|
gui_mch_get_rgb_color(int r, int g, int b)
|
||||||
|
{
|
||||||
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
|
return gui_get_rgb_color_cmn(r, g, b);
|
||||||
|
#else
|
||||||
|
GdkColor gcolor;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
gcolor.red = (guint16)(r / 255.0 * 65535 + 0.5);
|
||||||
|
gcolor.green = (guint16)(g / 255.0 * 65535 + 0.5);
|
||||||
|
gcolor.blue = (guint16)(b / 255.0 * 65535 + 0.5);
|
||||||
|
|
||||||
ret = gdk_colormap_alloc_color(gtk_widget_get_colormap(gui.drawarea),
|
ret = gdk_colormap_alloc_color(gtk_widget_get_colormap(gui.drawarea),
|
||||||
&gcolor, FALSE, TRUE);
|
&gcolor, FALSE, TRUE);
|
||||||
|
@ -3726,6 +3726,12 @@ gui_mch_get_color(char_u *name)
|
|||||||
return gui_get_color_cmn(name);
|
return gui_get_color_cmn(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guicolor_T
|
||||||
|
gui_mch_get_rgb_color(int r, int g, int b)
|
||||||
|
{
|
||||||
|
return gui_get_rgb_color_cmn(r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the current text foreground color.
|
* Set the current text foreground color.
|
||||||
*/
|
*/
|
||||||
|
@ -1986,6 +1986,12 @@ gui_mch_get_color(char_u *name)
|
|||||||
return gui_get_color_cmn(name);
|
return gui_get_color_cmn(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guicolor_T
|
||||||
|
gui_mch_get_rgb_color(int r, int g, int b)
|
||||||
|
{
|
||||||
|
return gui_get_rgb_color_cmn(r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gui_mch_set_fg_color(guicolor_T color)
|
gui_mch_set_fg_color(guicolor_T color)
|
||||||
{
|
{
|
||||||
|
@ -1597,6 +1597,12 @@ gui_mch_get_color(char_u *name)
|
|||||||
return gui_get_color_cmn(name);
|
return gui_get_color_cmn(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guicolor_T
|
||||||
|
gui_mch_get_rgb_color(int r, int g, int b)
|
||||||
|
{
|
||||||
|
return gui_get_rgb_color_cmn(r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return OK if the key with the termcap name "name" is supported.
|
* Return OK if the key with the termcap name "name" is supported.
|
||||||
*/
|
*/
|
||||||
|
@ -2272,8 +2272,6 @@ gui_mch_get_color(char_u *name)
|
|||||||
guicolor_T requested;
|
guicolor_T requested;
|
||||||
XColor available;
|
XColor available;
|
||||||
Colormap colormap;
|
Colormap colormap;
|
||||||
#define COLORSPECBUFSIZE 8 /* space enough to hold "#RRGGBB" */
|
|
||||||
char spec[COLORSPECBUFSIZE];
|
|
||||||
|
|
||||||
/* can't do this when GUI not running */
|
/* can't do this when GUI not running */
|
||||||
if (!gui.in_use || name == NULL || *name == NUL)
|
if (!gui.in_use || name == NULL || *name == NUL)
|
||||||
@ -2283,11 +2281,22 @@ gui_mch_get_color(char_u *name)
|
|||||||
if (requested == INVALCOLOR)
|
if (requested == INVALCOLOR)
|
||||||
return INVALCOLOR;
|
return INVALCOLOR;
|
||||||
|
|
||||||
vim_snprintf(spec, COLORSPECBUFSIZE, "#%.2x%.2x%.2x",
|
return gui_mch_get_rgb_color(
|
||||||
(requested & 0xff0000) >> 16,
|
(requested & 0xff0000) >> 16,
|
||||||
(requested & 0xff00) >> 8,
|
(requested & 0xff00) >> 8,
|
||||||
requested & 0xff);
|
requested & 0xff);
|
||||||
#undef COLORSPECBUFSIZE
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the Pixel value (color) for the given RGB values.
|
||||||
|
* Return INVALCOLOR for error.
|
||||||
|
*/
|
||||||
|
guicolor_T
|
||||||
|
gui_mch_get_rgb_color(int r, int g, int b)
|
||||||
|
{
|
||||||
|
char spec[8]; /* space enough to hold "#RRGGBB" */
|
||||||
|
|
||||||
|
vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b);
|
||||||
colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy));
|
colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy));
|
||||||
if (XParseColor(gui.dpy, colormap, (char *)spec, &available) != 0
|
if (XParseColor(gui.dpy, colormap, (char *)spec, &available) != 0
|
||||||
&& XAllocColor(gui.dpy, colormap, &available) != 0)
|
&& XAllocColor(gui.dpy, colormap, &available) != 0)
|
||||||
|
@ -36,6 +36,7 @@ GuiFont gui_mch_get_font(char_u *name, int report_error);
|
|||||||
char_u *gui_mch_get_fontname(GuiFont font, char_u *name);
|
char_u *gui_mch_get_fontname(GuiFont font, char_u *name);
|
||||||
void gui_mch_free_font(GuiFont font);
|
void gui_mch_free_font(GuiFont font);
|
||||||
guicolor_T gui_mch_get_color(char_u *name);
|
guicolor_T gui_mch_get_color(char_u *name);
|
||||||
|
guicolor_T gui_mch_get_rgb_color(int r, int g, int b);
|
||||||
void gui_mch_set_fg_color(guicolor_T color);
|
void gui_mch_set_fg_color(guicolor_T color);
|
||||||
void gui_mch_set_bg_color(guicolor_T color);
|
void gui_mch_set_bg_color(guicolor_T color);
|
||||||
void gui_mch_set_sp_color(guicolor_T color);
|
void gui_mch_set_sp_color(guicolor_T color);
|
||||||
@ -53,7 +54,7 @@ void gui_mch_draw_part_cursor(int w, int h, guicolor_T color);
|
|||||||
void gui_mch_update(void);
|
void gui_mch_update(void);
|
||||||
int gui_mch_wait_for_chars(long wtime);
|
int gui_mch_wait_for_chars(long wtime);
|
||||||
void gui_mch_flush(void);
|
void gui_mch_flush(void);
|
||||||
void gui_mch_clear_block(int row1, int col1, int row2, int col2);
|
void gui_mch_clear_block(int row1arg, int col1arg, int row2arg, int col2arg);
|
||||||
void gui_mch_clear_all(void);
|
void gui_mch_clear_all(void);
|
||||||
void gui_mch_delete_lines(int row, int num_lines);
|
void gui_mch_delete_lines(int row, int num_lines);
|
||||||
void gui_mch_insert_lines(int row, int num_lines);
|
void gui_mch_insert_lines(int row, int num_lines);
|
||||||
|
@ -47,6 +47,7 @@ void gui_mch_set_font(GuiFont font);
|
|||||||
int gui_mch_same_font(GuiFont f1, GuiFont f2);
|
int gui_mch_same_font(GuiFont f1, GuiFont f2);
|
||||||
void gui_mch_free_font(GuiFont font);
|
void gui_mch_free_font(GuiFont font);
|
||||||
guicolor_T gui_mch_get_color(char_u *name);
|
guicolor_T gui_mch_get_color(char_u *name);
|
||||||
|
guicolor_T gui_mch_get_rgb_color(int r, int g, int b);
|
||||||
void gui_mch_set_fg_color(guicolor_T color);
|
void gui_mch_set_fg_color(guicolor_T color);
|
||||||
void gui_mch_set_bg_color(guicolor_T color);
|
void gui_mch_set_bg_color(guicolor_T color);
|
||||||
void gui_mch_set_sp_color(guicolor_T color);
|
void gui_mch_set_sp_color(guicolor_T color);
|
||||||
|
@ -28,6 +28,7 @@ void gui_mch_setmouse(int x, int y);
|
|||||||
guicolor_T gui_mch_get_rgb(guicolor_T pixel);
|
guicolor_T gui_mch_get_rgb(guicolor_T pixel);
|
||||||
void gui_mch_new_colors(void);
|
void gui_mch_new_colors(void);
|
||||||
guicolor_T gui_mch_get_color(char_u *name);
|
guicolor_T gui_mch_get_color(char_u *name);
|
||||||
|
guicolor_T gui_mch_get_rgb_color(int r, int g, int b);
|
||||||
void gui_mch_set_fg_color(guicolor_T color);
|
void gui_mch_set_fg_color(guicolor_T color);
|
||||||
void gui_mch_set_bg_color(guicolor_T color);
|
void gui_mch_set_bg_color(guicolor_T color);
|
||||||
void gui_mch_set_sp_color(guicolor_T color);
|
void gui_mch_set_sp_color(guicolor_T color);
|
||||||
|
@ -21,6 +21,7 @@ GuiFont gui_mch_get_font(char_u *name, int giveErrorIfMissing);
|
|||||||
char_u *gui_mch_get_fontname(GuiFont font, char_u *name);
|
char_u *gui_mch_get_fontname(GuiFont font, char_u *name);
|
||||||
void gui_mch_free_font(GuiFont font);
|
void gui_mch_free_font(GuiFont font);
|
||||||
guicolor_T gui_mch_get_color(char_u *name);
|
guicolor_T gui_mch_get_color(char_u *name);
|
||||||
|
guicolor_T gui_mch_get_rgb_color(int r, int g, int b);
|
||||||
int gui_mch_haskey(char_u *name);
|
int gui_mch_haskey(char_u *name);
|
||||||
void gui_mch_beep(void);
|
void gui_mch_beep(void);
|
||||||
void gui_mch_invert_rectangle(int r, int c, int nr, int nc);
|
void gui_mch_invert_rectangle(int r, int c, int nr, int nc);
|
||||||
|
@ -25,6 +25,7 @@ GuiFontset gui_mch_get_fontset(char_u *name, int giveErrorIfMissing, int fixed_w
|
|||||||
int fontset_height(XFontSet fs);
|
int fontset_height(XFontSet fs);
|
||||||
int fontset_height2(XFontSet fs);
|
int fontset_height2(XFontSet fs);
|
||||||
guicolor_T gui_mch_get_color(char_u *name);
|
guicolor_T gui_mch_get_color(char_u *name);
|
||||||
|
guicolor_T gui_mch_get_rgb_color(int r, int g, int b);
|
||||||
void gui_mch_set_fg_color(guicolor_T color);
|
void gui_mch_set_fg_color(guicolor_T color);
|
||||||
void gui_mch_set_bg_color(guicolor_T color);
|
void gui_mch_set_bg_color(guicolor_T color);
|
||||||
void gui_mch_set_sp_color(guicolor_T color);
|
void gui_mch_set_sp_color(guicolor_T color);
|
||||||
|
@ -32,6 +32,7 @@ void hl_set_font_name(char_u *font_name);
|
|||||||
void hl_set_bg_color_name(char_u *name);
|
void hl_set_bg_color_name(char_u *name);
|
||||||
void hl_set_fg_color_name(char_u *name);
|
void hl_set_fg_color_name(char_u *name);
|
||||||
int get_cterm_attr_idx(int attr, int fg, int bg);
|
int get_cterm_attr_idx(int attr, int fg, int bg);
|
||||||
|
int get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg);
|
||||||
void clear_hl_tables(void);
|
void clear_hl_tables(void);
|
||||||
int hl_combine_attr(int char_attr, int prim_attr);
|
int hl_combine_attr(int char_attr, int prim_attr);
|
||||||
attrentry_T *syn_gui_attr2entry(int attr);
|
attrentry_T *syn_gui_attr2entry(int attr);
|
||||||
|
@ -24,7 +24,7 @@ void term_append_lines(int line_count);
|
|||||||
void term_delete_lines(int line_count);
|
void term_delete_lines(int line_count);
|
||||||
void term_set_winpos(int x, int y);
|
void term_set_winpos(int x, int y);
|
||||||
int term_get_winpos(int *x, int *y);
|
int term_get_winpos(int *x, int *y);
|
||||||
void term_set_winsize(int width, int height);
|
void term_set_winsize(int height, int width);
|
||||||
void term_fg_color(int n);
|
void term_fg_color(int n);
|
||||||
void term_bg_color(int n);
|
void term_bg_color(int n);
|
||||||
void term_fg_rgb_color(guicolor_T rgb);
|
void term_fg_rgb_color(guicolor_T rgb);
|
||||||
@ -68,4 +68,5 @@ int show_one_termcode(char_u *name, char_u *code, int printit);
|
|||||||
char_u *translate_mapping(char_u *str, int expmap);
|
char_u *translate_mapping(char_u *str, int expmap);
|
||||||
void update_tcap(int attr);
|
void update_tcap(int attr);
|
||||||
guicolor_T gui_get_color_cmn(char_u *name);
|
guicolor_T gui_get_color_cmn(char_u *name);
|
||||||
|
guicolor_T gui_get_rgb_color_cmn(int r, int g, int b);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
21
src/syntax.c
21
src/syntax.c
@ -7908,7 +7908,7 @@ do_highlight(
|
|||||||
HL_TABLE()[idx].sg_gui_fg = i;
|
HL_TABLE()[idx].sg_gui_fg = i;
|
||||||
# endif
|
# endif
|
||||||
vim_free(HL_TABLE()[idx].sg_gui_fg_name);
|
vim_free(HL_TABLE()[idx].sg_gui_fg_name);
|
||||||
if (STRCMP(arg, "NONE"))
|
if (STRCMP(arg, "NONE") != 0)
|
||||||
HL_TABLE()[idx].sg_gui_fg_name = vim_strsave(arg);
|
HL_TABLE()[idx].sg_gui_fg_name = vim_strsave(arg);
|
||||||
else
|
else
|
||||||
HL_TABLE()[idx].sg_gui_fg_name = NULL;
|
HL_TABLE()[idx].sg_gui_fg_name = NULL;
|
||||||
@ -8789,12 +8789,31 @@ get_cterm_attr_idx(int attr, int fg, int bg)
|
|||||||
{
|
{
|
||||||
attrentry_T at_en;
|
attrentry_T at_en;
|
||||||
|
|
||||||
|
vim_memset(&at_en, 0, sizeof(attrentry_T));
|
||||||
at_en.ae_attr = attr;
|
at_en.ae_attr = attr;
|
||||||
at_en.ae_u.cterm.fg_color = fg;
|
at_en.ae_u.cterm.fg_color = fg;
|
||||||
at_en.ae_u.cterm.bg_color = bg;
|
at_en.ae_u.cterm.bg_color = bg;
|
||||||
return get_attr_entry(&cterm_attr_table, &at_en);
|
return get_attr_entry(&cterm_attr_table, &at_en);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(FEAT_GUI) || defined(PROTO)
|
||||||
|
/*
|
||||||
|
* Get an attribute index for a cterm entry.
|
||||||
|
* Uses an existing entry when possible or adds one when needed.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg)
|
||||||
|
{
|
||||||
|
attrentry_T at_en;
|
||||||
|
|
||||||
|
vim_memset(&at_en, 0, sizeof(attrentry_T));
|
||||||
|
at_en.ae_attr = attr;
|
||||||
|
at_en.ae_u.gui.fg_color = fg;
|
||||||
|
at_en.ae_u.gui.bg_color = bg;
|
||||||
|
return get_attr_entry(&gui_attr_table, &at_en);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clear all highlight tables.
|
* Clear all highlight tables.
|
||||||
*/
|
*/
|
||||||
|
10
src/term.c
10
src/term.c
@ -6399,4 +6399,14 @@ gui_get_color_cmn(char_u *name)
|
|||||||
|
|
||||||
return INVALCOLOR;
|
return INVALCOLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guicolor_T
|
||||||
|
gui_get_rgb_color_cmn(int r, int g, int b)
|
||||||
|
{
|
||||||
|
guicolor_T color = RGB(r, g, b);
|
||||||
|
|
||||||
|
if (color > 0xffffff)
|
||||||
|
return INVALCOLOR;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
* while, if the terminal window is visible, the screen contents is drawn.
|
* while, if the terminal window is visible, the screen contents is drawn.
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
* - color for GUI
|
|
||||||
* - color for 'termguicolors'
|
* - color for 'termguicolors'
|
||||||
* - cursor flickers when moving the cursor
|
* - cursor flickers when moving the cursor
|
||||||
* - set buffer options to be scratch, hidden, nomodifiable, etc.
|
* - set buffer options to be scratch, hidden, nomodifiable, etc.
|
||||||
@ -720,7 +719,11 @@ cell2attr(VTermScreenCell *cell)
|
|||||||
#ifdef FEAT_GUI
|
#ifdef FEAT_GUI
|
||||||
if (gui.in_use)
|
if (gui.in_use)
|
||||||
{
|
{
|
||||||
/* TODO */
|
guicolor_T fg, bg;
|
||||||
|
|
||||||
|
fg = gui_mch_get_rgb_color(cell->fg.red, cell->fg.green, cell->fg.blue);
|
||||||
|
bg = gui_mch_get_rgb_color(cell->bg.red, cell->bg.green, cell->bg.blue);
|
||||||
|
return get_gui_attr_idx(attr, fg, bg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -769,6 +769,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
755,
|
||||||
/**/
|
/**/
|
||||||
754,
|
754,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user