mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
expand the area
This commit is contained in:
parent
774f382e2d
commit
ab723c5ba7
2 changed files with 11 additions and 4 deletions
|
|
@ -12,6 +12,7 @@ pub struct Completion {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Completion {
|
impl Completion {
|
||||||
|
// --- Cands
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn window(&self) -> &[String] {
|
pub fn window(&self) -> &[String] {
|
||||||
let end = (self.offset + self.limit()).min(self.cands.len());
|
let end = (self.offset + self.limit()).min(self.cands.len());
|
||||||
|
|
@ -19,8 +20,12 @@ impl Completion {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn limit(&self) -> usize { self.cands.len().min(5) }
|
pub fn limit(&self) -> usize { self.cands.len().min(10) }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn selected(&self) -> &String { &self.cands[self.cursor] }
|
pub fn selected(&self) -> &String { &self.cands[self.cursor] }
|
||||||
|
|
||||||
|
// --- Cursor
|
||||||
|
#[inline]
|
||||||
|
pub fn rel_cursor(&self) -> usize { self.cursor - self.offset }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ impl<'a> Widget for Completion<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut item = ListItem::new(format!(" {} {}", icon, x));
|
let mut item = ListItem::new(format!(" {} {}", icon, x));
|
||||||
if i == self.cx.completion.cursor {
|
if i == self.cx.completion.rel_cursor() {
|
||||||
item = item.style(THEME.completion.active.into());
|
item = item.style(THEME.completion.active.into());
|
||||||
} else {
|
} else {
|
||||||
item = item.style(THEME.completion.inactive.into());
|
item = item.style(THEME.completion.inactive.into());
|
||||||
|
|
@ -37,8 +37,10 @@ impl<'a> Widget for Completion<'a> {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let input_area = self.cx.area(&self.cx.input.position);
|
let input_area = self.cx.area(&self.cx.input.position);
|
||||||
let mut area =
|
let mut area = self.cx.area(&Position::Sticky(
|
||||||
self.cx.area(&Position::Sticky(Rect { x: 1, y: 0, width: 20, height: 15 }, input_area));
|
Rect { x: 1, y: 0, width: 20, height: items.len() as u16 + 2 },
|
||||||
|
input_area,
|
||||||
|
));
|
||||||
|
|
||||||
if area.y > input_area.y {
|
if area.y > input_area.y {
|
||||||
area.y = area.y.saturating_sub(1);
|
area.y = area.y.saturating_sub(1);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue