changeset 207:4968de555941

updated for version 7.0060
author vimboss
date Tue, 15 Mar 2005 22:48:14 +0000
parents 87857ffdbf46
children f922db5a1fb3
files src/gui_gtk_x11.c src/proto/gui_beval.pro
diffstat 2 files changed, 60 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- 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 
 
 #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, ch
 		      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 */
 
--- a/src/proto/gui_beval.pro
+++ b/src/proto/gui_beval.pro
@@ -1,11 +1,11 @@
 /* gui_beval.c */
-extern void general_beval_cb __ARGS((BalloonEval *beval, int state));
-extern BalloonEval *gui_mch_create_beval_area __ARGS((void *target, char_u *mesg, void (*mesgCB)(BalloonEval *, int), void *clientData));
-extern void gui_mch_destroy_beval_area __ARGS((BalloonEval *beval));
-extern void gui_mch_enable_beval_area __ARGS((BalloonEval *beval));
-extern void gui_mch_disable_beval_area __ARGS((BalloonEval *beval));
-extern BalloonEval *gui_mch_currently_showing_beval __ARGS((void));
-extern int get_beval_info __ARGS((BalloonEval *beval, int getword, win_T **winp, linenr_T *lnump, char_u **textp, int *colp));
-extern void gui_mch_post_balloon __ARGS((BalloonEval *beval, char_u *mesg));
-extern void gui_mch_unpost_balloon __ARGS((BalloonEval *beval));
+void general_beval_cb __ARGS((BalloonEval *beval, int state));
+BalloonEval *gui_mch_create_beval_area __ARGS((void *target, char_u *mesg, void (*mesgCB)(BalloonEval *, int), void *clientData));
+void gui_mch_destroy_beval_area __ARGS((BalloonEval *beval));
+void gui_mch_enable_beval_area __ARGS((BalloonEval *beval));
+void gui_mch_disable_beval_area __ARGS((BalloonEval *beval));
+BalloonEval *gui_mch_currently_showing_beval __ARGS((void));
+int get_beval_info __ARGS((BalloonEval *beval, int getword, win_T **winp, linenr_T *lnump, char_u **textp, int *colp));
+void gui_mch_post_balloon __ARGS((BalloonEval *beval, char_u *mesg));
+void gui_mch_unpost_balloon __ARGS((BalloonEval *beval));
 /* vim: set ft=c : */