Skip to content

Conversation

@DanielLukic
Copy link

hi there, this is just an fyi PR for you. i'm currently working on a fun side project to learn dart.

if you're interested:

anyway, i was using https://pub.dev/packages/dart_console initially. and it works for me. but i found your repo and it looks more advanced. so i integrated it as an alternative. the commit would be, again in case you're interested: DanielLukic/consul-dart@7e66d1a

but i noticed that a) mouse motion events are not delivered. i only then realized everything works in tmux and without a multiplexer. but not inside zellij. so obviously an edge case. but maybe worth mentioning or providing a potential work around? afaik zellij people are not eager to be more compatible. but ofc this seems to be a zellij issue.

i also noticed that <C-?> is mapped to and i don't know why that is.. 🙃 🤷 so another quirk fix in this PR would allow receiving <C-?>. not sure, i'm probably missing something here.

finally, i noticed that in raw mode is still mapped to . is this what is standard usually? i find that weird. doesn't raw mode remap to also? in my own code i have a dedicated Control.Return and don't even use "enter" because it confused me.. a lot.. 🤣 🤷 🙈

well... this being said.. this PR is just a fyi.. wasn't sure how else/best to contact you.. but feel free to ignore/close.. that's totally fine..

cheers, daniel

@kascote
Copy link
Owner

kascote commented Apr 25, 2024

First, thanks for the PR! I'll take a look shortly (I'm with a lot of work)
BTW I'll love in the meantime if have some time, to hear your comments/critics on the integration with Consul

@DanielLukic
Copy link
Author

integration was straight forward. i do have my own representation of mouse and key events. so it came down to mapping onto these. i'm running my kraken tui with termlib at the moment without issues.

but this PR is really only meant as an FYI. not meant to be merged like this. having the global switches is obviously not ideal. but i didn't want to invest too much time before checking with you. because i'm probably missing some info. never really looked much into modern term protocols or anything like that.. 🙈

this is the entire integration fyi: https://github.com/DanielLukic/consul-dart/blob/termlib/lib/src/consul/con_io/termlib_con_io.dart

@kascote
Copy link
Owner

kascote commented Apr 27, 2024

WOW.. consul-dart is super amazing! I'll be digging into that repo!, and krok-term is cool too, but I don't have a API to try

Regarding this PR.. I still do not did a proper rundown with multiplexers, but is on my to-do list. I'll work with them after the next release that is almost finished. I'll look more about the 1002 and 1005 events

Key detection/handling is more complex and the default/old terminal key handler has no way to disambiguate keys.

I suggest to use the examples key_viewer and raw_keyviewer from the termlib package to view what is being received and interpreted.

[C-?]: with the default key handling, this key combination is mapped to 0x7f and that is backspace, if you press backspace will receive the same key code. With the default key handling there is no way to know the difference.

[C-J]: seems this key sequence has the value 0x10 and that is a line feed, need to dig into this to be sure if is that value, but the same case as before, with the default key handling detection this are know issues.

The solution to this is use a terminal that implements the Kitty Key Handling protocol

this is an example output using dart run examples/key_async.dart -kitty, that will enable the kitty protocol handling:

Screenshot 2024-04-27 at 18 38 05

There are different modes that can enabled with the protocol and event get Press and Release events.

I'll not change the default key handling method, that could have a lot of unintended side effects. I'll think around this.

Regarding the raw mode, I'm not aware that raw mode modify in any way the key handling. It only change some terminal features, like disable echo, disable key interpretations and for example ctrl-c is delivered to the app and not send the break signal, etc.

@kascote
Copy link
Owner

kascote commented Apr 28, 2024

I was digging a bit into the 1015 mouse event and found this:

URXVT (1015)
The normal mouse response is altered to use CSI followed by
semicolon-separated encoded button value, the Cx and Cy ordi-
nates and final character M .
This uses the same button encoding as X10, but printing it as
a decimal integer rather than as a single byte.
However, CSI M can be mistaken for DL (delete lines), while
the highlight tracking CSI T can be mistaken for SD (scroll
down), and the Window manipulation controls. For these rea-
sons, the 1015 control is not recommended; it is not an
improvement over 1005.

https://gist.github.com/halcyon/334da650816876d7be4d1bee8a157f25#file-gistfile1-txt-L1703

I think '1000;1003;1006' is the good enough setup to avoid issues.

@DanielLukic
Copy link
Author

Understood. Again, I just hacked the code to make it work for me. I assumed there are good reasons for why it behaved differently. I clearly looks more "correct" than what I was using before.. 🙃

However, using the raw_keyviewer, weirdly I do receive 1f for <C-?> vs 7f for <Backspace>. Inside ZelliJ or TMux or without a multiplexer. This is in a standard Linux Mint terminal.. 🤷

Anyway, I can stick with the old input mapping that works for me. I can combine this easily with termlib.. 👍

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

Successfully merging this pull request may close these issues.

2 participants