diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-03-15 22:48:14 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-03-15 22:48:14 +0000 |
commit | f36d3693dd743d46449d3fbfd88969589a62bb38 (patch) | |
tree | 1fc29cbafb5a3f53cde9bda30f07fedc606a46ba /src/gui_gtk_x11.c | |
parent | fb26980c317c19f68e16e587fde88880e4e1e4ad (diff) | |
download | vim-git-f36d3693dd743d46449d3fbfd88969589a62bb38.tar.gz |
updated for version 7.0060
Diffstat (limited to 'src/gui_gtk_x11.c')
-rw-r--r-- | src/gui_gtk_x11.c | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index debc11bc4..819e3b491 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -2966,6 +2966,8 @@ gui_mch_init(void) gui.fgcolor = g_new0(GdkColor, 1); /* LINTED: avoid warning: conversion to 'unsigned long' */ gui.bgcolor = g_new0(GdkColor, 1); + /* LINTED: avoid warning: conversion to 'unsigned long' */ + gui.spcolor = g_new0(GdkColor, 1); /* Initialise atoms */ #ifdef FEAT_MBYTE @@ -4984,6 +4986,15 @@ gui_mch_set_bg_color(guicolor_T color) gui.bgcolor->pixel = (unsigned long)color; } +/* + * Set the current text special color. + */ + void +gui_mch_set_sp_color(guicolor_T color) +{ + gui.spcolor->pixel = (unsigned long)color; +} + #ifdef HAVE_GTK2 /* * Function-like convenience macro for the sake of efficiency. @@ -5163,6 +5174,42 @@ draw_glyph_string(int row, int col, int num_cells, int flags, #endif /* HAVE_GTK2 */ +/* + * Draw underline and undercurl at the bottom of the character cell. + */ + static void +draw_under(int flags, int row, int col, int cells) +{ + int i; + int offset; + const static int val[8] = {1, 0, 0, 0, 1, 2, 2, 2 }; + int y = FILL_Y(row + 1) - 1; + + /* Undercurl: draw curl at the bottom of the character cell. */ + if (flags & DRAW_UNDERC) + { + gdk_gc_set_foreground(gui.text_gc, gui.spcolor); + for (i = FILL_X(col); i < FILL_X(col + cells); ++i) + { + offset = val[i % 8]; + gdk_draw_point(gui.drawarea->window, gui.text_gc, i, y - offset); + } + gdk_gc_set_foreground(gui.text_gc, gui.fgcolor); + } + + /* Underline: draw a line at the bottom of the character cell. */ + if (flags & DRAW_UNDERL) + { + /* When p_linespace is 0, overwrite the bottom row of pixels. + * Otherwise put the line just below the character. */ + if (p_linespace > 1) + y -= p_linespace - 1; + gdk_draw_line(gui.drawarea->window, gui.text_gc, + FILL_X(col), y, + FILL_X(col + cells) - 1, y); + } +} + #if defined(HAVE_GTK2) || defined(PROTO) int gui_gtk2_draw_string(int row, int col, char_u *s, int len, int flags) @@ -5413,13 +5460,8 @@ not_ascii: } skipitall: - if (flags & DRAW_UNDERL) - gdk_draw_line(gui.drawarea->window, - gui.text_gc, - FILL_X(col), - FILL_Y(row + 1) - 1, - FILL_X(col + column_offset) - 1, - FILL_Y(row + 1) - 1); + /* Draw underline and undercurl. */ + draw_under(flags, row, col, column_offset); pango_glyph_string_free(glyphs); vim_free(conv_buf); @@ -5544,12 +5586,8 @@ gui_mch_draw_string(int row, int col, char_u *s, int len, int flags) TEXT_X(col) + 1, TEXT_Y(row), (const gchar *)text, textlen); - if (flags & DRAW_UNDERL) - { - gdk_draw_line(gui.drawarea->window, - gui.text_gc, FILL_X(col), - FILL_Y(row + 1) - 1, FILL_X(col + width) - 1, FILL_Y(row + 1) - 1); - } + /* Draw underline and undercurl. */ + draw_under(flags, row, col, width); } #endif /* !HAVE_GTK2 */ |