Commit Graph

72 Commits

Author SHA1 Message Date
Benjamin Sago
c911b5f6e4 Replace Cells with growable TextCells
A recent change to ansi-term [1] means that `ANSIString`s can now hold either
owned *or* borrowed data (Rust calls this the Cow type). This means that we
can delay formatting ANSIStrings into ANSI-control-code-formatted strings
until it's absolutely necessary. The process for doing this was:

1. Replace the `Cell` type with a `TextCell` type that holds a vector of
   `ANSIString` values instead of a formatted string. It still does the
   width tracking.

2. Rework the details module's `render` functions to emit values of this
   type.

3. Similarly, rework the functions that produce cells containing filenames
   to use a `File` value's `name` field, which is an owned `String` that
   can now be re-used.

4. Update the printing, formatting, and width-calculating code in the
   details and grid-details views to produce a table by adding vectors
   together instead of adding strings together, delaying the formatting as
   long as it can.

This results in fewer allocations (as fewer `String` values are produced), and
makes the API tidier (as fewer `String` values are being passed around without
having their contents specified).

This also paves the way to Windows support, or at least support for
non-ANSI terminals: by delaying the time until strings are formatted,
it'll now be easier to change *how* they are formatted.

Casualties include:

- Bump to ansi_term v0.7.1, which impls `PartialEq` and `Debug` on
  `ANSIString`.
- The grid_details and lines views now need to take a vector of files, rather
  than a borrowed slice, so the filename cells produced now own the filename
  strings that get taken from files.
- Fixed the signature of `File#link_target` to specify that the
  file produced refers to the same directory, rather than some phantom
  directory with the same lifetime as the file. (This was wrong from the
  start, but it broke nothing until now)

References:

[1]: ansi-term@f6a6579ba8174de1cae64d181ec04af32ba2a4f0
2015-12-17 08:25:20 +08:00
Benjamin Sago
c39a57294c Versions bump 2015-12-15 21:38:56 +00:00
Ben S
9218799e6e Upgrade versions to working ones 2015-11-18 18:32:40 +00:00
Ben S
e07992d08c Use lazy_static to cache datetime formats
One of those two date formats was re-compiled before any date was displayed. Now they are compiled only the first time they're used, and cached versions are used thereafter, resulting in a speedup.
2015-11-15 19:26:58 +00:00
Ben S
cc04d0452f Pin versions to those we know work 2015-11-04 17:01:05 +00:00
Ben S
63bd929eb5 Upgrade to latest ansi_term
Changes to the way ANSIStrings work mean we need to dereference the strings before putting them in an ANSIString. There's more that can be done here, but this gets it to compile for now.
2015-11-03 11:17:44 +00:00
Ben S
1bebab78d0 Upgrade Rust version necessary 2015-10-30 10:40:56 +00:00
Ben S
8f4a2087e6 Version v0.4.0 2015-10-18 20:34:46 +01:00
Ben S
878d54111d Pin to git2-rs version 0.3
This should prove more stable than relying on a Git version.
2015-10-02 00:56:39 +01:00
Ben S
41fb02a02d Upgrade to latest version of datetime crate
- VariableOffset -> TimeZone::VariableOffset
2015-09-21 00:15:07 +01:00
Benjamin Sago
12ab6bebc6 Versions bump (git2, winapi) 2015-09-15 20:04:21 +01:00
Ben S
d1e682b0c1 Remove pad crate and unnecessary qualifications 2015-09-04 11:20:13 +01:00
Ben S
d089fcc1d8 Update rust-tz, amongst others 2015-09-02 23:23:23 +01:00
Ben S
4e49b91d23 Parallelise the details view!
This commit removes the threadpool in `main.rs` that stats each command-line argument separately, and replaces it with a *scoped* threadpool in `options/details.rs` that builds the table in parallel! Running this on my machine halves the execution time when tree-ing my entire home directory (which isn't exactly a common occurrence, but it's the only way to give exa a large running time)

The statting will be added back in parallel at a later stage. This was facilitated by the previous changes to recursion that made it easier to deal with.

There's a lot of large sweeping architectural changes. Here's a smattering of them:

- In `main.rs`, the files are now passed around as vectors of files rather than array slices of files. This is because `File`s aren't `Clone`, and the `Vec` is necessary to give away ownership of the files at the appropriate point.
- In the details view, files are now sorted *all* the time, rather than obeying the command-line order. As they're run in parallel, they have no guaranteed order anyway, so we *have* to sort them again. (I'm not sure if this should be the intended behaviour or not!) This means that the `Details` struct has to have the filter *all* the time, not only while recursing, so it's been moved out of the `recurse` field.
- We use `scoped_threadpool` over `threadpool`, a recent addition. It's only safely used on Nightly, which we're using anyway, so that's OK!
- Removed a bunch of out-of-date comments.

