class Opal::Terminal::MockDriver

Overview

In-memory mock terminal driver for headless automated testing.

Defined in:

opal/terminal/mock.cr

Constructors

Instance Method Summary

Instance methods inherited from class Opal::Terminal::Driver

check_resize : ResizeEvent | Nil check_resize, clear : Nil clear, disable_mouse : Nil disable_mouse, enable_mouse : Nil enable_mouse, enter_alternate_screen : Nil enter_alternate_screen, exit_alternate_screen : Nil exit_alternate_screen, flush : Nil flush, flush_input : Nil flush_input, hide_cursor : Nil hide_cursor, input : IO input, input=(input : IO) input=, move_to(row : Int32, col : Int32) : Nil move_to, on_resize : Proc(Int32, Int32, Nil) | Nil on_resize, on_resize=(on_resize : Proc(Int32, Int32, Nil) | Nil) on_resize=, output : IO output, output=(output : IO) output=, poll_event(timeout_ms : Int32 = 0) : KeyEvent | MouseEvent | ResizeEvent | Nil poll_event, raw_mode(&) raw_mode, read_event : KeyEvent | MouseEvent | ResizeEvent | Nil read_event, show_cursor : Nil show_cursor, size : Tuple(Int32, Int32) size, write(str : String) : Nil write

Constructor methods inherited from class Opal::Terminal::Driver

new(output : IO = STDOUT, input : IO = STDIN) new

Constructor Detail

def self.new(width : Int32 = 80, height : Int32 = 24) #

[View source]

Instance Method Detail

def alt_screen? : Bool #

[View source]
def clear_output : Nil #

Clears the recorded output buffer


[View source]
def cursor_visible? : Bool #

[View source]
def disable_mouse : Nil #

[View source]
def enable_mouse : Nil #

[View source]
def enter_alternate_screen : Nil #

[View source]
def event_queue : Array(KeyEvent | MouseEvent | ResizeEvent) #

[View source]
def event_queue=(event_queue : Array(KeyEvent | MouseEvent | ResizeEvent)) #

[View source]
def exit_alternate_screen : Nil #

[View source]
def flush : Nil #

[View source]
def height : Int32 #

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

[View source]
def hide_cursor : Nil #

[View source]
def in_raw_mode? : Bool #

[View source]
def inject_key(name : String, char : Char | Nil = nil, ctrl : Bool = false, alt : Bool = false, shift : Bool = false) : self #

Injects a key event into the mock input stream


[View source]
def inject_mouse(x : Int32, y : Int32, button : MouseButton, action : MouseAction) : self #

Injects a mouse event


[View source]
def inject_resize(width : Int32, height : Int32) : self #

Injects a window resize event


[View source]
def mouse_enabled? : Bool #

[View source]
def output : String #

Returns the full recorded output string


[View source]
def output_io : IO::Memory #

[View source]
def poll_event(timeout_ms : Int32 = 0) : KeyEvent | MouseEvent | ResizeEvent | Nil #
Description copied from class Opal::Terminal::Driver

Non-blocking or timed check for input/resize events.


[View source]
def raw_mode(&) #

[View source]
def read_event : KeyEvent | MouseEvent | ResizeEvent | Nil #
Description copied from class Opal::Terminal::Driver

Reads the next key, mouse, or resize event from the terminal, consuming from the internal event queue if multiple events arrived in the same read chunk.


[View source]
def show_cursor : Nil #

[View source]
def size : Tuple(Int32, Int32) #

[View source]
def stripped_output : String #

Returns the output with all ANSI escape sequences removed


[View source]
def width : Int32 #

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

[View source]
def write(str : String) : Nil #

[View source]