Commit Graph

796 Commits

Author SHA1 Message Date
nwin
48b6123165 Implement display of extended attributes 2015-02-22 13:26:52 +01:00
nwin
376e417c3f Replace &String with &str 2015-02-22 13:26:20 +01:00
Corey Ford
43e8061996 Use file_name_width in grid
Filenames with characters that need multiple bytes in UTF-8, and/or
control characters like combining diacritics, would break the grid.
`StrExt::width` seems to do the right thing, and there's conveniently a
function here (which was otherwise unused) to call that.
2015-02-21 19:31:17 -08:00
Ben S
a4e17193d9 Add sort-by-date options
These were completely missing because I forgot about them... I added sorting functionality before I added date functionality, but it turns out I didn't even need the datetime library to do this!

However, this implementation feels incomplete. If you sort by the accessed date, it still displays the modified date, so the dates still look out of order. If I were to change the date column for the user, though, then there would still be no header to signify that the column has changed. I'm not sure how to proceed with this, but this is still missing functionality, so in it goes.
2015-02-22 00:40:46 +00:00
Ben S
f8768e7c01 Mandate --recurse with --tree
Fixes #7.
2015-02-21 23:43:40 +00:00
Ben S
363d52dbb0 Code cleanups in filetype detection 2015-02-21 22:00:59 +00:00
Ben S
b2ed264ba4 Upgrade to latest Rust
- Feature flags changes (old_io, old_path)
- Slice syntax changes ([] -> [..])
2015-02-21 13:54:35 +00:00
Ben S
03a05b7020 Detab 2015-02-13 21:24:29 +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
e39a20a5d4 Use locale-defined decimal separator
Also, fix the broken tests by just using the default locale at test
time.
2015-02-10 16:42:25 +00:00
Ben S
84b18e5521 Add thousands seps to links and blocks columns 2015-02-10 16:21:19 +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
Ben S
f3c3a02e98 Make --tree require --long 2015-02-10 12:08:01 +00:00
Ben S
8b520edf3d Only display the year if it's last year
Otherwise, just display the hour and minute.
2015-02-09 18:14:05 +00:00
Ben S
bc7492e7e6 Add hour and minute to timestamps 2015-02-09 17:55:55 +00:00
Ben S
bf815afa8e Use short month names to make them line up 2015-02-09 17:37:02 +00:00
Ben S
1e48539380 Add shorthand options for displaying timestamps
Add options -u, -U, and -m as shorthand options for displaying different
types of timestamp, not just one. It's possible to have more than one by
specifying more than one of these shorthands, but *not* when used with
--time, as this is only meant to display one at a time.
2015-02-09 17:20:42 +00:00
Ben S
4a6555b9a9 Forbid --time without --long option, too 2015-02-09 16:55:00 +00:00
Ben S
0d7de0a2fa Add --tree to README 2015-02-09 16:49:31 +00:00
Ben S
a777794f65 Change time option's description 2015-02-09 16:36:51 +00:00
Ben S
0d25a90ef1 Initial work on date/time columns for files
Using the datetime crate, add an extra column to the --long view that
prints out the modified, accessed, or created timestamp for each file.
Also, let the user pick which one they want to see based on the --time
command-line option.
2015-02-09 16:33:27 +00:00
Ben S
055854d839 Upgrade to latest Rust
- std::os -> std::env
2015-02-05 15:25:59 +00:00
Ben S
42ae7b3d33 Refactor the code after tree view changes
- Turn the views and main program loop into structs, rather than just as one gigantic function
- Separate views into their own files

