atuin icon indicating copy to clipboard operation
atuin copied to clipboard

crossterm support

Open conradludgate opened this issue 2 years ago • 7 comments

For #282, fixes #283.

Todo

  • [x] Fix failure to launch on 'up' keybinding
  • [x] Fix up/down keys in the TUI (ctrl-n/p work fine)

conradludgate avatar Apr 22 '22 20:04 conradludgate

A curiosity, I've decided to try partial upgrade (tui 0.18 + termion) and it's still eating my arrow key inputs, but otherwise still responsive. So I'm not sure what's going on there

conradludgate avatar Apr 26 '22 07:04 conradludgate

So I'm not sure what's going on there

Do you know what mode your terminal is in? Different modes can send different escape sequences, and it could be listening for the wrong ones

EG we switch to cursor mode here: https://github.com/ellie/atuin/blob/main/src/shell/atuin.zsh#L34

and perhaps termion doesn't like that

ellie avatar Apr 26 '22 07:04 ellie

Do you know what mode your terminal is in? Different modes can send different escape sequences, and it could be listening for the wrong ones

Yeah, I was debugging and termion/crossterm never get the up/down. Which made me try again with our current version.

When running atuin search -i manually, it exhibits this behaviour. When running from the keybinding, it is fine 🚀

conradludgate avatar Apr 26 '22 07:04 conradludgate

When running from the keybinding, it is fine 🚀

Yup I had this when I was writing the initial implementation. Some applications can switch terminal mode and then don't switch it back, leaving other programs in a broken state

Terminal stuff has a lot of baggage 😂

But otherwise it all works? search -i is only really supposed to run from the binding anyway 🤔

ellie avatar Apr 26 '22 07:04 ellie

I'm rebasing this branch now, I'll let you know

conradludgate avatar Apr 26 '22 07:04 conradludgate

https://github.com/crossterm-rs/crossterm/issues/396 :/

conradludgate avatar Apr 26 '22 08:04 conradludgate

Ok, final conclusion since I've spent a while debugging this now. It's a combination of quite a few problems:

  1. On ZSH, in our hook, stdin is not a tty. This is different to bash and fish
  2. On macos, kqueue can't poll from /dev/tty
  3. crossterm uses mio to poll from the tty, which uses kqueue on macos.

mio said they won't fix this specific behaviour, tbh I agree: https://github.com/tokio-rs/mio/issues/1377

There's an open PR for crossterm to manually use select() for /dev/tty: https://github.com/crossterm-rs/crossterm/pull/711

So far, this patch fixed it for me

conradludgate avatar Sep 14 '22 11:09 conradludgate

@conradludgate looks like there's been some motion on that crossterm PR, and now this has been opened

https://github.com/crossterm-rs/crossterm/pull/735

ellie avatar Dec 18 '22 17:12 ellie

Yep. I've been following it. Hopefully it gets merged at some point

conradludgate avatar Dec 18 '22 18:12 conradludgate

Just waiting for a new crossterm release after the merge ⏳

conradludgate avatar Jan 26 '23 11:01 conradludgate

Crossterm 0.26 is out 🎉 https://github.com/crossterm-rs/crossterm/releases/tag/0.26

pdecat avatar Jan 28 '23 12:01 pdecat

I have updated to 0.26 crossterm and started vendoring a minimal subset of tui (now that it's maintenance is in question). It can be trimmed down further, but I don't want to go too minimal incase there are features we end up using.

conradludgate avatar Jan 28 '23 13:01 conradludgate