Commit be3d27d4e6
be3d27d4e6ccec881adb689eaff58a548ef24ad8
parent: d9e445816a
Unregistered key
vaw <git@nlih.de> · 2026-09-21 22:24 UTC
committer: <noreply@github.com>
Add option to insert a linebreak on `<enter>` instead of sending a message (#727)
Layout: unified · split
docs/iamb.5
+4
| @@ -272,6 +272,10 @@ A message must be sent to the room before marking it read. |
| 272 | 272 | Defines whether or not read confirmations are displayed. |
| 273 | 273 | .It Sy request_timeout |
| 274 | 274 | Defines the maximum time per request in seconds. |
| 275 | .It Sy send_on_enter |
| 276 | If |
| 277 | .Sy true |
| 278 | (the default), pressing enter in insert mode will send the message instead of inserting a linebreak. |
| 275 | 279 | .It Sy sort |
| 276 | 280 | Configures how to sort the lists shown in windows like |
| 277 | 281 | .Sy :rooms |
src/config.rs
+4
| @@ -872,6 +872,7 @@ pub struct TunableValues { |
| 872 | 872 | pub default_split: SplitDirection, |
| 873 | 873 | pub ssl_verify: bool, |
| 874 | 874 | pub cache_policy: MediaRetentionPolicy, |
| 875 | pub send_on_enter: bool, |
| 875 | 876 | } |
| 876 | 877 | |
| 877 | 878 | #[derive(Clone, Debug, Default, Deserialize)] |
| @@ -928,6 +929,7 @@ pub struct Tunables { |
| 928 | 929 | pub default_split: Option<SplitDirection>, |
| 929 | 930 | pub ssl_verify: Option<bool>, |
| 930 | 931 | pub cache_policy: Option<MediaRetentionPolicy>, |
| 932 | pub send_on_enter: Option<bool>, |
| 931 | 933 | } |
| 932 | 934 | |
| 933 | 935 | impl Tunables { |
| @@ -982,6 +984,7 @@ impl Tunables { |
| 982 | 984 | default_split: self.default_split.or(other.default_split), |
| 983 | 985 | ssl_verify: self.ssl_verify.or(other.ssl_verify), |
| 984 | 986 | cache_policy: self.cache_policy.or(other.cache_policy), |
| 987 | send_on_enter: self.send_on_enter.or(other.send_on_enter), |
| 985 | 988 | } |
| 986 | 989 | } |
| 987 | 990 | |
| @@ -1028,6 +1031,7 @@ impl Tunables { |
| 1028 | 1031 | default_split: self.default_split.unwrap_or_default(), |
| 1029 | 1032 | ssl_verify: self.ssl_verify.unwrap_or(true), |
| 1030 | 1033 | cache_policy: self.cache_policy.unwrap_or_default(), |
| 1034 | send_on_enter: self.send_on_enter.unwrap_or(true), |
| 1031 | 1035 | } |
| 1032 | 1036 | } |
| 1033 | 1037 | } |
src/keybindings.rs
+3 −3
| @@ -9,7 +9,7 @@ use modalkit::env::vim::keybindings::{InputStep, VimBindings}; |
| 9 | 9 | use modalkit::keybindings::{EdgeEvent, EdgeRepeat, InputBindings}; |
| 10 | 10 | |
| 11 | 11 | use crate::base::{Keybindings, MATRIX_ID_WORD}; |
| 12 | | use crate::config::{Keys, SplitDirection}; |
| 12 | use crate::config::{Keys, SplitDirection, TunableValues}; |
| 13 | 13 | use crate::prelude::*; |
| 14 | 14 | |
| 15 | 15 | pub type IambStep = InputStep<IambInfo>; |
| @@ -19,11 +19,11 @@ fn once(key: &TerminalKey) -> (EdgeRepeat, EdgeEvent<TerminalKey, CommonKeyClass |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /// Initialize the default keybinding state. |
| 22 | | pub fn setup_keybindings() -> Keybindings { |
| 22 | pub fn setup_keybindings(tunables: &TunableValues) -> Keybindings { |
| 23 | 23 | let mut ism = Keybindings::empty(); |
| 24 | 24 | |
| 25 | 25 | let vim = VimBindings::default() |
| 26 | | .submit_on_enter(false) |
| 26 | .submit_on_enter(!tunables.send_on_enter) |
| 27 | 27 | .cursor_open(MATRIX_ID_WORD.clone()); |
| 28 | 28 | |
| 29 | 29 | vim.setup(&mut ism); |
src/main.rs
+1 −1
| @@ -288,7 +288,7 @@ impl Application { |
| 288 | 288 | let backend = CrosstermBackend::new(stdout()); |
| 289 | 289 | let terminal = Terminal::new(backend)?; |
| 290 | 290 | |
| 291 | | let mut bindings = crate::keybindings::setup_keybindings(); |
| 291 | let mut bindings = crate::keybindings::setup_keybindings(&settings.tunables); |
| 292 | 292 | settings.setup(&mut bindings); |
| 293 | 293 | let bindings = KeyManager::new(bindings); |
| 294 | 294 | |
src/tests.rs
+1
| @@ -201,6 +201,7 @@ pub fn mock_tunables() -> TunableValues { |
| 201 | 201 | default_split: Default::default(), |
| 202 | 202 | ssl_verify: true, |
| 203 | 203 | cache_policy: Default::default(), |
| 204 | send_on_enter: true, |
| 204 | 205 | } |
| 205 | 206 | } |
| 206 | 207 | |