]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/curs_addch.3x.html
ncurses 6.4 - patch 20230311
[ncurses.git] / doc / html / man / curs_addch.3x.html
1 <!--
2   * t
3   ****************************************************************************
4   * Copyright 2018-2022,2023 Thomas E. Dickey                                *
5   * Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
6   *                                                                          *
7   * Permission is hereby granted, free of charge, to any person obtaining a  *
8   * copy of this software and associated documentation files (the            *
9   * "Software"), to deal in the Software without restriction, including      *
10   * without limitation the rights to use, copy, modify, merge, publish,      *
11   * distribute, distribute with modifications, sublicense, and/or sell       *
12   * copies of the Software, and to permit persons to whom the Software is    *
13   * furnished to do so, subject to the following conditions:                 *
14   *                                                                          *
15   * The above copyright notice and this permission notice shall be included  *
16   * in all copies or substantial portions of the Software.                   *
17   *                                                                          *
18   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
19   * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
20   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
21   * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
22   * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
23   * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
24   * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
25   *                                                                          *
26   * Except as contained in this notice, the name(s) of the above copyright   *
27   * holders shall not be used in advertising or otherwise to promote the     *
28   * sale, use or other dealings in this Software without prior written       *
29   * authorization.                                                           *
30   ****************************************************************************
31   * @Id: curs_addch.3x,v 1.60 2023/03/11 20:39:26 tom Exp @
32 -->
33 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
34 <HTML>
35 <HEAD>
36 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
37 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
38 <TITLE>curs_addch 3x</TITLE>
39 <link rel="author" href="mailto:bug-ncurses@gnu.org">
40
41 </HEAD>
42 <BODY>
43 <H1 class="no-header">curs_addch 3x</H1>
44 <PRE>
45 <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>                                                  <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>
46
47
48
49
50 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
51        <STRONG>addch</STRONG>, <STRONG>waddch</STRONG>, <STRONG>mvaddch</STRONG>, <STRONG>mvwaddch</STRONG>, <STRONG>echochar</STRONG>, <STRONG>wechochar</STRONG> - add a character
52        (with attributes) to a <STRONG>curses</STRONG> window, then advance the cursor
53
54
55 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
56        <STRONG>#include</STRONG> <STRONG>&lt;curses.h&gt;</STRONG>
57
58        <STRONG>int</STRONG> <STRONG>addch(const</STRONG> <STRONG>chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG>
59        <STRONG>int</STRONG> <STRONG>waddch(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG>
60        <STRONG>int</STRONG> <STRONG>mvaddch(int</STRONG> <EM>y</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>x</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG>
61        <STRONG>int</STRONG> <STRONG>mvwaddch(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>y</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>x</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG>
62
63        <STRONG>int</STRONG> <STRONG>echochar(const</STRONG> <STRONG>chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG>
64        <STRONG>int</STRONG> <STRONG>wechochar(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG>
65
66
67 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
68
69 </PRE><H3><a name="h3-Adding-characters">Adding characters</a></H3><PRE>
70        The <STRONG>addch</STRONG>, <STRONG>waddch</STRONG>, <STRONG>mvaddch</STRONG> and <STRONG>mvwaddch</STRONG> routines put the  character  <EM>ch</EM>
71        into  the  given  window  at its current window position, which is then
72        advanced.  They are  analogous  to  <STRONG>putchar(3)</STRONG>  in  <STRONG>stdio(3)</STRONG>.   If  the
73        advance is at the right margin:
74
75        <STRONG>o</STRONG>   The cursor automatically wraps to the beginning of the next line.
76
77        <STRONG>o</STRONG>   At  the bottom of the current scrolling region, and if <STRONG><A HREF="scrollok.3x.html">scrollok(3x)</A></STRONG>
78            is enabled, the scrolling region is scrolled up one line.
79
80        <STRONG>o</STRONG>   If <STRONG><A HREF="scrollok.3x.html">scrollok(3x)</A></STRONG> is not enabled, writing a character  at  the  lower
81            right margin succeeds.  However, an error is returned because it is
82            not possible to wrap to a new line
83
84        If <EM>ch</EM> is a tab, newline, carriage return or backspace,  the  cursor  is
85        moved appropriately within the window:
86
87        <STRONG>o</STRONG>   Backspace  moves the cursor one character left; at the left edge of
88            a window it does nothing.
89
90        <STRONG>o</STRONG>   Carriage return moves the cursor to the window left margin  on  the
91            current line.
92
93        <STRONG>o</STRONG>   Newline  does  a <STRONG>clrtoeol</STRONG>, then moves the cursor to the window left
94            margin on the next line, scrolling the window if on the last line.
95
96        <STRONG>o</STRONG>   Tabs are considered to be at every eighth column.  The tab interval
97            may be altered by setting the <STRONG>TABSIZE</STRONG> variable.
98
99        If  <EM>ch</EM>  is  any  other nonprintable character, it is drawn in printable
100        form, using the same convention as <STRONG><A HREF="unctrl.3x.html">unctrl(3x)</A></STRONG>:
101
102        <STRONG>o</STRONG>   Control characters are displayed in the <STRONG>^</STRONG><EM>X</EM> notation.
103
104        <STRONG>o</STRONG>   Values above 128 are either meta characters (if the screen has  not
105            been  initialized,  or  if  <STRONG><A HREF="curs_inopts.3x.html">meta(3x)</A></STRONG>  has been called with a <STRONG>TRUE</STRONG> E
106            parameter),  shown  in  the  <STRONG>M-</STRONG><EM>X</EM>  notation,  or  are  displayed  as
107            themselves.   In  the latter case, the values may not be printable;
108            this follows the X/Open specification.
109
110        Calling <STRONG>winch</STRONG> after adding a nonprintable character does not return the
111        character  itself,  but instead returns the printable representation of
112        the character.
113
114        Video attributes can be combined with a character  argument  passed  to
115        <STRONG>addch</STRONG>  or  related  functions by logical-ORing them into the character.
116        (Thus, text, including attributes, can be  copied  from  one  place  to
117        another  using  <STRONG><A HREF="curs_inch.3x.html">inch(3x)</A></STRONG>  and  <STRONG>addch</STRONG>.)   See the <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG> page for
118        values of predefined video attribute constants  that  can  be  usefully
119        OR'ed into characters.
120
121
122 </PRE><H3><a name="h3-Echoing-characters">Echoing characters</a></H3><PRE>
123        The  <STRONG>echochar</STRONG>  and <STRONG>wechochar</STRONG> routines are equivalent to a call to <STRONG>addch</STRONG>
124        followed by a call to <STRONG><A HREF="curs_refresh.3x.html">refresh(3x)</A></STRONG>, or a call to <STRONG>waddch</STRONG>  followed  by  a
125        call  to <STRONG>wrefresh</STRONG>.  The knowledge that only a single character is being
126        output  is  used  and,  for  non-control  characters,  a   considerable
127        performance  gain  may be seen by using these routines instead of their
128        equivalents.
129
130
131 </PRE><H3><a name="h3-Line-Graphics">Line Graphics</a></H3><PRE>
132        The following variables may be used to add line drawing  characters  to
133        the  screen  with  routines of the <STRONG>addch</STRONG> family.  The default character
134        listed below is used if the <STRONG>acsc</STRONG> capability does not define a terminal-
135        specific   replacement   for   it,   or  if  the  terminal  and  locale
136        configuration requires  Unicode  but  the  library  is  unable  to  use
137        Unicode.
138
139        The names are taken from VT100 nomenclature.
140
141        <STRONG>ACS</STRONG>            <STRONG>ACS</STRONG>       <STRONG>acsc</STRONG>   <STRONG>Glyph</STRONG>
142        <STRONG>Name</STRONG>           <STRONG>Default</STRONG>   <STRONG>char</STRONG>   <STRONG>Name</STRONG>
143        ---------------------------------------------------------
144        ACS_BLOCK      #         0      solid square block
145        ACS_BOARD      #         h      board of squares
146        ACS_BTEE       +         v      bottom tee
147        ACS_BULLET     o         ~      bullet
148        ACS_CKBOARD    :         a      checker board (stipple)
149        ACS_DARROW     v         .      arrow pointing down
150        ACS_DEGREE     '         f      degree symbol
151        ACS_DIAMOND    +         `      diamond
152        ACS_GEQUAL     &gt;         &gt;      greater-than-or-equal-to
153        ACS_HLINE      -         q      horizontal line
154        ACS_LANTERN    #         i      lantern symbol
155        ACS_LARROW     &lt;         ,      arrow pointing left
156        ACS_LEQUAL     &lt;         y      less-than-or-equal-to
157        ACS_LLCORNER   +         m      lower left-hand corner
158        ACS_LRCORNER   +         j      lower right-hand corner
159        ACS_LTEE       +         t      left tee
160        ACS_NEQUAL     !         |      not-equal
161        ACS_PI         *         {      greek pi
162        ACS_PLMINUS    #         g      plus/minus
163        ACS_PLUS       +         n      plus
164        ACS_RARROW     &gt;         +      arrow pointing right
165        ACS_RTEE       +         u      right tee
166        ACS_S1         -         o      scan line 1
167        ACS_S3         -         p      scan line 3
168        ACS_S7         -         r      scan line 7
169        ACS_S9         _         s      scan line 9
170        ACS_STERLING   f         }      pound-sterling symbol
171        ACS_TTEE       +         w      top tee
172        ACS_UARROW     ^         -      arrow pointing up
173        ACS_ULCORNER   +         l      upper left-hand corner
174        ACS_URCORNER   +         k      upper right-hand corner
175        ACS_VLINE      |         x      vertical line
176
177
178 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
179        All routines return the integer <STRONG>ERR</STRONG> upon failure and <STRONG>OK</STRONG> on success (the
180        SVr4 manuals specify only "an  integer  value  other  than  <STRONG>ERR</STRONG>")  upon
181        successful  completion, unless otherwise noted in the preceding routine
182        descriptions.
183
184        Functions with a "mv" prefix first  perform  a  cursor  movement  using
185        <STRONG>wmove</STRONG>, and return an error if the position is outside the window, or if
186        the window pointer is null.
187
188        If it is not  possible  to  add  a  complete  character,  an  error  is
189        returned:
190
191        <STRONG>o</STRONG>   If  <STRONG><A HREF="scrollok.3x.html">scrollok(3x)</A></STRONG>  is  not enabled, writing a character at the lower
192            right margin succeeds.  However, an error is returned because it is
193            not possible to wrap to a new line
194
195        <STRONG>o</STRONG>   If  an error is detected when converting a multibyte character to a
196            sequence of bytes, or if it is not  possible  to  add  all  of  the
197            resulting bytes in the window, an error is returned.
198
199
200 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
201        Note that <STRONG>addch</STRONG>, <STRONG>mvaddch</STRONG>, <STRONG>mvwaddch</STRONG>, and <STRONG>echochar</STRONG> may be macros.
202
203
204 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
205        All  these functions are described in the XSI Curses standard, Issue 4.
206        The defaults specified for forms-drawing characters apply in the  POSIX
207        locale.
208
209
210 </PRE><H3><a name="h3-ACS-Symbols">ACS Symbols</a></H3><PRE>
211        X/Open Curses states that the <STRONG>ACS_</STRONG> definitions are <STRONG>char</STRONG> constants.  For
212        the  wide-character  implementation  (see  <STRONG>curs_add_wch</STRONG>),   there   are
213        analogous   <STRONG>WACS_</STRONG>   definitions  which  are  <STRONG>cchar_t</STRONG>  constants.   Some
214        implementations are problematic:
215
216        <STRONG>o</STRONG>   Some implementations define the ACS symbols to a constant (such  as
217            Solaris), while others define those to entries in an array.
218
219            This  implementation uses an array <STRONG>acs_map</STRONG>, as done in SVr4 curses.
220            NetBSD also uses an array, actually named <STRONG>_acs_char</STRONG>, with a <STRONG>#define</STRONG>
221            for compatibility.
222
223        <STRONG>o</STRONG>   HPUX curses equates some of the <STRONG>ACS_</STRONG> symbols to the analogous <STRONG>WACS_</STRONG>
224            symbols  as  if  the  <STRONG>ACS_</STRONG>  symbols  were  wide  characters.    The
225            misdefined  symbols  are the arrows and other symbols which are not
226            used for line-drawing.
227
228        <STRONG>o</STRONG>   X/Open Curses (issues 2 through 7) has a  typographical  error  for
229            the  ACS_LANTERN  symbol,  equating  its  "VT100+  Character"  to <STRONG>I</STRONG>
230            (capital I), while the header files for SVr4 curses and the various
231            implementations use <STRONG>i</STRONG> (lowercase).
232
233            None  of the terminal descriptions on Unix platforms use uppercase-
234            I,  except  for  Solaris  (i.e.,  <STRONG>screen</STRONG>'s  terminal   description,
235            apparently  based on the X/Open documentation around 1995).  On the
236            other hand, the terminal description <EM>gs6300</EM> (AT&amp;T PC6300 with EMOTS
237            Terminal Emulator) uses lowercase-i.
238
239        Some  ACS  symbols  (ACS_S3,  ACS_S7,  ACS_LEQUAL,  ACS_GEQUAL, ACS_PI,
240        ACS_NEQUAL, ACS_STERLING) were not documented in any publicly  released
241        System  V.   However,  many  publicly  available terminfos include <STRONG>acsc</STRONG>
242        strings in which their key characters (pryz{|})  are  embedded,  and  a
243        second-hand  list  of  their  character descriptions has come to light.
244        The ACS-prefixed names for them were invented for <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>.
245
246        The <EM>displayed</EM> values for the <STRONG>ACS_</STRONG> and <STRONG>WACS_</STRONG> constants depend on
247
248        <STRONG>o</STRONG>   the library configuration, i.e., <STRONG>ncurses</STRONG> versus <STRONG>ncursesw</STRONG>, where the
249            latter  is  capable  of displaying Unicode while the former is not,
250            and
251
252        <STRONG>o</STRONG>   whether the <EM>locale</EM> uses UTF-8 encoding.
253
254        In certain cases,  the  terminal  is  unable  to  display  line-drawing
255        characters   except   by   using   UTF-8   (see   the   discussion   of
256        <STRONG>NCURSES_NO_UTF8_ACS</STRONG> in <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>).
257
258
259 </PRE><H3><a name="h3-Character-Set">Character Set</a></H3><PRE>
260        X/Open Curses assumes that the parameter passed to  <STRONG>waddch</STRONG>  contains  a
261        single  character.   As  discussed in <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>, that character may
262        have been more than eight bits in an SVr3 or SVr4  implementation,  but
263        in  the  X/Open Curses model, the details are not given.  The important
264        distinction between SVr4 curses and X/Open  Curses  is  that  the  non-
265        character  information  (attributes  and  color) was separated from the
266        character information which is packed in a <STRONG>chtype</STRONG> to pass to <STRONG>waddch</STRONG>.
267
268        In this implementation,  <STRONG>chtype</STRONG>  holds  an  eight-bit  character.   But
269        ncurses  allows  multibyte  characters  to be passed in a succession of
270        calls to <STRONG>waddch</STRONG>.  The other implementations do not do this; a  call  to
271        <STRONG>waddch</STRONG>  passes  exactly  one  character which may be rendered as one or
272        more cells on the screen depending on whether it is printable.
273
274        Depending on the locale settings, ncurses will inspect the byte  passed
275        in  each  call  to <STRONG>waddch</STRONG>, and check if the latest call will continue a
276        multibyte sequence.  When a character is <EM>complete</EM>, ncurses displays the
277        character and moves to the next position in the screen.
278
279        If  the  calling  application  interrupts  the succession of bytes in a
280        multibyte character by moving the current location (e.g., using <STRONG>wmove</STRONG>),
281        ncurses discards the partially built character, starting over again.
282
283        For  portability  to  other  implementations,  do  not  rely  upon this
284        behavior:
285
286        <STRONG>o</STRONG>   check if a character can be represented as a  single  byte  in  the
287            current locale before attempting call <STRONG>waddch</STRONG>, and
288
289        <STRONG>o</STRONG>   call <STRONG>wadd_wch</STRONG> for characters which cannot be handled by <STRONG>waddch</STRONG>.
290
291
292 </PRE><H3><a name="h3-TABSIZE">TABSIZE</a></H3><PRE>
293        The  <STRONG>TABSIZE</STRONG>  variable  is  implemented  in  SVr4 and other versions of
294        curses, but is not part of X/Open curses  (see  <STRONG><A HREF="curs_variables.3x.html">curs_variables(3x)</A></STRONG>  for
295        more details).
296
297        If <EM>ch</EM> is a carriage return, the cursor is moved to the beginning of the
298        current row of the window.  This is true of other implementations,  but
299        is not documented.
300
301
302 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
303        <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>,      <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>,      <STRONG><A HREF="curs_clear.3x.html">curs_clear(3x)</A></STRONG>,     <STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>,
304        <STRONG><A HREF="curs_outopts.3x.html">curs_outopts(3x)</A></STRONG>, <STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>, <STRONG><A HREF="curs_variables.3x.html">curs_variables(3x)</A></STRONG>, <STRONG>putc(3)</STRONG>.
305
306        Comparable functions  in  the  wide-character  (ncursesw)  library  are
307        described in <STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG>.
308
309
310
311                                                                 <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>
312 </PRE>
313 <div class="nav">
314 <ul>
315 <li><a href="#h2-NAME">NAME</a></li>
316 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
317 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
318 <ul>
319 <li><a href="#h3-Adding-characters">Adding characters</a></li>
320 <li><a href="#h3-Echoing-characters">Echoing characters</a></li>
321 <li><a href="#h3-Line-Graphics">Line Graphics</a></li>
322 </ul>
323 </li>
324 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
325 <li><a href="#h2-NOTES">NOTES</a></li>
326 <li><a href="#h2-PORTABILITY">PORTABILITY</a>
327 <ul>
328 <li><a href="#h3-ACS-Symbols">ACS Symbols</a></li>
329 <li><a href="#h3-Character-Set">Character Set</a></li>
330 <li><a href="#h3-TABSIZE">TABSIZE</a></li>
331 </ul>
332 </li>
333 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
334 </ul>
335 </div>
336 </BODY>
337 </HTML>