]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_add_wch.3x
ncurses 6.4 - patch 20230715
[ncurses.git] / man / curs_add_wch.3x
1 .\"***************************************************************************
2 .\" Copyright 2019-2021,2023 Thomas E. Dickey                                *
3 .\" Copyright 2001-2015,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_add_wch.3x,v 1.37 2023/07/15 16:45:14 tom Exp $
31 .TH curs_add_wch 3X 2023-07-15 "ncurses 6.4" "Library calls"
32 .ie \n(.g .ds `` \(lq
33 .el       .ds `` ``
34 .ie \n(.g .ds '' \(rq
35 .el       .ds '' ''
36 .de bP
37 .ie n  .IP \(bu 4
38 .el    .IP \(bu 2
39 ..
40 .SH NAME
41 \fBadd_wch\fP,
42 \fBwadd_wch\fP,
43 \fBmvadd_wch\fP,
44 \fBmvwadd_wch\fP,
45 \fBecho_wchar\fP,
46 \fBwecho_wchar\fP \- add a complex character and rendition to a \fBcurses\fP window, then advance the cursor
47 .SH SYNOPSIS
48 \fB#include <curses.h>\fP
49 .sp
50 .B "int add_wch( const cchar_t *\fIwch\fB );"
51 .br
52 .B "int wadd_wch( WINDOW *\fIwin\fP, const cchar_t *\fIwch\fB );"
53 .br
54 .B "int mvadd_wch( int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fB );"
55 .br
56 .B "int mvwadd_wch( WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fB );"
57 .sp
58 .B "int echo_wchar( const cchar_t *\fIwch\fB );"
59 .br
60 .B "int wecho_wchar( WINDOW *\fIwin\fP, const cchar_t *\fIwch\fB );"
61 .SH DESCRIPTION
62 .SS add_wch
63 The
64 \fBadd_wch\fP,
65 \fBwadd_wch\fP,
66 \fBmvadd_wch\fP, and
67 \fBmvwadd_wch\fP
68 functions put the complex character \fIwch\fP into the given
69 window at its current position,
70 which is then advanced.
71 These functions perform
72 wrapping and special-character processing as follows:
73 .bP
74 If \fIwch\fP refers to a spacing character,
75 then any previous character at that location is removed.
76 A new character specified by \fIwch\fP is
77 placed at that location with rendition specified by \fIwch\fP.
78 The cursor then advances after this spacing character,
79 to prepare for writing the next character on the screen.
80 .IP
81 The newly added spacing character is the base of the active complex character.
82 Subsequent non-spacing characters can be combined with this base
83 until another spacing character is written to the screen,
84 or the cursor is moved, e.g., using \fBwmove\fP.
85 .bP
86 If \fIwch\fP refers to a non-spacing character,
87 it is appended to the active complex character,
88 retaining the previous characters at that location.
89 The rendition specified by \fIwch\fP is ignored.
90 .IP
91 The cursor is not advanced after adding a non-spacing character.
92 Subsequent calls to add non-spacing characters will update the same position.
93 .bP
94 If the character part of \fIwch\fP is
95 a tab, newline, backspace or other control character,
96 the window is updated and the cursor moves as if \fBaddch\fP were called.
97 .SS echo_wchar
98 The \fBecho_wchar\fP
99 function is functionally equivalent to a call to
100 \fBadd_wch\fP
101 followed by a call to
102 \fBrefresh\fP(3X).
103 Similarly, the
104 \fBwecho_wchar\fP
105 is functionally equivalent to a call to
106 \fBwadd_wch\fP
107 followed by a call to
108 \fBwrefresh\fP.
109 The knowledge
110 that only a single character is being output is taken into consideration and,
111 for non-control characters, a considerable performance gain might be seen
112 by using the *\fBecho\fP* functions instead of their equivalents.
113 .SS Line Graphics
114 Like \fBaddch\fP(3X),
115 \fBaddch_wch\fP accepts symbols which make it simple to draw lines and other
116 frequently used special characters.
117 These symbols correspond to the same VT100 line-drawing set as
118 \fBaddch\fP(3X).
119 .PP
120 .TS
121 l l l l l
122 l l l l l
123 _ _ _ _ _
124 lw(1.5i) lw5 lw5 lw5 lw20.
125 \fBACS\fP       \fBUnicode\fP   \fBASCII\fP     \fBacsc\fP      \fBGlyph\fP
126 \fBName\fP      \fBDefault\fP   \fBDefault\fP   \fBchar\fP      \fBName\fP
127 WACS_BLOCK      0x25ae  #       0       solid square block
128 WACS_BOARD      0x2592  #       h       board of squares
129 WACS_BTEE       0x2534  +       v       bottom tee
130 WACS_BULLET     0x00b7  o       ~       bullet
131 WACS_CKBOARD    0x2592  :       a       checker board (stipple)
132 WACS_DARROW     0x2193  v       .       arrow pointing down
133 WACS_DEGREE     0x00b0  '       f       degree symbol
134 WACS_DIAMOND    0x25c6  +       `       diamond
135 WACS_GEQUAL     0x2265  >       >       greater-than-or-equal-to
136 WACS_HLINE      0x2500  \-      q       horizontal line
137 WACS_LANTERN    0x2603  #       i       lantern symbol
138 WACS_LARROW     0x2190  <       ,       arrow pointing left
139 WACS_LEQUAL     0x2264  <       y       less-than-or-equal-to
140 WACS_LLCORNER   0x2514  +       m       lower left-hand corner
141 WACS_LRCORNER   0x2518  +       j       lower right-hand corner
142 WACS_LTEE       0x2524  +       t       left tee
143 WACS_NEQUAL     0x2260  !       |       not-equal
144 WACS_PI 0x03c0  *       {       greek pi
145 WACS_PLMINUS    0x00b1  #       g       plus/minus
146 WACS_PLUS       0x253c  +       n       plus
147 WACS_RARROW     0x2192  >       +       arrow pointing right
148 WACS_RTEE       0x251c  +       u       right tee
149 WACS_S1 0x23ba  \-      o       scan line 1
150 WACS_S3 0x23bb  \-      p       scan line 3
151 WACS_S7 0x23bc  \-      r       scan line 7
152 WACS_S9 0x23bd  \&_     s       scan line 9
153 WACS_STERLING   0x00a3  f       }       pound-sterling symbol
154 WACS_TTEE       0x252c  +       w       top tee
155 WACS_UARROW     0x2191          ^       \-      arrow pointing up
156 WACS_ULCORNER   0x250c  +       l       upper left-hand corner
157 WACS_URCORNER   0x2510  +       k       upper right-hand corner
158 WACS_VLINE      0x2502  |       x       vertical line
159 .TE
160 .PP
161 The wide-character configuration of ncurses also defines symbols
162 for thick lines (\fBacsc\fP \*(``J\*('' to \*(``V\*(''):
163 .TS
164 l l l l l
165 l l l l l
166 _ _ _ _ _
167 lw(1.5i) lw5 lw5 lw5 lw20.
168 \fBACS\fP       \fBUnicode\fP   \fBASCII\fP     \fBacsc\fP      \fBGlyph\fP
169 \fBName\fP      \fBDefault\fP   \fBDefault\fP   \fBchar\fP      \fBName\fP
170 WACS_T_BTEE     0x253b  +       V       thick tee pointing up
171 WACS_T_HLINE    0x2501  -       Q       thick horizontal line
172 WACS_T_LLCORNER 0x2517  +       M       thick lower left corner
173 WACS_T_LRCORNER 0x251b  +       J       thick lower right corner
174 WACS_T_LTEE     0x252b  +       T       thick tee pointing right
175 WACS_T_PLUS     0x254b  +       N       thick large plus
176 WACS_T_RTEE     0x2523  +       U       thick tee pointing left
177 WACS_T_TTEE     0x2533  +       W       thick tee pointing down
178 WACS_T_ULCORNER 0x250f  +       L       thick upper left corner
179 WACS_T_URCORNER 0x2513  +       K       thick upper right corner
180 WACS_T_VLINE    0x2503  |       X       thick vertical line
181 .TE
182 .PP
183 and for double-lines (\fBacsc\fP \*(``A\*('' to \*(``I\*(''):
184 .PP
185 .TS
186 l l l l l
187 l l l l l
188 _ _ _ _ _
189 lw(1.5i) lw5 lw5 lw5 lw20.
190 \fBACS\fP       \fBUnicode\fP   \fBASCII\fP     \fBacsc\fP      \fBGlyph\fP
191 \fBName\fP      \fBDefault\fP   \fBDefault\fP   \fBchar\fP      \fBName\fP
192 WACS_D_BTEE     0x2569  +       H       double tee pointing up
193 WACS_D_HLINE    0x2550  -       R       double horizontal line
194 WACS_D_LLCORNER 0x255a  +       D       double lower left corner
195 WACS_D_LRCORNER 0x255d  +       A       double lower right corner
196 WACS_D_LTEE     0x2560  +       F       double tee pointing right
197 WACS_D_PLUS     0x256c  +       E       double large plus
198 WACS_D_RTEE     0x2563  +       G       double tee pointing left
199 WACS_D_TTEE     0x2566  +       I       double tee pointing down
200 WACS_D_ULCORNER 0x2554  +       C       double upper left corner
201 WACS_D_URCORNER 0x2557  +       B       double upper right corner
202 WACS_D_VLINE    0x2551  |       Y       double vertical line
203 .TE
204 .PP
205 Unicode's descriptions for these characters differs slightly from ncurses,
206 by introducing the term \*(``light\*('' (along with less important details).
207 Here are its descriptions for the normal, thick, and double horizontal lines:
208 .bP
209 U+2500 BOX DRAWINGS LIGHT HORIZONTAL
210 .bP
211 U+2501 BOX DRAWINGS HEAVY HORIZONTAL
212 .bP
213 U+2550 BOX DRAWINGS DOUBLE HORIZONTAL
214 .SH RETURN VALUE
215 All routines return the integer \fBERR\fP upon failure and \fBOK\fP on success.
216 .PP
217 X/Open does not define any error conditions.
218 This implementation returns an error
219 .bP
220 if the window pointer is null or
221 .bP
222 if it is not possible to add a complete character in the window.
223 .PP
224 The latter may be due to different causes:
225 .bP
226 If \fBscrollok\fP(3X) is not enabled,
227 writing a character at the lower right margin succeeds.
228 However, an error is returned because
229 it is not possible to wrap to a new line
230 .bP
231 If an error is detected when converting a multibyte character to a sequence
232 of bytes,
233 or if it is not possible to add all of the resulting bytes in the window,
234 an error is returned.
235 .PP
236 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
237 \fBwmove\fP, and return an error if the position is outside the window,
238 or if the window pointer is null.
239 .SH NOTES
240 Note that
241 \fBadd_wch\fP,
242 \fBmvadd_wch\fP,
243 \fBmvwadd_wch\fP, and
244 \fBecho_wchar\fP
245 may be macros.
246 .SH PORTABILITY
247 All of these functions are described in the XSI Curses standard, Issue 4.
248 The defaults specified for line-drawing characters apply in the POSIX locale.
249 .SS WACS Symbols
250 X/Open Curses makes it clear that the WACS_ symbols should be defined as
251 a pointer to \fBcchar_t\fP data, e.g., in the discussion of \fBborder_set\fP.
252 A few implementations are problematic:
253 .bP
254 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
255 .bP
256 HPUX curses equates some of the \fBACS_\fP symbols
257 to the analogous \fBWACS_\fP symbols as if the \fBACS_\fP symbols were
258 wide characters.
259 The misdefined symbols are the arrows
260 and other symbols which are not used for line-drawing.
261 .PP
262 X/Open Curses does not define symbols for thick- or double-lines.
263 SVr4 curses implementations defined their line-drawing symbols in
264 terms of intermediate symbols.
265 This implementation extends those symbols, providing new definitions
266 which are not in the SVr4 implementations.
267 .PP
268 Not all Unicode-capable terminals provide support for VT100-style
269 alternate character sets (i.e., the \fBacsc\fP capability),
270 with their corresponding line-drawing characters.
271 X/Open Curses did not address the aspect of integrating Unicode with
272 line-drawing characters.
273 Existing implementations of Unix curses (AIX, HPUX, Solaris)
274 use only the \fBacsc\fP character-mapping to provide this feature.
275 As a result, those implementations can only use single-byte line-drawing
276 characters.
277 Ncurses 5.3 (2002) provided a table of Unicode values to solve these problems.
278 NetBSD curses incorporated that table in 2010.
279 .PP
280 In this implementation, the Unicode values are used instead of the
281 terminal description's \fBacsc\fP mapping as discussed in ncurses(3X)
282 for the environment variable \fBNCURSES_NO_UTF8_ACS\fP.
283 In contrast, for the same cases, the line-drawing characters
284 described in \fBcurs_addch\fP(3X) will use only the ASCII default values.
285 .PP
286 Having Unicode available does not solve all of the problems with
287 line-drawing for curses:
288 .bP
289 The closest Unicode equivalents to the
290 VT100 graphics \fIS1\fP, \fIS3\fP, \fIS7\fP and \fIS9\fP
291 frequently are not displayed at
292 the regular intervals which the terminal used.
293 .bP
294 The \fIlantern\fP is a special case.
295 It originated with the AT&T 4410 terminal in the early 1980s.
296 There is no accessible documentation depicting the lantern symbol
297 on the AT&T terminal.
298 .IP
299 Lacking documentation, most readers assume that a \fIstorm lantern\fP
300 was intended.
301 But there are several possibilities, all with problems.
302 .IP
303 Unicode 6.0 (2010) does provide two lantern symbols: U+1F383 and U+1F3EE.
304 Those were not available in 2002, and are irrelevant since
305 they lie outside the BMP and as a result are not generally available
306 in terminals.
307 They are not storm lanterns, in any case.
308 .IP
309 Most \fIstorm lanterns\fP have a tapering glass chimney
310 (to guard against tipping);
311 some have a wire grid protecting the chimney.
312 .IP
313 For the tapering appearance, \[u2603] U+2603 was adequate.
314 In use on a terminal, no one can tell what the image represents.
315 Unicode calls it a snowman.
316 .IP
317 Others have suggested these alternatives:
318 \[sc] U+00A7 (section mark),
319 \[u0398] U+0398 (theta),
320 \[u03A6] U+03A6 (phi),
321 \[u03B4] U+03B4 (delta),
322 \[u2327] U+2327 (x in a rectangle),
323 \[u256C] U+256C (forms double vertical and horizontal), and
324 \[u2612] U+2612 (ballot box with x).
325 .SS Complex Characters
326 The complex character type \fBcchar_t\fR
327 can store more than one wide character (\fBwchar_t\fR).
328 The X/Open Curses description does not mention this possibility,
329 describing only the cases where \fIwch\fP is a spacing character
330 or a non-spacing character.
331 .PP
332 This implementation assumes that \fIwch\fP is constructed using
333 \fBsetcchar\fP(3X), and in turn that the result
334 .bP
335 contains at most one spacing character in the beginning of its list of wide
336 characters,
337 and zero or more non-spacing characters
338 or
339 .bP
340 may hold one non-spacing character.
341 .PP
342 In the latter case, ncurses adds the non-spacing character to the active
343 (base) spacing character.
344 .SH SEE ALSO
345 .na
346 .hy 0
347 \fBcurses\fP(3X),
348 \fBcurs_addch\fP(3X),
349 \fBcurs_attr\fP(3X),
350 \fBcurs_clear\fP(3X),
351 \fBcurs_getcchar\fP(3X),
352 \fBcurs_outopts\fP(3X),
353 \fBcurs_refresh\fP(3X),
354 \fBputwc\fP(3)