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 is true, the TextDisplay will 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. TextDisplay will not draw on any part of the canvas outside the specified bounds. conversely, TextDisplay is 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. Draw should be called before performing any operation on the TextDisplay which 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. InsertText and DeleteText will cause the following characters on the line to move to accommodate the changes. ReplaceText replaces 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. Style replaces any existing style; AddStyle adds style style in addition to any existing styles; RemoveStyle removes style style without affecting other existing styles. styles are specified as any combination of the constants Plain, Boldface, Underlined, and Reversed. 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, UnderscoreCaret and OutlineCaret. important though bestie: TextDisplay does 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. LineNumber returns the number of the line that contains the specified vertical position y. LineIndex returns 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. Width returns the width of the longest line in the display. Height returns 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 the TextDisplay's bounds as returned by Bounds. 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 πŸ’‹βœ¨