9#ifndef LLDB_CORE_HIGHLIGHTER_H
10#define LLDB_CORE_HIGHLIGHTER_H
18#include "llvm/ADT/StringRef.h"
35 ColorStyle(llvm::StringRef prefix, llvm::StringRef suffix) {
47 void Set(llvm::StringRef prefix, llvm::StringRef suffix);
99 virtual llvm::StringRef
GetName()
const = 0;
116 std::optional<size_t> cursor_pos,
117 llvm::StringRef previous_lines,
Stream &s)
const = 0;
121 std::optional<size_t> cursor_pos,
122 llvm::StringRef previous_lines =
"")
const;
129 llvm::StringRef
GetName()
const override {
return "none"; }
132 std::optional<size_t> cursor_pos,
133 llvm::StringRef previous_lines,
Stream &s)
const override;
151 llvm::StringRef path)
const;
A default highlighter that only highlights the user cursor, but doesn't do any other highlighting.
llvm::StringRef GetName() const override
Returns a human readable name for the selected highlighter.
void Highlight(const HighlightStyle &options, llvm::StringRef line, std::optional< size_t > cursor_pos, llvm::StringRef previous_lines, Stream &s) const override
Highlights the given line.
A pair of strings that should be placed around a certain token.
ColorStyle(llvm::StringRef prefix, llvm::StringRef suffix)
void Set(llvm::StringRef prefix, llvm::StringRef suffix)
Sets the prefix and suffix strings.
void Apply(Stream &s, llvm::StringRef value) const
Applies this style to the given value.
Manages the available highlighters.
const Highlighter & getHighlighterFor(lldb::LanguageType language_type, llvm::StringRef path) const
Queries all known highlighter for one that can highlight some source code.
const Highlighter & getDefaultHighlighter() const
DefaultHighlighter m_default
Annotates source code with color attributes.
Highlighter(const Highlighter &)=delete
virtual void Highlight(const HighlightStyle &options, llvm::StringRef line, std::optional< size_t > cursor_pos, llvm::StringRef previous_lines, Stream &s) const =0
Highlights the given line.
const Highlighter & operator=(const Highlighter &)=delete
virtual llvm::StringRef GetName() const =0
Returns a human readable name for the selected highlighter.
virtual ~Highlighter()=default
A stream class that can stream formatted output to a file.
A class that represents a running process on the host machine.
LanguageType
Programming language type.
Represents style that the highlighter should apply to the given source code.
ColorStyle square_brackets
Matches '[' or ']'.
ColorStyle comment
Matches any comments in the language.
ColorStyle semicolons
Matches any semicolon: ';'.
static HighlightStyle MakeVimStyle()
Returns a HighlightStyle that is based on vim's default highlight style.
ColorStyle braces
Matches '{' or '}'.
ColorStyle scalar_literal
Matches scalar value literals like '42' or '0.1'.
ColorStyle comma
Matches commas: ','.
ColorStyle pp_directive
Matches directives to a preprocessor (if the language has any).
ColorStyle operators
Matches operators like '+', '-', '', '&', '='.
ColorStyle string_literal
Matches any string or character literals in the language: "foo" or 'f'.
ColorStyle keyword
Matches all reserved keywords in the language.
ColorStyle parentheses
Matches '(' or ')'.
ColorStyle selected
The style for the token which is below the cursor of the user.
ColorStyle identifier
Matches identifiers to variable or functions.
ColorStyle colon
Matches one colon: ':'.