Open Drugoy opened 1 year ago
I really like this idea, and had not thought about the mentioned use-case before - thank you!
My main concern about this is that in the future I'd like to use a built-in ctrl+mouse-click for other stuff (selecting multiple panes, dragging vs. resizing, etc.) - so maybe we can implement this as an optional feature? Or a bindable one?
First of all - the limits. Could you lay out what are the limitations of a terminal software written in Rust like Zellij is? Could it bind a hotkey that consists of mouse drags/clicks and multiple modifiers (like Ctrl+Shift+DragSelect)? Could it bind such a hotkey with 3 modifiers? Are all modifier combos supported? Or are some inaccessible due to being hardcoded / used by default by the major parts like terminal emulator / mainstream window managers / something else? Which mouse keys are supported? Just the LMB? Or also RMB? Maybe also MMB? What about extra mouse buttons that some advanced mice have?
The mechanism. IMO, this feature should of course be optional. I just imagine the config might look like something similar to this
mouse_mode true
copy_on_select true // btw, how to use this feature if this option is set to false?
keybinds {
...
some_section {
bind "Ctrl LButton" { SwitchToMode "RectangularSelection"; }
}
}
There are some questions though:
Should it be just something like LButton
or would you rather implement distinct triggers like LButtonClick
, LButtonDrag
(or a pair of LButtonDown
+ LButtonUp
instead of Drag?)?
Because since the copying should occur after the selection - then there should there basically be a 2nd bind for on LButtonUp
hotkey/event that would { SwitchToMode "Normal"; }
, would it be explicit or implicit?
Or maybe the realization of this feature doesn't even need to be 'a mode', but rather just some new special keyword like { RectangularSelection; }
that would be a continuous action that automatically ends on LButtonUp
event?
Selecting the defaults and saving some space for future mouse-clicks related ideas. You've mentioned that you had some ideas to use Ctrl+LMB actions and you and others might have even more in the future. IMO, you are at a good quite early moment in the Zellij's development to develop internal rules / self discipline in terms of future extensibility and I think it'd be better to set some rules that the implementation of all those future ideas/features should follow as to avoid conflicts. After all - Zellij is modular, so the conflicts are generally possible and should better be avoided by sticking to rules. Like: "Core config is above all. Plugins should implement new bindable actions, but the binds should never overlap with the core config. Mouse actions over (tool)bars owned by your plugin - aren't regarded as overlaps with similar actions over the rest of Zellij's interface including the content area (the stuff that is inside the panes)." That way - all you have to worry about is providing a sane set of defaults. (Defaults are important, but not THAT important for 'power users' if everything is reconfigurable). IMO, if Zellij had a feature of rectangular selection - that'd be quite a 'kicker': it might become sooo handy for sooo many use-cases (we don't even know the whole list yet!) that it also might become Zellij's 'selling point' as a quite unique feature: I know only some text editors that are currently capable of such a selection, but that means that if you'd like to select something from terminal's history using them - you would first have to copy-paste it from the terminal into said text editor, and only then use rectangular selection... that's quite long/uncomfy.
Sorry for this wall of text, haha 😃
I use Zellij with Alacritty and, if I understand this issue correctly, this interesting feature is already functional. By pressing Ctrl+Shift it is possible to select a text block in the terminal with the mouse. I can then press Ctrl+Shift+c to copy and Ctrl+Shift+v to paste into another pane or tab. But indeed, not all terminals are able to do this natively.
Imaging that some command basically output a small table and you'd like to select only (horizontally) middle part from it and you don't want to bother using awk/sed to get the necessary part.
It would be nice to be able to enter some mode (via menu? using some modifier key other than Shift [which is used by terminal]?) that would let the user do a rectangular selection using mouse (or maybe from keyword as well?).
This should work at very least inside a single pane. But as an extra that feature could also work across multiple panes inside of a single Zellij window. My only worry here would be to not have garbage spaces at the right edge, but that's just nitpicking beforehand.