mirror of https://github.com/Textualize/rich.git
added call syntax
This commit is contained in:
parent
e34eadb3a9
commit
6e6e85aa41
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [10.1.1] - Unreleased
|
||||
|
||||
### Added
|
||||
|
||||
- Added syntax for call, i.e. "Foo(bar)" will highlight Foo.pyth
|
||||
|
||||
## [10.1.0] - 2020-04-03
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -82,6 +82,9 @@ DEFAULT_STYLES: Dict[str, Style] = {
|
|||
"repr.none": Style(color="magenta", italic=True),
|
||||
"repr.url": Style(underline=True, color="bright_blue", italic=False, bold=False),
|
||||
"repr.uuid": Style(color="bright_yellow", bold=False),
|
||||
"repr.call": Style(color="bright_magenta"),
|
||||
"repr.path": Style(color="magenta"),
|
||||
"repr.filename": Style(color="bright_magenta"),
|
||||
"rule.line": Style(color="bright_green"),
|
||||
"rule.text": Style.null(),
|
||||
"prompt": Style.null(),
|
||||
|
@ -94,8 +97,6 @@ DEFAULT_STYLES: Dict[str, Style] = {
|
|||
"scope.key": Style(color="yellow", italic=True),
|
||||
"scope.key.special": Style(color="yellow", italic=True, dim=True),
|
||||
"scope.equals": Style(color="red"),
|
||||
"repr.path": Style(color="magenta"),
|
||||
"repr.filename": Style(color="bright_magenta"),
|
||||
"table.header": Style(bold=True),
|
||||
"table.footer": Style(bold=True),
|
||||
"table.cell": Style.null(),
|
||||
|
|
|
@ -83,12 +83,13 @@ class ReprHighlighter(RegexHighlighter):
|
|||
highlights = [
|
||||
r"(?P<tag_start>\<)(?P<tag_name>[\w\-\.\:]*)(?P<tag_contents>.*?)(?P<tag_end>\>)",
|
||||
r"(?P<attrib_name>[\w_]{1,50})=(?P<attrib_value>\"?[\w_]+\"?)?",
|
||||
r"(?P<brace>[\{\[\(\)\]\}])",
|
||||
_combine_regex(
|
||||
r"(?P<ipv4>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})",
|
||||
r"(?P<ipv6>([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})",
|
||||
r"(?P<eui64>(?:[0-9A-Fa-f]{1,2}-){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){3}[0-9A-Fa-f]{4})",
|
||||
r"(?P<eui48>(?:[0-9A-Fa-f]{1,2}-){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4})",
|
||||
r"(?P<brace>[\{\[\(\)\]\}])",
|
||||
r"(?P<call>[\w\.]*?)\(",
|
||||
r"(?P<bool_true>True)|(?P<bool_false>False)|(?P<none>None)",
|
||||
r"(?P<ellipsis>\.\.\.)",
|
||||
r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[\-\+]?\d+?)?\b|0x[0-9a-fA-F]*)",
|
||||
|
|
|
@ -83,11 +83,13 @@ def test_refresh_screen():
|
|||
layout = Layout()
|
||||
layout.split_row(Layout(name="foo"), Layout(name="bar"))
|
||||
console = Console(force_terminal=True, width=20, height=5)
|
||||
console.print(layout)
|
||||
with console.capture():
|
||||
console.print(layout)
|
||||
with console.screen():
|
||||
with console.capture() as capture:
|
||||
layout.refresh_screen(console, "foo")
|
||||
result = capture.get()
|
||||
print(repr(result))
|
||||
expected = "\x1b[1;1H\x1b[34m╭─\x1b[0m\x1b[34m \x1b[0m\x1b[32m'foo'\x1b[0m\x1b[34m─╮\x1b[0m\x1b[2;1H\x1b[34m│\x1b[0m Layout \x1b[34m│\x1b[0m\x1b[3;1H\x1b[34m│\x1b[0m \x1b[1m(\x1b[0m \x1b[34m│\x1b[0m\x1b[4;1H\x1b[34m│\x1b[0m \x1b[33mna\x1b[0m \x1b[34m│\x1b[0m\x1b[5;1H\x1b[34m╰────────╯\x1b[0m"
|
||||
expected = "\x1b[1;1H\x1b[34m╭─\x1b[0m\x1b[34m \x1b[0m\x1b[32m'foo'\x1b[0m\x1b[34m─╮\x1b[0m\x1b[2;1H\x1b[34m│\x1b[0m \x1b[95mLayout\x1b[0m \x1b[34m│\x1b[0m\x1b[3;1H\x1b[34m│\x1b[0m \x1b[1m(\x1b[0m \x1b[34m│\x1b[0m\x1b[4;1H\x1b[34m│\x1b[0m \x1b[33mna\x1b[0m \x1b[34m│\x1b[0m\x1b[5;1H\x1b[34m╰────────╯\x1b[0m"
|
||||
|
||||
assert result == expected
|
||||
|
|
Loading…
Reference in New Issue