SF.net SVN: geany:[4327] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Fri Oct 16 12:13:02 UTC 2009


Revision: 4327
          http://geany.svn.sourceforge.net/geany/?rev=4327&view=rev
Author:   ntrel
Date:     2009-10-16 12:13:01 +0000 (Fri, 16 Oct 2009)

Log Message:
-----------
Improve word part autocompletion so AC list is not cancelled and
reshown (this also stops the selection changing).
Add SCI_AUTOCGETCURRENTTEXT message (will be sent upstream).
Merge Scintilla.h, Scintilla.iface from upstream.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/scintilla/ScintillaBase.cxx
    trunk/scintilla/ScintillaBase.h
    trunk/scintilla/include/Scintilla.h
    trunk/scintilla/include/Scintilla.iface
    trunk/src/editor.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-10-16 11:07:49 UTC (rev 4326)
+++ trunk/ChangeLog	2009-10-16 12:13:01 UTC (rev 4327)
@@ -2,6 +2,13 @@
 
  * src/sciwrappers.c:
    Remove unnecessary line number margin padding.
+ * scintilla/include/Scintilla.h, scintilla/include/Scintilla.iface,
+   scintilla/ScintillaBase.h, scintilla/ScintillaBase.cxx,
+   src/editor.c:
+   Improve word part autocompletion so AC list is not cancelled and
+   reshown (this also stops the selection changing).
+   Add SCI_AUTOCGETCURRENTTEXT message (will be sent upstream).
+   Merge Scintilla.h, Scintilla.iface from upstream.
 
 
 2009-10-16  Lex Trotman  <elextr(at)gmail(dot)com>

Modified: trunk/scintilla/ScintillaBase.cxx
===================================================================
--- trunk/scintilla/ScintillaBase.cxx	2009-10-16 11:07:49 UTC (rev 4326)
+++ trunk/scintilla/ScintillaBase.cxx	2009-10-16 12:13:01 UTC (rev 4327)
@@ -392,6 +392,23 @@
 	return ac.lb->GetSelection();
 }
 
+int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) {
+	if (ac.Active()) {
+		int item = ac.lb->GetSelection();
+		char selected[1000];
+		selected[0] = '\0';
+		if (item != -1) {
+			ac.lb->GetValue(item, selected, sizeof(selected));
+			if (buffer != NULL)
+				strcpy(buffer, selected);
+			return strlen(selected);
+		}
+	}
+	if (buffer != NULL)
+		*buffer = '\0';
+	return 0;
+}
+
 void ScintillaBase::CallTipShow(Point pt, const char *defn) {
 	ac.Cancel();
 	pt.y += vs.lineHeight;
@@ -564,6 +581,9 @@
 	case SCI_AUTOCGETCURRENT:
 		return AutoCompleteGetCurrent();
 
+	case SCI_AUTOCGETCURRENTTEXT:
+		return AutoCompleteGetCurrentText(reinterpret_cast<char *>(lParam));
+
 	case SCI_AUTOCSETCANCELATSTART:
 		ac.cancelAtStartPos = wParam != 0;
 		break;

Modified: trunk/scintilla/ScintillaBase.h
===================================================================
--- trunk/scintilla/ScintillaBase.h	2009-10-16 11:07:49 UTC (rev 4326)
+++ trunk/scintilla/ScintillaBase.h	2009-10-16 12:13:01 UTC (rev 4327)
@@ -73,6 +73,7 @@
 	void AutoCompleteCancel();
 	void AutoCompleteMove(int delta);
 	int AutoCompleteGetCurrent();
+	int AutoCompleteGetCurrentText(char *buffer);
 	void AutoCompleteCharacterAdded(char ch);
 	void AutoCompleteCharacterDeleted();
 	void AutoCompleteCompleted(char key = '\0');

Modified: trunk/scintilla/include/Scintilla.h
===================================================================
--- trunk/scintilla/include/Scintilla.h	2009-10-16 11:07:49 UTC (rev 4326)
+++ trunk/scintilla/include/Scintilla.h	2009-10-16 12:13:01 UTC (rev 4327)
@@ -15,6 +15,10 @@
 typedef BOOL bool;
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if PLAT_WIN
 /* Return false on failure: */
 bool Scintilla_RegisterClasses(void *hInstance);
@@ -22,6 +26,10 @@
 #endif
 int Scintilla_LinkLexers();
 
+#ifdef __cplusplus
+}
+#endif
+
 /* Here should be placed typedefs for uptr_t, an unsigned integer type large enough to
  * hold a pointer and sptr_t, a signed integer large enough to hold a pointer.
  * May need to be changed for 64 bit platforms. */
