Commit Graph

1047 Commits

Author SHA1 Message Date
Benjamin Sago
1824313cda Put misfire.rs in a nicer order
The main type is now at the top.
2017-09-13 23:49:30 +01:00
Benjamin Sago
43bbf00478 Show a warning when running ‘exa -ltr’
Raised in #243 and #284. exa isn’t able to override the -t option like this, so the least it can do is detect that case (which is going to be an error case anyway) and show a suggestion.
2017-09-13 23:47:19 +01:00
Benjamin Sago
0fefc78cbb Add more modified date aliases
I don’t really see the modified date as the *modified* date, rather just the *date* field, because it’s the date field I refer to like 99.9% of the time. So now it has aliases to match.

Also are included are aliases for the reverse order, because I’d rather write “new” than “the reverse of old”.
2017-09-13 23:26:06 +01:00
Benjamin Sago
19b7780755 Fix typo in error message
It said “(Choices: (choices: this, that, other))” instead of “(choices: this, that, other)”. Also improve the same error elsewhere: options more have ‘settings’ than ‘values’.
2017-09-13 22:37:51 +01:00
Benjamin Sago
68e70bf036 Reword this comment 2017-09-13 22:12:11 +01:00
Benjamin Sago
aa2e3a5d9e Merge branch 'ls-colors-finally' 2017-09-13 10:12:08 +01:00
Benjamin Sago
dc45332d7b Implement file name colouring in {exa,ls}_colors
This commit adds to the parsing of the LS_COLORS and EXA_COLORS variables so that non-two-letter codes (keys other than things like ‘di’ or ‘ln’ or ‘ex’) will be treated as file name globs, and get used to colour files accordingly.

Fixes #116 for good.
2017-09-13 08:51:57 +01:00
Benjamin Sago
b86074d63b Rename Style to Styles to avoid a name clash 2017-09-13 08:44:59 +01:00
Theodore Dubois
f99d3417ea Update README.md 2017-09-04 14:42:17 -07:00
Benjamin Sago
28b4b672d4 Move FileStyle to the same options file as Colours
They are going to be deduced together (from the same environment variable) so it makes sense to put them in the same file first.
2017-09-03 19:50:40 +01:00
Benjamin Sago
4507edd734 256 colour support in ls_colors
This is more annoying than it should be because it has to work with Styles rather than with strings, which means parsing them, and parsing is always tricky business.
2017-09-03 17:05:38 +01:00
Benjamin Sago
bad794ab9d Versions bump 2017-09-03 17:03:30 +01:00
Benjamin Sago
265f93f7cd Merge branch 'late-git-discovery'
This merges in the new Git code, which now uses a global cache rather than being per-repository. This lets exa keep the Git column when listing files outside of a directory and when in recursive or tree views.

Fixes #24 and #183.
2017-09-02 21:59:15 +01:00
Benjamin Sago
c60ea36a31 Allow --git --tree, too
This works by checking if any of the (immediate) files being listed are under Git, and hiding the column if all aren’t.
2017-09-02 12:53:08 +01:00
Benjamin Sago
9cda05df20 Only display Git column for directories with repos
This fixes the previous commit.
2017-09-02 00:04:22 +01:00
Benjamin Sago
558b13880b Don’t pass Dirs to the Table
A Table now doesn’t need to know about (or even import) Dir, because we can just not pass the Git reference in if it shouldn’t be using it.
2017-09-01 22:52:13 +01:00
Benjamin Sago
f3c7fa500f Fix TableOptions Debug
The only field we can really show is the list of columns, and that happened to be useful this one time, so it might as well get shown!
2017-09-01 22:48:42 +01:00
Benjamin Sago
45a807a14f Redo Git implementation to allow --git --recurse
This is all a big commit because it took a lot more work than I thought it would! The commit basically moves Git repositories from being per-directory to living for the whole life of the program. This allows for several directories in the same repository to be listed in the same invocation; before, it would try to rediscover the repository each time! This is why two of the tests “broke”: it suddenly started working with --recurse.

