New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multipaste - Fixed #2328
base: master
Are you sure you want to change the base?
Multipaste - Fixed #2328
Conversation
…E_EACH - fixes the paste only one line when a vertical selection is selected.
Reverted to Scintilla default ship.
…into multipaste
Fixed spacing.
Copy paste error fix.
Fixed hardcoding the value set from SC_MULTIPASTE_EACH to the function parameter.
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 😁 |
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. ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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):
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 ;)
src/sciwrappers.c
Outdated
/* 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); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't actually need a new wrapper for just one call, especially not when that call is in editor.c.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I did this is because @elextr suggested that it should be an option. I agree that it should be the only behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/sciwrappers.h
Outdated
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in the GEANY_PRIVATE
section below. Only plugin API functions should be outside of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again the reason I did this is because @elextr suggested that it should be an option.
src/sciwrappers.h
Outdated
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is horrid in this file - I tried to be nice, it won't happen again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is horrid in this file
👍
At some point I'll probably make a PR to reformat this header to follow Geany's coding style.
SC_MULTIPASTE_EACH is no longer an option.
Setting SC_MULTIPASTE_EACH is defaulted and therefore no longer exposed.
Setting SC_MULTIPASTE_EACH has been made the default.
Updated - SC_MULTIPASTE_EACH is now set in geany/src/editor.c::editor_create_widget() without any wrappers since this is now the default. |
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? |
…direct scintilla settings are.
Don't worry guys, all fixed. =) |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change request from b4n is already implemented.
Changed sci_wrapper.c::sci_set_multipaste() from hardcoded value SC_MULTIPASTE_EACH to function parameter val.