@@ -254,6 +262,8 @@
 #define SCI_INDICGETUNDER 2511
 #define SCI_SETWHITESPACEFORE 2084
 #define SCI_SETWHITESPACEBACK 2085
+#define SCI_SETWHITESPACESIZE 2086
+#define SCI_GETWHITESPACESIZE 2087
 #define SCI_SETSTYLEBITS 2090
 #define SCI_GETSTYLEBITS 2091
 #define SCI_SETLINESTATE 2092
@@ -617,6 +627,7 @@
 #define SC_SEL_STREAM 0
 #define SC_SEL_RECTANGLE 1
 #define SC_SEL_LINES 2
+#define SC_SEL_THIN 3
 #define SCI_SETSELECTIONMODE 2422
 #define SCI_GETSELECTIONMODE 2423
 #define SCI_GETLINESELSTARTPOSITION 2424
@@ -641,6 +652,7 @@
 #define SCI_SETWHITESPACECHARS 2443
 #define SCI_SETCHARSDEFAULT 2444
 #define SCI_AUTOCGETCURRENT 2445
+#define SCI_AUTOCGETCURRENTTEXT 2610
 #define SCI_ALLOCATE 2446
 #define SCI_TARGETASUTF8 2447
 #define SCI_SETLENGTHFORENCODE 2448
@@ -713,6 +725,55 @@
 #define SCI_ADDUNDOACTION 2560
 #define SCI_CHARPOSITIONFROMPOINT 2561
 #define SCI_CHARPOSITIONFROMPOINTCLOSE 2562
+#define SCI_SETMULTIPLESELECTION 2563
+#define SCI_GETMULTIPLESELECTION 2564
+#define SCI_SETADDITIONALSELECTIONTYPING 2565
+#define SCI_GETADDITIONALSELECTIONTYPING 2566
+#define SCI_SETADDITIONALCARETSBLINK 2567
+#define SCI_GETADDITIONALCARETSBLINK 2568
+#define SCI_SETADDITIONALCARETSVISIBLE 2608
+#define SCI_GETADDITIONALCARETSVISIBLE 2609
+#define SCI_GETSELECTIONS 2570
+#define SCI_CLEARSELECTIONS 2571
+#define SCI_SETSELECTION 2572
+#define SCI_ADDSELECTION 2573
+#define SCI_SETMAINSELECTION 2574
+#define SCI_GETMAINSELECTION 2575
+#define SCI_SETSELECTIONNCARET 2576
+#define SCI_GETSELECTIONNCARET 2577
+#define SCI_SETSELECTIONNANCHOR 2578
+#define SCI_GETSELECTIONNANCHOR 2579
+#define SCI_SETSELECTIONNCARETVIRTUALSPACE 2580
+#define SCI_GETSELECTIONNCARETVIRTUALSPACE 2581
+#define SCI_SETSELECTIONNANCHORVIRTUALSPACE 2582
+#define SCI_GETSELECTIONNANCHORVIRTUALSPACE 2583
+#define SCI_SETSELECTIONNSTART 2584
+#define SCI_GETSELECTIONNSTART 2585
+#define SCI_SETSELECTIONNEND 2586
+#define SCI_GETSELECTIONNEND 2587
+#define SCI_SETRECTANGULARSELECTIONCARET 2588
+#define SCI_GETRECTANGULARSELECTIONCARET 2589
+#define SCI_SETRECTANGULARSELECTIONANCHOR 2590
+#define SCI_GETRECTANGULARSELECTIONANCHOR 2591
+#define SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE 2592
+#define SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE 2593
+#define SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE 2594
+#define SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE 2595
+#define SCVS_NONE 0
+#define SCVS_RECTANGULARSELECTION 1
+#define SCVS_USERACCESSIBLE 2
+#define SCI_SETVIRTUALSPACEOPTIONS 2596
+#define SCI_GETVIRTUALSPACEOPTIONS 2597
+#define SCI_SETRECTANGULARSELECTIONMODIFIER 2598
+#define SCI_GETRECTANGULARSELECTIONMODIFIER 2599
+#define SCI_SETADDITIONALSELFORE 2600
+#define SCI_SETADDITIONALSELBACK 2601
+#define SCI_SETADDITIONALSELALPHA 2602
+#define SCI_GETADDITIONALSELALPHA 2603
+#define SCI_SETADDITIONALCARETFORE 2604
+#define SCI_GETADDITIONALCARETFORE 2605
+#define SCI_ROTATESELECTION 2606
+#define SCI_SWAPMAINANCHORCARET 2607
 #define SCI_STARTRECORD 3001
 #define SCI_STOPRECORD 3002
 #define SCI_SETLEXER 4001
