diff options
author | Canop <cano.petrole@gmail.com> | 2020-06-29 16:03:41 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-06-29 16:03:41 +0200 |
commit | 83dcfd8166e6f07e7c6bb811bfe5dc2f58aede04 (patch) | |
tree | e55bc8bd2831431d322cfb81f99dc9396888f64b /src/display/flags_display.rs | |
parent | 93a5dcf11c9d1a35b429ac2bf3e164848c0f2ad5 (diff) |
version 0.18.2 - remove all flickering causesv0.18.2
Diffstat (limited to 'src/display/flags_display.rs')
-rw-r--r-- | src/display/flags_display.rs | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/display/flags_display.rs b/src/display/flags_display.rs index 97a2849..c7ff58e 100644 --- a/src/display/flags_display.rs +++ b/src/display/flags_display.rs @@ -1,38 +1,29 @@ use { + super::W, crate::{ - display::{Screen, W}, errors::ProgramError, flag::Flag, skin::PanelSkin, }, - termimad::Area, }; -/// draw the flags at the bottom right of the given area -/// (this area is usually the input: flags are displayed over it) -pub fn write_flags( - w: &mut W, - flags: &[Flag], - area: &Area, - input_content_len: u16, - screen: &mut Screen, - panel_skin: &PanelSkin, -) -> Result<(), ProgramError> { - if flags.is_empty() { - return Ok(()); - } +/// compute the needed length for displaying the flags +pub fn visible_width(flags: &[Flag]) -> u16 { let mut width = flags.len() * 2 + 1; for flag in flags { width += flag.name.len(); // we assume only ascii chars width += flag.value.len(); } - let width = width as u16; - if width + input_content_len + 2 >= area.width { - debug!("not enough space to display flags"); - return Ok(()); - } - screen.goto(w, area.left + area.width - 1 - width, area.top)?; + width as u16 +} + +/// draw the flags +pub fn write( + w: &mut W, + flags: &[Flag], + panel_skin: &PanelSkin, +) -> Result<(), ProgramError> { for flag in flags { panel_skin.styles.flag_label.queue_str(w, &format!( " {}:", flag.name))?; panel_skin.styles.flag_value.queue(w, flag.value)?; |