d99kris / nchat

Terminal-based Telegram / WhatsApp client for Linux and macOS
MIT License
524 stars 40 forks source link

Wrong behavior with Modifier keys and arrows #206

Closed xxkfqz closed 3 months ago

xxkfqz commented 3 months ago

Description:

I used nchat --keydump to get right codes (i.e. \1046 for Alt+LeftArrow with XFree 4 emulation or \404 with Linux emultation in Konsole) and edit config but there is "wrong character" in textbox instead of moving backward/forward one word. Same with Ctrl+AnyArrow. I think it is probably related to #179

Screenshot_20240319_013724

How to reproduce it:

Same as in #179: launch nchat, write some words in text input and then try Alt+LeftArrow or Ctrl+LeftArrow.

Environment:

Disonantemus commented 3 months ago

Maybe is related to this discussion and that information can help you.

Bellavene commented 3 months ago

Is it only on first press? I have this with only alt+right arrow, and only on first press.

xxkfqz commented 3 months ago

@Bellavene No, it is on every press

d99kris commented 3 months ago

Hi @xxkfqz - thanks for reporting a bug. I don't have a Gentoo setup available, but I tested openSUSE Tumbleweed with Konsole v24.02.0.

I used nchat --keydump to obtain key codes for alt-left and alt-right, and when the terminal is able to provide unique key codes for alt-left/right, nchat is also able to detect and handle them. Could you confirm whether nchat --keydump outputs the same code for left and alt-left, or whether it's a unique code when using alt?

Below are the results from testing the four Konsole Key bindings profiles. XFree 4 and macOS profiles work fine for me.

Default (XFree 4)

\4001050
\4001067

Working with ~/.nchat/key.conf config:

backward_word=\4001050
forward_word=\4001067

Linux console

\4000404 KEY_LEFT
\4000405 KEY_RIGHT

Not working - same key codes as without alt.

Solaris console (same result as Linux console)

macOS

\4001050
\4001067

Working with ~/.nchat/key.conf config:

backward_word=\4001050
forward_word=\4001067
xxkfqz commented 3 months ago

@d99kris Just tested key codes and got different results:

XFree 4 profile

\4000404 KEY_LEFT           <-- left
\4001046                    <-- alt+left
\4000405 KEY_RIGHT          <-- right
\4001065                    <-- alt+right

Linux profile

\4000404 KEY_LEFT           <-- left
\4000404 KEY_LEFT           <-- alt+left
\4000405 KEY_RIGHT          <-- right
\4000405 KEY_RIGHT          <-- alt+right

I switched to XFree 4 profile and changed key.conf to this:

backward_word=\4001046
forward_word=\4001065

and now it works how it should. Do not understand why it does not work before I opened issue. Anyway it was my mistake, sorry for disturbing

d99kris commented 3 months ago

No worries - good to hear it's working now 👍