The Dir type does now not use Git at all; because a Dir doesn’t have a Git, then a File doesn’t have one either, so the Git cache gets passed to the render functions which will put them in the Table to render them.
2017-09-01 19:13:47 +01:00
Benjamin Sago
3d4ddf8af6 Group Git repositories by their workdir
This uses the Git module’s newfound powers of getting actual GitRepo values from a factory to cache repositories a bit more. Now, when querying two directories under the same repository, it’ll open both, see that they have the same workdir, and only use the first one.
2017-08-28 23:52:21 +01:00
Benjamin Sago
62075fe984 Code and logging fix-ups 2017-08-28 18:40:52 +01:00
Benjamin Sago
cfc05eef00 Add test for nested Git repository
I don’t know how this should work, but let’s at least record the current behaviour in case it changes
2017-08-28 18:24:20 +01:00
Benjamin Sago
040dbb2414 Use a global Git cache
This commit adds a cache for Git repositories based on the path being queried.

Its only immediate effect is that when you query the same directory twice (such as /testcases/git /testcases/git), it won’t need to check that the second one is a Git directory the second time. So, a minuscule optimisation for something you’d never do anyway? Wrong! It’s going to let us combine multiple entries over the same repository later, letting us use --tree and --recurse, because now Git scanning is behind a factory.
2017-08-28 18:11:38 +01:00
Benjamin Sago
55aaecb74d Improve Git test coverage
- Two different repositories being queried at once
- The same one being queried twice, at different depths
- Tests for --tree and --recurse that should break in the future when that’s implemented
- Also just more tests in general
2017-08-28 15:10:29 +01:00
Benjamin Sago
be70fbdf98 Add test for multiple Git repositories 2017-08-27 00:33:02 +01:00
Benjamin Sago
d86fc4286b \t and \s+$ 2017-08-26 23:54:12 +01:00
Benjamin Sago
075fe802b4 Merge branch 'exa-colors'
This branch added support for the EXA_COLORS environment variable, and defines a bunch of two-letter configuration settings that allows theming exa.

The next step is to allow custom highlighting based on file names.
2017-08-26 23:46:54 +01:00
Benjamin Sago
b13b37ed29 Add exa_colors support to the Vagrant VM 2017-08-26 23:44:29 +01:00
Benjamin Sago
f6b7b7f298 Add exa_colors to make exa themable
This adds support for the EXA_COLORS environment variable, and defines a bunch of exa-specific two-letter codes that I pretty much made up arbitrarily that control parts of the interface.

Fixes #160, which I didn’t expect to actually fix this release cycle, but it unexpectedly became easy to do!
2017-08-26 23:17:07 +01:00
Benjamin Sago
504a0dd6b7 Stop collecting ls_colors into a hashmap
LSColors used to be built up from an iterator, and then queried later. But because the resulting HashMap gets queried in serial anyway, we might as well pass in a callback instead, saving the allocation.

This is also technically a little faster because styles that don’t map to anything (like `zz`) are no longer parsed.
2017-08-26 22:33:16 +01:00
Benjamin Sago
dd838c2dc1 Move Colours and LSColors to their own module
The ‘options’ module is allowed to depend on ‘style’, but ‘options::render’ is not.
2017-08-26 21:40:37 +01:00
Benjamin Sago
945fa1e83d Isolate and document the environment variables 2017-08-26 21:36:27 +01:00
Benjamin Sago
bf8ff3675b Move Vars into its own module 2017-08-26 20:48:51 +01:00
Benjamin Sago
bfb8a5a573 Extract trait above file name colours
This commit meddles about with both the Colours and the FileExtensions.

Even though all the renderable fields were turned into traits, the FileName struct kept on accessing fields directly on the Colours value instead of calling methods on it. It also did the usual amount of colour misappropriation (such as ‘punctuation’ instead of specifying ‘normal_arrow’)

In preparation for when custom file colours are configurable (any day now), the colourise-file-by-kind functionality (links, sockets, or directories) was separated from the colourise-file-by-name functionality (images, videos, archives). The FileStyle struct already allowed for both to be separate; it was only changed so that a type other than FileExtensions could be used instead, as long as it implements the FileColours trait. (I feel like I should re-visit the naming of all these at some point in the future)

