diff options
author | ath3 | 2023-12-19 01:17:12 +0000 |
---|---|---|
committer | GitHub | 2023-12-19 01:17:12 +0000 |
commit | 9ba691cd3a8ffb021cb194bd3185317a65c3194a (patch) | |
tree | 915ecd2d667ad492317e1a1748c2ba6f57983bcb /helix-view/src/editor.rs | |
parent | 06d7dc628e5a5dac9bbfe4802c3b00754a9f7731 (diff) |
Support drawing popup frame (#4313)
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r-- | helix-view/src/editor.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index f2e85307..76429a87 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -43,9 +43,8 @@ pub use helix_core::diagnostic::Severity; use helix_core::{ auto_pairs::AutoPairs, syntax::{self, AutoPairConfig, IndentationHeuristic, SoftWrap}, - Change, LineEnding, NATIVE_LINE_ENDING, + Change, LineEnding, Position, Selection, NATIVE_LINE_ENDING, }; -use helix_core::{Position, Selection}; use helix_dap as dap; use helix_lsp::lsp; @@ -291,6 +290,8 @@ pub struct Config { pub insert_final_newline: bool, /// Enables smart tab pub smart_tab: Option<SmartTabConfig>, + /// Draw border around popups. + pub popup_border: PopupBorderConfig, /// Which indent heuristic to use when a new line is inserted #[serde(default)] pub indent_heuristic: IndentationHeuristic, @@ -797,6 +798,15 @@ impl From<LineEndingConfig> for LineEnding { } } +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum PopupBorderConfig { + None, + All, + Popup, + Menu, +} + impl Default for Config { fn default() -> Self { Self { @@ -844,6 +854,7 @@ impl Default for Config { default_line_ending: LineEndingConfig::default(), insert_final_newline: true, smart_tab: Some(SmartTabConfig::default()), + popup_border: PopupBorderConfig::None, indent_heuristic: IndentationHeuristic::default(), } } @@ -1064,6 +1075,16 @@ impl Editor { } } + pub fn popup_border(&self) -> bool { + self.config().popup_border == PopupBorderConfig::All + || self.config().popup_border == PopupBorderConfig::Popup + } + + pub fn menu_border(&self) -> bool { + self.config().popup_border == PopupBorderConfig::All + || self.config().popup_border == PopupBorderConfig::Menu + } + pub fn apply_motion<F: Fn(&mut Self) + 'static>(&mut self, motion: F) { motion(self); self.last_motion = Some(Box::new(motion)); |