Skip to content

Commit b4d87c7

Browse files
authored
Merge branch 'main' into input-align
2 parents 5299477 + 96be1ea commit b4d87c7

File tree

8 files changed

+199
-99
lines changed

8 files changed

+199
-99
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Fixed
1111

1212
- Fixed issue where scrollbars weren't being unmounted
13+
- Fixed fr units for horizontal and vertical layouts https://github.com/Textualize/textual/pull/1067
14+
- Fixed `textual run` breaking sys.argv https://github.com/Textualize/textual/issues/1064
15+
- Fixed footer not updating styles when toggling dark mode
16+
- Fixed how the app title in a `Header` is centred https://github.com/Textualize/textual/issues/1060
17+
- Fixed the swapping of button variants https://github.com/Textualize/textual/issues/1048
18+
- Fixed reserved characters in screenshots https://github.com/Textualize/textual/issues/993
1319

1420
### Changed
1521

1622
- DOMQuery now raises InvalidQueryFormat in response to invalid query strings, rather than cryptic CSS error
1723
- Dropped quit_after, screenshot, and screenshot_title from App.run, which can all be done via auto_pilot
1824
- Widgets are now closed in reversed DOM order
1925
- Input widget justify hardcoded to left to prevent text-align interference
26+
- Changed `textual run` so that it patches `argv` in more situations
2027

2128
### Added
2229

@@ -27,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2734
- Added Widget._get_virtual_dom to get scrollbars
2835
- Added size parameter to run and run_async
2936
- Added always_update to reactive
37+
- Returned an awaitable from push_screen, switch_screen, and install_screen https://github.com/Textualize/textual/pull/1061
3038

3139
## [0.2.1] - 2022-10-23
3240

sandbox/will/fr.py

Lines changed: 0 additions & 96 deletions
This file was deleted.

src/textual/widgets/_footer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ def make_key_text(self) -> Text:
119119
text.append_text(key_text)
120120
return text
121121

122+
def _on_styles_updated(self) -> None:
123+
self._key_text = None
124+
self.refresh()
125+
122126
def post_render(self, renderable):
123127
return renderable
124128

src/textual/widgets/_text_log.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(
4646
) -> None:
4747
super().__init__(name=name, id=id, classes=classes)
4848
self.max_lines = max_lines
49+
self._start_line: int = 0
4950
self.lines: list[list[Segment]] = []
5051
self._line_cache: LRUCache[tuple[int, int, int, int], list[Segment]]
5152
self._line_cache = LRUCache(1024)
@@ -95,16 +96,20 @@ def write(self, content: RenderableType | object) -> None:
9596
)
9697
self.lines.extend(lines)
9798

98-
if self.max_lines is not None:
99+
if self.max_lines is not None and len(self.lines) > self.max_lines:
100+
self._start_line += len(self.lines) - self.max_lines
101+
self.refresh()
99102
self.lines = self.lines[-self.max_lines :]
100103
self.virtual_size = Size(self.max_width, len(self.lines))
101104
self.scroll_end(animate=False, speed=100)
102105

103106
def clear(self) -> None:
104107
"""Clear the text log."""
105108
del self.lines[:]
109+
self._start_line = 0
106110
self.max_width = 0
107111
self.virtual_size = Size(self.max_width, len(self.lines))
112+
self.refresh()
108113

109114
def render_line(self, y: int) -> list[Segment]:
110115
scroll_x, scroll_y = self.scroll_offset
@@ -129,7 +134,7 @@ def _render_line(self, y: int, scroll_x: int, width: int) -> list[Segment]:
129134
if y >= len(self.lines):
130135
return [Segment(" " * width, self.rich_style)]
131136

132-
key = (y, scroll_x, width, self.max_width)
137+
key = (y + self._start_line, scroll_x, width, self.max_width)
133138
if key in self._line_cache:
134139
return self._line_cache[key]
135140

tests/snapshot_tests/__snapshots__/test_snapshots.ambr

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6165,6 +6165,161 @@
61656165

