Enter newlines via modifier+enter
As long as the modifier doesn't get swallowed by the terminal, the editor will insert a newline at the current cursor location. My own terminal emulator swallows ctrl and shift but not alt, so alt+enter works for me.
This commit is contained in:
parent
76352f9b6b
commit
f14e9b8998
1 changed files with 9 additions and 2 deletions
|
|
@ -66,14 +66,14 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
||||||
coming_from: Option<M::Id>,
|
coming_from: Option<M::Id>,
|
||||||
parent: Option<M::Id>,
|
parent: Option<M::Id>,
|
||||||
) -> Reaction<M> {
|
) -> Reaction<M> {
|
||||||
let harmless_char = event.modifiers.difference(KeyModifiers::SHIFT).is_empty();
|
let harmless_char = (event.modifiers - KeyModifiers::SHIFT).is_empty();
|
||||||
|
|
||||||
match event.code {
|
match event.code {
|
||||||
KeyCode::Esc => {
|
KeyCode::Esc => {
|
||||||
self.cursor = coming_from.map(Cursor::Msg).unwrap_or(Cursor::Bottom);
|
self.cursor = coming_from.map(Cursor::Msg).unwrap_or(Cursor::Bottom);
|
||||||
Reaction::Handled
|
Reaction::Handled
|
||||||
}
|
}
|
||||||
KeyCode::Enter => {
|
KeyCode::Enter if event.modifiers.is_empty() => {
|
||||||
let content = self.editor.text();
|
let content = self.editor.text();
|
||||||
if content.trim().is_empty() {
|
if content.trim().is_empty() {
|
||||||
Reaction::Handled
|
Reaction::Handled
|
||||||
|
|
@ -85,6 +85,13 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
||||||
Reaction::Composed { parent, content }
|
Reaction::Composed { parent, content }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
KeyCode::Enter => {
|
||||||
|
// Enter with *any* modifier pressed - if ctrl and shift don't
|
||||||
|
// work, maybe alt does
|
||||||
|
self.editor.insert_char('\n');
|
||||||
|
self.correction = Some(Correction::MakeCursorVisible);
|
||||||
|
Reaction::Handled
|
||||||
|
}
|
||||||
KeyCode::Backspace => {
|
KeyCode::Backspace => {
|
||||||
self.editor.backspace();
|
self.editor.backspace();
|
||||||
self.correction = Some(Correction::MakeCursorVisible);
|
self.correction = Some(Correction::MakeCursorVisible);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue