]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_add_wch.3x
ncurses 6.2 - patch 20200215
[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.26 2020/02/02 23:34:34 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 .br
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 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
216 \fBwmove\fP, and return an error if the position is outside the window,
217 or if the window pointer is null.
218 .SH NOTES
219 .PP
220 Note that
221 \fBadd_wch\fP,
222 \fBmvadd_wch\fP,
223 \fBmvwadd_wch\fP, and
224 \fBecho_wchar\fP
225 may be macros.
226 .SH PORTABILITY
227 .PP
228 All of these functions are described in the XSI Curses standard, Issue 4.
229 The defaults specified for line-drawing characters apply in the POSIX locale.
230 .PP
231 X/Open Curses makes it clear that the WACS_ symbols should be defined as
232 a pointer to \fBcchar_t\fP data, e.g., in the discussion of \fBborder_set\fR.
233 A few implementations are problematic:
234 .bP
235 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
236 .bP
237 HPUX curses equates some of the \fIACS_\fP symbols
238 to the analogous \fIWACS_\fP symbols as if the \fIACS_\fP symbols were
239 wide characters.
240 The misdefined symbols are the arrows
241 and other symbols which are not used for line-drawing.
242 .PP
243 X/Open Curses does not define symbols for thick- or double-lines.
244 SVr4 curses implementations defined their line-drawing symbols in
245 terms of intermediate symbols.
246 This implementation extends those symbols, providing new definitions
247 which are not in the SVr4 implementations.
248 .PP
249 Not all Unicode-capable terminals provide support for VT100-style
250 alternate character sets (i.e., the \fBacsc\fP capability),
251 with their corresponding line-drawing characters.
252 X/Open Curses did not address the aspect of integrating Unicode with
253 line-drawing characters.
254 Existing implementations of Unix curses (AIX, HPUX, Solaris)
255 use only the \fBacsc\fP character-mapping to provide this feature.
256 As a result, those implementations can only use single-byte line-drawing
257 characters.
258 Ncurses 5.3 (2002) provided a table of Unicode values to solve these problems.
259 NetBSD curses incorporated that table in 2010.
260 .PP
261 In this implementation, the Unicode values are used instead of the
262 terminal description's \fBacsc\fP mapping as discussed in ncurses(3X)
263 for the environment variable \fBNCURSES_NO_UTF8_ACS\fP.
264 In contrast, for the same cases, the line-drawing characters
265 described in \fBcurs_addch\fP(3X) will use only the ASCII default values.
266 .PP
267 Having Unicode available does not solve all of the problems with
268 line-drawing for curses:
269 .bP
270 The closest Unicode equivalents to the
271 VT100 graphics \fIS1\fP, \fIS3\fP, \fIS7\fP and \fIS9\fP
272 frequently are not displayed at
273 the regular intervals which the terminal used.
274 .bP
275 The \fIlantern\fP is a special case.
276 It originated with the AT&T 4410 terminal in the early 1980s.
277 There is no accessible documentation depicting the lantern symbol
278 on the AT&T terminal.
279 .IP
280 Lacking documentation, most readers assume that a \fIstorm lantern\fP
281 was intended.
282 But there are several possibilities, all with problems.
283 .IP
284 Unicode 6.0 (2010) does provide two lantern symbols: U+1F383 and U+1F3EE.
285 Those were not available in 2002, and are irrelevant since
286 they lie outside the BMP and as a result are not generally available
287 in terminals.
288 They are not storm lanterns, in any case.
289 .IP
290 Most \fIstorm lanterns\fP have a tapering glass chimney
291 (to guard against tipping);
292 some have a wire grid protecting the chimney.
293 .IP
294 For the tapering appearance, \[u2603] U+2603 was adequate.
295 In use on a terminal, no one can tell what the image represents.
296 Unicode calls it a snowman.
297 .IP
298 Others have suggested these alternatives:
299 \[sc] U+00A7 (section mark),
300 \[u0398] U+0398 (theta),
301 \[u03A6] U+03A6 (phi),
302 \[u03B4] U+03B4 (delta),
303 \[u2327] U+2327 (x in a rectangle),
304 \[u256C] U+256C (forms double vertical and horizontal), and
305 \[u2612] U+2612 (ballot box with x).
306 .SH SEE ALSO
307 .na
308 .PP
309 \fBcurses\fR(3X),
310 \fBcurs_addch\fR(3X),
311 \fBcurs_attr\fR(3X),
312 \fBcurs_clear\fR(3X),
313 \fBcurs_outopts\fR(3X),
314 \fBcurs_refresh\fR(3X),
315 \fBputwc\fR(3)