This also fixes #77, mainly by accident :)
2015-09-02 23:19:10 +01:00
Ben S
e523520b56 Versions bump 2015-08-25 18:25:48 +01:00
Ben S
d710151ea9 Updates for term-grid
The separator_width field in the term_grid crate was replaced with a filling field.
2015-07-15 21:16:08 +01:00
Kevin K
decd0c21ae updates libgit2 to build on latest nightly 2015-07-09 09:08:13 -04:00
Ben S
fe0d433e65 Require functionality from new term_grid 2015-06-29 14:24:39 +01:00
Ben S
766279b803 Versions bump 2015-06-28 06:17:00 +01:00
Ben S
8d6f62840a Use term_grid crate for grid formatting
Fixes #39!
2015-06-23 10:54:57 +01:00
Ben S
b235b64060 The feature flags wheel keeps on turning... 2015-06-21 12:52:53 +01:00
Ben S
4c61361bfb Version bump! 2015-06-05 04:00:38 +01:00
Ben S
ea3a57eb97 Start using threadpool crate 2015-06-05 03:04:56 +01:00
Ben S
cc1d6aa5f1 Display dates with the host's timezone
Fixes #54 using the datetime crate's spiffy new time zone ability.
2015-06-04 15:15:39 +01:00
Ben S
334258c18d Versions bump 2015-05-29 11:33:27 +01:00
Ben S
2594690aff Start using the libc crate from crates.io 2015-05-16 13:17:50 +01:00
Ben S
36116a1420 Add colours module, and disable them sometimes
Colours are now disabled when output is not to a terminal. Fixes #53!

This required some internal restructuring - colours are now in their own object that gets passed around everywhere it's needed.
2015-05-09 23:57:18 +01:00
Ben S
a460f257d7 Friendly neighbourhood versions bump 2015-05-06 21:46:21 +01:00
Ben S
41aadaeab4 Re-implement no-longer-missing metadata fields 2015-05-03 12:46:05 +01:00
Ben S
c3915576c1 Versions bump 2015-05-03 11:47:25 +01:00
Ben S
d7d11f77f3 Use unicode_width crate 2015-04-23 13:46:37 +01:00
Ben S
adbaa51cb9 Use new io + path + fs libraries (LOTS OF CHANGES)
Exa now uses the new IO, Path, and Filesystem libraries that have been out for a while now.

Unfortunately, the new libraries don't *entirely* cover the range of the old libraries just yet: in particular, to become more cross-platform, the data in `UnstableFileStat` isn't available in the Unix `MetadataExt` yet. Much of this is contained in rust-lang/rfcs#1044 (which is due to be implemented in rust-lang/rust#14711), but it's not *entirely* there yet.

As such, this commits a serious loss of functionality: no symlink viewing, no hard links or blocks, or users or groups. Also, some of the code could now be optimised. I just wanted to commit this to sort out most of the 'teething problems' of having a different path system in advance.

Here's an example problem that took ages to fix for you, just because you read this far: when I first got exa to compile, it worked mostly fine, except calling `exa` by itself didn't list the current directory. I traced where the command-line options were being generated, to where files and directories were sorted, to where the threads were spawned... and the problem turned out to be that it was using the full path as the file name, rather than just the last component, and these paths happened to begin with `.`, so it thought they were dotfiles.
2015-04-23 13:00:34 +01:00
Ben S
9758e96755 Bump versions yet again 2015-04-09 11:32:30 +01:00
Benjamin Sago
4d2d2385c1 One last version bump for the road... 2015-04-04 00:27:05 +02:00
Benjamin Sago
f885568145 Upgrade to latest Rust
Still missing a few Beta features, but it compiles!

- Copy requires Clone
- current_dir returns a Path now
- num_cpus moved to a crate
2015-04-04 00:14:56 +02:00
Ben S
697e1e66e4 Versions bump for latest Rust
- Changes to users crate
2015-03-26 00:35:39 +00:00
Ben S
9c2858e447 Upgrade to latest Rust
- old_path::Path isn't imported by default anymore
- range -> ..
2015-03-22 19:46:45 +00:00
Ben S
e6fa6c5b92 Versions bump 2015-03-22 12:05:29 +00:00
Ben S
640949934e Versions bump 2015-03-17 12:33:18 +00:00
Ben S
714e22f7a5 Versions bump 2015-03-12 03:13:15 +00:00
Ben S
99f9a75a24 Versions bump 2015-03-07 23:01:57 +00:00
Ben S
67f60e614b Add --version command (and bump version) 2015-03-02 14:54:38 +00:00
Ben S
6b3d812af5 Use development version of libgit2-rs
This stops the openssl-sys version clash preventing exa from compiling.
2015-03-02 01:58:39 +00:00
Michael Faille
2701c20a36 FIX bitflags depedency 2015-02-21 17:59:38 -05:00
Ben S
e15f72f049 Versions bump
This compiles, but with manymany warnings.
2015-02-21 13:51:44 +00:00
Ben S
900081e9c1 Versions bump 2015-02-17 07:50:52 +00:00
Ben S
d180a5f5e4 Use ansi_term's awesome new continuation colours 2015-02-13 21:24:10 +00:00
Ben S
ec51867a53 Upgrade to latest Rust
- Update package versions
- locale::default -> locale::english
- Argument handling changes
2015-02-12 22:33:01 +00:00
Ben S
2906b8676a Translate month names into the user's locale
This has been mostly done with changes in the datetime crate's suddenly
supporting locales.

It's still important that the user's locale is touched only once and
cached from that point on, so a struct in output::details has been made
public, along with that module. This will change later as that object
gains more and more uses thoughout the codes.
2015-02-10 18:14:56 +00:00
Ben S
21ac16f808 Format file size in bytes with the user's locale
Use the `locale` crate as a dependency to read in the set
thousands-separator character, and pass this to the file size column,
which uses it to add the separators in.

en_GB uses ","
fr_FR uses "" and just displays the numbers in one go.
2015-02-10 16:08:10 +00:00