The addition of the git column and the tree view meant that a lot of functions now just took extra arguments that didn't seem to fit. For example, it didn't really work to have only one 'view' method that printed out everything, as the different view options now all take different parameters.
2015-02-05 14:39:56 +00:00
Ben S
5f2acf570c Use the new IntoIterator trait
See RFC 235
2015-02-04 16:03:39 +00:00
Ben S
2be30f36f2 Make transform_files stateful
Using `retain` instead of `filter` means we can just re-use the same Vec.
2015-02-04 15:47:52 +00:00
Ben S
8f36dbbc6f Start using the new getopts interface 2015-02-04 14:51:55 +00:00
Ben S
184c27f5b4 unwrap_err() now uses Debug 2015-02-04 01:40:12 +00:00
Ben S
1bced1423b Fix tests from tree view fallout 2015-02-04 01:12:08 +00:00
Ben S
e85460998e Replace hash marks with decent-looking tree
This commit has been brought to you by Unicode Box-Drawing Characters!
2015-02-04 00:59:27 +00:00
Ben S
5eb9f9e414 Have tree view obey filtering and sorting 2015-02-03 21:26:21 +00:00
Ben S
d4d04b7e92 Turn the file filter options into their own struct 2015-02-03 17:03:58 +00:00
Ben S
827a1e11fd Make filename not a column
FileName was always a special-cased column, as it was assumed to be the last column in the output. Now, it's explicitly marked as such. This allows the hash marks to be placed before the filename, rather than at the start of the line.
2015-02-03 13:48:39 +00:00
Ben S
f825397912 Replace tuple with actual struct 2015-02-03 13:32:42 +00:00
Ben S
5099b3f119 Initial tree implementation
There's still a lot to do, but this is actually *something*. The tree hierarchy is displayed using hashes at the start of a line. I want to have it just before the filename, but this will need some changes to the way that columns are handled.
2015-02-03 13:27:23 +00:00
Ben S
a2020c6457 What the heck? 2015-02-01 09:39:30 +00:00
Ben S
5611a5768a Recurse into directories 2015-02-01 02:14:31 +00:00
Ben S
3242cb216a Fix failing tests 2015-01-31 17:24:54 +00:00
Ben S
10096d1043 Prevent crash for filenames with no components
Now there are no more unwrap()s!
2015-01-31 17:18:53 +00:00
Ben S
6d4b30d531 Code changes in preparation for recursion 2015-01-31 16:10:40 +00:00
Ben S
c7e8a28e17 Add a bunch of feature flags 2015-01-29 14:06:17 +00:00
Ben S
b0cdd17b97 Change the way columns are created
You can now have different columns per directory. So now, the Git column only appears when there's a Git repository in the current directory.
2015-01-28 22:02:25 +00:00
Ben S
947087567c Upgrade to latest Rust
- Rename std::io to std::old_io
2015-01-28 16:55:34 +00:00
Ben S
be9eefe44b Oops, fix --no-default-features compilation 2015-01-28 16:53:13 +00:00
Ben S
04b2483d1f Compare vectors, not strings
This is good for two reasons: 1) shorter code! 2) it won't fail if any of the filenames aren't valid UTF-8.
2015-01-28 15:49:17 +00:00
Ben S
f794f5eda6 Implement Git status for directories 2015-01-28 10:43:19 +00:00
Ben S
1d0cc329eb Don't even show the column without the feature 2015-01-27 15:30:55 +00:00
Ben S
90d4684de4 Preliminary Git support!
This is something that I've long wanted to add. It uses libgit2 as an optional dependency.
2015-01-27 15:01:17 +00:00
Ben S
e835fe8fe3 Make all fields of Dir private 2015-01-26 17:26:11 +00:00
Ben S
da9d1f77d9 Cache the lowercased extension
Extensions aren't ever displayed in lowercase, just compared case-insensitively, so this makes sense.
2015-01-26 01:16:19 +00:00
Ben S
22a4dc90b9 Update #[derive] names 2015-01-26 00:27:06 +00:00
Benjamin Sago
8e33c75355 Simplify columns view code
The widths come pre-computed, so there's no reason to keep them around in this table anymore.
2015-01-25 19:20:51 +00:00
Benjamin Sago
628d90fe44 Test extension extraction 2015-01-25 13:47:07 +00:00
Benjamin Sago
ef4428fab1 Test highlighting of groups and group names 2015-01-25 13:43:44 +00:00
Benjamin Sago
191c0e5b90 Test highlighting of usernames 2015-01-25 13:04:15 +00:00
Benjamin Sago
c53a0156e6 Extract symlink stuff into its own method 2015-01-24 17:34:33 +00:00
Benjamin Sago
449592c150 Do column width calculations ourselves (speedup)
Instead of stripping the ANSI formatting characters from our strings, work out the length without them and use that. This is per-column, but most of them are simple (just the same number of characters in the non-coloured string).

