Skip to content

Commit 5e1aa4d

Browse files
authored
Merge pull request #5534 from Textualize/bump-2.0.0
Bump 2.0.0
2 parents 993ff75 + b28d7b3 commit 5e1aa4d

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## Unreleased - 2025
8+
## 2.0.0 - 2024-02-16
99

1010
### Added
1111

@@ -44,13 +44,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4444

4545
### Changed
4646

47-
- OptionList no longer supports `Separator`, a separator may be specified with `None`
47+
- Breaking change: OptionList no longer supports `Separator`, a separator may be specified with `None`
4848
- Implemented smooth (pixel perfect) scrolling on supported terminals. Set `TEXTUAL_SMOOTH_SCROLL=0` to disable.
4949

5050
### Removed
5151

52-
- Removed `wrap` argument from OptionList (use CSS `text-wrap: nowrap; text-overflow: ellipses`)
53-
- Removed `tooltip` argument from OptionList. Use `tooltip` attribute or `with_tooltip(...)` method.
52+
- Breaking change: Removed `wrap` argument from OptionList (use CSS `text-wrap: nowrap; text-overflow: ellipses`)
53+
- Breaking change: Removed `tooltip` argument from OptionList. Use `tooltip` attribute or `with_tooltip(...)` method.
5454

5555
## [1.0.0] - 2024-12-12
5656

docs/blog/posts/smooth-scrolling.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,38 @@ It isn't granular enough to know where the pointer is *within* a cell.
3131

3232
Until recently terminal apps couldn't do any better.
3333
More granular mouse reporting is possible in the terminal; write the required escape sequence and mouse coordinates are reported in pixels rather than cells.
34+
3435
So why haven't TUIs been using this?
3536

36-
The problem is that we can't translate between pixel coordinates and cell coordinates without first knowing how many pixels are in a cell.
37-
And in order to know that, we need to know the width and height of the terminal in *pixels*.
38-
Unfortunately, that standard way to get the terminal size reports just cells.
37+
The problem is that pixel coordinates are pretty much useless in TUIs unless we have some way of translating between pixel and cell coordinates.
38+
Without that, we can never know which cell the user clicked on.
39+
40+
It's a trivial calculation, but we are missing a vital piece of information; the size of the terminal window in pixels.
41+
If we had that, we could divide the pixel dimensions by the cell dimensions to calculate the pixels per cell.
42+
Divide the pixel coordinates by *pixels per cell* and we have cell coordinates.
43+
44+
But the terminal reports its size in cells, and *not* pixels.
45+
So we can't use granular mouse coordinates.
46+
47+
!!! question "What did people use pixel coordinate for?"
48+
49+
This does make we wonder what pixel reporting was ever used for in terminals.
50+
Ping me on Discord if you know!
51+
3952

40-
At least they didn't before [this extension](https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83) which reports the size of the terminal in cell *and* pixel coordinates.
53+
At least we couldn't until [this recent extension](https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83) which reports the size of the terminal in cell *and* pixel coordinates.
4154
Once we have both the mouse coordinates in pixels and the dimensions of the terminal in pixels, we can implement much smoother scrolling.
4255

4356
Let's see how this looks.
4457

45-
On the right we have smooth scrolling enabled, on the left is the default non-smooth scrolling:
58+
On the left we have the default scrolling, on the right, Textual is using granular mouse coordinates.
4659

4760

4861
| Default scrolling | Smooth scrolling |
4962
| ---------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
5063
| ![A TUI Scrollbar](../images/smooth-scroll/no-smooth-scroll.gif) | ![A TUI Scrollbar with smooth scrolling](../images/smooth-scroll/smooth-scroll.gif) |
5164

5265
Notice how much smoother the motion of the table is, now that it tracks the mouse cursor more accurately.
53-
If you move the scrollbar quickly, you may not notice the difference.
54-
But if you move slowly like you are searching for something, it is a respectable quality of life improvement.
5566

5667
If you have one of the terminals which support this feature[^2], and at least [Textual](https://github.com/textualize/textual/) 2.0.0 you will be able to see this in action.
5768

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "textual"
3-
version = "1.0.0"
3+
version = "2.0.0"
44
homepage = "https://github.com/Textualize/textual"
55
repository = "https://github.com/Textualize/textual"
66
documentation = "https://textual.textualize.io/"

src/textual/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,9 @@ def _delay_update(self, delay: float = 0.05) -> None:
938938

939939
def end_batch() -> None:
940940
"""Re-enable updates, and refresh screen."""
941-
self.screen.refresh()
942941
self._end_batch()
942+
if not self._batch_count:
943+
self.screen.refresh()
943944

944945
self.set_timer(delay, end_batch, name="_delay_update")
945946

0 commit comments

Comments
 (0)