Skip to content
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

only a limited set of keys can be combined with ctrl_; the error message is confusing #358

Open
t184256 opened this issue Sep 14, 2021 · 5 comments

Comments

@t184256
Copy link

t184256 commented Sep 14, 2021

On 8f4428e, with a key_map like

key_map:
    home: input_move_curs_start
    end: input_move_curs_end
    ctrl_n: tab_prev
    ctrl_h: tab_move_left

I get Can't parse TUI config: Message("invalid value: string \"ctrl_h\", expected single keys: backspace, del, end, esc, home, pgdown, pgup, tab, up, down, left right, [a-z], [0-9], [f1-f12]. modifiers with an arrow key, function key, or single characters: alt, shift, ctrl", Some(Pos { marker: Marker { index: 2702, line: 135, col: 4 }, path: "key_map" }))

My suspicions are, I'm unable to set bindings beyond what's defined in the default config.

@trevarj
Copy link
Contributor

trevarj commented Sep 14, 2021

The issue here is "ctrl_h", which isn't allowed for remapping since we already interpret it as a Backspace due to #295

@t184256
Copy link
Author

t184256 commented Sep 14, 2021

Not sure about that, since, e.g, ctrl_i, ctrl_0 or ctrl_щ also error out with the same message (with 1 char difference, of course).

@t184256
Copy link
Author

t184256 commented Sep 14, 2021

Oh, wait, sorry, now I get it. So, we'll never have ctrl_h or ctlr_i, we're limited to that list?

@t184256 t184256 changed the title cannot define a keybinding outside of the default ones only a limited set of keys can be combined with ctrl_; the error message is confusing Sep 14, 2021
@trevarj
Copy link
Contributor

trevarj commented Sep 14, 2021

Right...and since ctrl_щ and ctrl_o are the same keycodes (can check with showkey -a on linux), you'll have to use ctrl_o.

Maybe there is a different way to handle the keys so you can use ctrl_h but not lose backspace? (cc: maybe @osa1 knows)

@osa1
Copy link
Owner

osa1 commented Sep 14, 2021

So the general problem here is terminal emulators are often weird and map different key events to same byte sequences when passing them down to the shell (which then passes them to the program being run in the shell). You can try this by running cargo run --example input in crates/termbox. Try some ctrl+key combinations and other keys and you'll notice that some keys generate the same key sequence. (use ESC to quit) In tiny we only support xterm-compatible terminals (terminals that map keys to the same key sequences as xterm), and as shown in the issue linked above in xterm generates the same byte sequence for C-h and backspace in some recent versions. So we have no way of distinguishing C-h from backspace. There are a few more keys like this.

Action items:

  • We should document this in the Wiki page and link people to the page when this is asked.
  • We should use terminfo to read terminal capabilities and key mappings and allow this kind of thing if the terminal supports it. I'm guessing not all terminals map C-h and backspace to the same sequence. No need to treat these keys as the same on those terminals.
  • The error message in the report is confusing, improve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants