SF.net SVN: geany: [1233] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Jan 27 18:45:50 UTC 2007


Revision: 1233
          http://svn.sourceforge.net/geany/?rev=1233&view=rev
Author:   eht16
Date:     2007-01-27 10:45:47 -0800 (Sat, 27 Jan 2007)

Log Message:
-----------
Fixed some scrolling issues with session files and files remotely open via the socket. Added need_scrolling flag to document struct.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/callbacks.c
    trunk/src/document.c
    trunk/src/document.h
    trunk/src/keyfile.c
    trunk/src/sci_cb.c
    trunk/src/sciwrappers.c
    trunk/src/sciwrappers.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-01-26 10:43:25 UTC (rev 1232)
+++ trunk/ChangeLog	2007-01-27 18:45:47 UTC (rev 1233)
@@ -1,3 +1,11 @@
+2007-01-27  Enrico Troeger  <enrico.troeger at uvena.de>
+
+ * src/callbacks.c, src/document.c, src/document.h, src/keyfile.c,
+   src/sci_cb.c, src/sciwrappers.c, src/sciwrappers.h:
+   Fixed some scrolling issues with session files and files remotely
+   open via the socket. Added need_scrolling flag to document struct.
+
+
 2007-01-26  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * src/document.c: Applied patch from Jeff Pohlmeyer to clear the line

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2007-01-26 10:43:25 UTC (rev 1232)
+++ trunk/src/callbacks.c	2007-01-27 18:45:47 UTC (rev 1233)
@@ -1995,10 +1995,10 @@
 		line = sci_get_current_line(doc_list[idx].sci, old_pos);
 		ind_pos = sci_get_line_indent_position(doc_list[idx].sci, line);
 
-		sci_set_current_position(doc_list[idx].sci, ind_pos);
+		sci_set_current_position(doc_list[idx].sci, ind_pos, TRUE);
 		sci_cmd(doc_list[idx].sci, SCI_TAB);
 		sci_set_current_position(doc_list[idx].sci,
-			(old_pos > ind_pos) ? old_pos + 1 : old_pos);
+			(old_pos > ind_pos) ? old_pos + 1 : old_pos, TRUE);
 	}
 }
 
@@ -2024,10 +2024,10 @@
 
 		if (ind_pos == sci_get_position_from_line(doc_list[idx].sci, line))
 			return;
-		sci_set_current_position(doc_list[idx].sci, ind_pos);
+		sci_set_current_position(doc_list[idx].sci, ind_pos, TRUE);
 		sci_cmd(doc_list[idx].sci, SCI_BACKTAB);
 		sci_set_current_position(doc_list[idx].sci,
-			(old_pos >= ind_pos) ? old_pos - 1 : old_pos);
+			(old_pos >= ind_pos) ? old_pos - 1 : old_pos, TRUE);
 	}
 }
 

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2007-01-26 10:43:25 UTC (rev 1232)
+++ trunk/src/document.c	2007-01-27 18:45:47 UTC (rev 1233)
@@ -312,6 +312,7 @@
 	this->line_breaking = app->pref_editor_line_breaking;
 	this->use_auto_indention = app->pref_editor_use_auto_indention;
 	this->has_tags = FALSE;
+	this->need_scrolling = FALSE;
 
 	treeviews_openfiles_add(new_idx);	// sets this->iter
 
@@ -740,19 +741,19 @@
 	if (cl_options.goto_line >= 0)
 	{	// goto line which was specified on command line and then undefine the line
 		sci_goto_line(doc_list[idx].sci, cl_options.goto_line - 1, TRUE);
-		sci_scroll_to_line(doc_list[idx].sci, cl_options.goto_line - 1, 0.5);
+		doc_list[idx].need_scrolling = TRUE;
 		cl_options.goto_line = -1;
 	}
 	else if (pos >= 0)
 	{
-		sci_goto_pos(doc_list[idx].sci, pos, FALSE);
-		if (reload)
-			sci_scroll_to_line(doc_list[idx].sci, -1, 0.5);
+		sci_set_current_position(doc_list[idx].sci, pos, FALSE);
+		doc_list[idx].need_scrolling = TRUE;
 	}
 	if (cl_options.goto_column >= 0)
 	{	// goto column which was specified on command line and then undefine the column
 		gint cur_pos = sci_get_current_position(doc_list[idx].sci);
-		sci_set_current_position(doc_list[idx].sci, cur_pos + cl_options.goto_column);
+		sci_set_current_position(doc_list[idx].sci, cur_pos + cl_options.goto_column, FALSE);
+		doc_list[idx].need_scrolling = TRUE;
 		cl_options.goto_column = -1;
 	}
 

Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h	2007-01-26 10:43:25 UTC (rev 1232)
+++ trunk/src/document.h	2007-01-27 18:45:47 UTC (rev 1233)
@@ -64,6 +64,8 @@
 	gboolean		 changed;
 	gboolean		 line_breaking;
 	gboolean		 use_auto_indention;