The decision to separate the two means that FileExtensions is the one assigning the colours, rather than going through the fields on a Colours value, which have all been removed. This is why a bunch of arbitrary Styles now exist in filetype.rs.

Because the decision on which colourise-file-by-name code to use (currently just the standard extensions, or nothing if we aren’t colourising) is now determined by the Colours type (instead of being derived), it’s possible to get it wrong. And wrong it was! There was a bug where file names were colourised even though the rest of the --long output wasn’t, and this wasn’t caught by the xtests. It is now.
2017-08-26 20:43:47 +01:00
Benjamin Sago
e5e23e23c7 Use the file type colour trait methods 2017-08-26 15:29:39 +01:00
Benjamin Sago
4cab5b6b94 Don’t re-clone the git2-rs repo
Apparently trying to clone a repository onto an already-cloned clone just errors
2017-08-26 15:13:19 +01:00
Benjamin Sago
adfee28fb9 Merge branch 'ls-colors'
This branch went part of the way towards supporting LS_COLORS in exa. If the variable is set, exa will style certain file kinds, such as sockets or directories or links, according to the style that corresponds with the relevant two-letter code. It doesn’t work with globs for files or extensions yet. That’s coming soon. See #116
2017-08-26 15:03:03 +01:00
Benjamin Sago
276d18cf7c Give block and character devices different colours
There are now two device colours instead of one. Even though they’re both set to the same style for the default colour set, LS_COLORS allows the two to look different, so exa has to support it too.

It’s probably a good idea to support it anyway.
2017-08-26 14:30:33 +01:00
Benjamin Sago
44cee6b60c Add unnecessary hacker theme 2017-08-26 14:05:08 +01:00
Benjamin Sago
bd8e9d819c Add more ls_colors colours 2017-08-26 14:04:49 +01:00
Benjamin Sago
d517e9e12b Split FileTypes into types and kinds
This separates the colours to give to files with different filesystem types (directories, links, sockets) from files with different names or extensions (images, videos, archives).

I’m not 100% sure I’ve got the terms “kind” and “type” the right way round, but whatever.

This was done because colouring files based on their name is going to be handled differently and extensibly from colouring files based on what the filesystem thinks.
2017-08-25 17:50:22 +01:00
Benjamin Sago
fb3395883e Start actually parsing ls_colors
So far it only changes the colour of a directory, but it’s a start.
2017-08-25 17:43:36 +01:00
Benjamin Sago
59edc3b6ea These tests don’t need a type
Because the macros are now specialised to the type that’s being deduce-d, we don’t need to specify what the type is every time.
2017-08-25 09:07:28 +01:00
Benjamin Sago
974ddc0e63 Tests for turning colours on/off 2017-08-25 09:03:47 +01:00
Benjamin Sago
a581c871ed Split the colours tests in two
The TerminalColours tests used half the macros, and the Colours tests used the other half. Now only the macros used are actually in scope.
2017-08-25 08:53:35 +01:00
Benjamin Sago
4907565baf Move colour options to their own file 2017-08-24 23:38:26 +01:00
Benjamin Sago
30f3c6eb00 Strict mode and tests for colour scale 2017-08-23 11:45:29 +01:00
Benjamin Sago
8b0e483c0f More ls_colors parsing 2017-08-22 18:13:21 +01:00
Benjamin Sago
5e0003784d Start writing ls_colors parser 2017-08-20 22:59:22 +01:00
Benjamin Sago
b2201b72d5 A tree only needs the tree style
Now a tree only has access to the one style that’s used for colouring tree punctuation, rather than every style, 99% of which it wouldn’t ever use.
2017-08-20 21:39:52 +01:00
Benjamin Sago
9b24649d68 Reverse what knows how to render a cell
This commit adds many traits, all named ‘Colours’, to the code. Each one asks for a colour needed to render a cell: the number of links asks for colours for the number and the multi-link-file special case; the file size asks for number, unit, punctuation, and device ID colours, or it can do a scale with its own colours, however it wants.

This is a step towards LS_COLORS compatibility, believe it or not. If a text cell in a column doesn’t depend on Colours to render itself, then the source of the colours is open-ended.

I am glad to have not needed any test changes here.
2017-08-20 20:29:23 +01:00