1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-20 20:01:38 +03:00
wezterm/window/Cargo.toml
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

73 lines
2.1 KiB
TOML

[package]
name = "window"
version = "0.1.0"
authors = ["Wez Furlong"]
edition = "2018"
repository = "https://github.com/wez/wezterm"
description = "Cross platform window setup and render"
license = "MIT"
build = "build.rs"
[dev-dependencies]
pretty_env_logger = "0.4"
[build-dependencies]
gl_generator = {version="0.14", optional=true}
[dependencies]
async-task = "1.2"
anyhow = "1.0"
thiserror = "1.0"
bitflags = "1.0"
euclid = "0.20"
guillotiere = "0.6"
lazy_static = "1.4"
libloading = { version = "0.6", optional=true }
line_drawing = "0.8"
log = "0.4"
metrics = { version="0.12", features=["std"]}
palette = "0.5"
promise = { path = "../promise" }
resize = "0.3"
serde = {version="1.0", features = ["rc", "derive"]}
glium = { version = "0.28", optional=true, default-features = false}
[features]
opengl = ["cgl", "glium", "gl_generator", "libloading"]
wayland = ["smithay-client-toolkit", "memmap", "wayland-client", "wayland-egl"]
[target."cfg(windows)".dependencies]
winapi = { version = "0.3", features = [
"dwmapi",
"handleapi",
"imm",
"libloaderapi",
"synchapi",
"winerror",
"winuser",
]}
winreg = "0.6"
clipboard-win = "2.2"
shared_library = "0.1"
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
filedescriptor = { version="0.7", path = "../filedescriptor" }
x11 = {version ="2.18", features = ["xlib_xcb"]}
xcb = {version="0.9", features=["shm", "xkb", "xlib_xcb"]}
xcb-util = { features = [ "icccm", "ewmh", "keysyms", "shm"], version = "0.3" }
xkbcommon = { version = "0.5", features = ["x11", "wayland"], git="https://github.com/wez/xkbcommon-rs.git", rev="01a0a0cd5663405e6e4abb1ad3add9add1496f58"}
mio = "0.6"
libc = "0.2"
smithay-client-toolkit = {version = "0.9", optional = true, features=["calloop"], git="https://github.com/wez/client-toolkit.git", branch="title_trunc"}
memmap = {version="0.7", optional=true}
wayland-client = {version="0.26", optional=true}
wayland-egl = {version="0.26", optional=true}
[target.'cfg(target_os="macos")'.dependencies]
cocoa = "0.20"
objc = "0.2"
clipboard = "0.5"
core-foundation = "0.7"
core-graphics = "0.19"
cgl = { version = "0.3", optional = true }