diff options
author | RichardHitt <rbh00@netcom.com> | 2014-01-29 11:56:23 -0800 |
---|---|---|
committer | Arnavion <arnavion@gmail.com> | 2014-01-29 11:56:23 -0800 |
commit | 007f49c39f58abf6424f9a3612b025af4790f05a (patch) | |
tree | 3c18cff20c9b073aaf39f3533eb22273a32c4b93 /src/fe-gtk/xtext.c | |
parent | 6487e1b39130661afb0098e11fc1384340bc6fa7 (diff) |
Fixes #881 Fix two bugs --
gtk_xtext_find_char() adjust negative y for int typecast gtk_xtext_find_x() return out_of_bounds TRUE if line outside windodw gtk_xtext_selection_draw() recognize TRUE out_of_bounds
Diffstat (limited to 'src/fe-gtk/xtext.c')
-rw-r--r-- | src/fe-gtk/xtext.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c index 7010ac46..52751b69 100644 --- a/src/fe-gtk/xtext.c +++ b/src/fe-gtk/xtext.c @@ -857,7 +857,10 @@ gtk_xtext_find_x (GtkXText * xtext, int x, textentry * ent, int subline, indent = xtext->buffer->indent; if (line > xtext->adj->page_size || line < 0) + { + *out_of_bounds = TRUE; return 0; + } if (xtext->buffer->grid_dirty || line > 255) { @@ -890,6 +893,10 @@ gtk_xtext_find_char (GtkXText * xtext, int x, int y, int *off, int line; int subline; + /* Adjust y value for negative rounding, double to int */ + if (y < 0) + y -= xtext->fontsize; + line = (y + xtext->pixel_offset) / xtext->fontsize; ent = gtk_xtext_nth (xtext, line + (int)xtext->adj->value, &subline); if (!ent) @@ -1270,6 +1277,9 @@ gtk_xtext_selection_draw (GtkXText * xtext, GdkEventMotion * event, gboolean ren gtk_xtext_render_page (xtext); return; } + else if (tmp) { + offset_start = xtext->buffer->last_offset_start; + } ent_end = gtk_xtext_find_char (xtext, high_x, high_y, &offset_end, &tmp); if (!ent_end) @@ -1283,6 +1293,10 @@ gtk_xtext_selection_draw (GtkXText * xtext, GdkEventMotion * event, gboolean ren } offset_end = ent_end->str_len; } + else if (tmp) + { + offset_end = xtext->buffer->last_offset_end; + } /* marking less than a complete line? */ /* make sure "start" is smaller than "end" (swap them if need be) */ @@ -1317,6 +1331,11 @@ gtk_xtext_selection_draw (GtkXText * xtext, GdkEventMotion * event, gboolean ren ent = ent->next; } } + else + { + if (xtext->mark_stamp) + offset_start = 0; + } if (render) gtk_xtext_selection_render (xtext, ent_start, offset_start, ent_end, offset_end); @@ -1351,7 +1370,6 @@ gtk_xtext_scrolldown_timeout (GtkXText * xtext) return 0; } - adj->value = (int)adj->value; /* Align to line boundary */ xtext->select_start_y -= xtext->fontsize; xtext->select_start_adj++; adj->value++; @@ -1372,6 +1390,7 @@ gtk_xtext_scrollup_timeout (GtkXText * xtext) int p_y; xtext_buffer *buf = xtext->buffer; GtkAdjustment *adj = xtext->adj; + int delta_y; gdk_window_get_pointer (GTK_WIDGET (xtext)->window, 0, &p_y, 0); @@ -1384,10 +1403,16 @@ gtk_xtext_scrollup_timeout (GtkXText * xtext) return 0; } - adj->value = (int)adj->value; /* Align to line boundary */ - xtext->select_start_y += xtext->fontsize; - xtext->select_start_adj--; - adj->value--; + if (adj->value < 0) + { + delta_y = adj->value * xtext->fontsize; + adj->value = 0; + } else { + delta_y = xtext->fontsize; + adj->value--; + } + xtext->select_start_y += delta_y; + xtext->select_start_adj = adj->value; gtk_adjustment_value_changed (adj); gtk_xtext_selection_draw (xtext, NULL, TRUE); gtk_xtext_render_ents (xtext, buf->pagetop_ent->prev, buf->last_ent_end); @@ -1793,10 +1818,9 @@ gtk_xtext_unselect (GtkXText *xtext) gtk_xtext_selection_clear (xtext->buffer); /* FIXME: use jump_out on multi-line selects too! */ - gtk_xtext_render_ents (xtext, buf->last_ent_start, buf->last_ent_end); - xtext->jump_in_offset = 0; xtext->jump_out_offset = 0; + gtk_xtext_render_ents (xtext, buf->last_ent_start, buf->last_ent_end); xtext->skip_border_fills = FALSE; xtext->skip_stamp = FALSE; |