C# Класс PowerArgs.Cli.SimpleSyntaxHighlighter

A utility that makes it easy to perform common types of syntax highlighting based on keywords, regular expressions, etc.
Показать файл Открыть проект

Private Properties

Свойство Тип Описание
EnsureHighlighted bool

Открытые методы

Метод Описание
AddConditionalKeyword ( string keyword, Func conditionEval, ConsoleColor fg = null, ConsoleColor bg = null, System.StringComparison comparison = StringComparison.InvariantCulture ) : void

Registers a keyword with the highlighter that should only be highlighted if some condition is true

AddKeyword ( string keyword, ConsoleColor fg = null, ConsoleColor bg = null, System.StringComparison comparison = StringComparison.InvariantCulture ) : void

Registers a keyword with the highlighter.

AddRegex ( string regex, ConsoleColor fg = null, ConsoleColor bg = null ) : void

Registers a regular expression with the highlighter. Tokens that exactly match the given regex will be highlighted.

AddTokenHighlighter ( ITokenHighlighter highlighter ) : void

Registers a custom token highlighter

SetNumericHighlight ( ConsoleColor fg = null, ConsoleColor bg = null ) : void

Lets you control how numeric values should be highlighted

SetQuotedStringLiteralHighlight ( ConsoleColor fg = null, ConsoleColor bg = null ) : void

Lets you control how quoted string literals should be highlighted

SimpleSyntaxHighlighter ( ) : System

Creates a new SimpleSyntaxHighlighter

TryHighlight ( RichCommandLineContext readerContext ) : bool

The implementation of ISyntaxHighlighter that uses the configuration you've created to perform syntax highlighting.

Приватные методы

Метод Описание
EnsureHighlighted ( Token token, RichCommandLineContext context, ConsoleColor fg, ConsoleColor bg ) : bool

Описание методов

AddConditionalKeyword() публичный Метод

Registers a keyword with the highlighter that should only be highlighted if some condition is true
public AddConditionalKeyword ( string keyword, Func conditionEval, ConsoleColor fg = null, ConsoleColor bg = null, System.StringComparison comparison = StringComparison.InvariantCulture ) : void
keyword string The keyword that will conditionally be highlighted when found on the command line
conditionEval Func the conditional evaluation function
fg ConsoleColor The foreground highlight color
bg ConsoleColor The background highlight color
comparison System.StringComparison Determines how strings are compared.
Результат void

AddKeyword() публичный Метод

Registers a keyword with the highlighter.
public AddKeyword ( string keyword, ConsoleColor fg = null, ConsoleColor bg = null, System.StringComparison comparison = StringComparison.InvariantCulture ) : void
keyword string The keyword that will be highlighted when found on the command line
fg ConsoleColor The foreground highlight color
bg ConsoleColor The background highlight color
comparison System.StringComparison Determines how strings are compared.
Результат void

AddRegex() публичный Метод

Registers a regular expression with the highlighter. Tokens that exactly match the given regex will be highlighted.
public AddRegex ( string regex, ConsoleColor fg = null, ConsoleColor bg = null ) : void
regex string the regular expression pattern to search for
fg ConsoleColor The foreground highlight color
bg ConsoleColor The background highlight color
Результат void

AddTokenHighlighter() публичный Метод

Registers a custom token highlighter
public AddTokenHighlighter ( ITokenHighlighter highlighter ) : void
highlighter ITokenHighlighter the custom highlighter
Результат void

SetNumericHighlight() публичный Метод

Lets you control how numeric values should be highlighted
public SetNumericHighlight ( ConsoleColor fg = null, ConsoleColor bg = null ) : void
fg ConsoleColor The foreground highlight color
bg ConsoleColor The background highlight color
Результат void

SetQuotedStringLiteralHighlight() публичный Метод

Lets you control how quoted string literals should be highlighted
public SetQuotedStringLiteralHighlight ( ConsoleColor fg = null, ConsoleColor bg = null ) : void
fg ConsoleColor The foreground highlight color
bg ConsoleColor The background highlight color
Результат void

SimpleSyntaxHighlighter() публичный Метод

Creates a new SimpleSyntaxHighlighter
public SimpleSyntaxHighlighter ( ) : System
Результат System

TryHighlight() публичный Метод

The implementation of ISyntaxHighlighter that uses the configuration you've created to perform syntax highlighting.
public TryHighlight ( RichCommandLineContext readerContext ) : bool
readerContext RichCommandLineContext Context that is used internally
Результат bool