Raxol.Terminal.Cursor.Movement (Raxol v0.3.0)

View Source

Handles cursor movement and positioning for the terminal emulator.

This module provides functions for moving the cursor in various directions, handling relative and absolute positioning, and managing cursor boundaries.

Summary

Functions

Moves the cursor down by the specified number of lines.

Moves the cursor to the home position (0, 0).

Moves the cursor left by the specified number of columns.

Moves the cursor right by the specified number of columns.

Moves the cursor to the specified column.

Moves the cursor to the specified line.

Moves the cursor to the end of the line.

Moves the cursor to the beginning of the line.

Moves the cursor to the next tab stop.

Moves the cursor to the specified position.

Moves the cursor to the previous tab stop.

Moves the cursor up by the specified number of lines.

Functions

move_down(cursor, count \\ 1)

Moves the cursor down by the specified number of lines.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Movement.move_down(cursor, 2)
iex> cursor.position
{0, 2}

move_home(cursor)

Moves the cursor to the home position (0, 0).

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Manager.move_to(cursor, 10, 5)
iex> cursor = Movement.move_home(cursor)
iex> cursor.position
{0, 0}

move_left(cursor, count \\ 1)

Moves the cursor left by the specified number of columns.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Manager.move_to(cursor, 5, 0)
iex> cursor = Movement.move_left(cursor, 2)
iex> cursor.position
{3, 0}

move_right(cursor, count \\ 1)

Moves the cursor right by the specified number of columns.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Movement.move_right(cursor, 2)
iex> cursor.position
{2, 0}

move_to_column(cursor, column)

Moves the cursor to the specified column.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Movement.move_to_column(cursor, 10)
iex> cursor.position
{10, 0}

move_to_line(cursor, line)

Moves the cursor to the specified line.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Movement.move_to_line(cursor, 5)
iex> cursor.position
{0, 5}

move_to_line_end(cursor, line_width)

Moves the cursor to the end of the line.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Movement.move_to_line_end(cursor, 80)
iex> cursor.position
{79, 0}

move_to_line_start(cursor)

Moves the cursor to the beginning of the line.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Manager.move_to(cursor, 10, 0)
iex> cursor = Movement.move_to_line_start(cursor)
iex> cursor.position
{0, 0}

move_to_next_tab(cursor, tab_width)

Moves the cursor to the next tab stop.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Movement.move_to_next_tab(cursor, 8)
iex> cursor.position
{8, 0}

move_to_position(cursor, column, line)

Moves the cursor to the specified position.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Movement.move_to_position(cursor, 10, 5)
iex> cursor.position
{10, 5}

move_to_prev_tab(cursor, tab_width)

Moves the cursor to the previous tab stop.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Manager.move_to(cursor, 10, 0)
iex> cursor = Movement.move_to_prev_tab(cursor, 8)
iex> cursor.position
{8, 0}

move_up(cursor, count \\ 1)

Moves the cursor up by the specified number of lines.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Movement}
iex> cursor = Manager.new()
iex> cursor = Movement.move_up(cursor, 2)
iex> cursor.position
{0, 0}  # Already at top, no change