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