From 59612a516d0445211a946c3ddf1599826dc1d769 Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 16 Apr 2021 12:47:16 +0200 Subject: [PATCH] Minor refactoring. --- src/layout.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/layout.rs b/src/layout.rs index 1e24390..e7dfe89 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -5,6 +5,13 @@ pub struct Position { pub col: u16, } +impl Position { + // Terminal positions are 1-based. + pub fn new() -> Position { + Position {col: 1, line: 1} + } +} + pub struct Layout { pub force_redraw: bool, // Redraw elements on screen. force_recalc: bool, // Recalculate position of elements. @@ -35,16 +42,16 @@ impl Layout { clock_width: 0, clock_height: 0, digit_width: 0, - clock_sec: Position {col: 0, line: 0}, - clock_colon0: Position {col: 0, line: 0}, - clock_min: Position {col: 0, line: 0}, - clock_colon1: Position {col: 0, line: 0}, - clock_hr: Position {col: 0, line: 0}, - clock_days: Position {col: 0, line: 0}, + clock_sec: Position::new(), + clock_colon0: Position::new(), + clock_min: Position::new(), + clock_colon1: Position::new(), + clock_hr: Position::new(), + clock_days: Position::new(), roster: Position {col: 1, line: 3}, roster_width: 0, roster_height: 0, - buffer: Position {col: 0, line: 0}, + buffer: Position::new(), } }