Next: , Previous: , Up: The basic curses library   [Contents][Index]


5.2.6 Outputting characters

There are two primary functions that add a rendered character to a curses window, and then advance the cursor.

Procedure: addch win ch #:key y x

The addch routine puts the rendered character ch into the given window at its current window position, which is then advanced. If the advance is at the right margin, the cursor automatically wraps to the beginning of the next line. At the bottom of the current scrolling region, if scrollok! is enabled, the scrolling region is scrolled up one line.

If ch is a tab, newline, or backspace, the cursor is moved appropriately within the window. Backspace moves the cursor one character left; at the left edge of a window it does nothing. Newline does a clrtoeol, then moves the cursor to the window left margin on the next line, scrolling the window if on the last line. Tabs are considered to be at every eighth column. The tab interval may be altered with the set-tabsize! procedure.

If ch is any control character other than TAB, CR, or BS, it is drawn in ^X notation. Calling inch after adding a control character does not return the character itself, but instead returns the ^-representation of the control character.

Since ch is a rendered character, the rendition will be applied to the character when it is put on the screen.

This function returns #t on success and #f otherwise. A #f usually indicates an attempt to add a character that won’t fit on the screen or that would cause a wrap or scroll in a window that doesn’t wrap or scroll.

Procedure: echochar win ch #:key y x

The echochar routine is equivalent to a call to addch followed by a call to refresh. The knowledge that only a single character is being output allows for efficiency.

This function returns #t on success and #f otherwise. A #f usually indicates an attempt to add a character that won’t fit on the screen or that would cause a wrap or scroll in a window that doesn’t wrap or scroll.

Procedure: tabsize

Returns the current tabsize for this screen. The default is eight.

Procedure: set-tabsize! tab

Sets the tabsize for this screen to tab characters.

Its return value is unspecified.

5.2.6.1 Line Graphics

The line-graphics procedures may be used to add line drawing characters to the screen with routines of the addch family. Not all terminals have line-graphics characters. There is a default character listed below is used if the acsc capability doesn’t define a terminal-specific replacement for it. The names are taken from VT100 nomenclature. Each of these procedures takes no arguments and returns a rendered character with the ’normal’ attribute and with the default color pair. The following prints a less-than-or-equal-to sign to the window win, for example.

(addch win (normal (acs-lequal)))

The set of line-graphics characters is given in Table 5.1.

namedefaultdescription
acs-block#solid square block
acs-board#board of squares
acs-btee+bottom tee
acs-bulletobullet
acs-ckboard:checker board (stipple)
acs-darrowvarrow pointing down
acs-degreedegree symbol
acs-diamond+diamond
acs-gequal>greater-than-or-equal-to
acs-hline-horizontal line
acs-lantern#lantern symbol
acs-larrow<arrow pointing left
acs-lequal<less-than-or-equal-to
acs-llcorner+lower left-hand corner
acs-lrcorner+lower right-hand corner
acs-ltee+left tee
acs-nequal!not-equal
acs-pi*greek pi
acs-plminus#plus/minus
acs-plus+plus
acs-rarrow>arrow pointing right
acs-rtee+right tee
acs-s1-scan line 1
acs-s3-scan line 3
acs-s7-scan line 7
acs-s9_scan line 9
acs-sterlingfpound-sterling symbol
acs-ttee+top tee
acs-uarrow^arrow pointing up
acs-ulcorner+upper left-hand corner
acs-urcorner+upper right-hand corner
acs-vline|vertical line

Table 5.1: the line-graphics procedures


Next: , Previous: , Up: The basic curses library   [Contents][Index]