]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/curs_addch.3x.html
2e8bbe8363869f0a6c73b75ff2b1e7057d6c03ea
[ncurses.git] / doc / html / man / curs_addch.3x.html
1 <!--
2   * t
3   ****************************************************************************
4   * Copyright 2018-2023,2024 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.86 2024/05/11 20:39:53 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 2024-05-11 ncurses 6.5 Library calls</TITLE>
39 <link rel="author" href="mailto:bug-ncurses@gnu.org">
40
41 </HEAD>
42 <BODY>
43 <H1 class="no-header">curs_addch 3x 2024-05-11 ncurses 6.5 Library calls</H1>
44 <PRE>
45 <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>                   Library calls                  <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 <EM>curses</EM>
52        character to a window and 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-waddch">waddch</a></H3><PRE>
70        <STRONG>waddch</STRONG> writes the <EM>curses</EM> character <EM>ch</EM> to the window <EM>win</EM>, then  advances
71        the   cursor   position,   analogously  to  the  standard  C  library's
72        <STRONG>putchar(3)</STRONG>.  <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG> describes the variants of this function.
73
74        If advancement occurs at the right margin,
75
76        <STRONG>o</STRONG>   the cursor automatically wraps to the beginning of the  next  line,
77            then,
78
79        <STRONG>o</STRONG>   if   it  was  at  the  bottom  of  the  scrolling  region,  and  if
80            <STRONG><A HREF="scrollok.3x.html">scrollok(3x)</A></STRONG> is enabled for <EM>win</EM>, the scrolling  region  scrolls  up
81            one line.
82
83        If  <EM>ch</EM>  is  a backspace, carriage return, line feed, or tab, the cursor
84        moves appropriately within the window.
85
86        <STRONG>o</STRONG>   Backspace moves the cursor one character left; at the  left  margin
87            of a window, it does nothing.
88
89        <STRONG>o</STRONG>   Carriage  return moves the cursor to the left margin on the current
90            line of the window.
91
92        <STRONG>o</STRONG>   Line feed does a <STRONG><A HREF="curs_clear.3x.html">clrtoeol(3x)</A></STRONG>, then advances as if from  the  right
93            margin.
94
95        <STRONG>o</STRONG>   Tab  advances the cursor to the next tab stop (possibly on the next
96            line); these are placed at every eighth column by  default.   Alter
97            the    tab    interval    with    the    <STRONG>TABSIZE</STRONG>   extension;   see
98            <STRONG><A HREF="curs_variables.3x.html">curs_variables(3x)</A></STRONG>.
99
100        If <EM>ch</EM> is any other nonprintable character, it  is  drawn  in  printable
101        form using the same convention as <STRONG><A HREF="unctrl.3x.html">unctrl(3x)</A></STRONG>.
102
103        Calling  <STRONG><A HREF="curs_inch.3x.html">winch(3x)</A></STRONG> on the location of a nonprintable character does not
104        return the character itself, but its <STRONG><A HREF="unctrl.3x.html">unctrl(3x)</A></STRONG> representation.
105
106        The object or expression <EM>ch</EM> may contain attributes and/or a color  pair
107        identifier.   (A character with its attributes can be copied from place
108        to place using <STRONG><A HREF="curs_inch.3x.html">winch(3x)</A></STRONG> and <STRONG>waddch</STRONG>.)  See <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG> for values  of
109        predefined  video  attribute constants that can be usefully "or"ed with
110        characters.
111
112
113 </PRE><H3><a name="h3-wechochar">wechochar</a></H3><PRE>
114        <STRONG>echochar</STRONG> and <STRONG>wechochar</STRONG> are equivalent to calling (<STRONG>w</STRONG>)<STRONG>addch</STRONG>  followed  by
115        (<STRONG>w</STRONG>)<STRONG>refresh</STRONG>.   <EM>curses</EM>  interprets  these functions as a hint that only a
116        single  character  is  being  output;  for  non-control  characters,  a
117        considerable performance gain may be enjoyed by employing them.
118
119
120 </PRE><H3><a name="h3-Forms-Drawing-Characters">Forms-Drawing Characters</a></H3><PRE>
121        <EM>curses</EM>  defines  macros starting with <STRONG>ACS_</STRONG> that can be used with <STRONG>waddch</STRONG>
122        to write line-drawing and  other  special  characters  to  the  screen.
123        <EM>ncurses</EM>  terms  these <EM>forms-drawing</EM> <EM>characters.</EM>  The ACS default listed
124        below is used if the <STRONG>acs_chars</STRONG>  (<STRONG>acsc</STRONG>)  <EM>terminfo</EM>  capability  does  not
125        define  a  terminal-specific replacement for it, or if the terminal and
126        locale configuration requires Unicode to access  these  characters  but
127        the  library  is  unable  to  use  Unicode.   The  "acsc  char"  column
128        corresponds to how the characters are specified in the <STRONG>acs_chars</STRONG> (<STRONG>acsc</STRONG>)
129        string capability, and the characters in it may appear on the screen if
130        the terminal type's database entry incorrectly advertises ACS  support.
131        The name "ACS" originates in the Alternate Character Set feature of the
132        DEC VT100 terminal.
133
134                       <STRONG>ACS</STRONG>       <STRONG>acsc</STRONG>
135        <STRONG>Symbol</STRONG>         <STRONG>Default</STRONG>   <STRONG>char</STRONG>   <STRONG>Glyph</STRONG> <STRONG>Name</STRONG>
136        ------------------------------------------------------------------------
137        <STRONG>ACS_BLOCK</STRONG>      #         0      solid square block
138        <STRONG>ACS_BOARD</STRONG>      #         h      board of squares
139        <STRONG>ACS_BTEE</STRONG>       +         v      bottom tee
140        <STRONG>ACS_BULLET</STRONG>     o         ~      bullet
141        <STRONG>ACS_CKBOARD</STRONG>    :         a      checker board (stipple)
142        <STRONG>ACS_DARROW</STRONG>     v         .      arrow pointing down
143        <STRONG>ACS_DEGREE</STRONG>     '         f      degree symbol
144        <STRONG>ACS_DIAMOND</STRONG>    +         `      diamond
145        <STRONG>ACS_GEQUAL</STRONG>     &gt;         &gt;      greater-than-or-equal-to
146        <STRONG>ACS_HLINE</STRONG>      -         q      horizontal line
147        <STRONG>ACS_LANTERN</STRONG>    #         i      lantern symbol
148        <STRONG>ACS_LARROW</STRONG>     &lt;         ,      arrow pointing left
149        <STRONG>ACS_LEQUAL</STRONG>     &lt;         y      less-than-or-equal-to
150        <STRONG>ACS_LLCORNER</STRONG>   +         m      lower left-hand corner
151        <STRONG>ACS_LRCORNER</STRONG>   +         j      lower right-hand corner
152        <STRONG>ACS_LTEE</STRONG>       +         t      left tee
153        <STRONG>ACS_NEQUAL</STRONG>     !         |      not-equal
154        <STRONG>ACS_PI</STRONG>         *         {      greek pi
155        <STRONG>ACS_PLMINUS</STRONG>    #         g      plus/minus
156        <STRONG>ACS_PLUS</STRONG>       +         n      plus
157        <STRONG>ACS_RARROW</STRONG>     &gt;         +      arrow pointing right
158        <STRONG>ACS_RTEE</STRONG>       +         u      right tee
159        <STRONG>ACS_S1</STRONG>         -         o      scan line 1
160        <STRONG>ACS_S3</STRONG>         -         p      scan line 3
161        <STRONG>ACS_S7</STRONG>         -         r      scan line 7
162        <STRONG>ACS_S9</STRONG>         _         s      scan line 9
163        <STRONG>ACS_STERLING</STRONG>   f         }      pound-sterling symbol
164        <STRONG>ACS_TTEE</STRONG>       +         w      top tee
165        <STRONG>ACS_UARROW</STRONG>     ^         -      arrow pointing up
166        <STRONG>ACS_ULCORNER</STRONG>   +         l      upper left-hand corner
167        <STRONG>ACS_URCORNER</STRONG>   +         k      upper right-hand corner
168        <STRONG>ACS_VLINE</STRONG>      |         x      vertical line
169
170
171 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
172        These functions return <STRONG>OK</STRONG> on success and <STRONG>ERR</STRONG> on failure.
173
174        In <EM>ncurses</EM>, <STRONG>waddch</STRONG> returns <STRONG>ERR</STRONG> if
175
176        <STRONG>o</STRONG>   <EM>win</EM> is <STRONG>NULL</STRONG>,
177
178        <STRONG>o</STRONG>   wrapping to a new line is impossible because <STRONG><A HREF="scrollok.3x.html">scrollok(3x)</A></STRONG>  has  not
179            been  called  on  <EM>win</EM>  when a write to its bottom right location is
180            attempted, or
181
182        <STRONG>o</STRONG>   it is not possible to  add  a  complete  character  at  the  cursor
183            position.
184
185        The last may be due to different causes:
186
187        <STRONG>o</STRONG>   conversion of a multibyte character to a byte sequence can fail, or
188
189        <STRONG>o</STRONG>   at  least  one  of  the  bytes  resulting  from  conversion  from a
190            multibyte sequence cannot be added  to  the  window.   See  section
191            "PORTABILITY"  below  regarding  the  use  of <STRONG>waddch</STRONG> with multibyte
192            characters.
193
194        Functions prefixed with "mv" first perform cursor movement and fail  if
195        the position (<EM>y</EM>, <EM>x</EM>) is outside the window boundaries.
196
197
198 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
199        <STRONG>addch</STRONG>, <STRONG>mvaddch</STRONG>, <STRONG>mvwaddch</STRONG>, and <STRONG>echochar</STRONG> may be implemented as macros.
200
201
202 </PRE><H2><a name="h2-EXTENSIONS">EXTENSIONS</a></H2><PRE>
203
204 </PRE><H3><a name="h3-TABSIZE">TABSIZE</a></H3><PRE>
205        SVr4  and  other versions of <EM>curses</EM> implement the <STRONG>TABSIZE</STRONG> variable, but
206        X/Open Curses does not specify it; see <STRONG><A HREF="curs_variables.3x.html">curs_variables(3x)</A></STRONG>.
207
208
209 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
210        X/Open Curses, Issue 4 describes  these  functions.   It  specifies  no
211        error conditions for them.
212
213        SVr4  <EM>curses</EM>  describes  a  successful return value only as "an integer
214        value other than <STRONG>ERR</STRONG>".
215
216        The defaults specified for forms-drawing characters apply in the  POSIX
217        locale.
218
219
220 </PRE><H3><a name="h3-ACS-Symbols">ACS Symbols</a></H3><PRE>
221        X/Open Curses states that the <STRONG>ACS_</STRONG> definitions are <EM>char</EM> constants.
222
223        Some implementations are problematic.
224
225        <STRONG>o</STRONG>   Solaris  <EM>curses</EM>, for example, defines the ACS symbols as constants;
226            others define them as elements of an array.
227
228            This implementation uses an array, <STRONG>acs_map</STRONG>,  as  did  SVr4  <EM>curses</EM>.
229            NetBSD also uses an array, actually named <STRONG>_acs_char</STRONG>, with a <STRONG>#define</STRONG>
230            for compatibility.
231
232        <STRONG>o</STRONG>   HP-UX <EM>curses</EM> equates some of the  <STRONG>ACS_</STRONG>  symbols  to  the  analogous
233            <STRONG>WACS_</STRONG>  symbols  as  if  the  <STRONG>ACS_</STRONG> symbols were wide characters (see
234            <STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG>).  The  misdefined  symbols  are  the  arrows  and
235            others that are not used for line drawing.
236
237        <STRONG>o</STRONG>   X/Open  Curses  (Issues  2 through 7) has a typographical error for
238            the <STRONG>ACS_LANTERN</STRONG> symbol, equating  its  "VT100+  Character"  to  "I"
239            (capital  I),  while  the  header  files  for SVr4 <EM>curses</EM> and other
240            implementations use "i" (small i).
241
242            None of the terminal descriptions on Unix platforms  use  uppercase
243            I,  except  for  Solaris  (in  its  <EM>terminfo</EM>  entry  for <STRONG>screen(1)</STRONG>,
244            apparently based on the X/Open documentation around 1995).  On  the
245            other  hand,  its <STRONG>gs6300</STRONG> (AT&amp;T PC6300 with EMOTS Terminal Emulator)
246            description uses lowercase i.
247
248        Some ACS  symbols  (<STRONG>ACS_S3</STRONG>,  <STRONG>ACS_S7</STRONG>,  <STRONG>ACS_LEQUAL</STRONG>,  <STRONG>ACS_GEQUAL</STRONG>,  <STRONG>ACS_PI</STRONG>,
249        <STRONG>ACS_NEQUAL</STRONG>,  and  <STRONG>ACS_STERLING</STRONG>)  were  not  documented  in any publicly
250        released System V.  However, many publicly available  <EM>terminfo</EM>  entries
251        include  <STRONG>acsc</STRONG>  capabilities in which their key characters (<STRONG>pryz{|}</STRONG>) are
252        embedded, and a second-hand list of their  character  descriptions  has
253        come  to light.  The <EM>ncurses</EM> developers invented ACS-prefixed names for
254        them.
255
256        The <EM>displayed</EM> values of <STRONG>ACS_</STRONG> constants depend on
257
258        <STRONG>o</STRONG>   the  <EM>ncurses</EM>  ABI--for  example,  wide-character  versus  non-wide-
259            character  configurations  (the  former  is  capable  of displaying
260            Unicode while the latter is not), and
261
262        <STRONG>o</STRONG>   whether the locale uses UTF-8 encoding.
263
264        In certain cases, the  terminal  is  unable  to  display  forms-drawing
265        characters   <EM>except</EM>   by   using  UTF-8;  see  the  discussion  of  the
266        <EM>NCURSES</EM><STRONG>_</STRONG><EM>NO</EM><STRONG>_</STRONG><EM>UTF8</EM><STRONG>_</STRONG><EM>ACS</EM> environment variable in <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>.
267
268
269 </PRE><H3><a name="h3-Character-Set">Character Set</a></H3><PRE>
270        X/Open Curses assumes that the parameter passed to  <STRONG>waddch</STRONG>  contains  a
271        single  character.   That  character may have been more than eight bits
272        wide in an SVr3 or SVr4 implementation, but X/Open  Curses  leaves  the
273        width  of  a non-wide character code unspecified.  The standard further
274        does not specify the internal structure of a <EM>chtype</EM>, though the use  of
275        bit  operations  to  combine  the  character code with attributes and a
276        color pair identifier into a <EM>chtype</EM> for passage to <STRONG>waddch</STRONG> is common.  A
277        portable application uses only the macros discussed in <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG> to
278        manipulate a <EM>chtype</EM>.
279
280        In <EM>ncurses</EM>, <EM>chtype</EM> holds an eight-bit character, but the library allows
281        a  multibyte character to be passed in a succession of calls to <STRONG>waddch</STRONG>.
282        Other implementations do not;  a  <STRONG>waddch</STRONG>  call  transmits  exactly  one
283        character,  which  may  be  rendered  in  one  or more screen locations
284        depending on whether it is printable (see  <STRONG><A HREF="unctrl.3x.html">unctrl(3x)</A></STRONG>).   Depending  on
285        the  locale,  <EM>ncurses</EM>  inspects the byte passed in each <STRONG>waddch</STRONG> call and
286        checks whether the latest call continues a multibyte sequence.  When  a
287        character  is <EM>complete</EM>, <EM>ncurses</EM> displays the character and advances the
288        cursor.  If the calling application interrupts the succession of  bytes
289        in a multibyte character sequence by changing the current location--for
290        example, with <STRONG><A HREF="curs_move.3x.html">wmove(3x)</A></STRONG>--<EM>ncurses</EM> discards the incomplete character.
291
292        For  portability  to  other  implementations,  do  not  rely  upon  the
293        foregoing  behavior.  Check whether a character can be represented as a
294        single byte in the current locale.
295
296        <STRONG>o</STRONG>   If it can, call either <STRONG>waddch</STRONG> or <STRONG><A HREF="curs_add_wch.3x.html">wadd_wch(3x)</A></STRONG>.
297
298        <STRONG>o</STRONG>   If it cannot, use only <STRONG><A HREF="curs_add_wch.3x.html">wadd_wch(3x)</A></STRONG>.
299
300
301 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
302        <STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG> describes comparable functions of the <EM>ncurses</EM>  library
303        in its wide-character configuration (<EM>ncursesw</EM>).
304
305        <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>,    <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>,    <STRONG><A HREF="curs_addstr.3x.html">curs_addstr(3x)</A></STRONG>,    <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>,
306        <STRONG><A HREF="curs_clear.3x.html">curs_clear(3x)</A></STRONG>,  <STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>,   <STRONG><A HREF="curs_outopts.3x.html">curs_outopts(3x)</A></STRONG>,   <STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>,
307        <STRONG><A HREF="curs_variables.3x.html">curs_variables(3x)</A></STRONG>, <STRONG>putchar(3)</STRONG>
308
309
310
311 ncurses 6.5                       2024-05-11                    <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-waddch">waddch</a></li>
320 <li><a href="#h3-wechochar">wechochar</a></li>
321 <li><a href="#h3-Forms-Drawing-Characters">Forms-Drawing Characters</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-EXTENSIONS">EXTENSIONS</a>
327 <ul>
328 <li><a href="#h3-TABSIZE">TABSIZE</a></li>
329 </ul>
330 </li>
331 <li><a href="#h2-PORTABILITY">PORTABILITY</a>
332 <ul>
333 <li><a href="#h3-ACS-Symbols">ACS Symbols</a></li>
334 <li><a href="#h3-Character-Set">Character Set</a></li>
335 </ul>
336 </li>
337 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
338 </ul>
339 </div>
340 </BODY>
341 </HTML>