2 .\"***************************************************************************
3 .\" Copyright 2019-2021,2023 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.49 2023/12/16 21:19:37 tom Exp $
32 .TH curs_add_wch 3X 2023-12-16 "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 lw(1.5i) lw5 lw5 lw5 lw20.
132 \fBACS\fP \fBUnicode\fP \fBASCII\fP \fBacsc\fP \fBGlyph\fP
133 \fBName\fP \fBDefault\fP \fBDefault\fP \fBchar\fP \fBName\fP
134 WACS_BLOCK 0x25ae # 0 solid square block
135 WACS_BOARD 0x2592 # h board of squares
136 WACS_BTEE 0x2534 + v bottom tee
137 WACS_BULLET 0x00b7 o ~ bullet
138 WACS_CKBOARD 0x2592 : a checker board (stipple)
139 WACS_DARROW 0x2193 v . arrow pointing down
140 WACS_DEGREE 0x00b0 ' f degree symbol
141 WACS_DIAMOND 0x25c6 + \(ga diamond
142 WACS_GEQUAL 0x2265 > > greater-than-or-equal-to
143 WACS_HLINE 0x2500 \- q horizontal line
144 WACS_LANTERN 0x2603 # i lantern symbol
145 WACS_LARROW 0x2190 < , arrow pointing left
146 WACS_LEQUAL 0x2264 < y less-than-or-equal-to
147 WACS_LLCORNER 0x2514 + m lower left-hand corner
148 WACS_LRCORNER 0x2518 + j lower right-hand corner
149 WACS_LTEE 0x2524 + t left tee
150 WACS_NEQUAL 0x2260 ! | not-equal
151 WACS_PI 0x03c0 * { greek pi
152 WACS_PLMINUS 0x00b1 # g plus/minus
153 WACS_PLUS 0x253c + n plus
154 WACS_RARROW 0x2192 > + arrow pointing right
155 WACS_RTEE 0x251c + u right tee
156 WACS_S1 0x23ba \- o scan line 1
157 WACS_S3 0x23bb \- p scan line 3
158 WACS_S7 0x23bc \- r scan line 7
159 WACS_S9 0x23bd \&_ s scan line 9
160 WACS_STERLING 0x00a3 f } pound-sterling symbol
161 WACS_TTEE 0x252c + w top tee
162 WACS_UARROW 0x2191 ^ \- arrow pointing up
163 WACS_ULCORNER 0x250c + l upper left-hand corner
164 WACS_URCORNER 0x2510 + k upper right-hand corner
165 WACS_VLINE 0x2502 | x vertical line
168 The wide-character configuration of \fI\%ncurses\fP also defines symbols
169 for thick lines (\fBacsc\fP \*(``J\*('' to \*(``V\*(''):
175 lw(1.5i) lw5 lw5 lw5 lw20.
176 \fBACS\fP \fBUnicode\fP \fBASCII\fP \fBacsc\fP \fBGlyph\fP
177 \fBName\fP \fBDefault\fP \fBDefault\fP \fBchar\fP \fBName\fP
178 WACS_T_BTEE 0x253b + V thick tee pointing up
179 WACS_T_HLINE 0x2501 - Q thick horizontal line
180 WACS_T_LLCORNER 0x2517 + M thick lower left corner
181 WACS_T_LRCORNER 0x251b + J thick lower right corner
182 WACS_T_LTEE 0x252b + T thick tee pointing right
183 WACS_T_PLUS 0x254b + N thick large plus
184 WACS_T_RTEE 0x2523 + U thick tee pointing left
185 WACS_T_TTEE 0x2533 + W thick tee pointing down
186 WACS_T_ULCORNER 0x250f + L thick upper left corner
187 WACS_T_URCORNER 0x2513 + K thick upper right corner
188 WACS_T_VLINE 0x2503 | X thick vertical line
191 and for double-lines (\fBacsc\fP \*(``A\*('' to \*(``I\*(''):
197 lw(1.5i) lw5 lw5 lw5 lw20.
198 \fBACS\fP \fBUnicode\fP \fBASCII\fP \fBacsc\fP \fBGlyph\fP
199 \fBName\fP \fBDefault\fP \fBDefault\fP \fBchar\fP \fBName\fP
200 WACS_D_BTEE 0x2569 + H double tee pointing up
201 WACS_D_HLINE 0x2550 - R double horizontal line
202 WACS_D_LLCORNER 0x255a + D double lower left corner
203 WACS_D_LRCORNER 0x255d + A double lower right corner
204 WACS_D_LTEE 0x2560 + F double tee pointing right
205 WACS_D_PLUS 0x256c + E double large plus
206 WACS_D_RTEE 0x2563 + G double tee pointing left
207 WACS_D_TTEE 0x2566 + I double tee pointing down
208 WACS_D_ULCORNER 0x2554 + C double upper left corner
209 WACS_D_URCORNER 0x2557 + B double upper right corner
210 WACS_D_VLINE 0x2551 | Y double vertical line
213 Unicode's descriptions for these characters differs slightly from
215 by introducing the term \*(``light\*('' (along with less important details).
216 Here are its descriptions for the normal, thick, and double horizontal lines:
218 U+2500 BOX DRAWINGS LIGHT HORIZONTAL
220 U+2501 BOX DRAWINGS HEAVY HORIZONTAL
222 U+2550 BOX DRAWINGS DOUBLE HORIZONTAL
224 All routines return the integer \fBERR\fP upon failure and \fBOK\fP on success.
226 X/Open does not define any error conditions.
227 This implementation returns an error
229 if the window pointer is null or
231 if it is not possible to add a complete character in the window.
233 The latter may be due to different causes:
235 If \fB\%scrollok\fP(3X) is not enabled,
236 writing a character at the lower right margin succeeds.
238 an error is returned because it is not possible to wrap to a new line.
240 If an error is detected when converting a multibyte character to a sequence
242 or if it is not possible to add all of the resulting bytes in the window,
243 an error is returned.
245 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
246 \fBwmove\fP, and return an error if the position is outside the window,
247 or if the window pointer is null.
252 \fBmvwadd_wch\fP, and
256 These functions are described in the XSI Curses standard, Issue 4.
257 The defaults specified for line-drawing characters apply in the POSIX locale.
259 X/Open Curses makes it clear that the WACS_ symbols should be defined as
260 a pointer to \fBcchar_t\fP data, e.g., in the discussion of \fBborder_set\fP.
261 A few implementations are problematic:
263 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
265 HP-UX curses equates some of the \fBACS_\fP symbols
266 to the analogous \fBWACS_\fP symbols as if the \fBACS_\fP symbols were
268 The misdefined symbols are the arrows
269 and other symbols which are not used for line-drawing.
271 X/Open Curses does not define symbols for thick- or double-lines.
272 SVr4 curses implementations defined their line-drawing symbols in
273 terms of intermediate symbols.
274 This implementation extends those symbols, providing new definitions
275 which are not in the SVr4 implementations.
277 Not all Unicode-capable terminals provide support for VT100-style
278 alternate character sets (i.e., the \fBacsc\fP capability),
279 with their corresponding line-drawing characters.
280 X/Open Curses did not address the aspect of integrating Unicode with
281 line-drawing characters.
282 Existing implementations of Unix curses (AIX, HP-UX, Solaris)
283 use only the \fBacsc\fP character-mapping to provide this feature.
284 As a result, those implementations can only use single-byte line-drawing
286 \fI\%ncurses\fP 5.3 (2002) provided a table of Unicode values to solve
288 NetBSD curses incorporated that table in 2010.
290 In this implementation, the Unicode values are used instead of the
291 terminal description's \fBacsc\fP mapping as discussed in
292 \fB\%ncurses\fP(3X) for the environment variable
293 \fINCURSES_NO_UTF8_ACS\fP.
294 In contrast, for the same cases, the line-drawing characters
295 described in \fB\%addch\fP(3X) will use only the ASCII default values.
297 Having Unicode available does not solve all of the problems with
298 line-drawing for curses:
300 The closest Unicode equivalents to the
301 VT100 graphics \fIS1\fP, \fIS3\fP, \fIS7\fP and \fIS9\fP
302 frequently are not displayed at
303 the regular intervals which the terminal used.
305 The \fIlantern\fP is a special case.
306 It originated with the AT&T 4410 terminal in the early 1980s.
307 There is no accessible documentation depicting the lantern symbol
308 on the AT&T terminal.
310 Lacking documentation, most readers assume that a \fIstorm lantern\fP
312 But there are several possibilities, all with problems.
314 Unicode 6.0 (2010) does provide two lantern symbols: U+1F383 and U+1F3EE.
315 Those were not available in 2002, and are irrelevant since
316 they lie outside the BMP and as a result are not generally available
318 They are not storm lanterns, in any case.
320 Most \fIstorm lanterns\fP have a tapering glass chimney
321 (to guard against tipping);
322 some have a wire grid protecting the chimney.
324 For the tapering appearance, \[u2603] U+2603 was adequate.
325 In use on a terminal, no one can tell what the image represents.
326 Unicode calls it a snowman.
328 Others have suggested these alternatives:
329 \[sc] U+00A7 (section mark),
330 \[u0398] U+0398 (theta),
331 \[u03A6] U+03A6 (phi),
332 \[u03B4] U+03B4 (delta),
333 \[u2327] U+2327 (x in a rectangle),
334 \[u256C] U+256C (forms double vertical and horizontal), and
335 \[u2612] U+2612 (ballot box with x).
336 .SS Complex Characters
337 The complex character type \fBcchar_t\fR
338 can store more than one wide character (\fBwchar_t\fR).
339 The X/Open Curses description does not mention this possibility,
340 describing only the cases where \fIwch\fP is a spacing character
341 or a non-spacing character.
343 This implementation assumes that \fIwch\fP is constructed using
344 \fB\%setcchar\fP(3X), and in turn that the result
346 contains at most one spacing character in the beginning of its list of wide
348 and zero or more non-spacing characters
351 may hold one non-spacing character.
354 \fI\%ncurses\fP adds the non-spacing character to the active
355 (base) spacing character.
358 \fB\%curs_addch\fP(3X),
359 \fB\%curs_attr\fP(3X),
360 \fB\%curs_clear\fP(3X),
361 \fB\%curs_getcchar\fP(3X),
362 \fB\%curs_outopts\fP(3X),
363 \fB\%curs_refresh\fP(3X),