Skip to content

Commit eedae87

Browse files
committed
Yoo, Taik-Yon: Fix and improve line number issues
1 parent f106e04 commit eedae87

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1+
2012-10-24
2+
3+
The "Thanks to Yoo, Taik-Yon!" Release
4+
5+
version 0.8.18.1.10:
6+
* Fixed: indentation is not correctly initialized.
7+
* Fixed: the color of the line number is different from GTK theme.
8+
* Improved: remove overhead when drawing line numbers.
9+
* Improved: use the clipping information of the cairo context when
10+
drawing line numbers.
11+
Thanks to Yoo, Taik-Yon <jaagar AT gmail DOT com> for changes above.
12+
113
2012-05-21
14+
215
version 0.8.18.1.9:
316
* Better compatibility with some compilers and CFLAGS
417
Thanks to Daniel Richard G. <skunk AT iSKUNK DOT ORG>

src/callback.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,12 @@ void on_option_auto_indent(void)
326326

327327
void on_help_about(void)
328328
{
329-
const gchar *copyright = "Copyright \xc2\xa9 2004-2010 Tarot Osuji\nCopyright \xc2\xa9 2011 Wen-Yen Chuang\nCopyright \xc2\xa9 2011 Jack Gandy";
329+
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";
330330
const gchar *comments = _("GTK+ based simple text editor");
331331
const gchar *authors[] = {
332332
"Tarot Osuji <tarot@sdf.lonestar.org>",
333333
"Wen-Yen Chuang <caleb@calno.com>",
334+
"Yoo, Taik-Yon <jaagar@gmail.com>",
334335
NULL
335336
};
336337
const gchar *translator_credits = _("translator-credits");

src/linenum.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* L3afpad - GTK+ based simple text editor
33
* Copyright (C) 2004-2005 Tarot Osuji
4+
* Copyright (C) 2012 Yoo, Taik-Yon <jaagar AT gmail DOT com>
45
*
56
* This program is free software; you can redistribute it and/or modify
67
* it under the terms of the GNU General Public License as published by
@@ -106,6 +107,20 @@ get_lines (GtkTextView *text_view,
106107
*countp = count;
107108
}
108109

110+
static inline PangoAttribute *
111+
line_numbers_foreground_attr_new(GtkWidget *widget)
112+
{
113+
GtkStyleContext *context;
114+
GdkRGBA rgb;
115+
116+
context = gtk_widget_get_style_context(widget);
117+
gtk_style_context_get_color(context, GTK_STATE_FLAG_NORMAL, &rgb);
118+
119+
return pango_attr_foreground_new((guint16)(rgb.red * 65535),
120+
(guint16)(rgb.green * 65535),
121+
(guint16)(rgb.blue * 65535));
122+
}
123+
109124
static gint
110125
line_numbers_expose (GtkWidget *widget, cairo_t *event)
111126
{
@@ -122,6 +137,8 @@ line_numbers_expose (GtkWidget *widget, cairo_t *event)
122137
gint i;
123138
gchar str [8]; /* we don't expect more than ten million lines */
124139

140+
cairo_rectangle_list_t *clips;
141+
125142
if (line_number_visible) {
126143

127144
text_view = GTK_TEXT_VIEW (widget);
@@ -137,17 +154,28 @@ line_numbers_expose (GtkWidget *widget, cairo_t *event)
137154
y2 = y1 + event->area.height;
138155
#endif
139156

157+
/* get origin of the clipping area. */
158+
clips = cairo_copy_clip_rectangle_list(event);
159+
160+
i = (gint)clips->rectangles[0].x;
161+
y1 = (gint)clips->rectangles[0].y;
162+
163+
cairo_rectangle_list_destroy(clips);
164+
165+
/* skip drawing if not in the line number area. */
166+
if (i >= gtk_text_view_get_border_window_size(text_view, GTK_TEXT_WINDOW_LEFT))
167+
return FALSE;
168+
140169
gtk_text_view_window_to_buffer_coords (text_view,
141170
GTK_TEXT_WINDOW_LEFT,
142171
0,
143172
y1,
144173
NULL,
145174
&y1);
146-
147175
gtk_text_view_window_to_buffer_coords (text_view,
148176
GTK_TEXT_WINDOW_LEFT,
149177
0,
150-
y2,
178+
gtk_widget_get_allocated_height(widget),
151179
NULL,
152180
&y2);
153181

@@ -199,7 +227,7 @@ DV({g_print("Painting line numbers %d - %d\n",
199227

200228
alist = pango_attr_list_new();
201229
/* TODO: should change line number color by conffile */
202-
attr = pango_attr_foreground_new(0, 0, 0);
230+
attr = line_numbers_foreground_attr_new(widget);
203231
attr->start_index = 0;
204232
attr->end_index = G_MAXUINT;
205233
pango_attr_list_insert(alist, attr);
@@ -208,8 +236,7 @@ DV({g_print("Painting line numbers %d - %d\n",
208236

209237
/* Draw fully internationalized numbers! */
210238

211-
i = 0;
212-
while (i < count) {
239+
for (i = 0; i < count; i++) {
213240
gint pos;
214241

215242
gtk_text_view_buffer_to_window_coords (text_view,
@@ -228,7 +255,6 @@ DV({g_print("Painting line numbers %d - %d\n",
228255
layout_width + justify_width + margin / 2 + 1,
229256
pos,
230257
layout);
231-
++i;
232258
}
233259

234260
g_array_free (pixels, TRUE);

src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ gint main(gint argc, gchar **argv)
286286
}
287287

288288
set_main_window_title();
289+
indent_refresh_tab_width(pub->mw->view);
289290
// hlight_apply_all(pub->mw->buffer);
290291

291292
gtk_main();

0 commit comments

Comments
 (0)