Config editor buffer#2097
Conversation
81436f4 to
57912d4
Compare
ad60d28 to
cc1e0ba
Compare
1767839 to
6669278
Compare
6669278 to
d29c72f
Compare
initial work on text editor show proper error in footer add open config editor to keybind proper theming update command bar updated CHANGELOG better dark theme.
1a57ac7 to
b83e8e1
Compare
andymandias
left a comment
There was a problem hiding this comment.
I think this is really neat, should reduce friction for users who would rather not open a separate text editor (hopefully meaningfully so for such users), and is well integrated so we can use any benefits brought to it into the input box as well. Case in point, the undo/redo feature added as a side quest to this PR.
I have a few nits, but I think this is a very solid initial implementation.
| // Undo / redo | ||
| if key_press.modifiers.command() { | ||
| match key_press.key.as_ref() { | ||
| iced::keyboard::Key::Character("z") | ||
| if key_press.modifiers.shift() => | ||
| { | ||
| return Some(text_editor::Binding::Custom( | ||
| Message::Redo, | ||
| )); | ||
| } | ||
| iced::keyboard::Key::Character("z") => { | ||
| return Some(text_editor::Binding::Custom( | ||
| Message::Undo, | ||
| )); | ||
| } | ||
| iced::keyboard::Key::Character("y") => { | ||
| return Some(text_editor::Binding::Custom( | ||
| Message::Redo, | ||
| )); | ||
| } | ||
| _ => {} | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Should these be in text_editor_key_bindings?
| fn kill_binding( | ||
| kill: text_editor_key_bindings::Kill, | ||
| ) -> text_editor::Binding<Message> { | ||
| text_editor::Binding::Custom(Message::Kill(kill, true)) | ||
| } | ||
|
|
||
| #[cfg(target_os = "macos")] | ||
| fn platform_specific_key_bindings( | ||
| key_press: text_editor::KeyPress, | ||
| selection: Option<&str>, | ||
| ) -> Option<text_editor::Binding<Message>> { | ||
| match key_press.key.as_ref() { | ||
| iced::keyboard::Key::Named(iced::keyboard::key::Named::Backspace) | ||
| if key_press.modifiers.alt() && selection.is_none() => | ||
| { | ||
| Some(text_editor::Binding::Custom(Message::DeleteWordBackward( | ||
| Some(text_editor::Binding::Custom(Message::Kill( | ||
| text_editor_key_bindings::Kill::WordBackward, | ||
| false, | ||
| ))) | ||
| } | ||
| iced::keyboard::Key::Named(iced::keyboard::key::Named::Backspace) | ||
| if key_press.modifiers.logo() && selection.is_none() => | ||
| { | ||
| Some(text_editor::Binding::Custom(Message::DeleteToStart(false))) | ||
| Some(text_editor::Binding::Custom(Message::Kill( | ||
| text_editor_key_bindings::Kill::ToStart, | ||
| false, | ||
| ))) | ||
| } | ||
| iced::keyboard::Key::Named(iced::keyboard::key::Named::Delete) | ||
| if key_press.modifiers.alt() => | ||
| { | ||
| Some(text_editor::Binding::Custom(Message::DeleteWordForward( | ||
| Some(text_editor::Binding::Custom(Message::Kill( | ||
| text_editor_key_bindings::Kill::WordForward, | ||
| false, | ||
| ))) | ||
| } | ||
| iced::keyboard::Key::Named(iced::keyboard::key::Named::Delete) | ||
| if key_press.modifiers.logo() => | ||
| { | ||
| Some(text_editor::Binding::Custom(Message::DeleteToEnd(false))) | ||
| Some(text_editor::Binding::Custom(Message::Kill( | ||
| text_editor_key_bindings::Kill::ToEnd, | ||
| false, | ||
| ))) | ||
| } | ||
| // cmd+v routes to Message::Paste normally, which means we lose our control flow. overwrite it with our own handler | ||
| iced::keyboard::Key::Character("v") if key_press.modifiers.logo() => { | ||
| Some(text_editor::Binding::Custom(Message::Paste)) | ||
| } | ||
| _ => None, | ||
| } | ||
| } | ||
|
|
||
| #[cfg(not(target_os = "macos"))] | ||
| fn platform_specific_key_bindings( | ||
| key_press: text_editor::KeyPress, | ||
| selection: Option<&str>, | ||
| ) -> Option<text_editor::Binding<Message>> { | ||
| match key_press.key.as_ref() { | ||
| iced::keyboard::Key::Named(iced::keyboard::key::Named::Backspace) | ||
| if key_press.modifiers.control() && selection.is_none() => | ||
| { | ||
| if key_press.modifiers.shift() { | ||
| Some(text_editor::Binding::Custom(Message::DeleteToStart( | ||
| Some(text_editor::Binding::Custom(Message::Kill( | ||
| text_editor_key_bindings::Kill::ToStart, | ||
| false, | ||
| ))) | ||
| } else { | ||
| Some(text_editor::Binding::Custom(Message::DeleteWordBackward( | ||
| Some(text_editor::Binding::Custom(Message::Kill( | ||
| text_editor_key_bindings::Kill::WordBackward, | ||
| false, | ||
| ))) | ||
| } | ||
| } | ||
| iced::keyboard::Key::Named(iced::keyboard::key::Named::Delete) | ||
| if key_press.modifiers.control() => | ||
| { | ||
| if key_press.modifiers.shift() { | ||
| Some(text_editor::Binding::Custom(Message::DeleteToEnd(false))) | ||
| Some(text_editor::Binding::Custom(Message::Kill( | ||
| text_editor_key_bindings::Kill::ToEnd, | ||
| false, | ||
| ))) | ||
| } else { | ||
| Some(text_editor::Binding::Custom(Message::DeleteWordForward( | ||
| Some(text_editor::Binding::Custom(Message::Kill( | ||
| text_editor_key_bindings::Kill::WordForward, | ||
| false, | ||
| ))) | ||
| } | ||
| } | ||
| iced::keyboard::Key::Named(iced::keyboard::key::Named::Insert) | ||
| if key_press.modifiers.shift() && key_press.text.is_none() => | ||
| { | ||
| Some(text_editor::Binding::Custom(Message::Paste)) | ||
| } | ||
| // ctrl+v routes to Message::Paste normally, which means we lose our control flow. overwrite it with our own handler | ||
| iced::keyboard::Key::Character("v") | ||
| if key_press.modifiers.control() => | ||
| { | ||
| Some(text_editor::Binding::Custom(Message::Paste)) | ||
| } | ||
|
|
||
| _ => None, | ||
| } | ||
| } |
There was a problem hiding this comment.
Would it make sense to put these inside the text_editor_key_bindings module, so they could be re-used in the config editor?
| | Buffer::ChannelDiscovery(_) => Task::none(), | ||
| | Buffer::ChannelDiscovery(_) | ||
| | Buffer::ConfigEditor(_) => Task::none(), |
There was a problem hiding this comment.
I think we should pass PageUp to the config editor. Similarly with scroll_down_page. Otherwise, PageUp/PageDown are inoperable in the Config Editor by default (in Linux/Windows).
| Added: | ||
|
|
||
| - Internal buffers (logs, highlights, etc) can be added to sidebar | ||
| - Config editor pane for editing the config file in-app |
There was a problem hiding this comment.
We should add an entry for undo/redo. Very nice feature addition that needs a shout out.
| | Buffer::FileTransfers(_) | ||
| | Buffer::ChannelDiscovery(_) => Task::none(), | ||
| | Buffer::ChannelDiscovery(_) | ||
| | Buffer::ConfigEditor(_) => Task::none(), |
There was a problem hiding this comment.
Similar to page-up/down, I think this should work in the config editor to scroll to the bottom of the file (and scroll_to_start should scroll to the top of the file).
This introduces a config editor pane for easy edit of the config file.
You can
ctrl(cmd)+sto save, and you can also pressrefreshorsavein pane header.