Skip to content

Commit a98c00a

Browse files
authored
Merge branch 'main' into fix-datatable-change-max-height-back-to-100-percent
2 parents e3e39ab + a2ba9eb commit a98c00a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+5824
-573
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Fixed
1111

12+
- Fix priority bindings not appearing in footer when key clashes with focused widget https://github.com/Textualize/textual/pull/4342
13+
- Reverted auto-width change https://github.com/Textualize/textual/pull/4369
14+
15+
### Changed
16+
1217
- Exceptions inside `Widget.compose` or workers weren't bubbling up in tests https://github.com/Textualize/textual/issues/4282
1318
- Fixed `DataTable` scrolling issues by changing `max-height` back to 100% https://github.com/Textualize/textual/issues/4286
19+
- Fixed `Button` not rendering correctly with console markup https://github.com/Textualize/textual/issues/4328
1420

1521
### Added
1622

1723
- Added `Document.start` and `end` location properties for convenience https://github.com/Textualize/textual/pull/4267
24+
- Added support for JavaScript, Golang, Rust, Bash, Java and Kotlin to `TextArea` https://github.com/Textualize/textual/pull/4350
25+
- Added `inline` parameter to `run` and `run_async` to run app inline (under the prompt). https://github.com/Textualize/textual/pull/4343
26+
- Added `mouse` parameter to disable mouse support https://github.com/Textualize/textual/pull/4343
1827

1928
## [0.54.0] - 2024-03-26
2029

docs/examples/how-to/inline01.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from datetime import datetime
2+
3+
from textual.app import App, ComposeResult
4+
from textual.widgets import Digits
5+
6+
7+
class ClockApp(App):
8+
CSS = """
9+
Screen {
10+
align: center middle;
11+
}
12+
#clock {
13+
width: auto;
14+
}
15+
"""
16+
17+
def compose(self) -> ComposeResult:
18+
yield Digits("", id="clock")
19+
20+
def on_ready(self) -> None:
21+
self.update_clock()
22+
self.set_interval(1, self.update_clock)
23+
24+
def update_clock(self) -> None:
25+
clock = datetime.now().time()
26+
self.query_one(Digits).update(f"{clock:%T}")
27+
28+
29+
if __name__ == "__main__":
30+
app = ClockApp()
31+
app.run(inline=True) # (1)!

docs/examples/how-to/inline02.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from datetime import datetime
2+
3+
from textual.app import App, ComposeResult
4+
from textual.widgets import Digits
5+
6+
7+
class ClockApp(App):
8+
CSS = """
9+
Screen {
10+
align: center middle;
11+
&:inline {
12+
border: none;
13+
height: 50vh;
14+
Digits {
15+
color: $success;
16+
}
17+
}
18+
}
19+
#clock {
20+
width: auto;
21+
}
22+
"""
23+
24+
def compose(self) -> ComposeResult:
25+
yield Digits("", id="clock")
26+
27+
def on_ready(self) -> None:
28+
self.update_clock()
29+
self.set_interval(1, self.update_clock)
30+
31+
def update_clock(self) -> None:
32+
clock = datetime.now().time()
33+
self.query_one(Digits).update(f"{clock:%T}")
34+
35+
36+
if __name__ == "__main__":
37+
app = ClockApp()
38+
app.run(inline=True)

docs/examples/widgets/clock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ def update_clock(self) -> None:
2828

2929
if __name__ == "__main__":
3030
app = ClockApp()
31-
app.run()
31+
app.run(inline=True)

docs/guide/CSS.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,13 @@ The `background: green` is only applied to the Button underneath the mouse curso
321321

322322
Here are some other pseudo classes:
323323

324+
- `:blur` Matches widgets which *do not* have input focus.
325+
- `:dark` Matches widgets in dark mode (where `App.dark == True`).
324326
- `:disabled` Matches widgets which are in a disabled state.
325327
- `:enabled` Matches widgets which are in an enabled state.
326-
- `:focus` Matches widgets which have input focus.
327-
- `:blur` Matches widgets which *do not* have input focus.
328328
- `:focus-within` Matches widgets with a focused child widget.
329-
- `:dark` Matches widgets in dark mode (where `App.dark == True`).
329+
- `:focus` Matches widgets which have input focus.
330+
- `:inline` Matches widgets when the app is running in inline mode.
330331
- `:light` Matches widgets in dark mode (where `App.dark == False`).
331332

