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