1 .\"***************************************************************************
2 .\" Copyright 2019-2021,2023 Thomas E. Dickey *
3 .\" Copyright 2001-2015,2017 Free Software Foundation, Inc. *
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: *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
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. *
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 *
28 .\"***************************************************************************
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"
46 \fBwecho_wchar\fP \- add a complex character and rendition to a \fBcurses\fP window, then advance the cursor
48 \fB#include <curses.h>\fP
50 .B "int add_wch( const cchar_t *\fIwch\fB );"
52 .B "int wadd_wch( WINDOW *\fIwin\fP, const cchar_t *\fIwch\fB );"
54 .B "int mvadd_wch( int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fB );"
56 .B "int mvwadd_wch( WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fB );"
58 .B "int echo_wchar( const cchar_t *\fIwch\fB );"
60 .B "int wecho_wchar( WINDOW *\fIwin\fP, const cchar_t *\fIwch\fB );"
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:
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.
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.
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.
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.
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.
99 function is functionally equivalent to a call to
101 followed by a call to
105 is functionally equivalent to a call to
107 followed by a call to
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.
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
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
161 The wide-character configuration of ncurses also defines symbols
162 for thick lines (\fBacsc\fP \*(``J\*('' to \*(``V\*(''):
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
183 and for double-lines (\fBacsc\fP \*(``A\*('' to \*(``I\*(''):
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
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:
209 U+2500 BOX DRAWINGS LIGHT HORIZONTAL
211 U+2501 BOX DRAWINGS HEAVY HORIZONTAL
213 U+2550 BOX DRAWINGS DOUBLE HORIZONTAL
215 All routines return the integer \fBERR\fP upon failure and \fBOK\fP on success.
217 X/Open does not define any error conditions.
218 This implementation returns an error
220 if the window pointer is null or
222 if it is not possible to add a complete character in the window.
224 The latter may be due to different causes:
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
231 If an error is detected when converting a multibyte character to a sequence
233 or if it is not possible to add all of the resulting bytes in the window,
234 an error is returned.
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.
243 \fBmvwadd_wch\fP, and
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.
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:
254 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
256 HPUX curses equates some of the \fBACS_\fP symbols
257 to the analogous \fBWACS_\fP symbols as if the \fBACS_\fP symbols were
259 The misdefined symbols are the arrows
260 and other symbols which are not used for line-drawing.
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.
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
277 Ncurses 5.3 (2002) provided a table of Unicode values to solve these problems.
278 NetBSD curses incorporated that table in 2010.
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.
286 Having Unicode available does not solve all of the problems with
287 line-drawing for curses:
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.
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.
299 Lacking documentation, most readers assume that a \fIstorm lantern\fP
301 But there are several possibilities, all with problems.
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
307 They are not storm lanterns, in any case.
309 Most \fIstorm lanterns\fP have a tapering glass chimney
310 (to guard against tipping);
311 some have a wire grid protecting the chimney.
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.
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.
332 This implementation assumes that \fIwch\fP is constructed using
333 \fBsetcchar\fP(3X), and in turn that the result
335 contains at most one spacing character in the beginning of its list of wide
337 and zero or more non-spacing characters
340 may hold one non-spacing character.
342 In the latter case, ncurses adds the non-spacing character to the active
343 (base) spacing character.
348 \fBcurs_addch\fP(3X),
350 \fBcurs_clear\fP(3X),
351 \fBcurs_getcchar\fP(3X),
352 \fBcurs_outopts\fP(3X),
353 \fBcurs_refresh\fP(3X),