332333
## Combinators

docs/guide/animation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Animation
22

3-
Ths chapter discusses how to use Textual's animation system to create visual effects such as movement, blending, and fading.
3+
This chapter discusses how to use Textual's animation system to create visual effects such as movement, blending, and fading.
44

55

66
## Animating styles

docs/guide/app.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ If you hit ++ctrl+c++ Textual will exit application mode and return you to the c
3838

3939
A side effect of application mode is that you may no longer be able to select and copy text in the usual way. Terminals typically offer a way to bypass this limit with a key modifier. On iTerm you can select text if you hold the ++option++ key. See the documentation for your terminal software for how to select text in application mode.
4040

41+
#### Run inline
42+
43+
!!! tip "Added in version 0.45.0"
44+
45+
You can also run apps in _inline_ mode, which will cause the app to appear beneath the prompt (and won't go in to application mode).
46+
Inline apps are useful for tools that integrate closely with the typical workflow of a terminal.
47+
48+
To run an app in inline mode set the `inline` parameter to `True` when you call [App.run()][textual.app.App.run]. See [Style Inline Apps](../how-to/style-inline-apps.md) for how to apply additional styles to inline apps.
4149

4250
## Events
4351

docs/how-to/style-inline-apps.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Style Inline Apps
2+
3+
Version 0.55.0 of Textual added support for running apps *inline* (below the prompt).
4+
Running an inline app is as simple as adding `inline=True` to [`run()`][textual.app.App.run].
5+
6+
<iframe width="100%" style="aspect-ratio:757/804;" src="https://www.youtube.com/embed/dxAf3vDr4aQ" title="Textual Inline mode" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
7+
8+
Your apps will typically run inline without modification, but you may want to make some tweaks for inline mode, which you can do with a little CSS.
9+
This How-To will explain how.
10+
11+
Let's look at an inline app.
12+
The following app displays the the current time (and keeps it up to date).
13+
14+
```python hl_lines="31"
15+
--8<-- "docs/examples/how-to/inline01.py"
16+
```
17+
18+
1. The `inline=True` runs the app inline.
19+
20+
With Textual's default settings, this clock will be displayed in 5 lines; 3 for the digits and 2 for a top and bottom border.
21+
22+
You can change the height or the border with CSS and the `:inline` pseudo-selector, which only matches rules in inline mode.
23+
Let's update this app to remove the default border, and increase the height:
24+
25+
```python hl_lines="11-17"
26+
--8<-- "docs/examples/how-to/inline02.py"
27+
```
28+
29+
The highlighted CSS targets online inline mode.
30+
By setting the `height` rule on Screen we can define how many lines the app should consume when it runs.
31+
Setting `border: none` removes the default border when running in inline mode.
32+
33+
We've also added a rule to change the color of the clock when running inline.
34+
35+
## Summary
36+
37+
Most apps will not require modification to run inline, but if you want to tweak the height and border you can write CSS that targets inline mode with the `:inline` pseudo-selector.

docs/widgets/selection_list.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ my_selection_list: SelectionList[int] = SelectionList(*selections)
3030
## Examples
3131

3232
A selection list is designed to be built up of single-line prompts (which
33-
can be [Rich renderables](../guide/widgets.md#rich-renderables)) and an
34-
associated unique value.
33+
can be [Rich `Text`](https://rich.readthedocs.io/en/stable/text.html)) and
34+
an associated unique value.
3535

3636
### Selections as tuples
3737

examples/calculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,4 @@ def pressed_equals(self) -> None:
168168

169169

170170
if __name__ == "__main__":
171-
CalculatorApp().run()
171+
CalculatorApp().run(inline=True)

0 commit comments

Comments
 (0)