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.
272272Defines whether or not read confirmations are displayed.
273273.It Sy request_timeout
274274Defines the maximum time per request in seconds.
275.It Sy send_on_enter
276If
277.Sy true
278(the default), pressing enter in insert mode will send the message instead of inserting a linebreak.
275279.It Sy sort
276280Configures how to sort the lists shown in windows like
277281.Sy :rooms
src/config.rs +4
@@ -872,6 +872,7 @@ pub struct TunableValues {
872872 pub default_split: SplitDirection,
873873 pub ssl_verify: bool,
874874 pub cache_policy: MediaRetentionPolicy,
875 pub send_on_enter: bool,
875876}
876877
877878#[derive(Clone, Debug, Default, Deserialize)]
@@ -928,6 +929,7 @@ pub struct Tunables {
928929 pub default_split: Option<SplitDirection>,
929930 pub ssl_verify: Option<bool>,
930931 pub cache_policy: Option<MediaRetentionPolicy>,
932 pub send_on_enter: Option<bool>,
931933}
932934
933935impl Tunables {
@@ -982,6 +984,7 @@ impl Tunables {
982984 default_split: self.default_split.or(other.default_split),
983985 ssl_verify: self.ssl_verify.or(other.ssl_verify),
984986 cache_policy: self.cache_policy.or(other.cache_policy),
987 send_on_enter: self.send_on_enter.or(other.send_on_enter),
985988 }
986989 }
987990
@@ -1028,6 +1031,7 @@ impl Tunables {
10281031 default_split: self.default_split.unwrap_or_default(),
10291032 ssl_verify: self.ssl_verify.unwrap_or(true),
10301033 cache_policy: self.cache_policy.unwrap_or_default(),
1034 send_on_enter: self.send_on_enter.unwrap_or(true),
10311035 }
10321036 }
10331037}
src/keybindings.rs +3 −3
@@ -9,7 +9,7 @@ use modalkit::env::vim::keybindings::{InputStep, VimBindings};
99use modalkit::keybindings::{EdgeEvent, EdgeRepeat, InputBindings};
1010
1111use crate::base::{Keybindings, MATRIX_ID_WORD};
12use crate::config::{Keys, SplitDirection};
12use crate::config::{Keys, SplitDirection, TunableValues};
1313use crate::prelude::*;
1414
1515pub type IambStep = InputStep<IambInfo>;
@@ -19,11 +19,11 @@ fn once(key: &TerminalKey) -> (EdgeRepeat, EdgeEvent<TerminalKey, CommonKeyClass
1919}
2020
2121/// Initialize the default keybinding state.
22pub fn setup_keybindings() -> Keybindings {
22pub fn setup_keybindings(tunables: &TunableValues) -> Keybindings {
2323 let mut ism = Keybindings::empty();
2424
2525 let vim = VimBindings::default()
26 .submit_on_enter(false)
26 .submit_on_enter(!tunables.send_on_enter)
2727 .cursor_open(MATRIX_ID_WORD.clone());
2828
2929 vim.setup(&mut ism);
src/main.rs +1 −1
@@ -288,7 +288,7 @@ impl Application {
288288 let backend = CrosstermBackend::new(stdout());
289289 let terminal = Terminal::new(backend)?;
290290
291 let mut bindings = crate::keybindings::setup_keybindings();
291 let mut bindings = crate::keybindings::setup_keybindings(&settings.tunables);
292292 settings.setup(&mut bindings);
293293 let bindings = KeyManager::new(bindings);
294294
src/tests.rs +1
@@ -201,6 +201,7 @@ pub fn mock_tunables() -> TunableValues {
201201 default_split: Default::default(),
202202 ssl_verify: true,
203203 cache_policy: Default::default(),
204 send_on_enter: true,
204205 }
205206}
206207