class Termisu::Cursor

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.cr

Constant Summary

HIDDEN = -1

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Creates a new cursor, hidden by default.


[View source]

Instance Method Detail

def clamp(max_x : Int32, max_y : Int32) #

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.


[View source]
def hidden? : Bool #

Returns true if cursor is hidden.


[View source]
def hide #

Hides the cursor (sets position to HIDDEN).


[View source]
def set_position(x : Int32, y : Int32) #

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.


[View source]
def show #

Shows the cursor at last known position (or 0,0 if never positioned).


[View source]
def visible? : Bool #

Returns true if cursor is visible.


[View source]
def x : Int32 #

[View source]
def x=(x : Int32) #

[View source]
def y : Int32 #

[View source]
def y=(y : Int32) #

[View source]