61666166
'''
61676167
# ---
6168+
# name: test_textlog_max_lines
6169+
'''
6170+
<svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">
6171+
<!-- Generated with Rich https://www.textualize.io -->
6172+
<style>
6173+
6174+
@font-face {
6175+
font-family: "Fira Code";
6176+
src: local("FiraCode-Regular"),
6177+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
6178+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
6179+
font-style: normal;
6180+
font-weight: 400;
6181+
}
6182+
@font-face {
6183+
font-family: "Fira Code";
6184+
src: local("FiraCode-Bold"),
6185+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
6186+
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
6187+
font-style: bold;
6188+
font-weight: 700;
6189+
}
6190+
6191+
.terminal-2820474000-matrix {
6192+
font-family: Fira Code, monospace;
6193+
font-size: 20px;
6194+
line-height: 24.4px;
6195+
font-variant-east-asian: full-width;
6196+
}
6197+
6198+
.terminal-2820474000-title {
6199+
font-size: 18px;
6200+
font-weight: bold;
6201+
font-family: arial;
6202+
}
6203+
6204+
.terminal-2820474000-r1 { fill: #e1e1e1 }
6205+
.terminal-2820474000-r2 { fill: #c5c8c6 }
6206+
</style>
6207+
6208+
<defs>
6209+
<clipPath id="terminal-2820474000-clip-terminal">
6210+
<rect x="0" y="0" width="975.0" height="584.5999999999999" />
6211+
</clipPath>
6212+
<clipPath id="terminal-2820474000-line-0">
6213+
<rect x="0" y="1.5" width="976" height="24.65"/>
6214+
</clipPath>
6215+
<clipPath id="terminal-2820474000-line-1">
6216+
<rect x="0" y="25.9" width="976" height="24.65"/>
6217+
</clipPath>
6218+
<clipPath id="terminal-2820474000-line-2">
6219+
<rect x="0" y="50.3" width="976" height="24.65"/>
6220+
</clipPath>
6221+
<clipPath id="terminal-2820474000-line-3">
6222+
<rect x="0" y="74.7" width="976" height="24.65"/>
6223+
</clipPath>
6224+
<clipPath id="terminal-2820474000-line-4">
6225+
<rect x="0" y="99.1" width="976" height="24.65"/>
6226+
</clipPath>
6227+
<clipPath id="terminal-2820474000-line-5">
6228+
<rect x="0" y="123.5" width="976" height="24.65"/>
6229+
</clipPath>
6230+
<clipPath id="terminal-2820474000-line-6">
6231+
<rect x="0" y="147.9" width="976" height="24.65"/>
6232+
</clipPath>
6233+
<clipPath id="terminal-2820474000-line-7">
6234+
<rect x="0" y="172.3" width="976" height="24.65"/>
6235+
</clipPath>
6236+
<clipPath id="terminal-2820474000-line-8">
6237+
<rect x="0" y="196.7" width="976" height="24.65"/>
6238+
</clipPath>
6239+
<clipPath id="terminal-2820474000-line-9">
6240+
<rect x="0" y="221.1" width="976" height="24.65"/>
6241+
</clipPath>
6242+
<clipPath id="terminal-2820474000-line-10">
6243+
<rect x="0" y="245.5" width="976" height="24.65"/>
6244+
</clipPath>
6245+
<clipPath id="terminal-2820474000-line-11">
6246+
<rect x="0" y="269.9" width="976" height="24.65"/>
6247+
</clipPath>
6248+
<clipPath id="terminal-2820474000-line-12">
6249+
<rect x="0" y="294.3" width="976" height="24.65"/>
6250+
</clipPath>
6251+
<clipPath id="terminal-2820474000-line-13">
6252+
<rect x="0" y="318.7" width="976" height="24.65"/>
6253+
</clipPath>
6254+
<clipPath id="terminal-2820474000-line-14">
6255+
<rect x="0" y="343.1" width="976" height="24.65"/>
6256+
</clipPath>
6257+
<clipPath id="terminal-2820474000-line-15">
6258+
<rect x="0" y="367.5" width="976" height="24.65"/>
6259+
</clipPath>
6260+
<clipPath id="terminal-2820474000-line-16">
6261+
<rect x="0" y="391.9" width="976" height="24.65"/>
6262+
</clipPath>
6263+
<clipPath id="terminal-2820474000-line-17">
6264+
<rect x="0" y="416.3" width="976" height="24.65"/>
6265+
</clipPath>
6266+
<clipPath id="terminal-2820474000-line-18">
6267+
<rect x="0" y="440.7" width="976" height="24.65"/>
6268+
</clipPath>
6269+
<clipPath id="terminal-2820474000-line-19">
6270+
<rect x="0" y="465.1" width="976" height="24.65"/>
6271+
</clipPath>
6272+
<clipPath id="terminal-2820474000-line-20">
6273+
<rect x="0" y="489.5" width="976" height="24.65"/>
6274+
</clipPath>
6275+
<clipPath id="terminal-2820474000-line-21">
6276+
<rect x="0" y="513.9" width="976" height="24.65"/>
6277+
</clipPath>
6278+
<clipPath id="terminal-2820474000-line-22">
6279+
<rect x="0" y="538.3" width="976" height="24.65"/>
6280+
</clipPath>
6281+
</defs>
6282+
6283+
<rect fill="#292929" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="1" y="1" width="992" height="633.6" rx="8"/><text class="terminal-2820474000-title" fill="#c5c8c6" text-anchor="middle" x="496" y="27">TextLogLines</text>
6284+
<g transform="translate(26,22)">
6285+
<circle cx="0" cy="0" r="7" fill="#ff5f57"/>
6286+
<circle cx="22" cy="0" r="7" fill="#febc2e"/>
6287+
<circle cx="44" cy="0" r="7" fill="#28c840"/>
6288+
</g>
6289+
6290+
<g transform="translate(9, 41)" clip-path="url(#terminal-2820474000-clip-terminal)">
6291+
<rect fill="#1e1e1e" x="0" y="1.5" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="1.5" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="25.9" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="25.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="50.3" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="50.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="74.7" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="74.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="99.1" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="99.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="123.5" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="123.5" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="147.9" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="147.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="172.3" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="172.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="196.7" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="196.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="221.1" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="221.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="245.5" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="245.5" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="269.9" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="269.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="294.3" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="294.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="318.7" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="318.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="343.1" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="343.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="367.5" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="367.5" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="391.9" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="391.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="416.3" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="416.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="440.7" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="440.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="465.1" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="465.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="489.5" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="489.5" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="513.9" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="513.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="538.3" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="538.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="562.7" width="951.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#14191f" x="951.6" y="562.7" width="24.4" height="24.65" shape-rendering="crispEdges"/>
6292+
<g class="terminal-2820474000-matrix">
6293+
<text class="terminal-2820474000-r1" x="0" y="20" textLength="951.6" clip-path="url(#terminal-2820474000-line-0)">Key&#160;press&#160;#3&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text class="terminal-2820474000-r2" x="976" y="20" textLength="12.2" clip-path="url(#terminal-2820474000-line-0)">
6294+
</text><text class="terminal-2820474000-r1" x="0" y="44.4" textLength="951.6" clip-path="url(#terminal-2820474000-line-1)">Key&#160;press&#160;#4&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text class="terminal-2820474000-r2" x="976" y="44.4" textLength="12.2" clip-path="url(#terminal-2820474000-line-1)">
6295+
</text><text class="terminal-2820474000-r1" x="0" y="68.8" textLength="951.6" clip-path="url(#terminal-2820474000-line-2)">Key&#160;press&#160;#5&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text class="terminal-2820474000-r2" x="976" y="68.8" textLength="12.2" clip-path="url(#terminal-2820474000-line-2)">
6296+
</text><text class="terminal-2820474000-r2" x="976" y="93.2" textLength="12.2" clip-path="url(#terminal-2820474000-line-3)">
6297+
</text><text class="terminal-2820474000-r2" x="976" y="117.6" textLength="12.2" clip-path="url(#terminal-2820474000-line-4)">
6298+
</text><text class="terminal-2820474000-r2" x="976" y="142" textLength="12.2" clip-path="url(#terminal-2820474000-line-5)">
6299+
</text><text class="terminal-2820474000-r2" x="976" y="166.4" textLength="12.2" clip-path="url(#terminal-2820474000-line-6)">
6300+
</text><text class="terminal-2820474000-r2" x="976" y="190.8" textLength="12.2" clip-path="url(#terminal-2820474000-line-7)">
6301+
</text><text class="terminal-2820474000-r2" x="976" y="215.2" textLength="12.2" clip-path="url(#terminal-2820474000-line-8)">
6302+
</text><text class="terminal-2820474000-r2" x="976" y="239.6" textLength="12.2" clip-path="url(#terminal-2820474000-line-9)">
6303+
</text><text class="terminal-2820474000-r2" x="976" y="264" textLength="12.2" clip-path="url(#terminal-2820474000-line-10)">
6304+
</text><text class="terminal-2820474000-r2" x="976" y="288.4" textLength="12.2" clip-path="url(#terminal-2820474000-line-11)">
6305+
</text><text class="terminal-2820474000-r2" x="976" y="312.8" textLength="12.2" clip-path="url(#terminal-2820474000-line-12)">
6306+
</text><text class="terminal-2820474000-r2" x="976" y="337.2" textLength="12.2" clip-path="url(#terminal-2820474000-line-13)">
6307+
</text><text class="terminal-2820474000-r2" x="976" y="361.6" textLength="12.2" clip-path="url(#terminal-2820474000-line-14)">
6308+
</text><text class="terminal-2820474000-r2" x="976" y="386" textLength="12.2" clip-path="url(#terminal-2820474000-line-15)">
6309+
</text><text class="terminal-2820474000-r2" x="976" y="410.4" textLength="12.2" clip-path="url(#terminal-2820474000-line-16)">
6310+
</text><text class="terminal-2820474000-r2" x="976" y="434.8" textLength="12.2" clip-path="url(#terminal-2820474000-line-17)">
6311+
</text><text class="terminal-2820474000-r2" x="976" y="459.2" textLength="12.2" clip-path="url(#terminal-2820474000-line-18)">
6312+
</text><text class="terminal-2820474000-r2" x="976" y="483.6" textLength="12.2" clip-path="url(#terminal-2820474000-line-19)">
6313+
</text><text class="terminal-2820474000-r2" x="976" y="508" textLength="12.2" clip-path="url(#terminal-2820474000-line-20)">
6314+
</text><text class="terminal-2820474000-r2" x="976" y="532.4" textLength="12.2" clip-path="url(#terminal-2820474000-line-21)">
6315+
</text><text class="terminal-2820474000-r2" x="976" y="556.8" textLength="12.2" clip-path="url(#terminal-2820474000-line-22)">
6316+
</text>
6317+
</g>
6318+
</g>
6319+
</svg>
6320+
6321+
'''
6322+
# ---
61686323
# name: test_vertical_layout
61696324
'''
61706325
<svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">

tests/snapshot_tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def compare(
5252
Args:
5353
app_path (str): The path of the app.
5454
press (Iterable[str]): Key presses to run before taking screenshot. "_" is a short pause.
55-
terminal_size (tuple[int, int]): A pair of integers (WIDTH, SIZE), representing terminal size.
55+
terminal_size (tuple[int, int]): A pair of integers (WIDTH, HEIGHT), representing terminal size.
5656
5757
Returns:
5858
bool: True if the screenshot matches the snapshot.

0 commit comments

Comments
 (0)