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