summaryrefslogtreecommitdiffstats
path: root/src/display/flags_display.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/display/flags_display.rs')
-rw-r--r--src/display/flags_display.rs33
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)?;