SF.net SVN: geany: [1708] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Tue Jul 17 08:09:16 UTC 2007


Revision: 1708
          http://svn.sourceforge.net/geany/?rev=1708&view=rev
Author:   eht16
Date:     2007-07-17 01:09:15 -0700 (Tue, 17 Jul 2007)

Log Message:
-----------
Improve selection handling when decreasing indent by one space.
Avoid using SCI_DELETEBACK for simple text removal.
Fix a typo in is_doc_comment_char().	 

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/editor.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-07-16 20:16:28 UTC (rev 1707)
+++ trunk/ChangeLog	2007-07-17 08:09:15 UTC (rev 1708)
@@ -1,3 +1,11 @@
+2007-07-17  Enrico Tröger  <enrico.troeger at uvena.de>
+
+ * src/editor.c:
+   Improve selection handling when decreasing indent by one space.
+   Avoid using SCI_DELETEBACK for simple text removal.
+   Fix a typo in is_doc_comment_char().
+
+
 2007-07-16  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * src/document.c, src/editor.c:

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2007-07-16 20:16:28 UTC (rev 1707)
+++ trunk/src/editor.c	2007-07-17 08:09:15 UTC (rev 1708)
@@ -1549,8 +1549,8 @@
 						continue;
 				}
 
-				SSM(doc_list[idx].sci, SCI_GOTOPOS, line_start + x + co_len, 0);
-				for (j = 0; j < co_len; j++) SSM(doc_list[idx].sci, SCI_DELETEBACK, 0, 0);
+				SSM(doc_list[idx].sci, SCI_SETSEL, line_start + x, line_start + x + co_len);
+				sci_replace_sel(doc_list[idx].sci, "");
 				count++;
 			}
 			// use multi line comment
@@ -1952,7 +1952,7 @@
 
 static gboolean is_doc_comment_char(gchar c, gint lexer)
 {
-	if (c == '*' && (lexer = SCLEX_HTML || lexer == SCLEX_CPP))
+	if (c == '*' && (lexer == SCLEX_HTML || lexer == SCLEX_CPP))
 		return TRUE;
 	else if ((c == '*' || c == '+') && lexer == SCLEX_D)
 		return TRUE;
@@ -2415,7 +2415,7 @@
 void editor_auto_line_indentation(gint idx, gint pos)
 {
 	gint i, first_line, last_line;
-	gint first_sel_start, first_sel_end, sel_start, sel_end;
+	gint first_sel_start, first_sel_end, sel_start = 0, sel_end = 0;
 
 	g_return_if_fail(DOC_IDX_VALID(idx));
 
@@ -2450,7 +2450,7 @@
 		if (sel_start < sel_end)
 		{
 			SSM(doc_list[idx].sci, SCI_SETSEL, sel_start, sel_end);
-			SSM(doc_list[idx].sci, SCI_DELETEBACK, 0, 0);
+			sci_replace_sel(doc_list[idx].sci, "");
 		}
 		sci_insert_text(doc_list[idx].sci, sel_start, indent);
 	}
@@ -2500,8 +2500,8 @@
 
 			if (sci_get_char_at(doc_list[idx].sci, indentation_end) == ' ')
 			{
-				sci_set_current_position(doc_list[idx].sci, indentation_end + 1, FALSE);
-				SSM(doc_list[idx].sci, SCI_DELETEBACK, 0, 0);
+				SSM(doc_list[idx].sci, SCI_SETSEL, indentation_end, indentation_end + 1);
+				sci_replace_sel(doc_list[idx].sci, "");
 				count--;
 				if (i == first_line)
 					first_line_offset = -1;
@@ -2519,7 +2519,12 @@
 	// set cursor position
 	if (sel_start < sel_end)
 	{
-		sci_set_selection_start(doc_list[idx].sci, sel_start + first_line_offset);
+		gint start = sel_start + first_line_offset;
+		if (first_line_offset < 0)
+			start = MAX(sel_start + first_line_offset,
+						SSM(doc_list[idx].sci, SCI_POSITIONFROMLINE, first_line, 0));
+
+		sci_set_selection_start(doc_list[idx].sci, start);
 		sci_set_selection_end(doc_list[idx].sci, sel_end + count);
 	}
 	else


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