Terminal Info¶
import chafa
db = chafa.TermDb()
capabilities = db.detect_capabilities()
print("CanvasMode:", capabilities.canvas_mode)
print("PixelMode: ", capabilities.pixel_mode)
TermInfo¶
A TermInfo
describes the characteristics of one particular kind of display terminal. It stores control sequences that can be used to move the cursor, change text attributes, mark the beginning and end of sixel graphics data, etc.
TermInfo
also implements an efficient low-level API for formatting these sequences with marshaled arguments so they can be sent to the terminal.
- class chafa.TermInfo¶
-
- supplement(source: TermInfo)¶
Supplements missing sequences in this
TermInfo
with ones copied from source.
- emit(*args)¶
Returns the terminal sequences asked for as
bytes
.Note
To “use” the sequence with
print()
you will first need to decode it withbytes.decode()
For an example, check out the Animating with control sequences example.
Added in version 1.2.0.
- detect_capabilities()¶
A method that tries to automatically detect the current terminal’s capabilities.
The priority for
CanvasMode
isThe priority for
PixelMode
isYou can use the results for
CanvasConfig.canvas_mode
andCanvasConfig.pixel_mode
in yourCanvasConfig
.- Return type:
TerminalCapabilities¶
This class is just a simple dataclass representing the capabilities of a terminal. It is generated by TermInfo.detect_capabilities()