Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_ime=true conflicts with key assigments that defined in LEADER mode #1409

Closed
tizee opened this issue Dec 17, 2021 · 2 comments
Closed

use_ime=true conflicts with key assigments that defined in LEADER mode #1409

tizee opened this issue Dec 17, 2021 · 2 comments
Labels
bug Something isn't working fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. macOS Issue applies to Apple macOS

Comments

@tizee
Copy link

tizee commented Dec 17, 2021

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

macOS

WezTerm version

wezterm 20211213-091602-1f958fa1

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

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

When use_ime=false, everything works fine.
When use_ime=true, key assigments with LEADER are swallowed and all of them fail to work.

To Reproduce

set use_ime=true in your configuration.

Configuration

local wezterm = require 'wezterm';

-- The filled in variant of the < symbol
local SOLID_LEFT_ARROW = utf8.char(0xe0b2)

-- The filled in variant of the > symbol
local SOLID_RIGHT_ARROW = utf8.char(0xe0b0)

wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
  local edge_background = "#0b0022"
  local background = "#1b1032"
  local foreground = "#808080"

  if tab.is_active then
    background = "#2b2042"
    foreground = "#c0c0c0"
  elseif hover then
    background = "#3b3052"
    foreground = "#909090"
  end

  local edge_foreground = background

  -- ensure that the titles fit in the available space,
  -- and that we have room for the edges
  local title = wezterm.truncate_right(tab.active_pane.title, max_width-2)

  return {
    {Background={Color=edge_background}},
    {Foreground={Color=edge_foreground}},
    {Text=SOLID_LEFT_ARROW},
    {Background={Color=background}},
    {Foreground={Color=foreground}},
    {Text=(tab.tab_index+1) .. ":" .. title},
    {Background={Color=edge_background}},
    {Foreground={Color=edge_foreground}},
    {Text=SOLID_RIGHT_ARROW},
  }
end)

return {
  -- general settings <-
  check_for_updates = true,
  exit_behavior="CloseOnCleanExit", -- only exit with a successful status
  default_cursor_style = "SteadyUnderline",
  -- http://www.leonerd.org.uk/hacks/fixterms/
  enable_csi_u_key_encoding = true,
  -- ->
  -- window settings <-
  window_padding = {
    left = 0,
    right = 0,
    top = 0,
    bottom = 0,
  },
  -- ->
  -- tab bar settings <-
  -- set to false to disable the tab bar completely
  enable_tab_bar = true,
  -- ->
  -- font settings <-
  font_size = 16,
  font = wezterm.font_with_fallback({
    {
      family="JetBrains Mono",
      weight="Regular",
      italic=false
    },
    {
      family="JetBrainsMono Nerd Font",
      weight="Bold"
    },
    "SimHei" -- for Chinese or Japanese
    }),
  -- ->
  -- hotkeys <-
  -- tmux uses CTRL-A
  leader = { key="a", mods="CMD", timeout_milliseconds=1002 },
  keys = {
     -- Send "CTRL-A" to the terminal when pressing LEADER-a for tmux
    {key="a", mods="LEADER", action=wezterm.action{SendString="\x01"}},
    -- h,j,k,l move between panes
    {key="h", mods="LEADER", action=wezterm.action{ActivatePaneDirection="Left"}},
    {key="j", mods="LEADER", action=wezterm.action{ActivatePaneDirection="Down"}},
    {key="k", mods="LEADER", action=wezterm.action{ActivatePaneDirection="Up"}},
    {key="l", mods="LEADER", action=wezterm.action{ActivatePaneDirection="Right"}},
    -- vertical split direction
    {key="s", mods="LEADER", action=wezterm.action{SplitVertical={domain="CurrentPaneDomain"}}},
    -- horizontal split direction
    {key="d", mods="LEADER", action=wezterm.action{SplitHorizontal={domain="CurrentPaneDomain"}}},
    -- close current pane
    {key="x", mods="LEADER", action=wezterm.action{CloseCurrentPane={confirm=true}}},
    -- zoom state
    {key="z", mods="LEADER", action="TogglePaneZoomState"},
    -- fullscreen
    {key="f", mods="LEADER", action="ToggleFullScreen"},
    -- debug
    {key="p", mods="LEADER", action="ShowDebugOverlay"},
    -- copy mode
    {key="c", mods="LEADER", action="ActivateCopyMode"},
    -- quick select mode - git hash, url etc.
    {key="q", mods="LEADER", action="QuickSelect"},
    -- reload configuration
    {key="r", mods="LEADER", action="ReloadConfiguration"},
  },
  -- ->
  -- IME
  -- https://github.com/wez/wezterm/pull/1096
  send_composed_key_when_left_alt_is_pressed=false,
  send_composed_key_when_right_alt_is_pressed=true,
  use_ime = true,
  use_dead_keys= false, -- prevent combination 
  -- debug by launching wezterm in other terminal
  debug_key_events = true,
  color_scheme = "Dracula",
  -- enables ligatures
  harfbuzz_features = {"calt=1", "clig=1", "liga=1"},
}

-- vim:foldmarker=<-,-> foldmethod=marker

Expected Behavior

When use_ime=true, shortcut defined with LEADER modifier works.

Logs

INFO  wezterm_mux_server_impl::local > setting up /Users/tizee/.local/share/wezterm/gui-sock-20481
INFO  wezterm_gui::termwindow        > OpenGL initialized! AMD Radeon Pro 5500M OpenGL Engine 4.1 ATI-4.7.29 is_context_loss_possible=false wezterm version: 20211213-091602-1f958fa1
INFO  wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Char('a'), modifiers: SUPER, raw_key: None, raw_modifiers: SUPER, raw_code: Some(0), repeat_count: 1, key_is_down: true }
wezterm-gui[20481:38817506] TSM AdjustCapsLockLEDForKeyTransitionHandling - _ISSetPhysicalKeyboardCapsLockLED Inhibit
INFO  wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Composed("s"), modifiers: NONE, raw_key: None, raw_modifiers: NONE, raw_code: None, repeat_count: 1, key_is_down: true }

Anything else?

No response

@tizee tizee added the bug Something isn't working label Dec 17, 2021
@tizee
Copy link
Author

tizee commented Dec 17, 2021

I have to address this by modifying the code on handling KeyCode::Compose(String).

wez added a commit that referenced this issue Dec 31, 2021
When the IME is enabled, pressing `CTRL-A P` would generate
`Composed("P")` for the second key press, which we couldn't
then match in the keymapping layer.

This commit checks for that and normalizes it to `Char('P')`
instead.

refs: #1409
refs: #1410
@wez wez added fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. macOS Issue applies to Apple macOS labels Dec 31, 2021
@tizee tizee closed this as completed Dec 31, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. macOS Issue applies to Apple macOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants