2 .\"***************************************************************************
3 .\" Copyright 2018-2023,2024 Thomas E. Dickey *
4 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc. *
6 .\" Permission is hereby granted, free of charge, to any person obtaining a *
7 .\" copy of this software and associated documentation files (the *
8 .\" "Software"), to deal in the Software without restriction, including *
9 .\" without limitation the rights to use, copy, modify, merge, publish, *
10 .\" distribute, distribute with modifications, sublicense, and/or sell *
11 .\" copies of the Software, and to permit persons to whom the Software is *
12 .\" furnished to do so, subject to the following conditions: *
14 .\" The above copyright notice and this permission notice shall be included *
15 .\" in all copies or substantial portions of the Software. *
17 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 .\" Except as contained in this notice, the name(s) of the above copyright *
26 .\" holders shall not be used in advertising or otherwise to promote the *
27 .\" sale, use or other dealings in this Software without prior written *
29 .\"***************************************************************************
31 .\" $Id: curs_addch.3x,v 1.85 2024/04/20 19:03:47 tom Exp $
32 .TH curs_addch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
61 add a \fIcurses\fP character to a window and advance the cursor
64 \fB#include <curses.h>
66 \fBint addch(const chtype \fIch\fP);
67 \fBint waddch(WINDOW *\fIwin\fP, const chtype \fIch\fP);
68 \fBint mvaddch(int \fIy\fP, int \fIx\fP, const chtype \fIch\fP);
69 \fBint mvwaddch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const chtype \fIch\fP);
71 \fBint echochar(const chtype \fIch\fP);
72 \fBint wechochar(WINDOW *\fIwin\fP, const chtype \fIch\fP);
75 .SS "Adding Characters"
79 at the cursor position of window
81 then advances the cursor position,
82 analogously to the standard C library's \fI\%putchar\fP(3).
83 \fB\%ncurses\fP(3X) describes the variants of this function.
85 If advancement occurs at the right margin,
87 the cursor automatically wraps to the beginning of the next line;
90 at the bottom of the current scrolling region,
91 and if \fB\%scrollok\fP(3X) is enabled for
93 the scrolling region scrolls up one line.
103 the cursor moves appropriately within the window.
105 Backspace moves the cursor one character left;
106 at the left margin of a window,
109 Carriage return moves the cursor to the left margin on the current line
112 Line feed does a \fB\%clrtoeol\fP(3X),
113 then moves the cursor to the left margin on the next line of the window,
114 and if \fB\%scrollok\fP(3X) is enabled for
116 scrolls the window if the cursor was already on the last line.
118 Tab advances the cursor to the next tab stop
119 (possibly on the next line);
120 these are placed at every eighth column by default.
121 Alter the tab interval with the
124 see \fB\%curs_variables\fP(3X).
128 is any other nonprintable character,
129 it is drawn in printable form,
130 using the same convention as \fB\%unctrl\fP(3X).
132 Calling \fB\%winch\fP(3X) on the location of a nonprintable character
133 does not return the character itself,
134 but its \fB\%unctrl\fP(3X) representation.
137 may contain rendering and/or color attributes,
138 and others can be combined with the parameter
139 by logically \*(``or\*(''ing with it.
140 (A character with its attributes can be copied from place to place
141 using \fB\%winch\fP(3X) and
143 See \fB\%curs_attr\fP(3X) for values of predefined video attribute
144 constants that can be usefully \*(``or\*(''ed with characters.
145 .SS "Echoing Characters"
149 are equivalent to calling
152 .RB \%( w ) refresh .
154 interprets these functions as a hint that only a single character is
156 for non-control characters,
157 a considerable performance gain may be enjoyed by employing them.
158 .\" TODO: Combine the following with the "Line Drawing" subsection of
159 .\" terminfo(5) and replace this with a cross reference there.
160 .SS "Forms-Drawing Characters"
162 defines macros starting with
164 that can be used with
166 to write line-drawing and other special characters to the screen.
169 .I "forms-drawing characters."
170 The ACS default listed below is used if the
174 capability does not define a terminal-specific replacement for it,
175 or if the terminal and locale configuration requires Unicode to access
176 these characters but the library is unable to use Unicode.
177 The \*(``acsc char\*('' column corresponds to how the characters are
181 and the characters in it may appear on the screen if the terminal's
182 database entry incorrectly advertises ACS support.
183 The name \*(``ACS\*('' originates in the Alternate Character Set feature
184 of the DEC VT100 terminal.
191 Symbol Default char Glyph Name
193 ACS_BLOCK # 0 solid square block
194 ACS_BOARD # h board of squares
195 ACS_BTEE + v bottom tee
196 ACS_BULLET o \*~ bullet
197 ACS_CKBOARD : a checker board (stipple)
198 ACS_DARROW v . arrow pointing down
199 ACS_DEGREE \*' f degree symbol
200 ACS_DIAMOND + \(ga diamond
201 ACS_GEQUAL > > greater-than-or-equal-to
202 ACS_HLINE \- q horizontal line
203 ACS_LANTERN # i lantern symbol
204 ACS_LARROW < , arrow pointing left
205 ACS_LEQUAL < y less-than-or-equal-to
206 ACS_LLCORNER + m lower left-hand corner
207 ACS_LRCORNER + j lower right-hand corner
208 ACS_LTEE + t left tee
209 ACS_NEQUAL ! | not-equal
211 ACS_PLMINUS # g plus/minus
213 ACS_RARROW > + arrow pointing right
214 ACS_RTEE + u right tee
215 ACS_S1 \- o scan line 1
216 ACS_S3 \- p scan line 3
217 ACS_S7 \- r scan line 7
218 ACS_S9 \&_ s scan line 9
219 ACS_STERLING f } pound-sterling symbol
221 ACS_UARROW \*^ \- arrow pointing up
222 ACS_ULCORNER + l upper left-hand corner
223 ACS_URCORNER + k upper right-hand corner
224 ACS_VLINE | x vertical line
227 These functions return
238 if it is not possible to add a complete character at the cursor
240 as when conversion of a multibyte character to a byte sequence fails,
241 or at least one of the resulting bytes cannot be added to the window.
242 See section \*(``PORTABILITY\*('' below regarding the use of
244 with multibyte characters.
247 can successfully write a character at the bottom right location of the
253 if \fB\%scrollok\fP(3X) is not enabled in that event,
254 because it is not possible to wrap to a new line.
256 Functions prefixed with \*(``mv\*('' first perform cursor movement and
260 is outside the window boundaries.
267 may be implemented as macros.
270 Issue 4 describes these functions.
271 It specifies no error conditions for them.
275 describes a successful return value only as
276 \*(``an integer value other than
279 The defaults specified for forms-drawing characters apply in the POSIX
282 X/Open Curses states that the
288 Some implementations are problematic.
293 define the ACS symbols as constants;
294 others define them as elements of an array.
296 This implementation uses an array,
300 NetBSD also uses an array,
311 symbols to the analogous
315 symbols were wide characters
316 (see \fB\%curs_add_wch\fP(3X)).
317 The misdefined symbols are the arrows and others that are not used for
322 has a typographical error
325 symbol, equating its \*(``VT100+ Character\*('' to \*(``I\*(''
327 while the header files for SVr4
329 and other implementations use \*(``i\*(''
332 None of the terminal descriptions on Unix platforms use uppercase I,
336 entry for \fI\%screen\fP(1),
337 apparently based on the X/Open documentation around 1995).
341 (AT&T PC6300 with EMOTS Terminal Emulator)
342 description uses lowercase i.
353 were not documented in any publicly released System\ V.
355 many publicly available
359 strings in which their key characters
362 and a second-hand list of their character descriptions has come to
366 developers invented ACS-prefixed names for them.
377 wide-character versus non-wide-character configurations
378 (the former is capable of displaying Unicode while the latter is not),
381 whether the locale uses UTF-8 encoding.
384 the terminal is unable to display forms-drawing characters
387 see the discussion of the
388 .I \%NCURSES_NO_UTF8_ACS
389 environment variable in \fB\%ncurses\fP(3X)).
391 X/Open Curses assumes that the parameter passed to
393 contains a single character.
394 As discussed in \fB\%curs_attr\fP(3X),
395 that character may have been more than eight bits wide in an SVr3 or
397 but in the X/Open Curses model,
398 the details are not given.
399 The important distinction between SVr4
401 and X/Open Curses is that the latter separates non-character information
402 (attributes and color)
403 from the character code,
404 which SVr4 packs into a
412 holds an eight-bit character.
413 But the library allows a multibyte character to be passed in a
414 succession of calls to
416 Other implementations do not;
419 call transmits exactly one character,
420 which may be rendered in one or more screen locations depending on
421 whether it is printable.
423 Depending on the locale settings,
425 inspects the byte passed in each
428 and checks whether the latest call continues a multibyte sequence.
432 displays the character and advances the cursor.
434 If the calling application interrupts the succession of bytes in
435 a multibyte character sequence by changing the current location\(emfor
437 with \fB\%wmove\fP(3X)\(em\c
439 discards the incomplete character.
441 For portability to other implementations,
442 do not rely upon this behavior.
443 Check whether a character can be represented as a single byte in the
449 or \fB\%wadd_wch\fP(3X).
453 \fB\%wadd_wch\fP(3X).
455 SVr4 and other versions of
460 but X/Open Curses does not specify it
461 (see \fB\%curs_variables\fP(3X)).
463 \fB\%curs_add_wch\fP(3X) describes comparable functions of the
465 library in its wide-character configuration
469 \fB\%curs_addchstr\fP(3X),
470 \fB\%curs_addstr\fP(3X),
471 \fB\%curs_attr\fP(3X),
472 \fB\%curs_clear\fP(3X),
473 \fB\%curs_inch\fP(3X),
474 \fB\%curs_outopts\fP(3X),
475 \fB\%curs_refresh\fP(3X),
476 \fB\%curs_variables\fP(3X),