Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._vendor.rich.syntax Namespace Reference

Data Structures

class  _SyntaxHighlightRange
 
class  ANSISyntaxTheme
 
class  PygmentsSyntaxTheme
 
class  Syntax
 
class  SyntaxTheme
 

Functions

Optional[int_get_code_index_for_syntax_position (Sequence[int] newlines_offsets, SyntaxPosition position)
 

Variables

 TokenType = Tuple[str, ...]
 
str WINDOWS = "Windows"
 
str DEFAULT_THEME = "monokai"
 
dict ANSI_LIGHT
 
dict ANSI_DARK
 
dict RICH_SYNTAX_THEMES = {"ansi_light": ANSI_LIGHT, "ansi_dark": ANSI_DARK}
 
int NUMBERS_COLUMN_DEFAULT_PADDING = 2
 
 SyntaxPosition = Tuple[int, int]
 
 parser
 
 metavar
 
 help
 
 dest
 
 action
 
 default
 
 type
 
 int
 
 args = parser.parse_args()
 
 console = Console(force_terminal=args.force_color, width=args.width)
 
 code = sys.stdin.read()
 
 syntax
 
 soft_wrap
 

Function Documentation

◆ _get_code_index_for_syntax_position()

Optional[int] _get_code_index_for_syntax_position ( Sequence[int newlines_offsets,
SyntaxPosition   position 
)
protected
Returns the index of the code string for the given positions.

Args:
    newlines_offsets (Sequence[int]): The offset of each newline character found in the code snippet.
    position (SyntaxPosition): The position to search for.

Returns:
    Optional[int]: The index of the code string for this position, or `None`
        if the given position's line number is out of range (if it's the column that is out of range
        we silently clamp its value so that it reaches the end of the line)

Definition at line 804 of file syntax.py.

806) -> Optional[int]:
807 """
808 Returns the index of the code string for the given positions.
809
810 Args:
811 newlines_offsets (Sequence[int]): The offset of each newline character found in the code snippet.
812 position (SyntaxPosition): The position to search for.
813
814 Returns:
815 Optional[int]: The index of the code string for this position, or `None`
816 if the given position's line number is out of range (if it's the column that is out of range
817 we silently clamp its value so that it reaches the end of the line)
818 """
819 lines_count = len(newlines_offsets)
820
821 line_number, column_index = position
822 if line_number > lines_count or len(newlines_offsets) < (line_number + 1):
823 return None # `line_number` is out of range
824 line_index = line_number - 1
825 line_length = newlines_offsets[line_index + 1] - newlines_offsets[line_index] - 1
826 # If `column_index` is out of range: let's silently clamp it:
827 column_index = min(line_length, column_index)
828 return newlines_offsets[line_index] + column_index
829
830
for i

References i.

Referenced by Syntax._apply_stylized_ranges().

Here is the caller graph for this function:

Variable Documentation

◆ action

action

Definition at line 847 of file syntax.py.

◆ ANSI_DARK

dict ANSI_DARK
Initial value:
1= {
2 Token: Style(),
3 Whitespace: Style(color="bright_black"),
4 Comment: Style(dim=True),
5 Comment.Preproc: Style(color="bright_cyan"),
6 Keyword: Style(color="bright_blue"),
7 Keyword.Type: Style(color="bright_cyan"),
8 Operator.Word: Style(color="bright_magenta"),
9 Name.Builtin: Style(color="bright_cyan"),
10 Name.Function: Style(color="bright_green"),
11 Name.Namespace: Style(color="bright_cyan", underline=True),
12 Name.Class: Style(color="bright_green", underline=True),
13 Name.Exception: Style(color="bright_cyan"),
14 Name.Decorator: Style(color="bright_magenta", bold=True),
15 Name.Variable: Style(color="bright_red"),
16 Name.Constant: Style(color="bright_red"),
17 Name.Attribute: Style(color="bright_cyan"),
18 Name.Tag: Style(color="bright_blue"),
19 String: Style(color="yellow"),
20 Number: Style(color="bright_blue"),
21 Generic.Deleted: Style(color="bright_red"),
22 Generic.Inserted: Style(color="bright_green"),
23 Generic.Heading: Style(bold=True),
24 Generic.Subheading: Style(color="bright_magenta", bold=True),
25 Generic.Prompt: Style(bold=True),
26 Generic.Error: Style(color="bright_red"),
27 Error: Style(color="red", underline=True),
28}