+	// whether the current position in the doc needs to be made visible on a tab switch event
+	gboolean		 need_scrolling;
 	time_t			 last_check;	// to remember the last disk check
 	time_t			 mtime;
 	GTrashStack		*undo_actions;

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2007-01-26 10:43:25 UTC (rev 1232)
+++ trunk/src/keyfile.c	2007-01-27 18:45:47 UTC (rev 1233)
@@ -588,21 +588,6 @@
 		gtk_paned_set_position(GTK_PANED(lookup_widget(app->window, "vpaned1")), vpan_position);
 	}
 
-	// now the scintilla widget pages may need scrolling in view
-	if (app->pref_main_load_session)
-	{
-		gint idx;
-		guint tabnum = 0;
-
-		while (tabnum < (guint) gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)))
-		{
-			idx = document_get_n_idx(tabnum);
-			if (idx < 0) break;
-			sci_scroll_to_line(doc_list[idx].sci, -1, 0.5F);
-			tabnum++;
-		}
-	}
-
 	// set fullscreen after initial draw so that returning to normal view is the right size.
 	// fullscreen mode is disabled by default, so act only if it is true
 	if (app->fullscreen)

Modified: trunk/src/sci_cb.c
===================================================================
--- trunk/src/sci_cb.c	2007-01-26 10:43:25 UTC (rev 1232)
+++ trunk/src/sci_cb.c	2007-01-27 18:45:47 UTC (rev 1233)
@@ -164,6 +164,12 @@
 			sci_cb_highlight_braces(sci, pos);
 
 			ui_update_statusbar(idx, pos);
+			
+			if (doc_list[idx].need_scrolling)
+			{	// scroll the document if needed because here it is already realised
+				sci_scroll_to_line(doc_list[idx].sci, -1, 0.5F);
+				doc_list[idx].need_scrolling = FALSE;
+			}		
 
 #if 0
 			/// experimental code for inverting selections
@@ -407,7 +413,7 @@
 	{
 		sci_add_text(sci, "}");
 	}
-	sci_set_current_position(sci, pos);
+	sci_set_current_position(sci, pos, TRUE);
 }
 
 
@@ -1623,7 +1629,7 @@
 	else if (count_uncommented > 0)
 	{
 		gint eol_len = (sci_get_eol_mode(doc_list[idx].sci) == SC_EOL_CRLF) ? 2 : 1;
-		sci_set_current_position(doc_list[idx].sci, sel_start - co_len - eol_len);
+		sci_set_current_position(doc_list[idx].sci, sel_start - co_len - eol_len, TRUE);
 	}
 }
 
@@ -2068,7 +2074,7 @@
 	else
 		pos += strlen(indent);
 
-	sci_set_current_position(doc_list[idx].sci, pos);
+	sci_set_current_position(doc_list[idx].sci, pos, TRUE);
 	// reset the selection
 	sci_set_anchor(doc_list[idx].sci, pos);
 }

Modified: trunk/src/sciwrappers.c
===================================================================
--- trunk/src/sciwrappers.c	2007-01-26 10:43:25 UTC (rev 1232)
+++ trunk/src/sciwrappers.c	2007-01-27 18:45:47 UTC (rev 1233)
@@ -380,9 +380,15 @@
 }
 
 
-void sci_set_current_position(ScintillaObject* sci, gint position )
+void sci_set_current_position(ScintillaObject* sci, gint position, gboolean scroll_to_caret)
 {
-	SSM(sci, SCI_GOTOPOS, position, 0);
+	if (scroll_to_caret)
+		SSM(sci, SCI_GOTOPOS, position, 0);
+	else
+	{
+		SSM(sci, SCI_SETCURRENTPOS, position, 0);
+		SSM(sci, SCI_SETANCHOR, position, 0); // to avoid creation of a selection
+	}
 }
 
 

Modified: trunk/src/sciwrappers.h
===================================================================
--- trunk/src/sciwrappers.h	2007-01-26 10:43:25 UTC (rev 1232)
+++ trunk/src/sciwrappers.h	2007-01-27 18:45:47 UTC (rev 1233)
@@ -69,7 +69,7 @@
 gint 				sci_get_line_from_position	(ScintillaObject* sci, gint position);
 gint 				sci_get_position_from_line	(ScintillaObject* sci, gint line );
 gint 				sci_get_current_position	(ScintillaObject* sci);
-void 				sci_set_current_position	(ScintillaObject* sci, gint position);
+void 				sci_set_current_position	(ScintillaObject* sci, gint position, gboolean scroll_to_caret);
 void 				sci_set_current_line		(ScintillaObject* sci, gint line);
 
 void 				sci_cut						(ScintillaObject* sci);


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