]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_addch.3x
ncurses 6.1 - patch 20191221
[ncurses.git] / man / curs_addch.3x
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright (c) 1998-2018,2019 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_addch.3x,v 1.50 2019/11/30 20:07:00 tom Exp $
31 .TH curs_addch 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 \fBaddch\fR,
42 \fBwaddch\fR,
43 \fBmvaddch\fR,
44 \fBmvwaddch\fR,
45 \fBechochar\fR,
46 \fBwechochar\fR \- add a character (with attributes) to a \fBcurses\fR window, then advance the cursor
47 .SH SYNOPSIS
48 \fB#include <curses.h>\fR
49 .PP
50 \fBint addch(const chtype ch);\fR
51 .br
52 \fBint waddch(WINDOW *win, const chtype ch);\fR
53 .br
54 \fBint mvaddch(int y, int x, const chtype ch);\fR
55 .br
56 \fBint mvwaddch(WINDOW *win, int y, int x, const chtype ch);\fR
57 .br
58 \fBint echochar(const chtype ch);\fR
59 .br
60 \fBint wechochar(WINDOW *win, const chtype ch);\fR
61 .br
62 .SH DESCRIPTION
63 .SS Adding characters
64 The \fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR and \fBmvwaddch\fR routines put
65 the character \fIch\fR into the given window at its current window position,
66 which is then advanced.
67 They are analogous to \fBputchar\fR(3) in \fBstdio\fR(3).
68 If the advance is at the right margin:
69 .bP
70 The cursor automatically wraps to the beginning of the next line.
71 .bP
72 At the bottom of the current scrolling region,
73 and if \fBscrollok\fR is enabled,
74 the scrolling region is scrolled up one line.
75 .bP
76 If \fBscrollok\fR is not enabled,
77 writing a character at the lower right margin succeeds.
78 However, an error is returned because
79 it is not possible to wrap to a new line
80 .PP
81 If \fIch\fR is a tab, newline, carriage return or backspace,
82 the cursor is moved appropriately within the window:
83 .bP
84 Backspace moves the cursor one character left; at the left
85 edge of a window it does nothing.
86 .bP
87 Carriage return moves the cursor to the window left margin on the current line.
88 .bP
89 Newline does a \fBclrtoeol\fR,
90 then moves the cursor to the window left margin on the next line,
91 scrolling the window if on the last line.
92 .bP
93 Tabs are considered to be at every eighth column.
94 The tab interval may be altered by setting the \fBTABSIZE\fR variable.
95 .PP
96 If \fIch\fR is any other control character, it
97 is drawn in \fB^\fR\fIX\fR notation.
98 Calling \fBwinch\fR after adding a
99 control character does not return the character itself, but instead returns
100 the ^-representation of the control character.
101 .PP
102 Video attributes can be combined with a character argument passed to
103 \fBaddch\fR or related functions by logical-ORing them into the character.
104 (Thus, text, including attributes, can be copied from one place to another
105 using \fBinch\fR(3X) and \fBaddch\fR.)  See the \fBcurs_attr\fR(3X) page for
106 values of predefined video attribute constants that can be usefully OR'ed
107 into characters.
108 .SS Echoing characters
109 .PP
110 The \fBechochar\fR and \fBwechochar\fR routines are equivalent to a call to
111 \fBaddch\fR followed by a call to \fBrefresh\fR(3X), or a call to \fBwaddch\fR
112 followed by a call to \fBwrefresh\fR.
113 The knowledge that only a single
114 character is being output is used and, for non-control characters, a
115 considerable performance gain may be seen by using these routines instead of
116 their equivalents.
117 .SS Line Graphics
118 The following variables may be used to add line drawing characters to the
119 screen with routines of the \fBaddch\fR family.
120 The default character listed
121 below is used if the \fBacsc\fR capability does not define a terminal-specific
122 replacement for it,
123 or if the terminal and locale configuration requires Unicode but the
124 library is unable to use Unicode.
125 .PP
126 The names are taken from VT100 nomenclature.
127 .PP
128 .TS
129 l l l l
130 l l l l
131 _ _ _ _
132 l l l l.
133 \fBACS\fR       \fBACS\fR       \fBacsc\fP      \fBGlyph\fR
134 \fBName\fR      \fBDefault\fR   \fBchar\fP      \fBName\fR
135 ACS_BLOCK       #       0       solid square block
136 ACS_BOARD       #       h       board of squares
137 ACS_BTEE        +       v       bottom tee
138 ACS_BULLET      o       ~       bullet
139 ACS_CKBOARD     :       a       checker board (stipple)
140 ACS_DARROW      v       .       arrow pointing down
141 ACS_DEGREE      '       f       degree symbol
142 ACS_DIAMOND     +       `       diamond
143 ACS_GEQUAL      >       >       greater-than-or-equal-to
144 ACS_HLINE       \-      q       horizontal line
145 ACS_LANTERN     #       i       lantern symbol
146 ACS_LARROW      <       ,       arrow pointing left
147 ACS_LEQUAL      <       y       less-than-or-equal-to
148 ACS_LLCORNER    +       m       lower left-hand corner
149 ACS_LRCORNER    +       j       lower right-hand corner
150 ACS_LTEE        +       t       left tee
151 ACS_NEQUAL      !       |       not-equal
152 ACS_PI  *       {       greek pi
153 ACS_PLMINUS     #       g       plus/minus
154 ACS_PLUS        +       n       plus
155 ACS_RARROW      >       +       arrow pointing right
156 ACS_RTEE        +       u       right tee
157 ACS_S1  \-      o       scan line 1
158 ACS_S3  \-      p       scan line 3
159 ACS_S7  \-      r       scan line 7
160 ACS_S9  \&_     s       scan line 9
161 ACS_STERLING    f       }       pound-sterling symbol
162 ACS_TTEE        +       w       top tee
163 ACS_UARROW      ^       \-      arrow pointing up
164 ACS_ULCORNER    +       l       upper left-hand corner
165 ACS_URCORNER    +       k       upper right-hand corner
166 ACS_VLINE       |       x       vertical line
167 .TE
168 .SH RETURN VALUE
169 All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
170 (the SVr4 manuals specify only
171 \*(``an integer value other than \fBERR\fR\*('') upon successful completion,
172 unless otherwise noted in the preceding routine descriptions.
173 .PP
174 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
175 \fBwmove\fP, and return an error if the position is outside the window,
176 or if the window pointer is null.
177 .SH NOTES
178 Note that \fBaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR, and
179 \fBechochar\fR may be macros.
180 .SH PORTABILITY
181 All these functions are described in the XSI Curses standard, Issue 4.
182 The defaults specified for forms-drawing characters apply in the POSIX locale.
183 .SS ACS Symbols
184 .LP
185 X/Open Curses states that the \fIACS_\fP definitions are \fBchar\fP constants.
186 For the wide-character implementation (see \fBcurs_add_wch\fP),
187 there are analogous \fIWACS_\fP definitions which are \fBcchar_t\fP constants.
188 Some implementations are problematic:
189 .bP
190 Some implementations define the ACS symbols to a constant
191 (such as Solaris), while others define those to entries in an array.
192 .IP
193 This implementation uses an array \fBacs_map\fP, as done in SVr4 curses.
194 NetBSD also uses an array, actually named \fB_acs_char\fP, with a \fB#define\fP
195 for compatibility.
196 .bP
197 HPUX curses equates some of the \fIACS_\fP symbols
198 to the analogous \fIWACS_\fP symbols as if the \fIACS_\fP symbols were
199 wide characters.
200 The misdefined symbols are the arrows
201 and other symbols which are not used for line-drawing.
202 .bP
203 X/Open Curses (issues 2 through 7) has a typographical error
204 for the ACS_LANTERN symbol, equating its \*(``VT100+ Character\*(''
205 to \fBI\fP (capital I), while the header files for SVr4 curses
206 and the various implementations use \fBi\fP (lowercase).
207 .IP
208 None of the terminal descriptions on Unix platforms use uppercase-I,
209 except for Solaris (i.e., \fIscreen\fP's terminal description,
210 apparently based on the X/Open documentation around 1995).
211 On the other hand, the terminal description \fIgs6300\fP
212 (AT&T PC6300 with EMOTS Terminal Emulator) uses lowercase-i.
213 .LP
214 Some ACS symbols
215 (ACS_S3,
216 ACS_S7,
217 ACS_LEQUAL,
218 ACS_GEQUAL,
219 ACS_PI,
220 ACS_NEQUAL,
221 ACS_STERLING)
222 were not documented in
223 any publicly released System V.
224 However, many publicly available terminfos
225 include \fBacsc\fR strings in which their key characters (pryz{|}) are
226 embedded, and a second-hand list of their character descriptions has come
227 to light.
228 The ACS-prefixed names for them were invented for \fBncurses\fR(3X).
229 .LP
230 The \fIdisplayed\fP values for the \fIACS_\fP and \fIWACS_\fP constants
231 depend on 
232 .bP
233 the library configuration, i.e., \fBncurses\fP versus \fBncursesw\fP,
234 where the latter is capable of displaying Unicode while the former is not, and
235 .bP
236 whether the \fIlocale\fP uses UTF-8 encoding.
237 .LP
238 In certain cases, the terminal is unable to display line-drawing characters
239 except by using UTF-8 (see the discussion of \fBNCURSES_NO_UTF8_ACS\fP in
240 ncurses(3X)).
241 .SS Character Set
242 X/Open Curses assumes that the parameter passed to \fBwaddch\fP contains
243 a single character.
244 As discussed in \fBcurs_attr\fP(3X), that character may have been
245 more than eight bits in an SVr3 or SVr4 implementation,
246 but in the X/Open Curses model, the details are not given.
247 The important distinction between SVr4 curses and X/Open Curses is
248 that the non-character information (attributes and color) was
249 separated from the character information which is packed in a \fBchtype\fP
250 to pass to \fBwaddch\fP.
251 .PP
252 In this implementation, \fBchtype\fP holds an eight-bit character.
253 But ncurses allows multibyte characters to be passed in a succession
254 of calls to \fBwaddch\fP.
255 The other implementations do not do this;
256 a call to \fBwaddch\fP passes exactly one character
257 which may be rendered as one or more cells on the screen
258 depending on whether it is printable.
259 .PP
260 Depending on the locale settings,
261 ncurses will inspect the byte passed in each call to \fBwaddch\fP,
262 and check if the latest call will continue a multibyte sequence.
263 When a character is \fIcomplete\fP,
264 ncurses displays the character and moves to the next position in the screen.
265 .PP
266 If the calling application interrupts the succession of bytes in
267 a multibyte character by moving the current location (e.g., using \fBwmove\fP),
268 ncurses discards the partially built character,
269 starting over again.
270 .PP
271 For portability to other implementations,
272 do not rely upon this behavior:
273 .bP
274 check if a character can be represented as a single byte in the current locale
275 before attempting call \fBwaddch\fP, and
276 .bP
277 call \fBwadd_wch\fP for characters which cannot be handled by \fBwaddch\fP.
278 .SS TABSIZE
279 .LP
280 The \fBTABSIZE\fR variable is implemented in SVr4 and other versions of curses,
281 but is not part of X/Open curses
282 (see \fBcurs_variables\fR(3X) for more details).
283 .LP
284 If \fIch\fR is a carriage return,
285 the cursor is moved to the beginning of the current row of the window.
286 This is true of other implementations, but is not documented.
287 .SH SEE ALSO
288 \fBcurses\fR(3X),
289 \fBcurs_attr\fR(3X),
290 \fBcurs_clear\fR(3X),
291 \fBcurs_inch\fR(3X),
292 \fBcurs_outopts\fR(3X),
293 \fBcurs_refresh\fR(3X),
294 \fBcurs_variables\fR(3X),
295 \fBputc\fR(3).
296 .PP
297 Comparable functions in the wide-character (ncursesw) library are
298 described in
299 \fBcurs_add_wch\fR(3X).