it compiles!

gui
Blaž Hrastnik 2022-04-05 16:06:13 +09:00
parent afcb78a538
commit d151567192
No known key found for this signature in database
GPG Key ID: 1238B9C4AD889640
4 changed files with 18 additions and 9 deletions

View File

@ -994,6 +994,7 @@ fn set_option(
}; };
let config = serde_json::from_value(config).map_err(field_error)?; let config = serde_json::from_value(config).map_err(field_error)?;
#[cfg(feature = "tokio")]
cx.editor cx.editor
.config_events .config_events
.0 .0
@ -1121,6 +1122,7 @@ fn refresh_config(
_args: &[Cow<str>], _args: &[Cow<str>],
_event: PromptEvent, _event: PromptEvent,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
#[cfg(feature = "tokio")]
cx.editor.config_events.0.send(ConfigEvent::Refresh)?; cx.editor.config_events.0.send(ConfigEvent::Refresh)?;
Ok(()) Ok(())
} }

View File

@ -190,6 +190,7 @@ impl Compositor {
} }
} }
#[cfg(feature = "term")]
pub fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) { pub fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
for layer in self.layers.iter().rev() { for layer in self.layers.iter().rev() {
if let (Some(pos), kind) = layer.cursor(area, editor) { if let (Some(pos), kind) = layer.cursor(area, editor) {

View File

@ -43,10 +43,10 @@ pub fn default() -> HashMap<Mode, Keymap> {
"h" => goto_line_start, "h" => goto_line_start,
"l" => goto_line_end, "l" => goto_line_end,
"s" => goto_first_nonwhitespace, "s" => goto_first_nonwhitespace,
"d" => goto_definition, // "d" => goto_definition,
"y" => goto_type_definition, // "y" => goto_type_definition,
"r" => goto_reference, // "r" => goto_reference,
"i" => goto_implementation, // "i" => goto_implementation,
"t" => goto_window_top, "t" => goto_window_top,
"c" => goto_window_center, "c" => goto_window_center,
"b" => goto_window_bottom, "b" => goto_window_bottom,
@ -198,9 +198,9 @@ pub fn default() -> HashMap<Mode, Keymap> {
"f" => file_picker, "f" => file_picker,
"F" => file_picker_in_current_directory, "F" => file_picker_in_current_directory,
"b" => buffer_picker, "b" => buffer_picker,
"s" => symbol_picker, // "s" => symbol_picker,
"S" => workspace_symbol_picker, // "S" => workspace_symbol_picker,
"a" => code_action, // "a" => code_action,
"'" => last_picker, "'" => last_picker,
"w" => { "Window" "w" => { "Window"
"C-w" | "w" => rotate_view, "C-w" | "w" => rotate_view,
@ -225,8 +225,8 @@ pub fn default() -> HashMap<Mode, Keymap> {
"P" => paste_clipboard_before, "P" => paste_clipboard_before,
"R" => replace_selections_with_clipboard, "R" => replace_selections_with_clipboard,
"/" => global_search, "/" => global_search,
"k" => hover, // "k" => hover,
"r" => rename_symbol, // "r" => rename_symbol,
"?" => command_palette, "?" => command_palette,
}, },
"z" => { "View" "z" => { "View"

View File

@ -55,6 +55,7 @@ impl EditorView {
keymaps, keymaps,
on_next_key: None, on_next_key: None,
last_insert: (commands::MappableCommand::normal_mode, Vec::new()), last_insert: (commands::MappableCommand::normal_mode, Vec::new()),
#[cfg(feature = "term")]
completion: None, completion: None,
spinners: ProgressSpinners::default(), spinners: ProgressSpinners::default(),
} }
@ -1189,6 +1190,7 @@ impl Component for EditorView {
EventResult::Consumed(None) EventResult::Consumed(None)
} }
Event::Key(mut key) => { Event::Key(mut key) => {
#[cfg(feature = "term")]
cx.editor.reset_idle_timer(); cx.editor.reset_idle_timer();
canonicalize_key(&mut key); canonicalize_key(&mut key);
@ -1206,6 +1208,7 @@ impl Component for EditorView {
Mode::Insert => { Mode::Insert => {
// let completion swallow the event if necessary // let completion swallow the event if necessary
let mut consumed = false; let mut consumed = false;
#[cfg(feature = "term")]
if let Some(completion) = &mut self.completion { if let Some(completion) = &mut self.completion {
// use a fake context here // use a fake context here
let mut cx = Context { let mut cx = Context {
@ -1226,6 +1229,7 @@ impl Component for EditorView {
// if completion didn't take the event, we pass it onto commands // if completion didn't take the event, we pass it onto commands
if !consumed { if !consumed {
#[cfg(feature = "term")]
if let Some(compl) = cx.editor.last_completion.take() { if let Some(compl) = cx.editor.last_completion.take() {
self.last_insert.1.push(InsertEvent::CompletionApply(compl)); self.last_insert.1.push(InsertEvent::CompletionApply(compl));
} }
@ -1236,6 +1240,7 @@ impl Component for EditorView {
self.last_insert.1.push(InsertEvent::Key(key)); self.last_insert.1.push(InsertEvent::Key(key));
// lastly we recalculate completion // lastly we recalculate completion
#[cfg(feature = "term")]
if let Some(completion) = &mut self.completion { if let Some(completion) = &mut self.completion {
completion.update(&mut cx); completion.update(&mut cx);
if completion.is_empty() { if completion.is_empty() {
@ -1283,6 +1288,7 @@ impl Component for EditorView {
}; };
self.last_insert.1.clear(); self.last_insert.1.clear();
} }
#[cfg(feature = "term")]
(Mode::Insert, Mode::Normal) => { (Mode::Insert, Mode::Normal) => {
// if exiting insert mode, remove completion // if exiting insert mode, remove completion
self.completion = None; self.completion = None;