diff options
author | Rory Dudley | 2024-09-21 21:05:31 -0600 |
---|---|---|
committer | Rory Dudley | 2024-09-21 21:05:31 -0600 |
commit | da7aa5dbeb5e1c98c83fba10648b68962b614353 (patch) | |
tree | 4d665e35b474b6f2f59de310ec8083d5d40be64a /Cargo.lock | |
parent | 2852f93b714cf8ea83ba7d9aa5d6b138f58ee7e6 (diff) | |
download | dwarvish-da7aa5dbeb5e1c98c83fba10648b68962b614353.tar.gz |
Expand filepath autocomplete
This patch expands upon the last one, by providing a filepath
autcomplete routine, which works more similarly to that of zsh or bash.
It works for:
- Any paths containing the current directory (`.`)
- Any paths containing the parent directory (`..`)
- Any paths containing the root directory (`/`)
- Any paths that don't contain any explicit directory (defaults to the
current directory, i.e. `.`)
In order to achieve this, the pwd (present working directory) was broken
out from the autocomplete() function, and is now recomputed every time a
character is typed (in the getline() function). pwd always starts off as
the current directory, but may change based off of user input. If the
current directory cannot be read (likely due to a permissions issue),
dwvsh defaults to the user's home directory for now.
The filepath autocomplete also works for paths with mutliple directories
now (i.e. /etc/mail/xxx), will still allow you to autocomplete files and
directories beginning with 'xxx' inside the '/etc/mail' directory.
It is also possible to use the tilda character (`~`) with the filepath
autocomplete now (it denotes the user's home directory, for instance,
autocomplete works for '~/.config/').
Finally, some logic for Shift+Tab was added to autocomplete. It works
the same as Tab, except runs backwards through the files and directories
(as opposed to forwards).
Notes
Notes:
Some commented out code was left in this commit, just in case it may
have any use in future code (it was quite helpful in figuring out some
of the intricaces for proper filepath autocomplete). Speaking of which,
the autocomplete code should probably be documented (annotated) a bit
better. It is somewhat complex, so it is definitely worth writing some
unit tests for (ugh, dangling participle), as well.
Diffstat (limited to 'Cargo.lock')
0 files changed, 0 insertions, 0 deletions