orbitalquark / textadept

Textadept is a fast, minimalist, and remarkably extensible cross-platform text editor for programmers.
https://orbitalquark.github.io/textadept
MIT License
636 stars 38 forks source link

Keyboard shortcuts for adding a caret in Linux #446

Closed jozsefk9 closed 1 year ago

jozsefk9 commented 1 year ago

Is it possible to change the keybindings for adding a caret from Alt+Shift+Arrow up (or down), to something else? If yes, how? Coz in Linux Alt+Shift+Arrow up/down already does something in the system.

orbitalquark commented 1 year ago

Try changing view.rectangular_selection_modifier in your ~/.textadept/init.lua: https://orbitalquark.github.io/textadept/api.html#view.rectangular_selection_modifier

ClaudioGi commented 1 year ago

I am on a Linux Mint 21 Cinnamon driven machine and this key combination works OK for me in the GTK version of Textadept I am using, so you may check how does it come that you mean that "Alt+Shift+Arrow up/down Linux already does something in the system" which seems not to be generally true. Maybe on your box you are not aware of by someone else by chance centrally registered keyboard shortcuts? Check your system settings for keyboard to find out.

By the way: what is that "something else" you want to change the combination to? There are not really meaningful alternatives to the default keyboard shortcut for this functionality as all of the others are actually already taken for some other purposes by the system or by the editor (for example for selection).

jozsefk9 commented 1 year ago

Try changing view.rectangular_selection_modifier in your ~/.textadept/init.lua: https://orbitalquark.github.io/textadept/api.html#view.rectangular_selection_modifier

If I change that it still doesn't work. Super+Shift+Arrow up/down didn't add a new caret. Same with Ctrl+Shift+Arrow up/down. I tried to do it in both ./textadept/init.lua and ~/.textadept/init.lua. Nothing helped.

I am on a Linux Mint 21 Cinnamon driven machine and this key combination works OK for me in the GTK version of Textadept I am using, so you may check how does it come that you mean that "Alt+Shift+Arrow up/down Linux already does something in the system" which seems not to be generally true. Maybe on your box you are not aware of by someone else by chance centrally registered keyboard shortcuts? Check your system settings for keyboard to find out.

By the way: what is that "something else" you want to change the combination to? There are not really meaningful alternatives to the default keyboard shortcut for this functionality as all of the others are actually already taken for some other purposes by the system or by the editor (for example for selection).

I'm on Lubuntu right now and Alt+Shift+Arrow up/down is switching between open windows. But I'm not always on Lubuntu. So for me it's easier to fix the shortcut in Textadept and have it working on any system. Windows key+Shift+Arrow up/down could work. Or else, only one key+Arrow up/down could work too. Like Windows+Arrow up/down or Alt+Arrow up/down. Anything. I would already figure out something. But I can't find the place where are the keyboard shortcuts settings for Textadept.

rgieseke commented 1 year ago

I'm not sure whether you mean this by adding a caret but think the following should work (in your init.lua):

keys['ctrl+up'] = buffer.line_up_rect_extend
keys['ctrl+down'] = buffer.line_down_rect_extend

This will overwrite the previous value for 'ctrl+up'.

Keys are defined in textadept/modules/keys: https://github.com/orbitalquark/textadept/blob/default/modules/textadept/keys.lua#L518

rgieseke commented 1 year ago

alt+up should work as well, the Windows key is not available in Textadept.

jozsefk9 commented 1 year ago

alt+up should work as well, the Windows key is not available in Textadept.

Perfect! That worked! Thanks so much.

orbitalquark commented 1 year ago

Try changing view.rectangular_selection_modifier in your ~/.textadept/init.lua: https://orbitalquark.github.io/textadept/api.html#view.rectangular_selection_modifier

If I change that it still doesn't work. Super+Shift+Arrow up/down didn't add a new caret. Same with Ctrl+Shift+Arrow up/down. I tried to do it in both ./textadept/init.lua and ~/.textadept/init.lua. Nothing helped.

Ugh, sorry, I got confused again thinking that that setting applies to key bindings. It does not. It only applies to the mouse. If you want to use key bindings, you would do as @rgieseke suggests: assign key bindings to the rectangular selection keys: https://orbitalquark.github.io/textadept/api.html#make-rectangular-selections

rgieseke commented 1 year ago

@orbitalquark Since the values for non Mac are nil in https://orbitalquark.github.io/textadept/api.html#view.rectangular_selection_modifier are these Win/Linux platform defaults?

orbitalquark commented 1 year ago

I'm pretty sure they are. I use them all the time.