]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_add_wch.3x
ncurses 6.1 - patch 20191207
[ncurses.git] / man / curs_add_wch.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 2001-2017,2019 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_add_wch.3x,v 1.25 2019/10/27 00:07:13 tom Exp $
30 .TH curs_add_wch 3X ""
31 .ie \n(.g .ds `` \(lq
32 .el       .ds `` ``
33 .ie \n(.g .ds '' \(rq
34 .el       .ds '' ''
35 .de bP
36 .ie n  .IP \(bu 4
37 .el    .IP \(bu 2
38 ..
39 .SH NAME
40 \fBadd_wch\fP,
41 \fBwadd_wch\fP,
42 \fBmvadd_wch\fP,
43 \fBmvwadd_wch\fP,
44 \fBecho_wchar\fP,
45 \fBwecho_wchar\fP \- add a complex character and rendition to a \fBcurses\fR window, then advance the cursor
46 .SH SYNOPSIS
47 .PP
48 \fB#include <curses.h>\fP
49 .sp
50 .B "int add_wch( const cchar_t *\fIwch\fB );"
51 .br
52 .B "int wadd_wch( WINDOW *\fIwin\fP, const cchar_t *\fIwch\fB );"
53 .br
54 .B "int mvadd_wch( int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fB );"
55 .br
56 .B "int mvwadd_wch( WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fB );"
57 .br
58 .B "int echo_wchar( const cchar_t *\fIwch\fB );"
59 .br
60 .B "int wecho_wchar( WINDOW *\fIwin\fP, const cchar_t *\fIwch\fB );"
61 .br
62 .SH DESCRIPTION
63 .SS add_wch
64 .PP
65 The
66 \fBadd_wch\fP,
67 \fBwadd_wch\fP,
68 \fBmvadd_wch\fP, and
69 \fBmvwadd_wch\fP
70 functions put the complex character \fIwch\fP into the given
71 window at its current position,
72 which is then advanced.
73 These functions perform
74 wrapping and special-character processing as follows:
75 .bP
76 If \fIwch\fP refers to a spacing character,
77 then any previous character at that location is removed.
78 A new character specified by \fIwch\fP is
79 placed at that location with rendition specified by \fIwch\fP.
80 The cursor then advances to
81 the next spacing character on the screen.
82 .bP
83 If \fIwch\fP refers to a non-spacing character,
84 all previous characters at that location are preserved.
85 The non-spacing characters of \fIwch\fP
86 are added to the spacing complex character,
87 and the rendition specified by \fIwch\fP is ignored.
88 .bP
89 If the character part of \fIwch\fP is
90 a tab, newline, backspace or other control character,
91 the window is updated and the cursor moves as if \fBaddch\fR were called.
92 .SS echo_wchar
93 .PP
94 The \fBecho_wchar\fP
95 function is functionally equivalent to a call to
96 \fBadd_wch\fP
97 followed by a call to
98 \fBrefresh\fP(3X).
99 Similarly, the
100 \fBwecho_wchar\fP
101 is functionally equivalent to a call to
102 \fBwadd_wch\fP
103 followed by a call to
104 \fBwrefresh\fP.
105 The knowledge
106 that only a single character is being output is taken into consideration and,
107 for non-control characters, a considerable performance gain might be seen
108 by using the *\fBecho\fP* functions instead of their equivalents.
109 .SS Line Graphics
110 Like \fBaddch\fP(3X),
111 \fBaddch_wch\fP accepts symbols which make it simple to draw lines and other
112 frequently used special characters.
113 These symbols correspond to the same VT100 line-drawing set as
114 \fBaddch\fP(3X).
115 .PP
116 .TS
117 l l l l l
118 l l l l l
119 _ _ _ _ _
120 lw(1.5i) lw5 lw5 lw5 lw20.
121 \fBACS\fR       \fBUnicode\fP   \fBASCII\fR     \fBacsc\fP      \fBGlyph\fR
122 \fBName\fR      \fBDefault\fP   \fBDefault\fR   \fBchar\fP      \fBName\fR
123 WACS_BLOCK      0x25ae  #       0       solid square block
124 WACS_BOARD      0x2592  #       h       board of squares
125 WACS_BTEE       0x2534  +       v       bottom tee
126 WACS_BULLET     0x00b7  o       ~       bullet
127 WACS_CKBOARD    0x2592  :       a       checker board (stipple)
128 WACS_DARROW     0x2193  v       .       arrow pointing down
129 WACS_DEGREE     0x00b0  '       f       degree symbol
130 WACS_DIAMOND    0x25c6  +       `       diamond
131 WACS_GEQUAL     0x2265  >       >       greater-than-or-equal-to
132 WACS_HLINE      0x2500  \-      q       horizontal line
133 WACS_LANTERN    0x2603  #       i       lantern symbol
134 WACS_LARROW     0x2190  <       ,       arrow pointing left
135 WACS_LEQUAL     0x2264  <       y       less-than-or-equal-to
136 WACS_LLCORNER   0x2514  +       m       lower left-hand corner
137 WACS_LRCORNER   0x2518  +       j       lower right-hand corner
138 WACS_LTEE       0x2524  +       t       left tee
139 WACS_NEQUAL     0x2260  !       |       not-equal
140 WACS_PI 0x03c0  *       {       greek pi
141 WACS_PLMINUS    0x00b1  #       g       plus/minus
142 WACS_PLUS       0x253c  +       n       plus
143 WACS_RARROW     0x2192  >       +       arrow pointing right
144 WACS_RTEE       0x251c  +       u       right tee
145 WACS_S1 0x23ba  \-      o       scan line 1
146 WACS_S3 0x23bb  \-      p       scan line 3
147 WACS_S7 0x23bc  \-      r       scan line 7
148 WACS_S9 0x23bd  \&_     s       scan line 9
149 WACS_STERLING   0x00a3  f       }       pound-sterling symbol
150 WACS_TTEE       0x252c  +       w       top tee
151 WACS_UARROW     0x2191          ^       \-      arrow pointing up
152 WACS_ULCORNER   0x250c  +       l       upper left-hand corner
153 WACS_URCORNER   0x2510  +       k       upper right-hand corner
154 WACS_VLINE      0x2502  |       x       vertical line
155 .TE
156 .PP
157 The wide-character configuration of ncurses also defines symbols
158 for thick lines (\fBacsc\fP \*(``J\*('' to \*(``V\*(''):
159 .TS
160 l l l l l
161 l l l l l
162 _ _ _ _ _
163 lw(1.5i) lw5 lw5 lw5 lw20.
164 \fBACS\fR       \fBUnicode\fP   \fBASCII\fR     \fBacsc\fP      \fBGlyph\fR
165 \fBName\fR      \fBDefault\fP   \fBDefault\fR   \fBchar\fP      \fBName\fR
166 WACS_T_BTEE     0x253b  +       V       thick tee pointing up
167 WACS_T_HLINE    0x2501  -       Q       thick horizontal line
168 WACS_T_LLCORNER 0x2517  +       M       thick lower left corner
169 WACS_T_LRCORNER 0x251b  +       J       thick lower right corner
170 WACS_T_LTEE     0x252b  +       T       thick tee pointing right
171 WACS_T_PLUS     0x254b  +       N       thick large plus
172 WACS_T_RTEE     0x2523  +       U       thick tee pointing left
173 WACS_T_TTEE     0x2533  +       W       thick tee pointing down
174 WACS_T_ULCORNER 0x250f  +       L       thick upper left corner
175 WACS_T_URCORNER 0x2513  +       K       thick upper right corner
176 WACS_T_VLINE    0x2503  |       X       thick vertical line
177 .TE
178 .PP
179 and for double-lines (\fBacsc\fP \*(``A\*('' to \*(``I\*(''):
180 .PP
181 .TS
182 l l l l l
183 l l l l l
184 _ _ _ _ _
185 lw(1.5i) lw5 lw5 lw5 lw20.
186 \fBACS\fR       \fBUnicode\fP   \fBASCII\fR     \fBacsc\fP      \fBGlyph\fR
187 \fBName\fR      \fBDefault\fP   \fBDefault\fR   \fBchar\fP      \fBName\fR
188 WACS_D_BTEE     0x2569  +       H       double tee pointing up
189 WACS_D_HLINE    0x2550  -       R       double horizontal line
190 WACS_D_LLCORNER 0x255a  +       D       double lower left corner
191 WACS_D_LRCORNER 0x255d  +       A       double lower right corner
192 WACS_D_LTEE     0x2560  +       F       double tee pointing right
193 WACS_D_PLUS     0x256c  +       E       double large plus
194 WACS_D_RTEE     0x2563  +       G       double tee pointing left
195 WACS_D_TTEE     0x2566  +       I       double tee pointing down
196 WACS_D_ULCORNER 0x2554  +       C       double upper left corner
197 WACS_D_URCORNER 0x2557  +       B       double upper right corner
198 WACS_D_VLINE    0x2551  |       Y       double vertical line
199 .TE
200 .PP
201 Unicode's descriptions for these characters differs slightly from ncurses,
202 by introducing the term \*(``light\*('' (along with less important details).
203 Here are its descriptions for the normal, thick, and double horizontal lines:
204 .bP
205 U+2500 BOX DRAWINGS LIGHT HORIZONTAL
206 .bP
207 U+2501 BOX DRAWINGS HEAVY HORIZONTAL
208 .bP
209 U+2550 BOX DRAWINGS DOUBLE HORIZONTAL
210 .SH RETURN VALUE
211 .PP
212 All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success.
213 .PP
214 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
215 \fBwmove\fP, and return an error if the position is outside the window,
216 or if the window pointer is null.
217 .SH NOTES
218 .PP
219 Note that
220 \fBadd_wch\fP,
221 \fBmvadd_wch\fP,
222 \fBmvwadd_wch\fP, and
223 \fBecho_wchar\fP
224 may be macros.
225 .SH PORTABILITY
226 .PP
227 All of these functions are described in the XSI Curses standard, Issue 4.
228 The defaults specified for line-drawing characters apply in the POSIX locale.
229 .PP
230 X/Open Curses makes it clear that the WACS_ symbols should be defined as
231 a pointer to \fBcchar_t\fP data, e.g., in the discussion of \fBborder_set\fR.
232 A few implementations are problematic:
233 .bP
234 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
235 .bP
236 HPUX curses equates some of the \fIACS_\fP symbols
237 to the analogous \fIWACS_\fP symbols as if the \fIACS_\fP symbols were
238 wide characters.
239 The misdefined symbols are the arrows
240 and other symbols which are not used for line-drawing.
241 .PP
242 X/Open Curses does not define symbols for thick- or double-lines.
243 SVr4 curses implementations defined their line-drawing symbols in
244 terms of intermediate symbols.
245 This implementation extends those symbols, providing new definitions
246 which are not in the SVr4 implementations.
247 .PP
248 Not all Unicode-capable terminals provide support for VT100-style
249 alternate character sets (i.e., the \fBacsc\fP capability),
250 with their corresponding line-drawing characters.
251 X/Open Curses did not address the aspect of integrating Unicode with
252 line-drawing characters.
253 Existing implementations of Unix curses (AIX, HPUX, Solaris)
254 use only the \fBacsc\fP character-mapping to provide this feature.
255 As a result, those implementations can only use single-byte line-drawing
256 characters.
257 Ncurses 5.3 (2002) provided a table of Unicode values to solve these problems.
258 NetBSD curses incorporated that table in 2010.
259 .PP
260 In this implementation, the Unicode values are used instead of the
261 terminal description's \fBacsc\fP mapping as discussed in ncurses(3X)
262 for the environment variable \fBNCURSES_NO_UTF8_ACS\fP.
263 In contrast, for the same cases, the line-drawing characters
264 described in \fBcurs_addch\fP(3X) will use only the ASCII default values.
265 .PP
266 Having Unicode available does not solve all of the problems with
267 line-drawing for curses:
268 .bP
269 The closest Unicode equivalents to the
270 VT100 graphics \fIS1\fP, \fIS3\fP, \fIS7\fP and \fIS9\fP
271 frequently are not displayed at
272 the regular intervals which the terminal used.
273 .bP
274 The \fIlantern\fP is a special case.
275 It originated with the AT&T 4410 terminal in the early 1980s.
276 There is no accessible documentation depicting the lantern symbol
277 on the AT&T terminal.
278 .IP
279 Lacking documentation, most readers assume that a \fIstorm lantern\fP
280 was intended.
281 But there are several possibilities, all with problems.
282 .IP
283 Unicode 6.0 (2010) does provide two lantern symbols: U+1F383 and U+1F3EE.
284 Those were not available in 2002, and are irrelevant since
285 they lie outside the BMP and as a result are not generally available
286 in terminals.
287 They are not storm lanterns, in any case.
288 .IP
289 Most \fIstorm lanterns\fP have a tapering glass chimney
290 (to guard against tipping);
291 some have a wire grid protecting the chimney.
292 .IP
293 For the tapering appearance, \[u2603] U+2603 was adequate.
294 In use on a terminal, no one can tell what the image represents.
295 Unicode calls it a snowman.
296 .IP
297 Others have suggested these alternatives:
298 \[sc] U+00A7 (section mark),
299 \[u0398] U+0398 (theta),
300 \[u03A6] U+03A6 (phi),
301 \[u03B4] U+03B4 (delta),
302 \[u2327] U+2327 (x in a rectangle),
303 \[u256C] U+256C (forms double vertical and horizontal), and
304 \[u2612] U+2612 (ballot box with x).
305 .SH SEE ALSO
306 .na
307 .PP
308 \fBcurses\fR(3X),
309 \fBcurs_addch\fR(3X),
310 \fBcurs_attr\fR(3X),
311 \fBcurs_clear\fR(3X),
312 \fBcurs_outopts\fR(3X),
313 \fBcurs_refresh\fR(3X),
314 \fBputwc\fR(3)