Raxol.Terminal.Cursor.Manager (Raxol v0.4.0)

View Source

Manages cursor state and operations.

Summary

Types

t()

Cursor struct representing position, style, state, and saved values.

Functions

Adds the current cursor state to history.

Clamps a position to the screen bounds.

Gets the cursor's current position.

Gets the cursor's current state.

Gets the cursor's current style.

Gets whether the cursor is visible.

Moves the cursor down by the specified number of lines, clamped to the screen bounds.

Moves the cursor left by the specified number of columns, clamped to the screen bounds.

Moves the cursor right by the specified number of columns, clamped to the screen bounds.

Moves the cursor to a new position (no clamping, arity 2).

Moves the cursor to a new position (no clamping, arity 3 for compatibility).

Moves the cursor to a new position (clamped to the screen bounds).

Moves the cursor to a new position, clamped to the screen bounds.

Moves the cursor to the specified column, clamped to the screen bounds.

Moves the cursor to the beginning of the line.

Moves the cursor to the next tab stop.

Moves the cursor to the previous tab stop.

Moves the cursor up by the specified number of lines, clamped to the screen bounds.

Creates a new cursor with default values.

Restores the cursor state from history.

Restores the cursor's saved position (if any).

Restores the cursor's saved state.

Saves the cursor's current position (only position, not style or state).

Saves the cursor's current state.

Sets a custom cursor shape and dimensions.

Sets the cursor's state.

Sets the cursor's style.

Sets the cursor visibility.

Updates the cursor's blink state and returns the updated cursor and visibility.

Types

position()

@type position() :: {non_neg_integer(), non_neg_integer()}

state()

@type state() :: :visible | :hidden | :blinking

style()

@type style() :: :block | :underline | :bar | :custom

t()

@type t() :: %Raxol.Terminal.Cursor.Manager{
  blink_rate: integer(),
  custom_dimensions: any() | nil,
  custom_shape: any() | nil,
  history: list(),
  history_index: integer(),
  history_limit: integer(),
  position: position(),
  saved_position: position() | nil,
  saved_state: state() | nil,
  saved_style: style() | nil,
  shape: {integer(), integer()},
  state: state(),
  style: style()
}

Cursor struct representing position, style, state, and saved values.

Functions

add_to_history(cursor)

Adds the current cursor state to history.

clamp_position(arg, width, height)

@spec clamp_position({integer(), integer()}, integer(), integer()) ::
  {integer(), integer()}

Clamps a position to the screen bounds.

get_position(cursor)

Gets the cursor's current position.

get_state(cursor)

Gets the cursor's current state.

get_style(cursor)

Gets the cursor's current style.

is_visible?(cursor)

Gets whether the cursor is visible.

move_down(cursor, lines, width, height)

Moves the cursor down by the specified number of lines, clamped to the screen bounds.

move_left(cursor, columns, width, height)

Moves the cursor left by the specified number of columns, clamped to the screen bounds.

move_right(cursor, columns, width, height)

Moves the cursor right by the specified number of columns, clamped to the screen bounds.

move_to(cursor, arg)

Moves the cursor to a new position (no clamping, arity 2).

move_to(cursor, x, y)

Moves the cursor to a new position (no clamping, arity 3 for compatibility).

move_to(cursor, arg, width, height)

Moves the cursor to a new position (clamped to the screen bounds).

move_to(cursor, x, y, width, height)

Moves the cursor to a new position, clamped to the screen bounds.

move_to_column(cursor, column, width, height)

Moves the cursor to the specified column, clamped to the screen bounds.

move_to_line_start(cursor)

Moves the cursor to the beginning of the line.

move_to_next_tab(cursor, tab_stops, width)

Moves the cursor to the next tab stop.

move_to_previous_tab(cursor, tab_stops)

Moves the cursor to the previous tab stop.

move_up(cursor, lines, width, height)

Moves the cursor up by the specified number of lines, clamped to the screen bounds.

new(opts \\ [])

Creates a new cursor with default values.

restore_from_history(cursor)

Restores the cursor state from history.

restore_position(cursor)

Restores the cursor's saved position (if any).

restore_state(cursor)

Restores the cursor's saved state.

save_position(cursor)

Saves the cursor's current position (only position, not style or state).

save_state(cursor)

Saves the cursor's current state.

set_custom_shape(cursor, shape, dimensions)

Sets a custom cursor shape and dimensions.

set_state(cursor, state)

Sets the cursor's state.

set_style(cursor, style)

Sets the cursor's style.

set_visibility(cursor, visible)

Sets the cursor visibility.

update_blink(cursor)

Updates the cursor's blink state and returns the updated cursor and visibility.