]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_addch.3x
ncurses 6.1 - patch 20180630
[ncurses.git] / man / curs_addch.3x
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright (c) 1998-2017,2018 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.45 2018/05/19 21:03:18 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.  Calling \fBwinch\fR after adding a
98 control character does not return the character itself, but instead returns
99 the ^-representation of the control character.
100 .PP
101 Video attributes can be combined with a character argument passed to
102 \fBaddch\fR or related functions by logical-ORing them into the character.
103 (Thus, text, including attributes, can be copied from one place to another
104 using \fBinch\fR(3X) and \fBaddch\fR.)  See the \fBcurs_attr\fR(3X) page for
105 values of predefined video attribute constants that can be usefully OR'ed
106 into characters.
107 .SS Echoing characters
108 .PP
109 The \fBechochar\fR and \fBwechochar\fR routines are equivalent to a call to
110 \fBaddch\fR followed by a call to \fBrefresh\fR(3X), or a call to \fBwaddch\fR
111 followed by a call to \fBwrefresh\fR.  The knowledge that only a single
112 character is being output is used and, for non-control characters, a
113 considerable performance gain may be seen by using these routines instead of
114 their equivalents.
115 .SS Line Graphics
116 The following variables may be used to add line drawing characters to the
117 screen with routines of the \fBaddch\fR family.  The default character listed
118 below is used if the \fBacsc\fR capability does not define a terminal-specific
119 replacement for it,
120 or if the terminal and locale configuration requires Unicode but the
121 library is unable to use Unicode.
122 .PP
123 The names are taken from VT100 nomenclature.
124 .PP
125 .TS
126 l l l l
127 l l l l
128 _ _ _ _
129 l l l l.
130 \fBACS\fR       \fBACS\fR       \fBacsc\fP      \fBGlyph\fR
131 \fBName\fR      \fBDefault\fR   \fBchar\fP      \fBName\fR
132 ACS_BLOCK       #       0       solid square block
133 ACS_BOARD       #       h       board of squares
134 ACS_BTEE        +       v       bottom tee
135 ACS_BULLET      o       ~       bullet
136 ACS_CKBOARD     :       a       checker board (stipple)
137 ACS_DARROW      v       .       arrow pointing down
138 ACS_DEGREE      '       f       degree symbol
139 ACS_DIAMOND     +       `       diamond
140 ACS_GEQUAL      >       >       greater-than-or-equal-to
141 ACS_HLINE       \-      q       horizontal line
142 ACS_LANTERN     #       i       lantern symbol
143 ACS_LARROW      <       ,       arrow pointing left
144 ACS_LEQUAL      <       y       less-than-or-equal-to
145 ACS_LLCORNER    +       m       lower left-hand corner
146 ACS_LRCORNER    +       j       lower right-hand corner
147 ACS_LTEE        +       t       left tee
148 ACS_NEQUAL      !       |       not-equal
149 ACS_PI  *       {       greek pi
150 ACS_PLMINUS     #       g       plus/minus
151 ACS_PLUS        +       n       plus
152 ACS_RARROW      >       +       arrow pointing right
153 ACS_RTEE        +       u       right tee
154 ACS_S1  \-      o       scan line 1
155 ACS_S3  \-      p       scan line 3
156 ACS_S7  \-      r       scan line 7
157 ACS_S9  \&_     s       scan line 9
158 ACS_STERLING    f       }       pound-sterling symbol
159 ACS_TTEE        +       w       top tee
160 ACS_UARROW      ^       \-      arrow pointing up
161 ACS_ULCORNER    +       l       upper left-hand corner
162 ACS_URCORNER    +       k       upper right-hand corner
163 ACS_VLINE       |       x       vertical line
164 .TE
165 .SH RETURN VALUE
166 All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
167 (the SVr4 manuals specify only
168 \*(``an integer value other than \fBERR\fR\*('') upon successful completion,
169 unless otherwise noted in the preceding routine descriptions.
170 .PP
171 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
172 \fBwmove\fP, and return an error if the position is outside the window,
173 or if the window pointer is null.
174 .SH NOTES
175 Note that \fBaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR, and
176 \fBechochar\fR may be macros.
177 .SH PORTABILITY
178 All these functions are described in the XSI Curses standard, Issue 4.
179 The defaults specified for forms-drawing characters apply in the POSIX locale.
180 .SS ACS Symbols
181 .LP
182 X/Open Curses states that the \fIACS_\fP definitions are \fBchar\fP constants.
183 For the wide-character implementation (see \fBcurs_add_wch\fP),
184 there are analogous \fIWACS_\fP definitions which are \fBcchar_t\fP constants.
185 .LP
186 Some ACS symbols
187 (ACS_S3,
188 ACS_S7,
189 ACS_LEQUAL,
190 ACS_GEQUAL,
191 ACS_PI,
192 ACS_NEQUAL,
193 ACS_STERLING)
194 were not documented in
195 any publicly released System V.  However, many publicly available terminfos
196 include \fBacsc\fR strings in which their key characters (pryz{|}) are
197 embedded, and a second-hand list of their character descriptions has come
198 to light.  The ACS-prefixed names for them were invented for \fBncurses\fR(3X).
199 .LP
200 The \fIdisplayed\fP values for the \fIACS_\fP and \fIWACS_\fP constants
201 depend on 
202 .bP
203 the library configuration, i.e., \fBncurses\fP versus \fBncursesw\fP,
204 where the latter is capable of displaying Unicode while the former is not, and
205 .bP
206 whether the \fIlocale\fP uses UTF-8 encoding.
207 .LP
208 In certain cases, the terminal is unable to display line-drawing characters
209 except by using UTF-8 (see the discussion of \fBNCURSES_NO_UTF8_ACS\fP in
210 ncurses(3X)).
211 .SS Character Set
212 X/Open Curses assumes that the parameter passed to \fBwaddch\fP contains
213 a single character.
214 As discussed in \fBcurs_attr\fP(3X), that character may have been
215 more than eight bits in an SVr3 or SVr4 implementation,
216 but in the X/Open Curses model, the details are not given.
217 The important distinction between SVr4 curses and X/Open Curses is
218 that the non-character information (attributes and color) was
219 separated from the character information which is packed in a \fBchtype\fP
220 to pass to \fBwaddch\fP.
221 .PP
222 In this implementation, \fBchtype\fP holds eight bits.
223 But ncurses allows multibyte characters to be passed in a succession
224 of calls to \fBwaddch\fP.
225 The other implementations do not do this;
226 a call to \fBwaddch\fP passes exactly one character
227 which may be rendered as one or more cells on the screen
228 depending on whether it is printable.
229 .PP
230 Depending on the locale settings,
231 ncurses will inspect the byte passed in each call to \fBwaddch\fP,
232 and check if the latest call will continue a multibyte sequence.
233 When a character is \fIcomplete\fP,
234 ncurses displays the character and moves to the next position in the screen.
235 .PP
236 If the calling application interrupts the succession of bytes in
237 a multibyte character by moving the current location (e.g., using \fBwmove\fP),
238 ncurses discards the partially built character,
239 starting over again.
240 .PP
241 For portability to other implementations,
242 do not rely upon this behavior:
243 .bP
244 check if a character can be represented as a single byte in the current locale
245 before attempting call \fBwaddch\fP, and
246 .bP
247 call \fBwadd_wch\fP for characters which cannot be handled by \fBwaddch\fP.
248 .SS TABSIZE
249 .LP
250 The \fBTABSIZE\fR variable is implemented in some versions of curses,
251 but is not part of X/Open curses.
252 .LP
253 If \fIch\fR is a carriage return,
254 the cursor is moved to the beginning of the current row of the window.
255 This is true of other implementations, but is not documented.
256 .SH SEE ALSO
257 \fBcurses\fR(3X),
258 \fBcurs_attr\fR(3X),
259 \fBcurs_clear\fR(3X),
260 \fBcurs_inch\fR(3X),
261 \fBcurs_outopts\fR(3X),
262 \fBcurs_refresh\fR(3X),
263 \fBcurs_variables\fR(3X),
264 \fBputc\fR(3).
265 .PP
266 Comparable functions in the wide-character (ncursesw) library are
267 described in
268 \fBcurs_add_wch\fR(3X).