mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-19 14:51:13 -03:00
highlight: Add colorize_shell wrapper
Since we don't reuse the vector anyway, this allows us to keep the highlighting on the C++-side.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "output.h"
|
||||
#include "parse_constants.h"
|
||||
#include "parse_util.h"
|
||||
#include "parser.h"
|
||||
#include "path.h"
|
||||
#include "redirection.h"
|
||||
#include "tokenizer.h"
|
||||
@@ -1372,3 +1373,9 @@ void highlight_shell(const wcstring &buff, std::vector<highlight_spec_t> &color,
|
||||
highlighter_t highlighter(buff, cursor, ctx, working_directory, io_ok);
|
||||
color = highlighter.highlight();
|
||||
}
|
||||
|
||||
wcstring colorize_shell(const wcstring &text, parser_t &parser) {
|
||||
std::vector<highlight_spec_t> colors;
|
||||
highlight_shell(text, colors, parser.context());
|
||||
return str2wcstring(colorize(text, colors, parser.vars()));
|
||||
}
|
||||
|
||||
@@ -111,6 +111,11 @@ void highlight_shell(const wcstring &buffstr, std::vector<highlight_spec_t> &col
|
||||
const operation_context_t &ctx, bool io_ok = false,
|
||||
maybe_t<size_t> cursor = {});
|
||||
|
||||
|
||||
class parser_t;
|
||||
/// Wrapper around colorize(highlight_shell)
|
||||
wcstring colorize_shell(const wcstring &text, parser_t &parser);
|
||||
|
||||
/// highlight_color_resolver_t resolves highlight specs (like "a command") to actual RGB colors.
|
||||
/// It maintains a cache with no invalidation mechanism. The lifetime of these should typically be
|
||||
/// one screen redraw.
|
||||
|
||||
Reference in New Issue
Block a user