Commit Graph

100 Commits

Author SHA1 Message Date
ridiculousfish
822b53c67a Don't color a whole string invalid because of an unclosed quote
When syntax highlighting a quoted string, if the string is not closed,
only show the opening quote as an error, not the whole string.
2019-07-24 12:43:47 -07:00
ridiculousfish
c0053ceef5 highlighter_t to return color array directly
Saves some copying and allocations.
2019-07-24 12:42:18 -07:00
Dawid Dziurla
0b3bb0e7c1 Underline every valid entered path (#5872)
* src/highlight: Underline every valid entered path

* update CHANGELOG

* fix highlight test
2019-05-19 10:03:56 +02:00
Fabian Homborg
c2970f9618 Reformat all files
This runs build_tools/style.fish, which runs clang-format on C++, fish_indent on fish and (new) black on python.

If anything is wrong with the formatting, we should fix the tools, but automated formatting is worth it.
2019-05-05 12:09:25 +02:00
ridiculousfish
bffacd2fbf Thread a parser into expansion
Expansion may perform command substitution, which needs to know the parser
to use.
2019-05-04 19:30:00 -07:00
ridiculousfish
496529b20a Remove EXPAND prefix from expand_flags and lowercase them 2019-04-25 11:34:49 -07:00
ridiculousfish
d8ab6290e8 Switch expand_flags_t to enum_set 2019-04-25 11:23:03 -07:00
ridiculousfish
dcaac58f45 Rename expand_error_t to expand_result_t and make it class enum
Also lowercase it all.
2019-04-25 10:47:28 -07:00
ridiculousfish
a173c079d5 expand_abbreviation to always accept an environment_t
Now that snapshotting is fixed, we don't need to get the principal
environment stack any more.
2019-04-16 22:45:58 -07:00
Aaron Gyes
477b2e8d7c std::vector<wcstring> is wcstring_list_t 2019-03-14 11:17:26 -07:00
Aaron Gyes
d5ac239f68 This commit changes wchar.h includes to cwchar, and uses std::
for everything it provides.
2019-03-12 15:09:36 -07:00
ridiculousfish
717ac9a8d5 Switch highlight_spec_t to a struct
Rather than a janky bitmask, use a real struct with real fields.
2019-03-03 18:04:22 -08:00
ridiculousfish
d165d1df27 Remove highlight_modifier_sloppy_background
It's no longer ever set
2019-03-03 17:56:08 -08:00
Dan Zimmerman
50448e4319 Enable configuring more pager colors
Originally I sought out to configure the foreground color of the
selected text in the pager. After reading a thread on a github issue I
was inpired to do more: now you can conifgure any part of the pager when
selected, and when a row is secondary. More specifically this commit adds the
ability to specify a pager row's:

- Prefix
- Completion text
- Description
- Background

when said row is selected or secondary.
2019-01-26 15:43:23 -08:00
Dan Zimmerman
f73b4fb746 Connect highlight env vars to their specs better
I was hacking on this part of the codebase and found this comment
mentioning to keep two things in sync, and felt like we could do better.
2019-01-26 15:43:23 -08:00
ridiculousfish
2d3e8ec0a9 Correct highlighting of abbreviations
Abbreviation highlighting cannot use the snapshot environment because we do
not know up-front which variables to capture. Will revisit this later.
2019-01-11 20:43:52 -08:00
ridiculousfish
77884bc21a Instantize env_get
This removes env_get(). All fish variable accesses must go through an
environment_t.
2019-01-10 20:08:06 -08:00
ridiculousfish
6f52e6bb1c Instantize contents of exec.cpp and others 2019-01-10 20:07:47 -08:00
ridiculousfish
038f3cca6d Remove the abbreviation cache
Read abbreviations directly from the environment.
2019-01-10 20:07:41 -08:00
ridiculousfish
9f62a53077 Instantize env_get inside highlighting 2019-01-10 20:07:35 -08:00
ridiculousfish
abcd24f716 Eliminate env_snapshot_t::current()
These uses are better served by passing in the real environment stack,
now that we have environment_t as a shared base class.
2019-01-10 20:07:14 -08:00
ridiculousfish
03b92ffe00 Clean up path_get_cdpath and path_can_be_implicit_cd 2019-01-10 20:07:10 -08:00
ridiculousfish
421fbdd52a Instantize env_get_pwd_slash
This requires threading environment_t through many places, such as completions
and history. We introduce null_environment_t for when the environment isn't
important.
2019-01-10 20:01:28 -08:00
ridiculousfish
391af6af0c Introduce class environment_t
This will be used as a base class for variable snapshots and variable stacks.
2019-01-10 20:29:10 -08:00
Mahmoud Al-Qudsi
803619b19b Convert some old-school int booleans to bool 2018-12-31 00:46:31 -06:00
ridiculousfish
a8ce7bad7b Always pass in the working directory in path_get_cdpath
If the user is in a directory which has been unlinked, it is possible
for the path .. to not exist, relative to the working directory.
Always pass in the working directory (potentially virtual) to
path_get_cdpath; this ensures we check absolute paths and are immune
from issues if the working directory has been unlinked.

Also introduce a new function path_normalize_for_cd which normalizes the
"join point" of a path and a working directory. This allows us to 'cd' out of
a non-existent directory, but not cd into such a directory.

Fixes #5341
2018-11-18 14:36:42 -08:00
Fabian Homborg
f64a87a374 path: Make working_directory wcstring
Kinda weird that that one was a wchar_t*
2018-10-23 19:10:14 +02:00
ridiculousfish
5fa4e0d2ee Highlight %self as an operator 2018-10-19 16:17:30 -07:00
ridiculousfish
d73c487d60 Restore %self to refer to the fish pid
This brings back the %self argument. Like the original %self it only expands
if the argument is literally %self.
2018-10-19 16:17:25 -07:00
ridiculousfish
6147e9ee0d path_get_cdpath to accept string instead of env_var_t
Unclear why it ever needed an env_var_t. wcstring is sufficient and much
simpler.
2018-09-30 18:13:14 -04:00
ridiculousfish
7bd26f9ff0 Teach syntax highlighting about variables in commands 2018-09-01 12:00:56 -07:00
ridiculousfish
de2b0d1ae8 Remove some #if 0 code 2018-08-26 02:36:28 -07:00
ridiculousfish
4194b4efee Add a feature_test() function
This is a convenience over fish_features().test()
2018-05-06 11:20:15 -07:00
ridiculousfish
762c31be87 Feature flag support for ? wildcard
This partially reverts 6e56637cf0 and #4520
by bringing back the ? wildcard, guarded by the qmark-noglob feature flag.
2018-05-06 11:20:15 -07:00
ridiculousfish
6e56637cf0 Remove support for the ? wildcard
Fixes #4520
2018-03-31 16:54:50 -07:00
Mahmoud Al-Qudsi
65a03c86cb Rename BRACKET in reference to { to BRACE instead per #3802
This `{` is a curly brace. This `[` is a square bracket.
2018-03-10 13:16:53 -06:00
Mahmoud Al-Qudsi
e45e2bf20e Initial removal of '%' syntax for process/job expansion 2018-03-09 03:36:10 -06:00
ridiculousfish
c7f16439bf Add support for ! as an analog to 'not'
! and not are effectively interchangeable now.
Mark them both as operators for syntax highlighting.
2018-03-05 14:04:49 -08:00
ridiculousfish
f83742d579 Highlight && and || as operators
This also switches 'and' and 'or' to operators as well.
2018-03-05 13:51:05 -08:00
ridiculousfish
357d3b8c6d Rework 'and' and 'or' to be "job decorators"
This promotes "and" and "or" from a type of statement to "job
decorators," as a possible prefix on a job. The point is to rationalize
how they interact with && and ||.

In the new world 'and' and 'or' apply to a entire job conjunction, i.e.
they have "lower precedence." Example:

if [ $age -ge 0 ] && [ $age -le 18 ]
   or [ $age -ge 75 ] && [ $age -le 100 ]
   echo "Child or senior"
end
2018-03-05 13:41:36 -08:00
ridiculousfish
99fb7bb6aa Refactor how redirections are represented by the tokenizer
Prior to this fix, each redirection type was a separate token_type.
Unify these under a single type TOK_REDIRECT and break the redirection
type out into a new sub-type redirection_type_t.
2018-02-23 15:19:58 -08:00
ridiculousfish
da84b38430 Constructors to accept more parameters by value
In cases where the constructor needs to take ownership of parameters,
pass them by value and use std::move.
2018-02-18 19:12:45 -08:00
ridiculousfish
f025269195 env_var_t to forget its name
Store properties associated with the name via flags instead
2018-01-30 12:36:50 -08:00
ridiculousfish
094e853a20 Migrate tnode_t into new header tnode.h 2018-01-20 12:15:28 -08:00
ridiculousfish
242512f0df Migrate argument_list_is_root out of parse_node_tree_t 2018-01-20 11:45:43 -08:00
ridiculousfish
fa0f552fe9 Convert populate_block_process to tnode_t 2018-01-20 11:45:43 -08:00
ridiculousfish
6f4db9f8ad Add type safety to tnode_t::try_get_child
Detect when no options in an alternation type match the requested type,
and ensure such cases do not compile.
2018-01-20 11:31:40 -08:00
ridiculousfish
f0f56a6910 Teach decoration_for_plain_statement about tnode, rename it get_decoration 2018-01-20 11:31:40 -08:00
ridiculousfish
84dcb24682 Namespace alias grammar to 'g' in highlight.cpp 2018-01-20 11:31:40 -08:00
ridiculousfish
539e9bf970 Continued adoption of tnode_t in highlight.cpp 2018-01-20 11:31:40 -08:00