class
Termisu::Cursor
- Termisu::Cursor
- Reference
- Object
Overview
Cursor manages cursor position and visibility state.
The cursor tracks both position (x, y) and visibility. Hidden cursor is represented by (-1, -1) coordinates.
Example:
cursor = Termisu::Cursor.new
cursor.set_position(10, 5)
cursor.visible? # => true (set_position shows cursor)
cursor.hide
cursor.hidden? # => true
cursor.show # restores to last position
Defined in:
termisu/cursor.crConstant Summary
-
HIDDEN =
-1
Constructors
-
.new
Creates a new cursor, hidden by default.
Instance Method Summary
-
#clamp(max_x : Int32, max_y : Int32)
Clamps cursor position to be within the given bounds.
-
#hidden? : Bool
Returns true if cursor is hidden.
-
#hide
Hides the cursor (sets position to HIDDEN).
-
#set_position(x : Int32, y : Int32)
Sets cursor position and makes it visible.
-
#show
Shows the cursor at last known position (or 0,0 if never positioned).
-
#visible? : Bool
Returns true if cursor is visible.
- #x : Int32
- #x=(x : Int32)
- #y : Int32
- #y=(y : Int32)
Constructor Detail
Instance Method Detail
Clamps cursor position to be within the given bounds.
If cursor is hidden, it remains hidden but last_x/last_y are clamped. If cursor is visible and outside bounds, it's clamped to max valid position.
Sets cursor position and makes it visible.
Note: This method has a side effect of showing the cursor. Use hide() after if you want to position without showing.