@@ -774,6 +835,7 @@
 #define SCMOD_SHIFT 1
 #define SCMOD_CTRL 2
 #define SCMOD_ALT 4
+#define SCMOD_SUPER 8
 #define SCN_STYLENEEDED 2000
 #define SCN_CHARADDED 2001
 #define SCN_SAVEPOINTREACHED 2002

Modified: trunk/scintilla/include/Scintilla.iface
===================================================================
--- trunk/scintilla/include/Scintilla.iface	2009-10-16 11:07:49 UTC (rev 4326)
+++ trunk/scintilla/include/Scintilla.iface	2009-10-16 12:13:01 UTC (rev 4327)
@@ -477,10 +477,10 @@
 # Set a style to be a hotspot or not.
 set void StyleSetHotSpot=2409(int style, bool hotspot)
 
-# Set the foreground colour of the selection and whether to use this setting.
+# Set the foreground colour of the main and additional selections and whether to use this setting.
 fun void SetSelFore=2067(bool useSetting, colour fore)
 
-# Set the background colour of the selection and whether to use this setting.
+# Set the background colour of the main and additional selections and whether to use this setting.
 fun void SetSelBack=2068(bool useSetting, colour back)
 
 # Get the alpha of the selection.
@@ -571,6 +571,12 @@
 # Set the background colour of all whitespace and whether to use this setting.
 fun void SetWhitespaceBack=2085(bool useSetting, colour back)
 
+# Set the size of the dots used to mark space characters.
+fun void SetWhitespaceSize=2086(int size,)
+
+# Get the size of the dots used to mark space characters.
+fun void GetWhitespaceSize=2087(,)
+
 # Divide each styling byte into lexical class bits (default: 5) and indicator
 # bits (default: 3). If a lexer requires more than 32 lexical states, then this
 # is used to expand the possible states.
@@ -1637,8 +1643,9 @@
 val SC_SEL_STREAM=0
 val SC_SEL_RECTANGLE=1
 val SC_SEL_LINES=2
+val SC_SEL_THIN=3
 
-# Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
+# Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or
 # by lines (SC_SEL_LINES).
 set void SetSelectionMode=2422(int mode,)
 
@@ -1717,6 +1724,10 @@
 # Get currently selected item position in the auto-completion list
 fun int AutoCGetCurrent=2445(,)
 
+# Get currently selected item text in the auto-completion list
+# Returns the length of the item text
+fun int AutoCGetCurrentText=2610(, stringresult s)
+
 # Enlarge the document to a particular size of text bytes.
 fun void Allocate=2446(int bytes,)
 
@@ -1926,6 +1937,122 @@
 # Return INVALID_POSITION if not close to text.
 fun position CharPositionFromPointClose=2562(int x, int y)
 
