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 /gtk | |
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+
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/ScintillaGTK.cxx | 51 |
1 files changed, 38 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); |