SF.net SVN: geany: [2468] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Thu Apr 10 18:18:35 UTC 2008
Revision: 2468
http://geany.svn.sourceforge.net/geany/?rev=2468&view=rev
Author: eht16
Date: 2008-04-10 11:18:34 -0700 (Thu, 10 Apr 2008)
Log Message:
-----------
Make navigation queue position based to restore the line and column when returning to a previous position (closes #1936927).
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/navqueue.c
trunk/src/utils.c
trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-04-10 18:12:43 UTC (rev 2467)
+++ trunk/ChangeLog 2008-04-10 18:18:34 UTC (rev 2468)
@@ -3,9 +3,12 @@
* src/editor.c:
Fix a couple of wrong or missing checks to prevent auto completion
in comments in several filetypes.
- * scripts/create_php_tags.php, data/php.tags:
+ * THANKS, scripts/create_php_tags.php, data/php.tags:
Add script to generate PHP tags file (by Matti Mårds, thanks).
Update PHP tags file to latest PHP API docs (closes #1888691).
+ * src/navqueue.c, src/utils.c, src/utils.c:
+ Make navigation queue position based to restore the line and column
+ when returning to a previous position (closes #1936927).
2008-04-09 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
Modified: trunk/src/navqueue.c
===================================================================
--- trunk/src/navqueue.c 2008-04-10 18:12:43 UTC (rev 2467)
+++ trunk/src/navqueue.c 2008-04-10 18:18:34 UTC (rev 2468)
@@ -39,9 +39,7 @@
typedef struct
{
gchar *file; /* this is the tagmanager filename, not document::file_name */
- /** TODO maybe it is better to work on positions than on lines to be more accurate when
- * switching back or forward, sci_get_position_from_line() could be used for tm_tag lines */
- gint line; /* line is counted with 1 as the first line, not 0 */
+ gint pos;
} filepos;
static GQueue *navigation_queue;
@@ -96,29 +94,29 @@
static gboolean
-queue_pos_matches(guint queue_pos, const gchar *fname, gint line)
+queue_pos_matches(guint queue_pos, const gchar *fname, gint pos)
{
if (queue_pos < g_queue_get_length(navigation_queue))
{
filepos *fpos = g_queue_peek_nth(navigation_queue, queue_pos);
- return (utils_str_equal(fpos->file, fname) && fpos->line == line);
+ return (utils_str_equal(fpos->file, fname) && fpos->pos == pos);
}
return FALSE;
}
-static void add_new_position(gchar *tm_filename, gint line)
+static void add_new_position(gchar *tm_filename, gint pos)
{
filepos *npos;
guint i;
- if (queue_pos_matches(nav_queue_pos, tm_filename, line))
+ if (queue_pos_matches(nav_queue_pos, tm_filename, pos))
return; /* prevent duplicates */
npos = g_new0(filepos, 1);
npos->file = tm_filename;
- npos->line = line;
+ npos->pos = pos;
/* if we've jumped to a new position from inside the queue rather than going forward */
if (nav_queue_pos > 0)
@@ -141,22 +139,28 @@
* @param line is counted with 1 as the first line, not 0. */
gboolean navqueue_goto_line(gint old_idx, gint new_idx, gint line)
{
+ gint pos;
+
g_return_val_if_fail(DOC_IDX_VALID(new_idx), FALSE);
g_return_val_if_fail(line >= 1, FALSE);
+ pos = sci_get_position_from_line(doc_list[new_idx].sci, line - 1);
+
/* first add old file position */
if (DOC_IDX_VALID(old_idx) && doc_list[old_idx].tm_file)
{
- gint cur_line = sci_get_current_line(doc_list[old_idx].sci);
+ gint cur_pos = sci_get_current_position(doc_list[old_idx].sci);
- add_new_position(doc_list[old_idx].tm_file->file_name, cur_line + 1);
+ add_new_position(doc_list[old_idx].tm_file->file_name, cur_pos);
}
/* now add new file position */
if (doc_list[new_idx].tm_file)
- add_new_position(doc_list[new_idx].tm_file->file_name, line);
+ {
+ add_new_position(doc_list[new_idx].tm_file->file_name, pos);
+ }
- return utils_goto_line(new_idx, line);
+ return utils_goto_pos(new_idx, pos);
}
@@ -171,7 +175,7 @@
/* jump back */
fprev = g_queue_peek_nth(navigation_queue, nav_queue_pos + 1);
- if (utils_goto_file_line(fprev->file, TRUE, fprev->line))
+ if (utils_goto_file_pos(fprev->file, TRUE, fprev->pos))
{
nav_queue_pos++;
}
@@ -194,7 +198,7 @@
/* jump forward */
fnext = g_queue_peek_nth(navigation_queue, nav_queue_pos - 1);
- if (utils_goto_file_line(fnext->file, TRUE, fnext->line))
+ if (utils_goto_file_pos(fnext->file, TRUE, fnext->pos))
{
nav_queue_pos--;
}
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2008-04-10 18:12:43 UTC (rev 2467)
+++ trunk/src/utils.c 2008-04-10 18:18:34 UTC (rev 2468)
@@ -186,13 +186,13 @@
/* line is counted with 1 as the first line, not 0 */
-gboolean utils_goto_file_line(const gchar *file, gboolean is_tm_filename, gint line)
+gboolean utils_goto_file_pos(const gchar *file, gboolean is_tm_filename, gint pos)
{
gint file_idx = document_find_by_filename(file, is_tm_filename);
if (file_idx < 0) return FALSE;
- return utils_goto_line(file_idx, line);
+ return utils_goto_pos(file_idx, pos);
}
@@ -203,7 +203,7 @@
line--; /* the user counts lines from 1, we begin at 0 so bring the user line to our one */
- if (idx == -1 || ! doc_list[idx].is_valid || line < 0)
+ if (! DOC_IDX_VALID(idx) || line < 0)
return FALSE;
/* mark the tag */
@@ -221,6 +221,31 @@
}
+gboolean utils_goto_pos(gint idx, gint pos)
+{
+ gint page_num;
+ gint line;
+
+ if (! DOC_IDX_VALID(idx) || pos < 0)
+ return FALSE;
+
+ line = sci_get_line_from_position(doc_list[idx].sci, pos);
+
+ /* mark the tag */
+ sci_marker_delete_all(doc_list[idx].sci, 0);
+ sci_set_marker_at_line(doc_list[idx].sci, line, TRUE, 0);
+
+ sci_goto_pos(doc_list[idx].sci, pos, TRUE);
+ doc_list[idx].scroll_percent = 0.25F;
+
+ /* finally switch to the page */
+ page_num = gtk_notebook_page_num(GTK_NOTEBOOK(app->notebook), GTK_WIDGET(doc_list[idx].sci));
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), page_num);
+
+ return TRUE;
+}
+
+
/**
* Write the given @c text into a file with @c filename.
* If the file doesn't exist, it will be created.
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2008-04-10 18:12:43 UTC (rev 2467)
+++ trunk/src/utils.h 2008-04-10 18:18:34 UTC (rev 2468)
@@ -54,10 +54,12 @@
gboolean utils_is_opening_brace(gchar c, gboolean include_angles);
-gboolean utils_goto_file_line(const gchar *file, gboolean is_tm_filename, gint line);
+gboolean utils_goto_file_pos(const gchar *file, gboolean is_tm_filename, gint pos);
gboolean utils_goto_line(gint idx, gint line);
+gboolean utils_goto_pos(gint idx, gint pos);
+
gint utils_write_file(const gchar *filename, const gchar *text);
gchar *utils_find_open_xml_tag(const gchar sel[], gint size, gboolean check_tag);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list