]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_inch.3x
786ab2f7a7527a70c1173d5f57a18145702e5c1f
[ncurses.git] / man / curs_inch.3x
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
4 .\" Copyright 1998-2010,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_inch.3x,v 1.54 2024/05/18 20:07:52 tom Exp $
32 .TH curs_inch 3X 2024-05-18 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
33 .ie \n(.g \{\
34 .ds `` \(lq
35 .ds '' \(rq
36 .\}
37 .el \{\
38 .ie t .ds `` ``
39 .el   .ds `` ""
40 .ie t .ds '' ''
41 .el   .ds '' ""
42 .\}
43 .
44 .de bP
45 .ie n  .IP \(bu 4
46 .el    .IP \(bu 2
47 ..
48 .SH NAME
49 \fB\%inch\fP,
50 \fB\%winch\fP,
51 \fB\%mvinch\fP,
52 \fB\%mvwinch\fP \-
53 get a \fIcurses\fR character from a window
54 .SH SYNOPSIS
55 .nf
56 \fB#include <curses.h>
57 .PP
58 \fBchtype inch(void);
59 \fBchtype winch(WINDOW * \fIwin\fP);
60 \fBchtype mvinch(int \fIy\fP, int \fIx\fP);
61 \fBchtype mvwinch(WINDOW * \fIwin\fP, int \fIy\fP, int \fIx\fP);
62 .fi
63 .SH DESCRIPTION
64 .B \%winch
65 returns the
66 .I curses
67 character,
68 including its attributes and color pair identifier,
69 at the cursor position in the window
70 .IR win "."
71 Subsection \*(``Video Attributes\*('' of \fB\%attron\fP(3X) explains
72 how to extract these data from a
73 .IR chtype "."
74 \fB\%ncurses\fP(3X) describes the variants of this function.
75 .SH RETURN VALUE
76 These functions return
77 .B OK
78 on success and
79 .B ERR
80 on failure.
81 .PP
82 In
83 .IR \%ncurses ","
84 .B \%winch
85 returns
86 .B ERR
87 if
88 .I win
89 is
90 .BR NULL "."
91 .PP
92 Functions prefixed with \*(``mv\*('' first perform cursor movement and
93 fail if the position
94 .RI ( y ,
95 .IR x )
96 is outside the window boundaries.
97 .SH NOTES
98 .BR \%inch ,
99 .BR \%mvinch ,
100 and
101 .B \%mvwinch
102 may be implemented as macros.
103 .PP
104 These functions do not return an error if the window contains cells of
105 .I curses
106 complex characters;
107 that is,
108 if they contain characters with codes wider than eight bits
109 (or greater than 255 as an unsigned decimal integer).
110 They instead extract only the low-order eight bits of the character code
111 from the cell.
112 .SH PORTABILITY
113 X/Open Curses,
114 Issue 4 describes these functions.
115 It specifies no error conditions for them.
116 .SH HISTORY
117 The original
118 .I curses
119 in 4BSD (1980) defined
120 .I \%winch
121 as a macro accessing the
122 .I \%WINDOW
123 structure member representing character cell data,
124 at that time a
125 .IR char ","
126 containing only a 7-bit ASCII character code
127 and a \*(``standout\*(`` attribute bit,
128 the only one the library supported.
129 .PP
130 SVr2
131 .I curses
132 (1984)
133 extended this approach,
134 widening the character code to eight bits
135 and permitting several attributes to be combined with it
136 by storing them together in a
137 .IR \%chtype ","
138 an alias of
139 .IR "unsigned short" "."
140 .\" ...indirectly through a preprocessor macro named CHTYPE, encouraging
141 .\" builders to change the typedef to `char` or `long` as desired.  More
142 .\" innocent times with respect to ABI compatibility concerns... --GBR
143 Because a macro was used,
144 its value was not type-checked
145 as a function return value could have been.
146 Goodheart documented SVr3 (1987)
147 .I \%winch
148 as returning an
149 .IR int "."
150 .\" ...but the implementation remained unchanged.
151 SVr3.1's (1987)
152 .I \%chtype
153 became an alias of
154 .IR "unsigned long" ","
155 using 16 bits for the character code and
156 widening the type in practical terms to 32 bits,
157 as 64-bit Unix systems were not yet in wide use,
158 and fixed-width integral types would not be standard until ISO C99.
159 .\" Cray's UNICOS was 1985 (how many shops had Crays?).  DEC OSF/1 for
160 .\" the Alpha arrived in 1993.  --GBR
161 SVr3.2 (1988)
162 added a 6-bit color pair identifier alongside the attributes.
163 .PP
164 X/Open Curses does not specify the sizes of the character code or
165 color pair identifier,
166 nor the quantity of attribute bits,
167 in
168 .IR chtype ";"
169 these are implementation-dependent.
170 .I \%ncurses
171 uses eight bits for the character code.
172 An application requiring a wider character type,
173 for instance to represent Unicode,
174 should use the wide-character counterparts of these functions.
175 .SH SEE ALSO
176 \fB\%curs_in_wch\fP(3X) describes comparable functions of the
177 .I \%ncurses
178 library in its wide-character configuration
179 .RI ( \%ncursesw ).
180 .PP
181 \fB\%curses\fP(3X),
182 \fB\%curs_instr\fP(3X)