mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-07-17 15:56:57 +02:00
145e...
This commit is contained in:
parent
9283c54eec
commit
b44dc635ef
3 changed files with 31 additions and 37 deletions
53
src/tek.rs
53
src/tek.rs
|
|
@ -404,20 +404,14 @@ pub fn view_transport (
|
|||
/// let _ = tek::view_status(None, x.clone(), x.clone(), x.clone());
|
||||
/// let _ = tek::view_status(Some("".into()), x.clone(), x.clone(), x.clone());
|
||||
/// ```
|
||||
pub fn view_status (
|
||||
sel: Option<Arc<str>>,
|
||||
sr: Arc<RwLock<String>>,
|
||||
buf: Arc<RwLock<String>>,
|
||||
lat: Arc<RwLock<String>>,
|
||||
) -> impl Draw<Tui> {
|
||||
pub fn view_status (sel: Option<Arc<str>>, sr: &str, buf: &str, lat: &str) -> impl Draw<Tui> {
|
||||
let theme = ItemTheme::G[96];
|
||||
let sr = field_h(theme, "SR", sr);
|
||||
let buf = field_h(theme, "Buf", buf);
|
||||
let lat = field_h(theme, "Lat", lat);
|
||||
bg(Black, east!(above(
|
||||
wh_full(origin_w(sel.map(|sel|field_h(theme, "Selected", sel)))),
|
||||
wh_full(origin_e(east!(
|
||||
field_h(theme, "SR", sr),
|
||||
field_h(theme, "Buf", buf),
|
||||
field_h(theme, "Lat", lat),
|
||||
)))
|
||||
wh_full(origin_e(east!(sr, buf, lat))),
|
||||
)))
|
||||
}
|
||||
|
||||
|
|
@ -466,24 +460,25 @@ pub fn view_wrap (bg: Color, fg: Color, content: impl Draw<Tui>) -> impl Draw<Tu
|
|||
/// let _ = tek::view_meters(&[0.0, 0.0]);
|
||||
/// ```
|
||||
pub fn view_meter <'a> (label: &'a str, value: f32) -> impl Draw<Tui> + 'a {
|
||||
south!(
|
||||
field_h(ItemTheme::G[128], label, format!("{:>+9.3}", value)),
|
||||
wh_exact(if value >= 0.0 { &"13" }
|
||||
else if value >= -1.0 { &"12" }
|
||||
else if value >= -2.0 { &"11" }
|
||||
else if value >= -3.0 { &"10" }
|
||||
else if value >= -4.0 { &"9" }
|
||||
else if value >= -6.0 { &"8" }
|
||||
else if value >= -9.0 { &"7" }
|
||||
else if value >= -12.0 { &"6" }
|
||||
else if value >= -15.0 { &"5" }
|
||||
else if value >= -20.0 { &"4" }
|
||||
else if value >= -25.0 { &"3" }
|
||||
else if value >= -30.0 { &"2" }
|
||||
else if value >= -40.0 { &"1" }
|
||||
else { 0 }, 1, bg(if value >= 0.0 { Red }
|
||||
else if value >= -3.0 { Yellow }
|
||||
else { Green }, ())))
|
||||
let f = field_h(ItemTheme::G[128], label, format!("{:>+9.3}", value));
|
||||
let w = if value >= 0.0 { 13 }
|
||||
else if value >= -1.0 { 12 }
|
||||
else if value >= -2.0 { 11 }
|
||||
else if value >= -3.0 { 10 }
|
||||
else if value >= -4.0 { 9 }
|
||||
else if value >= -6.0 { 8 }
|
||||
else if value >= -9.0 { 7 }
|
||||
else if value >= -12.0 { 6 }
|
||||
else if value >= -15.0 { 5 }
|
||||
else if value >= -20.0 { 4 }
|
||||
else if value >= -25.0 { 3 }
|
||||
else if value >= -30.0 { 2 }
|
||||
else if value >= -40.0 { 1 }
|
||||
else { 0 };
|
||||
let c = if value >= 0.0 { Red }
|
||||
else if value >= -3.0 { Yellow }
|
||||
else { Green };
|
||||
south!(f, wh_exact(Some(w), Some(1), bg(c, ())))
|
||||
}
|
||||
|
||||
pub fn view_meters (values: &[f32;2]) -> impl Draw<Tui> + use<'_> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue