b4n requested changes on this pull request.
With a quick test, I agree that changing the behavior makes sense and is mostly compatible. For the implementation part, I think this should be all what's needed (no need for a new Scintilla wrapper for something only used once in *editor.c*, and the function shouldn't be exposed in the headers anyway): ```diff
From 9b503708203a4986736da33d882f695dee6119c0 Mon Sep 17 00:00:00 2001
From: Colomban Wendling ban@herbesfolles.org Date: Mon, 30 Sep 2019 20:09:12 +0200 Subject: [PATCH] Enable multi-selection clipboard paste
When pasting a single-line clipboard content inside multiple or rectangular selections, paste it in each selection rather than only in the main one.
This changes behavior, but the old behavior is easily reproduced by canceling a multiple selection when a single paste is desired, whereas it was not possible to obtain multiple pastes before.
diff --git a/src/editor.c b/src/editor.c index df25c8808..b02705e36 100644 --- a/src/editor.c +++ b/src/editor.c @@ -4940,6 +4940,10 @@ static ScintillaObject *create_new_sci(GeanyEditor *editor) #endif SSM(sci, SCI_SETRECTANGULARSELECTIONMODIFIER, rectangular_selection_modifier, 0);
+ /* With multiple selections, paste in them all (doesn't affect pasting + * multi-line data in a rectangular selection) */ + SSM(sci, SCI_SETMULTIPASTE, SC_MULTIPASTE_EACH, 0); + /* virtual space */ SSM(sci, SCI_SETVIRTUALSPACEOPTIONS, editor_prefs.show_virtual_space, 0);
```
I'd be happy to get this through, but I won't open a new PR just yet (hehe) and I can't push here. Of course I can create a new PR if @elextr's happy with it ;)
editor->sci = editor_create_widget(editor);
+ sci_set_multipaste(editor->sci, SC_MULTIPASTE_EACH);
This should go in `editor_create_widget()` along the other similar ones.
@@ -93,6 +93,10 @@ sptr_t sci_send_message_internal (const gchar *file, guint line, ScintillaObject
} #endif
+ /* Set multi paste setting (at 3104 scintilla defaults to SC_MULTIPASTE_ONCE) */ +void sci_set_multipaste(ScintillaObject *sci, gint mpval) { + SSM(sci, SCI_SETMULTIPASTE, mpval, 0); +}
We don't actually need a new wrapper for just one call, especially not when that call is in *editor.c*.
@@ -39,9 +39,10 @@ sptr_t sci_send_message_internal (const gchar *file, guint line, ScintillaObject
# endif #endif
-void sci_set_text (ScintillaObject *sci, const gchar *text); -gboolean sci_has_selection (ScintillaObject *sci); -void sci_end_undo_action (ScintillaObject *sci); +void sci_set_multipaste (ScintillaObject *sci, gint mpval);
This should be in the `GEANY_PRIVATE` section below. Only plugin API functions should be outside of it.
@@ -56,162 +57,162 @@ void sci_set_current_position (ScintillaObject *sci, gint position, gboolean
gint sci_get_selection_start (ScintillaObject *sci); gint sci_get_selection_end (ScintillaObject *sci); -void sci_replace_sel (ScintillaObject *sci, const gchar *text); +void sci_replace_sel (ScintillaObject *sci, const gchar *text);
Please don't rewrite unrelated indentation, even if it was incorrect (and here it's not, Geany uses a tab width of 4, which aligns well). Changes like this make it a lot harder to read the actual, meaningful changes, and should be made in a specific commit if at all.