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