struct TermBuf::Capabilities

Overview

A capability mask that keeps itself consistent.

Support is capped, not limited: a terminal that can do 24 bit colour can also do the 256 colour palette and the original sixteen, so setting the broader capability implies the narrower ones. The encoder relies on that, and checks only the capability it is about to use.

Defined in:

termbuf/caps/capability.cr

Constant Summary

ANSI = new(((((((Capability::Color16 | Capability::Bold) | Capability::Underline) | Capability::Reverse) | Capability::Blink) | Capability::ScrollRegion) | Capability::InsertDeleteLine) | Capability::AltScreen)

What essentially every terminal emulator written since the 1980s does.

MODERN = new((((((((((((XTERM.flags | Capability::TrueColor) | Capability::ExtendedUnderline) | Capability::UnderlineColor) | Capability::Overline) | Capability::RapidBlink) | Capability::SynchronizedOutput) | Capability::BracketedPaste) | Capability::FocusEvents) | Capability::MouseSgr) | Capability::Osc8Links) | Capability::Titles) | Capability::CursorShape)

A current terminal such as kitty, ghostty, or WezTerm.

NONE = new

Nothing at all: plain text, no escape sequences. The starting point for detection, and what an unrecognised terminal gets.

XTERM = new(((((((ANSI.flags | Capability::Color256) | Capability::BrightColors) | Capability::Italic) | Capability::Faint) | Capability::Strike) | Capability::Conceal) | Capability::EraseChars)

A typical xterm-256color terminal.

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(flags : Capability = Capability::None) #

[View source]

Class Method Detail

def self.normalize(flags : Capability) : Capability #

Applies the implications a capability carries with it.


[View source]

Instance Method Detail

def flags : Capability #

The mask itself, already normalized.


[View source]
def includes?(capability : Capability) : Bool #

Whether every capability in capability is present.


[View source]
def to_s(io : IO) : Nil #
Description copied from struct Struct

Same as #inspect(io).


[View source]
def with(capability : Capability) : Capabilities #

Adds a capability along with everything it implies, so that setting TrueColor also sets Color256 and Color16.


[View source]
def without(capability : Capability) : Capabilities #

Removes a capability along with everything that implies it, so that clearing Color256 also clears TrueColor rather than leaving a mask that claims both.


[View source]