Terminal support for status displays.
os
io0
typing0
itertools0
collections0
tools0
frames0
duration_repr827%typing.Tuple[float, str]
duration_repr(seconds)
Phrase
Phrase__slots__0
__slots__ = ()
Phrasecellcount0
cellcount(self)
Legacy0
Abstraction for legacy ANSI/DEC escapes.
Legacy_escape0
_escape = b'\x1b'
Legacy_csi_open0
_csi_open = _escape + b'['
Legacy_pm_open0
_pm_open = _csi_open + b'?'
Legacy_pm_save0
_pm_save = _pm_open + b'6;1049s'
Legacy_pm_restore0
_pm_restore = _pm_open + b'6;1049r'
Legacy_pm_origin_set0
_pm_origin_set = _pm_open + b'6h'
Legacy_pm_origin_reset0
_pm_origin_reset = _pm_open + b'6l'
Legacy_pm_screen_set0
_pm_screen_set = _pm_open + b'1049h'
Legacy_pm_screen_reset0
_pm_screen_reset = _pm_open + b'1049l'
Legacy_pm_show_cursor0
_pm_show_cursor = _pm_open + b'25h'
Legacy_pm_hide_cursor0
_pm_hide_cursor = _pm_open + b'25l'
Legacy_restore_cursor0
_restore_cursor = _escape + b'8'
Legacy_store_cursor0
_store_cursor = _escape + b'7'
Legacy_nl0
_nl = _csi_open + b'1B'
Legacy_reset_sgr0
_reset_sgr = _csi_open + b'0;39;49;59m'
Legacy_styles0
_styles = {
'default': b'39',
'black': b'30',
'red': b'31',
'green': b'32',
'yellow': b'33',
'blue': b'34',
'magenta': b'35',
'cyan': b'36',
'white': b'37',
'orange': b'38;5;208',
'violet': b'38;5;135',
'teal': b'38;5;23',
'purple': b'38;5;93',
'dark': b'38;5;236',
'gray': b'38;5;241',
}
Legacy_reset_text0
_reset_text = _csi_open + _styles['default'] + b'm'
@classmethod
Legacy_join0
_join(Class, *i)
Legacy__init__0
__init__(self)
Legacyset_cursor_visible0
set_cursor_visible(self, visible)
Adjust cursor visibility.
Legacyset_scrolling_region0
set_scrolling_region(self, top, bottom)
Confine the scrolling region to the given rows.
Legacyreset_scrolling_region0
reset_scrolling_region(self)
Release confinements on scrolling region.
Legacyopen_scrolling_region0
open_scrolling_region(self, top, bottom)
Set the scrolling region, enter it, and seek the bottom. Subsequent exit_scrolling_region and enter_scrolling_region should be use to maintain the SR's state.
Legacyclose_scrolling_region0
close_scrolling_region(self)
Save the screen buffer, reset the scrolling region, and restore the buffer. This preserves the screen's state after the transition.
Legacyenter_scrolling_region0
enter_scrolling_region(self)
Enter scrolling region; normal terminal output; restores cursor location.
Legacyexit_scrolling_region0
exit_scrolling_region(self)
Exit scrolling region; allow out of region printing; saves cursor location.
Legacyclear0
clear(self)
Clear the staionary area according to its configured width and default text properties.
Legacyerase0
erase(self, area)
Erase the given area.
Legacyseek0bytes
seek(self, monitor, top_offset, left_offset)
Primitive relative seek; Context cursor position is not updated.
Legacystyle0
style(self, name, text)
Text color will be reset to the default.
Legacyrender0
render(self, phrase)
Translate the color names to SGR codes.
Legacyconfigure0
configure(self, height, width, lines)
Update the dimensions of the screen.
Legacyposition0
Layout0
The set, sizes, and ordering of fields present in a monitor.
LayoutDefinition0
Definition = typing.Tuple[str, int]
LayoutFields0
Fields = typing.Sequence[Definition]
@staticmethod
Layoutseparators0
separators(fields)
Generate a series of separators finished with a terminator. Given a number of a fields, emit separators until the final index is reached.
Layoutlabel0
label(self, field, text)
The display text for the field's label.
Layout__init__0
__init__(self, fields, **updates)
Layoutfields0
fields(self)
Iterate over the fields in their designated order along with separators that can be used to follow the rendered field.
Layoutpositions0
positions(self)
Join the field identifier, cell allocation, and field label in the order designated by order.
Theme0
The rendering methods and parameters used by a Status.
ThemeFormatter0
Formatter = tuple[str, str]
Themedefault_render_method0
default_render_method(self, key, field)
Renders the string form of field with the style set identified by key.
Themer_transparent20%
r_transparent(value)
Render method expecting and returning a sequence of formatting pairs.
Used in cases where the field wishes to control theme-relative formatting directly.
Themer_duration0
r_duration(value)
Render method for common duration fields.
Themedefine0
define(self, name, style)
Themeimplement0
implement(self, type, render)
Theme__init__0
__init__(self)
Themeconfigure0
configure(self)
Themestyle0
style(self, celltexts)
Emit words formatted according to their associated style set.
Themerender0
render(self, type, field)
Render the given field according to the configured type' render method.
Status0
Allocated area for status display of a set of changing fields.
Statusview_state_loop0
view_state_loop = {
'total': 'rate_window',
'rate_window': 'rate_overall',
'rate_overall': 'total',
}
Statusunit_type_separators0
unit_type_separators = {
'total': '+',
'rate_window': '<',
'rate_overall': '^',
}
Status__init__0
__init__(self, theme, layout, position)
Status_calculate_fields190%
_calculate_fields(self)
Status_update_field_cache0
_update_field_cache(self)
Statusreset0
reset(self, time, metrics)
Reset the metrics records using the given entry as the only one.
Statuscurrent0
Statuselapse0
elapse(self, time)
Update the time field on the last metrics record.
Statusupdate0
update(self, time, metrics)
Update the metrics record for the given point in time.
Statusduration0
duration(self)
Statuscycle40%
cycle(self, field)
Select the next read type for the given field using the view_state_loop.
Statusset_field_read_type166%
set_field_read_type(self, field, units)
Statusprefix20%
prefix(self, *words)
Attach a constant phrase to the beginning of the monitor.
Statussuffix20%
suffix(self, *words)
Attach a constant phrase to the end of the monitor.
Statustitle0
title(self, title, *dimensions)
Assign the monitor's title and dimension identifiers.
Statuswindow_period0
window_period(self)
Calculate the current metrics window size.
Statusorigin10%
origin(self, field)
Statuswindow_delta40%
window_delta(self, field)
Statusedge0
edge(self, field)
Statustotal0
total(self, field)
Statusrate_window0
rate_window(self, field)
Statusrate_overall0
rate_overall(self, field)
Statusrender0
render(self)
Statusdelta190%
delta(self, fields)
Statusphrase0
phrase(self)
The monitor's image as a single phrase instance.
Statussnapshot0
snapshot(self)
A bytes form of the Status.phrase. (The image without cursor movement)
Statusprofile0
profile(self)
Construct a triple containing the start and stop time and the final metrics.
Statussynopsis283%
synopsis(self)
Construct a status frame synopsis using the monitor's configuration and metrics.
Statusframe0
frame(self, control, type, identifier)
Construct a transaction frame for reporting the status. Used after the completion of the dispatcher.
Monitor0
Terminal display management for monitoring changes in Status instances.
Monitorrender_status_text0str
render_status_text(self, monitor, identifier)
Construct the string representation of the given monitor' status.
Monitor__init__0
__init__(self, screen, fileno)
Monitorinstall0
install(self, monitor)
Erase, reframe, and update the given monitor.
Monitorframe469%
frame(self, monitor)
Render and emit the prefix, title, and suffix of the monitor.
Operation is buffered and must be flushed to be displayed.
Monitorupdate191%
update(self, monitor, fields)
Render and emit the given fields.
Operation is buffered and must be flushed to be displayed.
Monitorflush191%
flush(self)
Write any buffered terminal changes to the device.
Monitorclear0
clear(self)
Clear the entire status regions.
Monitorconfigure191%
configure(self, lines)
Configure the scrolling region allocating lines at the top or bottom of the screen for status display.
This method should be called after window changes of any type. The window size is refreshed from the device; monitors should also be reallocated so that their Context positions can be adjusted.
Monitor_save0
_save(self)
Monitor_restore0
_restore(self)
_metric_units0
_metric_units = [
('', '', 0),
('kilo', 'k', 3),
('mega', 'M', 6),
('giga', 'G', 9),
('tera', 'T', 12),
('peta', 'P', 15),
('exa', 'E', 18),
('zetta', 'Z', 21),
('yotta', 'Y', 24),
]
_precision180%
_precision(count)
_strings0
_strings(value)
r_count0
r_count(field, value)
Render method for counts providing compression using metric units.
r_title0
r_title(value)
Render method for monitor titles.
form0
form(module)
Construct a Layout and Theme from the provided order and formatting structures.
identify_device60%
identify_device()
Use the first three file descriptors to determine the path to the tty device. If no path can be identified, return the given path which defaults to /dev/tty.
setup0
setup()
aggregate0
aggregate(control, module)
Construct Status instances allocated using control for displaying the aggregate of the dimension allocations.
Returns a sequence of Status instances for the dimensions and a single Status for the aggregation.