1curs_addch(3X)                                                  curs_addch(3X)
2
3
4

NAME

6       addch, waddch, mvaddch, mvwaddch, echochar, wechochar - add a character
7       (with attributes) to a curses window, then advance the cursor
8

SYNOPSIS

10       #include <curses.h>
11
12       int addch(const chtype ch);
13       int waddch(WINDOW *win, const chtype ch);
14       int mvaddch(int y, int x, const chtype ch);
15       int mvwaddch(WINDOW *win, int y, int x, const chtype ch);
16
17       int echochar(const chtype ch);
18       int wechochar(WINDOW *win, const chtype ch);
19

DESCRIPTION

21   Adding characters
22       The addch, waddch, mvaddch and mvwaddch routines put the  character  ch
23       into the given window at its current window position, which is then ad‐
24       vanced.  They are analogous to putchar(3) in stdio(3).  If the  advance
25       is at the right margin:
26
27       •   The cursor automatically wraps to the beginning of the next line.
28
29       •   At  the bottom of the current scrolling region, and if scrollok(3X)
30           is enabled, the scrolling region is scrolled up one line.
31
32       •   If scrollok(3X) is not enabled, writing a character  at  the  lower
33           right margin succeeds.  However, an error is returned because it is
34           not possible to wrap to a new line
35
36       If ch is a tab, newline, carriage return or backspace,  the  cursor  is
37       moved appropriately within the window:
38
39       •   Backspace  moves the cursor one character left; at the left edge of
40           a window it does nothing.
41
42       •   Carriage return moves the cursor to the window left margin  on  the
43           current line.
44
45       •   Newline  does  a clrtoeol, then moves the cursor to the window left
46           margin on the next line, scrolling the window if on the last line.
47
48       •   Tabs are considered to be at every eighth column.  The tab interval
49           may be altered by setting the TABSIZE variable.
50
51       If  ch  is  any  other nonprintable character, it is drawn in printable
52       form, using the same convention as unctrl(3X):
53
54       •   Control characters are displayed in the ^X notation.
55
56       •   Values above 128 are either meta characters (if the screen has  not
57           been  initialized, or if meta(3X) has been called with a TRUE E pa‐
58           rameter), shown in the M-X notation,  or  are  displayed  as  them‐
59           selves.   In the latter case, the values may not be printable; this
60           follows the X/Open specification.
61
62       Calling winch after adding a nonprintable character does not return the
63       character  itself,  but instead returns the printable representation of
64       the character.
65
66       Video attributes can be combined with a character  argument  passed  to
67       addch  or  related  functions by logical-ORing them into the character.
68       (Thus, text, including attributes, can be copied from one place to  an‐
69       other using inch(3X) and addch.)  See the curs_attr(3X) page for values
70       of predefined video attribute constants that can be usefully OR'ed into
71       characters.
72
73   Echoing characters
74       The  echochar  and wechochar routines are equivalent to a call to addch
75       followed by a call to refresh(3X), or a call to waddch  followed  by  a
76       call  to wrefresh.  The knowledge that only a single character is being
77       output is used and, for non-control characters, a considerable  perfor‐
78       mance gain may be seen by using these routines instead of their equiva‐
79       lents.
80
81   Line Graphics
82       The following variables may be used to add line drawing  characters  to
83       the  screen  with  routines of the addch family.  The default character
84       listed below is used if the acsc capability does not define a terminal-
85       specific  replacement  for it, or if the terminal and locale configura‐
86       tion requires Unicode but the library is unable to use Unicode.
87
88       The names are taken from VT100 nomenclature.
89
90       ACS            ACS       acsc   Glyph
91       Name           Default   char   Name
92       ─────────────────────────────────────────────────────────
93       ACS_BLOCK      #         0      solid square block
94       ACS_BOARD      #         h      board of squares
95       ACS_BTEE       +         v      bottom tee
96       ACS_BULLET     o         ~      bullet
97       ACS_CKBOARD    :         a      checker board (stipple)
98       ACS_DARROW     v         .      arrow pointing down
99       ACS_DEGREE     '         f      degree symbol
100       ACS_DIAMOND    +         `      diamond
101       ACS_GEQUAL     >         >      greater-than-or-equal-to
102       ACS_HLINE      -         q      horizontal line
103       ACS_LANTERN    #         i      lantern symbol
104       ACS_LARROW     <         ,      arrow pointing left
105       ACS_LEQUAL     <         y      less-than-or-equal-to
106       ACS_LLCORNER   +         m      lower left-hand corner
107       ACS_LRCORNER   +         j      lower right-hand corner
108       ACS_LTEE       +         t      left tee
109       ACS_NEQUAL     !         |      not-equal
110       ACS_PI         *         {      greek pi
111       ACS_PLMINUS    #         g      plus/minus
112       ACS_PLUS       +         n      plus
113       ACS_RARROW     >         +      arrow pointing right
114       ACS_RTEE       +         u      right tee
115       ACS_S1         -         o      scan line 1
116       ACS_S3         -         p      scan line 3
117       ACS_S7         -         r      scan line 7
118       ACS_S9         _         s      scan line 9
119       ACS_STERLING   f         }      pound-sterling symbol
120       ACS_TTEE       +         w      top tee
121       ACS_UARROW     ^         -      arrow pointing up
122       ACS_ULCORNER   +         l      upper left-hand corner
123       ACS_URCORNER   +         k      upper right-hand corner
124       ACS_VLINE      |         x      vertical line
125

RETURN VALUE

127       All routines return the integer ERR upon failure and OK on success (the
128       SVr4  manuals specify only “an integer value other than ERR”) upon suc‐
129       cessful completion, unless otherwise noted in the preceding routine de‐
130       scriptions.
131
132       Functions  with  a  “mv”  prefix  first perform a cursor movement using
133       wmove, and return an error if the position is outside the window, or if
134       the window pointer is null.
135
136       If  it  is  not  possible  to add a complete character, an error is re‐
137       turned:
138
139       •   If scrollok(3X) is not enabled, writing a character  at  the  lower
140           right margin succeeds.  However, an error is returned because it is
141           not possible to wrap to a new line
142
143       •   If an error is detected when converting a multibyte character to  a
144           sequence  of  bytes, or if it is not possible to add all of the re‐
145           sulting bytes in the window, an error is returned.
146

NOTES

148       Note that addch, mvaddch, mvwaddch, and echochar may be macros.
149

PORTABILITY

151       All these functions are described in the XSI Curses standard, Issue  4.
152       The  defaults specified for forms-drawing characters apply in the POSIX
153       locale.
154
155   ACS Symbols
156       X/Open Curses states that the ACS_ definitions are char constants.  For
157       the  wide-character implementation (see curs_add_wch), there are analo‐
158       gous WACS_ definitions which are cchar_t constants.   Some  implementa‐
159       tions are problematic:
160
161       •   Some  implementations define the ACS symbols to a constant (such as
162           Solaris), while others define those to entries in an array.
163
164           This implementation uses an array acs_map, as done in SVr4  curses.
165           NetBSD also uses an array, actually named _acs_char, with a #define
166           for compatibility.
167
168       •   HPUX curses equates some of the ACS_ symbols to the analogous WACS_
169           symbols  as  if  the ACS_ symbols were wide characters.  The misde‐
170           fined symbols are the arrows and other symbols which are  not  used
171           for line-drawing.
172
173       •   X/Open  Curses  (issues  2 through 7) has a typographical error for
174           the ACS_LANTERN symbol, equating its “VT100+ Character” to I (capi‐
175           tal  I), while the header files for SVr4 curses and the various im‐
176           plementations use i (lowercase).
177
178           None of the terminal descriptions on Unix platforms use  uppercase-
179           I,  except for Solaris (i.e., screen's terminal description, appar‐
180           ently based on the X/Open documentation around 1995).  On the other
181           hand,  the terminal description gs6300 (AT&T PC6300 with EMOTS Ter‐
182           minal Emulator) uses lowercase-i.
183
184       Some ACS  symbols  (ACS_S3,  ACS_S7,  ACS_LEQUAL,  ACS_GEQUAL,  ACS_PI,
185       ACS_NEQUAL,  ACS_STERLING) were not documented in any publicly released
186       System V.  However, many  publicly  available  terminfos  include  acsc
187       strings  in  which  their  key characters (pryz{|}) are embedded, and a
188       second-hand list of their character descriptions  has  come  to  light.
189       The ACS-prefixed names for them were invented for ncurses(3X).
190
191       The displayed values for the ACS_ and WACS_ constants depend on
192
193       •   the library configuration, i.e., ncurses versus ncursesw, where the
194           latter is capable of displaying Unicode while the  former  is  not,
195           and
196
197       •   whether the locale uses UTF-8 encoding.
198
199       In  certain cases, the terminal is unable to display line-drawing char‐
200       acters except by using UTF-8 (see the discussion of NCURSES_NO_UTF8_ACS
201       in ncurses(3X)).
202
203   Character Set
204       X/Open  Curses  assumes  that the parameter passed to waddch contains a
205       single character.  As discussed in curs_attr(3X),  that  character  may
206       have  been  more than eight bits in an SVr3 or SVr4 implementation, but
207       in the X/Open Curses model, the details are not given.   The  important
208       distinction between SVr4 curses and X/Open Curses is that the non-char‐
209       acter information (attributes and color) was separated from the charac‐
210       ter information which is packed in a chtype to pass to waddch.
211
212       In  this  implementation,  chtype  holds  an  eight-bit character.  But
213       ncurses allows multibyte characters to be passed  in  a  succession  of
214       calls  to  waddch.  The other implementations do not do this; a call to
215       waddch passes exactly one character which may be  rendered  as  one  or
216       more cells on the screen depending on whether it is printable.
217
218       Depending  on the locale settings, ncurses will inspect the byte passed
219       in each call to waddch, and check if the latest call  will  continue  a
220       multibyte sequence.  When a character is complete, ncurses displays the
221       character and moves to the next position in the screen.
222
223       If the calling application interrupts the  succession  of  bytes  in  a
224       multibyte character by moving the current location (e.g., using wmove),
225       ncurses discards the partially built character, starting over again.
226
227       For portability to other implementations, do not rely upon this  behav‐
228       ior:
229
230       •   check  if  a  character  can be represented as a single byte in the
231           current locale before attempting call waddch, and
232
233       •   call wadd_wch for characters which cannot be handled by waddch.
234
235   TABSIZE
236       The TABSIZE variable is implemented  in  SVr4  and  other  versions  of
237       curses,  but  is  not part of X/Open curses (see curs_variables(3X) for
238       more details).
239
240       If ch is a carriage return, the cursor is moved to the beginning of the
241       current  row of the window.  This is true of other implementations, but
242       is not documented.
243

SEE ALSO

245       curses(3X),  curs_attr(3X),  curs_clear(3X),  curs_inch(3X),  curs_out‐
246       opts(3X), curs_refresh(3X), curs_variables(3X), putc(3).
247
248       Comparable  functions  in the wide-character (ncursesw) library are de‐
249       scribed in curs_add_wch(3X).
250
251
252
253                                                                curs_addch(3X)
Impressum