+# Set whether multiple selections can be made
+set void SetMultipleSelection=2563(bool multipleSelection,)
+
+# Whether multiple selections can be made
+get bool GetMultipleSelection=2564(,)
+
+# Set whether typing can be performed into multiple selections
+set void SetAdditionalSelectionTyping=2565(bool additionalSelectionTyping,)
+
+# Whether typing can be performed into multiple selections
+get bool GetAdditionalSelectionTyping=2566(,)
+
+# Set whether additional carets will blink
+set void SetAdditionalCaretsBlink=2567(bool additionalCaretsBlink,)
+
+# Whether additional carets will blink
+get bool GetAdditionalCaretsBlink=2568(,)
+
+# Set whether additional carets are visible
+set void SetAdditionalCaretsVisible=2608(bool additionalCaretsBlink,)
+
+# Whether additional carets are visible
+get bool GetAdditionalCaretsVisible=2609(,)
+
+# How many selections are there?
+get int GetSelections=2570(,)
+
+# Clear selections to a single empty stream selection
+fun void ClearSelections=2571(,)
+
+# Set a simple selection
+fun int SetSelection=2572(int caret,int anchor)
+
+# Add a selection
+fun int AddSelection=2573(int caret,int anchor)
+
+# Set the main selection
+set void SetMainSelection=2574(int selection,)
+
+# Which selection is the main selection
+get int GetMainSelection=2575(,)
+
+set void SetSelectionNCaret=2576(int selection, position pos)
+get position GetSelectionNCaret=2577(int selection,)
+set void SetSelectionNAnchor=2578(int selection, position posAnchor)
+get position GetSelectionNAnchor=2579(int selection,)
+set void SetSelectionNCaretVirtualSpace=2580(int selection, int space)
+get int GetSelectionNCaretVirtualSpace=2581(int selection,)
+set void SetSelectionNAnchorVirtualSpace=2582(int selection, int space)
+get int GetSelectionNAnchorVirtualSpace=2583(int selection,)
+
+# Sets the position that starts the selection - this becomes the anchor.
+set void SetSelectionNStart=2584(int selection, position pos)
+
+# Returns the position at the start of the selection.
+get position GetSelectionNStart=2585(,)
+
+# Sets the position that ends the selection - this becomes the currentPosition.
+set void SetSelectionNEnd=2586(int selection, position pos,)
+
+# Returns the position at the end of the selection.
+get position GetSelectionNEnd=2587(,)
+
+set void SetRectangularSelectionCaret=2588(position pos,)
+get position GetRectangularSelectionCaret=2589(,)
+set void SetRectangularSelectionAnchor=2590(position posAnchor,)
+get position GetRectangularSelectionAnchor=2591(,)
+set void SetRectangularSelectionCaretVirtualSpace=2592(int space,)
+get int GetRectangularSelectionCaretVirtualSpace=2593(,)
+set void SetRectangularSelectionAnchorVirtualSpace=2594(int space,)
+get int GetRectangularSelectionAnchorVirtualSpace=2595(,)
+
+enu VirtualSpace=SCVS_
+val SCVS_NONE=0
+val SCVS_RECTANGULARSELECTION=1
+val SCVS_USERACCESSIBLE=2
+
+set void SetVirtualSpaceOptions=2596(int virtualSpaceOptions,)
+get int GetVirtualSpaceOptions=2597(,)
+
+# On GTK+, allow selecting the modifier key to use for mouse-based
+# rectangular selection. Often the window manager requires Alt+Mouse Drag
+# for moving windows.
+# Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER.
+
+set void SetRectangularSelectionModifier=2598(int modifier,)
+
+# Get the modifier key used for rectangular selection.
+get int GetRectangularSelectionModifier=2599(,)
+
+# Set the foreground colour of additional selections.
+# Must have previously called SetSelFore with non-zero first argument for this to have an effect.
+set void SetAdditionalSelFore=2600(colour fore,)
+
+# Set the background colour of additional selections.
+# Must have previously called SetSelBack with non-zero first argument for this to have an effect.
+set void SetAdditionalSelBack=2601(colour back,)
+
+# Set the alpha of the selection.
+set void SetAdditionalSelAlpha=2602(int alpha,)
+
+# Get the alpha of the selection.
+get int GetAdditionalSelAlpha=2603(,)
+
+# Set the foreground colour of additional carets.
+set void SetAdditionalCaretFore=2604(colour fore,)
+
+# Get the foreground colour of additional carets.
+get colour GetAdditionalCaretFore=2605(,)
+
+# Set the main selection to the next selection.
+fun void RotateSelection=2606(,)
+
+# Swap that caret and anchor of the main selection.
+fun void SwapMainAnchorCaret=2607(,)
+
 # Start notifying the container of all key presses and commands.
 fun void StartRecord=3001(,)
 
