Improve view of project search
This commit is contained in:
parent
a08eb6bc8b
commit
608d96ef7f
1 changed files with 22 additions and 5 deletions
27
src/main.rs
27
src/main.rs
|
|
@ -1183,6 +1183,7 @@ impl Application for App {
|
||||||
let cosmic_theme::Spacing {
|
let cosmic_theme::Spacing {
|
||||||
space_none,
|
space_none,
|
||||||
space_s,
|
space_s,
|
||||||
|
space_xs,
|
||||||
space_xxs,
|
space_xxs,
|
||||||
..
|
..
|
||||||
} = self.core().system_theme().cosmic().spacing;
|
} = self.core().system_theme().cosmic().spacing;
|
||||||
|
|
@ -1259,16 +1260,32 @@ impl Application for App {
|
||||||
{
|
{
|
||||||
let mut column =
|
let mut column =
|
||||||
widget::column::with_capacity(file_search_result.lines.len());
|
widget::column::with_capacity(file_search_result.lines.len());
|
||||||
|
let mut line_number_width = 1;
|
||||||
|
if let Some(line_search_result) = file_search_result.lines.last() {
|
||||||
|
let mut number = line_search_result.number;
|
||||||
|
while number >= 10 {
|
||||||
|
number /= 10;
|
||||||
|
line_number_width += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (line_i, line_search_result) in
|
for (line_i, line_search_result) in
|
||||||
file_search_result.lines.iter().enumerate()
|
file_search_result.lines.iter().enumerate()
|
||||||
{
|
{
|
||||||
column = column.push(
|
column = column.push(
|
||||||
widget::button(
|
widget::button(
|
||||||
widget::text(format!(
|
widget::row::with_children(vec![
|
||||||
"{}: {}",
|
widget::text(format!(
|
||||||
line_search_result.number, line_search_result.text
|
"{:width$}",
|
||||||
))
|
line_search_result.number,
|
||||||
.font(Font::MONOSPACE),
|
width = line_number_width,
|
||||||
|
))
|
||||||
|
.font(Font::MONOSPACE)
|
||||||
|
.into(),
|
||||||
|
widget::text(format!("{}", line_search_result.text))
|
||||||
|
.font(Font::MONOSPACE)
|
||||||
|
.into(),
|
||||||
|
])
|
||||||
|
.spacing(space_xs),
|
||||||
)
|
)
|
||||||
.on_press(Message::OpenSearchResult(file_i, line_i))
|
.on_press(Message::OpenSearchResult(file_i, line_i))
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue