From 4e6cd3fd06d59872d09a8c0fbc46cc1bc8c2998f Mon Sep 17 00:00:00 2001 From: Stephen Broadley Date: Fri, 2 Aug 2024 20:13:49 +0100 Subject: [PATCH] added 'shift_left' and 'shift_right' to Rect --- helix-term/src/ui/editor.rs | 3 +-- helix-view/src/editor.rs | 2 +- helix-view/src/graphics.rs | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 4710f833b..2d48c1fb6 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -213,8 +213,7 @@ impl EditorView { let gutter_width = view.gutter_offset(doc); if gutter_width > 0 { - let mut gutter_area = inner.with_width(gutter_width); - gutter_area.x -= gutter_width; + let gutter_area = inner.with_width(gutter_width).shift_left(gutter_width); Self::render_gutter( editor, diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 5054e79d5..a8ede13d6 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -710,7 +710,7 @@ pub struct NullspaceConfig { impl Default for NullspaceConfig { fn default() -> Self { Self { - enable: true, + enable: false, pattern: String::from("╲"), } } diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs index a26823b97..a04394a0a 100644 --- a/helix-view/src/graphics.rs +++ b/helix-view/src/graphics.rs @@ -153,6 +153,22 @@ impl Rect { } } + // Returns a new Rect shifted left. + pub fn shift_left(self, shift: u16) -> Rect { + Rect { + x: self.x - shift, + ..self + } + } + + // Returns a new Rect shifted left. + pub fn shift_right(self, shift: u16) -> Rect { + Rect { + x: self.x + shift, + ..self + } + } + // Returns a new Rect with height reduced from the bottom. // This does _not_ change the `y` coordinate. pub fn clip_bottom(self, height: u16) -> Rect {