From 8e8367eea6ff146c7e1097af153398832691e078 Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Tue, 21 Jun 2022 22:22:08 +0530 Subject: Refactor Margin for fine grained control (#2727) --- helix-tui/src/layout.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'helix-tui/src') diff --git a/helix-tui/src/layout.rs b/helix-tui/src/layout.rs index e6a84aa0..7c72a778 100644 --- a/helix-tui/src/layout.rs +++ b/helix-tui/src/layout.rs @@ -68,10 +68,7 @@ impl Default for Layout { fn default() -> Layout { Layout { direction: Direction::Vertical, - margin: Margin { - horizontal: 0, - vertical: 0, - }, + margin: Margin::none(), constraints: Vec::new(), } } @@ -87,20 +84,19 @@ impl Layout { } pub fn margin(mut self, margin: u16) -> Layout { - self.margin = Margin { - horizontal: margin, - vertical: margin, - }; + self.margin = Margin::all(margin); self } pub fn horizontal_margin(mut self, horizontal: u16) -> Layout { - self.margin.horizontal = horizontal; + self.margin.left = horizontal; + self.margin.right = horizontal; self } pub fn vertical_margin(mut self, vertical: u16) -> Layout { - self.margin.vertical = vertical; + self.margin.top = vertical; + self.margin.bottom = vertical; self } -- cgit v1.2.3-70-g09d2