Commit 71c1efcd37

71c1efcd37792bca8d034f30df44307a1a1df4b9

parent: ec9bd32a8d

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-07-26 16:04 UTC
committer: <noreply@github.com>

Allow explicitly controlling when extended keypresses are enabled (#632)

Layout: unified · split

docs/iamb.5 +22
@@ -221,6 +221,11 @@ See
221221for more details.
222222.It Sy state_event_display
223223Defines whether the state events like joined or left are shown.
224.It Sy terminal
225Subsection for configuring how specific terminal features are used (or not used).
226See
227.Sx TERMINAL
228for more details.
224229.It Sy typing_notice_send
225230Defines whether or not the typing state is sent.
226231.It Sy typing_notice_display
@@ -289,6 +294,7 @@ and
289294(the default).
290295Both can be used via
291296.Dq Sy title|prompt .
297.El
292298.Sh MOUSE
293299The
294300.Sy settings.mouse
@@ -424,6 +430,22 @@ in front of any value to flip the order.
424430[settings.sort]
425431members = ["server", "~localpart"]
426432.Ed
433.Sh TERMINAL
434The
435.Sy settings.terminal
436subsection allows overriding how
437.Sy iamb
438interacts with your terminal.
439.Pp
440The available fields in this subsection are:
441.Bl -tag -width Ds
442.It Sy enable_extended_keys
443Defines whether to explicitly enable or disable requesting extended keypresses from your terminal.
444By default, when unset,
445.Sy iamb
446will attempt to auto-detect support in your terminal and request extended keypresses from the terminal if supported.
447.El
448.It Sy indicator
427449.Sh "USER OVERRIDES"
428450The
429451.Sy settings.users
src/config.rs +62 −25
@@ -317,23 +317,6 @@ pub struct UserDisplayTunables {
317317
318318pub type UserOverrides = HashMap<OwnedUserId, UserDisplayTunables>;
319319
320fn merge_encryption(profile: Encryption, global: Encryption) -> Encryption {
321 Encryption {
322 indicator: profile.indicator.or(global.indicator),
323 indicator_location: profile.indicator_location.or(global.indicator_location),
324 }
325}
326
327fn merge_sorts(profile: SortOverrides, global: SortOverrides) -> SortOverrides {
328 SortOverrides {
329 chats: profile.chats.or(global.chats),
330 dms: profile.dms.or(global.dms),
331 rooms: profile.rooms.or(global.rooms),
332 spaces: profile.spaces.or(global.spaces),
333 members: profile.members.or(global.members),
334 }
335}
336
337320fn merge_maps<K, V>(
338321 profile: Option<HashMap<K, V>>,
339322 global: Option<HashMap<K, V>>,
@@ -509,6 +492,13 @@ pub struct Encryption {
509492}
510493
511494impl Encryption {
495 fn merge(profile: Self, global: Self) -> Self {
496 Encryption {
497 indicator: profile.indicator.or(global.indicator),
498 indicator_location: profile.indicator_location.or(global.indicator_location),
499 }
500 }
501
512502 pub fn values(self) -> EncryptionValues {
513503 EncryptionValues {
514504 indicator: self.indicator.unwrap_or_default(),
@@ -641,6 +631,16 @@ pub struct SortOverrides {
641631}
642632
643633impl SortOverrides {
634 fn merge(profile: Self, global: Self) -> Self {
635 Self {
636 chats: profile.chats.or(global.chats),
637 dms: profile.dms.or(global.dms),
638 rooms: profile.rooms.or(global.rooms),
639 spaces: profile.spaces.or(global.spaces),
640 members: profile.members.or(global.members),
641 }
642 }
643
644644 pub fn values(self) -> SortValues {
645645 let rooms = self.rooms.unwrap_or_else(|| Vec::from(DEFAULT_ROOM_SORT));
646646 let chats = self.chats.unwrap_or_else(|| rooms.clone());
@@ -652,6 +652,28 @@ impl SortOverrides {
652652 }
653653}
654654
655#[derive(Clone, Debug, Default, Deserialize)]
656pub struct Terminal {
657 pub enable_extended_keys: Option<bool>,
658}
659
660impl Terminal {
661 fn merge(profile: Self, global: Self) -> Self {
662 Self {
663 enable_extended_keys: profile.enable_extended_keys.or(global.enable_extended_keys),
664 }
665 }
666
667 pub fn values(self) -> TerminalValues {
668 TerminalValues { enable_extended_keys: self.enable_extended_keys }
669 }
670}
671
672#[derive(Clone, Debug)]
673pub struct TerminalValues {
674 pub enable_extended_keys: Option<bool>,
675}
676
655677#[derive(Clone)]
656678pub struct TunableValues {
657679 pub encryption: EncryptionValues,
@@ -675,6 +697,7 @@ pub struct TunableValues {
675697 pub open_command: Option<Vec<String>>,
676698 pub mouse: Mouse,
677699 pub notifications: Notifications,
700 pub terminal: TerminalValues,
678701 pub image_preview: Option<ImagePreviewValues>,
679702 pub user_gutter_width: usize,
680703 pub external_edit_file_suffix: String,
@@ -684,8 +707,21 @@ pub struct TunableValues {
684707
685708#[derive(Clone, Default, Deserialize)]
686709pub struct Tunables {
710 /// Subsection for overriding encryption-related settings.
687711 #[serde(default)]
688712 pub encryption: Encryption,
713
714 /// Subsection for overriding sort orders in UI lists.
715 #[serde(default)]
716 pub sort: SortOverrides,
717
718 /// Subsection for overriding terminal settings.
719 #[serde(default)]
720 pub terminal: Terminal,
721
722 /// Subsection for overriding how specific Matrix users are rendered.
723 pub users: Option<UserOverrides>,
724
689725 pub log_level: Option<String>,
690726 pub max_log_files: Option<usize>,
691727 pub message_shortcode_display: Option<bool>,
@@ -695,12 +731,9 @@ pub struct Tunables {
695731 pub read_receipt_send: Option<bool>,
696732 pub read_receipt_display: Option<bool>,
697733 pub request_timeout: Option<u64>,
698 #[serde(default)]
699 pub sort: SortOverrides,
700734 pub state_event_display: Option<bool>,
701735 pub typing_notice_send: Option<bool>,
702736 pub typing_notice_display: Option<bool>,
703 pub users: Option<UserOverrides>,
704737 pub username_display: Option<UserDisplayStyle>,
705738 pub message_user_color: Option<bool>,
706739 pub default_room: Option<String>,
@@ -717,7 +750,11 @@ pub struct Tunables {
717750impl Tunables {
718751 fn merge(self, other: Self) -> Self {
719752 Tunables {
720 encryption: merge_encryption(self.encryption, other.encryption),
753 encryption: Encryption::merge(self.encryption, other.encryption),
754 sort: SortOverrides::merge(self.sort, other.sort),
755 terminal: Terminal::merge(self.terminal, other.terminal),
756 users: merge_maps(self.users, other.users),
757
721758 log_level: self.log_level.or(other.log_level),
722759 max_log_files: self.max_log_files.or(other.max_log_files),
723760 message_shortcode_display: self
@@ -731,11 +768,9 @@ impl Tunables {
731768 read_receipt_send: self.read_receipt_send.or(other.read_receipt_send),
732769 read_receipt_display: self.read_receipt_display.or(other.read_receipt_display),
733770 request_timeout: self.request_timeout.or(other.request_timeout),
734 sort: merge_sorts(self.sort, other.sort),
735771 state_event_display: self.state_event_display.or(other.state_event_display),
736772 typing_notice_send: self.typing_notice_send.or(other.typing_notice_send),
737773 typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
738 users: merge_maps(self.users, other.users),
739774 username_display: self.username_display.or(other.username_display),
740775 message_user_color: self.message_user_color.or(other.message_user_color),
741776 default_room: self.default_room.or(other.default_room),
@@ -754,8 +789,11 @@ impl Tunables {
754789
755790 fn values(self) -> TunableValues {
756791 TunableValues {
757 log_level: self.log_level.unwrap_or_else(|| "warn".to_string()),
758792 encryption: self.encryption.values(),
793 sort: self.sort.values(),
794 terminal: self.terminal.values(),
795
796 log_level: self.log_level.unwrap_or_else(|| "warn".to_string()),
759797 max_log_files: self.max_log_files.unwrap_or(7),
760798 message_shortcode_display: self.message_shortcode_display.unwrap_or(false),
761799 normal_after_send: self.normal_after_send.unwrap_or(false),
@@ -764,7 +802,6 @@ impl Tunables {
764802 read_receipt_send: self.read_receipt_send.unwrap_or(true),
765803 read_receipt_display: self.read_receipt_display.unwrap_or(true),
766804 request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT),
767 sort: self.sort.values(),
768805 state_event_display: self.state_event_display.unwrap_or(true),
769806 typing_notice_send: self.typing_notice_send.unwrap_or(true),
770807 typing_notice_display: self.typing_notice_display.unwrap_or(true),
src/main.rs +9 −8
@@ -1063,14 +1063,15 @@ async fn run(settings: ApplicationSettings) -> IambResult<()> {
10631063 }
10641064
10651065 // Set up the terminal for drawing, and cleanup properly on panics.
1066 let enable_enhanced_keys = match crossterm::terminal::supports_keyboard_enhancement() {
1067 Ok(supported) => supported,
1068 Err(e) => {
1069 tracing::warn!(err = %e,
1070 "Failed to determine whether the terminal supports keyboard enhancements");
1071 false
1072 },
1073 };
1066 let enable_enhanced_keys =
1067 settings.tunables.terminal.enable_extended_keys.unwrap_or_else(|| {
1068 crossterm::terminal::supports_keyboard_enhancement()
1069 .inspect_err(|e| tracing::warn!(
1070 err = %e,
1071 "Failed to determine whether the terminal supports keyboard enhancements"
1072 ))
1073 .unwrap_or_default()
1074 });
10741075 setup_tty(&settings, enable_enhanced_keys)?;
10751076
10761077 let orig_hook = std::panic::take_hook();
src/tests.rs +2
@@ -31,6 +31,7 @@ use crate::{
3131 NotifyVia,
3232 ProfileConfig,
3333 SortOverrides,
34 Terminal,
3435 TunableValues,
3536 UserColor,
3637 UserDisplayStyle,
@@ -183,6 +184,7 @@ pub fn mock_tunables() -> TunableValues {
183184 request_timeout: 120,
184185 sort: SortOverrides::default().values(),
185186 state_event_display: true,
187 terminal: Terminal::default().values(),
186188 typing_notice_send: true,
187189 typing_notice_display: true,
188190 users: vec![(TEST_USER5.clone(), UserDisplayTunables {