@@ -2035,6 +2162,7 @@
 val SCMOD_SHIFT=1
 val SCMOD_CTRL=2
 val SCMOD_ALT=4
+val SCMOD_SUPER=8
 
 ################################################
 # For SciLexer.h

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2009-10-16 11:07:49 UTC (rev 4326)
+++ trunk/src/editor.c	2009-10-16 12:13:01 UTC (rev 4327)
@@ -767,22 +767,12 @@
 }
 
 
-static gboolean delay_autocomplete(gpointer data)
-{
-	keybindings_send_command(GEANY_KEY_GROUP_EDITOR, GEANY_KEYS_EDITOR_AUTOCOMPLETE);
-	return FALSE;
-}
-
-
 static void partial_complete(ScintillaObject *sci, const gchar *text)
 {
 	gint pos = sci_get_current_position(sci);
 
 	sci_insert_text(sci, pos, text);
 	sci_set_current_position(sci, pos + strlen(text), TRUE);
-	sci_cancel(sci);	/* cancel full AC */
-	/* a timeout of 0 means the AC box doesn't flicker */
-	g_timeout_add(0, delay_autocomplete, NULL);
 }
 
 
@@ -804,6 +794,7 @@
 	{
 		ptr[1] = '\0';
 		partial_complete(editor->sci, text);
+		return;
 	}
 	else
 	{
@@ -816,10 +807,12 @@
 			{
 				ptr[0] = '\0';
 				partial_complete(editor->sci, text);
-				break;
+				return;
 			}
 		}
 	}
+	/* no word part, complete normally */
+	SSM(editor->sci, SCI_AUTOCCOMPLETE, 0, 0);
 }
 
 
@@ -901,10 +894,6 @@
 				utils_beep();
 				break;
 			}
-			if (nt->ch == '\t')
-			{
-				check_partial_completion(editor, nt->text);
-			}
 			/* fall through */
 		case SCN_AUTOCCANCELLED:
 			/* now that autocomplete is finishing or was cancelled, reshow calltips
@@ -4741,6 +4730,36 @@
 }
 
 
+/* safe way to read Scintilla string into a buffer */
+static gchar *sci_get_string(ScintillaObject *sci, gint msg)
+{
+	gint size = SSM(sci, msg, 0, 0) + 1;
+	gchar *str = g_malloc(size);
+
+	SSM(sci, msg, 0, (sptr_t)str);
+	return str;
+}
+
+
+static gboolean on_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+	GeanyDocument *doc;
+	gchar *entry;
+
+	if (event->state || event->keyval != GDK_Tab)
+		return FALSE;
+
+	doc = document_get_current();
+	if (!doc || !SSM(doc->editor->sci, SCI_AUTOCACTIVE, 0, 0))
+		return FALSE;
+
+	entry = sci_get_string(doc->editor->sci, SCI_AUTOCGETCURRENTTEXT);
+	check_partial_completion(doc->editor, entry);
+	g_free(entry);
+	return TRUE;
+}
+
+
 void editor_init(void)
 {
 	static GeanyIndentPrefs indent_prefs;
@@ -4753,6 +4772,8 @@
 	 * handler (on_editor_notify) is called */
 	g_signal_connect_after(geany_object, "editor-notify", G_CALLBACK(on_editor_notify), NULL);
 
+	g_signal_connect(main_widgets.window, "key-press-event", G_CALLBACK(on_key_press_event), NULL);
+
 	ui_add_config_file_menu_item(utils_build_path(app->configdir, "snippets.conf", NULL),
 		NULL, NULL);
 	g_signal_connect(geany_object, "document-save", G_CALLBACK(on_document_save), NULL);


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