diff options
author | Ignacio Casal Quinteiro <nacho.resa@gmail.com> | 2008-11-22 14:04:06 +0000 |
---|---|---|
committer | Ignacio Casal Quinteiro <icq@src.gnome.org> | 2008-11-22 14:04:06 +0000 |
commit | 2d6854be1a8b425a4a302ce39886c7234d43624a (patch) | |
tree | f6732bcefded8e37654f85703b035699f783d7cf | |
parent | 07c3b7ef3adf1e98bd3fe43b591c61e26847b502 (diff) | |
download | gedit-2d6854be1a8b425a4a302ce39886c7234d43624a.tar.gz |
Allow the use of "+N" and "-N" in the Move to Line entry. Fixes bug
2008-11-22 Ignacio Casal Quinteiro <nacho.resa@gmail.com>
* gedit/gedit-view.c:
Allow the use of "+N" and "-N" in the Move to Line entry.
Fixes bug #560013.
svn path=/trunk/; revision=6605
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | gedit/gedit-view.c | 41 |
2 files changed, 43 insertions, 4 deletions
@@ -1,3 +1,9 @@ +2008-11-22 Ignacio Casal Quinteiro <nacho.resa@gmail.com> + + * gedit/gedit-view.c: + Allow the use of "+N" and "-N" in the Move to Line entry. + Fixes bug #560013. + 2008-11-19 Jesse van den Kieboom <jesse@icecrew.nl> * plugins/filebrowser/gedit-file-browser-utils.c: fixed wrong use of diff --git a/gedit/gedit-view.c b/gedit/gedit-view.c index 633803585..5045b2e67 100644 --- a/gedit/gedit-view.c +++ b/gedit/gedit-view.c @@ -1253,12 +1253,24 @@ search_entry_insert_text (GtkEditable *editable, gunichar c; const gchar *p; const gchar *end; + const gchar *next; p = text; end = text + length; - while (p != end) { - const gchar *next; + if (p == end) + return; + + c = g_utf8_get_char (p); + + if (c == '-' || c == '+') + { + next = g_utf8_next_char (p); + p = next; + } + + while (p != end) + { next = g_utf8_next_char (p); c = g_utf8_get_char (p); @@ -1651,8 +1663,29 @@ search_init (GtkWidget *entry, { gboolean moved; gint line; - - line = MAX (atoi (entry_text) - 1, 0); + gint offset_line = 0; + + if (*entry_text == '-') + { + if (*(entry_text + 1) != '\0') + offset_line = MAX (atoi (entry_text + 1), 0); + + line = gtk_text_iter_get_line (&view->priv->start_search_iter) + - offset_line; + } + else if (*entry_text == '+') + { + if (*(entry_text + 1) != '\0') + offset_line = MAX (atoi (entry_text + 1), 0); + + line = gtk_text_iter_get_line (&view->priv->start_search_iter) + + offset_line; + } + else + { + line = MAX (atoi (entry_text) - 1, 0); + } + moved = gedit_document_goto_line (doc, line); gedit_view_scroll_to_cursor (view); |