Definition at line 90 of file syntax.py.

◆ ANSI_LIGHT

dict ANSI_LIGHT
Initial value:
1= {
2 Token: Style(),
3 Whitespace: Style(color="white"),
4 Comment: Style(dim=True),
5 Comment.Preproc: Style(color="cyan"),
6 Keyword: Style(color="blue"),
7 Keyword.Type: Style(color="cyan"),
8 Operator.Word: Style(color="magenta"),
9 Name.Builtin: Style(color="cyan"),
10 Name.Function: Style(color="green"),
11 Name.Namespace: Style(color="cyan", underline=True),
12 Name.Class: Style(color="green", underline=True),
13 Name.Exception: Style(color="cyan"),
14 Name.Decorator: Style(color="magenta", bold=True),
15 Name.Variable: Style(color="red"),
16 Name.Constant: Style(color="red"),
17 Name.Attribute: Style(color="cyan"),
18 Name.Tag: Style(color="bright_blue"),
19 String: Style(color="yellow"),
20 Number: Style(color="blue"),
21 Generic.Deleted: Style(color="bright_red"),
22 Generic.Inserted: Style(color="green"),
23 Generic.Heading: Style(bold=True),
24 Generic.Subheading: Style(color="magenta", bold=True),
25 Generic.Prompt: Style(bold=True),
26 Generic.Error: Style(color="bright_red"),
27 Error: Style(color="red", underline=True),
28}

Definition at line 61 of file syntax.py.

◆ args

args = parser.parse_args()

Definition at line 917 of file syntax.py.

◆ code

code = sys.stdin.read()

Definition at line 924 of file syntax.py.

◆ console

console = Console(force_terminal=args.force_color, width=args.width)

Definition at line 921 of file syntax.py.

◆ default

default

Definition at line 848 of file syntax.py.

◆ DEFAULT_THEME

str DEFAULT_THEME = "monokai"

Definition at line 56 of file syntax.py.

◆ dest

dest

Definition at line 846 of file syntax.py.

◆ help

help

Definition at line 841 of file syntax.py.

◆ int

int

Definition at line 908 of file syntax.py.

◆ metavar

metavar

Definition at line 840 of file syntax.py.

◆ NUMBERS_COLUMN_DEFAULT_PADDING

int NUMBERS_COLUMN_DEFAULT_PADDING = 2

Definition at line 120 of file syntax.py.

◆ parser

parser
Initial value:
2 description="Render syntax to the console with Rich"
3 )

Definition at line 835 of file syntax.py.

◆ RICH_SYNTAX_THEMES

dict RICH_SYNTAX_THEMES = {"ansi_light": ANSI_LIGHT, "ansi_dark": ANSI_DARK}

Definition at line 119 of file syntax.py.

◆ soft_wrap

soft_wrap

Definition at line 948 of file syntax.py.

◆ syntax

syntax
Initial value:
1= Syntax(
2 code=code,
3 lexer=args.lexer_name,
4 line_numbers=args.line_numbers,
5 word_wrap=args.word_wrap,
6 theme=args.theme,
7 background_color=args.background_color,
8 indent_guides=args.indent_guides,
9 padding=args.padding,
10 highlight_lines={args.highlight_line},
11 )

Definition at line 925 of file syntax.py.

◆ SyntaxPosition

SyntaxPosition = Tuple[int, int]

Definition at line 212 of file syntax.py.

◆ TokenType

TokenType = Tuple[str, ...]

Definition at line 53 of file syntax.py.

◆ type

type

Definition at line 869 of file syntax.py.

◆ WINDOWS

str WINDOWS = "Windows"

Definition at line 55 of file syntax.py.