]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_add_wch.3x
ncurses 6.1 - patch 20190601
[ncurses.git] / man / curs_add_wch.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 2001-2015,2017 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.24 2017/11/18 23:47:37 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 double-lines:
159 .PP
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_D_BTEE     0x2569  +       H       double tee pointing up
168 WACS_D_HLINE    0x2550  -       R       double horizontal line
169 WACS_D_LLCORNER 0x255a  +       D       double lower left corner
170 WACS_D_LRCORNER 0x255d  +       A       double lower right corner
171 WACS_D_LTEE     0x2560  +       F       double tee pointing right
172 WACS_D_PLUS     0x256c  +       E       double large plus
173 WACS_D_RTEE     0x2563  +       G       double tee pointing left
174 WACS_D_TTEE     0x2566  +       I       double tee pointing down
175 WACS_D_ULCORNER 0x2554  +       C       double upper left corner
176 WACS_D_URCORNER 0x2557  +       B       double upper right corner
177 WACS_D_VLINE    0x2551  |       Y       double vertical line
178 .TE
179 .PP
180 and for thick lines:
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_T_BTEE     0x253b  +       V       thick tee pointing up
189 WACS_T_HLINE    0x2501  -       Q       thick horizontal line
190 WACS_T_LLCORNER 0x2517  +       M       thick lower left corner
191 WACS_T_LRCORNER 0x251b  +       J       thick lower right corner
192 WACS_T_LTEE     0x252b  +       T       thick tee pointing right
193 WACS_T_PLUS     0x254b  +       N       thick large plus
194 WACS_T_RTEE     0x2523  +       U       thick tee pointing left
195 WACS_T_TTEE     0x2533  +       W       thick tee pointing down
196 WACS_T_ULCORNER 0x250f  +       L       thick upper left corner
197 WACS_T_URCORNER 0x2513  +       K       thick upper right corner
198 WACS_T_VLINE    0x2503  |       X       thick vertical line
199 .TE
200 .SH RETURN VALUE
201 .PP
202 All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success.
203 .PP
204 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
205 \fBwmove\fP, and return an error if the position is outside the window,
206 or if the window pointer is null.
207 .SH NOTES
208 .PP
209 Note that
210 \fBadd_wch\fP,
211 \fBmvadd_wch\fP,
212 \fBmvwadd_wch\fP, and
213 \fBecho_wchar\fP
214 may be macros.
215 .SH PORTABILITY
216 .PP
217 All of these functions are described in the XSI Curses standard, Issue 4.
218 The defaults specified for line-drawing characters apply in the POSIX locale.
219 .PP
220 X/Open Curses makes it clear that the WACS_ symbols should be defined as
221 a pointer to \fBcchar_t\fP data, e.g., in the discussion of \fBborder_set\fR.
222 A few implementations are problematic:
223 .bP
224 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
225 .bP
226 HPUX curses equates some of the \fIACS_\fP symbols
227 to the analogous \fIWACS_\fP symbols as if the \fIACS_\fP symbols were
228 wide characters.
229 The misdefined symbols are the arrows
230 and other symbols which are not used for line-drawing.
231 .PP
232 X/Open Curses does not define symbols for thick- or double-lines.
233 SVr4 curses implementations defined their line-drawing symbols in
234 terms of intermediate symbols.
235 This implementation extends those symbols, providing new definitions
236 which are not in the SVr4 implementations.
237 .PP
238 Not all Unicode-capable terminals provide support for VT100-style
239 alternate character sets (i.e., the \fBacsc\fP capability),
240 with their corresponding line-drawing characters.
241 X/Open Curses did not address the aspect of integrating Unicode with
242 line-drawing characters.
243 Existing implementations of Unix curses (AIX, HPUX, Solaris)
244 use only the \fBacsc\fP character-mapping to provide this feature.
245 As a result, those implementations can only use single-byte line-drawing
246 characters.
247 Ncurses 5.3 (2002) provided a table of Unicode values to solve these problems.
248 NetBSD curses incorporated that table in 2010.
249 .PP
250 In this implementation, the Unicode values are used instead of the
251 terminal description's \fBacsc\fP mapping as discussed in ncurses(3X)
252 for the environment variable \fBNCURSES_NO_UTF8_ACS\fP.
253 In contrast, for the same cases, the line-drawing characters
254 described in \fBcurs_addch\fP(3X) will use only the ASCII default values.
255 .PP
256 Having Unicode available does not solve all of the problems with
257 line-drawing for curses:
258 .bP
259 The closest Unicode equivalents to the
260 VT100 graphics \fIS1\fP, \fIS3\fP, \fIS7\fP and \fIS9\fP
261 frequently are not displayed at
262 the regular intervals which the terminal used.
263 .bP
264 The \fIlantern\fP is a special case.
265 It originated with the AT&T 4410 terminal in the early 1980s.
266 There is no accessible documentation depicting the lantern symbol
267 on the AT&T terminal.
268 .IP
269 Lacking documentation, most readers assume that a \fIstorm lantern\fP
270 was intended.
271 But there are several possibilities, all with problems.
272 .IP
273 Unicode 6.0 (2010) does provide two lantern symbols: U+1F383 and U+1F3EE.
274 Those were not available in 2002, and are irrelevant since
275 they lie outside the BMP and as a result are not generally available
276 in terminals.
277 They are not storm lanterns, in any case.
278 .IP
279 Most \fIstorm lanterns\fP have a tapering glass chimney
280 (to guard against tipping);
281 some have a wire grid protecting the chimney.
282 .IP
283 For the tapering appearance, \[u2603] U+2603 was adequate.
284 In use on a terminal, no one can tell what the image represents.
285 Unicode calls it a snowman.
286 .IP
287 Others have suggested these alternatives:
288 \[sc] U+00A7 (section mark),
289 \[u0398] U+0398 (theta),
290 \[u03A6] U+03A6 (phi),
291 \[u03B4] U+03B4 (delta),
292 \[u2327] U+2327 (x in a rectangle),
293 \[u256C] U+256C (forms double vertical and horizontal), and
294 \[u2612] U+2612 (ballot box with x).
295 .SH SEE ALSO
296 .na
297 .PP
298 \fBcurses\fR(3X),
299 \fBcurs_addch\fR(3X),
300 \fBcurs_attr\fR(3X),
301 \fBcurs_clear\fR(3X),
302 \fBcurs_outopts\fR(3X),
303 \fBcurs_refresh\fR(3X),
304 \fBputwc\fR(3)