mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Move DataTable cursor with page up/down, home, end (#2228)
* Add pageup and pagedown actions to DataTable, with no impls * Pagedown moves DataTable cursor now * Account for header height in pagedown action * Page Up support in the DataTable * Fix and off-by-1, ensure page up/down works on col cursor * Add placeholder scroll home/end action handlers to datatable * Add scroll home and scroll end * Hide hover cursor when home or end is used * Ensure home and end work correctly with all curosrs * Testing home/end/pagedown/pageup cursor movement in DataTable * Docstrings for new datatable actions * Fix a broken unit test for the DataTable
This commit is contained in:
@@ -167,10 +167,36 @@ async def test_datatable_message_emission():
|
||||
async def test_empty_table_interactions():
|
||||
app = DataTableApp()
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.press("enter", "up", "down", "left", "right")
|
||||
await pilot.press(
|
||||
"enter", "up", "down", "left", "right", "home", "end", "pagedown", "pageup"
|
||||
)
|
||||
assert app.message_names == []
|
||||
|
||||
|
||||
async def test_cursor_movement_with_home_pagedown_etc():
|
||||
app = DataTableApp()
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
table = app.query_one(DataTable)
|
||||
table.add_columns("A", "B")
|
||||
table.add_rows(ROWS)
|
||||
await pilot.press("right", "pagedown")
|
||||
await pilot.pause()
|
||||
assert table.cursor_coordinate == Coordinate(2, 1)
|
||||
|
||||
await pilot.press("pageup")
|
||||
await pilot.pause()
|
||||
assert table.cursor_coordinate == Coordinate(0, 1)
|
||||
|
||||
await pilot.press("end")
|
||||
await pilot.pause()
|
||||
assert table.cursor_coordinate == Coordinate(2, 1)
|
||||
|
||||
await pilot.press("home")
|
||||
await pilot.pause()
|
||||
assert table.cursor_coordinate == Coordinate(0, 1)
|
||||
|
||||
|
||||
async def test_add_rows():
|
||||
app = DataTableApp()
|
||||
async with app.run_test():
|
||||
|
||||
Reference in New Issue
Block a user