orbitalquark / textadept

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

cannot get backslash char with 11.4beta in Windows #212

Closed ousia closed 2 years ago

ousia commented 2 years ago

I’m afraid I cannot get \ using a Spanish keyboard (requires Alt Gr with the to get the char).

Here you have the key (top left one):

From 11.4beta, I toggle wrap mode, but in Windows only.

It works fine with 11.3 in Windows, or 11.4beta in Linux.

In Linux, I need Ctrl+Alt (besides Alt Gr to get the char).

As a workaround I tried to reassign another key:

keys['ctr+t'] = m('Buffer/Toggle Wrap Mode')

But that didn’t work (and the API seems not to contain any information to toggle wrap mode).

Besides the bug, is there any way to assign toggle wrap mode to a different keystroke?

Many thanks for your help.

rgieseke commented 2 years ago

The m function is defined here:

https://github.com/orbitalquark/textadept/blob/default/modules/textadept/keys.lua#L281

If you didn't copy all that into your init.lua it will not work.

The wrap mode definition is here: https://github.com/orbitalquark/textadept/blob/default/modules/textadept/menu.lua#L256

function()
  local first_visible_line = view.first_visible_line
  local display_line = view:visible_from_doc_line(first_visible_line)
  view.wrap_mode = view.wrap_mode == 0 and view.WRAP_WHITESPACE or 0
  view:line_scroll(0, first_visible_line - display_line)
end

It's probably easiest if you copy that to your init.lua and assign it to your shortcut.

paaguti commented 2 years ago

Hola Pablo

what Linux is that? Maybe you need to tune the keyboard module...

Best, /PA

ousia commented 2 years ago

@rgieseke, many thanks for your help.

Copying the function allows me to have another shortcut to toggle wrap mode.

This is really great and I’m already using it.

But I also want to disable the following shortcut:

https://github.com/orbitalquark/textadept/blob/1520422fd368c5d4badc8036c4eae11e45076a4f/modules/textadept/keys.lua#L420

I need to disable it, because pressing Alt Gr + º to get \ in a Spanish keyboard (see image above) triggers the previous shortcut.

@paaguti, many thanks for your reply.

Linux is fine. Windows is the misbehaving OS here.

rgieseke commented 2 years ago

I need to disable it, because pressing Alt Gr + º to get \ in a Spanish keyboard (see image above) triggers the previous shortcut.

You can set the value to nil:

keys['ctrl+alt+\\'] = nil
ousia commented 2 years ago

This was exactly what I needed, @rgieseke.

BTW, in the email message I got (exactly the unfinished expression):

keys['ctrl+alt+\'] = nil

Another issue with the interface.

ousia commented 2 years ago

@orbitalquark,

I’m afraid I can only avoid this issue by adding to init.lua:

keys['ctrl+alt+\\'] = nil
orbitalquark commented 2 years ago

Textadept 11.4 beta now uses Gtk 3 instead of Gtk 2 (Gtk is a cross-platform GUI toolkit). I suspect key handling has changed slightly, but I don't know exactly. I came up with key bindings based on a US English key layout, so there may be issues on international keyboards. Sorry about that.

ousia commented 2 years ago

This might be fixed in GTK+4 (who knows).

This is fine for me. It might be interesting to warn users about this possible unintended interaction.