blob: 15d859b653a51f04290a7afa51660defb3d3f0f2 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301'\" t
2.\"***************************************************************************
Steve Kondikae271bc2015-11-15 02:50:53 +01003.\" Copyright (c) 1998-2014,2015 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
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.\"
Steve Kondikae271bc2015-11-15 02:50:53 +010030.\" $Id: curs_addch.3x,v 1.36 2015/07/16 09:14:44 tom Exp $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053031.TH curs_addch 3X ""
Steve Kondikae271bc2015-11-15 02:50:53 +010032.de bP
33.IP \(bu 4
34..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053035.SH NAME
Steve Kondikae271bc2015-11-15 02:50:53 +010036\fBaddch\fR,
37\fBwaddch\fR,
38\fBmvaddch\fR,
39\fBmvwaddch\fR,
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053040\fBechochar\fR,
Steve Kondikae271bc2015-11-15 02:50:53 +010041\fBwechochar\fR \- add a character (with attributes) to a \fBcurses\fR window, then advance the cursor
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053042.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
Steve Kondikae271bc2015-11-15 02:50:53 +010058.SS Adding characters
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053059The \fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR and \fBmvwaddch\fR routines put
60the character \fIch\fR into the given window at its current window position,
61which is then advanced. They are analogous to \fBputchar\fR in \fBstdio\fR(3).
Steve Kondikae271bc2015-11-15 02:50:53 +010062If the advance is at the right margin:
63.bP
64The cursor automatically wraps to the beginning of the next line.
65.bP
66At the bottom of the current scrolling region,
67and if \fBscrollok\fR is enabled,
68the scrolling region is scrolled up one line.
69.bP
70If \fBscrollok\fR is not enabled,
71writing a character at the lower right margin succeeds.
72However, an error is returned because
73it is not possible to wrap to a new line
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053074.PP
Steve Kondikae271bc2015-11-15 02:50:53 +010075If \fIch\fR is a tab, newline, carriage return or backspace,
76the cursor is moved appropriately within the window:
77.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053078Backspace moves the cursor one character left; at the left
79edge of a window it does nothing.
Steve Kondikae271bc2015-11-15 02:50:53 +010080.bP
81Carriage return moves the cursor to the window left margin on the current line.
82.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053083Newline does a \fBclrtoeol\fR,
84then moves the cursor to the window left margin on the next line,
85scrolling the window if on the last line.
Steve Kondikae271bc2015-11-15 02:50:53 +010086.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053087Tabs are considered to be at every eighth column.
88The tab interval may be altered by setting the \fBTABSIZE\fR variable.
89.PP
Steve Kondikae271bc2015-11-15 02:50:53 +010090If \fIch\fR is any other control character, it
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053091is drawn in \fB^\fR\fIX\fR notation. Calling \fBwinch\fR after adding a
92control character does not return the character itself, but instead returns
93the ^-representation of the control character.
94.PP
95Video 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
98using \fBinch\fR and \fBaddch\fR.) See the \fBcurs_attr\fR(3X) page for
99values of predefined video attribute constants that can be usefully OR'ed
100into characters.
Steve Kondikae271bc2015-11-15 02:50:53 +0100101.SS Echoing characters
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530102.PP
103The \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
105followed by a call to \fBwrefresh\fR. The knowledge that only a single
106character is being output is used and, for non-control characters, a
107considerable performance gain may be seen by using these routines instead of
108their equivalents.
109.SS Line Graphics
110The following variables may be used to add line drawing characters to the
111screen with routines of the \fBaddch\fR family. The default character listed
112below is used if the \fBacsc\fR capability does not define a terminal-specific
113replacement for it.
114The names are taken from VT100 nomenclature.
115.PP
116.TS
117l l l
118_ _ _
119l l l.
120\fIName\fR \fIDefault\fR \fIDescription\fR
121ACS_BLOCK # solid square block
122ACS_BOARD # board of squares
123ACS_BTEE + bottom tee
124ACS_BULLET o bullet
125ACS_CKBOARD : checker board (stipple)
126ACS_DARROW v arrow pointing down
127ACS_DEGREE ' degree symbol
128ACS_DIAMOND + diamond
129ACS_GEQUAL > greater-than-or-equal-to
Steve Kondikae271bc2015-11-15 02:50:53 +0100130ACS_HLINE \- horizontal line
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530131ACS_LANTERN # lantern symbol
132ACS_LARROW < arrow pointing left
133ACS_LEQUAL < less-than-or-equal-to
134ACS_LLCORNER + lower left-hand corner
135ACS_LRCORNER + lower right-hand corner
136ACS_LTEE + left tee
137ACS_NEQUAL ! not-equal
138ACS_PI * greek pi
139ACS_PLMINUS # plus/minus
140ACS_PLUS + plus
141ACS_RARROW > arrow pointing right
142ACS_RTEE + right tee
Steve Kondikae271bc2015-11-15 02:50:53 +0100143ACS_S1 \- scan line 1
144ACS_S3 \- scan line 3
145ACS_S7 \- scan line 7
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530146ACS_S9 \&_ scan line 9
147ACS_STERLING f pound-sterling symbol
148ACS_TTEE + top tee
149ACS_UARROW ^ arrow pointing up
150ACS_ULCORNER + upper left-hand corner
151ACS_URCORNER + upper right-hand corner
152ACS_VLINE | vertical line
153.TE
154.SH RETURN VALUE
155All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
156(the SVr4 manuals specify only "an integer value other than \fBERR\fR") upon
157successful completion, unless otherwise noted in the preceding routine
158descriptions.
Steve Kondikae271bc2015-11-15 02:50:53 +0100159.PP
160Functions with a "mv" prefix first perform a cursor movement using
161\fBwmove\fP, and return an error if the position is outside the window,
162or if the window pointer is null.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530163.SH NOTES
164Note that \fBaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR, and
165\fBechochar\fR may be macros.
166.SH PORTABILITY
167All these functions are described in the XSI Curses standard, Issue 4.
168The defaults specified for forms-drawing characters apply in the POSIX locale.
169.LP
Steve Kondikae271bc2015-11-15 02:50:53 +0100170X/Open Curses states that the \fIACS_\fP definitions are \fBchar\fP constants.
171For the wide-character implementation (see \fBcurs_add_wch\fP),
172there are analogous \fIWACS_\fP definitions which are \fBcchar_t\fP constants.
173.LP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530174Some ACS symbols
175(ACS_S3,
176ACS_S7,
177ACS_LEQUAL,
178ACS_GEQUAL,
179ACS_PI,
180ACS_NEQUAL,
181ACS_STERLING)
182were not documented in
183any publicly released System V. However, many publicly available terminfos
184include \fBacsc\fR strings in which their key characters (pryz{|}) are
185embedded, and a second-hand list of their character descriptions has come
186to light. The ACS-prefixed names for them were invented for \fBncurses\fR(3X).
187.LP
188The \fBTABSIZE\fR variable is implemented in some versions of curses,
189but is not part of X/Open curses.
190.LP
191If \fIch\fR is a carriage return,
192the cursor is moved to the beginning of the current row of the window.
193This is true of other implementations, but is not documented.
194.SH SEE ALSO
195\fBcurses\fR(3X),
196\fBcurs_attr\fR(3X),
197\fBcurs_clear\fR(3X),
198\fBcurs_inch\fR(3X),
199\fBcurs_outopts\fR(3X),
200\fBcurs_refresh\fR(3X),
Steve Kondikae271bc2015-11-15 02:50:53 +0100201\fBcurs_variables\fR(3X),
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530202\fBputc\fR(3).
203.PP
204Comparable functions in the wide-character (ncursesw) library are
205described in
206\fBcurs_add_wch\fR(3X).