]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_add_wch.3x
ncurses 6.2 - patch 20201107
[ncurses.git] / man / curs_add_wch.3x
1 .\"***************************************************************************
2 .\" Copyright 2019,2020 Thomas E. Dickey                                     *
3 .\" Copyright 2001-2015,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
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:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
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.                               *
23 .\"                                                                          *
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       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_add_wch.3x,v 1.28 2020/10/17 23:10:38 tom Exp $
31 .TH curs_add_wch 3X ""
32 .ie \n(.g .ds `` \(lq
33 .el       .ds `` ``
34 .ie \n(.g .ds '' \(rq
35 .el       .ds '' ''
36 .de bP
37 .ie n  .IP \(bu 4
38 .el    .IP \(bu 2
39 ..
40 .SH NAME
41 \fBadd_wch\fP,
42 \fBwadd_wch\fP,
43 \fBmvadd_wch\fP,
44 \fBmvwadd_wch\fP,
45 \fBecho_wchar\fP,
46 \fBwecho_wchar\fP \- add a complex character and rendition to a \fBcurses\fR window, then advance the cursor
47 .SH SYNOPSIS
48 .PP
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 .br
63 .SH DESCRIPTION
64 .SS add_wch
65 .PP
66 The
67 \fBadd_wch\fP,
68 \fBwadd_wch\fP,
69 \fBmvadd_wch\fP, and
70 \fBmvwadd_wch\fP
71 functions put the complex character \fIwch\fP into the given
72 window at its current position,
73 which is then advanced.
74 These functions perform
75 wrapping and special-character processing as follows:
76 .bP
77 If \fIwch\fP refers to a spacing character,
78 then any previous character at that location is removed.
79 A new character specified by \fIwch\fP is
80 placed at that location with rendition specified by \fIwch\fP.
81 The cursor then advances to
82 the next spacing character on the screen.
83 .bP
84 If \fIwch\fP refers to a non-spacing character,
85 all previous characters at that location are preserved.
86 The non-spacing characters of \fIwch\fP
87 are added to the spacing complex character,
88 and the rendition specified by \fIwch\fP is ignored.
89 .bP
90 If the character part of \fIwch\fP is
91 a tab, newline, backspace or other control character,
92 the window is updated and the cursor moves as if \fBaddch\fR were called.
93 .SS echo_wchar
94 .PP
95 The \fBecho_wchar\fP
96 function is functionally equivalent to a call to
97 \fBadd_wch\fP
98 followed by a call to
99 \fBrefresh\fP(3X).
100 Similarly, the
101 \fBwecho_wchar\fP
102 is functionally equivalent to a call to
103 \fBwadd_wch\fP
104 followed by a call to
105 \fBwrefresh\fP.
106 The knowledge
107 that only a single character is being output is taken into consideration and,
108 for non-control characters, a considerable performance gain might be seen
109 by using the *\fBecho\fP* functions instead of their equivalents.
110 .SS Line Graphics
111 Like \fBaddch\fP(3X),
112 \fBaddch_wch\fP accepts symbols which make it simple to draw lines and other
113 frequently used special characters.
114 These symbols correspond to the same VT100 line-drawing set as
115 \fBaddch\fP(3X).
116 .PP
117 .TS
118 l l l l l
119 l l l l l
120 _ _ _ _ _
121 lw(1.5i) lw5 lw5 lw5 lw20.
122 \fBACS\fR       \fBUnicode\fP   \fBASCII\fR     \fBacsc\fP      \fBGlyph\fR
123 \fBName\fR      \fBDefault\fP   \fBDefault\fR   \fBchar\fP      \fBName\fR
124 WACS_BLOCK      0x25ae  #       0       solid square block
125 WACS_BOARD      0x2592  #       h       board of squares
126 WACS_BTEE       0x2534  +       v       bottom tee
127 WACS_BULLET     0x00b7  o       ~       bullet
128 WACS_CKBOARD    0x2592  :       a       checker board (stipple)
129 WACS_DARROW     0x2193  v       .       arrow pointing down
130 WACS_DEGREE     0x00b0  '       f       degree symbol
131 WACS_DIAMOND    0x25c6  +       `       diamond
132 WACS_GEQUAL     0x2265  >       >       greater-than-or-equal-to
133 WACS_HLINE      0x2500  \-      q       horizontal line
134 WACS_LANTERN    0x2603  #       i       lantern symbol
135 WACS_LARROW     0x2190  <       ,       arrow pointing left
136 WACS_LEQUAL     0x2264  <       y       less-than-or-equal-to
137 WACS_LLCORNER   0x2514  +       m       lower left-hand corner
138 WACS_LRCORNER   0x2518  +       j       lower right-hand corner
139 WACS_LTEE       0x2524  +       t       left tee
140 WACS_NEQUAL     0x2260  !       |       not-equal
141 WACS_PI 0x03c0  *       {       greek pi
142 WACS_PLMINUS    0x00b1  #       g       plus/minus
143 WACS_PLUS       0x253c  +       n       plus
144 WACS_RARROW     0x2192  >       +       arrow pointing right
145 WACS_RTEE       0x251c  +       u       right tee
146 WACS_S1 0x23ba  \-      o       scan line 1
147 WACS_S3 0x23bb  \-      p       scan line 3
148 WACS_S7 0x23bc  \-      r       scan line 7
149 WACS_S9 0x23bd  \&_     s       scan line 9
150 WACS_STERLING   0x00a3  f       }       pound-sterling symbol
151 WACS_TTEE       0x252c  +       w       top tee
152 WACS_UARROW     0x2191          ^       \-      arrow pointing up
153 WACS_ULCORNER   0x250c  +       l       upper left-hand corner
154 WACS_URCORNER   0x2510  +       k       upper right-hand corner
155 WACS_VLINE      0x2502  |       x       vertical line
156 .TE
157 .PP
158 The wide-character configuration of ncurses also defines symbols
159 for thick lines (\fBacsc\fP \*(``J\*('' to \*(``V\*(''):
160 .TS
161 l l l l l
162 l l l l l
163 _ _ _ _ _
164 lw(1.5i) lw5 lw5 lw5 lw20.
165 \fBACS\fR       \fBUnicode\fP   \fBASCII\fR     \fBacsc\fP      \fBGlyph\fR
166 \fBName\fR      \fBDefault\fP   \fBDefault\fR   \fBchar\fP      \fBName\fR
167 WACS_T_BTEE     0x253b  +       V       thick tee pointing up
168 WACS_T_HLINE    0x2501  -       Q       thick horizontal line
169 WACS_T_LLCORNER 0x2517  +       M       thick lower left corner
170 WACS_T_LRCORNER 0x251b  +       J       thick lower right corner
171 WACS_T_LTEE     0x252b  +       T       thick tee pointing right
172 WACS_T_PLUS     0x254b  +       N       thick large plus
173 WACS_T_RTEE     0x2523  +       U       thick tee pointing left
174 WACS_T_TTEE     0x2533  +       W       thick tee pointing down
175 WACS_T_ULCORNER 0x250f  +       L       thick upper left corner
176 WACS_T_URCORNER 0x2513  +       K       thick upper right corner
177 WACS_T_VLINE    0x2503  |       X       thick vertical line
178 .TE
179 .PP
180 and for double-lines (\fBacsc\fP \*(``A\*('' to \*(``I\*(''):
181 .PP
182 .TS
183 l l l l l
184 l l l l l
185 _ _ _ _ _
186 lw(1.5i) lw5 lw5 lw5 lw20.
187 \fBACS\fR       \fBUnicode\fP   \fBASCII\fR     \fBacsc\fP      \fBGlyph\fR
188 \fBName\fR      \fBDefault\fP   \fBDefault\fR   \fBchar\fP      \fBName\fR
189 WACS_D_BTEE     0x2569  +       H       double tee pointing up
190 WACS_D_HLINE    0x2550  -       R       double horizontal line
191 WACS_D_LLCORNER 0x255a  +       D       double lower left corner
192 WACS_D_LRCORNER 0x255d  +       A       double lower right corner
193 WACS_D_LTEE     0x2560  +       F       double tee pointing right
194 WACS_D_PLUS     0x256c  +       E       double large plus
195 WACS_D_RTEE     0x2563  +       G       double tee pointing left
196 WACS_D_TTEE     0x2566  +       I       double tee pointing down
197 WACS_D_ULCORNER 0x2554  +       C       double upper left corner
198 WACS_D_URCORNER 0x2557  +       B       double upper right corner
199 WACS_D_VLINE    0x2551  |       Y       double vertical line
200 .TE
201 .PP
202 Unicode's descriptions for these characters differs slightly from ncurses,
203 by introducing the term \*(``light\*('' (along with less important details).
204 Here are its descriptions for the normal, thick, and double horizontal lines:
205 .bP
206 U+2500 BOX DRAWINGS LIGHT HORIZONTAL
207 .bP
208 U+2501 BOX DRAWINGS HEAVY HORIZONTAL
209 .bP
210 U+2550 BOX DRAWINGS DOUBLE HORIZONTAL
211 .SH RETURN VALUE
212 .PP
213 All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success.
214 .PP
215 X/Open does not define any error conditions.
216 This implementation returns an error
217 .bP
218 if the window pointer is null or
219 .bP
220 if it is not possible to add a complete character in the window.
221 .PP
222 The latter may be due to different causes:
223 .bP
224 If \fBscrollok\fR is not enabled,
225 writing a character at the lower right margin succeeds.
226 However, an error is returned because
227 it is not possible to wrap to a new line
228 .bP
229 If an error is detected when converting a multibyte character to a sequence
230 of bytes,
231 or if it is not possible to add all of the resulting bytes in the window,
232 an error is returned.
233 .PP
234 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
235 \fBwmove\fP, and return an error if the position is outside the window,
236 or if the window pointer is null.
237 .SH NOTES
238 .PP
239 Note that
240 \fBadd_wch\fP,
241 \fBmvadd_wch\fP,
242 \fBmvwadd_wch\fP, and
243 \fBecho_wchar\fP
244 may be macros.
245 .SH PORTABILITY
246 .PP
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.
249 .PP
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\fR.
252 A few implementations are problematic:
253 .bP
254 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
255 .bP
256 HPUX curses equates some of the \fIACS_\fP symbols
257 to the analogous \fIWACS_\fP symbols as if the \fIACS_\fP symbols were
258 wide characters.
259 The misdefined symbols are the arrows
260 and other symbols which are not used for line-drawing.
261 .PP
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.
267 .PP
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
276 characters.
277 Ncurses 5.3 (2002) provided a table of Unicode values to solve these problems.
278 NetBSD curses incorporated that table in 2010.
279 .PP
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.
285 .PP
286 Having Unicode available does not solve all of the problems with
287 line-drawing for curses:
288 .bP
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.
293 .bP
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.
298 .IP
299 Lacking documentation, most readers assume that a \fIstorm lantern\fP
300 was intended.
301 But there are several possibilities, all with problems.
302 .IP
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
306 in terminals.
307 They are not storm lanterns, in any case.
308 .IP
309 Most \fIstorm lanterns\fP have a tapering glass chimney
310 (to guard against tipping);
311 some have a wire grid protecting the chimney.
312 .IP
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.
316 .IP
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 .SH SEE ALSO
326 .na
327 .PP
328 \fBcurses\fR(3X),
329 \fBcurs_addch\fR(3X),
330 \fBcurs_attr\fR(3X),
331 \fBcurs_clear\fR(3X),
332 \fBcurs_outopts\fR(3X),
333 \fBcurs_refresh\fR(3X),
334 \fBputwc\fR(3)