]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_add_wch.3x
ncurses 6.4 - patch 20230805
[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.38 2023/08/06 00:03:38 tom Exp $
32 .TH curs_add_wch 3X 2023-08-05 "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 .TS
165 l l l l l
166 l l l l l
167 _ _ _ _ _
168 lw(1.5i) lw5 lw5 lw5 lw20.
169 \fBACS\fP       \fBUnicode\fP   \fBASCII\fP     \fBacsc\fP      \fBGlyph\fP
170 \fBName\fP      \fBDefault\fP   \fBDefault\fP   \fBchar\fP      \fBName\fP
171 WACS_T_BTEE     0x253b  +       V       thick tee pointing up
172 WACS_T_HLINE    0x2501  -       Q       thick horizontal line
173 WACS_T_LLCORNER 0x2517  +       M       thick lower left corner
174 WACS_T_LRCORNER 0x251b  +       J       thick lower right corner
175 WACS_T_LTEE     0x252b  +       T       thick tee pointing right
176 WACS_T_PLUS     0x254b  +       N       thick large plus
177 WACS_T_RTEE     0x2523  +       U       thick tee pointing left
178 WACS_T_TTEE     0x2533  +       W       thick tee pointing down
179 WACS_T_ULCORNER 0x250f  +       L       thick upper left corner
180 WACS_T_URCORNER 0x2513  +       K       thick upper right corner
181 WACS_T_VLINE    0x2503  |       X       thick vertical line
182 .TE
183 .PP
184 and for double-lines (\fBacsc\fP \*(``A\*('' to \*(``I\*(''):
185 .PP
186 .TS
187 l l l l l
188 l l l l l
189 _ _ _ _ _
190 lw(1.5i) lw5 lw5 lw5 lw20.
191 \fBACS\fP       \fBUnicode\fP   \fBASCII\fP     \fBacsc\fP      \fBGlyph\fP
192 \fBName\fP      \fBDefault\fP   \fBDefault\fP   \fBchar\fP      \fBName\fP
193 WACS_D_BTEE     0x2569  +       H       double tee pointing up
194 WACS_D_HLINE    0x2550  -       R       double horizontal line
195 WACS_D_LLCORNER 0x255a  +       D       double lower left corner
196 WACS_D_LRCORNER 0x255d  +       A       double lower right corner
197 WACS_D_LTEE     0x2560  +       F       double tee pointing right
198 WACS_D_PLUS     0x256c  +       E       double large plus
199 WACS_D_RTEE     0x2563  +       G       double tee pointing left
200 WACS_D_TTEE     0x2566  +       I       double tee pointing down
201 WACS_D_ULCORNER 0x2554  +       C       double upper left corner
202 WACS_D_URCORNER 0x2557  +       B       double upper right corner
203 WACS_D_VLINE    0x2551  |       Y       double vertical line
204 .TE
205 .PP
206 Unicode's descriptions for these characters differs slightly from ncurses,
207 by introducing the term \*(``light\*('' (along with less important details).
208 Here are its descriptions for the normal, thick, and double horizontal lines:
209 .bP
210 U+2500 BOX DRAWINGS LIGHT HORIZONTAL
211 .bP
212 U+2501 BOX DRAWINGS HEAVY HORIZONTAL
213 .bP
214 U+2550 BOX DRAWINGS DOUBLE HORIZONTAL
215 .SH RETURN VALUE
216 All routines return the integer \fBERR\fP upon failure and \fBOK\fP on success.
217 .PP
218 X/Open does not define any error conditions.
219 This implementation returns an error
220 .bP
221 if the window pointer is null or
222 .bP
223 if it is not possible to add a complete character in the window.
224 .PP
225 The latter may be due to different causes:
226 .bP
227 If \fBscrollok\fP(3X) is not enabled,
228 writing a character at the lower right margin succeeds.
229 However, an error is returned because
230 it is not possible to wrap to a new line
231 .bP
232 If an error is detected when converting a multibyte character to a sequence
233 of bytes,
234 or if it is not possible to add all of the resulting bytes in the window,
235 an error is returned.
236 .PP
237 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
238 \fBwmove\fP, and return an error if the position is outside the window,
239 or if the window pointer is null.
240 .SH NOTES
241 Note that
242 \fBadd_wch\fP,
243 \fBmvadd_wch\fP,
244 \fBmvwadd_wch\fP, and
245 \fBecho_wchar\fP
246 may be macros.
247 .SH PORTABILITY
248 All of these functions are described in the XSI Curses standard, Issue 4.
249 The defaults specified for line-drawing characters apply in the POSIX locale.
250 .SS WACS Symbols
251 X/Open Curses makes it clear that the WACS_ symbols should be defined as
252 a pointer to \fBcchar_t\fP data, e.g., in the discussion of \fBborder_set\fP.
253 A few implementations are problematic:
254 .bP
255 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
256 .bP
257 HPUX curses equates some of the \fBACS_\fP symbols
258 to the analogous \fBWACS_\fP symbols as if the \fBACS_\fP symbols were
259 wide characters.
260 The misdefined symbols are the arrows
261 and other symbols which are not used for line-drawing.
262 .PP
263 X/Open Curses does not define symbols for thick- or double-lines.
264 SVr4 curses implementations defined their line-drawing symbols in
265 terms of intermediate symbols.
266 This implementation extends those symbols, providing new definitions
267 which are not in the SVr4 implementations.
268 .PP
269 Not all Unicode-capable terminals provide support for VT100-style
270 alternate character sets (i.e., the \fBacsc\fP capability),
271 with their corresponding line-drawing characters.
272 X/Open Curses did not address the aspect of integrating Unicode with
273 line-drawing characters.
274 Existing implementations of Unix curses (AIX, HPUX, Solaris)
275 use only the \fBacsc\fP character-mapping to provide this feature.
276 As a result, those implementations can only use single-byte line-drawing
277 characters.
278 Ncurses 5.3 (2002) provided a table of Unicode values to solve these problems.
279 NetBSD curses incorporated that table in 2010.
280 .PP
281 In this implementation, the Unicode values are used instead of the
282 terminal description's \fBacsc\fP mapping as discussed in ncurses(3X)
283 for the environment variable \fBNCURSES_NO_UTF8_ACS\fP.
284 In contrast, for the same cases, the line-drawing characters
285 described in \fBcurs_addch\fP(3X) will use only the ASCII default values.
286 .PP
287 Having Unicode available does not solve all of the problems with
288 line-drawing for curses:
289 .bP
290 The closest Unicode equivalents to the
291 VT100 graphics \fIS1\fP, \fIS3\fP, \fIS7\fP and \fIS9\fP
292 frequently are not displayed at
293 the regular intervals which the terminal used.
294 .bP
295 The \fIlantern\fP is a special case.
296 It originated with the AT&T 4410 terminal in the early 1980s.
297 There is no accessible documentation depicting the lantern symbol
298 on the AT&T terminal.
299 .IP
300 Lacking documentation, most readers assume that a \fIstorm lantern\fP
301 was intended.
302 But there are several possibilities, all with problems.
303 .IP
304 Unicode 6.0 (2010) does provide two lantern symbols: U+1F383 and U+1F3EE.
305 Those were not available in 2002, and are irrelevant since
306 they lie outside the BMP and as a result are not generally available
307 in terminals.
308 They are not storm lanterns, in any case.
309 .IP
310 Most \fIstorm lanterns\fP have a tapering glass chimney
311 (to guard against tipping);
312 some have a wire grid protecting the chimney.
313 .IP
314 For the tapering appearance, \[u2603] U+2603 was adequate.
315 In use on a terminal, no one can tell what the image represents.
316 Unicode calls it a snowman.
317 .IP
318 Others have suggested these alternatives:
319 \[sc] U+00A7 (section mark),
320 \[u0398] U+0398 (theta),
321 \[u03A6] U+03A6 (phi),
322 \[u03B4] U+03B4 (delta),
323 \[u2327] U+2327 (x in a rectangle),
324 \[u256C] U+256C (forms double vertical and horizontal), and
325 \[u2612] U+2612 (ballot box with x).
326 .SS Complex Characters
327 The complex character type \fBcchar_t\fR
328 can store more than one wide character (\fBwchar_t\fR).
329 The X/Open Curses description does not mention this possibility,
330 describing only the cases where \fIwch\fP is a spacing character
331 or a non-spacing character.
332 .PP
333 This implementation assumes that \fIwch\fP is constructed using
334 \fBsetcchar\fP(3X), and in turn that the result
335 .bP
336 contains at most one spacing character in the beginning of its list of wide
337 characters,
338 and zero or more non-spacing characters
339 or
340 .bP
341 may hold one non-spacing character.
342 .PP
343 In the latter case, ncurses adds the non-spacing character to the active
344 (base) spacing character.
345 .SH SEE ALSO
346 .na
347 .hy 0
348 \fBcurses\fP(3X),
349 \fBcurs_addch\fP(3X),
350 \fBcurs_attr\fP(3X),
351 \fBcurs_clear\fP(3X),
352 \fBcurs_getcchar\fP(3X),
353 \fBcurs_outopts\fP(3X),
354 \fBcurs_refresh\fP(3X),
355 \fBputwc\fP(3)