Commit 1799941957

17999419570a0d3b4650c05c0bc0d01efcde92f8

parent: 0cd0155f9a

Unregistered key

vaw <git@nlih.de> · 2026-09-12 00:18 UTC
committer: <noreply@github.com>

Add `CursorShape::Auto` (#665)

Layout: unified · split

docs/iamb.5 +11 −1
@@ -583,11 +583,21 @@ The available fields in this subsection are:
583583Control the terminal cursor shape used by iamb.
584584Possible values are:
585585.Dq Sy default ,
586.Dq Sy auto ,
586587.Dq Sy block ,
587588.Dq Sy line , and
588589.Dq Sy underline .
590The mode
591.Dq Sy auto
592switches between
593.Dq Sy block
594in normal mode,
595.Dq Sy line
596in insert mode, and
597.Dq Sy underline
598in replace mode.
589599Defaults to
590.Dq Sy default .
600.Dq Sy auto .
591601.It Sy enable_extended_keys
592602Defines whether to explicitly enable or disable requesting extended keypresses from your terminal.
593603By default, when unset,
src/config.rs +7 −2
@@ -1009,11 +1009,12 @@ impl Tunables {
10091009#[serde(rename_all = "kebab-case")]
10101010#[repr(u8)]
10111011pub enum CursorShape {
1012 #[default]
10131012 Default,
10141013 Block,
10151014 Line,
10161015 Underline,
1016 #[default]
1017 Auto,
10171018}
10181019
10191020impl From<CursorShape> for modalkit::crossterm::cursor::SetCursorStyle {
@@ -1023,6 +1024,9 @@ impl From<CursorShape> for modalkit::crossterm::cursor::SetCursorStyle {
10231024 CursorShape::Block => Self::SteadyBlock,
10241025 CursorShape::Line => Self::SteadyBar,
10251026 CursorShape::Underline => Self::SteadyUnderScore,
1027
1028 // use steady block at startup and switch to the correct value on first render
1029 CursorShape::Auto => Self::SteadyBlock,
10261030 }
10271031 }
10281032}
@@ -1792,7 +1796,8 @@ mod tests {
17921796
17931797 #[test]
17941798 fn test_parse_cursor_shape() {
1795 assert_eq!(CursorShape::Default, CursorShape::default());
1799 assert_eq!(CursorShape::Auto, CursorShape::default());
1800 assert_eq!(CursorShape::Auto, serde_json::from_str(r#""auto""#).unwrap());
17961801 assert_eq!(CursorShape::Default, serde_json::from_str(r#""default""#).unwrap());
17971802 assert_eq!(CursorShape::Block, serde_json::from_str(r#""block""#).unwrap());
17981803 assert_eq!(CursorShape::Line, serde_json::from_str(r#""line""#).unwrap());
src/main.rs +10 −1
@@ -66,7 +66,7 @@ use tracing_subscriber::{EnvFilter, FmtSubscriber};
6666
6767use crate::base::{HomeserverAction, KeysAction};
6868use crate::completions::IambCompleter;
69use crate::config::Iamb;
69use crate::config::{CursorShape, Iamb};
7070use crate::prelude::*;
7171use crate::windows::IambWindow;
7272use crate::worker::{ClientWorker, LoginStyle, create_room};
@@ -295,6 +295,15 @@ impl Application {
295295 let inner = Rect::new(cx, cy, 1, 1);
296296 f.render_widget(para, inner)
297297 }
298 if store.application.settings.tunables.terminal.cursor_shape == CursorShape::Auto {
299 let shape = match cursor.get_insert_style() {
300 Some(InsertStyle::Insert) => CursorShape::Line,
301 Some(InsertStyle::Replace) => CursorShape::Underline,
302 None => CursorShape::Block,
303 };
304 let _ = crossterm::execute!(stdout(), SetCursorStyle::from(shape));
305 }
306
298307 f.set_cursor_position((cx, cy));
299308 }
300309 })?;