mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Fix
This commit is contained in:
parent
769b469bba
commit
26c2269302
1 changed files with 9 additions and 20 deletions
|
|
@ -1,5 +1,4 @@
|
|||
use ratatui::{buffer::Buffer, layout::{self, Alignment, Constraint, Rect}, text::{Line, Text}, widgets::{Block, BorderType, List, Padding, Widget}};
|
||||
use textwrap::Options;
|
||||
use yazi_config::THEME;
|
||||
use yazi_core::tasks::TASKS_PERCENT;
|
||||
|
||||
|
|
@ -42,27 +41,17 @@ impl Widget for Tasks<'_> {
|
|||
.border_style(THEME.tasks.border);
|
||||
block.clone().render(area, buf);
|
||||
|
||||
let inner = block.inner(area);
|
||||
let tasks = &self.cx.tasks;
|
||||
let items = tasks
|
||||
.summaries
|
||||
.iter()
|
||||
.take(area.height.saturating_sub(2) as usize)
|
||||
.enumerate()
|
||||
.map(|(i, v)| {
|
||||
let line_otions = Options::new(area.width as usize).subsequent_indent(" ");
|
||||
let lines = textwrap::wrap(&v.name, line_otions)
|
||||
.iter()
|
||||
.map(|s| Line::from(s.clone()))
|
||||
.collect::<Vec<Line>>();
|
||||
|
||||
let mut item = Text::from(lines);
|
||||
let items = tasks.summaries.iter().take(inner.height as usize).enumerate().map(|(i, v)| {
|
||||
let mut item =
|
||||
Text::from_iter(textwrap::wrap(&v.name, inner.width as usize).into_iter().map(Line::from));
|
||||
if i == tasks.cursor {
|
||||
item = item.style(THEME.tasks.hovered);
|
||||
}
|
||||
item
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
});
|
||||
List::new(items).render(block.inner(area), buf);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue