Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Sep 3, 2023
1 parent 9b1c605 commit f2703a3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
10 changes: 6 additions & 4 deletions app/src/manager/folder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::files::File;

use config::{MANAGER, THEME};
use ratatui::{buffer::Buffer, layout::Rect, style::{Color, Modifier, Style, Stylize}, text::{Line, Span}, widgets::{List, ListItem, Widget}};
use ratatui::{buffer::Buffer, layout::Rect, style::{Color, Modifier, Style}, text::{Line, Span}, widgets::{List, ListItem, Widget}};
use shared::readable_path;

use crate::Ctx;
Expand Down Expand Up @@ -99,14 +99,16 @@ impl<'a> Widget for Folder<'a> {
self.file_style(f)
};

let mut spans = Vec::with_capacity(10);

let mut spans = Vec::with_capacity(5);
spans.push(Span::raw(format!(" {} ", Self::icon(f))));
spans.push(Span::raw(readable_path(f.path(), &self.folder.cwd)));

if let Some(link_to) = f.link_to() {
if MANAGER.show_symlink {
spans.push(Span::raw(format!(" -> {}", link_to.display())));
spans.push(Span::styled(
format!(" -> {}", link_to.display()),
Style::new().add_modifier(Modifier::ITALIC),
));
}
}

Expand Down
19 changes: 15 additions & 4 deletions config/src/keymap/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,23 @@ impl Exec {

impl Exec {
#[inline]
pub fn call(cwd: &str, args: Vec<String>) -> Vec<Self> {
vec![Exec { cmd: cwd.to_owned(), args, named: Default::default() }]
pub fn call(cwd: &str, args: Vec<String>) -> Self {
Exec { cmd: cwd.to_owned(), args, named: Default::default() }
}

#[inline]
pub fn call_named(cwd: &str, named: BTreeMap<String, String>) -> Vec<Self> {
vec![Exec { cmd: cwd.to_owned(), args: Default::default(), named }]
pub fn call_named(cwd: &str, named: BTreeMap<String, String>) -> Self {
Exec { cmd: cwd.to_owned(), args: Default::default(), named }
}

#[inline]
pub fn vec(self) -> Vec<Self> { vec![self] }

#[inline]
pub fn with_bool(mut self, name: &str, state: bool) -> Self {
if state {
self.named.insert(name.to_string(), "".to_string());
}
self
}
}
1 change: 0 additions & 1 deletion core/src/manager/finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ impl Finder {
if self.version == files.version() {
return false;
}

self.matched.clear();

let mut i = 0u8;
Expand Down
5 changes: 4 additions & 1 deletion core/src/manager/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ impl Tab {

tokio::spawn(async move {
if let Ok(s) = emit!(Input(InputOpt::top("Find:"))).await {
emit!(Call(Exec::call("find", vec![s]), KeymapLayer::Manager));
emit!(Call(
Exec::call("find", vec![s]).with_bool("previous", prev).vec(),
KeymapLayer::Manager
));
}
});
false
Expand Down

0 comments on commit f2703a3

Please sign in to comment.