diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b2ca4324..03be1199c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `DOMNode.tree` now displays simple DOM structure only https://github.com/Textualize/textual/pull/1778 - `App.install_screen` now returns None rather than AwaitMount https://github.com/Textualize/textual/pull/1778 - `DOMNode.children` is now a simple sequence, the NodesList is exposed as `DOMNode._nodes` https://github.com/Textualize/textual/pull/1778 +- `DataTable` cursor can now enter fixed columns https://github.com/Textualize/textual/pull/1799 ### Fixed diff --git a/examples/markdown.py b/examples/markdown.py index 59eaea9e3..140c89038 100644 --- a/examples/markdown.py +++ b/examples/markdown.py @@ -1,3 +1,5 @@ +from pathlib import Path + from textual.app import App, ComposeResult from textual.reactive import var from textual.widgets import Footer, MarkdownViewer @@ -10,7 +12,7 @@ class MarkdownApp(App): ("f", "forward", "Forward"), ] - path = var("demo.md") + path = var(Path(__file__).parent / "demo.md") @property def markdown_viewer(self) -> MarkdownViewer: diff --git a/src/textual/widgets/_data_table.py b/src/textual/widgets/_data_table.py index 181688d1f..3a3d5e100 100644 --- a/src/textual/widgets/_data_table.py +++ b/src/textual/widgets/_data_table.py @@ -877,7 +877,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True): """Clamp a coordinate such that it falls within the boundaries of the table.""" row, column = coordinate row = clamp(row, 0, self.row_count - 1) - column = clamp(column, self.fixed_columns, len(self.columns) - 1) + column = clamp(column, 0, len(self.columns) - 1) return Coordinate(row, column) def watch_cursor_type(self, old: str, new: str) -> None: @@ -1590,11 +1590,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True): that is occupied by fixed rows and columns respectively. Fixed rows and columns are rows and columns that do not participate in scrolling.""" top = self.header_height if self.show_header else 0 - top += sum( - self.rows[self._row_locations.get_key(row_index)].height - for row_index in range(self.fixed_rows) - if row_index in self.rows - ) + top += sum(row.height for row in self.ordered_rows[: self.fixed_rows]) left = sum( column.render_width for column in self.ordered_columns[: self.fixed_columns] ) diff --git a/src/textual/widgets/_markdown.py b/src/textual/widgets/_markdown.py index 1a00ef147..50812dd9d 100644 --- a/src/textual/widgets/_markdown.py +++ b/src/textual/widgets/_markdown.py @@ -1,6 +1,6 @@ from __future__ import annotations -from pathlib import Path +from pathlib import Path, PurePath from typing import Iterable from markdown_it import MarkdownIt @@ -37,7 +37,7 @@ class Navigator: return Path(".") return self.stack[self.index] - def go(self, path: str) -> Path: + def go(self, path: str | PurePath) -> Path: """Go to a new document. Args: @@ -749,7 +749,7 @@ class MarkdownViewer(Vertical, can_focus=True, can_focus_children=True): if self._markdown is not None: await self.document.update(self._markdown) - async def go(self, location: str) -> bool: + async def go(self, location: str | PurePath) -> bool: """Navigate to a new document path.""" return await self.document.load(self.navigator.go(location)) diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr index 0f74a7ff5..01de5b3e8 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr +++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr @@ -10015,134 +10015,134 @@ font-weight: 700; } - .terminal-3966238525-matrix { + .terminal-234487613-matrix { font-family: Fira Code, monospace; font-size: 20px; line-height: 24.4px; font-variant-east-asian: full-width; } - .terminal-3966238525-title { + .terminal-234487613-title { font-size: 18px; font-weight: bold; font-family: arial; } - .terminal-3966238525-r1 { fill: #dde6ed;font-weight: bold } - .terminal-3966238525-r2 { fill: #1e1201;font-weight: bold } - .terminal-3966238525-r3 { fill: #e1e1e1 } - .terminal-3966238525-r4 { fill: #c5c8c6 } - .terminal-3966238525-r5 { fill: #211505 } + .terminal-234487613-r1 { fill: #dde6ed;font-weight: bold } + .terminal-234487613-r2 { fill: #1e1201;font-weight: bold } + .terminal-234487613-r3 { fill: #e1e1e1 } + .terminal-234487613-r4 { fill: #c5c8c6 } + .terminal-234487613-r5 { fill: #211505 } - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - TableApp + TableApp - - - -  lane  swimmer               country        time   -  4     Joseph Schooling      Singapore      50.39  -  2     Michael Phelps        United States  51.14  -  5     Chad le Clos          South Africa   51.14  -  6     László Cseh           Hungary        51.14  -  3     Li Zhuhao             China          51.26  -  8     Mehdy Metella         France         51.58  -  7     Tom Shields           United States  51.73  -  1     Aleksandr Sadovnikov  Russia         51.84  - - - - - - - - - - - - - - + + + +  lane  swimmer               country        time   +  4     Joseph Schooling      Singapore      50.39  +  2     Michael Phelps        United States  51.14  +  5     Chad le Clos          South Africa   51.14  +  6     László Cseh           Hungary        51.14  +  3     Li Zhuhao             China          51.26  +  8     Mehdy Metella         France         51.58  +  7     Tom Shields           United States  51.73  +  1     Aleksandr Sadovnikov  Russia         51.84  + + + + + + + + + + + + + +