Scroll to navigation

TextDisplay(3I) InterViews Reference Manual TextDisplay(3I)


TextDisplay - unstructured text display


#include <InterViews/textdisplay.h>


A TextDisplay manages and displays an array of lines of text. Operations are provided to insert and delete lines, to insert and delete text within a line, and to scroll the display. TextDisplays are typically used to implement interactors that require non-trivial display of unstructured text.

The array is addressed by a line number and an index into the line. Text can be inserted or deleted at arbitrary positions. 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. Each character in the array has an associated text style. Operations are provided to apply, add, or remove font styles to a range of the text. TextDisplay can be used with both constant-width and proportionally-spaced fonts and with arbitrary geometric transformations.


~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.
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.
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.
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.
Redraw a specified region of the display.
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.
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. The specified line need not refer to an existing line.
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.
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.
Control the shape and position of a caret. Valid caret styles are currently NoCaret, BarCaret, UnderscoreCaret and OutlineCaret. TextDisplay does not automatically adjust the position of the caret following insertions and deletions.
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.
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.
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.


Painter(2I), Canvas(2I)

23 May 1989 InterViews