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       int echochar(const chtype ch);
17       int wechochar(WINDOW *win, const chtype ch);
18

DESCRIPTION

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

RETURN VALUE

116       All routines return the integer ERR upon failure and OK on success (the
117       SVr4  manuals specify only “an integer value other than ERR”) upon suc‐
118       cessful completion, unless otherwise noted  in  the  preceding  routine
119       descriptions.
120
121       Functions  with  a  “mv”  prefix  first perform a cursor movement using
122       wmove, and return an error if the position is outside the window, or if
123       the window pointer is null.
124

NOTES

126       Note that addch, mvaddch, mvwaddch, and echochar may be macros.
127

PORTABILITY

129       All  these functions are described in the XSI Curses standard, Issue 4.
130       The defaults specified for forms-drawing characters apply in the  POSIX
131       locale.
132
133   ACS Symbols
134       X/Open Curses states that the ACS_ definitions are char constants.  For
135       the wide-character implementation (see curs_add_wch), there are  analo‐
136       gous WACS_ definitions which are cchar_t constants.
137
138       Some  ACS  symbols  (ACS_S3,  ACS_S7,  ACS_LEQUAL,  ACS_GEQUAL, ACS_PI,
139       ACS_NEQUAL, ACS_STERLING) were not documented in any publicly  released
140       System  V.   However,  many  publicly  available terminfos include acsc
141       strings in which their key characters (pryz{|})  are  embedded,  and  a
142       second-hand  list  of  their  character descriptions has come to light.
143       The ACS-prefixed names for them were invented for ncurses(3X).
144
145       The displayed values for the ACS_ and WACS_ constants depend on
146
147       ·   the library configuration, i.e., ncurses versus ncursesw, where the
148           latter  is  capable  of displaying Unicode while the former is not,
149           and
150
151       ·   whether the locale uses UTF-8 encoding.
152
153       In certain cases, the terminal is unable to display line-drawing  char‐
154       acters except by using UTF-8 (see the discussion of NCURSES_NO_UTF8_ACS
155       in ncurses(3X)).
156
157   Character Set
158       X/Open Curses assumes that the parameter passed to  waddch  contains  a
159       single  character.   As  discussed in curs_attr(3X), that character may
160       have been more than eight bits in an SVr3 or SVr4  implementation,  but
161       in  the  X/Open Curses model, the details are not given.  The important
162       distinction between SVr4 curses and X/Open Curses is that the non-char‐
163       acter information (attributes and color) was separated from the charac‐
164       ter information which is packed in a chtype to pass to waddch.
165
166       In this implementation, chtype holds eight bits.   But  ncurses  allows
167       multibyte  characters  to be passed in a succession of calls to waddch.
168       The other implementations do not do  this;  a  call  to  waddch  passes
169       exactly one character which may be rendered as one or more cells on the
170       screen depending on whether it is printable.
171
172       Depending on the locale settings, ncurses will inspect the byte  passed
173       in  each  call  to waddch, and check if the latest call will continue a
174       multibyte sequence.  When a character is complete, ncurses displays the
175       character and moves to the next position in the screen.
176
177       If  the  calling  application  interrupts  the succession of bytes in a
178       multibyte character by moving the current location (e.g., using wmove),
179       ncurses discards the partially built character, starting over again.
180
181       For  portability to other implementations, do not rely upon this behav‐
182       ior:
183
184       ·   check if a character can be represented as a  single  byte  in  the
185           current locale before attempting call waddch, and
186
187       ·   call wadd_wch for characters which cannot be handled by waddch.
188
189   TABSIZE
190       The  TABSIZE variable is implemented in some versions of curses, but is
191       not part of X/Open curses.
192
193       If ch is a carriage return, the cursor is moved to the beginning of the
194       current  row of the window.  This is true of other implementations, but
195       is not documented.
196

SEE ALSO

198       curses(3X),  curs_attr(3X),  curs_clear(3X),  curs_inch(3X),  curs_out‐
199       opts(3X), curs_refresh(3X), curs_variables(3X), putc(3).
200
201       Comparable  functions  in  the  wide-character  (ncursesw)  library are
202       described in curs_add_wch(3X).
203
204
205
206                                                                curs_addch(3X)
Impressum