Files found from search are now displayed with their absolute path

This commit is contained in:
veeso
2021-11-09 16:40:35 +01:00
committed by Christian Visintin
parent 028f64a588
commit 3927fb2a39
9 changed files with 68 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ Released on FIXME:
- If find command doesn't return any result show an info dialog and not an empty explorer
- It is now possible to keep navigating on the other explorer while "found tab" is open
- ❗ It is not possible though to have the "found tab" on both explorers (otherwise you wouldn't be able to tell whether you're transferring files)
- Files found from search are now displayed with their absolute path
## 0.7.0

View File

@@ -339,6 +339,7 @@ These are the keys supported by the formatter:
- `GROUP`: Owner group
- `MTIME`: Last change time (with syntax `%b %d %Y %H:%M`); Extra might be provided as the time syntax (e.g. `{MTIME:8:%H:%M}`)
- `NAME`: File name (Elided if longer than LENGTH)
- `PATH`: File absolute path (Elided if longer than LENGHT)
- `PEX`: File permissions (UNIX format)
- `SIZE`: File size (omitted for directories)
- `SYMLINK`: Symlink (if any `-> {FILE_PATH}`)

View File

@@ -337,7 +337,8 @@ Estas son las claves admitidas por el formateador:
- `CTIME`: Hora de creación (con sintaxis`%b %d %Y %H:%M`); Se puede proporcionar un extra como sintaxis de tiempo (p. Ej., `{CTIME:8:%H:%M}`)
- `GROUP`: Grupo propietario
- `MTIME`: Hora del último cambio (con sintaxis`%b %d %Y %H:%M`); Se puede proporcionar extra como sintaxis de tiempo (p. Ej., `{MTIME: 8:% H:% M}`)
- `NAME`: nombre de archivo (se omite si es más largo que LENGTH)
- `NAME`: nombre de archivo (Las carpetas entre la raíz y los primeros antepasados se eliminan si es más largo que LENGTH)
- `PATH`: Percorso completo de archivo (Las carpetas entre la raíz y los primeros antepasados se eliminan si es màs largo que LENGHT)
- `PEX`: permisos de archivo (formato UNIX)
- `SIZE`: Tamaño del archivo (se omite para directorios)
- `SYMLINK`: Symlink (si existe` -> {FILE_PATH} `)

View File

