Raxol.Terminal.Integration (Raxol v0.2.0)

View Source

Integrates various terminal components like Emulator, Buffer Manager, Cursor Manager, etc.

This module acts as a central orchestrator, managing interactions between:

Summary

Functions

Clears the damage regions in the buffer manager.

Clears the screen with integrated buffer management.

Clears the scroll buffer with integrated scroll buffer management.

Executes a command and updates the command history.

Gets the current cursor position with integrated cursor management.

Gets the current cursor state with integrated cursor management.

Gets the current cursor style with integrated cursor management.

Gets the damage regions from the buffer manager.

Gets the total scroll height with integrated scroll buffer management.

Gets the current scroll position with integrated scroll buffer management.

Gets a view of the scroll buffer with integrated scroll buffer management.

Gets the visible content of the terminal with integrated buffer management.

Handles a device status query.

Handles input from the user, including command history navigation.

Hides the cursor with integrated cursor management.

Invokes a character set.

Moves the cursor to the specified position with integrated cursor management.

Creates a new integrated terminal system with the specified dimensions.

Resets a specific screen mode in the emulator.

Restores the previously saved cursor position with integrated cursor management.

Saves the current cursor position with integrated cursor management.

Checks if a screen mode is enabled.

Scrolls the terminal content with integrated scroll buffer management.

Sets a character set for a G-set.

Sets the cursor blink rate with integrated cursor management.

Sets the cursor style with integrated cursor management.

Sets a specific screen mode in the emulator.

Shows the cursor with integrated cursor management.

Switches the active and back buffers in the buffer manager.

Switches to the alternate screen buffer.

Switches back to the main screen buffer.

Updates the terminal configuration.

Updates the cursor blink state with integrated cursor management.

Updates memory usage tracking in the buffer manager.

Checks if memory usage is within limits.

Writes text to the terminal with integrated buffer and cursor management.

Types

t()

@type t() :: %Raxol.Terminal.Integration{
  buffer_manager: Raxol.Terminal.Buffer.Manager.t(),
  command_history: Raxol.Terminal.Commands.History.t(),
  config: map(),
  cursor_manager: Raxol.Terminal.Cursor.Manager.t(),
  emulator: Raxol.Terminal.Emulator.t(),
  last_cleanup: integer(),
  renderer: Raxol.Terminal.Renderer.t(),
  scroll_buffer: Raxol.Terminal.Buffer.Scroll.t()
}

Functions

clear_damage_regions(integration)

Clears the damage regions in the buffer manager.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.write(integration, "Hello")
iex> integration = Integration.clear_damage_regions(integration)
iex> Integration.get_damage_regions(integration)
[]

clear_screen(integration)

Clears the screen with integrated buffer management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.write(integration, "Hello")
iex> integration = Integration.clear_screen(integration)
iex> Integration.get_visible_content(integration)
""

clear_scroll_buffer(integration)

