1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 13:21:38 +03:00

rename dead_key_is_active -> composition_status, dead_key_cursor -> compose_cursor

Since the composition state isn't strictly tied to dead keys, use
a name that better reflects that.
This commit is contained in:
Wez Furlong 2022-01-09 08:39:21 -07:00
parent ca69515e3b
commit 627001762e
9 changed files with 51 additions and 44 deletions

View File

@ -77,7 +77,7 @@ pub struct Palette {
/// color is used instead.
pub visual_bell: Option<RgbColor>,
/// The color to use for the cursor when a dead key or leader state is active
pub dead_key_cursor: Option<RgbColor>,
pub compose_cursor: Option<RgbColor>,
}
impl_lua_conversion!(Palette);

View File

@ -13,8 +13,8 @@ As features stabilize some brief notes about them will accumulate here.
#### New
* [window:dead_key_is_active()](config/lua/window/dead_key_is_active.md) and [window:leader_is_active()](config/lua/window/leader_is_active.md) methods that can help populate [window:set_right_status()](config/lua/window/set_right_status.md) [#686](https://github.com/wez/wezterm/issues/686)
* You may now use `colors = { dead_key_cursor = "orange" }` to change the cursor color when either a dead key or leader key is active.
* [window:composition_status()](config/lua/window/composition_status.md) and [window:leader_is_active()](config/lua/window/leader_is_active.md) methods that can help populate [window:set_right_status()](config/lua/window/set_right_status.md) [#686](https://github.com/wez/wezterm/issues/686)
* You may now use `colors = { compose_cursor = "orange" }` to change the cursor color when either a dead key or leader key is active.
* Support for SGR-Pixels mouse reporting. Thanks to [Autumn Lamonte](https://gitlab.com/klamonte)! [#1457](https://github.com/wez/wezterm/issues/1457)
* [ActivatePaneByIndex](config/lua/keyassignment/ActivatePaneByIndex.md) key assignment action. [#1517](https://github.com/wez/wezterm/issues/1517)
* Windows: wezterm will now use [win32-input-mode](https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md) to send high-fidelity keyboard input to ConPTY. This means that win32 console applications, such as [FAR Manager](https://github.com/FarGroup/FarManager) that use the low level `INPUT_RECORD` API will now receive key-up events as well as events for modifier-only key presses. [#318](https://github.com/wez/wezterm/issues/318) [#1509](https://github.com/wez/wezterm/issues/1509) [#1510](https://github.com/wez/wezterm/issues/1510)

View File

@ -62,9 +62,10 @@ return {
indexed = {[136] = "#af8700"},
-- Since: nightly builds only
-- When a dead key or a leader key are being processed, change the cursor
-- to this color to give a visual cue about the hold state
dead_key_cursor = "orange",
-- When the IME, a dead key or a leader key are being processed and are effectively
-- holding input pending the result of input composition, change the cursor
-- to this color to give a visual cue about the compose state.
compose_cursor = "orange",
}
}
```

View File

@ -0,0 +1,32 @@
# wezterm:composition_status()
*Since: nightly builds only*
Returns a string holding the current dead key or IME composition text,
or `nil` if the input layer is not in a composition state.
This is the same text that is shown at the cursor position when composing.
This example shows how to show the composition status in the status area.
The cursor color is also changed to `orange` when in this state.
```lua
local wezterm = require 'wezterm';
wezterm.on("update-right-status", function(window, pane)
local compose = window:composition_status()
if compose then
compose = "COMPOSING: " .. compose
end
window:set_right_status(compose)
end);
return {
colors = {
compose_cursor = "orange",
},
}
```
See also: [window:leader_is_active()](leader_is_active.md).

View File

@ -1,30 +0,0 @@
# wezterm:dead_key_is_active()
*Since: nightly builds only*
Returns `true` if a dead key is active in the window, or false otherwise.
This example shows `DEAD` in the right status area, and turns the cursor orange,
when a dead key is active:
```lua
local wezterm = require 'wezterm';
wezterm.on("update-right-status", function(window, pane)
local dead = ""
if window:dead_key_is_active() then
dead = "DEAD"
end
window:set_right_status(dead)
end);
return {
leader = { key="a", mods="CTRL" },
colors = {
dead_key_cursor = "orange",
},
}
```
See also: [window:leader_is_active()](leader_is_active.md).

View File

@ -21,9 +21,9 @@ end);
return {
leader = { key="a", mods="CTRL" },
colors = {
dead_key_cursor = "orange",
compose_cursor = "orange",
},
}
```
See also: [window:dead_key_is_active()](dead_key_is_active.md).
See also: [window:composition_status()](composition_status.md).

View File

@ -9,7 +9,7 @@ use mlua::{UserData, UserDataMethods};
use mux::window::WindowId as MuxWindowId;
use serde::*;
use wezterm_toast_notification::ToastNotification;
use window::{Connection, ConnectionOps, WindowOps, WindowState};
use window::{Connection, ConnectionOps, DeadKeyStatus, WindowOps, WindowState};
#[derive(Clone)]
pub struct GuiWin {
@ -146,11 +146,15 @@ impl UserData for GuiWin {
Ok(result)
});
methods.add_async_method("dead_key_is_active", |_, this, _: ()| async move {
methods.add_async_method("composition_status", |_, this, _: ()| async move {
let (tx, rx) = smol::channel::bounded(1);
this.window
.notify(TermWindowNotif::Apply(Box::new(move |term_window| {
tx.try_send(term_window.dead_key_active()).ok();
tx.try_send(match term_window.composition_status() {
DeadKeyStatus::None => None,
DeadKeyStatus::Composing(s) => Some(s.clone()),
})
.ok();
})));
let result = rx
.recv()

View File

@ -288,8 +288,8 @@ impl super::TermWindow {
}
}
pub fn dead_key_active(&self) -> bool {
self.dead_key_status != DeadKeyStatus::None
pub fn composition_status(&self) -> &DeadKeyStatus {
&self.dead_key_status
}
fn leader_done(&mut self) {

View File

@ -2454,7 +2454,7 @@ impl super::TermWindow {
let color = params
.config
.resolved_palette
.dead_key_cursor
.compose_cursor
.map(rgbcolor_to_window_color)
.unwrap_or(bg_color);