@@ -336,6 +336,7 @@ Voici les clés prises en charge par le formateur :
- `GROUP`: Groupe de propriétaires
- `MTIME`: Heure du dernier changement (avec la syntaxe `%b %d %Y %H:%M`); Un supplément peut être fourni comme syntaxe de l'heure (par exemple, `{MTIME:8:%H:%M}`)
- `NAME`: Nom du fichier (élidé si plus long que LENGTH)
- `PATH`: Chemin absolu du fichier (les dossiers entre la racine et les premiers ancêtres sont éludés s'ils sont plus longs que LENGTH)
- `PEX`: Autorisations de fichiers (format UNIX)
- `SIZE`: Taille du fichier (omis pour les répertoires)
- `SYMLINK`: Lien symbolique (le cas échéant `-> {FILE_PATH}`)

View File

@@ -333,7 +333,8 @@ These are the keys supported by the formatter:
- `CTIME`: Creation time (con sintassi di default `%b %d %Y %H:%M`); Extra definisce il formato data (e.g. `{CTIME:8:%H:%M}`)
- `GROUP`: Owner group
- `MTIME`: Last change time (con sintassi di default `%b %d %Y %H:%M`); Extra definisce il formato data (e.g. `{MTIME:8:%H:%M}`)
- `NAME`: Nome file (Elided if longer than LENGTH)
- `NAME`: Nome file (Le cartelle comprese tra la root ed il genitore del file sono omessi se la lunghezza è maggiore di LENGTH)
- `PATH`: Percorso assoluto del file (Le cartelle comprese tra la root ed il genitore del file sono omessi se la lunghezza è maggiore di LENGHT)
- `PEX`: Permessi utente (formato UNIX)
- `SIZE`: Dimensione file (omesso per le directory)
- `SYMLINK`: Link simbolico (se presente `-> {FILE_PATH}`)

View File

@@ -336,7 +336,8 @@ These are the keys supported by the formatter:
- `CTIME`: Creation time (with syntax `%b %d %Y %H:%M`); Extra might be provided as the time syntax (e.g. `{CTIME:8:%H:%M}`)
- `GROUP`: Owner group
- `MTIME`: Last change time (with syntax `%b %d %Y %H:%M`); Extra might be provided as the time syntax (e.g. `{MTIME:8:%H:%M}`)
- `NAME`: File name (Elided if longer than LENGTH)
- `NAME`: File name (Folders between root and first ancestors are elided if longer than LENGTH)
- `PATH`: File absolute path (Folders between root and first ancestors are elided if longer than LENGHT)
- `PEX`: File permissions (UNIX format)
- `SIZE`: File size (omitted for directories)
- `SYMLINK`: Symlink (if any `-> {FILE_PATH}`)

View File

@@ -330,6 +330,7 @@ termscp和书签一样只需要保证这些路径是可访问的
- `GROUP`: 所属组
- `MTIME`: 最后修改时间(语法为`%b %d %Y %H:%M`Extra参数可以指定时间显示语法例如`{MTIME:8:%H:%M}`
- `NAME`: 文件名(超过 LENGTH 个字符的部分会被省略)
- `PATH`:文件绝对路径(如果长于 LENGTH则根目录和第一个祖先之间的文件夹将被排除
- `PEX`: 文件权限UNIX格式
- `SIZE`: 文件大小(目录不显示)
- `SYMLINK`: 超链接(如果存在的话`-> {FILE_PATH}`)。

View File

@@ -43,6 +43,7 @@ const FMT_KEY_CTIME: &str = "CTIME";
const FMT_KEY_GROUP: &str = "GROUP";
const FMT_KEY_MTIME: &str = "MTIME";
const FMT_KEY_NAME: &str = "NAME";
const FMT_KEY_PATH: &str = "PATH";
const FMT_KEY_PEX: &str = "PEX";
const FMT_KEY_SIZE: &str = "SIZE";
const FMT_KEY_SYMLINK: &str = "SYMLINK";
@@ -68,10 +69,15 @@ lazy_static! {
/// a chain of function is made using the Formatters method.
/// This method provides an extremely fast way to format fs entries
struct CallChainBlock {
/// The function to call to format current item
func: FmtCallback,
/// All the content which is between two `{KEY}` items
prefix: String,
/// The fmt len, specied for key as `{KEY:LEN}`
fmt_len: Option<usize>,
/// The extra argument for formatting, specified for key as `{KEY:LEN:EXTRA}`
fmt_extra: Option<String>,
/// The next block to format
next_block: Option<Box<CallChainBlock>>,
}
@@ -331,6 +337,28 @@ impl Formatter {
format!("{}{}{:0width$}", cur_str, prefix, name, width = file_len)
}
/// ### fmt_path
///
/// Format path
fn fmt_path(
&self,
fsentry: &FsEntry,
cur_str: &str,
prefix: &str,
fmt_len: Option<&usize>,
_fmt_extra: Option<&String>,
) -> String {
format!(
"{}{}{}",
cur_str,
prefix,
match fmt_len {
None => fsentry.get_abs_path().display().to_string(),
Some(len) => fmt_path_elide(fsentry.get_abs_path().as_path(), *len),
}
)
}
/// ### fmt_pex
///
/// Format file permissions
@@ -490,6 +518,7 @@ impl Formatter {
FMT_KEY_GROUP => Self::fmt_group,
FMT_KEY_MTIME => Self::fmt_mtime,
FMT_KEY_NAME => Self::fmt_name,
FMT_KEY_PATH => Self::fmt_path,
FMT_KEY_PEX => Self::fmt_pex,
FMT_KEY_SIZE => Self::fmt_size,
FMT_KEY_SYMLINK => Self::fmt_symlink,
@@ -880,6 +909,34 @@ mod tests {
));
}
#[test]
fn should_fmt_path() {
let t: SystemTime = SystemTime::now();
let entry: FsEntry = FsEntry::File(FsFile {
name: String::from("bar.txt"),
abs_path: PathBuf::from("/tmp/a/b/c/bar.txt"),
last_change_time: t,
last_access_time: t,
creation_time: t,
size: 8192,
ftype: Some(String::from("txt")),
symlink: None, // UNIX only
user: None, // UNIX only
group: None, // UNIX only
unix_pex: Some((UnixPex::from(6), UnixPex::from(4), UnixPex::from(4))), // UNIX only
});
let formatter: Formatter = Formatter::new("File path: {PATH}");
assert_eq!(
formatter.fmt(&entry).as_str(),
"File path: /tmp/a/b/c/bar.txt"
);
let formatter: Formatter = Formatter::new("File path: {PATH:8}");
assert_eq!(
formatter.fmt(&entry).as_str(),
"File path: /tmp/…/c/bar.txt"
);
}
/// ### dummy_fmt
///
/// Dummy formatter, just yelds an 'A' at the end of the current string

View File

@@ -174,7 +174,7 @@ impl Browser {
.with_group_dirs(Some(GroupDirs::First))
.with_hidden_files(true)
.with_stack_size(0)
.with_formatter(Some("{NAME:32} {SYMLINK}"))
.with_formatter(Some("{PATH:36} {SYMLINK}"))
.build()
}
}