mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: wrong height of Select component (#65)
This commit is contained in:
parent
f510693beb
commit
639b8425d9
2 changed files with 5 additions and 5 deletions
|
|
@ -10,20 +10,22 @@ pub struct SelectOpt {
|
||||||
|
|
||||||
impl SelectOpt {
|
impl SelectOpt {
|
||||||
pub fn top(title: &str, items: Vec<String>) -> Self {
|
pub fn top(title: &str, items: Vec<String>) -> Self {
|
||||||
|
let height = 2 + items.len().min(/* TODO: hardcode */ 5) as u16;
|
||||||
Self {
|
Self {
|
||||||
title: title.to_owned(),
|
title: title.to_owned(),
|
||||||
items,
|
items,
|
||||||
position: Position::Top(/* TODO: hardcode */ Rect { x: 0, y: 2, width: 50, height: 3 }),
|
position: Position::Top(/* TODO: hardcode */ Rect { x: 0, y: 2, width: 50, height }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hovered(title: &str, items: Vec<String>) -> Self {
|
pub fn hovered(title: &str, items: Vec<String>) -> Self {
|
||||||
|
let height = 2 + items.len().min(/* TODO: hardcode */ 5) as u16;
|
||||||
Self {
|
Self {
|
||||||
title: title.to_owned(),
|
title: title.to_owned(),
|
||||||
items,
|
items,
|
||||||
position: Position::Hovered(
|
position: Position::Hovered(
|
||||||
// TODO: hardcode
|
// TODO: hardcode
|
||||||
Rect { x: 0, y: 1, width: 50, height: 3 },
|
Rect { x: 0, y: 1, width: 50, height },
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,9 +76,7 @@ impl Select {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn limit(&self) -> usize {
|
pub fn limit(&self) -> usize { self.items.len().min(5) }
|
||||||
self.items.len().min(tty_size().ws_row.saturating_sub(SELECT_PADDING).min(5) as usize)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Select {
|
impl Select {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue