1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-29 00:21:57 +03:00
A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
Go to file
Wez Furlong 61c52af491 wezterm: add raw_code concept to input layer
This commit is a bit noisy because it also meant flipping the key map
code from using the termwiz input types to the window input types, which
I thought I'd done some time ago, but clearly didn't.

This commit allows defining key assignments in terms of the underlying
operating system raw codes, if provided by the relevant layer in the
window crate (currently, only X11/Wayland).

The raw codes are inherently OS/Machine/Hardware dependent; they are the
rawest value that we have available and there is no meaningful
understanding that we can perform in code to understand what that key
is.

One useful property of the raw code is that, because it hasn't gone
through any OS level keymapping processing, its value reflects its
physical position on the keyboard, allowing you to map keys by position
rather than by value.  That's useful if you use software to implement
eg: DVORAK or COLEMAK but want your muscle memory to kick in for some of
your key bindings.

New config option:

`debug_key_events = true` will cause wezterm to log an "error" to stderr
each time you press a key and show the details in the key event:

```
2020-12-06T21:23:10.313Z ERROR wezterm_gui::gui::termwindow > key_event KeyEvent { key: Char('@'), modifiers: SHIFT | CTRL, raw_key: None, raw_modifiers: SHIFT | CTRL, raw_code: Some(11), repeat_count: 1, key_is_down: true }
```

This is useful if you want to figure out the `raw_code` for a key in your
setup.

In your config, you can use this information to setup new key bindings.
The motivating example for me is that because `raw_key` (the unmodified
equivalent of `key`) is `None`, the built-in `CTRL-SHIFT-1` key
assignment doesn't function for me on Linux, but I can now "fix" this in
my local configuration, taking care to make it linux specific:

```lua
local wezterm = require 'wezterm';
local keys = {}

if wezterm.target_triple == "x86_64-unknown-linux-gnu" then
  local tab_no = 0
  -- raw codes 10 through 19 correspond to the number key 1-9 positions
  -- on my keyboard on my linux system.  They may be different on
  -- your system!
  for i = 10, 20 do
    table.insert(keys, {
      key="raw:"..tostring(i),
      mods="CTRL|SHIFT",
      action=wezterm.action{ActivateTab=tab_no},
    })
    tab_no = tab_no + 1
  end
end

return {
  keys = keys,
}
```

Notice that the key assignment accepts encoding a raw key code using
a value like `key="raw:11"` to indicate that you want a `raw_code` of
`11` to match your key assignment.  The `raw_modifiers` portion of
the `KeyEvent` is used together with the `raw_code` when deciding
the key assignment.

cc: @bew
2020-12-06 13:41:29 -08:00
.cargo build static on windows for static openssl linkage 2020-02-02 13:03:07 -08:00
.github Updates for building on Fedora 33 2020-11-29 10:26:11 -08:00
assets wezterm-font: bundle a last resort font 2020-11-22 16:12:20 -08:00
async_ossl fixup tls mux sessions 2020-10-04 21:47:12 -07:00
base91 dyn everywhere 2019-06-08 21:28:11 -07:00
bintree wezterm: improve pane resize logic 2020-09-27 16:07:08 -07:00
ci docs: link to fedora 33 nightly builds 2020-12-04 22:09:48 -08:00
codec cargo update 2020-12-05 10:35:00 -08:00
config wezterm: add raw_code concept to input layer 2020-12-06 13:41:29 -08:00
deps harfbuzz: skip some unused bits 2020-12-05 14:19:47 -08:00
docs docs: link to fedora 33 nightly builds 2020-12-04 22:09:48 -08:00
env-bootstrap wezterm: add env bootstrap to mux server, too 2020-10-24 23:33:31 -07:00
filedescriptor fix filedescriptor::poll on macos 2020-09-10 13:58:14 -07:00
licenses macOS: bundle and use MetalANGLE to enable Metal rendering 2020-10-17 09:34:01 -07:00
luahelper deps: remove unused deps 2020-11-20 12:37:38 -08:00
mux wezterm: improve shaping of emoji 2020-11-23 13:45:38 -08:00
promise deps: remove unused deps 2020-11-20 12:37:38 -08:00
pty deps: normalize the lazy-static version 2020-11-13 08:15:35 -08:00
rangeset wezterm-font: compute codepoint coverage for font-dirs 2020-11-25 20:41:09 -08:00
ratelim move ratelim to its own crate 2020-10-03 11:15:57 -07:00
strip-ansi-escapes move strip-ansi-escapes into its own crate 2020-10-03 11:15:57 -07:00
tabout Change cell api to avoid direct access to hyperlink/image 2020-10-11 13:12:46 -07:00
term term: fix ALT-Escape 2020-11-23 14:20:43 -08:00
termwiz wezterm-font: improve fallback font scaling 2020-11-23 16:59:30 -08:00
test-data wezterm: improve shaping of emoji 2020-11-23 13:45:38 -08:00
tmux-cc tmux: attach control mode parser to terminal 2020-11-20 09:24:50 -08:00
umask Move server to its own wezterm-mux-server binary 2020-10-03 11:15:57 -07:00
vtparse avoid panic if someone cats a PNG to the terminal 2020-10-16 13:09:50 -07:00
wezterm wezterm: add wezterm set-working-directory 2020-11-13 09:27:14 -08:00
wezterm-client mux/wezterm: move Renderable into Pane 2020-11-20 09:24:56 -08:00
wezterm-font harfbuzz: skip some unused bits 2020-12-05 14:19:47 -08:00
wezterm-gui wezterm: add raw_code concept to input layer 2020-12-06 13:41:29 -08:00
wezterm-gui-subcommands wezterm: add --class option to specify window class 2020-11-13 08:15:35 -08:00
wezterm-mux-server mux/wezterm: move Renderable into Pane 2020-11-20 09:24:56 -08:00
window wezterm: add raw_code concept to input layer 2020-12-06 13:41:29 -08:00
.cirrus.yml ci: moar freebsd 2020-10-06 09:53:45 -07:00
.gitignore wezterm-font: move caching of freetype font size into Face 2020-11-25 09:20:14 -08:00
.gitmodules fix CI: savannah is down, use a github mirror for freetype 2019-11-24 13:28:02 -08:00
.rustfmt.toml Make rustfmt happy about "async move" 2020-01-20 13:58:21 -08:00
Cargo.lock wezterm: add raw_code concept to input layer 2020-12-06 13:41:29 -08:00
Cargo.toml wezterm-font: move caching of freetype font size into Face 2020-11-25 09:20:14 -08:00
CONTRIBUTING.md Add get-deps script for installing dependencies 2018-02-25 09:24:56 -08:00
get-deps Updates for building on Fedora 33 2020-11-29 10:26:11 -08:00
LICENSE.md wezterm: bundle JetBrains Mono and Noto Color Emoji fonts 2020-09-29 22:05:18 -07:00
README.md docs: add a bit about contributing 2020-06-16 22:16:56 -07:00
wt-record make it a bit easier to consume wt-record 2020-06-12 08:51:15 -07:00
wt-replay update record/play scripts for macos 2019-03-22 20:41:50 -07:00

Wez's Terminal

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust

User facing home page at: https://wezfurlong.org/wezterm/

Screenshot

Screenshot of wezterm on macOS, running vim

Installation

https://wezfurlong.org/wezterm/installation.html

Getting help

This is a spare time project, so please bear with me. There are two channels for support:

The Matrix/Gitter room is probably better suited to questions than it is to bug reports, but don't be afraid to use whichever you are most comfortable using and we'll work it out.