Hi,
I made a patch for GTK Scintilla to move to the end of a word e.g. when 
pressing Ctrl-right (instead of the start). This is more like what GTK 
widgets do by default, such as GtkEntry.

We've been testing it in the Geany IDE SVN for some weeks, combined  
with using SCI_SETWHITESPACECHARS to ignore punctuation.

Is it suitable to be applied by default?

Thanks,
Nick
Index: ScintillaGTK.cxx
===================================================================
--- ScintillaGTK.cxx	(revision 1671)
+++ ScintillaGTK.cxx	(revision 1672)
@@ -285,6 +285,9 @@
 
 	static sptr_t DirectFunction(ScintillaGTK *sciThis,
 	                             unsigned int iMessage, uptr_t wParam, sptr_t lParam);
+
+protected:
+	virtual int KeyCommand(unsigned int iMessage);
 };
 
 enum {
@@ -2720,3 +2723,32 @@
 void scintilla_release_resources(void) {
 	Platform_Finalise();
 }
+
+int ScintillaGTK::KeyCommand(unsigned int iMessage) {
+	switch (iMessage) {
+	/* Try to act more like a GtkWidget, e.g. GtkEntry.
+	 * The container app should also call SCI_SETWHITESPACECHARS to include punctuation
+	 * chars as whitespace. */
+	case SCI_WORDRIGHT:
+		MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, 1), 1));
+		SetLastXChosen();
+		break;
+	case SCI_WORDRIGHTEXTEND:
+		MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, 1), 1), selStream);
+		SetLastXChosen();
+		break;
+	case SCI_DELWORDRIGHT: {
+			int endWord = pdoc->NextWordEnd(currentPos, 1);
+			pdoc->DeleteChars(currentPos, endWord - currentPos);
+		}
+		break;
+	default:
+		return ScintillaBase::KeyCommand(iMessage);
+	}
+	/* Mimic what ScintillaBase::KeyCommand would do as we're overriding it. */
+	if (ac.Active())
+		ac.Cancel();
+	if (ct.inCallTipMode)
+		ct.CallTipCancel();
+	return 0;
+}

_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to