Debian Codegraph @

upstream/opensuse-leap-16-1/man3/addch.3ncurses

raw
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright 2018-2024,2025 Thomas E. Dickey *
4 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc. *
5 .\" *
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: *
13 .\" *
14 .\" The above copyright notice and this permission notice shall be included *
15 .\" in all copies or substantial portions of the Software. *
16 .\" *
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. *
24 .\" *
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 *
28 .\" authorization. *
29 .\"***************************************************************************
30 .\"
31 .\" $Id: curs_addch.3x,v 1.137 2025/04/26 19:57:22 tom Exp $
32 .TH addch 3NCURSES 2025-04-26 "ncurses 6.5" "Library calls"
33 .ie \n(.g \{\
34 .ds `` \(lq
35 .ds '' \(rq
36 .ds ' \(aq
37 .ds ^ \(ha
38 .ds ~ \(ti
39 .\}
40 .el \{\
41 .ie t .ds `` ``
42 .el .ds `` ""
43 .ie t .ds '' ''
44 .el .ds '' ""
45 .ds ' '
46 .ds ^ ^
47 .ds ~ ~
48 .\}
49 .
50 .de bP
51 .ie n .IP \(bu 4
52 .el .IP \(bu 2
53 ..
54 .SH NAME
55 \fB\%addch\fP,
56 \fB\%waddch\fP,
57 \fB\%mvaddch\fP,
58 \fB\%mvwaddch\fP,
59 \fB\%echochar\fP,
60 \fB\%wechochar\fP \-
61 add a \fIcurses\fP character to a window and advance the cursor
62 .SH SYNOPSIS
63 .nf
64 \fB#include <ncursesw/curses.h>
65 .PP
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);
70 .PP
71 \fBint echochar(const chtype \fIch\fP);
72 \fBint wechochar(WINDOW * \fIwin\fP, const chtype \fIch\fP);
73 .PP
74 \fI/* (integer) constants */\fP
75 /*\fI .\|.\|. */ \fBACS_BLOCK;\fR
76 /*\fI .\|.\|. */ \fBACS_BOARD;\fR
77 /*\fI .\|.\|. */ \fBACS_BTEE;\fR
78 /*\fI .\|.\|. */ \fBACS_BULLET;\fR
79 /*\fI .\|.\|. */ \fBACS_CKBOARD;\fR
80 /*\fI .\|.\|. */ \fBACS_DARROW;\fR
81 /*\fI .\|.\|. */ \fBACS_DEGREE;\fR
82 /*\fI .\|.\|. */ \fBACS_DIAMOND;\fR
83 /*\fI .\|.\|. */ \fBACS_HLINE;\fR
84 /*\fI .\|.\|. */ \fBACS_LANTERN;\fR
85 /*\fI .\|.\|. */ \fBACS_LARROW;\fR
86 /*\fI .\|.\|. */ \fBACS_LLCORNER;\fR
87 /*\fI .\|.\|. */ \fBACS_LRCORNER;\fR
88 /*\fI .\|.\|. */ \fBACS_LTEE;\fR
89 /*\fI .\|.\|. */ \fBACS_PLMINUS;\fR
90 /*\fI .\|.\|. */ \fBACS_PLUS;\fR
91 /*\fI .\|.\|. */ \fBACS_RARROW;\fR
92 /*\fI .\|.\|. */ \fBACS_RTEE;\fR
93 /*\fI .\|.\|. */ \fBACS_S1;\fR
94 /*\fI .\|.\|. */ \fBACS_S9;\fR
95 /*\fI .\|.\|. */ \fBACS_TTEE;\fR
96 /*\fI .\|.\|. */ \fBACS_UARROW;\fR
97 /*\fI .\|.\|. */ \fBACS_ULCORNER;\fR
98 /*\fI .\|.\|. */ \fBACS_URCORNER;\fR
99 /*\fI .\|.\|. */ \fBACS_VLINE;\fR
100 \fI/* extensions */\fP
101 /*\fI .\|.\|. */ \fBACS_GEQUAL;\fR
102 /*\fI .\|.\|. */ \fBACS_LEQUAL;\fR
103 /*\fI .\|.\|. */ \fBACS_NEQUAL;\fR
104 /*\fI .\|.\|. */ \fBACS_PI;\fR
105 /*\fI .\|.\|. */ \fBACS_S3;\fR
106 /*\fI .\|.\|. */ \fBACS_S7;\fR
107 /*\fI .\|.\|. */ \fBACS_STERLING;\fR
108 .fi
109 .SH DESCRIPTION
110 .SS waddch
111 .B \%waddch
112 writes the
113 .I curses
114 character
115 .I ch
116 to the window
117 .IR win ","
118 then advances the cursor position,
119 analogously to the standard C library's \fI\%putchar\fP(3).
120 \fB\%ncurses\fP(3NCURSES) describes the variants of this function.
121 .PP
122 Construct a
123 .I curses
124 character
125 from a
126 .I char
127 by assignment or typecast.
128 Subsection \*(``Video Attributes\*('' of \fB\%attron\fP(3NCURSES) describes
129 how to manipulate its attributes and color pair.
130 (A color pair selection is not honored unless initialized;
131 see \fB\%start_color\fP(3NCURSES).)
132 .PP
133 The object or expression
134 .I ch
135 may contain attributes and/or a color pair identifier.
136 (A
137 .I \%chtype
138 can be copied from place to place using \fB\%winch\fP(3NCURSES) and
139 .BR \%waddch .)
140 See \fB\%attr\fP(3NCURSES) for values of predefined constants that can be
141 usefully \*(``or\*(''ed with characters.
142 A
143 .I ch
144 whose character component is a space,
145 and whose only attribute is
146 .BR \%A_NORMAL ,
147 is a
148 .IR "blank character" ","
149 and therefore combines with the window's background character;
150 see \fB\%bkgd\fP(3NCURSES).
151 .PP
152 If
153 .I ch
154 is a
155 backspace,
156 carriage return,
157 line feed,
158 or
159 tab,
160 the cursor moves appropriately within the window.
161 .bP
162 Backspace moves the cursor one character left;
163 at the left margin of a window,
164 it does nothing.
165 .bP
166 Carriage return moves the cursor to the left margin on the same line of
167 the window.
168 .bP
169 Line feed does a \fB\%clrtoeol\fP(3NCURSES),
170 then advances as if from the right margin.
171 .bP
172 Tab advances the cursor to the next tab stop
173 (possibly on the next line);
174 these are placed at every eighth column by default.
175 .IP
176 Alter the tab interval with the
177 .B \%TABSIZE
178 extension;
179 see \fB\%curses_variables\fP(3NCURSES).
180 .PP
181 If
182 .I ch
183 is any other nonprintable character,
184 it is drawn in printable form using the same convention as
185 \fB\%unctrl\fP(3NCURSES).
186 Calling \fB\%winch\fP(3NCURSES) on the location of a nonprintable character
187 does not return the character itself,
188 but its \fB\%unctrl\fP(3NCURSES) representation.
189 .PP
190 Adding printable characters with \fB\%waddch\fP
191 causes it to wrap at the right margin of the window:
192 .bP
193 If the cursor is not at the bottom of the scrolling region
194 and advancement occurs at the right margin,
195 the cursor automatically wraps to the beginning of the next line.
196 .bP
197 If the cursor is at the bottom of the scrolling region
198 when advancement occurs at the right margin,
199 and \fB\%scrollok\fP(3NCURSES) is enabled for
200 .IR win ,
201 the scrolling region scrolls up one line
202 and the cursor wraps as above.
203 Otherwise,
204 advancement and scrolling do not occur,
205 and
206 .B \%waddch
207 returns
208 .BR ERR "."
209 .PP
210 A window's margins may coincide with the screen boundaries.
211 This may be a problem when
212 .I \%ncurses
213 updates the screen to match the curses window.
214 When their right and bottom margins coincide,
215 .I \%ncurses
216 uses different strategies to handle the variations of scrolling and wrapping
217 at the lower-right corner
218 by depending on the terminal capabilities:
219 .bP
220 If the terminal does not automatically wrap as characters
221 are added at the right margin
222 (i.e., auto right margins),
223 .I \%ncurses
224 writes the character directly.
225 .bP
226 If the terminal has auto right margins,
227 but also has capabilities for turning auto margins off and on,
228 .I \%ncurses
229 turns the auto margin feature off temporarily
230 when writing to the lower-right corner.
231 .bP
232 If the terminal has an insertion mode which can be turned off and on,
233 .I \%ncurses
234 writes the character just before the lower-right corner,
235 and then inserts a character to push the update into the corner.
236 .SS wechochar
237 .B \%echochar
238 and
239 .B \%wechochar
240 are equivalent to calling
241 .RB \%( w ) addch
242 followed by
243 .RB \%( w ) refresh
244 on
245 .B \%stdscr
246 or the specified window.
247 .I curses
248 interprets these functions as a hint to its optimizer
249 that only a single character cell in the window
250 is being altered between refreshes;
251 for non-control characters,
252 a considerable performance gain may be enjoyed by employing them.
253 .\" TODO: Combine the following with the "Line Drawing" subsection of
254 .\" terminfo(5) and replace this with a cross reference there.
255 .SS "Forms-Drawing Characters"
256 .I curses
257 defines macros starting with
258 .B \%ACS_
259 that can be used with
260 .B \%waddch
261 to write line-drawing and other symbols to the screen.
262 .I \%ncurses
263 terms these
264 .I "forms-drawing characters."
265 .I curses
266 uses the ACS default listed below if the terminal type lacks the
267 .B \%acs_chars
268 .RB \%( acsc )
269 capability;
270 that capability does not define a replacement for the character;
271 or if the terminal type and locale configuration
272 require Unicode to access these characters,
273 but the library is unable to use Unicode.
274 The \*(``acsc char\*('' column corresponds to how the characters are
275 specified in the
276 .B \%acs_chars
277 .RB \%( acsc )
278 string capability,
279 and the characters in it may appear on the screen if the terminal type's
280 database entry incorrectly advertises ACS support.
281 The name \*(``ACS\*('' originates in the Alternate Character Set feature
282 of the DEC VT100 terminal.
283 .PP
284 .ie t .ne 4v
285 .el .ne 5v
286 .TS
287 Lb Lb Lb Lb
288 Lb Lb Lb Lb
289 Lb L L Lx.
290 \& ACS acsc \&
291 Symbol Default char Glyph Name
292 _
293 ACS_BLOCK # 0 solid square block
294 ACS_BOARD # h board of squares
295 ACS_BTEE + v bottom tee
296 ACS_BULLET o \*~ bullet
297 ACS_CKBOARD : a checker board (stipple)
298 ACS_DARROW v . arrow pointing down
299 ACS_DEGREE \*' f degree symbol
300 ACS_DIAMOND + \(ga diamond
301 ACS_GEQUAL > > greater-than-or-equal-to
302 ACS_HLINE \- q horizontal line
303 ACS_LANTERN # i lantern symbol
304 ACS_LARROW < , arrow pointing left
305 ACS_LEQUAL < y less-than-or-equal-to
306 ACS_LLCORNER + m lower left-hand corner
307 ACS_LRCORNER + j lower right-hand corner
308 ACS_LTEE + t left tee
309 ACS_NEQUAL ! | not-equal
310 ACS_PI * { greek pi
311 ACS_PLMINUS # g plus/minus
312 ACS_PLUS + n plus
313 ACS_RARROW > + arrow pointing right
314 ACS_RTEE + u right tee
315 ACS_S1 \- o scan line 1
316 ACS_S3 \- p scan line 3
317 ACS_S7 \- r scan line 7
318 ACS_S9 \&_ s scan line 9
319 ACS_STERLING f } pound-sterling symbol
320 ACS_TTEE + w top tee
321 ACS_UARROW \*^ \- arrow pointing up
322 ACS_ULCORNER + l upper left-hand corner
323 ACS_URCORNER + k upper right-hand corner
324 ACS_VLINE | x vertical line
325 .TE
326 .SH RETURN VALUE
327 These functions return
328 .B OK
329 on success and
330 .B ERR
331 on failure.
332 .PP
333 In
334 .IR \%ncurses ,
335 these functions fail if
336 .bP
337 the
338 .I curses
339 screen has not been initialized,
340 .bP
341 (for functions taking a
342 .I \%WINDOW
343 pointer argument)
344 .I win
345 is a null pointer,
346 .bP
347 wrapping to a new line is impossible because \fB\%scrollok\fP(3NCURSES) has
348 not been called on
349 .I win
350 (or
351 .BR \%stdscr ","
352 as applicable)
353 when a write to its bottom right location is attempted,
354 or
355 .bP
356 it is not possible to add a complete character at the cursor position.
357 .PP
358 The last may be due to different causes:
359 .bP
360 conversion of a wide character to a multibyte character sequence can
361 fail,
362 or
363 .bP
364 at least one of the bytes resulting from wide character conversion to a
365 multibyte character sequence cannot be added to the window.
366 See section \*(``PORTABILITY\*('' below regarding the use of
367 .B \%waddch
368 with wide characters.
369 .PP
370 Functions prefixed with \*(``mv\*('' first perform cursor movement and
371 fail if the position
372 .RI ( y ,
373 .IR x )
374 is outside the window boundaries.
375 .SH NOTES
376 .BR \%addch ","
377 .BR \%mvaddch ","
378 .BR \%mvwaddch ","
379 and
380 .B \%echochar
381 may be implemented as macros.
382 .SH EXTENSIONS
383 The symbols
384 .IR \%ACS_S3 ","
385 .IR \%ACS_S7 ","
386 .IR \%ACS_LEQUAL ","
387 .IR \%ACS_GEQUAL ","
388 .IR \%ACS_PI ","
389 .IR \%ACS_NEQUAL ","
390 and
391 .I \%ACS_STERLING
392 were not documented in any publicly released System\ V
393 .\" And did not exist yet as late as SVr4.
394 .\" https://github.com/ryanwoodsmall/oldsysv/blob/master/\
395 .\" sysvr4/svr4/lib/xlibcurses/screen/curses.ed
396 and are not standard.
397 However,
398 many publicly available
399 .I \%term\%info
400 entries include
401 .B \%acs_chars
402 .RB \%( acsc )
403 capabilities in which their key characters
404 .RB ( pryz{|} )
405 are embedded,
406 and a second-hand list of their character descriptions has come to light,
407 which identifies them as VT100 special characters.
408 .PP
409 The DEC Special Character and Line Drawing Set (VT100) is indexed by
410 an ASCII character in the range 96 (`) to 126 (~).
411 That index character is part of the definition for the curses
412 .B \%ACS_
413 symbols.
414 The VT100 special characters can be categorized in three groups:
415 .bP
416 useful graphic symbols with a standard
417 .B \%ACS_
418 symbol,
419 (e.g., the line-drawing symbols),
420 .bP
421 possibly useful characters (these non-standard symbols),
422 .bP
423 representations of control characters (e.g., newline and vertical tabulation).
424 .PP
425 A few
426 .B \%ACS_
427 symbols do not fit into DEC's VT100 scheme.
428 The AT&T Teletype 5410v1 arrow symbols and
429 .B \%ACS_BLOCK
430 use indices outside the range 96 to 126.
431 Two of the Teletype symbols use indices in that range,
432 with different meaning versus the VT100:
433 .bP
434 .B \%ACS_BOARD
435 corresponds to the VT100 symbol for newline
436 .bP
437 .B \%ACS_LANTERN
438 corresponds to the VT100 symbol for vertical tabulation
439 .PP
440 AT&T defined
441 .B \%ACS_
442 names for the most useful graphic symbols,
443 as well as for its own.
444 Its header file commented:
445 .sp
446 .EX
447 /*
448 * Standard alternate character set. The current ACS world is evolving,
449 * so we support only a widely available subset: the line drawing characters
450 * from the VT100, plus a few from the Teletype 5410v1. Eventually there
451 * may be support of more sophisticated ACS line drawing, such as that
452 * in the Teletype 5410, the HP line drawing set, and the like. There may
453 * be support for some non line oriented characters as well.
454 *
455 * Line drawing ACS names are of the form ACS_trbl, where t is the top, r
456 * is the right, b is the bottom, and l is the left. t, r, b, and l might
457 * be B (blank), S (single), D (double), or T (thick). The subset defined
458 * here only uses B and S.
459 */
460 .EE
461 .PP
462 Although these less-useful graphic symbols were not given names,
463 they were used in
464 .I \%terminfo
465 entries.
466 The
467 .I \%ncurses
468 developers invented ACS-prefixed names for them.
469 .\" in v1_9_5_950928_e227
470 .SH PORTABILITY
471 Applications employing
472 .I \%ncurses
473 extensions should condition their use on the visibility of the
474 .B \%NCURSES_VERSION
475 preprocessor macro.
476 .PP
477 X/Open Curses Issue\ 4 describes these functions.
478 It specifies no error conditions for them.
479 .PP
480 SVr4 describes a successful return value only as
481 \*(``an integer value other than
482 .IR ERR \*(''. \" Courier roman in source; SVID 4, vol. 3, p. 472
483 .PP
484 The defaults specified for forms-drawing characters apply in the POSIX
485 locale.
486 .SS "ACS Symbols"
487 X/Open Curses states that the
488 .I \%ACS_
489 definitions are
490 .I char
491 constants.
492 Some implementations are problematic.
493 .bP
494 Solaris
495 .IR curses ,
496 for example,
497 defines the ACS symbols as constants;
498 others define them as elements of an array.
499 .IP
500 SVr4 used an array,
501 .IR \%acs_map ,
502 as does
503 .IR \%ncurses "."
504 NetBSD
505 .I curses
506 also uses an array,
507 actually named
508 .IR \%_acs_char ,
509 with a \%\*(``#define\*('' for compatibility.
510 .bP
511 HP-UX
512 .I curses
513 equates some of the
514 .I \%ACS_
515 symbols to the analogous
516 .I \%WACS_
517 symbols as if the
518 .I \%ACS_
519 symbols were wide characters
520 (see \fB\%add_wch\fP(3NCURSES)).
521 The misdefined symbols are the arrows and others that are not used for
522 line drawing.
523 .bP
524 X/Open Curses
525 (Issues\ 2 through 7)
526 has a typographical error
527 for the
528 .I \%ACS_LANTERN
529 symbol, equating its \*(``VT100+ Character\*('' to \*(``I\*(''
530 (capital I),
531 while the header files for SVr4
532 .I curses
533 and other implementations use \*(``i\*(''
534 (small i).
535 .IP
536 None of the terminal descriptions on Unix platforms use uppercase I,
537 except for Solaris
538 (in its
539 .I \%term\%info
540 entry for \fI\%screen\fP(1),
541 apparently based on the X/Open documentation around 1995).
542 On the other hand,
543 its
544 .B \%gs6300
545 (AT&T PC6300 with EMOTS Terminal Emulator)
546 description uses lowercase i.
547 .PP
548 The
549 .I displayed
550 values of
551 .I \%ACS_
552 constants depend on
553 .bP
554 the
555 .I \%ncurses
556 ABI \(em
557 for example,
558 wide-character versus non-wide-character configurations
559 (the former is capable of displaying Unicode while the latter is not),
560 and
561 .bP
562 whether the locale uses UTF-8 encoding.
563 .PP
564 In certain cases,
565 the terminal is unable to display forms-drawing characters
566 .I except
567 by using UTF-8;
568 see the discussion of the
569 .I \%NCURSES_NO_UTF8_ACS
570 environment variable in \fB\%ncurses\fP(3NCURSES).
571 .SS "Character Set"
572 X/Open Curses assumes that the parameter passed to
573 .I \%waddch
574 contains a single character.
575 That character may have been more than eight bits wide in an SVr3 or
576 SVr4 implementation,
577 but X/Open Curses leaves the width of a non-wide character code
578 unspecified.
579 The standard further does not specify the internal structure of a
580 .IR chtype ","
581 though the use of bit operations to combine the character code with
582 attributes and a color pair identifier into a
583 .I \%chtype
584 for passage to
585 .I \%waddch
586 is common.
587 A portable application uses only the macros discussed in
588 \fB\%attr\fP(3NCURSES) to manipulate a
589 .IR \%chtype "."
590 .PP
591 In
592 .IR \%ncurses ,
593 .I \%chtype
594 holds an eight-bit character,
595 but the library allows a multibyte character sequence to be passed via a
596 succession of calls to
597 .IR \%waddch "."
598 Other implementations do not;
599 a
600 .I \%waddch
601 call transmits exactly one character,
602 which may be rendered in one or more screen locations depending on
603 whether it is printable
604 (see \fB\%unctrl\fP(3NCURSES)).
605 Depending on the locale,
606 .I \%ncurses
607 inspects the byte passed in each
608 .I \%waddch
609 call and checks whether the latest call continues a multibyte character.
610 When a character is
611 .IR complete ","
612 .I \%ncurses
613 displays the character and advances the cursor.
614 If the calling application interrupts the succession of bytes in
615 a multibyte character sequence by changing the current location \(em
616 for example,
617 with \fB\%wmove\fP(3NCURSES) \(em
618 .I \%ncurses
619 discards the incomplete character.
620 .PP
621 For portability to other implementations,
622 do not rely upon the foregoing behavior.
623 Check whether a character can be represented as a single byte in the
624 current locale.
625 .bP
626 If it can,
627 call either
628 .I \%waddch
629 or
630 .IR \%wadd_wch "."
631 .bP
632 If it cannot,
633 use only
634 .IR \%wadd_wch "."
635 .SH HISTORY
636 4BSD (1980)
637 introduced
638 .I \%waddch
639 and its variants.
640 .PP
641 SVr3 (1987)
642 added the
643 .I \%echochar
644 and
645 .I \%wechochar
646 functions and most of the
647 .I ACS_
648 constants,
649 except for
650 .IR \%ACS_GEQUAL ","
651 .IR \%ACS_LEQUAL ","
652 .IR \%ACS_NEQUAL ","
653 .IR \%ACS_PI ","
654 .IR \%ACS_S3 ","
655 .IR \%ACS_S7 ","
656 and
657 .IR \%ACS_STERLING "."
658 .PP
659 .I \%ncurses
660 1.9.6 (1995)
661 furnished the remaining
662 .I ACS_
663 constants.
664 .SH SEE ALSO
665 \fB\%add_wch\fP(3NCURSES) describes comparable functions of the
666 .I \%ncurses
667 library in its wide-character configuration
668 .RI \%( ncursesw ).
669 .PP
670 \fB\%ncurses\fP(3NCURSES),
671 \fB\%addchstr\fP(3NCURSES),
672 \fB\%addstr\fP(3NCURSES),
673 \fB\%attr\fP(3NCURSES),
674 \fB\%bkgd\fP(3NCURSES),
675 \fB\%clear\fP(3NCURSES),
676 \fB\%inch\fP(3NCURSES),
677 \fB\%outopts\fP(3NCURSES),
678 \fB\%refresh\fP(3NCURSES),
679 \fB\%curses_variables\fP(3NCURSES),
680 \fB\%putchar\fP(3)