Skip to content

Commit

Permalink
Work around Linux keycodes by mapping ^_ to ^7
Browse files Browse the repository at this point in the history
On Linux terminal, keycodes for `^/`, `^_`, and `^7` are the same. The
parsed key depends on the library that handles the input. In case of
Zee, it uses Zi framework for terminal based applications, which uses
crossterm library to get key events.

For more details, see crossterm issues:

- crossterm-rs/crossterm#540
- crossterm-rs/crossterm#685

To check if it reproduces on your machine, you can try

```
showkey --ascii
```

- Crossterm - https://github.com/crossterm-rs/crossterm
- Zi - https://github.com/mcobzarenco/zi
  • Loading branch information
qezz committed Jun 10, 2024
1 parent 00cb661 commit 8dd6a52
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion zee/src/components/buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,22 @@ impl Component for Buffer {
.command("undo", |this: &Self| {
this.properties.cursor.undo();
})
.with([Ctrl('_')])
.with([Ctrl('z')])
// On Linux terminal, keycodes for `^/`, `^_`, and `^7` are the same. The
// parsed key depends on the library that handles the input. In case of Zee,
// it uses Zi framework for terminal based applications, which uses
// crossterm library to get key events.
//
// For more details, see crossterm issues:
// - https://github.com/crossterm-rs/crossterm/issues/540
// - https://github.com/crossterm-rs/crossterm/issues/685
//
// To check if it reproduces on your machine, you can try
// ```shell
// showkey --ascii
// ```
.with([Ctrl('7')])
.with([Ctrl('_')])
.with([Ctrl('/')]);

// Redo
Expand Down

0 comments on commit 8dd6a52

Please sign in to comment.