You may return to the Cvo Object Documenation Index from this document. This document contains the following sections describing the Cvo_CRT object:
Cvo_CRT
Cvo_Window
#include
<Cvo/CRT.h++>
new
Cvo_CRT ( char *resource_name,
{ Cvo_Object *parent | Display *display } )
The Cvo_CRT object provides the basic features needed for text display. It allows text to be displayed in a variety of fonts and colors, as well as to have multiple highlighted sections. The Cvo_CRT_Highlight object is used for highlighting sections.
This object defines the following member functions in addition to those defined by its parent and ancestor objects.
Flush (
)
Although this is defined by derived objects, it is important to note that text may not actually be displayed by the Cvo_CRT object until this has been called. This is so multiple writes of a single character do not constantly redraw portions of the screen.
InsertLine (
int line,
[ int count ] )
This function causes one or count lines to be inserted at line. When inserted at line zero, this has the effect of scrolling the Cvo_CRT display backwards, leaving the upper lines blank.
DeleteLine (
int line,
[ int count ] )
This function deletes one or count lines starting at line. When deleted at line zero, this has the effect of scrolling the Cvo_CRT display forwards, leaving the lower lines blank.
DeleteAt (
int line,
int column,
[ int count ] )
This function deletes one or count characters on line beginning at column.
InsertAt (
int line,
int column,
[ int count ] )
This function inserts 1 or count characters on line starting at column.
InsertAt (
int line,
int column,
{ wchar_t | char } *string,
[ int count ] )
This function inserts either count characters of string, or if
count is not specified, up to a NULL
character in string, on
line starting at column. Multibyte character strings will be
converted and any partial multibyte codes at the end of the string
will be discarded.
ReplaceAt (
int line,
int column,
{ wchar_t | char } *string,
[ int count ] )
This function replaces the characters on line starting at
column with either count characters of string, or if count is
not specified, up to a NULL
character in string. Multibyte
character strings will be converted and any partial multibyte codes
at the end of the string will be discarded.
AppendTo (
int line,
{ wchar_t | char } *string,
[ Cvo_TextAttribute **attrs ],
[ int count ] )
This function will append string to line, either up to a
NULL
character or up to count characters. If attrs is
specified, it contains an array of pointers to Cvo_TextAttribute
objects, one for each character, to be used in place of the current
attribute for the Cvo_CRT. It is problematical to use attrs with
a char *string
string argument.
MoveCursor (
int line,
int column )
This function moves the cursor to line at column.
ShowCursor (
)
This function causes the cursor to be displayed. By default the cursor is not displayed.
HideCursor (
)
This function causes the cursor to not be displayed.
BOOL OverFlowed (
int line )
This function returns a True
value if line has overflowed,
that is, if drawn text goes past the right edge of the drawable are.
AllocateLines (
int lines )
This function is typically used prior to creating or mapping a Cvo_CRT object to indicate how many lines of text you are going to preload with information, specified by lines. If this function is not used, text assigned to the Cvo_CRT prior to actual creation may be discarded.
ClearWindow( (
)
This function clears all the lines of text in the CRT.
ChangeOrigin (
int origin )
This function changes the pixel origin of the lines of text. By default the value is 0, but when a positive number is assigned to the origin, the text will be drawn as if it had been shifted origin pixels to the left. This is used for horizontal scrolling.
FixedWidth (
[ BOOL value ] )
This function is used to indicate that the Cvo_CRT contains a fixed
width font and certain "magic" may be applied to "wide characters" to
assume they are twice as wide as a normal character. This is to
support programs like vi
which make such assumptions. If
value is not given, or it is True
, the fixed width mode is
turned on. If value is False
, it is turned of..
JumpScroll (
[ BOOL value ] )
This function determines if jump scroll should be allowed. By default
jump scroll is turned off. If value is not given or is True
,
then jump scroll is turned on. If value is False
, it is
turned off.
int Rows (
)
This function returns the current number of rows on the Cvo_CRT. Note that this value may change as different sized fonts are used.
int Cols (
)
This function returns the current number of columns on the Cvo_CRT. Note that this value may change as different sized fonts are used.
int TabWidth (
)
This function returns the current character width of tabs. This defaults to 8, and can be changed via resources.
int PixelLengthOf (
int line )
This function returns the number of pixels required to draw line, in the horizontal direction. .pp)
int PixelHeightOf (
int line )
This function returns the number of pixels required to draw line, in the vertical direction.
void SetExtraPad (
int pad )
This function sets the amount of extra pad, in pixels, to place between
lines of text. This needs to be used if chamfers are to be drawn
around text. See the RaiseLine()
function below.
void RaiseLine (
int line )
Cause line to appear raised. This works best if SetExtraPad()
has been called with, for example, a value of two.
void FlattenLine (
int line )
This function causes line to no longer appear raised. This is
useful only after having called RaiseLine()
.
int FindLine (
int y )
This function returns the Cvo_CRT line on which pixel y in the vertical direction will be.
int FindColumn (
int line,
int x )
This function returns the column in line on which pixel x in the horizontal direction will be.
PixelToCharacter (
int *y,
int *x )
This function takes an (x, y) pixel pair and converts them to a (row, column) pair. The results are stored at the addresses pointed to by x and y.
Cvo_TextAttribute *SetState (
Cvo_TextAttribute *attr )
This function sets the current drawing attribute to be attr. It returns the previous attribute.
Cvo_CRT_Highlight *NewHighlight (
)
This function returns a new Cvo_CRT_Highlight that can be used to highlight text in the Cvo_CRT.
This object defines the following Cvo Events in addition to those defined by its parent and ancestor objects.
CvoTextChangedSizeEvent
struct
Cvo_TextChangedSizeEvent
int rows,
int width,
int oldrows,
int oldwidth
This event is sent whenever the number of rows, or the average number of characters in a row, changes. The rows and width elements of the event structure are the new number of rows and average number of characters per row, while oldrows and oldwidth are the previous values.
This object defines the following event translations in addition to those defined by its parent and ancestor objects.
<Btn1Down>
:
select-start()
<Btn1Down>(2)
:
select-start(WORD)
<Btn1Down>(3)
:
select-start(LINE)
<Btn1Motion>
:
select-extend()
<Btn3Down>
:
start-extend()
<Btn3Motion>
:
select-extend()
<Btn1Up>
:
select-end(PRIMARY, CUT_BUFFER0)
<Btn1Up>(2)
:
select-end(PRIMARY, CUT_BUFFER0)
<Btn1Up>(3)
:
select-end(PRIMARY, CUT_BUFFER0)
<Btn3Up>
:
select-end(PRIMARY, CUT_BUFFER0)
This object uses the following X resources in addition to those used by its parent and ancestor objects.
*CvoCRT.jumpScroll
(class:
JumpScroll
) (default value:
True
)
This resource determines whether or not the Cvo_CRT object will scroll line by line to a new position, or jump immediately to the new position.
*CvoCRT.tabStop
(class:
TabStop
) (default value:
8
)
*CvoCRT.selectionForeground
(class:
SelectionForeground
)
*CvoCRT.selectionBackground
(class:
SelectionBackground
)
This object modifies the following X resources which are used by its parent or other ancestors.
*CvoCRT*Sunken
(new value:
True
)
*CvoCRT*Pad
(new value:
2
)
*CvoCRT.Cursor
(new value:
xterm
)
*CvoCRT*FontFamily
(new value:
Helvetica
)
*CvoCRT*TabStop
(new value:
8
)
See the example source code for an example of how to use this object.
See the legend for information about the conventions used in this documentation.