Skip to content

Commit

Permalink
Tweaks to DataTable docs.
Browse files Browse the repository at this point in the history
Related PRs: #2479.
  • Loading branch information
rodrigogiraoserrao committed May 4, 2023
1 parent 04083a7 commit 8a801fe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/widgets/data_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ If you want to change the table based solely on coordinates, you can use the [co

### Cursors

The coordinate of the cursor is exposed via the `cursor_coordinate` reactive attribute.
The coordinate of the cursor is exposed via the [`cursor_coordinate`][textual.widgets.DataTable.cursor_coordinate] reactive attribute.
Three types of cursors are supported: `cell`, `row`, and `column`.
Change the cursor type by assigning to the `cursor_type` reactive attribute.
Change the cursor type by assigning to the [`cursor_type`][textual.widgets.DataTable.cursor_type] reactive attribute.

=== "Column Cursor"

Expand Down
2 changes: 2 additions & 0 deletions src/textual/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
from ._types import CallbackType, MessageTarget, WatchCallbackType
from .actions import ActionParseResult
from .css.styles import RenderStyles
from .widgets._data_table import CursorType

__all__ = [
"ActionParseResult",
"Animatable",
"CallbackType",
"CursorType",
"EasingFunction",
"MessageTarget",
"NoActiveAppError",
Expand Down
5 changes: 4 additions & 1 deletion src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
LineCacheKey: TypeAlias = "tuple[int, int, int, int, Coordinate, Coordinate, Style, CursorType, bool, int, PseudoClasses]"
RowCacheKey: TypeAlias = "tuple[RowKey, int, Style, Coordinate, Coordinate, CursorType, bool, bool, int, PseudoClasses]"
CursorType = Literal["cell", "row", "column", "none"]
"""The legal types of cursors for [`DataTable.cursor_type`][DataTable.cursor_type]."""
CellType = TypeVar("CellType")

CELL_X_PADDING = 2
Expand Down Expand Up @@ -304,14 +305,16 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
zebra_stripes = Reactive(False)
header_height = Reactive(1)
show_cursor = Reactive(True)
cursor_type = Reactive("cell")
cursor_type: Reactive[CursorType] = Reactive[CursorType]("cell")
"""The type of the cursor of the `DataTable`."""

cursor_coordinate: Reactive[Coordinate] = Reactive(
Coordinate(0, 0), repaint=False, always_update=True
)
hover_coordinate: Reactive[Coordinate] = Reactive(
Coordinate(0, 0), repaint=False, always_update=True
)
"""The coordinate of the `DataTable` that is being hovered."""

class CellHighlighted(Message, bubble=True):
"""Posted when the cursor moves to highlight a new cell.
Expand Down

0 comments on commit 8a801fe

Please sign in to comment.