This chapter summarizes the curses functions and macros that process characters and character strings from the screen or keyboard. Tables in each section note if there is more than one curses interface available to perform the same operation, but only one handles wide-character or complex-character format and conforms to the X/Open Curses CAE specification. In such cases, make sure your application uses the curses interface listed in the Recommended Routine column of the table. The Section 3 reference pages provide syntax and detailed information for each interface. Use this chapter to determine the interface needed for the operation you want to do; then use the man or xman command to display the reference page for the chosen interface.
Some curses interfaces overwrite existing characters on the curses window. Only the interfaces that use the wchar_t or cchar_t data type ensure that overwriting does not leave partial characters on the screen. When the display width of an overwritten character is greater than one column, as may be the case for multibyte characters, these interfaces write extra blank characters to remove partial characters. For example, if the English character a overwrites the first column of a 2-column Chinese character, the second column of the Chinese character is overwritten with a blank. Note
Behavior is undefined when you overwrite multibyte characters with curses interfaces that have not been internationalized.
Your choice of interface depends on whether you need to:
Use the cchar_t data type to pass a wide character with its attributes to these interfaces.
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
add_wch | addch, addwch |
Window: default Position: current Screen refresh: no
|
wadd_wch | waddch, waddwch |
Window: specified Position: current Screen refresh: no
|
mvadd_wch | mvaddch, mvaddwch |
Window: default Position: specified Screen refresh: no
|
mvwadd_wch | mvwaddch, mvwaddwch |
Window: specified Position: specified Screen refresh: no
|
echo_wchar | echowchar |
Window: default Position: current Screen refresh: yes
|
wecho_wchar | wechowchar |
Window: specified Position: current Screen refresh: yes
|
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
ins_wch | insch, inswch |
Window: default Position: current
|
wins_wch | winsch, winswch |
Window: specified Position: current
|
mvins_wch | mvinsch, mvinswch |
Window: default Position: specified
|
mvwins_wch | mvwinsch, mvwinswch |
Window: specified Position: specified
|
Characters in the string that these interfaces add overwrite characters that already exist at the target position. Your choice of interface in this category depends on whether you need to:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
add_wchstr | addwchstr |
Number of characters: all Window: default Position: current
|
add_wchnstr | addwchnstr |
Number of characters: specified Window: default Position: current
|
wadd_wchstr | waddwchstr |
Number of characters: all Window: specified Position: current
|
wadd_wchnstr | waddwchnstr |
Number of characters: specified Window: specified Position: current
|
mvadd_wchstr | mvaddwchstr |
Number of characters: all Window: default Position: specified
|
mvadd_wchnstr | mvaddwchnstr |
Number of characters: specified Window: default Position: specified
|
mvwadd_wchstr | mvwaddwchstr |
Number of characters: all Window: specified Position: specified
|
mvwadd_wchnstr | mvwaddwchnstr |
Number of characters: specified Window: specified Position: specified
|
Your choice of interface in this category depends on whether you want to:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
addwstr | addstr |
Number of characters: all Window: default Position: current
|
addnwstr | -- |
Number of characters: specified Window: default Position: current
|
waddwstr | waddstr |
Number of characters: all Window: specified Position: current
|
waddnwstr | -- |
Number of characters: specified Window: specified Position: current
|
mvaddwstr | mvaddstr |
Number of characters: all Window: default Position: specified
|
mvaddnwstr | -- |
Number of characters: specified Window: default Position: specified
|
mvwaddwstr | mvwaddstr |
Number of characters: all Window: specified Position: specified
|
mvwaddnwstr | -- |
Number of characters: specified Window: specified Position: specified
|
Existing characters are not overwritten, but rightmost characters may be truncated at the end of the line.
Your choice of interface in this category depends on whether you need to:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
ins_wstr | inswstr |
Number of characters: all Window: default Position: current
|
ins_nwstr | insnwstr |
Number of characters: specified Window: default Position: current
|
wins_wstr | winswstr |
Number of characters: all Window: specified Position: current
|
wins_nwstr | winsnwstr |
Number of characters: specified Window: specified Position: current
|
mvins_wstr | mvinswstr |
Number of characters: all Window: default Position: specified
|
mvins_nwstr | mvinsnwstr |
Number of characters: specified Window: default Position: specified
|
mvwins_wstr | mvwinswstr |
Number of characters: all Window: specified Position: specified
|
mvwins_nwstr | mvwinsnwstr |
Number of characters: specified Window: specified Position: specified
|
Your choice of interface in this category depends on whether you need to:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
delch | same |
Window: default Position: current
|
wdelch | same |
Window: specified Position: current
|
mvdelch | same |
Window: default Position: specified
|
mvwdelch | same |
Window: specified Position: specified
|
Your choice of interface in this category depends on whether the character being read is:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
in_wch | inch, inwch |
Window: default Position: current
|
win_wch | winch, winwch |
Window: specified Position: current
|
mvin_wch | mvinch, mvinwch |
Window: default Position: specified
|
mvwin_wch | mvwinch, mvwinwch |
Window: specified Position: specified
|
Your choice of interface in this category depends on whether you want to:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
in_wchstr | inwchstr |
Number of characters: all Window: default Position: current
|
in_wchnstr | inwchnstr |
Number of characters: specified Window: default Position: current
|
win_wchstr | winwchstr |
Number of characters: all Window: specified Position: current
|
win_wchnstr | winwchnstr |
Number of characters: specified Window: specified Position: current
|
mvin_wchstr | mvinwchstr |
Number of characters: all Window: default Position: specified
|
mvin_wchnstr | mvinwchnstr |
Number of characters: specified Window: default Position: specified
|
mvwin_wchstr | mvwinwchstr |
Number of characters: all Window: specified Position: specified
|
mvwin_wchnstr | mvwinwchnstr |
Number of characters: specified Window: specified Position: specified
|
Your choice of interface in this category depends on whether you want to:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
inwstr | -- |
Number of characters: all Window: default Position: current
|
innwstr | -- |
Number of characters: specified Window: default Position: current
|
winwstr | -- |
Number of characters: all Window: specified Position: current
|
winnwstr | -- |
Number of characters: specified Window: specified Position: current
|
mvinwstr | -- |
Number of characters: all Window: default Position: specified
|
mvinnwstr | -- |
Number of characters: specified Window: default Position: specified
|
mvwinwstr | -- |
Number of characters: all Window: specified Position: specified
|
mvwinnwstr | -- |
Number of characters: specified Window: specified Position: specified
|
Your choice of interface in this category depends on whether you want to:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
get_wstr | getstr, getwstr |
Number of characters: all Window: default Position: current
|
getn_wstr | getnwstr |
Number of characters: specified Window: default Position: current
|
wget_wstr | wgetstr, wgetwstr |
Number of characters: all Window: specified Position: current
|
wgetn_wstr | wgetnwstr |
Number of characters: specified Window: specified Position: current
|
mvget_wstr | mvgetstr, mvgetwstr |
Number of characters: all Window: default Position: specified
|
mvgetn_wstr | mvgetnwstr |
Number of characters: specified Window: default Position: specified
|
mvwget_wstr | mvwgetstr, mvwgetwstr |
Number of characters: all Window: specified Position: specified
|
mvwgetn_wstr | mvwgetnwstr |
Number of characters: specified Window: specified Position: specified
|
The unget_wch interface places the wide character at the head of the input queue. In this case, the next call to wget_wch returns the character from the input queue to the program.
Your choice of interface in this category depends on whether you get the character for:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
get_wch | getch, getwch |
Window: uses default Position: uses current
|
wget_wch | wgetch, wgetwch |
Window: uses specified Position: uses current
|
mvget_wch | mvgetch, mvgetwch |
Window: uses default Position: uses specified
|
mvwget_wch | mvwgetch, mvwgetwch |
Window: uses specified Position: uses specified
|
unget_wch | ungetch, ungetwch |
Window: not applicable Position: not applicable Input queue: queues character
|
scanf
(3) reference page for more information.Your choice of interface in this category depends on whether you:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
scanw | same |
Window: default Position: current Number of arguments: fixed
|
wscanw | same |
Window: specified Position: current Number of arguments: fixed
|
mvscanw | same |
Window: default Position: specified Number of arguments: fixed
|
mvwscanw | same |
Window: specified Position: specified Number of arguments: fixed
|
vw_scanw | vwscanw |
Window: specified Position: current Number of arguments: variable
|
printf
(3)
reference page for formatting information.Your choice of interface in this category depends on whether you need to:
Recommended Routine | Used in Place of: | Behavior with Respect to: |
---|---|---|
printw | same |
Window: default Position: current Number of arguments: fixed
|
wprintw | same |
Window: specified Position: current Number of arguments: fixed
|
mvprintw | same |
Window: default Position: specified Number of arguments: fixed
|
mvwprintw | same |
Window: specified Position: specified Number of arguments: fixed
|
vw_printw | vwprintw |
Window: specified Position: current Number of arguments: variable
|
Digital UNIX enhancements for Asian languages include additional escape sequences for drawing and removing ruled lines in a specified area of a DECterm window. These additional escape sequences allow applications to construct tables and diagrams. The feature is a market requirement for Japanese terminals but has been incorporated into DECterm software for all terminal types.
The following sections describe the escape sequences that draw and erase lines according to pattern and area parameters.
Mnemonic | Description | Sequence |
---|---|---|
DECDRLBR | Draws ruled lines on the boundaries of a rectangular area | CSI P1;Px;Plx;Py;Ply ,r
where: P1 indicates the pattern of drawing ruled lines. P1 indicates whether lines are drawn on all sides of the rectangular area, on the left and right sides only, on the top and bottom only, and so forth. Px indicates the absolute position of the start point in columns. Plx indicates the width of the area in columns. Py indicates the absolute position of the start point in rows. Ply indicates the height of the area in rows.
|
When the DECDRLBR escape sequence is received from an application, DECterm software draws ruled lines on one or more of the boundaries of the area between the coordinates(Px,Py ) and(Px+Plx-1, Py+Ply -1) according to the pattern specified in P1. Consider the following example:
CSI 15 ; 1 ; 5 ; 1 ; 2 , r
The preceding escape sequence causes DECterm software to draw ruled lines as shown in Figure 4-1.
DECterm software draws ruled lines that are one pixel in width. When the display scrolls, these lines correctly scroll as if text.
Figure 4-2 and the table following the figure describe the bit pattern that the DECDRLBR parameters map to.
Bit | Bit Value | Description |
---|---|---|
Bit 0 | 1 | Draws line on the bottom boundary |
Bit 1 | 2 | Draws line on the right boundary |
Bit 2 | 4 | Draws line on the top boundary |
Bit 3 | 8 | Draws line on the left boundary |
The pattern is a bitmask that controls how the ruled lines are drawn on the boundaries of the area. Ruled lines are drawn according to whether the bits for the boundaries are set on or off. For example, ruled lines are drawn on all boundaries if P1 is set to 15 and on the top and bottom boundary if P1 is set to 5:
Boundary : Bottom Right Top Left P1 = Bit0 + Bit1 + Bit2 + Bit3 P1 = 1 + 2 + 4 + 8 = 15 P1 = 1 + 4 = 5
Px is the starting column position and Py is the starting row position. If you omit these parameters or explicitly set them to 0 (zero), the starting position is at column 1 and row 1. In other words, the upper left corner of the rectangle is at the coordinates (1,1).
Plx is the width of the area in columns and Ply is the height of the area in rows. If you omit these parameters or explicitly set them to 0 (zero), the area is 1 column in width and 1 row in height.
Mnemonic | Description | Sequence |
---|---|---|
DECERLBRP | Erases ruled lines on the boundaries of a rectangular area | CSI P1;Px;Plx;Py ,s
where:
P1 indicates the pattern of drawing ruled lines. P1 indicates whether lines are drawn on all sides of the rectangular
area, on the left and right sides only, on the top and bottom only, and so
forth. Px indicates the absolute position of the start point in columns. Plx indicates the width of the area in columns. Py indicates the absolute position of the start point in rows. Ply indicates the height of the area in rows.
|
Mnemonic | Description | Sequence |
---|---|---|
DECERLBRA | Erases ruled lines within a rectangular area | CSI P1;Px;Plx;Py;Ply ,t where:
P1 determines whether
the area encompasses the entire display screen or a specific section of the
screen. When P1 is the value 1, DECterm software erases all ruled
lines on the screen. In this case, the parameters Px, Plx, Py, and Ply are ignored. When P1
is the value 2, DECterm software erases all ruled lines within a rectangular
area defined by the parameters Px, Plx, Py,
and Ply. When P1 is omitted or explicitly set to 0 (zero),
DECterm software erases all ruled lines on the screen (the same result as
for the value 1, which is the default). Px indicates the absolute position of the start point in columns. Plx indicates the width of the area in columns. Py indicates the absolute position of the start point in rows. Ply indicates the height of the area in rows.
|
Mnemonic | Description | Effect on Ruled Lines |
---|---|---|
DECDWL, DECDHLT, DECDHLB | Display as double width or double height | These escape sequences have no effect on ruled lines, whose width is always one pixel. Furthermore, the parameter units for the escape sequences controlling ruled line display are always specified in terms of single width and single height columns and rows, even when the escape sequences are used with those that double the height and width of text. |
GSM | Modify graphic size | These escape sequences have no effect on ruled lines, whose width is always one pixel. Comments made in the entry for DECDWL, DECDHLT, and DECDHLB also apply to GSM. |
ED, EL, ECH | Erase display, erase line, and erase character | These escape sequences do not erase ruled
lines, only the characters within the boundaries of the ruled lines. For example:
+------+------+ +------+------+ |ABCDEF|abcdef| | | | +------+------+ --> +------+------+ |123456|123456| | | | +------+------+ +------+------+ |
DL | Delete line | This escape sequence erases both lines of
characters and ruled lines at the active position of deletion. The text lines
and accompanying ruled lines that follow the deletion point are scrolled up.
For example:
+------+------+ +------+------+ |ABCDEF|abcdef| |123456|123456| +------+------+ --> +------+------+ |123456|123456| +------+------+ |
IL | Insert line | This escape sequence causes insertion of
blank lines at the active position. It causes both text and accompanying ruled
lines currently at the active position to be scrolled down. For example:
+------+------+ |ABCDEF|abcdef| +------+------+ --> +------+------+ |123456|123456| |ABCDEF|abcdef| +------+------+ +------+------+ |123456|123456| +------+------+ |
DCH | Delete character | This escape sequence does not delete ruled
lines. The following example shows the result of deleting four characters
at the third column position:
+------+------+ +------+------+ |ABCDEF|abcdef| |ABabcd|ef | +------+------+ --> +------+------+ |123456|123456| |123456|123456| +------+------+ +------+------+ |
ICH | Insert character | This escape sequence causes blank spaces
to be inserted at the active position but has no effect on ruled lines. The
following example shows the result of inserting four characters at the third
column position:
+------+------+ +------+------+ |ABCDEF|abcdef| |AB |CDEFab|cdef +------+------+ --> +------+------+ |123456|123456| |123456|123456| +------+------+ +------+------+ |
IRM | Invoke insert/replace mode | Insert/replace mode has no effect on ruled
lines. The following example shows the result of inserting the characters
w, x, y, and z at the third column position and replacing the character f
with s:
+------+------+ +------+------+ |ABCDEF|abcdef| |ABwxyz|CDEFab|cdes +------+------+ --> +------+------+ |123456|123456| |123456|123456| +------+------+ +------+------+ |
DECCOLM | Invoke column mode | Ruled lines are erased with accompanying text when column mode is in effect. |
RIS, DECSTR | Reset to initial state and soft terminal, invoke reset SETUP mode | The RIS sequence erases all ruled lines displayed on the screen while the DECSTR sequence does not. Note that the Clear Display option on the DECterm Commands menu erases all ruled lines whereas the Reset Terminal option does not. |
VT terminals and DECterm software return a primary device attributes report on request from applications. If the extension value 43 is included in this report, drawing ruled lines is enabled for the device. This extension is valid at a level-2 video display or higher. For example, if a DECterm window is emulating a VT382-J terminal, which is the Japanese version of a VT382, the primary device attributes are generated as follows:
CSI ? 63 ; 1 ; 2 ; 4 ; 5 ; 6 ; 7 ; 8 ; 10 ; 15 ; 43 c
Applications can send either the CSI c or CSI 0 c escape sequence to a VT terminal or DECterm software to request a device attributes report.