Yoo, Taik-Yon: Fix and improve line number issues

This commit is contained in:
Wen-Yen Chuang 2012-10-24 20:44:07 +08:00
parent f106e048b1
commit eedae87768
4 changed files with 48 additions and 7 deletions

View File

@ -1,4 +1,17 @@
2012-10-24
The "Thanks to Yoo, Taik-Yon!" Release
version 0.8.18.1.10:
* Fixed: indentation is not correctly initialized.
* Fixed: the color of the line number is different from GTK theme.
* Improved: remove overhead when drawing line numbers.
* Improved: use the clipping information of the cairo context when
drawing line numbers.
Thanks to Yoo, Taik-Yon <jaagar AT gmail DOT com> for changes above.
2012-05-21 2012-05-21
version 0.8.18.1.9: version 0.8.18.1.9:
* Better compatibility with some compilers and CFLAGS * Better compatibility with some compilers and CFLAGS
Thanks to Daniel Richard G. <skunk AT iSKUNK DOT ORG> Thanks to Daniel Richard G. <skunk AT iSKUNK DOT ORG>

View File

@ -326,11 +326,12 @@ void on_option_auto_indent(void)
void on_help_about(void) void on_help_about(void)
{ {
const gchar *copyright = "Copyright \xc2\xa9 2004-2010 Tarot Osuji\nCopyright \xc2\xa9 2011 Wen-Yen Chuang\nCopyright \xc2\xa9 2011 Jack Gandy"; const gchar *copyright = "Copyright \xc2\xa9 2004-2010 Tarot Osuji\nCopyright \xc2\xa9 2011 Wen-Yen Chuang\nCopyright \xc2\xa9 2012 Yoo, Taik-Yon\nCopyright \xc2\xa9 2011 Jack Gandy";
const gchar *comments = _("GTK+ based simple text editor"); const gchar *comments = _("GTK+ based simple text editor");
const gchar *authors[] = { const gchar *authors[] = {
"Tarot Osuji <tarot@sdf.lonestar.org>", "Tarot Osuji <tarot@sdf.lonestar.org>",
"Wen-Yen Chuang <caleb@calno.com>", "Wen-Yen Chuang <caleb@calno.com>",
"Yoo, Taik-Yon <jaagar@gmail.com>",
NULL NULL
}; };
const gchar *translator_credits = _("translator-credits"); const gchar *translator_credits = _("translator-credits");

View File

@ -1,6 +1,7 @@
/* /*
* L3afpad - GTK+ based simple text editor * L3afpad - GTK+ based simple text editor
* Copyright (C) 2004-2005 Tarot Osuji * Copyright (C) 2004-2005 Tarot Osuji
* Copyright (C) 2012 Yoo, Taik-Yon <jaagar AT gmail DOT com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -106,6 +107,20 @@ get_lines (GtkTextView *text_view,
*countp = count; *countp = count;
} }
static inline PangoAttribute *
line_numbers_foreground_attr_new(GtkWidget *widget)
{
GtkStyleContext *context;
GdkRGBA rgb;
context = gtk_widget_get_style_context(widget);
gtk_style_context_get_color(context, GTK_STATE_FLAG_NORMAL, &rgb);
return pango_attr_foreground_new((guint16)(rgb.red * 65535),
(guint16)(rgb.green * 65535),
(guint16)(rgb.blue * 65535));
}
static gint static gint
line_numbers_expose (GtkWidget *widget, cairo_t *event) line_numbers_expose (GtkWidget *widget, cairo_t *event)
{ {
@ -122,6 +137,8 @@ line_numbers_expose (GtkWidget *widget, cairo_t *event)
gint i; gint i;
gchar str [8]; /* we don't expect more than ten million lines */ gchar str [8]; /* we don't expect more than ten million lines */
cairo_rectangle_list_t *clips;
if (line_number_visible) { if (line_number_visible) {
text_view = GTK_TEXT_VIEW (widget); text_view = GTK_TEXT_VIEW (widget);
@ -137,17 +154,28 @@ line_numbers_expose (GtkWidget *widget, cairo_t *event)
y2 = y1 + event->area.height; y2 = y1 + event->area.height;
#endif #endif
/* get origin of the clipping area. */
clips = cairo_copy_clip_rectangle_list(event);
i = (gint)clips->rectangles[0].x;
y1 = (gint)clips->rectangles[0].y;
cairo_rectangle_list_destroy(clips);
/* skip drawing if not in the line number area. */
if (i >= gtk_text_view_get_border_window_size(text_view, GTK_TEXT_WINDOW_LEFT))
return FALSE;
gtk_text_view_window_to_buffer_coords (text_view, gtk_text_view_window_to_buffer_coords (text_view,
GTK_TEXT_WINDOW_LEFT, GTK_TEXT_WINDOW_LEFT,
0, 0,
y1, y1,
NULL, NULL,
&y1); &y1);
gtk_text_view_window_to_buffer_coords (text_view, gtk_text_view_window_to_buffer_coords (text_view,
GTK_TEXT_WINDOW_LEFT, GTK_TEXT_WINDOW_LEFT,
0, 0,
y2, gtk_widget_get_allocated_height(widget),
NULL, NULL,
&y2); &y2);
@ -199,7 +227,7 @@ DV({g_print("Painting line numbers %d - %d\n",
alist = pango_attr_list_new(); alist = pango_attr_list_new();
/* TODO: should change line number color by conffile */ /* TODO: should change line number color by conffile */
attr = pango_attr_foreground_new(0, 0, 0); attr = line_numbers_foreground_attr_new(widget);
attr->start_index = 0; attr->start_index = 0;
attr->end_index = G_MAXUINT; attr->end_index = G_MAXUINT;
pango_attr_list_insert(alist, attr); pango_attr_list_insert(alist, attr);
@ -208,8 +236,7 @@ DV({g_print("Painting line numbers %d - %d\n",
/* Draw fully internationalized numbers! */ /* Draw fully internationalized numbers! */
i = 0; for (i = 0; i < count; i++) {
while (i < count) {
gint pos; gint pos;
gtk_text_view_buffer_to_window_coords (text_view, gtk_text_view_buffer_to_window_coords (text_view,
@ -228,7 +255,6 @@ DV({g_print("Painting line numbers %d - %d\n",
layout_width + justify_width + margin / 2 + 1, layout_width + justify_width + margin / 2 + 1,
pos, pos,
layout); layout);
++i;
} }
g_array_free (pixels, TRUE); g_array_free (pixels, TRUE);

View File

@ -286,6 +286,7 @@ gint main(gint argc, gchar **argv)
} }
set_main_window_title(); set_main_window_title();
indent_refresh_tab_width(pub->mw->view);
// hlight_apply_all(pub->mw->buffer); // hlight_apply_all(pub->mw->buffer);
gtk_main(); gtk_main();