From 9ba691cd3a8ffb021cb194bd3185317a65c3194a Mon Sep 17 00:00:00 2001 From: ath3 Date: Tue, 19 Dec 2023 02:17:12 +0100 Subject: Support drawing popup frame (#4313) Co-authored-by: Blaž Hrastnik --- helix-view/src/editor.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'helix-view/src/editor.rs') 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, + /// 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 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(&mut self, motion: F) { motion(self); self.last_motion = Some(Box::new(motion)); -- cgit v1.2.3-70-g09d2