mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-27 10:22:40 +00:00
Remove dependency between file and output mods
By removing the `File#file_name_width` method, we can make the file module have no dependency on the output module -- in other words, the model (file) and the view (output) are now separate again!
This commit is contained in:
parent
4c2bf2f2e6
commit
88653a00eb
10
src/file.rs
10
src/file.rs
@ -8,7 +8,6 @@ use std::os::unix::fs::{MetadataExt, PermissionsExt};
|
|||||||
use std::path::{Component, Path, PathBuf};
|
use std::path::{Component, Path, PathBuf};
|
||||||
|
|
||||||
use dir::Dir;
|
use dir::Dir;
|
||||||
use output::DisplayWidth;
|
|
||||||
|
|
||||||
use self::fields as f;
|
use self::fields as f;
|
||||||
|
|
||||||
@ -179,15 +178,6 @@ impl<'dir> File<'dir> {
|
|||||||
path_prefix
|
path_prefix
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The Unicode 'display width' of the filename.
|
|
||||||
///
|
|
||||||
/// This is related to the number of graphemes in the string: most
|
|
||||||
/// characters are 1 columns wide, but in some contexts, certain
|
|
||||||
/// characters are actually 2 columns wide.
|
|
||||||
pub fn file_name_width(&self) -> DisplayWidth {
|
|
||||||
DisplayWidth::from(&*self.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Assuming the current file is a symlink, follows the link and
|
/// Assuming the current file is a symlink, follows the link and
|
||||||
/// returns a File object from the path the link points to.
|
/// returns a File object from the path the link points to.
|
||||||
///
|
///
|
||||||
|
@ -281,7 +281,7 @@ impl Details {
|
|||||||
let mut errors = egg.errors;
|
let mut errors = egg.errors;
|
||||||
|
|
||||||
let name = TextCell {
|
let name = TextCell {
|
||||||
length: egg.file.file_name_width(),
|
length: DisplayWidth::from(&*egg.file.name),
|
||||||
contents: filename(egg.file, &self.colours, true),
|
contents: filename(egg.file, &self.colours, true),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -461,7 +461,7 @@ impl<U> Table<U> where U: Users {
|
|||||||
|
|
||||||
pub fn filename_cell(&self, file: File, links: bool) -> TextCell {
|
pub fn filename_cell(&self, file: File, links: bool) -> TextCell {
|
||||||
TextCell {
|
TextCell {
|
||||||
length: file.file_name_width(),
|
length: DisplayWidth::from(&*file.name),
|
||||||
contents: filename(file, &self.colours, links),
|
contents: filename(file, &self.colours, links),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use colours::Colours;
|
use colours::Colours;
|
||||||
use file::File;
|
use file::File;
|
||||||
use filetype::file_colour;
|
use filetype::file_colour;
|
||||||
|
use output::DisplayWidth;
|
||||||
|
|
||||||
use term_grid as grid;
|
use term_grid as grid;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ impl Grid {
|
|||||||
for file in files.iter() {
|
for file in files.iter() {
|
||||||
grid.add(grid::Cell {
|
grid.add(grid::Cell {
|
||||||
contents: file_colour(&self.colours, file).paint(&*file.name).to_string(),
|
contents: file_colour(&self.colours, file).paint(&*file.name).to_string(),
|
||||||
width: *file.file_name_width(),
|
width: *DisplayWidth::from(&*file.name),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user