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.
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.
4.1 Handling Wide-Character Data with curses Routines
The curses library provides functions for developing user interfaces on
character-cell terminals. The Digital UNIX curses library provides
functions for processing single-byte and multibyte characters. The recommended
functions for handling multibyte characters in wide-character or complex-character
format conform to Version 4 of the X/Open Curses CAE specification and supercede
those specified by the System V Multi-National Language Supplement (MNLS).Note
4.1.1 Writing a Wide Character to a curses Window
The following sections discuss different categories of routines that
add or insert individual wide characters on a curses window. There
are two categories of routines and these differ, partly due to whether the
cursor is advanced after the wide character is written.4.1.1.1 Add Wide Character (Overwrite) and Advance Cursor
The functions and macros in the following
table add a wide character, along with its attributes, to a window on the
screen and advance the cursor. If a character already exists at the target
position, the character is overwritten by the one being added.
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
|
4.1.1.2 Insert Wide Character (no Overwrite) and Do Not Advance Cursor
The following functions and macros insert a
wide character in a window at the current or specified coordinates and do
not change the position of the cursor after the write operation. The wide
character is inserted before an existing character at the target position,
so these interfaces do not overwrite characters that already exist on the
line. Existing characters at and to the right of the target position are moved
further to the right and the character in the rightmost position is truncated.
Your choice of interface in this category depends on whether you want to:
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:
4.1.2 Writing a Wide-Character String to a curses Window
The following sections discuss routines that add or insert wide-character
strings in curses windows.4.1.2.1 Add Wide-Character String (Overwrite) and Do Not Advance Cursor
The functions and macros in the following
table add a wide-character string, along with character attributes, to a window.
These interfaces:
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:
4.1.2.2 Add Wide-Character String (Overwrite) and Advance Cursor
Like the functions and macros discussed in
the preceding section, the interfaces in the following table also add a wide-character
string (but without video-character attributes) to a window and overwrite
existing characters. However, these interfaces also:
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:
4.1.2.3 Insert Wide-Character String (no Overwrite) and Do Not Advance Cursor
The functions and macros discussed in this
section insert a wide-character string before a target position in a curses window. These interfaces:
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:
4.1.3 Removing a Wide Character from a curses Window
The function and macros in the following table
delete a wide character at the target position in a curses window.
Characters that follow the deleted character on the line shift one character
to the left. These interfaces existed in the curses library before
multibyte characters were supported and have been redefined for correct handling
of wide-character format.
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:
4.1.4 Reading a Wide Character from a curses Window
The function and macros in this section read
a wide character, along with its video attributes, from a curses
window. The data returned to the program is of data type cchar_t,
so that both the wide character and its attributes are stored.
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:
4.1.5 Reading a Wide-Character String from a curses Windows
There are two sets of routines that allow you to read a wide-character
string from a curses window. Routines in one set retrieve strings
that include wide characters with their video attributes. Routines in the
other set strip attributes from the characters in the string.4.1.5.1 Reading Wide-Character Strings with Attributes
The function and macros in the following
table read a wide-character string, along with character attributes, from
a curses window. The string returned by the recommended interfaces
is of the data type cchar_t.
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:
4.1.5.2 Reading Wide-Character Strings Without Attributes
The function and macros in the following table
read a wide-character string from a curses window and return a
string of data type wchar_t. Video attributes are stripped from
the characters included in the string.
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:
4.1.6 Reading a String of Characters from a Terminal
The function and macros in the following table
get strings of characters from the terminal associated with a curses window and store the characters in a program buffer.
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:
4.1.7 Reading or Queuing a Wide Character from the Keyboard
Most functions or macros in the following table
get a single-byte or multibyte character from the terminal keyboard associated
with a curses window, convert the character to wide-character format,
and return the character to the program. Unless curses input mode
is set to noecho, these interfaces also echo each character back
to the screen.
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
|
Your choice of interface in this category depends on whether you:
4.1.8 Converting Formatted Text in a curses Window
The following functions read wide characters
from a curses window and convert them. These functions existed
in the curses library before it was internationalized and have
been enhanced to handle wide-character data. In all cases, these functions
call wgetstr to read a wide-character string from a window and
then interpret and convert characters according to scanf function
rules. Refer to the scanf
(3) reference page for more information.
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
|
Your choice of interface in this category depends on whether you need
to:
4.1.9 Printing Formatted Text on a curses Window
The functions in the following table format
a string and then print it on a curses window. The functions existed
in the curses library before it was internationalized and have
been redefined to process data in wide-character format. These functions are
analogous to printf (or vprintf) formatting the string
and then addstr (or waddstr) writing it. Refer to the printf
(3)
reference page for formatting information.
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.
4.2 Drawing Ruled Lines in a DECterm Window
Programming guides
for video terminals discuss how you use ANSI escape sequences to perform operations,
such as inserting and deleting characters, inserting and removing blank lines,
and requesting character display in double height and width. Because a DECterm
window is a terminal emulator, these escape sequences also apply to programs
that display text and graphics in a DECterm window.4.2.1 Drawing Ruled Lines in a Pattern
The escape sequence identified by the
mnemonic DECDRLBR draws ruled lines on the boundaries of a rectangular
area according to a specified pattern. The following table provides format
information:
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.
Figure 4-1: Drawing Ruled Lines with the DECDRLBR Sequence
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.
Figure 4-2: Bit Pattern for DECDRLBR Parameters
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.
4.2.2 Erasing Ruled Lines in a Pattern
The escape sequence DECERLBRP erases ruled lines
on the boundaries of a rectangular area according to a specified pattern.
The following table provides format information:
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.
|
4.2.3 Erasing All Ruled Lines in an Area
The escape sequence DECERLBRA
erases all ruled lines, not just those drawn on the area boundaries, in a
rectangular area. The following table provides format information:
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.
|
4.2.4 Interaction of Ruled Lines and Other DECterm Escape Sequences
Table 4-18 describes the effect of using standard
DECterm escape sequences when ruled lines are drawn on the screen.
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:
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.
4.2.5 Determining if the DECterm Device Setting Supports Ruled Lines
The feature that allows applications to draw ruled lines
is enabled only when a DECterm window is emulating a terminal type that supports
this feature. Your application can check for device support by requesting
primary device attributes from DECterm software.
CSI ? 63 ; 1 ; 2 ; 4 ; 5 ; 6 ; 7 ; 8 ; 10 ; 15 ; 43 c
4.3 DECterm Programming Restrictions
This section discusses DECterm software restrictions with respect to
terminal programming features discussed in hardware manuals.4.3.1 Downline Loadable Characters
DECterm software does not support
the downline loadable characters that are used for preloading and on-demand
loading of terminals. The software ignores the escape sequence for these characters.4.3.2 DRCS Characters
DECterm software supports only the Standard Character
Set (SCS) component of DRCS. When DECterm software receives the SCS characters,
it searches the X window server for the fonts with XLFD named as -*-dec-drcs and treats them as a soft character set. The software ignores the DECDLD
control string sent by the terminal programming application.