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