Sometimes, this is really simple: for example, trwxrwxrwx permissions strings are always going to be ten characters long, and the strings that get returned are chock full of ANSI escape codes.

This should have a small benefit on performance.
2015-01-24 17:26:26 +00:00
Benjamin Sago
f82dc741de Correct argument name 2015-01-24 17:14:25 +00:00
Benjamin Sago
74fd04c1fb Forbid a few more option combinations 2015-01-24 16:03:58 +00:00
Benjamin Sago
0edf761d22 Add all-important dots 2015-01-24 16:02:52 +00:00
Ben S
64c1600cd4 Make some fields private 2015-01-24 13:44:25 +00:00
Ben S
709fb71e69 Actually use the is_dotfile method 2015-01-24 12:53:25 +00:00
Ben S
2ba0b3bd5f Convert docs to standard format 2015-01-24 12:38:05 +00:00
Ben S
6457f4b577 Rename exa.rs to main.rs 2015-01-23 19:36:01 +00:00
Ben S
0e473bf37b Upgrade to latest Rust, and move options code 2015-01-23 19:27:06 +00:00
Benjamin Sago
95388e6e90 Fix header-printing logic 2015-01-13 00:35:44 +01:00
Benjamin Sago
728e7dd976 Forbid certain argument combinations 2015-01-13 00:31:30 +01:00
Benjamin Sago
3d59a48efe Make option parsing unit-testable 2015-01-12 22:47:05 +01:00
Benjamin Sago
1ec4451016 rm trailing whitespace 2015-01-12 22:46:04 +01:00
Benjamin Sago
23e5d3ce8d Allow for different types of failure 2015-01-12 22:14:27 +01:00
Benjamin Sago
3f08836c3f Move viewing code to its own module 2015-01-12 21:08:42 +01:00
Benjamin Sago
9729679f05 Main code tidy-ups 2015-01-12 20:48:07 +01:00
Benjamin Sago
d93bca8779 Make some options fields private 2015-01-12 19:44:39 +01:00
Benjamin Sago
1c5409e253 Upgrade to Rust alpha
- uint -> usize
- getopts Cargo library
- replace feature gates with unstable APIs
2015-01-12 01:31:24 +01:00
Ben S
d400231de5 Upgrade to latest Rust
Also, remove dependency on the Regex library by replacing the one place it was used with standard code that should hopefully be faster anyway.
2015-01-05 14:41:43 +00:00
Ben S
ba36d4f7f0 Library and Rust upgrades 2015-01-04 13:56:07 +00:00
Benjamin Sago
fdf95fc206 to_ascii_lower -> to_ascii_lowercase 2015-01-01 02:37:10 +00:00
Ben S
e3a8342173 Upgrade code and libraries to latest Rust
std::str changes, and the way macros are expanded.
2014-12-24 04:31:59 +00:00
Ben S
a871a448be Add --bytes to not use prefixes at all 2014-12-18 07:04:31 +00:00
Ben S
f03a496424 Only underline executable *files* in perms view 2014-12-18 07:00:51 +00:00
Ben S
24628f97be Use number_prefix crate for number prefixes 2014-12-18 07:00:31 +00:00
Ben S
e005174577 Extract separator_width variable 2014-12-14 19:05:07 +00:00
Ben S
49c1b8ea16 Use a more compact grid view
Now the grids are optimised so each column is only as wide as its longest file name. The method could do with some optimising, but at least it works.
2014-12-14 18:30:41 +00:00
Ben S
224849b0e9 Make copyable values copyable 2014-12-14 18:23:06 +00:00
Ben S
bcaed1ff35 Remove redundant slicing 2014-12-12 14:17:57 +00:00
Ben S
57430dbbe5 Why be so specific?
Different types of user caches could come in the future...
2014-12-12 14:13:08 +00:00
Ben S
66339e7a15 Miscellaneous little optimisations
- Prefer iter over into_iter where appropriate
- Cut down on cloning
2014-12-12 14:06:48 +00:00
Ben S
4484982734 Whitespace fixes 2014-12-12 12:08:14 +00:00
Ben S
65f124fe39 Use the natord library instead of our own sorter
I'm serious, the more functionality I can use external crates for, the better.
2014-12-12 11:26:18 +00:00
Ben S
6770ac5475 Replare Unix module with users crate
Feels good turning all that code into a dependency!
2014-12-12 11:17:55 +00:00
Ben S
6134096586 Upgrade to latest Rust
I can't complain, because the breaking changes were caused by my pull request...
2014-12-02 14:20:28 +00:00
Ben S
c217dce73d Simplify width-checking code
With suggestions from helpful #rust folk. Thank you!
2014-11-26 08:23:17 +00:00
Ben S
c52625b1ce Display files on a single line if possible 2014-11-26 08:05:07 +00:00
Ben S
8b3602f20f Remove unused lifetime 2014-11-26 07:40:52 +00:00
Ben S
05dd644c92 Upgrade to latest ansi_term
Yeah, I broke my own code again.
2014-11-26 07:36:09 +00:00
Ben S
6ade060eb6 Use curlies consistently 2014-11-25 20:50:23 +00:00
Ben S
e1d3512a69 Add --help flag 2014-11-25 15:54:50 +00:00
Ben S
0b1e94a3c8 Fix bug where header line would appear twice 2014-11-25 01:31:26 +00:00
Ben S
df6544aae0 from_buf -> String::from_raw_buf 2014-11-25 01:29:33 +00:00
Ben S
bcaf54d7dd Add a flag to print directories as files
Also, re-use the stat result from directory-checking.
2014-11-25 01:27:26 +00:00
Ben S
cbd2f1fa37 List files and directories separately
This finally fixes the issue where trying to list a file causes a crash. Also, tidy up some of the uses of references.
2014-11-24 17:03:36 +00:00
Ben S
c7417e0bca Remove unnecessary namespacing 2014-11-24 02:18:22 +00:00
Ben S
8e455f9390 Optimise unsafe usage 2014-11-24 02:16:28 +00:00
Ben S
5b7124bb71 I like aligning things 2014-11-24 02:13:54 +00:00
Ben S
d72be30c30 Reduce unnecessary String allocations
- Remove uses of to_string() on a &str where it wasn't necessary
- Use SendStr to reduce allocations further
2014-11-24 02:01:08 +00:00
Ben S
c75bbf7f79 Add path to symlinks 2014-11-24 01:48:51 +00:00
Ben S
03ecb8c9e1 Fix bug with empty directories 2014-11-24 01:24:45 +00:00
Ben S
b7e7bc7057 Fix bug that panics when getting group info
I'm not sure if this a Rust change or something I've introduced...
2014-11-24 01:13:58 +00:00
Ben S
71f03157aa Add some more file extensions 2014-11-23 23:01:06 +00:00
Ben S
ab66c681c2 Add some pointers 2014-11-23 22:36:03 +00:00
Ben S
d7b8b230ef Remove containers from file name in grid view
What a strange bug to happen
2014-11-23 21:57:33 +00:00
Ben S
933f98d2c3 Upgrade to latest Rust nightly 2014-11-23 21:29:11 +00:00
Ben S
26f8ad08bf Replace from_c_str with from_buf 2014-09-22 21:47:22 +02:00
Ben S
c80d1ec862 Replace to_option() with as_ref() 2014-09-22 21:12:07 +02:00
Ben S
b0c51d93f8 Remove a few deprecated constructs
The language keeps changing when I'm not looking!
2014-09-22 18:03:47 +02:00
Ben S
a2e9144866 Match file extensions case-insensitively
I truly didn't realise this wasn't already done until someone sent me a .BMP file.
2014-07-22 22:32:16 +01:00
Ben S
fb8821164c Misc style changes 2014-07-22 22:27:37 +01:00
Ben S
527528e81f Move file-sorting code outside the view functions 2014-07-22 22:19:51 +01:00
Ben S
e2f9a80ca5 Add none and inode sort options 2014-07-22 21:27:36 +01:00
Ben S
35a0ba3ba0 Use one-line view when output is not to a terminal 2014-07-22 20:50:53 +01:00
Ben S
44a9819417 Add --oneline option
Also, rename old 'lines' view to 'details' which makes more sense
2014-07-22 20:47:30 +01:00
Ben S
cf3e32c9c1 Get terminal width for grid view (resolve #1) 2014-07-22 15:41:20 +01:00
Ben S
b1560edb85 Use string width, rather than length, to calculate column size 2014-07-21 22:05:39 +01:00
Ben S
4cbc1f063a Upgrade to latest Rust nightly
- Lifetime changes in unix.rs
- lexical_ordering -> cmp
- from_utf8_lossy got moved into String
- vec.get(n) -> vec[n]
2014-07-21 22:05:04 +01:00
Ben S
90099f28cf Upgrade to latest Rust nightly
- change to_string() on numbers to to_str()
2014-07-10 22:20:52 +01:00
Ben S
fc90f4bfc9 Don't pad the final column 2014-07-07 20:11:30 +01:00
Ben S
240cbf7b41 Add --across parameter 2014-07-07 19:18:09 +01:00
Ben S
03c51f0bfd Correctly calculate number of rows 2014-07-07 18:42:09 +01:00
Ben S
92ccf821ff Colour file names in grid view 2014-07-06 18:00:27 +01:00
Ben S
728f9f1804 Add grid view by default
This makes it more like ls. The --long (-l) argument has been added to get at the old behaviour, and the --links argument is now on -H. I can't crib this behaviour from ls because it shows it by default.

TODO: The terminal size is currently assumed to be 80, and it uses the string length, rather than the width.
2014-07-06 17:33:40 +01:00
Ben S
de9c2d29dd Merge branch 'master' of github.com:ogham/exa 2014-07-05 22:37:03 +01:00
Ben S
8daeba2617 Move string-to-filenames-vector code to its own function 2014-07-05 22:36:43 +01:00
Ben S
0de80ad7ec Rename variable 2014-07-05 19:54:34 +01:00
Ben S
cfb0fa9b72 Import Paint trait from rust-ansi-term 2014-07-04 09:54:14 +01:00
Ben S
43e3f742ca Comply with latest rust-ansi-term 2014-07-02 21:47:43 +01:00
Ben S
d2647df0ca Move some stuff out to rust-ansi-term crate 2014-07-01 19:00:36 +01:00
Ben S
eecfd88363 Simplify alignment code 2014-06-30 09:59:54 +01:00
Ben S
178e24552d Move comment 2014-06-30 02:06:07 +01:00
Ben S
44628ba6e2 Standardise on a grey 2014-06-30 02:04:36 +01:00
Ben S
0a1d3f56ec Add guard to get_source_files 2014-06-30 02:00:05 +01:00
Ben S
c494c0cd22 Don't scan the filename string twice 2014-06-30 01:51:11 +01:00
Ben S
f0fc7e992a Make pointers const (to comply with nightly Rust) 2014-06-29 22:28:52 +01:00
Ben S
df65886d6d Properly handle invalid UTF-8 filenames 2014-06-29 21:02:14 +01:00
Ben S
85e557a744 Highlight common build files 2014-06-28 17:56:57 +01:00
Ben S
a8465fed45 Move to Cargo 2014-06-28 17:24:20 +01:00