[anjuta-extras/gtk3] scintilla: Fix a few functions using the removed WindowsAccessor and commented in a previous patch



commit f3a16d95a60942d91f3378563f51e1337bb17bfb
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Mon May 23 22:06:27 2011 +0200

    scintilla: Fix a few functions using the removed WindowsAccessor and commented in a previous patch

 plugins/scintilla/aneditor-indent.cxx |   16 ++++--
 plugins/scintilla/aneditor-priv.h     |    1 -
 plugins/scintilla/aneditor.cxx        |   85 +++++++++++---------------------
 plugins/scintilla/plugin.c            |    2 +-
 plugins/scintilla/style-editor.c      |    2 +-
 5 files changed, 41 insertions(+), 65 deletions(-)
---
diff --git a/plugins/scintilla/aneditor-indent.cxx b/plugins/scintilla/aneditor-indent.cxx
index 9983ac3..cb4cf00 100644
--- a/plugins/scintilla/aneditor-indent.cxx
+++ b/plugins/scintilla/aneditor-indent.cxx
@@ -90,14 +90,18 @@ int AnEditor::GetLineIndentPosition(int line) {
 }
 
 bool AnEditor::RangeIsAllWhitespace(int start, int end) {
-	//FIXME WindowAccessor acc(wEditor.GetID(), *props);
-#if 0
+	char *buffer = new char [end - start + 1];
+	bool all_white = true;
+	
+	GetRange(wEditor, start, end, buffer);
+	
 	for (int i = start;i < end;i++) {
-		if ((acc[i] != ' ') && (acc[i] != '\t'))
-			return false;
+		if ((buffer[i] != ' ') && (buffer[i] != '\t'))
+			all_white = false;
+			break;
 	}
-#endif
-	return true;
+
+	return all_white;
 }
 
 #if 0
diff --git a/plugins/scintilla/aneditor-priv.h b/plugins/scintilla/aneditor-priv.h
index b31da0c..331d5db 100644
--- a/plugins/scintilla/aneditor-priv.h
+++ b/plugins/scintilla/aneditor-priv.h
@@ -296,7 +296,6 @@ protected:
 	void ClearDocument();
 	void CountLineEnds(int &linesCR, int &linesLF, int &linesCRLF);
 	CharacterRange GetSelection();
-	void SelectionWord(char *word, int len);
 	void WordSelect();
 	void LineSelect();
 	void SelectionIntoProperties();
