summaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorJoe2022-03-25 09:05:20 +0000
committerGitHub2022-03-25 09:05:20 +0000
commitbee05dd32a685b58015514492525673b1b568b0d (patch)
tree4d141ece2ff029b881013f7ef4e89bfb9b064919 /helix-term/src/ui
parent309f2c2c8e64f8be2123a0232c5f9761496b6514 (diff)
Add refresh-config and open-config command (#1803)
* Add refresh-config and open-config command * clippy * Use dynamic dispatch for editor config * Refactor Result::Ok to Ok * Remove unused import * cargo fmt * Modify config error handling * cargo xtask docgen * impl display for ConfigLoadError * cargo fmt * Put keymaps behind dyn access, refactor config.load() * Update command names * Update helix-term/src/application.rs Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> * Switch to unbounded_channel * Remove --edit-config command * Update configuration docs * Revert "Put keymaps behind dyn access", too hard This reverts commit 06bad8cf492b9331d0a2d1e9242f3ad4e2c1cf79. * Add refresh for keys * Refactor default_keymaps, fix config default, add test * swap -> store, remove unneeded clone * cargo fmt * Rename default_keymaps to default Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs20
-rw-r--r--helix-term/src/ui/mod.rs5
2 files changed, 13 insertions, 12 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 611d65fb..28665ec3 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -118,7 +118,7 @@ impl EditorView {
let highlights: Box<dyn Iterator<Item = HighlightEvent>> = if is_focused {
Box::new(syntax::merge(
highlights,
- Self::doc_selection_highlights(doc, view, theme, &editor.config.cursor_shape),
+ Self::doc_selection_highlights(doc, view, theme, &editor.config().cursor_shape),
))
} else {
Box::new(highlights)
@@ -702,7 +702,6 @@ impl EditorView {
cxt: &mut commands::Context,
event: KeyEvent,
) -> Option<KeymapResult> {
- cxt.editor.autoinfo = None;
let key_result = self.keymaps.get(mode, event);
cxt.editor.autoinfo = self.keymaps.sticky().map(|node| node.infobox());
@@ -845,7 +844,7 @@ impl EditorView {
pub fn handle_idle_timeout(&mut self, cx: &mut crate::compositor::Context) -> EventResult {
if self.completion.is_some()
- || !cx.editor.config.auto_completion
+ || !cx.editor.config().auto_completion
|| doc!(cx.editor).mode != Mode::Insert
{
return EventResult::Ignored(None);
@@ -871,6 +870,7 @@ impl EditorView {
event: MouseEvent,
cxt: &mut commands::Context,
) -> EventResult {
+ let config = cxt.editor.config();
match event {
MouseEvent {
kind: MouseEventKind::Down(MouseButton::Left),
@@ -971,7 +971,7 @@ impl EditorView {
None => return EventResult::Ignored(None),
}
- let offset = cxt.editor.config.scroll_lines.abs() as usize;
+ let offset = config.scroll_lines.abs() as usize;
commands::scroll(cxt, offset, direction);
cxt.editor.tree.focus = current_view;
@@ -983,7 +983,7 @@ impl EditorView {
kind: MouseEventKind::Up(MouseButton::Left),
..
} => {
- if !cxt.editor.config.middle_click_paste {
+ if !config.middle_click_paste {
return EventResult::Ignored(None);
}
@@ -1039,7 +1039,7 @@ impl EditorView {
..
} => {
let editor = &mut cxt.editor;
- if !editor.config.middle_click_paste {
+ if !config.middle_click_paste {
return EventResult::Ignored(None);
}
@@ -1163,9 +1163,9 @@ impl Component for EditorView {
if cx.editor.should_close() {
return EventResult::Ignored(None);
}
-
+ let config = cx.editor.config();
let (view, doc) = current!(cx.editor);
- view.ensure_cursor_in_view(doc, cx.editor.config.scrolloff);
+ view.ensure_cursor_in_view(doc, config.scrolloff);
// Store a history state if not in insert mode. This also takes care of
// commiting changes when leaving insert mode.
@@ -1206,7 +1206,7 @@ impl Component for EditorView {
fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) {
// clear with background color
surface.set_style(area, cx.editor.theme.get("ui.background"));
-
+ let config = cx.editor.config();
// if the terminal size suddenly changed, we need to trigger a resize
cx.editor.resize(area.clip_bottom(1)); // -1 from bottom for commandline
@@ -1215,7 +1215,7 @@ impl Component for EditorView {
self.render_view(cx.editor, doc, view, area, surface, is_focused);
}
- if cx.editor.config.auto_info {
+ if config.auto_info {
if let Some(mut info) = cx.editor.autoinfo.take() {
info.render(area, surface, cx);
cx.editor.autoinfo = Some(info)
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 2273477f..6242ea2e 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -37,6 +37,7 @@ pub fn regex_prompt(
let doc_id = view.doc;
let snapshot = doc.selection(view.id).clone();
let offset_snapshot = view.offset;
+ let config = cx.editor.config();
let mut prompt = Prompt::new(
prompt,
@@ -65,7 +66,7 @@ pub fn regex_prompt(
return;
}
- let case_insensitive = if cx.editor.config.search.smart_case {
+ let case_insensitive = if config.search.smart_case {
!input.chars().any(char::is_uppercase)
} else {
false
@@ -84,7 +85,7 @@ pub fn regex_prompt(
fun(view, doc, regex, event);
- view.ensure_cursor_in_view(doc, cx.editor.config.scrolloff);
+ view.ensure_cursor_in_view(doc, config.scrolloff);
}
Err(_err) => (), // TODO: mark command line as error
}