Clears the scroll buffer with integrated scroll buffer management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.write(integration, "Line 1

Line 2 Line 3")

iex> integration = Integration.clear_scroll_buffer(integration)
iex> Integration.get_scroll_height(integration)
0

execute_command(integration, command)

Executes a command and updates the command history.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.execute_command(integration, "ls -la")

get_cursor_position(integration)

Gets the current cursor position with integrated cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.move_cursor(integration, 10, 5)
iex> Integration.get_cursor_position(integration)
{10, 5}

get_cursor_state(integration)

Gets the current cursor state with integrated cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.hide_cursor(integration)
iex> Integration.get_cursor_state(integration)
:hidden

get_cursor_style(integration)

Gets the current cursor style with integrated cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.set_cursor_style(integration, :underline)
iex> Integration.get_cursor_style(integration)
:underline

get_damage_regions(integration)

Gets the damage regions from the buffer manager.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.write(integration, "Hello")
iex> regions = Integration.get_damage_regions(integration)
iex> length(regions)
1

get_scroll_height(integration)

Gets the total scroll height with integrated scroll buffer management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.write(integration, "Line 1

Line 2 Line 3")

iex> Integration.get_scroll_height(integration)
3

get_scroll_position(integration)

Gets the current scroll position with integrated scroll buffer management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.scroll(integration, 5)
iex> Integration.get_scroll_position(integration)
5

get_scroll_view(integration, view_height)

Gets a view of the scroll buffer with integrated scroll buffer management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.write(integration, "Line 1

Line 2 Line 3")

iex> view = Integration.get_scroll_view(integration, 2)
iex> length(view)
2

get_visible_content(integration)

Gets the visible content of the terminal with integrated buffer management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.write(integration, "Hello")
iex> Integration.get_visible_content(integration)
"Hello"

handle_device_status_query(integration, query)

Handles a device status query.

Examples

iex> integration = Integration.new(80, 24)
iex> response = Integration.handle_device_status_query(integration, "6")
iex> response
""

handle_event(integration, arg)

handle_input(integration, input)

Handles input from the user, including command history navigation.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.handle_input(integration, "ls -la")
iex> integration = Integration.handle_input(integration, :up_arrow)

hide_cursor(integration)

Hides the cursor with integrated cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.hide_cursor(integration)
iex> integration.cursor_manager.state
:hidden

invoke_character_set(integration, gset)

Invokes a character set.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.invoke_character_set(integration, "0")

move_cursor(integration, x, y)

Moves the cursor to the specified position with integrated cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.move_cursor(integration, 10, 5)
iex> integration.cursor_manager.position
{10, 5}

new(width, height, opts \\ [])

Creates a new integrated terminal system with the specified dimensions.

Examples

iex> integration = Integration.new(80, 24)
iex> integration.emulator.width
80
iex> integration.emulator.height
24

reset_screen_mode(integration, mode)

Resets a specific screen mode in the emulator.

restore_cursor(integration)

Restores the previously saved cursor position with integrated cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.move_cursor(integration, 10, 5)
iex> integration = Integration.save_cursor(integration)
iex> integration = Integration.move_cursor(integration, 0, 0)
iex> integration = Integration.restore_cursor(integration)
iex> integration.cursor_manager.position
{10, 5}

save_cursor(integration)

Saves the current cursor position with integrated cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.move_cursor(integration, 10, 5)
iex> integration = Integration.save_cursor(integration)
iex> integration.cursor_manager.saved_position
{10, 5}

screen_mode_enabled?(integration, mode)

Checks if a screen mode is enabled.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.screen_mode_enabled?(integration, :alternate_screen)
false

scroll(integration, lines)

Scrolls the terminal content with integrated scroll buffer management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.write(integration, "Line 1

Line 2 Line 3")

iex> integration = Integration.scroll(integration, 1)
iex> Integration.get_visible_content(integration)
"Line 2

Line 3"

set_character_set(integration, gset, charset)

Sets a character set for a G-set.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.set_character_set(integration, "0", "B")

set_cursor_style(integration, style)

Sets the cursor style with integrated cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.set_cursor_style(integration, :underline)
iex> integration.cursor_manager.style
:underline

set_screen_mode(integration, mode)

Sets a specific screen mode in the emulator.

show_cursor(integration)

Shows the cursor with integrated cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.hide_cursor(integration)
iex> integration = Integration.show_cursor(integration)
iex> integration.cursor_manager.state
:visible

switch_buffers(integration)

Switches the active and back buffers in the buffer manager.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.write(integration, "Hello")
iex> integration = Integration.switch_buffers(integration)
iex> integration.buffer_manager.active_buffer != integration.buffer_manager.back_buffer
true

switch_to_alternate_buffer(integration)

Switches to the alternate screen buffer.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.switch_to_alternate_buffer(integration)

switch_to_main_buffer(integration)

Switches back to the main screen buffer.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.switch_to_main_buffer(integration)

update_config(integration, opts)

Updates the terminal configuration.

Merges the provided opts into the current configuration and validates the result before applying.

Examples

iex> integration = Integration.new(80, 24)
iex> {:ok, integration} = Integration.update_config(integration, theme: "light", behavior: [scrollback_lines: 2000])
iex> integration.config.theme
"light"
iex> integration.config.behavior.scrollback_lines
2000

iex> {:error, _reason} = Integration.update_config(integration, invalid_opt: :bad)

update_cursor_blink(integration)

Updates the cursor blink state with integrated cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.set_cursor_style(integration, :blinking)
iex> {integration, visible} = Integration.update_cursor_blink(integration)
iex> is_boolean(visible)
true

update_memory_usage(integration)

Updates memory usage tracking in the buffer manager.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.update_memory_usage(integration)
iex> integration.buffer_manager.memory_usage > 0
true

within_memory_limits?(integration)

Checks if memory usage is within limits.

Examples

iex> integration = Integration.new(80, 24)
iex> Integration.within_memory_limits?(integration)
true

write(integration, text)

Writes text to the terminal with integrated buffer and cursor management.

Examples

iex> integration = Integration.new(80, 24)
iex> integration = Integration.write(integration, "Hello")
iex> Integration.get_visible_content(integration)
"Hello"