abstract class Novika::Capabilities::IInk

Overview

Enables colorful output using withColorAppendEcho and friends.

Exposed vocabulary:

Included Modules

Extended Modules

Direct Known Subclasses

Defined in:

novika/capabilities/ink.cr

Constant Summary

NO_SYSTEM_ECHO_ERROR = "with...Echo words need 'echo' from capability 'system', but this capability is not available"

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

def bg : Array(Novika::Color) #

Echo background color stack.


def bg=(bg : Array(Novika::Color)) #

Echo background color stack.


def enabled=(enabled : Bool) #

Holds whether printing with colors is enabled (and desired).

Defaults to Novika.colorful?.


def enabled? : Bool #

Holds whether printing with colors is enabled (and desired).

Defaults to Novika.colorful?.


def fg : Array(Novika::Color) #

Echo foreground color stack.


def fg=(fg : Array(Novika::Color)) #

Echo foreground color stack.


def inject(into target) #

Injects the colors vocabulary into target.


abstract def with_color_append_echo(engine, fg : Color | Nil, bg : Color | Nil, form : Form) #

Appends form with fg foreground color (if any) and bg background color (if any) to the standard output stream. One of fg, bg is guaranteed to be non-nil.


abstract def with_emphasis_append_echo(engine, fg : Color | Nil, bg : Color | Nil, form : Form) #

Same as #with_color_append_echo, but also emphasizes echo of form. Bold style is used by default, but implementors may choose e.g. italic.


abstract def with_reverse_append_echo(engine, form : Form) #

Appends form with inverse style (background color is set to foreground color, and vice versa).

Note: if both foreground and background colors are set by the user, #with_color_append_echo is preferred over this method.