Raxol.Terminal.Cursor.Style behaviour (Raxol v2.0.1)

View Source

Handles cursor style and visibility control for the terminal emulator.

This module provides functions for changing cursor appearance, controlling visibility, and managing cursor blinking.

Summary

Functions

Makes the cursor blink.

Gets the current cursor blink mode.

Gets the current cursor state.

Gets the current cursor style.

Hides the cursor.

Sets the cursor style to bar.

Sets the cursor blink rate in milliseconds.

Sets the cursor style to block.

Sets a custom cursor shape.

Sets the cursor style to underline.

Makes the cursor visible.

Toggles the cursor blinking state.

Toggles the cursor visibility.

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

Callbacks

blink(cursor)

get_blink(cursor)

@callback get_blink(cursor :: Raxol.Terminal.Cursor.Manager.t()) :: boolean()

get_state(cursor)

@callback get_state(cursor :: Raxol.Terminal.Cursor.Manager.t()) :: atom()

get_style(cursor)

@callback get_style(cursor :: Raxol.Terminal.Cursor.Manager.t()) :: atom()

hide(cursor)

set_bar(cursor)

set_block(cursor)

set_custom(cursor, shape, dimensions)

@callback set_custom(
  cursor :: Raxol.Terminal.Cursor.Manager.t(),
  shape :: atom(),
  dimensions :: map()
) :: Raxol.Terminal.Cursor.Manager.t()

set_underline(cursor)

@callback set_underline(cursor :: Raxol.Terminal.Cursor.Manager.t()) ::
  Raxol.Terminal.Cursor.Manager.t()

show(cursor)

toggle_blink(cursor)

@callback toggle_blink(cursor :: Raxol.Terminal.Cursor.Manager.t()) ::
  Raxol.Terminal.Cursor.Manager.t()

toggle_visibility(cursor)

@callback toggle_visibility(cursor :: Raxol.Terminal.Cursor.Manager.t()) ::
  Raxol.Terminal.Cursor.Manager.t()

update_blink(cursor)

@callback update_blink(cursor :: Raxol.Terminal.Cursor.Manager.t()) ::
  {Raxol.Terminal.Cursor.Manager.t(), boolean()}

Functions

blink(cursor)

Makes the cursor blink.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> cursor = Style.blink(cursor)
iex> cursor.state
:blinking

get_blink(cursor)

Gets the current cursor blink mode.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> Style.get_blink(cursor)
true

get_state(cursor)

Gets the current cursor state.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> Style.get_state(cursor)
:visible

get_style(cursor)

Gets the current cursor style.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> Style.get_style(cursor)
:block

hide(cursor)

Hides the cursor.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> cursor = Style.hide(cursor)
iex> cursor.state
:hidden

set_bar(cursor)

Sets the cursor style to bar.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> cursor = Style.set_bar(cursor)
iex> cursor.style
:bar

set_block(cursor)

Sets the cursor style to block.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> cursor = Style.set_block(cursor)
iex> cursor.style
:block

set_custom(cursor, shape, dimensions)

Sets a custom cursor shape.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> cursor = Style.set_custom(cursor, "█", {2, 1})
iex> cursor.style
:custom
iex> cursor.custom_shape
"█"

set_underline(cursor)

Sets the cursor style to underline.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> cursor = Style.set_underline(cursor)
iex> cursor.style
:underline

show(cursor)

Makes the cursor visible.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> cursor = Manager.set_state(cursor, :hidden)
iex> cursor = Style.show(cursor)
iex> cursor.state
:visible

toggle_blink(cursor)

Toggles the cursor blinking state.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> cursor = Style.toggle_blink(cursor)
iex> cursor.state
:blinking
iex> cursor = Style.toggle_blink(cursor)
iex> cursor.state
:visible

toggle_visibility(cursor)

Toggles the cursor visibility.

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> cursor = Style.toggle_visibility(cursor)
iex> cursor.state
:hidden
iex> cursor = Style.toggle_visibility(cursor)
iex> cursor.state
:visible

update_blink(cursor)

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

Examples

iex> alias Raxol.Terminal.Cursor.{Manager, Style}
iex> cursor = Manager.new()
iex> cursor = Style.blink(cursor)
iex> {_cursor, visible} = Style.update_blink(cursor)
iex> is_boolean(visible)
true