[anjuta-extras] scintilla: bgo#575926 – 'Maintain past indentation' disables itself



commit 831d6ff5a78354200ba1b7f4f256b54340a343e6
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sun Aug 2 16:06:43 2009 +0200

    scintilla: bgo#575926 â?? 'Maintain past indentation' disables itself

 plugins/scintilla/aneditor-priv.h     |    1 +
 plugins/scintilla/aneditor.cxx        |   14 ++++++--------
 plugins/scintilla/aneditor.h          |    2 --
 plugins/scintilla/text_editor.c       |    5 ++++-
 plugins/scintilla/text_editor_prefs.c |    7 ++-----
 5 files changed, 13 insertions(+), 16 deletions(-)
---
diff --git a/plugins/scintilla/aneditor-priv.h b/plugins/scintilla/aneditor-priv.h
index cd3ab95..7cf6408 100644
--- a/plugins/scintilla/aneditor-priv.h
+++ b/plugins/scintilla/aneditor-priv.h
@@ -179,6 +179,7 @@ protected:
 	*/
 	
 	bool indentMaintain;
+	bool indentAutomatic;
 	/*
 	int statementLookback;
 	StyleAndWords statementIndent;
diff --git a/plugins/scintilla/aneditor.cxx b/plugins/scintilla/aneditor.cxx
index ed3f039..10ce61c 100644
--- a/plugins/scintilla/aneditor.cxx
+++ b/plugins/scintilla/aneditor.cxx
@@ -54,6 +54,7 @@ AnEditor::AnEditor(PropSetFile* p) {
 	statementLookback = 10;
 	*/
 	indentMaintain = true;
+	indentAutomatic = true;
 	
 	wrapLine = true;
 	isReadOnly = false;
@@ -1378,7 +1379,7 @@ void AnEditor::CharAdded(char ch) {
 			} else if (HandleXml(ch)) {
 				// Handled in the routine
 			} else {	// we don't have autocompetion nor calltip active
-					if (indentMaintain)
+					if (indentMaintain && indentAutomatic)
 						MaintainIndentation(ch);
 			}
 		}
@@ -1824,11 +1825,11 @@ long AnEditor::Command(int cmdID, long wParam, long lParam) {
 	case ANE_SETWRAPBOOKMARKS:
 		// Nothing to do.
 		break;
-	/*
+	
 	case ANE_SETAUTOINDENTATION:
-		// Nothing to do.
+		indentAutomatic = wParam;
 		break;
-	*/
+
 	case ANE_SETUSETABFORINDENT:
 		SendEditor(SCI_SETUSETABS, wParam);
 		break;
@@ -1851,10 +1852,7 @@ long AnEditor::Command(int cmdID, long wParam, long lParam) {
 		break;
 	*/
 	case ANE_SETINDENTMAINTAIN:
-		if (wParam)
-			props->Set ("indent.maintain.*", "1");
-		else
-			props->Set ("indent.opening.*", "0");
+		props->Set ("indent.maintain.*", wParam ? "1" : "0");
 		indentMaintain = wParam;
 		break;
 	
diff --git a/plugins/scintilla/aneditor.h b/plugins/scintilla/aneditor.h
index df5598b..939352c 100644
--- a/plugins/scintilla/aneditor.h
+++ b/plugins/scintilla/aneditor.h
@@ -113,9 +113,7 @@ extern "C" {
 #define   ANE_GOTOPOS                   (ANE_COMMAND_BASE+73)
 
 #define   ANE_SETWRAPBOOKMARKS          (ANE_COMMAND_BASE+74)
-/*
 #define   ANE_SETAUTOINDENTATION        (ANE_COMMAND_BASE+75)
-*/
 #define   ANE_SETUSETABFORINDENT        (ANE_COMMAND_BASE+76)
 #define   ANE_SETINDENTSIZE             (ANE_COMMAND_BASE+77)
 #define   ANE_SETINDENTBRACESCHECK      (ANE_COMMAND_BASE+78)
diff --git a/plugins/scintilla/text_editor.c b/plugins/scintilla/text_editor.c
index f706edb..b11a1a7 100644
--- a/plugins/scintilla/text_editor.c
+++ b/plugins/scintilla/text_editor.c
@@ -2226,10 +2226,13 @@ itext_editor_set_use_spaces (IAnjutaEditor *editor, gboolean use_spaces, GError
 							SCI_SETUSETABS, !use_spaces, 0);
 }
 
+/* This function does not set automatic indentation but allow or not
+ * the editor to indent the text. Used to disable editor indentation when
+ * another plugin take care of it. */
 static void
 itext_editor_set_auto_indent (IAnjutaEditor *editor, gboolean auto_indent, GError **e)
 {
-  text_editor_command (TEXT_EDITOR(editor), ANE_SETINDENTMAINTAIN, auto_indent, 0);
+	text_editor_command (TEXT_EDITOR(editor), ANE_SETAUTOINDENTATION, auto_indent, 0);
 }
 
 static void
diff --git a/plugins/scintilla/text_editor_prefs.c b/plugins/scintilla/text_editor_prefs.c
index 98fc15d..ccc9855 100644
--- a/plugins/scintilla/text_editor_prefs.c
+++ b/plugins/scintilla/text_editor_prefs.c
@@ -218,7 +218,7 @@ on_notify_indent_maintain (AnjutaPreferences* prefs,
 	gboolean state;
 
 	te = TEXT_EDITOR (user_data);
-	state = set_n_get_prop_int (te, INDENT_MAINTAIN);
+	state = set_n_get_prop_bool (te, INDENT_MAINTAIN);
 	text_editor_command (te, ANE_SETINDENTMAINTAIN, state, 0);
 }
 
@@ -416,10 +416,7 @@ text_editor_prefs_init (TextEditor *te)
 	
 	/* This one is special */
 	val = set_n_get_prop_bool (te, INDENT_MAINTAIN);
-	if (val)
-		sci_prop_set_int_with_key (te->props_base, INDENT_MAINTAIN".*", 1);
-	else
-		sci_prop_set_int_with_key (te->props_base, INDENT_MAINTAIN".*", 0);
+	sci_prop_set_int_with_key (te->props_base, INDENT_MAINTAIN".*", val);
 	
 	set_n_get_prop_bool (te, TAB_INDENTS);
 	set_n_get_prop_bool (te, BACKSPACE_UNINDENTS);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]