abstract class Novika::Capabilities::IConsole

Overview

Enables the console API.

Exposed vocabulary:

Included Modules

Extended Modules

Direct Known Subclasses

Defined in:

novika/capabilities/console.cr

Constant Summary

BG_DEFAULT = Color.new(Decimal.new(0), Decimal.new(0), Decimal.new(0))

Background color used when there is no user-provided background color.

FG_DEFAULT = Color.new(Decimal.new(255), Decimal.new(255), Decimal.new(255))

Foreground color used when there is no user-provided foreground color.

Class Method Summary

Instance Method Summary

Instance methods inherited from module Novika::ICapability

capabilities : CapabilityCollection capabilities, inject(into target : Block) inject

Constructor methods inherited from module Novika::ICapability

new(capabilities) new

Class Method Detail

def self.id : String #

def self.on_by_default? : Bool #

def self.purpose : String #

Instance Method Detail

abstract def append_echo(engine, x : Decimal, y : Decimal, fg : Color, bg : Color, quote : Quote) #

Appends echo of quote colorized with fg and bg colors at the given x and y position (in columns, rows).


def bg #

Returns the active primary background color.


abstract def clear(engine, fg : Color, bg : Color) #

Clears the console with fg and bg colors.


abstract def colors_256(engine) #

Enables the 256-color output mode.


abstract def colors_compat(engine) #

Enables the compatibility color (8-color) output mode.


abstract def colors_truecolor(engine) #

Enables the truecolor output mode.


def fg #

Returns the active primary foreground color.


abstract def get_char_pressed(engine) : Quote #

Returns char quote for the key that was pressed. Usually a lowercase or uppercase letter; but also may look like '\\n' or '\\t', etc.)

In case the key that was pressed cannot be represented by the means of a quote, or if the user did not press any key, an empty quote is returned.


abstract def had_alt_pressed?(engine) : Boolean #

Returns whether the ALT key was pressed.


abstract def had_backspace_pressed?(engine) : Boolean #

Returns whether the Backspace key was pressed.


abstract def had_char_pressed?(engine) : Boolean #

Returns whether EXCLUSIVELY a printable character key was pressed (no CTRL, ALT, etc.) Whether the SHIFT key was pressed or not is ignored.


abstract def had_ctrl_pressed?(engine) : Boolean #

Returns whether the CTRL key was pressed.


abstract def had_delete_pressed?(engine) : Boolean #

Returns whether the DELETE key was pressed.


abstract def had_down_pressed?(engine) : Boolean #

Returns whether the DOWN ARROW key was pressed.


abstract def had_end_pressed?(engine) : Boolean #

Returns whether the END key was pressed.


abstract def had_fn_pressed?(engine) : Boolean #

Returns whether one of the function keys F1-F12 was pressed.


abstract def had_home_pressed?(engine) : Boolean #

Returns whether the HOME key was pressed.


abstract def had_insert_pressed?(engine) : Boolean #

Returns whether the INSERT key was pressed.


abstract def had_key_pressed?(engine) : Boolean #

Returns whether any key was pressed.


abstract def had_left_pressed?(engine) : Boolean #

Returns whether the LEFT ARROW key was pressed.


abstract def had_pgdn_pressed?(engine) : Boolean #

Returns whether the PAGE DOWN key was pressed.


abstract def had_pgup_pressed?(engine) : Boolean #

Returns whether the PAGE UP key was pressed.


abstract def had_right_pressed?(engine) : Boolean #

Returns whether the RIGHT ARROW key was pressed.


abstract def had_shift_pressed?(engine) : Boolean #

Returns whether the SHIFT key was pressed.


abstract def had_up_pressed?(engine) : Boolean #

Returns whether the UP ARROW key was pressed.


def inject(into target) #

abstract def off(engine) #

Disables the Console API.


abstract def on(engine) #

Enables the Console API.


abstract def present(engine) #

Syncs the internal buffer with console.


abstract def read_key(engine, timeout : Decimal) #

Peeks or waits for input. Refreshes the input state.

  • Negative timeout must wait indefinitely for input, and after receiving input refresh the state.

  • Zero timeout must refresh the input state without waiting for input.

  • Positive timeout must wait for input in a window timeout milliseconds long, and refresh the input state after receiving input.


abstract def size(engine) : Tuple(Decimal, Decimal) #

Returns the console width (in columns) and height (in rows).