wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
16.37k stars 726 forks source link

ctrl-space tra #4055

Open Amleto opened 1 year ago

Amleto commented 1 year ago

What Operating System(s) are you seeing this problem on?

Windows

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20230712-072601-f4abf8fd

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

No, and I'll explain why below

Describe the bug

Not sure how to get nightly through winget. I have seen the couple of previous bug from mar/april referring to ctrl /, and ctrl-i. I am seeing an issue with ctrl-space.

I first found this due to being unable to get a keymap working in neovim. If I open the neovim qt terminal, then c-space works ok.

To Reproduce

in wezterm launch nvim with nvim --clean

in nvim, after pressing i to enter insert mode, ctrl + v enters a kind of 'capture' mode. Then enter ctrl + space. The initial ^ from the ctrl-v is present and hasnt been updated from the ctrl-space combination.

Configuration

-- Pull in the wezterm API
local wezterm = require 'wezterm'
local act = wezterm.action

-- This table will hold the configuration.
local config = {}

-- config.debug_key_events = true

-- In newer versions of wezterm, use the config_builder which will
-- help provide clearer error messages
if wezterm.config_builder then
  config = wezterm.config_builder()
end

-- This is where you actually apply your config choices

-- For example, changing the color scheme:
--config.color_scheme = 'rose-pine-moon'
config.color_scheme = 'rose-pine-moon'
config.colors = {
  scrollbar_thumb = '#555588',
}

config.default_prog = { 'c:\\Program Files\\git\\bin\\bash.exe', '--login' }

config.font = wezterm.font_with_fallback({
    "CaskaydiaCove Nerd Font Mono",
    "Cascadia Code Mono",
    "JetBrains Mono",
})

-- disable ligatures
config.harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' }

config.enable_scroll_bar = true

config.keys = {
    { key = 'v', mods = 'CTRL|SHIFT', action = act.PasteFrom 'Clipboard' },
    { key = 'c', mods = 'CTRL|SHIFT', action = act.CopyTo 'Clipboard' },
}

-- multiplexing
--config.unix_domains = {
--  {
--    name = 'unix',
--  },
--}

-- This causes `wezterm` to act as though it was started as
-- `wezterm connect unix` by default, connecting to the unix
-- domain on startup.
-- If you prefer to connect manually, leave out this line.
-- config.default_gui_startup_args = { 'connect', 'unix' }

config.initial_rows = 25
config.initial_cols = 120

-- and finally, return the configuration to wezterm
return config

Expected Behavior

launch nvim with nvim --clean

in nvim, after pressing i to enter insert mode, ctrl + v enters a kind of 'capture' mode. Then ctrl + space should result in <C-Space> being inserted.

Check that ctrl+v functionality is working as expected (from insert mode): ctrl + v, ctrl + j should insert ^@

Logs

23:44:53.547  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(LeftControl), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(LeftControl), raw_code: 17, scan_code: 29, repeat_count: 1, key_is_down: true, handled: Handled(false) }
23:44:53.550  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: LeftControl, modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(LeftControl), raw_code: 17, scan_code: 29, repeat_count: 1, key_is_down: true, handled: Handled(false) }), win32_uni_char: Some('\0') }
23:44:53.551  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > win32: Encoded input as "\u{1b}[17;29;0;1;8;1_"
23:44:53.850  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(Space), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(Space), raw_code: 32, scan_code: 57, repeat_count: 1, key_is_down: true, handled: Handled(false) }
23:44:53.853  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: Char(' '), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(Space), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(Space), raw_code: 32, scan_code: 57, repeat_count: 1, key_is_down: true, handled: Handled(false) }), win32_uni_char: Some(' ') }
23:44:53.855  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > win32: Encoded input as "\u{1b}[32;57;32;1;8;1_"
23:44:53.943  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(Space), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(Space), raw_code: 32, scan_code: 57, repeat_count: 1, key_is_down: false, handled: Handled(false) }
23:44:53.946  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: Char(' '), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(Space), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(Space), raw_code: 32, scan_code: 57, repeat_count: 1, key_is_down: false, handled: Handled(false) }), win32_uni_char: Some(' ') }
23:44:53.948  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > win32: Encoded input as "\u{1b}[32;57;32;0;8;1_"
23:44:54.124  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, leds: NUM_LOCK, phys_code: Some(LeftControl), raw_code: 17, scan_code: 29, repeat_count: 1, key_is_down: false, handled: Handled(false) }
23:44:54.127  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: LeftControl, modifiers: NONE, leds: NUM_LOCK, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, leds: NUM_LOCK, phys_code: Some(LeftControl), raw_code: 17, scan_code: 29, repeat_count: 1, key_is_down: false, handled: Handled(false) }), win32_uni_char: Some('\0') }
23:44:54.128  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > win32: Encoded input as "\u{1b}[17;29;0;0;0;1_"

Anything else?

on windows with nvim installed, launching the nvim qt terminal handles ctrl-space as expected.

Amleto commented 1 year ago

Possibly I could use this workaround that was mentioned for win terminal (not sure how to convert to wezterm config) https://github.com/microsoft/terminal/issues/2865#issuecomment-929522127

wez commented 1 year ago

I'd suggest disabling https://wezfurlong.org/wezterm/config/lua/config/allow_win32_input_mode.html https://wezfurlong.org/wezterm/config/key-encoding.html has more information about keyboard encoding

Amleto commented 1 year ago

Thanks for the reply.

I tried different combinations of enable_csi_u_key_encoding and allow_win32_input_mode, but didn't see any differences.

Kamholtz commented 1 year ago

After some experimenting I have had success with this workaround in the context of Neovim (I have not tested it elsewhere):

local act = wezterm.action
local config = {}

config.default_prog = { 'pwsh.exe' }

config.keys = {
  {
    key = ' ',
    mods = 'CTRL',
    action = act.SendKey {
      key = ' ',
      mods = 'CTRL',
    },
  }
}

return config
Amleto commented 1 year ago

Wow, great! This works with git-bash and neovim

ashb commented 3 months ago

If anyone is on OSX and wondering why it's not working, -- ctrl-space is the default "previous input source" hotkey https://apple.stackexchange.com/questions/423971/disable-controlspace-keyboard-shortcut so if it's on (which it is by default) then Wezterm never even sees the hotkey. Disable it in osx and it should just work (none of the keymapping needed)