TextDisplay(3I)
πΈ NAME πΈ
TextDisplay β unstructured text display π
okay bestie, so this is TextDisplay(3I) from the InterViews Reference Manual, and it's literally the girl who holds all your text and makes it look cute on screen. let's get into it π
β¨ SYNOPSIS β¨
#include <InterViews/textdisplay.h>
π¦ DESCRIPTION π¦
so a TextDisplay manages and displays an array of lines of text. like, it's the whole vibe. it gives you operations to insert and delete lines, insert and delete text within a line, and scroll the whole display around. TextDisplays are typically used to implement interactors that need non-trivial display of unstructured text. no cap. π«Ά
the array is addressed by a line number and an index into the line. you can insert or delete text at arbitrary positions β go off, honestly. by default, the first character in line number zero is positioned with its top left corner at the top left corner of the TextDisplay. the display is automatically updated following modifications to the text or when scrolling. β¨
every single character in the array has an associated text style. there are operations to apply, add, or remove font styles to a range of the text. and TextDisplay can be used with both constant-width and proportionally-spaced fonts, plus arbitrary geometric transformations. versatile icon behavior only π
π PUBLIC OPERATIONS π
π creating & destroying
TextDisplay()
~TextDisplay(boolean autosized = false)
- create or destroy a
TextDisplay. if autosized istrue, theTextDisplaywill automatically grow its size as text is added. the default is to keep the size constant. so if you don't say anything, it stays the same size, periodt. πΈ
π§ sizing the lines
void LineHeight(Coord lineheight)
void TabWidth(Coord tabwidth)
- lines of text will be positioned with baselines separated by lineheight. tab characters in the text will cause the following character to be positioned an integral multiple of tabwidth from the beginning of the line. math girlies rise π«Ά
π¦ bounds & resizing
void Resize(Coord xmin, Coord ymin, Coord xmax, Coord ymax)
void Bounds(Coord& xmin, Coord& ymin, Coord& xmax, Coord& ymax)
- specify or query the size of the display. only lines of text that fall completely inside the specified region will be displayed.
TextDisplaywill not draw on any part of the canvas outside the specified bounds. conversely,TextDisplayis free to draw on any part of the canvas within the specified bounds. so like, inside = yes, outside = absolutely not π«
π drawing setup
void Draw(Painter*, Canvas*)
- specify the painter and canvas to use for drawing operations; the painter specifies the font, colors, and geometric transformation.
Drawshould be called before performing any operation on theTextDisplaywhich produces output or requires graphical information, or when there is a possibility that the painter or canvas has changed since the function was last called. basically: call it first or things get weird π
β¨ redrawing
void Redraw(Coord left, Coord bottom, Coord right, Coord top)
- redraw a specified region of the display. touch up that little corner, she deserves it π
π scrolling
void Scroll(int line, Coord x, Coord y)
- scroll the display so that line line is positioned with its upper-left corner at (x, y). there are no restrictions on the arguments: it is possible to scroll the display so that no lines are visible. wild, right? you can literally scroll into the void and there's nothing stopping you π
π inserting & deleting whole lines
void InsertLinesAfter(int line, int count)
void InsertLinesBefore(int line, int count)
void DeleteLinesAfter(int line, int count)
void DeleteLinesBefore(int line, int count)
- insert or delete whole lines of text. line line is not affected by the operation. other lines will move up or down to accommodate the changes. newly inserted lines are blank. and the specified line need not refer to an existing line β she's chill like that π«Ά
π editing text inside a line
void InsertText(int line, int index, const char*, int count)
void DeleteText(int line, int index, int count)
void ReplaceText(int line, const char*, int count)
- modify the text within line line.
InsertTextandDeleteTextwill cause the following characters on the line to move to accommodate the changes.ReplaceTextreplaces the entire text of the line. if the specified line is non-existent, a new line will be created. slay, self-healing π§
π styling the text
void Style(int line1, int index1, int line2, int index2, int style)
void AddStyle(int line1, int index1, int line2, int index2, int style)
void RemoveStyle(int line1, int index1, int line2, int index2, int
style)
- modify the styling of a range of text.
Stylereplaces any existing style;AddStyleadds style style in addition to any existing styles;RemoveStyleremoves style style without affecting other existing styles. styles are specified as any combination of the constantsPlain,Boldface,Underlined, andReversed. mix and match, she contains multitudes π
π― the caret
void CaretStyle(int style)
void Caret(int line, int index)
- control the shape and position of a caret. valid caret styles are currently
NoCaret,BarCaret,UnderscoreCaretandOutlineCaret. important though bestie:TextDisplaydoes not automatically adjust the position of the caret following insertions and deletions. you gotta move her yourself π
π coordinates β text
int LineNumber(Coord y)
int LineIndex(int line, Coord x)
- map x and y display coordinates into line and index text coordinates.
LineNumberreturns the number of the line that contains the specified vertical position y.LineIndexreturns the index into line line that best corresponds to the specified horizontal position x. translation services, she provides them π«Ά
πΈ how big is she
Coord Width()
Coord Height()
- return the width or the height of the text currently displayed by the
TextDisplay.Widthreturns the width of the longest line in the display.Heightreturns the distance from the top of the topmost line to the bottom of the bottommost line. note that these dimensions do not necessarily correspond to theTextDisplay's bounds as returned byBounds. two different numbers, don't get it twisted π
β text β coordinates
Coord Base(int line)
Coord Top(int line)
Coord Left(int line, int index)
Coord Right(int line, int index)
- map line and index text coordinates into x and y display coordinates. the return values define a bounding box for the character specified by line and index. little box, big feelings π
π₯ SEE ALSO π₯
Painter(2I)Canvas(2I)
π that's the whole page bestie, every flag and function accounted for, nothing skipped, nothing invented. iykyk π
and that's a wrap!! this one's from InterViews, dated 23 May 1989, and honestly for a 1989 girlie she ate. mwah πβ¨
π¦ where this page comes from
- debian bookworm: ivtools-dev 2.0.11d.a1-1+b4
- debian trixie: ivtools-dev 2.0.11d.a1-3+b4
- ubuntu jammy: ivtools-dev 2.0.11d.a1-1build1
- ubuntu noble: ivtools-dev 2.0.11d.a1-3build1
- ubuntu questing: ivtools-dev 2.0.11d.a1-3build7
- ubuntu resolute: ivtools-dev 2.0.11d.a1-3build9
- ubuntu stonking: ivtools-dev 2.1.1+git.2025.07.26.a1-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms