Skip to content

Commit 2b41ff1

Browse files
committed
added constant
1 parent 71e6f54 commit 2b41ff1

File tree

6 files changed

+18
-2
lines changed

6 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4545
### Changed
4646

4747
- OptionList no longer supports `Separator`, a separator may be specified with `None`
48+
- Implemented smooth (pixel perfect) scrolling on supported terminals. Set `TEXTUAL_SMOOTH_SCROLL=0` to disable.
4849

4950
### Removed
5051

src/textual/_xterm_parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,12 @@ def send_escape() -> None:
287287
setting_parameter = int(mode_report_match["setting_parameter"])
288288
if mode_id == "2026" and setting_parameter > 0:
289289
on_token(messages.TerminalSupportsSynchronizedOutput())
290-
elif mode_id == "2048" and not IS_ITERM:
290+
elif (
291+
mode_id == "2048"
292+
and constants.SMOOTH_SCROLL
293+
and not IS_ITERM
294+
):
295+
# TODO: iTerm is buggy in one or more of the protocols required here
291296
in_band_event = messages.TerminalSupportInBandWindowResize.from_setting_parameter(
292297
setting_parameter
293298
)

src/textual/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,7 @@ def _get_textual_animations() -> AnimationLevel:
157157
"""Textual theme to make default. More than one theme may be specified in a comma separated list.
158158
Textual will use the first theme that exists.
159159
"""
160+
161+
SMOOTH_SCROLL: Final[bool] = _get_environ_int("TEXTUAL_SMOOTH_SCROLL", 1) == 1
162+
"""Should smooth scrolling be enabled? set `TEXTUAL_SMOOTH_SCROLL=0` to disable smooth scrolling.
163+
"""

src/textual/drivers/linux_driver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def _enable_mouse_support(self) -> None:
136136
# extensions.
137137

138138
def _enable_mouse_pixels(self) -> None:
139+
"""Enable mouse reporting as pixels."""
139140
if not self._mouse:
140141
return
141142
self.write("\x1b[?1016h")

src/textual/events.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,26 +399,32 @@ def __init__(
399399

400400
@property
401401
def x(self) -> int:
402+
"""The relative X coordinate."""
402403
return int(self._x)
403404

404405
@property
405406
def y(self) -> int:
407+
"""The relative Y coordinate."""
406408
return int(self._y)
407409

408410
@property
409411
def delta_x(self) -> int:
412+
"""Change in `x` since last message."""
410413
return int(self._delta_x)
411414

412415
@property
413416
def delta_y(self) -> int:
417+
"""Change in `y` since the last message."""
414418
return int(self._delta_y)
415419

416420
@property
417421
def screen_x(self) -> int:
422+
"""X coordinate relative to top left of screen."""
418423
return int(self._screen_x)
419424

420425
@property
421426
def screen_y(self) -> int:
427+
"""Y coordinate relative to top left of screen."""
422428
return int(self._screen_y)
423429

424430
@classmethod

src/textual/scrollbar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ async def _on_mouse_move(self, event: events.MouseMove) -> None:
379379
(event._screen_x - self.grabbed.x)
380380
* (virtual_size / self.window_size)
381381
)
382-
print(event)
383382
self.post_message(ScrollTo(x=x, y=y))
384383
event.stop()
385384

0 commit comments

Comments
 (0)