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