]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_addch.3x
ncurses 6.0 - patch 20170708
[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.41 2017/05/05 18:15:29 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 .IP \(bu 4
38 ..
39 .SH NAME
40 \fBaddch\fR,
41 \fBwaddch\fR,
42 \fBmvaddch\fR,
43 \fBmvwaddch\fR,
44 \fBechochar\fR,
45 \fBwechochar\fR \- add a character (with attributes) to a \fBcurses\fR window, then advance the cursor
46 .SH SYNOPSIS
47 \fB#include <curses.h>\fR
48 .PP
49 \fBint addch(const chtype ch);\fR
50 .br
51 \fBint waddch(WINDOW *win, const chtype ch);\fR
52 .br
53 \fBint mvaddch(int y, int x, const chtype ch);\fR
54 .br
55 \fBint mvwaddch(WINDOW *win, int y, int x, const chtype ch);\fR
56 .br
57 \fBint echochar(const chtype ch);\fR
58 .br
59 \fBint wechochar(WINDOW *win, const chtype ch);\fR
60 .br
61 .SH DESCRIPTION
62 .SS Adding characters
63 The \fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR and \fBmvwaddch\fR routines put
64 the character \fIch\fR into the given window at its current window position,
65 which is then advanced.  They are analogous to \fBputchar\fR(3) in \fBstdio\fR(3).
66 If the advance is at the right margin:
67 .bP
68 The cursor automatically wraps to the beginning of the next line.
69 .bP
70 At the bottom of the current scrolling region,
71 and if \fBscrollok\fR is enabled,
72 the scrolling region is scrolled up one line.
73 .bP
74 If \fBscrollok\fR is not enabled,
75 writing a character at the lower right margin succeeds.
76 However, an error is returned because
77 it is not possible to wrap to a new line
78 .PP
79 If \fIch\fR is a tab, newline, carriage return or backspace,
80 the cursor is moved appropriately within the window:
81 .bP
82 Backspace moves the cursor one character left; at the left
83 edge of a window it does nothing.
84 .bP
85 Carriage return moves the cursor to the window left margin on the current line.
86 .bP
87 Newline does a \fBclrtoeol\fR,
88 then moves the cursor to the window left margin on the next line,
89 scrolling the window if on the last line.
90 .bP
91 Tabs are considered to be at every eighth column.
92 The tab interval may be altered by setting the \fBTABSIZE\fR variable.
93 .PP
94 If \fIch\fR is any other control character, it
95 is drawn in \fB^\fR\fIX\fR notation.  Calling \fBwinch\fR after adding a
96 control character does not return the character itself, but instead returns
97 the ^-representation of the control character.
98 .PP
99 Video attributes can be combined with a character argument passed to
100 \fBaddch\fR or related functions by logical-ORing them into the character.
101 (Thus, text, including attributes, can be copied from one place to another
102 using \fBinch\fR(3X) and \fBaddch\fR.)  See the \fBcurs_attr\fR(3X) page for
103 values of predefined video attribute constants that can be usefully OR'ed
104 into characters.
105 .SS Echoing characters
106 .PP
107 The \fBechochar\fR and \fBwechochar\fR routines are equivalent to a call to
108 \fBaddch\fR followed by a call to \fBrefresh\fR(3X), or a call to \fBwaddch\fR
109 followed by a call to \fBwrefresh\fR.  The knowledge that only a single
110 character is being output is used and, for non-control characters, a
111 considerable performance gain may be seen by using these routines instead of
112 their equivalents.
113 .SS Line Graphics
114 The following variables may be used to add line drawing characters to the
115 screen with routines of the \fBaddch\fR family.  The default character listed
116 below is used if the \fBacsc\fR capability does not define a terminal-specific
117 replacement for it,
118 or if the terminal and locale configuration requires Unicode but the
119 library is unable to use Unicode.
120 .PP
121 The names are taken from VT100 nomenclature.
122 .PP
123 .TS
124 l l l l
125 l l l l
126 _ _ _ _
127 l l l l.
128 \fBACS\fR       \fBACS\fR       \fBacsc\fP      \fBGlyph\fR
129 \fBName\fR      \fBDefault\fR   \fBchar\fP      \fBName\fR
130 ACS_BLOCK       #       0       solid square block
131 ACS_BOARD       #       h       board of squares
132 ACS_BTEE        +       v       bottom tee
133 ACS_BULLET      o       ~       bullet
134 ACS_CKBOARD     :       a       checker board (stipple)
135 ACS_DARROW      v       .       arrow pointing down
136 ACS_DEGREE      '       f       degree symbol
137 ACS_DIAMOND     +       `       diamond
138 ACS_GEQUAL      >       >       greater-than-or-equal-to
139 ACS_HLINE       \-      q       horizontal line
140 ACS_LANTERN     #       i       lantern symbol
141 ACS_LARROW      <       ,       arrow pointing left
142 ACS_LEQUAL      <       y       less-than-or-equal-to
143 ACS_LLCORNER    +       m       lower left-hand corner
144 ACS_LRCORNER    +       j       lower right-hand corner
145 ACS_LTEE        +       t       left tee
146 ACS_NEQUAL      !       |       not-equal
147 ACS_PI  *       {       greek pi
148 ACS_PLMINUS     #       g       plus/minus
149 ACS_PLUS        +       n       plus
150 ACS_RARROW      >       +       arrow pointing right
151 ACS_RTEE        +       u       right tee
152 ACS_S1  \-      o       scan line 1
153 ACS_S3  \-      p       scan line 3
154 ACS_S7  \-      r       scan line 7
155 ACS_S9  \&_     s       scan line 9
156 ACS_STERLING    f       }       pound-sterling symbol
157 ACS_TTEE        +       w       top tee
158 ACS_UARROW      ^       \-      arrow pointing up
159 ACS_ULCORNER    +       l       upper left-hand corner
160 ACS_URCORNER    +       k       upper right-hand corner
161 ACS_VLINE       |       x       vertical line
162 .TE
163 .SH RETURN VALUE
164 All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
165 (the SVr4 manuals specify only
166 \*(``an integer value other than \fBERR\fR\*('') upon successful completion,
167 unless otherwise noted in the preceding routine descriptions.
168 .PP
169 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
170 \fBwmove\fP, and return an error if the position is outside the window,
171 or if the window pointer is null.
172 .SH NOTES
173 Note that \fBaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR, and
174 \fBechochar\fR may be macros.
175 .SH PORTABILITY
176 All these functions are described in the XSI Curses standard, Issue 4.
177 The defaults specified for forms-drawing characters apply in the POSIX locale.
178 .LP
179 X/Open Curses states that the \fIACS_\fP definitions are \fBchar\fP constants.
180 For the wide-character implementation (see \fBcurs_add_wch\fP),
181 there are analogous \fIWACS_\fP definitions which are \fBcchar_t\fP constants.
182 .LP
183 Some ACS symbols
184 (ACS_S3,
185 ACS_S7,
186 ACS_LEQUAL,
187 ACS_GEQUAL,
188 ACS_PI,
189 ACS_NEQUAL,
190 ACS_STERLING)
191 were not documented in
192 any publicly released System V.  However, many publicly available terminfos
193 include \fBacsc\fR strings in which their key characters (pryz{|}) are
194 embedded, and a second-hand list of their character descriptions has come
195 to light.  The ACS-prefixed names for them were invented for \fBncurses\fR(3X).
196 .LP
197 The \fIdisplayed\fP values for the \fIACS_\fP and \fIWACS_\fP constants
198 depend on 
199 .bP
200 the library configuration, i.e., \fBncurses\fP versus \fBncursesw\fP,
201 where the latter is capable of displaying Unicode while the former is not, and
202 .bP
203 whether the \fIlocale\fP uses UTF-8 encoding.
204 .LP
205 In certain cases, the terminal is unable to display line-drawing characters
206 except by using UTF-8 (see the discussion of \fBNCURSES_NO_UTF8_ACS\fP in
207 ncurses(3X)).
208 .LP
209 The \fBTABSIZE\fR variable is implemented in some versions of curses,
210 but is not part of X/Open curses.
211 .LP
212 If \fIch\fR is a carriage return,
213 the cursor is moved to the beginning of the current row of the window.
214 This is true of other implementations, but is not documented.
215 .SH SEE ALSO
216 \fBcurses\fR(3X),
217 \fBcurs_attr\fR(3X),
218 \fBcurs_clear\fR(3X),
219 \fBcurs_inch\fR(3X),
220 \fBcurs_outopts\fR(3X),
221 \fBcurs_refresh\fR(3X),
222 \fBcurs_variables\fR(3X),
223 \fBputc\fR(3).
224 .PP
225 Comparable functions in the wide-character (ncursesw) library are
226 described in
227 \fBcurs_add_wch\fR(3X).