refactor: ui factor out goto cursor

This commit is contained in:
graelo 2020-06-02 11:17:35 +02:00
parent a98c4598ba
commit 45a4083547

View file

@ -196,13 +196,14 @@ impl<'a> Ui<'a> {
let bg_color = color::Bg(colors.hint_bg.as_ref()); let bg_color = color::Bg(colors.hint_bg.as_ref());
let fg_reset = color::Fg(color::Reset); let fg_reset = color::Fg(color::Reset);
let bg_reset = color::Bg(color::Reset); let bg_reset = color::Bg(color::Reset);
let goto = cursor::Goto(offset.0 as u16 + 1, offset.1 as u16 + 1);
match hint_style { match hint_style {
None => { None => {
write!( write!(
stdout, stdout,
"{goto}{bg_color}{fg_color}{hint}{fg_reset}{bg_reset}", "{goto}{bg_color}{fg_color}{hint}{fg_reset}{bg_reset}",
goto = cursor::Goto(offset.0 as u16 + 1, offset.1 as u16 + 1), goto = goto,
fg_color = fg_color, fg_color = fg_color,
bg_color = bg_color, bg_color = bg_color,
fg_reset = fg_reset, fg_reset = fg_reset,
@ -216,7 +217,7 @@ impl<'a> Ui<'a> {
write!( write!(
stdout, stdout,
"{goto}{bg_color}{fg_color}{sty}{hint}{sty_reset}{fg_reset}{bg_reset}", "{goto}{bg_color}{fg_color}{sty}{hint}{sty_reset}{fg_reset}{bg_reset}",
goto = cursor::Goto(offset.0 as u16 + 1, offset.1 as u16 + 1), goto = goto,
fg_color = fg_color, fg_color = fg_color,
bg_color = bg_color, bg_color = bg_color,
fg_reset = fg_reset, fg_reset = fg_reset,
@ -231,7 +232,7 @@ impl<'a> Ui<'a> {
write!( write!(
stdout, stdout,
"{goto}{bg_color}{fg_color}{sty}{hint}{sty_reset}{fg_reset}{bg_reset}", "{goto}{bg_color}{fg_color}{sty}{hint}{sty_reset}{fg_reset}{bg_reset}",
goto = cursor::Goto(offset.0 as u16 + 1, offset.1 as u16 + 1), goto = goto,
fg_color = fg_color, fg_color = fg_color,
bg_color = bg_color, bg_color = bg_color,
fg_reset = fg_reset, fg_reset = fg_reset,
@ -246,7 +247,7 @@ impl<'a> Ui<'a> {
write!( write!(
stdout, stdout,
"{goto}{bg_color}{fg_color}{sty}{hint}{sty_reset}{fg_reset}{bg_reset}", "{goto}{bg_color}{fg_color}{sty}{hint}{sty_reset}{fg_reset}{bg_reset}",
goto = cursor::Goto(offset.0 as u16 + 1, offset.1 as u16 + 1), goto = goto,
fg_color = fg_color, fg_color = fg_color,
bg_color = bg_color, bg_color = bg_color,
fg_reset = fg_reset, fg_reset = fg_reset,
@ -261,7 +262,7 @@ impl<'a> Ui<'a> {
write!( write!(
stdout, stdout,
"{goto}{bg_color}{fg_color}{bra}{hint}{bra_close}{fg_reset}{bg_reset}", "{goto}{bg_color}{fg_color}{bra}{hint}{bra_close}{fg_reset}{bg_reset}",
goto = cursor::Goto(offset.0 as u16 + 1, offset.1 as u16 + 1), goto = goto,
fg_color = fg_color, fg_color = fg_color,
bg_color = bg_color, bg_color = bg_color,
fg_reset = fg_reset, fg_reset = fg_reset,