Text¶
Text is shaped with parley:
ligatures, kerning, bidirectional text, and fallback between faces are
handled for you. Three kinds show it: "text" for labels,
"text_input" for editing, and "terminal" for a shell.
Text nodes¶
title = window.create("text", text="Quarterly report", font_size=22,
font_weight=500, fill=(0x1D, 0x1B, 0x20, 0xFF),
width=280, height=28)
The styling properties are font_family, font_size (pixels),
font_weight (1–1000), font_style ("normal" or "italic"),
letter_spacing, line_height (a multiple of the size), and text_align
("start", "center", "end"). vertical_align (0.6.11: "start", "center", "end") places
the lines in a box taller than they are; letter_spacing, line_height and vertical_align
work on a text_input too, which centres a single line by default:
field = window.create("text_input", height=32, padding=4) # text in the middle
label = window.create("text", text="Name", height=32, vertical_align="center")
Text wraps at word boundaries within the
node's width; wrap="none" keeps each paragraph on one line, max_lines
caps the lines shown, and overflow="ellipsis" ends a cut line with "…".
Sizing text to its content¶
Default (0.6.2, #263). A text node with no width or height is the size of
its text, wherever it sits. "auto" and "fit-content" (0.5.7) mean the same
thing on a text node, so these three labels are alike:
label = window.create("text", text="Julia set, drawn by a fill shader", font_size=22)
label = window.create("text", text="Julia set, drawn by a fill shader", font_size=22,
width="auto", height="auto")
label = window.create("text", text="Julia set, drawn by a fill shader", font_size=22,
width="fit-content", height="fit-content")
The width is the text on one line plus 2 pixels, narrowed to the space the parent
offers when the text wraps (so a long label wraps instead of overflowing, and
height is then the wrapped height). The 2 pixels are there because a box
exactly as wide as the measured text can cut it off or wrap its last word; the
height is exact. In a box that centres or start-aligns its children the label is
as wide as the text; a stretched child still fills the box, as in CSS. It is
measured by the same shaper as measure_text, rounded up to a whole pixel, and
laid out again when the text, font size, family, weight or wrapping changes.
Either side can be set on its own: any value other than "auto" or
"fit-content" (a number such as 80 or 0, "50%", "calc(100% - 16)")
takes that side off fit, and get("width") reads "fit-content" back for a
side that fits. On a box or any other node "auto" stays "auto", since those
already fit their content.
Before 0.6.2 an unsized text node was zero wide and zero tall, and
"fit-content" was the opt-in: the box an effect shader paints into was only as
big as the padding, so an effect over unsized text cropped it. Now the box is the
text. To size text by hand, give it a number, or use
window.measure_text, which lays the text out exactly as a text node with the
same properties paints it and returns exact numbers, with no extra pixels:
style = dict(font_size=14, max_lines=1, overflow="ellipsis")
width, height = window.measure_text("A long list item title", max_width=180, **style)
label = window.create("text", text="A long list item title",
width=min(width, 180), height=height, **style)
That's how a button hugs its label, or a chip fits its text.
Layout rounds every box to whole pixels, so a text node's explicit width
(and min_width, max_width) is laid out rounded up: a width the text fits
in still fits. Given the 66.43 that measure_text returned, the node is 67
wide and the text stays on one line; rounded down to 66, it would have wrapped.
get("width") still reads back what you set, and layout_width is the whole
pixel above it. Percentage and auto widths, and every other kind of node
(boxes included), are rounded as before.
Fonts¶
Tesserae Engine bundles Roboto (regular and medium), Noto Sans Arabic, and Hack Nerd
Font Mono, and by default never loads system fonts, so text renders the same on every
machine. tess_re.MONOSPACE_FONT_FAMILY names the monospace face, which
terminals use — use it for anything that must line up with one, such as an
editor's line numbers.
Any other font is bytes you load and register:
from pathlib import Path
import tess_re
families = tess_re.register_font(Path("fonts/Inter-Regular.ttf").read_bytes())
# ["Inter"] -- the name to use as font_family
Registration is for the whole process: every window sees the font, and one
already running picks it up on its next frame. Until a family is registered,
a font_family naming it falls back to a bundled face.
Other languages and emoji¶
The bundled fonts cover Latin, Cyrillic, Greek and Arabic. Hebrew, CJK, Indic scripts, Thai, colour emoji and the rest have no bundled font, so text in them draws as missing-glyph boxes or nothing. There are two ways to supply them.
Use the machine's fonts (0.5.4). One switch lets text fall back to whatever is installed, for exactly the glyphs the bundled and registered fonts lack:
tess_re.set_system_fonts(True) # for every window in this process, live
A node whose text mixes scripts then needs no special handling: with
font_family="Roboto", Latin comes from Roboto and the rest from a system font
chosen for its script, so "Hello 漢字 😀 שלום" shows all of it. A right-to-left
paragraph (Arabic, Hebrew) lays out right to left and aligns its start on the
right. The switch is off by default because it makes text depend on the machine:
the same app shows different pixels where different fonts are installed, and
where no installed font has a script it still shows boxes. Text the bundled
fonts cover is unaffected either way, and turning the switch off again returns
to the exact same frames.
Colour emoji (0.5.7). Colour emoji draw in colour from a font in the COLR
format (Windows' Segoe UI Emoji, a Noto Color Emoji COLR build) and from a
bitmap font: the CBDT format of the Noto Color Emoji package most Linux
distributions install, and macOS's Apple Color Emoji (sbix). Before 0.5.7 a
bitmap emoji drew nothing. A bitmap emoji is a picture, so it is drawn from the
glyph cache whatever set_glyph_cache says, and it scales from the nearest
size the font ships rather than from an outline: a large emoji is a magnified
bitmap. The sbix path is the same code as CBDT but has not been checked on a
Mac. For the same emoji on every machine, register a COLR emoji font you ship
(subset it to the emoji you use, as above).
Ship the fonts with the app. For the same pixels everywhere, register font files you bundle, such as subsets of Noto:
from importlib.resources import files
import tess_re
for name in ("NotoSansJP-Regular.otf", "NotoSansHebrew-Regular.ttf", "NotoEmoji-Regular.ttf"):
tess_re.register_font(files("myapp.fonts").joinpath(name).read_bytes())
Registered fonts take part in fallback too: a glyph that font_family lacks is
taken from any registered font that has it, so one call per script is enough and
no node needs to name them. Subset a font to the glyphs you need
(pyftsubset) to keep an app small; a full CJK font is many megabytes.
Rich text and selectable text¶
One text node can mix styles. spans styles ranges of its content (0.5.4),
given as UTF-8 byte offsets, as a text input's selection and syntax_spans
are:
label = window.create("text", text="Sale: $12 $9, ends Friday", font_size=18, width=300)
label.set(spans=[
(0, 5, {"weight": 500}), # "Sale:"
(6, 9, {"strikethrough": True}), # "$12"
(10, 12, {"color": (0xB3, 0x26, 0x1E, 0xFF), "weight": 500}),
(20, 26, {"italic": True, "underline": True}),
])
A style may set any of color, weight (an OpenType weight, 100 to 950),
italic, underline, strikethrough, font_size (pixels), font_family and
link; what it leaves out stays the node's
own, and a later span wins where two overlap. Offsets past the text, or inside a
multi-byte character, are clamped, so a span survives a shorter text. Spans
change the shape of the text (a heavier weight is wider), so the node's width
is yours to size, as it is for any text. Underline and strikethrough follow the
text's own font metrics and are drawn in the span's colour.
selectable=True lets the user select the text with the pointer and copy it
(0.5.4):
help_text.set(selectable=True) # press and drag selects; Ctrl+C copies
help_text.get("selection") # (start, end) or None; equal ends are a caret
help_text.set(selection=(0, 5)) # select from code; None clears
Links (0.5.4). A span with a link makes its range clickable. A click (press
and release on it, with no selection made between) fires a link event on the
text node, which bubbles, and event.href is the span's link string. tess_re opens
nothing and styles nothing: colour and underline the span yourself, and decide
in the listener what href means. The pointer shows as a hand over a link
(unless the node sets its own cursor), and text with a link takes pointer
events, as selectable text does.
label.set(spans=[(10, 14, {"link": "docs", "color": BLUE, "underline": True})])
label.on("link", lambda event: open_page(event.href))
A span's font_size makes its line taller when it is larger than the rest, and
font_family picks another face for the range.
Selected text shows the text colour at 30% behind it (the scheme's primary at 30% while
the text has no fill of its own; see Selection appearance). Double-click selects a
word and triple-click a line. With a selection showing, Ctrl+A selects all of
that text, and Shift+Left, Shift+Right, Shift+Home and Shift+End move the end
of the selection a character, or to the start or end of the text. Ctrl+Shift+Left
and Ctrl+Shift+Right move it a word (a run of letters and digits, a run of
punctuation, then the spaces after it), and Shift+Up and Shift+Down a line, keeping
the column. Moving past the start or end of a text goes on into the neighbouring
selectable text, and Shift+Up on the first line goes to the start of the text, as
Shift+Down on the last goes to its end, before they do. While a selection in static
text exists these keys belong to it: a scroll view does not also scroll for Shift+Up
and Shift+Down, and Ctrl+Shift+Left and Right are consumed by the selection, so no
key_down listener hears them (the other Shift keys still reach key_down
listeners). The pointer
is an I-beam over selectable text, unless the node sets a cursor. A press anywhere else
clears the selection.
A drag that starts in one selectable text and moves on into others (0.5.4) selects
across them, so a document with a text node per paragraph selects like one text:
the start text from the press to its end, every selectable text between whole, and
the last text up to the pointer. Copy joins the pieces with a newline, and each
node's own range reads back from node.get("selection"). The drag follows the
pointer only while it is over selectable text; over anything else it keeps what it
had, and it does not scroll the view. Setting selection from code selects within
that one text and clears the rest. Ctrl+A and the Shift keys act on the text the
selection started in. A selectable text
claims the pointer events over its box, which plain text never does (so a label
inside a button doesn't swallow the button's clicks): turn it on for text that
stands alone. A text input's own selection is separate, and Copy takes the
focused input's selection first. A screen reader sees the selection (see
Text, selection and links).
Selection appearance (0.6.12)¶
How a selection is painted is three properties, on a static text and on a text_input
(a terminal's selection is its palette["selection"]):
label.set(
selectable=True,
selection_fill=(103, 80, 164, 77), # the highlight behind the glyphs
selection_foreground=(255, 255, 255, 255), # the glyphs inside it
selection_radius=4, # its corners, in pixels
)
| Property | Default | Meaning |
|---|---|---|
selection_fill |
None: the scheme's primary at 30% (the text colour at 30% when the node has its own fill) |
The highlight's colour. A text had no way to set it before 0.6.12; a text_input did |
selection_foreground |
None: every glyph keeps its own colour |
The colour of the glyphs the selection covers. A ligature or a glyph the highlight's edge cuts goes by where its middle is |
selection_radius |
0: square |
The highlight's corner radius. Each selected line is one rectangle, rounded alone, never by more than half its shorter side |
The defaults paint exactly what 0.6.11 painted. The UX note "Text Selection" gives the highlight as
primary at 30% with the selected text keeping its colour and a square corner (shape.none): those
are the defaults, so a project sets these only to depart from the spec. None returns a property to
its default; Window.set_defaults("text", selection_radius=4) sets one for every text created
afterwards.
Text input¶
A "text_input" is editable text with a caret, selection, clipboard, and
input-method support. Its fill is the text color, so it paints no background
of its own — put it in a "box" for a field's background (its own
stroke_color, stroke_width, and corner_radius draw and round a border, and
its own padding insets its text, 0.5.1).
Of the styling properties above it takes
font_family, font_size, and font_weight; the rest are for text nodes
only:
field_box = window.create("box", width=240, height=40, padding=8,
corner_radius=4, stroke_color=(0x79, 0x74, 0x7E, 0xFF),
stroke_width=1)
field = window.create("text_input", placeholder="Email", width=224, height=24)
field_box.add_child(field)
field.on("change", lambda e: validate(e.new_value))
| Property | Does |
|---|---|
text |
the content; setting it fires no change |
placeholder, placeholder_fill |
the hint shown while it's empty |
multiline |
Enter inserts a newline, and Tab a tab character |
tab_navigates |
(0.6.8) a multiline input: True makes Tab and Shift+Tab move focus out of it, typing nothing, as they do from a single-line input; False (the default) keeps Tab as indentation. A keyboard user is otherwise held in the field, with Escape the only way out |
wrap |
(0.6.6) a multiline input: "word" breaks lines at its width, "none" keeps each line whole and scrolls sideways; None (the default) is as before. See Long lines |
overflow |
(0.6.6) a single-line input: "scroll", "ellipsis" or "clip" for a line longer than the box, which then stays one line; None (the default) is as before |
selection |
(start, end) as UTF-8 byte offsets; equal ends are a caret |
obscured |
a password field: bullets, and no copy or cut |
selection_start, selection_end |
the ends of the selection in order (0.5.6); set one and the other moves along if it would cross |
max_length |
(0.5.6) the most characters it holds, or None. Typing, paste and an IME commit are cut short at it, and a rejected edit fires no change. Text already longer is kept and can be deleted |
read_only |
(0.5.6) it can be focused, selected and copied but not edited; Enter still submits |
input_mode |
(0.5.6) "text", "numeric", "decimal", "email", "phone", "url" or "search": kept for a keyboard that can adapt. A desktop window has no use for it yet; obscured is passed to the IME as a password |
caret_color, selection_fill |
the caret and selection colors; caret_color animates (0.5.6) |
selection_foreground, selection_radius |
(0.6.12) the colour of the selected glyphs (None: each keeps its own) and the highlight's corner radius in pixels (0: square); see Selection appearance |
caret_visible, caret_width, caret_shape |
(0.5.6) draw the caret or leave it to you, its width in pixels (an underline's thickness; default 1.5), and "bar", "block" or "underline" |
caret_blink |
(0.5.6) milliseconds between the caret going off and on, or None for steady. A keystroke or click restarts it, so it is solid while you type, and an idle field wakes only at each edge |
syntax_spans |
[(start, end, color), ...] byte ranges to color |
folded_ranges |
[(start, end), ...] byte ranges drawn as "…" |
show_whitespace |
draw spaces and tabs as marks |
Long lines in a text input (0.6.6)¶
A text input chooses what a line longer than its box does with wrap (a multiline input)
or overflow (a single-line one). Left unset, both are as they were: a single-line input
wraps its text by word onto further lines, and a multiline one keeps each line whole.
| Input | Setting | What it does |
|---|---|---|
| multiline | wrap="word" |
lines break at the box width, at spaces; the box scrolls down to the caret |
| multiline | wrap="none" |
each line whole; the box scrolls sideways and down to the caret |
| single line | overflow="scroll" |
one line high; the text scrolls sideways to keep the caret in view |
| single line | overflow="ellipsis" |
one line; a long line is cut and ended with "…" until the input has the focus, then it scrolls |
| single line | overflow="clip" |
one line, cut at the box edge; it never scrolls, so the caret can sit past the edge |
note = window.create("text_input", width=240, height=80, multiline=True, wrap="word", text=long_text)
name = window.create("text_input", width=160, height=28, overflow="ellipsis", text="A long file name.txt")
- Setting
overflowon a single-line input makes it one line;wrapmeans nothing to a single-line input, andoverflowmeans nothing to a multiline one. Set neither and a single-line input still wraps, which is how it was before 0.6.6. - The scroll follows the caret by the shaped text, so it is exact for any font. It moves only as far as the caret needs, comes back when the caret does, and a wider box brings scrolled text back. It follows only while the input has the focus: a single-line input that loses it shows its start again, and a multiline one keeps its place.
- A multiline input with no
wrapkeeps the old scroll, which assumes a monospace face (a code editor's) and is out by a few pixels in a proportional one. Setwrapto"none"to have the exact one. - The caret keys of a multiline input with a
wrapgo by the rows you see (0.6.7): see Keys, rows and clicks. With nowrapthey are as before. "ellipsis"shows no selection while it is cut (an unfocused input), and a click in it focuses it and shows the whole line. Clearing a property withNonegives back the old behavior; changing either starts the scroll from the top left.caret_rect()andtext_rects()read the scroll as it is, so they are right straight after you setselectionortext.
A scrollbar on a multiline input (0.6.13)¶
A multiline input scrolls its text by its own offsets (the caret-follow above); a scrollbar over them is opt-in, so an input that never asked for one draws none and behaves as it did:
note = window.create("text_input", width=240, height=120, multiline=True, wrap="word",
padding_right=12, scrollbar_show="overflow") # the bar shows while the text overflows
It is the scroll view's bar, so scrollbar_width, scrollbar_fill, scrollbar_opacity, scrollbar_arrows,
scrollbar_lane_click, scrollbar_show="auto_hide" and the rest apply, with the spec's defaults (an 8 px thumb 2 px
from the edge, at least 32 px long, 70 % opaque and 80 % hovered). Its content is the shaped text and the input's
padding, so ten screens of text is a thumb of a tenth of the lane (32 px if that is less).
- Drag, lane click, arrows. Dragging the thumb, pressing the lane (a page of
page_fractionof the box, repeating while held) or an arrow scrolls the input; a press on the bar places no caret and selects nothing. The caret does not move, and the scroll is not pulled back to it until the caret moves or the text changes (typing shows the caret again, as in any editor). - The caret-follow moves the thumb. An edit, a caret key or a click that scrolls the text to the caret moves the
thumb with it. With the bar on the scroll follows the caret by the shaped text even with no
wrap(the monospace estimate of the old scroll cannot size a thumb); the keys themselves still go by logical line unless awrapis set. - Axes. A vertical bar always. A horizontal one too when the lines are not wrapped (
wrapother than"word"), which is the multiline input's default;scrollbar_cornerkeeps the two lanes apart. - Keys and wheel. The keys stay the caret's (the bar adds none). The wheel scrolls the input while its bar is on
(
wheel_notcha notch; Shift turns it sideways) and passes to the scroll view around it at the ends; with the bar off the wheel is not the input's, as before. - Single-line inputs take the properties and read them back, and show no bar; set
multilineand it appears, in either order. - The properties that make no sense on an input (
scrollbar_gutter,scrollbar_gutter_reserve,key_line,scroll_smooth_ms,scroll_easing, the snap, fling and edge-scroll ones) raiseValueError. - The Tesserae UX note "Text Field" says a multiline field shows this bar when its content exceeds the box;
here it is opt-in (
scrollbar_show="never"by default) so that no existing input changes. Setscrollbar_show="overflow"for the spec's behaviour. - The bar draws over the input's right (and bottom) edge and reserves no space: give the input padding on that side if the last column matters.
Keys, rows and clicks in a text input (0.6.7)¶
| Key | In any text input | In a multiline input with a wrap ("word" or "none") |
|---|---|---|
| Up, Down | (a single-line input: nothing) | one visual row, keeping the column; on the first row to the start of the text, on the last to its end |
| Home, End | the start and end of the text | the start and end of the row (End stops before the spaces a wrap fell on) |
| Page Up, Page Down | left to the scroll view around it | as many rows as the box shows, keeping the column; at the first or last row to the start or end |
| Ctrl+Home, Ctrl+End | the start and end of the whole text | the same |
| Ctrl+Left, Ctrl+Right | by word (a run of letters and digits, or of punctuation, then the spaces after it) | the same |
| Ctrl+Backspace, Ctrl+Delete | delete back to the start of the word, or on to the next | the same |
| Shift with any of these | extends the selection from its fixed end: it shrinks when the direction reverses and, past the end, selects on the other side | the same, by row |
| Insert | toggles overwrite mode (below) | the same |
Backspace and Delete remove one character before and after the caret, or the selection; at the start of a row they remove the last character of the row above (the space a wrap fell on, or the line break, which joins two lines), and nothing at the very start or end of the text.
The column is held across a run of Up, Down, Page Up and Page Down, so passing a short row
does not lose it. A wrap of either value gives the multiline input these exact row keys
(with "none" a row is a logical line); with no wrap set it keeps the 0.6.6 keys, which go by
logical line and count characters, not pixels. A single-line input has one row.
Overwrite mode. text_input.get("overwrite") and set(overwrite=True); the Insert key toggles it
and fires overwrite_change (old_value, new_value; not for set). Off by default. With it on, each
character you type, a space and an IME-committed character included, replaces the one after the
caret and the caret moves on; at the end of the text, or before a line break, it is added instead, so a
break is never eaten. Typing over a selection replaces just the selection in both modes, and a paste is
always inserted. A caret_shape of "bar" (the default) is drawn as a block while overwrite is on;
"block" and "underline" stay as you set them. max_length lets a replacement through, since the
text does not grow.
Double and triple click (0.6.7). A double click selects the word under the pointer: letters, digits
and the underscore, Unicode ones too, so a double click on well in well-known selects well. On a
space or on punctuation it selects that run of spaces or of punctuation. A triple click selects the
string around it up to the spaces, special characters included: well-known. Both stop at the edge
of the visual row, so a string that wraps is selected one row at a time, and neither
starts a drag; click, hold and drag selects by character as before.
Submit, composition and the caret (0.5.6)¶
submitfires on Enter in a single-line input (a multiline one inserts a newline). It doesn't bubble.- IME composition fires
compose_start,compose_updateandcompose_endon the input.event.textis the preedit text (not oncompose_end) andevent.preedit_cursorthe IME's cursor range inside it, in bytes. Nothing is intextuntil the IME commits: the commit arrives as ordinaryinputandchange, aftercompose_end. Typing over a selection replaces it at the commit. The OS's candidate window is placed at the caret, and a password input tells the IME not to learn from it. A read-only input takes no composition. caret_movefires after a key, click or drag moves the caret or changes the text of an input, once per input event.event.caretis the caret's rectangle(x, y, width, height)in the node's coordinates andevent.insertedthe(start, end)bytes an edit inserted (Nonefor a plain move). It doesn't fire forset(text=...)orset(selection=...), aschangedoesn't.node.caret_rect()gives the caret's rectangle at any time, shaped fresh so it is right straight after an edit, andnode.text_rects(start, end)the rectangles covering a byte range, one per line. Both are in the node's coordinates, with padding and scrolling in them: put an overlay of your own at the character just typed, or glide a caret of your own (withcaret_visible=False) to the next position.- A shader on the input still sees only its pixels, not where a character is; the rectangles above can drive its uniforms.
field.set(caret_visible=False) # we draw our own caret
def moved(event):
x, y, w, h = event.caret
my_caret.animate("translate_x", x, 90)
if event.inserted:
flash.set(...) # at field.text_rects(*event.inserted)
field.on("caret_move", moved)
In tests, window.simulate("ime_preedit", text="ni", cursor=(0, 2)) sends a composition
preview (empty text ends it), then simulate("input", text="你") commits.
A code editor is a multiline input in the monospace face, with syntax spans from your highlighter:
editor = window.create("text_input", text=source, multiline=True,
font_family=tess_re.MONOSPACE_FONT_FAMILY, font_size=13,
width=600, height=400)
editor.set(syntax_spans=[(0, 3, (0xB5, 0x3F, 0x8C, 0xFF))]) # "def"
Its events — input and change — are on
Events and Input.
Terminal¶
A "terminal" runs a shell on a pseudo-terminal and emulates its screen:
term = window.create("terminal", shell="/bin/bash", cols=80, rows=24,
scrollback_lines=5000, font_size=13)
Its box follows its grid and font. While focused it takes every key: text
and named keys go to the shell, and Ctrl+letter sends that control byte, so
Ctrl+C interrupts. Ctrl+Shift+C copies its selection, the wheel scrolls its
history, and set(cols=, rows=) resizes the grid and tells the shell.
get("text") reads the visible grid, one line per row, and selection is
(start_row, start_col, end_row, end_col).
Leaving a terminal from the keyboard (0.6.11, UXREQ-006). Because the terminal takes every key, a keyboard user
could never leave it (WCAG 2.1.2). The chord escape_chord, default "ctrl+shift+escape", is checked first: it is
not sent to the shell, focus moves to the next focusable node in tab order, and terminal_escape fires on the
terminal (event.key is the chord, event.related_target the node that took focus). escape_chord_reverse
(default None) does the same toward the previous node. A chord is modifiers (ctrl, shift, alt, meta) and one
key joined by +, matched exactly: Ctrl+Escape and Ctrl+Shift+Alt+Escape do not fire it and reach the shell.
None turns the chord off; a malformed chord raises ValueError listing the format and the keys.
term.on("terminal_escape", lambda e: print("left with", e.key))
term.set(escape_chord="ctrl+alt+tab", escape_chord_reverse="ctrl+alt+shift+tab")
print(term.get("escape_chord")) # "ctrl+alt+tab"
A scrollbar over the history (0.6.12, UXREQ-006). The wheel scrolls a terminal's history; a scrollbar over it is opt-in, so a terminal that never asked for one draws none:
term.set(scrollbar_show="overflow") # the bar shows while there is history
It is the scroll view's bar, so scrollbar_width, scrollbar_fill, scrollbar_opacity, scrollbar_arrows,
scrollbar_lane_click and the rest apply, with the spec's defaults (an 8 px thumb 2 px from the edge, at least 32 px
long, 70 % opaque and 80 % hovered). Its content is the history and the screen: 500 lines of history under 24 visible
rows is a thumb of 24/524 of the lane (32 px if that is less). Dragging the thumb, pressing the lane (a page, repeating
while held) or an arrow moves the view through the history one line at a time, and what the shell prints while you are
scrolled back keeps the view on its line and moves the thumb. The wheel and the keys stay the terminal's own: the
bar adds no key to it. The bar draws over the grid's right edge and reserves no space, so give the box room if the
last column matters. See Terminal properties.
Terminal appearance (0.6.12)¶
How a terminal draws is properties too, each with the value it always had as its default:
term.set(
font_family="JetBrains Mono", line_height=1.3, # the cell
caret_shape="bar", caret_width=2, caret_blink=530, # the cursor (blink: steady under reduced motion)
caret_unfocused="outline", # hollow when the terminal has no focus
bold_weight=600, dim_opacity=0.5, # SGR 1 and 2
underline_offset=15, underline_thickness=2, # SGR 4
selection_foreground=(255, 255, 255, 255), selection_radius=2,
)
The box follows font_family and line_height; the glyphs stay centred in a taller or shorter cell. The
selection's colour is palette["selection"]. The 256-colour cube and grey ramp are the xterm values, not a design
choice, and stay fixed; the 16 ANSI colours are in palette.
The palette recolors it — any of
ansi (16 colors), foreground, background, cursor, and selection:
term.set(palette={"background": (0x1E, 0x1E, 0x1E, 0xFF),
"foreground": (0xD4, 0xD4, 0xD4, 0xFF)})