diff options
author | nyamatongwe <unknown> | 2009-07-12 02:22:26 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2009-07-12 02:22:26 +0000 |
commit | c1bd09cfd4175f9ae03691e836a7f40985f2303a (patch) | |
tree | 146506eeb98f7d67fcd6e130bf7415d8291c8e22 | |
parent | 8bf93b50f043fc9e6d52ce07105f7b4dcd11687a (diff) | |
download | scintilla-mirror-c1bd09cfd4175f9ae03691e836a7f40985f2303a.tar.gz |
Allow setting the modifier key to be used for rectangular
selection on GTK+.
Paste can be performed in virtual space on GTK+
-rw-r--r-- | gtk/ScintillaGTK.cxx | 51 | ||||
-rw-r--r-- | include/Scintilla.h | 3 | ||||
-rw-r--r-- | include/Scintilla.iface | 11 |
3 files changed, 52 insertions, 13 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 922d6ea75..be8a357f2 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -117,6 +117,7 @@ class ScintillaGTK : public ScintillaBase { bool capturedMouse; bool dragWasDropped; int lastKey; + int rectangularSelectionModifier; GtkWidgetClass *parentClass; @@ -347,7 +348,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) : adjustmentv(0), adjustmenth(0), scrollBarWidth(30), scrollBarHeight(30), capturedMouse(false), dragWasDropped(false), - lastKey(0), parentClass(0), + lastKey(0), rectangularSelectionModifier(SCMOD_CTRL), parentClass(0), #ifdef INTERNATIONAL_INPUT #if GTK_MAJOR_VERSION < 2 ic(NULL), @@ -363,6 +364,12 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) : wMain = GTK_WIDGET(sci); #if PLAT_GTK_WIN32 + rectangularSelectionModifier = SCMOD_ALT; +#else + rectangularSelectionModifier = SCMOD_CTRL; +#endif + +#if PLAT_GTK_WIN32 // There does not seem to be a real standard for indicating that the clipboard // contains a rectangular selection, so copy Developer Studio. cfColumnSelect = static_cast<CLIPFORMAT>( @@ -1020,6 +1027,13 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam return EncodedFromUTF8(reinterpret_cast<char*>(wParam), reinterpret_cast<char*>(lParam)); + case SCI_SETRECTANGULARSELECTIONMODIFIER: + rectangularSelectionModifier = wParam; + break; + + case SCI_GETRECTANGULARSELECTIONMODIFIER: + return rectangularSelectionModifier; + default: return ScintillaBase::WndProc(iMessage, wParam, lParam); } @@ -1523,9 +1537,10 @@ void ScintillaGTK::ReceivedSelection(GtkSelectionData *selection_data) { if (selText.rectangular) { PasteRectangular(selStart, selText.s, selText.len); } else { - int caretMain = sel.MainCaret(); - pdoc->InsertString(caretMain, selText.s, selText.len); - SetEmptySelection(caretMain + selText.len); + selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace())); + if (pdoc->InsertString(selStart.Position(),selText.s, selText.len)) { + SetEmptySelection(selStart.Position() + selText.len); + } } EnsureCaretVisible(); } @@ -1781,6 +1796,21 @@ static void SetAdjustmentValue(GtkObject *object, int value) { gtk_adjustment_set_value(adjustment, value); } +static int modifierTranslated(int sciModifier) { + switch (sciModifier) { + case SCMOD_SHIFT: + return GDK_SHIFT_MASK; + case SCMOD_CTRL: + return GDK_CONTROL_MASK; + case SCMOD_ALT: + return GDK_MOD1_MASK; + case SCMOD_SUPER: + return GDK_MOD4_MASK; + default: + return 0; + } +} + gint ScintillaGTK::PressThis(GdkEventButton *event) { try { //Platform::DebugPrintf("Press %x time=%d state = %x button = %x\n",this,event->time, event->state, event->button); @@ -1804,19 +1834,14 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) { gtk_widget_grab_focus(PWidget(wMain)); if (event->button == 1) { - // On X, instead of sending literal modifiers use control instead of alt + // On X, instead of sending literal modifiers use the user specified + // modifier, defaulting to control instead of alt. // This is because most X window managers grab alt + click for moving -#if !PLAT_GTK_WIN32 +fprintf(stderr, "state=%x %x\n", event->state, event->state & GDK_MOD4_MASK); ButtonDown(pt, event->time, (event->state & GDK_SHIFT_MASK) != 0, (event->state & GDK_CONTROL_MASK) != 0, - (event->state & GDK_CONTROL_MASK) != 0); -#else - ButtonDown(pt, event->time, - (event->state & GDK_SHIFT_MASK) != 0, - (event->state & GDK_CONTROL_MASK) != 0, - (event->state & GDK_MOD1_MASK) != 0); -#endif + (event->state & modifierTranslated(rectangularSelectionModifier)) != 0); } else if (event->button == 2) { // Grab the primary selection if it exists SelectionPosition pos = SPositionFromLocation(pt); diff --git a/include/Scintilla.h b/include/Scintilla.h index 5e89ddb84..877caa712 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -749,6 +749,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #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 @@ -816,6 +818,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #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 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 76d9da08a..d17de8018 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1995,6 +1995,16 @@ val SCVS_USERACCESSIBLE=2 set void SetVirtualSpaceOptions=2596(int virtualSpace,) 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,) @@ -2124,6 +2134,7 @@ val SCMOD_NORM=0 val SCMOD_SHIFT=1 val SCMOD_CTRL=2 val SCMOD_ALT=4 +val SCMOD_SUPER=8 ################################################ # For SciLexer.h |