diff --git a/plugins/scintilla/aneditor.cxx b/plugins/scintilla/aneditor.cxx
index 7246059..3019ee1 100644
--- a/plugins/scintilla/aneditor.cxx
+++ b/plugins/scintilla/aneditor.cxx
@@ -541,12 +541,18 @@ bool AnEditor::FindMatchingBracePosition(bool editor, int &braceAtCaret, int &br
 	braceOpposite = -1;
 	char charBefore = '\0';
 	char styleBefore = '\0';
-	//FIXME WindowAccessor acc(win.GetID(), *props);
-#if 0
+	char buffer[6];
+
 	if (caretPos > 0) {
-		charBefore = acc[caretPos - 1];
-		styleBefore = static_cast<char>(acc.StyleAt(caretPos - 1) & 31);
+		GetRange (caretPos - 1, caretPos + 1, buffer, true);
+		charBefore = buffer[0];
+		styleBefore = buffer[1];
 	}
+	else
+	{
+		GetRange (caretPos, caretPos + 1, buffer + 2, true);
+	}
+	
 	// Priority goes to character before caret
 	if (charBefore && strchr("[](){}", charBefore) &&
 			((styleBefore == bracesStyleCheck) || (!bracesStyle))) {
@@ -560,8 +566,8 @@ bool AnEditor::FindMatchingBracePosition(bool editor, int &braceAtCaret, int &br
 	bool isAfter = true;
 	if (sloppy && (braceAtCaret < 0)) {
 		// No brace found so check other side
-		char charAfter = acc[caretPos];
-		char styleAfter = static_cast<char>(acc.StyleAt(caretPos) & 31);
+		char charAfter = buffer[2];
+		char styleAfter = buffer[3] & 31;
 		if (charAfter && strchr("[](){}", charAfter) && (styleAfter == bracesStyleCheck)) {
 			braceAtCaret = caretPos;
 			isAfter = false;
@@ -585,7 +591,7 @@ bool AnEditor::FindMatchingBracePosition(bool editor, int &braceAtCaret, int &br
 			isInside = !isAfter;
 		}
 	}
-#endif
+
 	return isInside;
 }
 
@@ -640,48 +646,32 @@ bool AnEditor::iswordcharforsel(char ch) {
 	return !strchr("\t\n\r !\"#$%&'()*+,-./:;<=>? [\\]^`{|}~", ch);
 }
 
-void AnEditor::SelectionWord(char *word, int len) {
-	int lengthDoc = LengthDocument();
-	CharacterRange cr = GetSelection();
-	int selStart = cr.cpMin;
-	int selEnd = cr.cpMax;
-	if (selStart == selEnd) {
-		//FIXME WindowAccessor acc(wEditor.GetID(), *props);
-#if 0
-		// Try and find a word at the caret
-		if (iswordcharforsel(acc[selStart])) {
-			while ((selStart > 0) && (iswordcharforsel(acc[selStart - 1])))
-				selStart--;
-			while ((selEnd < lengthDoc - 1) && (iswordcharforsel(acc[selEnd + 1])))
-				selEnd++;
-			if (selStart < selEnd)
-				selEnd++;   	// Because normal selections end one past
-		}
-#endif
-	}
-	word[0] = '\0';
-	if ((selStart < selEnd) && ((selEnd - selStart + 1) < len)) {
-		GetRange(wEditor, selStart, selEnd, word);
-	}
-}
-
 void AnEditor::WordSelect() {
 	int lengthDoc = LengthDocument();
 	int selStart;
 	int selEnd;
-	
+	int line; 	
+	int lineStart;
+	int lineEnd;
+	char *buffer;
+
 	selStart = selEnd = SendEditor(SCI_GETCURRENTPOS);
-	//FIXME WindowAccessor acc(wEditor.GetID(), *props);
-#if 0
-	if (iswordcharforsel(acc[selStart])) {
-			while ((selStart > 0) && (iswordcharforsel(acc[selStart - 1])))
+	line = SendEditor(SCI_LINEFROMPOSITION, selStart);
+	lineStart = SendEditor(SCI_POSITIONFROMLINE, line);
+	lineEnd = SendEditor(SCI_GETLINEENDPOSITION, line);
+
+	buffer = new char [lineEnd - lineStart + 1];
+	GetRange(wEditor, lineStart, lineEnd, buffer);
+	
+	if (iswordcharforsel(buffer[selStart - lineStart])) {
+			while ((selStart > lineStart) && (iswordcharforsel(buffer[selStart - 1 - lineStart])))
 				selStart--;
-			while ((selEnd < lengthDoc - 1) && (iswordcharforsel(acc[selEnd + 1])))
+			while ((selEnd < lineEnd - 1) && (iswordcharforsel(buffer[selEnd + 1 + lineStart])))
 				selEnd++;
 			if (selStart < selEnd)
 				selEnd++;   	// Because normal selections end one past
 	}
-#endif
+	delete []buffer;
 	SetSelection(selStart, selEnd);
 }
 
@@ -694,23 +684,6 @@ void AnEditor::LineSelect() {
 	SetSelection(lineStart, lineEnd);
 }
 
-void AnEditor::SelectionIntoProperties() {
-	CharacterRange cr = GetSelection();
-	char currentSelection[1000];
-	if ((cr.cpMin < cr.cpMax) && ((cr.cpMax - cr.cpMin + 1) < static_cast<int>(sizeof(currentSelection)))) {
-		GetRange(wEditor, cr.cpMin, cr.cpMax, currentSelection);
-		int len = strlen(currentSelection);
-		if (len > 2 && iscntrl(currentSelection[len - 1]))
-			currentSelection[len - 1] = '\0';
-		if (len > 2 && iscntrl(currentSelection[len - 2]))
-			currentSelection[len - 2] = '\0';
-		props->Set("CurrentSelection", currentSelection);
-	}
-	char word[200];
-	SelectionWord(word, sizeof(word));
-	props->Set("CurrentWord", word);
-}
-
 long AnEditor::Find (long flags, char* findWhat) {
 	if (!findWhat) return -1;
 	TextToFind ft = {{0, 0}, 0, {0, 0}};
diff --git a/plugins/scintilla/plugin.c b/plugins/scintilla/plugin.c
index 2b5f2b1..c92c8c9 100644
--- a/plugins/scintilla/plugin.c
+++ b/plugins/scintilla/plugin.c
@@ -36,7 +36,7 @@
 #include "style-editor.h"
 #include "text_editor.h"
 
-#define PREFS_GLADE PACKAGE_DATA_DIR"/glade/anjuta-editor-scintilla.ui"
+#define PREFS_GLADE PACKAGE_DATA_DIR "/glade/anjuta-editor-scintilla.ui"
 #define ICON_FILE "anjuta-editor-scintilla-plugin-48.png"
 
 gpointer parent_class;
diff --git a/plugins/scintilla/style-editor.c b/plugins/scintilla/style-editor.c
index ff54584..e4ee580 100644
--- a/plugins/scintilla/style-editor.c
+++ b/plugins/scintilla/style-editor.c
@@ -33,7 +33,7 @@
 #include "style-editor.h"
 
 #define string_assign(dest, src) g_free ((*dest)); (*dest) = g_strdup ((src));
-#define GLADE_FILE PACKAGE_DATA_DIR"/glade/anjuta-editor-scintilla.ui"
+#define GLADE_FILE PACKAGE_DATA_DIR "/glade/anjuta-editor-scintilla.ui"
 
 gchar *hilite_style[] = {
 	"Normal <Default>", "style.anjuta.normal",



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