mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-01-27 07:38:27 +00:00
Apply sort order to line and grid outputs. Fix #404
This commit is contained in:
parent
13b91cced4
commit
2708360fb5
@ -264,13 +264,15 @@ impl<'args> Exa<'args> {
|
||||
|
||||
match (mode, self.console_width) {
|
||||
(Mode::Grid(ref opts), Some(console_width)) => {
|
||||
let r = grid::Render { files, theme, file_style, opts, console_width };
|
||||
let filter = &self.options.filter;
|
||||
let r = grid::Render { files, theme, file_style, opts, console_width, filter };
|
||||
r.render(&mut self.writer)
|
||||
}
|
||||
|
||||
(Mode::Grid(_), None) |
|
||||
(Mode::Lines, _) => {
|
||||
let r = lines::Render { files, theme, file_style };
|
||||
let filter = &self.options.filter;
|
||||
let r = lines::Render { files, theme, file_style, filter };
|
||||
r.render(&mut self.writer)
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ use std::io::{self, Write};
|
||||
use term_grid as tg;
|
||||
|
||||
use crate::fs::File;
|
||||
use crate::fs::filter::FileFilter;
|
||||
use crate::output::file_name::Options as FileStyle;
|
||||
use crate::theme::Theme;
|
||||
|
||||
@ -26,10 +27,11 @@ pub struct Render<'a> {
|
||||
pub file_style: &'a FileStyle,
|
||||
pub opts: &'a Options,
|
||||
pub console_width: usize,
|
||||
pub filter: &'a FileFilter,
|
||||
}
|
||||
|
||||
impl<'a> Render<'a> {
|
||||
pub fn render<W: Write>(&self, w: &mut W) -> io::Result<()> {
|
||||
pub fn render<W: Write>(mut self, w: &mut W) -> io::Result<()> {
|
||||
let mut grid = tg::Grid::new(tg::GridOptions {
|
||||
direction: self.opts.direction(),
|
||||
filling: tg::Filling::Spaces(2),
|
||||
@ -37,6 +39,7 @@ impl<'a> Render<'a> {
|
||||
|
||||
grid.reserve(self.files.len());
|
||||
|
||||
self.filter.sort_files(&mut self.files);
|
||||
for file in &self.files {
|
||||
let filename = self.file_style.for_file(file, self.theme).paint();
|
||||
|
||||
|
@ -3,6 +3,7 @@ use std::io::{self, Write};
|
||||
use ansi_term::ANSIStrings;
|
||||
|
||||
use crate::fs::File;
|
||||
use crate::fs::filter::FileFilter;
|
||||
use crate::output::cell::TextCellContents;
|
||||
use crate::output::file_name::{Options as FileStyle};
|
||||
use crate::theme::Theme;
|
||||
@ -13,10 +14,12 @@ pub struct Render<'a> {
|
||||
pub files: Vec<File<'a>>,
|
||||
pub theme: &'a Theme,
|
||||
pub file_style: &'a FileStyle,
|
||||
pub filter: &'a FileFilter,
|
||||
}
|
||||
|
||||
impl<'a> Render<'a> {
|
||||
pub fn render<W: Write>(&self, w: &mut W) -> io::Result<()> {
|
||||
pub fn render<W: Write>(mut self, w: &mut W) -> io::Result<()> {
|
||||
self.filter.sort_files(&mut self.files);
|
||||
for file in &self.files {
|
||||
let name_cell = self.render_file(file);
|
||||
writeln!(w, "{}", ANSIStrings(&name_cell))?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user