@@ -464,13 +464,18 @@ def _position_to_cell(self, position: int) -> int:
464464 def _cursor_offset (self ) -> int :
465465 """The cell offset of the cursor."""
466466 offset = self ._position_to_cell (self .cursor_position )
467- if self ._cursor_at_end :
467+ if self .cursor_at_end :
468468 offset += 1
469469 return offset
470470
471471 @property
472- def _cursor_at_end (self ) -> bool :
473- """Flag to indicate if the cursor is at the end"""
472+ def cursor_at_start (self ) -> bool :
473+ """Flag to indicate if the cursor is at the start."""
474+ return self .cursor_position == 0
475+
476+ @property
477+ def cursor_at_end (self ) -> bool :
478+ """Flag to indicate if the cursor is at the end."""
474479 return self .cursor_position == len (self .value )
475480
476481 def check_consume_key (self , key : str , character : str | None ) -> bool :
@@ -513,7 +518,7 @@ def _watch_cursor_blink(self, blink: bool) -> None:
513518
514519 @property
515520 def cursor_screen_offset (self ) -> Offset :
516- """The offset of the cursor of this input in screen-space. (x, y)/(column, row)"""
521+ """The offset of the cursor of this input in screen-space. (x, y)/(column, row). """
517522 x , y , _width , _height = self .content_region
518523 scroll_x , _ = self .scroll_offset
519524 return Offset (x + self ._cursor_offset - scroll_x , y )
@@ -640,7 +645,7 @@ def render_line(self, y: int) -> Strip:
640645 if self ._cursor_visible :
641646 cursor_style = self .get_component_rich_style ("input--cursor" )
642647 cursor = self .cursor_position
643- if not show_suggestion and self ._cursor_at_end :
648+ if not show_suggestion and self .cursor_at_end :
644649 result .pad_right (1 )
645650 result .stylize (cursor_style , cursor , cursor + 1 )
646651
@@ -848,7 +853,7 @@ def action_cursor_right(self, select: bool = False) -> None:
848853 if select :
849854 self .selection = Selection (start , end + 1 )
850855 else :
851- if self ._cursor_at_end and self ._suggestion :
856+ if self .cursor_at_end and self ._suggestion :
852857 self .value = self ._suggestion
853858 self .cursor_position = len (self .value )
854859 else :
0 commit comments