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:
583Control the terminal cursor shape used by iamb. 583Control the terminal cursor shape used by iamb.
584Possible values are: 584Possible values are:
585.Dq Sy default , 585.Dq Sy default ,
586.Dq Sy auto ,
586.Dq Sy block , 587.Dq Sy block ,
587.Dq Sy line , and 588.Dq Sy line , and
588.Dq Sy underline . 589.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.
589Defaults to 599Defaults to
590.Dq Sy default . 600.Dq Sy auto .
591.It Sy enable_extended_keys 601.It Sy enable_extended_keys
592Defines whether to explicitly enable or disable requesting extended keypresses from your terminal. 602Defines whether to explicitly enable or disable requesting extended keypresses from your terminal.
593By default, when unset, 603By default, when unset,
src/config.rs +7 −2
@@ -1009,11 +1009,12 @@ impl Tunables {
1009#[serde(rename_all = "kebab-case")] 1009#[serde(rename_all = "kebab-case")]
1010#[repr(u8)] 1010#[repr(u8)]
1011pub enum CursorShape { 1011pub enum CursorShape {
1012 #[default]
1013 Default, 1012 Default,
1014 Block, 1013 Block,
1015 Line, 1014 Line,
1016 Underline, 1015 Underline,
1016 #[default]
1017 Auto,
1017} 1018}
1018 1019
1019impl From<CursorShape> for modalkit::crossterm::cursor::SetCursorStyle { 1020impl From<CursorShape> for modalkit::crossterm::cursor::SetCursorStyle {
@@ -1023,6 +1024,9 @@ impl From<CursorShape> for modalkit::crossterm::cursor::SetCursorStyle {
1023 CursorShape::Block => Self::SteadyBlock, 1024 CursorShape::Block => Self::SteadyBlock,
1024 CursorShape::Line => Self::SteadyBar, 1025 CursorShape::Line => Self::SteadyBar,
1025 CursorShape::Underline => Self::SteadyUnderScore, 1026 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,
1026 } 1030 }
1027 } 1031 }
1028} 1032}
@@ -1792,7 +1796,8 @@ mod tests {
1792 1796
1793 #[test] 1797 #[test]
1794 fn test_parse_cursor_shape() { 1798 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());
1796 assert_eq!(CursorShape::Default, serde_json::from_str(r#""default""#).unwrap()); 1801 assert_eq!(CursorShape::Default, serde_json::from_str(r#""default""#).unwrap());
1797 assert_eq!(CursorShape::Block, serde_json::from_str(r#""block""#).unwrap()); 1802 assert_eq!(CursorShape::Block, serde_json::from_str(r#""block""#).unwrap());
1798 assert_eq!(CursorShape::Line, serde_json::from_str(r#""line""#).unwrap()); 1803 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};
66 66
67use crate::base::{HomeserverAction, KeysAction}; 67use crate::base::{HomeserverAction, KeysAction};
68use crate::completions::IambCompleter; 68use crate::completions::IambCompleter;
69use crate::config::Iamb; 69use crate::config::{CursorShape, Iamb};
70use crate::prelude::*; 70use crate::prelude::*;
71use crate::windows::IambWindow; 71use crate::windows::IambWindow;
72use crate::worker::{ClientWorker, LoginStyle, create_room}; 72use crate::worker::{ClientWorker, LoginStyle, create_room};
@@ -295,6 +295,15 @@ impl Application {
295 let inner = Rect::new(cx, cy, 1, 1); 295 let inner = Rect::new(cx, cy, 1, 1);
296 f.render_widget(para, inner) 296 f.render_widget(para, inner)
297 } 297 }
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
298 f.set_cursor_position((cx, cy)); 307 f.set_cursor_position((cx, cy));
299 } 308 }
300 })?; 309 })?;