1curs_get_wstr(3X) curs_get_wstr(3X)
2
3
4
6 get_wstr, getn_wstr, wget_wstr, wgetn_wstr, mvget_wstr, mvgetn_wstr,
7 mvwget_wstr, mvwgetn_wstr - get an array of wide characters from a
8 curses terminal keyboard
9
11 #include <curses.h>
12
13 int get_wstr(wint_t *wstr);
14 int getn_wstr(wint_t *wstr, int n);
15 int wget_wstr(WINDOW *win, wint_t *wstr);
16 int wgetn_wstr(WINDOW *win, wint_t *wstr, int n);
17 int mvget_wstr(int y, int x, wint_t *wstr);
18 int mvgetn_wstr(int y, int x, wint_t *wstr, int n);
19 int mvwget_wstr(WINDOW *win, int y, int x, wint_t *wstr);
20 int mvwgetn_wstr(WINDOW *win, int y, int x, wint_t *wstr, int n);
21
23 The effect of get_wstr is as though a series of calls to get_wch(3X)
24 were made, until a newline, other end-of-line, or end-of-file condition
25 is processed. An end-of-file condition is represented by WEOF, as de‐
26 fined in <wchar.h>. The newline and end-of-line conditions are repre‐
27 sented by the \n wchar_t value. In all instances, the end of the
28 string is terminated by a null wchar_t. The routine places resulting
29 values in the area pointed to by wstr.
30
31 The user's erase and kill characters are interpreted. If keypad mode
32 is on for the window, KEY_LEFT and KEY_BACKSPACE are both considered
33 equivalent to the user's kill character.
34
35 Characters input are echoed only if echo is currently on. In that
36 case, backspace is echoed as deletion of the previous character (typi‐
37 cally a left motion).
38
39 The effect of wget_wstr is as though a series of calls to wget_wch were
40 made.
41
42 The effect of mvget_wstr is as though a call to move and then a series
43 of calls to get_wch were made.
44
45 The effect of mvwget_wstr is as though a call to wmove and then a se‐
46 ries of calls to wget_wch were made.
47
48 The getn_wstr, mvgetn_wstr, mvwgetn_wstr, and wgetn_wstr functions are
49 identical to the get_wstr, mvget_wstr, mvwget_wstr, and wget_wstr func‐
50 tions, respectively, except that the *n_* versions read at most n char‐
51 acters, letting the application prevent overflow of the input buffer.
52
54 Using get_wstr, mvget_wstr, mvwget_wstr, or wget_wstr to read a line
55 that overflows the array pointed to by wstr causes undefined results.
56 The use of getn_wstr, mvgetn_wstr, mvwgetn_wstr, or wgetn_wstr, respec‐
57 tively, is recommended.
58
59 These functions cannot return KEY_ values because there is no way to
60 distinguish a KEY_ value from a valid wchar_t value.
61
62 All of these routines except wgetn_wstr may be macros.
63
65 All of these functions return OK upon successful completion. Other‐
66 wise, they return ERR.
67
68 Functions using a window parameter return an error if it is null.
69
70 wgetn_wstr
71 returns an error if the associated call to wget_wch failed.
72
73 Functions with a "mv" prefix first perform a cursor movement using
74 wmove, and return an error if the position is outside the window, or if
75 the window pointer is null.
76
78 These functions are described in The Single Unix Specification, Version
79 2. No error conditions are defined. This implementation returns ERR
80 if the window pointer is null, or if the lower-level wget_wch call re‐
81 turns an ERR. In the latter case, an ERR return without other data is
82 treated as an end-of-file condition, and the returned array contains a
83 WEOF followed by a null wchar_t.
84
85 X/Open curses documented these functions to pass an array of wchar_t in
86 1997, but that was an error because of this part of the description:
87
88 The effect of get_wstr() is as though a series of calls to
89 get_wch() were made, until a newline character, end-of-line
90 character, or end-of-file character is processed.
91
92 The latter function get_wch() can return a negative value, while
93 wchar_t is a unsigned type. All of the vendors implement this using
94 wint_t, following the standard.
95
96 X/Open Curses issue 7 is unclear regarding whether the terminating null
97 wchar_t value is counted in the length parameter n. X/Open Curses is‐
98 sue 7 revised the corresponding description of wgetnstr to address this
99 issue. The unrevised description of wget_nwstr can be interpreted ei‐
100 ther way. This implementation counts the terminator in the length.
101
102 X/Open Curses does not specify what happens if the length n is nega‐
103 tive.
104
105 · For analogy with wgetnstr, ncurses 6.2 uses a limit (based on
106 LINE_MAX).
107
108 · Some other implementations (such as Solaris xcurses) do the same,
109 while others (PDCurses) do not allow this.
110
111 · NetBSD 7 curses imitates ncurses 6.1 in this regard, treating a -1
112 as an indefinite number of characters.
113
115 Functions: curses(3X), curs_get_wch(3X), curs_getstr(3X).
116
117
118
119 curs_get_wstr(3X)