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
Multiple carets, selections, insertion points and paste #1141
Comments
This is a significant change, pull requests are welcome. |
Scintilla (the editing component Geany uses) can do that. So it's a "mere matter" of adding UI capability to Geany (and design how it should actually work from a UI perspective). And it possibly requires enhancing several parts of Geany so it plays nicely with multiple selections (I'm afraid a lot of our code was written carelessly to that regard, or even way before the feature even existed in Scintilla). |
Which is why its a significant change.
|
It looks like the multi-select copy/paste insert portion of this request was added as of 1.23.1. |
@AdamDanischewski its definitely only possible to have one selection still, you havn't confused it with rectangular selection have you? |
This feature is just about the only thing holding me back from switching away from another editor for everything, so I thought I would take a stab at it. I cloned master and added a wrapper for SCI_SETMULTIPLESELECTION in FWIW, further on in that discussion I linked to, an |
@Ryan1729 good on you for trying. One thought on why it does nothing is that something has to do the selection, are you sure Scintilla has a default binding for
I would expect everything to simply ignore multiple selections, and just read the main selection and operate on that. And thats where the "significant change" part above comes in. The PS removed the backticks around your link so it would work, markup is ignored inside backticks. |
I had assumed that it was built in to Scintilla since that docs page I mentioned before [1] seems to be about Scintilla only and it explicitly mentions So I've now tried calling [1] Regarding the link, I meant to do something |
What exactly is expected, I can't get Scite to do anything interesting on crtl+click. The version in my distro is kind of old (3.6.0) and maybe it was added after that. How do you know it didn't work? IIUC multiple selections have a separate styling from the main selection, and since Geany doesn't set that style they may not be visible? |
Ryan by Ctrl-click do you mean Ctrl + Shift Click? If you haven't tried that, give it a shot I think that provides the functionality that is referred to in the API documents. |
@AdamDanischewski as noted in reply to your previous post above, ctrl+shift+click makes a rectangular selection, not a multiple selection, this is not the same thing. |
@elextr It sounds like you want something like crtrl-click multipositional multiselect |
@AdamDanischewski read the OP (and its not me that wants it :) |
Lol, yea I was only scrolling up only to his new comment for some reason - disregard the clarification request. I see what you are looking for now, best of luck. I developed the first patch for the multiselect functionality that's working now. I didn't implement it ultimately in Geany because of the user interface complexity. What I did was simply hook the functionality to an existing loaded user interface component for testing - to make sure it was turned on. That way you don't have to worry about the user interface - you can just turn on the functionality and test that it works then upload what you have and ask a developer to integrate it into the user interface. As far as the Scintilla functions, I think these may be the ones you want to play around with: Look in the Geany code where SCI_SETMULTIPLESELECTION is set, to see how to turn on these on then look at the keybindings code to see if you can remap them to buttons (easier for testing). Try to focus on one thing that you can see working or not to get it going then ramp it up the full functionality. |
Just to be absolutely clear what we're talking about, here's a gif recording of an unconfigured SciTE 4.0.2: In the gif I I guess I was assuming Scintila handled more of the GUI, rather than, as appears to be the case, just managing the editor state. @AdamDanischewski Those seem like good suggestions. assuming extra selections are actually working, just not showing in the UI, SCI_ROTATESELECTION should allow a quick demonstration that will actually show up. I'll get started on that. |
I've got a branch here that callsSCI_ADDSELECTION on ctrl-click, and calls SCI_ROTATESELECTION on ctrl-right-click. Mysteriously, if you ctrl-click then ctrl-right-click somewhere else, by the time the right click happens, the number of selections is back down to 1. So I also quickly co-opted the dubug mode for the Unless someone knows some weird thing the code is doing that wold cause this, (setting the selection outside the Scintilla API?!) I suppose I'll have to try getting GDB working. |
Maybe something is overwriting your multiple select setting so its back to single? |
I just tried adding the result of SCI_GETMULTIPLESELECTION to the printouts, and once it's set it to true, it remains true. |
Dunno, can only suggest looking at one of the scintilla based apps that does what you want and steal, erm reuse, their algorithms. |
Textadept (https://foicica.com/textadept/) has this feature and I believe it uses Scintilla. I am not a programmer, so I have no idea how to search Textadepts's code and adapt the feature to Geany. But maybe someone with the skills can give it a try. This is the only feature I really miss in Geany and it would be great to have it. PS: The feature I'm talking about is the "multi-caret editing", as displayed by Ryan1729. Textadept doesn't have the "column/retangular multipaste" feature. |
@diohja Textadept does seem to have the feature yet it doesn't look like it's really using Scintilla. It includes ScintillaLua a lexer for Scintilla. The Scintilla functionality appears to have been recreated in Lua. |
Textadept appears to use ScintillaGTK, not Scintilla directly, so it comes in a library rather than included source code. That also means the API may be different. |
@elextr It does say that it uses Scintilla as the core text editing component, when I first browsed the code it looked like mainly lua, looking closer I see some calls that create a Scintilla document. See textadept.c line no. 1355.
https://foicica.com/textadept/TECHNOLOGY.html See here for the Textadept API, the mapping from Textadept to Scintilla happens in the buffer object: https://foicica.com/textadept/api.html#buffer |
Kind of like textadept now that I've played around with it, you have to a hack a colorizer (theme) to get the color scheme to Geany though. Copy and modify a theme in the themes directory under the source directory (exploded tar ball). Presuming you named your cloned theme to be your-new-theme.lua Add this to your ~/.textadept/init.lua file: ui.set_theme(not CURSES and 'your-new-theme') Then modify the colors and type Ctrl-e for a command window in textadept and enter: reset() Keep modifying it to your preference (hint you can choose more than the colors listed (e.g. color.red works), once you get the color scheme you like it's not that different from Geany, and it seems a lot faster. Here is my pseudo-Bash colorizer clone I just put together - it's not an exact match yet it works for me:
|
Textadept is blazing fast, but I miss two features:
I currently use Visual Studio Code, because it has all the features I use and has many useful extensions. The downside is that its not as fast as Geany or Textadept. But its faster than any other text editor with similar functions. |
I've now got ctrl-click multiple selections working, (I can make multiple selections and type into all of them at once) on my debugging branch. Note that that branch simply deletes the old ctrl-click functionality, (and has a bunch of printouts besides), so it' is not suitable to add to the main codebase, but it works as a proof of concept. So the question now seems to be how should the settings for ctrl-clicking be handled? The natural thing to do right now seems (to me) to be a set of radio buttons, (and a corresponding enum) that allows selecting between the old functionality (goto-tag and find-matching-brace), adding a selection, and not doing anything on ctrl-click at all. However, that old discussion thread mentioned the idea of mouse bindings, (so the user could bind arbitrary actions to mouse inputs,) which seems like a reasonable idea. If that's ever going to happen, then we should probably think about that when deciding how this setting works. If we go with my enum proposal then later mouse bindings get added, then either user's configuration files break or we have one of two undesirable situations : this enum overrides the keybindings, meaning the user might set mouse bindings and not understand why they need to set the enum to "None" or an additional setting of "Allow keybinding", or the other situation where the keybindings override the enum and if a user binds something to ctrl-shift-click and is surprised that ctrl-click stops doing what they expect. Then again, would not having either setting override each other be best? If a user is surprised that ctrl-clicking adds a selection, in addition to whatever they set it to do, then hopefully that would prompt them to look in the settings to turn that off? Maybe someone else has a better idea that avoids even that problem? |
Since the current default behavior is different, it may be argued to not make it a default. Yet the functionality seems to be much better and I personally would prefer to see Geany remain consistent with other editors that offer this same functionality. It is a quirk in my opinion that Geany using Scintilla defaults to a different functionality than what the other Scintilla editors have as standard with regards to multi-caret on Ctrl-click. I vote to make the new Ctrl-click functionality standard in accordance with the other Scintilla editors. Btw: you are in the same situation, I was in, with regards to fixing it yet not being able to add it to the user interface. Hopefully elextr knows how to route this to the appropriate parties for implementation. |
IMO a few things are need to be resolved for this to progress:
Some mice have many buttons and these could be bound by the user to suit their use-case, while other users may keep the current ctrl-click and bind the multiple select elsewhere and others go for interapp compatibility. Giving the user control takes the heat out of the debate about backward compatibility vs interapp commonality. This would need a bit of work because the current keybindings are based on
But before any multiple select capability is introduced it must be checked that no other Geany and core plugin functionality is affected by their presence and any problems fixed. Then the basic ability to make multiple selections and type in them, as @Ryan1729 has here, can be added and contributions solicited for making other Geany functions multiple select aware when it makes sense for that.
|
@Ryan1729 is it possible to embed this feature to may be https://github.com/geany/geany-plugins/tree/master/geanyextrasel ? This is just a personal opinion but may be the workflow would be |
@sagarchalise That plugin relies on geany providing the functions I'm not sure how to handle the mouse portion in this scenario though. |
Enabling Scintilla multiple selections is easy, but everybody seems to have missed the following: Geany and plugins are not written to handle multiple selects, its is unknown what will happen in Geany or plugin functions if there is a multiple selection. In the best case it will "just work" on the main selection and ignore the rest, in the worse case who knows, crash maybe. Geany handles rectangular selections, but they are provided by Scintilla as a single selection, not multiple selections. No plugin can change this as its in Geany and other plugins code. Until the plan for introducing multiple selects addresses this it is likely to go nowhere. |
@Ryan1729 That sounds like a reasonable plan to move forward -- since it is unknown what the effects will be, just make it an option to let those who want to use it, give it a shot and they can report if there are issues - fixing them where possible (although it probably will require an overhaul for handling selects at some point). |
Any news in this? I will like to see this feature in Geany |
Sorry, I have stopped working on this, and I probably should have said something. If someone else wants to go forward with this, hopefully the gist I linked to above which shows how to enable the scintilla feature would be helpful.
… On Jan 4, 2019, at 10:41 AM, João Paulo Pulga ***@***.***> wrote:
Any news in this? I will like to see this feature in Geany
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
+1 for this feature: hope will be implemented. |
Contributions are welcome, but as the comment above says, the original implementor has stopped working on it, and it appears nobody else is interested/needs it enough. |
It would be great to have the ability to create multiple carets, select multiple pieces, or progressively clone a selection of a word to the next identical match creating multiple selections, not necessarily square, and then be able to type, delete, replace, etc. using the multiple carets until Esc is hit, pasting into all carets with Ctrl-V, and so on.
Here's an animated demonstration of these features: https://www.sublimetext.com/
This is a killer feature of software like Sublime Text, TextMate or Ultra Edit, and this would put Geany closer to some of the most reputed, feature rich commercial multiplatform editors, while still being free software. I believe there's support for this in Scintilla, at least to some extent.
This supersets #850 and #625.
The text was updated successfully, but these errors were encountered: