2 .\"***************************************************************************
3 .\" Copyright 2019-2023,2024 Thomas E. Dickey *
4 .\" Copyright 2001-2015,2017 Free Software Foundation, Inc. *
6 .\" Permission is hereby granted, free of charge, to any person obtaining a *
7 .\" copy of this software and associated documentation files (the *
8 .\" "Software"), to deal in the Software without restriction, including *
9 .\" without limitation the rights to use, copy, modify, merge, publish, *
10 .\" distribute, distribute with modifications, sublicense, and/or sell *
11 .\" copies of the Software, and to permit persons to whom the Software is *
12 .\" furnished to do so, subject to the following conditions: *
14 .\" The above copyright notice and this permission notice shall be included *
15 .\" in all copies or substantial portions of the Software. *
17 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 .\" Except as contained in this notice, the name(s) of the above copyright *
26 .\" holders shall not be used in advertising or otherwise to promote the *
27 .\" sale, use or other dealings in this Software without prior written *
29 .\"***************************************************************************
31 .\" $Id: curs_add_wch.3x,v 1.53 2024/01/13 22:05:39 tom Exp $
32 .TH curs_add_wch 3X 2024-01-13 "ncurses 6.4" "Library calls"
54 \fB\%wecho_wchar\fP \-
55 add a \fIcurses\fR complex character to a window and advance the cursor
58 \fB#include <curses.h>
60 \fBint add_wch(const cchar_t *\fIwch\fP);
61 \fBint wadd_wch(WINDOW *\fIwin\fP, const cchar_t *\fIwch\fP);
62 \fBint mvadd_wch(int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fP);
63 \fBint mvwadd_wch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fP);
65 \fBint echo_wchar(const cchar_t *\fIwch\fP);
66 \fBint wecho_wchar(WINDOW *\fIwin\fP, const cchar_t *\fIwch\fP);
75 functions put the complex character \fIwch\fP into the given
76 window at its current position,
77 which is then advanced.
78 These functions perform
79 wrapping and special-character processing as follows:
81 If \fIwch\fP refers to a spacing character,
82 then any previous character at that location is removed.
83 A new character specified by \fIwch\fP is
84 placed at that location with rendition specified by \fIwch\fP.
85 The cursor then advances after this spacing character,
86 to prepare for writing the next character on the screen.
88 The newly added spacing character is the base of the active complex character.
89 Subsequent non-spacing characters can be combined with this base
90 until another spacing character is written to the screen,
91 or the cursor is moved, e.g., using \fBwmove\fP.
93 If \fIwch\fP refers to a non-spacing character,
94 it is appended to the active complex character,
95 retaining the previous characters at that location.
96 The rendition specified by \fIwch\fP is ignored.
98 The cursor is not advanced after adding a non-spacing character.
99 Subsequent calls to add non-spacing characters will update the same position.
101 If the character part of \fIwch\fP is
102 a tab, newline, backspace or other control character,
103 the window is updated and the cursor moves as if \fBaddch\fP were called.
106 function is functionally equivalent to a call to
108 followed by a call to
112 is functionally equivalent to a call to
114 followed by a call to
117 that only a single character is being output is taken into consideration and,
118 for non-control characters, a considerable performance gain might be seen
119 by using the *\fBecho\fP* functions instead of their equivalents.
121 Like \fB\%addch\fP(3X),
122 \fBaddch_wch\fP accepts symbols which make it simple to draw lines and other
123 frequently used special characters.
124 These symbols correspond to the same VT100 line-drawing set as
131 \& Unicode ASCII acsc \&
132 ACS Name Default Default Char Glyph Name
134 WACS_BLOCK 0x25ae # 0 T{
137 WACS_BOARD 0x2592 # h board of squares
138 WACS_BTEE 0x2534 + v bottom tee
139 WACS_BULLET 0x00b7 o ~ bullet
140 WACS_CKBOARD 0x2592 : a T{
141 checker board (stipple)
143 WACS_DARROW 0x2193 v . T{
146 WACS_DEGREE 0x00b0 ' f degree symbol
147 WACS_DIAMOND 0x25c6 + \(ga diamond
148 WACS_GEQUAL 0x2265 > > T{
149 greater-than-or-equal-to
151 WACS_HLINE 0x2500 \- q horizontal line
152 WACS_LANTERN 0x2603 # i lantern symbol
153 WACS_LARROW 0x2190 < , T{
156 WACS_LEQUAL 0x2264 < y T{
157 less-than-or-equal-to
159 WACS_LLCORNER 0x2514 + m T{
160 lower left-hand corner
162 WACS_LRCORNER 0x2518 + j T{
163 lower right-hand corner
165 WACS_LTEE 0x2524 + t left tee
166 WACS_NEQUAL 0x2260 ! | not-equal
167 WACS_PI 0x03c0 * { greek pi
168 WACS_PLMINUS 0x00b1 # g plus/minus
169 WACS_PLUS 0x253c + n plus
170 WACS_RARROW 0x2192 > + T{
173 WACS_RTEE 0x251c + u right tee
174 WACS_S1 0x23ba \- o scan line 1
175 WACS_S3 0x23bb \- p scan line 3
176 WACS_S7 0x23bc \- r scan line 7
177 WACS_S9 0x23bd \&_ s scan line 9
178 WACS_STERLING 0x00a3 f } T{
179 pound-sterling symbol
181 WACS_TTEE 0x252c + w top tee
182 WACS_UARROW 0x2191 ^ \- T{
185 WACS_ULCORNER 0x250c + l T{
186 upper left-hand corner
188 WACS_URCORNER 0x2510 + k T{
189 upper right-hand corner
191 WACS_VLINE 0x2502 | x vertical line
194 The wide-character configuration of \fI\%ncurses\fP also defines symbols
195 for thick lines (\fBacsc\fP \*(``J\*('' to \*(``V\*(''):
201 \& Unicode ASCII acsc \&
202 ACS Name Default Default Char Glyph Name
204 WACS_T_BTEE 0x253b + V T{
205 thick tee pointing up
207 WACS_T_HLINE 0x2501 - Q T{
208 thick horizontal line
210 WACS_T_LLCORNER 0x2517 + M T{
211 thick lower left corner
213 WACS_T_LRCORNER 0x251b + J T{
214 thick lower right corner
216 WACS_T_LTEE 0x252b + T T{
217 thick tee pointing right
219 WACS_T_PLUS 0x254b + N T{
222 WACS_T_RTEE 0x2523 + U T{
223 thick tee pointing left
225 WACS_T_TTEE 0x2533 + W T{
226 thick tee pointing down
228 WACS_T_ULCORNER 0x250f + L T{
229 thick upper left corner
231 WACS_T_URCORNER 0x2513 + K T{
232 thick upper right corner
234 WACS_T_VLINE 0x2503 | X T{
239 and for double-lines (\fBacsc\fP \*(``A\*('' to \*(``I\*(''):
245 \& Unicode ASCII acsc \&
246 ACS Name Default Default Char Glyph Name
248 WACS_D_BTEE 0x2569 + H T{
249 double tee pointing up
251 WACS_D_HLINE 0x2550 - R T{
252 double horizontal line
254 WACS_D_LLCORNER 0x255a + D T{
255 double lower left corner
257 WACS_D_LRCORNER 0x255d + A T{
258 double lower right corner
260 WACS_D_LTEE 0x2560 + F T{
261 double tee pointing right
263 WACS_D_PLUS 0x256c + E T{
266 WACS_D_RTEE 0x2563 + G T{
267 double tee pointing left
269 WACS_D_TTEE 0x2566 + I T{
270 double tee pointing down
272 WACS_D_ULCORNER 0x2554 + C T{
273 double upper left corner
275 WACS_D_URCORNER 0x2557 + B T{
276 double upper right corner
278 WACS_D_VLINE 0x2551 | Y T{
283 Unicode's descriptions for these characters differs slightly from
285 by introducing the term \*(``light\*('' (along with less important details).
286 Here are its descriptions for the normal, thick, and double horizontal lines:
288 U+2500 BOX DRAWINGS LIGHT HORIZONTAL
290 U+2501 BOX DRAWINGS HEAVY HORIZONTAL
292 U+2550 BOX DRAWINGS DOUBLE HORIZONTAL
294 All routines return the integer \fBERR\fP upon failure and \fBOK\fP on success.
296 X/Open does not define any error conditions.
297 This implementation returns an error
299 if the window pointer is null or
301 if it is not possible to add a complete character in the window.
303 The latter may be due to different causes:
305 If \fB\%scrollok\fP(3X) is not enabled,
306 writing a character at the lower right margin succeeds.
308 an error is returned because it is not possible to wrap to a new line.
310 If an error is detected when converting a multibyte character to a sequence
312 or if it is not possible to add all of the resulting bytes in the window,
313 an error is returned.
315 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
316 \fBwmove\fP, and return an error if the position is outside the window,
317 or if the window pointer is null.
322 \fBmvwadd_wch\fP, and
326 These functions are described in the XSI Curses standard, Issue 4.
327 The defaults specified for line-drawing characters apply in the POSIX locale.
329 X/Open Curses makes it clear that the WACS_ symbols should be defined as
330 a pointer to \fBcchar_t\fP data, e.g., in the discussion of \fBborder_set\fP.
331 A few implementations are problematic:
333 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
335 HP-UX curses equates some of the \fBACS_\fP symbols
336 to the analogous \fBWACS_\fP symbols as if the \fBACS_\fP symbols were
338 The misdefined symbols are the arrows
339 and other symbols which are not used for line-drawing.
341 X/Open Curses does not define symbols for thick- or double-lines.
342 SVr4 curses implementations defined their line-drawing symbols in
343 terms of intermediate symbols.
344 This implementation extends those symbols, providing new definitions
345 which are not in the SVr4 implementations.
347 Not all Unicode-capable terminals provide support for VT100-style
348 alternate character sets (i.e., the \fBacsc\fP capability),
349 with their corresponding line-drawing characters.
350 X/Open Curses did not address the aspect of integrating Unicode with
351 line-drawing characters.
352 Existing implementations of Unix curses (AIX, HP-UX, Solaris)
353 use only the \fBacsc\fP character-mapping to provide this feature.
354 As a result, those implementations can only use single-byte line-drawing
356 \fI\%ncurses\fP 5.3 (2002) provided a table of Unicode values to solve
358 NetBSD curses incorporated that table in 2010.
360 In this implementation, the Unicode values are used instead of the
361 terminal description's \fBacsc\fP mapping as discussed in
362 \fB\%ncurses\fP(3X) for the environment variable
363 \fINCURSES_NO_UTF8_ACS\fP.
364 In contrast, for the same cases, the line-drawing characters
365 described in \fB\%addch\fP(3X) will use only the ASCII default values.
367 Having Unicode available does not solve all of the problems with
368 line-drawing for curses:
370 The closest Unicode equivalents to the
371 VT100 graphics \fIS1\fP, \fIS3\fP, \fIS7\fP and \fIS9\fP
372 frequently are not displayed at
373 the regular intervals which the terminal used.
375 The \fIlantern\fP is a special case.
376 It originated with the AT&T 4410 terminal in the early 1980s.
377 There is no accessible documentation depicting the lantern symbol
378 on the AT&T terminal.
380 Lacking documentation, most readers assume that a \fIstorm lantern\fP
382 But there are several possibilities, all with problems.
384 Unicode 6.0 (2010) does provide two lantern symbols: U+1F383 and U+1F3EE.
385 Those were not available in 2002, and are irrelevant since
386 they lie outside the BMP and as a result are not generally available
388 They are not storm lanterns, in any case.
390 Most \fIstorm lanterns\fP have a tapering glass chimney
391 (to guard against tipping);
392 some have a wire grid protecting the chimney.
394 For the tapering appearance, \[u2603] U+2603 was adequate.
395 In use on a terminal, no one can tell what the image represents.
396 Unicode calls it a snowman.
398 Others have suggested these alternatives:
399 \[sc] U+00A7 (section mark),
400 \[u0398] U+0398 (theta),
401 \[u03A6] U+03A6 (phi),
402 \[u03B4] U+03B4 (delta),
403 \[u2327] U+2327 (x in a rectangle),
404 \[u256C] U+256C (forms double vertical and horizontal), and
405 \[u2612] U+2612 (ballot box with x).
406 .SS "Complex Characters"
407 The complex character type \fBcchar_t\fR
408 can store more than one wide character (\fBwchar_t\fR).
409 The X/Open Curses description does not mention this possibility,
410 describing only the cases where \fIwch\fP is a spacing character
411 or a non-spacing character.
413 This implementation assumes that \fIwch\fP is constructed using
414 \fB\%setcchar\fP(3X), and in turn that the result
416 contains at most one spacing character in the beginning of its list of wide
418 and zero or more non-spacing characters
421 may hold one non-spacing character.
424 \fI\%ncurses\fP adds the non-spacing character to the active
425 (base) spacing character.
428 \fB\%curs_addch\fP(3X),
429 \fB\%curs_attr\fP(3X),
430 \fB\%curs_clear\fP(3X),
431 \fB\%curs_getcchar\fP(3X),
432 \fB\%curs_outopts\fP(3X),
433 \fB\%curs_refresh\fP(3X),