Changed sci_wrapper.c::sci_set_multipaste() from hardcoded value SC_MULTIPASTE_EACH to function parameter val. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/2328
-- Commit Summary --
* Changed the scintilla default from SC_MULTIPASTE_ONCE to SC_MULTIPASTE_EACH - fixes the paste only one line when a vertical selection is selected. * Update Editor.cxx * Moved scintilla SC_MULTIPASTE_EACH default setting to Geany. * Merge branch 'multipaste' of https://github.com/AdamDanischewski/geany into multipaste * Update sciwrappers.h * Update Editor.cxx * Update sciwrappers.c
-- File Changes --
M src/editor.c (3) M src/sciwrappers.c (4) M src/sciwrappers.h (165)
-- Patch Links --
https://github.com/geany/geany/pull/2328.patch https://github.com/geany/geany/pull/2328.diff
This looks like the same topic/changes as #2325 and #2327. Please don't make multiple PRs for the same thing, just update the original one (ie. #2325). If you're having problems with Git, which is completely understandable as it has a steep learning curve, just ask about it in the comments or on the mailing list or IRC or wherever.
@codebrainz They are the same. #2325 was approved but had a subsequent update. I'll keep it on the same PR in the future. For now I'll leave this open since there is no point to going back to #2325.
Ideally the latter two PRs would be closed and the original updated since it has comments and reviews on it.
This also has comments, it still needs to be re-reviewed. No?
@AdamDanischewski Geany operates on tab == 4 not tab == 8, please set Geany correctly and undo your alignment changes to sciwrapper.h
And FGS don't make another PR do it on this one :grin:
I tried to be nice and clean it up, I really don't have time for this project. Go ahead and review the code and put it through or let me know if there is an actual problem. The team here seems very ungrateful for an extra helping hand at fixing a problem that's making Geany look bad.
@elextr You can open up your own PR for the cosmetics. ;-)
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.
codebrainz commented on this pull request.
@@ -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);
To be fair, aligning stuff like this (GNU/GTK+-style) is a terrible idea, especially when tabs are used. Not sure why this one file in Geany uses this alignment style.
elextr commented on this pull request.
@@ -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);
Yeah, but to return it to its original state only needs `git checkout src/sciwrappers.h`. There was so much noise I didn't even notice that there was an actual change. @b4n did better.
AdamDanischewski commented on this pull request.
@@ -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); +}
The reason I did this is because @elextr suggested that it should be an option. I agree that it should be the only behavior.
AdamDanischewski commented on this pull request.
@@ -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);
The indentation is horrid in this file - I tried to be nice, it won't happen again.
AdamDanischewski commented on this pull request.
@@ -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);
Again the reason I did this is because @elextr suggested that it should be an option.
@AdamDanischewski pushed 1 commit.
f22fc13f9d19b68c5dcac2bba3165dfc575ecaef SC_MULTIPASTE_EACH is default
@AdamDanischewski pushed 1 commit.
921142866e85a851ca2341f4ce16e96c6d6d6959 Setting SC_MULTIPASTE_EACH no longer exposed
@AdamDanischewski pushed 1 commit.
b78159d71fa989132155ccd879e79ae24df00e76 Setting SC_MULTIPASTE_EACH is no longer exposed
Updated - SC_MULTIPASTE_EACH is now set in geany/src/editor.c::editor_create_widget() without any wrappers since this is now the default.
b4n commented on this pull request.
editor->sci = editor_create_widget(editor);
+ sci_set_multipaste(editor->sci, SC_MULTIPASTE_EACH);
My bad, I meant `create_new_sci()` which is the one having the other similar defaults
Better. IMO we should just use my version that has all the small things I'd like to see changed here (comment, location of the change (which is my bad because of an incorrect comment, sorry), no leftover unrelated whitespace changes, clearer commit message, no leftover history), but basically I'm now happy with the spirit of the changes here.
@b4n It sounds like you're not really interested in crediting me for fixing this - does this mean I won't be added to the list of contributors?
@AdamDanischewski pushed 2 commits.
a1a185e87c085d330c15e623f5005886ce5c24b0 Reverted - a blank line at the end was missing 79923d281814d95ffebe1a2cb44381cd31d7d4b1 Moved SC_MULTIPASTE_EACH setting to create_new_sci() where the other direct scintilla settings are.
Don't worry guys, all fixed. =)
@b4n It sounds like you're not really interested in crediting me for fixing this - does this mean I won't be added to the list of contributors?
To be blunt, I really don't care who's credited here :) But I'll happily credit you, my example was not trying to draw it away from you.
codebrainz commented on this pull request.
@@ -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);
The indentation is horrid in this file
:+1:
At some point I'll probably make a PR to reformat this header to follow Geany's coding style.
Akronix commented on this pull request.
@@ -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); +}
Related discussion can be found in #2317 and in #850
AdamDanischewski commented on this pull request.
The change request from b4n is already implemented.
editor->sci = editor_create_widget(editor);
+ sci_set_multipaste(editor->sci, SC_MULTIPASTE_EACH);
That's where it is now.
github-comments@lists.geany.org