added 'shift_left' and 'shift_right' to Rect

pull/11409/head
Stephen Broadley 4 months ago
parent 35657560dd
commit 4e6cd3fd06

@ -213,8 +213,7 @@ impl EditorView {
let gutter_width = view.gutter_offset(doc); let gutter_width = view.gutter_offset(doc);
if gutter_width > 0 { if gutter_width > 0 {
let mut gutter_area = inner.with_width(gutter_width); let gutter_area = inner.with_width(gutter_width).shift_left(gutter_width);
gutter_area.x -= gutter_width;
Self::render_gutter( Self::render_gutter(
editor, editor,

@ -710,7 +710,7 @@ pub struct NullspaceConfig {
impl Default for NullspaceConfig { impl Default for NullspaceConfig {
fn default() -> Self { fn default() -> Self {
Self { Self {
enable: true, enable: false,
pattern: String::from("╲"), pattern: String::from("╲"),
} }
} }

@ -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. // Returns a new Rect with height reduced from the bottom.
// This does _not_ change the `y` coordinate. // This does _not_ change the `y` coordinate.
pub fn clip_bottom(self, height: u16) -> Rect { pub fn clip_bottom(self, height: u16) -> Rect {

Loading…
Cancel
Save