]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_add_wch.3x
ncurses 6.4 - patch 20231007
[ncurses.git] / man / curs_add_wch.3x
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright 2019-2021,2023 Thomas E. Dickey                                *
4 .\" Copyright 2001-2015,2017 Free Software Foundation, Inc.                  *
5 .\"                                                                          *
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:                 *
13 .\"                                                                          *
14 .\" The above copyright notice and this permission notice shall be included  *
15 .\" in all copies or substantial portions of the Software.                   *
16 .\"                                                                          *
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.                               *
24 .\"                                                                          *
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       *
28 .\" authorization.                                                           *
29 .\"***************************************************************************
30 .\"
31 .\" $Id: curs_add_wch.3x,v 1.46 2023/10/07 21:19:07 tom Exp $
32 .TH curs_add_wch 3X 2023-10-07 "ncurses 6.4" "Library calls"
33 .ie \n(.g \{\
34 .ds `` \(lq
35 .ds '' \(rq
36 .\}
37 .el \{\
38 .ie t .ds `` ``
39 .el   .ds `` ""
40 .ie t .ds '' ''
41 .el   .ds '' ""
42 .\}
43 .
44 .de bP
45 .ie n  .IP \(bu 4
46 .el    .IP \(bu 2
47 ..
48 .SH NAME
49 \fB\%add_wch\fP,
50 \fB\%wadd_wch\fP,
51 \fB\%mvadd_wch\fP,
52 \fB\%mvwadd_wch\fP,
53 \fB\%echo_wchar\fP,
54 \fB\%wecho_wchar\fP \-
55 add a \fIcurses\fR complex character to a window and advance the cursor
56 .SH SYNOPSIS
57 .nf
58 \fB#include <curses.h>
59 .PP
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);
64 .PP
65 \fBint echo_wchar(const cchar_t *\fIwch\fP);
66 \fBint wecho_wchar(WINDOW *\fIwin\fP, const cchar_t *\fIwch\fP);
67 .fi
68 .SH DESCRIPTION
69 .SS add_wch
70 The
71 \fBadd_wch\fP,
72 \fBwadd_wch\fP,
73 \fBmvadd_wch\fP, and
74 \fBmvwadd_wch\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:
80 .bP
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.
87 .IP
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.
92 .bP
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.
97 .IP
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.
100 .bP
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.
104 .SS echo_wchar
105 The \fBecho_wchar\fP
106 function is functionally equivalent to a call to
107 \fBadd_wch\fP
108 followed by a call to
109 \fBrefresh\fP(3X).
110 Similarly, the
111 \fBwecho_wchar\fP
112 is functionally equivalent to a call to
113 \fBwadd_wch\fP
114 followed by a call to
115 \fBwrefresh\fP.
116 The knowledge
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.
120 .SS Line Graphics
121 Like \fBaddch\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
125 \fBaddch\fP(3X).
126 .PP
127 .TS
128 l l l l l
129 l l l l l
130 _ _ _ _ _
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
166 .TE
167 .PP
168 The wide-character configuration of ncurses also defines symbols
169 for thick lines (\fBacsc\fP \*(``J\*('' to \*(``V\*(''):
170 .PP
171 .TS
172 l l l l l
173 l l l l l
174 _ _ _ _ _
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
189 .TE
190 .PP
191 and for double-lines (\fBacsc\fP \*(``A\*('' to \*(``I\*(''):
192 .PP
193 .TS
194 l l l l l
195 l l l l l
196 _ _ _ _ _
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
211 .TE
212 .PP
213 Unicode's descriptions for these characters differs slightly from ncurses,
214 by introducing the term \*(``light\*('' (along with less important details).
215 Here are its descriptions for the normal, thick, and double horizontal lines:
216 .bP
217 U+2500 BOX DRAWINGS LIGHT HORIZONTAL
218 .bP
219 U+2501 BOX DRAWINGS HEAVY HORIZONTAL
220 .bP
221 U+2550 BOX DRAWINGS DOUBLE HORIZONTAL
222 .SH RETURN VALUE
223 All routines return the integer \fBERR\fP upon failure and \fBOK\fP on success.
224 .PP
225 X/Open does not define any error conditions.
226 This implementation returns an error
227 .bP
228 if the window pointer is null or
229 .bP
230 if it is not possible to add a complete character in the window.
231 .PP
232 The latter may be due to different causes:
233 .bP
234 If \fBscrollok\fP(3X) is not enabled,
235 writing a character at the lower right margin succeeds.
236 However, an error is returned because
237 it is not possible to wrap to a new line
238 .bP
239 If an error is detected when converting a multibyte character to a sequence
240 of bytes,
241 or if it is not possible to add all of the resulting bytes in the window,
242 an error is returned.
243 .PP
244 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
245 \fBwmove\fP, and return an error if the position is outside the window,
246 or if the window pointer is null.
247 .SH NOTES
248 Note that
249 \fBadd_wch\fP,
250 \fBmvadd_wch\fP,
251 \fBmvwadd_wch\fP, and
252 \fBecho_wchar\fP
253 may be macros.
254 .SH PORTABILITY
255 All of these functions are described in the XSI Curses standard, Issue 4.
256 The defaults specified for line-drawing characters apply in the POSIX locale.
257 .SS WACS Symbols
258 X/Open Curses makes it clear that the WACS_ symbols should be defined as
259 a pointer to \fBcchar_t\fP data, e.g., in the discussion of \fBborder_set\fP.
260 A few implementations are problematic:
261 .bP
262 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
263 .bP
264 HPUX curses equates some of the \fBACS_\fP symbols
265 to the analogous \fBWACS_\fP symbols as if the \fBACS_\fP symbols were
266 wide characters.
267 The misdefined symbols are the arrows
268 and other symbols which are not used for line-drawing.
269 .PP
270 X/Open Curses does not define symbols for thick- or double-lines.
271 SVr4 curses implementations defined their line-drawing symbols in
272 terms of intermediate symbols.
273 This implementation extends those symbols, providing new definitions
274 which are not in the SVr4 implementations.
275 .PP
276 Not all Unicode-capable terminals provide support for VT100-style
277 alternate character sets (i.e., the \fBacsc\fP capability),
278 with their corresponding line-drawing characters.
279 X/Open Curses did not address the aspect of integrating Unicode with
280 line-drawing characters.
281 Existing implementations of Unix curses (AIX, HPUX, Solaris)
282 use only the \fBacsc\fP character-mapping to provide this feature.
283 As a result, those implementations can only use single-byte line-drawing
284 characters.
285 Ncurses 5.3 (2002) provided a table of Unicode values to solve these problems.
286 NetBSD curses incorporated that table in 2010.
287 .PP
288 In this implementation, the Unicode values are used instead of the
289 terminal description's \fBacsc\fP mapping as discussed in ncurses(3X)
290 for the environment variable \fBNCURSES_NO_UTF8_ACS\fP.
291 In contrast, for the same cases, the line-drawing characters
292 described in \fBcurs_addch\fP(3X) will use only the ASCII default values.
293 .PP
294 Having Unicode available does not solve all of the problems with
295 line-drawing for curses:
296 .bP
297 The closest Unicode equivalents to the
298 VT100 graphics \fIS1\fP, \fIS3\fP, \fIS7\fP and \fIS9\fP
299 frequently are not displayed at
300 the regular intervals which the terminal used.
301 .bP
302 The \fIlantern\fP is a special case.
303 It originated with the AT&T 4410 terminal in the early 1980s.
304 There is no accessible documentation depicting the lantern symbol
305 on the AT&T terminal.
306 .IP
307 Lacking documentation, most readers assume that a \fIstorm lantern\fP
308 was intended.
309 But there are several possibilities, all with problems.
310 .IP
311 Unicode 6.0 (2010) does provide two lantern symbols: U+1F383 and U+1F3EE.
312 Those were not available in 2002, and are irrelevant since
313 they lie outside the BMP and as a result are not generally available
314 in terminals.
315 They are not storm lanterns, in any case.
316 .IP
317 Most \fIstorm lanterns\fP have a tapering glass chimney
318 (to guard against tipping);
319 some have a wire grid protecting the chimney.
320 .IP
321 For the tapering appearance, \[u2603] U+2603 was adequate.
322 In use on a terminal, no one can tell what the image represents.
323 Unicode calls it a snowman.
324 .IP
325 Others have suggested these alternatives:
326 \[sc] U+00A7 (section mark),
327 \[u0398] U+0398 (theta),
328 \[u03A6] U+03A6 (phi),
329 \[u03B4] U+03B4 (delta),
330 \[u2327] U+2327 (x in a rectangle),
331 \[u256C] U+256C (forms double vertical and horizontal), and
332 \[u2612] U+2612 (ballot box with x).
333 .SS Complex Characters
334 The complex character type \fBcchar_t\fR
335 can store more than one wide character (\fBwchar_t\fR).
336 The X/Open Curses description does not mention this possibility,
337 describing only the cases where \fIwch\fP is a spacing character
338 or a non-spacing character.
339 .PP
340 This implementation assumes that \fIwch\fP is constructed using
341 \fBsetcchar\fP(3X), and in turn that the result
342 .bP
343 contains at most one spacing character in the beginning of its list of wide
344 characters,
345 and zero or more non-spacing characters
346 or
347 .bP
348 may hold one non-spacing character.
349 .PP
350 In the latter case, ncurses adds the non-spacing character to the active
351 (base) spacing character.
352 .SH SEE ALSO
353 \fB\%curses\fP(3X),
354 \fB\%curs_addch\fP(3X),
355 \fB\%curs_attr\fP(3X),
356 \fB\%curs_clear\fP(3X),
357 \fB\%curs_getcchar\fP(3X),
358 \fB\%curs_outopts\fP(3X),
359 \fB\%curs_refresh\fP(3X),
360 \fB\%putwc\fP(3)