Debian Codegraph @

upstream/debian-unstable/man3/slk.3ncurses

raw
1 .\"***************************************************************************
2 .\" Copyright 2018-2024,2025 Thomas E. Dickey *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
4 .\" *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a *
6 .\" copy of this software and associated documentation files (the *
7 .\" "Software"), to deal in the Software without restriction, including *
8 .\" without limitation the rights to use, copy, modify, merge, publish, *
9 .\" distribute, distribute with modifications, sublicense, and/or sell *
10 .\" copies of the Software, and to permit persons to whom the Software is *
11 .\" furnished to do so, subject to the following conditions: *
12 .\" *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
15 .\" *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 .\" *
24 .\" Except as contained in this notice, the name(s) of the above copyright *
25 .\" holders shall not be used in advertising or otherwise to promote the *
26 .\" sale, use or other dealings in this Software without prior written *
27 .\" authorization. *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_slk.3x,v 1.85 2025/01/19 00:51:10 tom Exp $
31 .TH slk 3NCURSES 2025-01-18 "ncurses 6.6" "Library calls"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .\}
36 .el \{\
37 .ie t .ds `` ``
38 .el .ds `` ""
39 .ie t .ds '' ''
40 .el .ds '' ""
41 .\}
42 .
43 .de bP
44 .ie n .IP \(bu 4
45 .el .IP \(bu 2
46 ..
47 .SH NAME
48 \fB\%slk_init\fP,
49 \fB\%slk_set\fP,
50 \fB\%slk_wset\fP,
51 \fB\%slk_refresh\fP,
52 \fB\%slk_noutrefresh\fP,
53 \fB\%slk_label\fP,
54 \fB\%slk_clear\fP,
55 \fB\%slk_restore\fP,
56 \fB\%slk_touch\fP,
57 \fB\%slk_attron\fP,
58 \fB\%slk_attrset\fP,
59 \fB\%slk_attroff\fP,
60 \fB\%slk_attr_on\fP,
61 \fB\%slk_attr_set\fP,
62 \fB\%slk_attr_off\fP,
63 \fB\%slk_attr\fP,
64 \fB\%slk_color\fP,
65 \fB\%extended_slk_color\fP \-
66 \fIcurses\fR soft label key routines
67 .SH SYNOPSIS
68 .nf
69 \fB#include <curses.h>
70 .PP
71 \fBint slk_init(int \fIfmt\fP);
72 .PP
73 \fBint slk_set(int \fIlabnum\fP, const char *\fIlabel\fP, int \fIalign\fP);
74 \fBint slk_wset(int \fIlabnum\fP, const wchar_t *\fIlabel\fP, int \fIalign\fP);
75 .PP
76 \fBchar *slk_label(int \fIlabnum\fP);
77 .PP
78 \fBint slk_refresh(void);
79 \fBint slk_noutrefresh(void);
80 \fBint slk_clear(void);
81 \fBint slk_restore(void);
82 \fBint slk_touch(void);
83 .PP
84 \fBint slk_attron(const chtype \fIattrs\fP);
85 \fBint slk_attroff(const chtype \fIattrs\fP);
86 \fBint slk_attrset(const chtype \fIattrs\fP);
87 \fBint slk_attr_on(attr_t \fIattrs\fP, void *\fIopts\fP);
88 \fBint slk_attr_off(const attr_t \fIattrs\fP, void *\fIopts\fP);
89 \fBint slk_attr_set(const attr_t \fIattrs\fP, short \fIpair\fP, void*\fIopts\fP);
90 \fI/* extension */
91 \fBattr_t slk_attr(void);
92 .PP
93 \fBint slk_color(short \fIpair\fP);
94 \fI/* extension */
95 \fBint extended_slk_color(int \fIpair\fP);
96 .fi
97 .SH DESCRIPTION
98 These functions manipulate the soft function key labels that some
99 hardware terminals support.
100 For those terminals that do not have soft labels,
101 \fIcurses\fP takes over the bottom line of \fB\%stdscr\fP,
102 reducing its vertical size and the value of \fBLINES\fP by one.
103 By default,
104 \fIcurses\fP uses eight labels of up to eight characters each.
105 .PP
106 \fI\%ncurses\fP
107 furthermore supports a mode comprising twelve labels of up to five
108 characters each,
109 following a convention associated with the IBM PC/AT keyboard.
110 \fI\%ncurses\fP simulates this mode by taking over up to two lines at
111 the bottom of the screen;
112 it does not try to use any hardware support for this
113 mode.
114 .SS Initialization
115 \fB\%slk_init\fP must be called before \fB\%initscr\fP or
116 \fB\%newterm\fP.
117 If \fB\%initscr\fP eventually uses a line from \fB\%stdscr\fP to
118 emulate the soft labels,
119 then \fIfmt\fP determines how the labels are arranged on the screen.
120 .TP 3
121 .B 0
122 indicates a 3\-2\-3 arrangement of
123 the labels.
124 .TP 3
125 .B 1
126 indicates a 4\-4 arrangement
127 .TP 3
128 .B 2
129 indicates the PC-like 4\-4\-4 mode.
130 .TP 3
131 .B 3
132 is again the PC-like 4\-4\-4 mode,
133 but in addition an index line is generated,
134 helping the user to associate each label with its numbered function key.
135 \fBLINES\fP and the vertical size of \fB\%stdscr\fP are further reduced.
136 .SS Labels
137 Populate the labels with normal strings
138 \%(\fBslk_set\fP)
139 or wide-character strings
140 \%(\fBslk_wset\fP).
141 Each function takes three parameters.
142 .TP 8 \" "labnum" + 2n
143 .I labnum
144 is the label number, from \fB1\fP to \fB8\fP
145 (12 if \fIfmt\fP in \fB\%slk_init\fP is \fB2\fP or \fB3\fP);
146 .TP
147 .I label
148 is be the string to put on the label,
149 up to eight
150 (five if \fIfmt\fP in \fB\%slk_init\fP is \fB2\fP or \fB3\fP)
151 characters in length.
152 A empty string or a null pointer sets up a blank label.
153 .TP
154 .I align
155 is
156 .BR 0 ,
157 .BR 1 ,
158 or
159 .BR 2 ,
160 aligning
161 .I label
162 to the left,
163 center,
164 or right,
165 respectively,
166 within the 8 (5) character cells housing it.
167 .PP
168 \fB\%slk_label\fP obtains the string assigned to label number
169 \fIlabnum\fP,
170 with any leading and trailing blanks stripped.
171 .SS "Screen Updates"
172 \fB\%slk_refresh\fP and \fB\%slk_noutrefresh\fP affect the soft key
173 label lines as \fB\%wrefresh\fP and \fB\%wnoutrefresh\fP do the
174 .I curses
175 window.
176 .PP
177 The \fB\%slk_clear\fP routine clears the soft labels from the screen.
178 .PP
179 The \fB\%slk_restore\fP routine restores the soft labels to the screen
180 after a \fB\%slk_clear\fP has been performed.
181 .PP
182 The \fB\%slk_touch\fP routine forces all the soft labels to be output
183 the next time a \fB\%slk_noutrefresh\fP is performed.
184 .SS "Video Attributes"
185 The
186 \fB\%slk_attron\fP,
187 \fB\%slk_attrset\fP,
188 \fB\%slk_attroff\fP,
189 and
190 \fB\%slk_attr\fP
191 routines correspond to
192 \fB\%attron\fP,
193 \fB\%attrset\fP,
194 \fB\%attroff\fP,
195 and
196 \fB\%attr_get\fP,
197 respectively.
198 They have an effect only if soft labels are simulated on the bottom line
199 of the screen.
200 The default highlight for soft key labels is \fB\%A_STANDOUT\fP
201 (as in System\ V \fIcurses\fP,
202 which does not document this fact).
203 .SS Colors
204 The \fB\%slk_color\fP routine corresponds to \fB\%color_set\fP.
205 It has an effect only
206 if soft labels are simulated on the bottom line of the screen.
207 .PP
208 Because \fB\%slk_color\fP accepts
209 only \fIshort\fP
210 (signed 16-bit integer)
211 values,
212 this implementation provides
213 \fB\%extended_slk_color\fP,
214 which accepts an \fIint\fP value of at least 32 bits.
215 .SH RETURN VALUE
216 Functions that return integers return
217 .B ERR
218 upon failure and
219 .B OK
220 upon success.
221 .PP
222 In
223 .IR \%ncurses ","
224 .RS 3
225 .TP 5
226 \fBslk_attr\fP
227 returns the attribute used for the soft keys.
228 .TP 5
229 \fBslk_attroff\fP, \fBslk_attron\fP, \fBslk_clear\fP, \fBslk_noutrefresh\fP, \fBslk_refresh\fP, \fBslk_touch\fP
230 return
231 .B ERR
232 if the terminal or the softkeys were not initialized.
233 .TP 5
234 \fBslk_attrset\fP
235 returns
236 .B ERR
237 if the terminal or the softkeys were not initialized.
238 .TP 5
239 \fBslk_attr_set\fP
240 returns
241 .B ERR
242 if the terminal or the softkeys were not initialized, or
243 the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
244 .TP 5
245 \fBslk_color\fP
246 returns
247 .B ERR
248 if the terminal or the softkeys were not initialized, or
249 the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
250 .TP 5
251 \fBslk_init\fP
252 returns
253 .B ERR
254 if the format parameter is outside the range 0..3.
255 .TP 5
256 \fBslk_label\fP
257 returns
258 .I NULL
259 on error.
260 .TP 5
261 \fBslk_set\fP
262 returns
263 .B ERR
264 if the terminal or the softkeys were not initialized, or
265 the \fIlabnum\fP parameter is outside the range of label counts, or
266 if the format parameter is outside the range 0..2, or if
267 memory for the labels cannot be allocated.
268 .RE
269 .SH NOTES
270 Most applications would use \fB\%slk_noutrefresh\fP because a
271 \fB\%wrefresh\fP is likely to follow soon.
272 .SH EXTENSIONS
273 X/Open Curses documents the
274 .I opts
275 argument as reserved for future use,
276 saying that it must be a null pointer.
277 The
278 .IR \%ncurses\ 6
279 ABI uses it
280 for the functions that accept a color pair parameter
281 to support extended color pairs.
282 .PP
283 For functions which modify the color,
284 e.g.,
285 \fB\%slk_attr_set\fP,
286 if \fIopts\fP is set it is treated as a pointer to \fIint\fP,
287 and used to set the color pair instead of the \fIshort\fP pair
288 parameter.
289 .SH PORTABILITY
290 X/Open Curses Issue\ 4 describes these functions.
291 It specifies no error conditions for them.
292 .PP
293 SVr4 describes a successful return value only as
294 \*(``an integer value other than
295 .IR ERR \*(''. \" Courier roman in source; SVID 4, vol. 3, p. 533
296 .bP
297 X/Open added functions like the SVr4 attribute-manipulation functions
298 \fB\%slk_attron\fP,
299 \fB\%slk_attroff\fP,
300 and
301 \fB\%slk_attrset\fP,
302 but which use \fI\%attr_t\fP parameters
303 (rather than \fI\%chtype\fP),
304 along with a reserved \fIopts\fP parameter.
305 .IP
306 Two of these new functions
307 (unlike the SVr4 functions)
308 have no provision for color:
309 \fB\%slk_attr_on\fP and \fB\%slk_attr_off\fP.
310 .IP
311 The third function \%(\fBslk_attr_set\fP) has a color pair parameter.
312 .bP
313 It added \fIconst\fP qualifiers to parameters (unnecessarily),
314 and
315 .bP
316 It added \fB\%slk_color\fP.
317 .PP
318 Although \fB\%slk_start\fP is declared in the \fIcurses\fP header file,
319 it was not documented by SVr4 other than its presence in a list
320 of libtermlib.so.1 symbols.
321 Reading the source code (i.e., Illumos):
322 .bP
323 \fB\%slk_start\fP has two parameters:
324 .RS
325 .bP
326 \fIng\fP (number of groups) and
327 .bP
328 \fIgp\fP (group pointer).
329 .RE
330 .bP
331 Soft-key groups are an array of \fIng\fP integers.
332 .bP
333 In SVr4, \fB\%slk_init\fP calls \fB\%slk_start\fP passing a null for \fIgp\fP.
334 For this case, \fB\%slk_start\fP uses the number of groups \fIng\fP
335 (3 for the 3-2-3 layout, 2 for the 4-4 layout) which \fB\%slk_init\fP provided.
336 .IP
337 If \fIng\fP is neither 2 or 3,
338 \fB\%slk_start\fP checks the terminfo \fBfln\fP (label_format) capability,
339 interpreting that as a comma-separated list of numbers,
340 e.g., \*(``3,2,3\*('' for the 3-2-3 layout.
341 .IP
342 Finally, if there is no \fBfln\fP capability,
343 \fB\%slk_start\fP returns \fBERR\fP.
344 .bP
345 If \fB\%slk_start\fP is given a non-null \fIgp\fP,
346 it copies the \fIng\fP elements of the group of soft-keys, up to 16.
347 .IP
348 If there are more than 16 elements, \fB\%slk_start\fP returns
349 .BR ERR "."
350 .bP
351 The format codes \fB2\fP and \fB3\fP for \fB\%slk_init\fP
352 were added by \fI\%ncurses\fP in 1996.
353 .I \%PDCurses
354 2.4 added this feature in 2001.
355 .PP
356 The function \fB\%slk_attr\fP was added by \fI\%ncurses\fP in 1996.
357 .PP
358 X/Open Curses does not specify a limit for the number of colors and
359 color pairs which a terminal can support.
360 However, in its use of \fIshort\fP for the parameters,
361 it carries over SVr4's implementation detail for the compiled
362 terminfo database, which uses signed 16-bit numbers.
363 This implementation provides extended versions of those functions
364 which use \fIint\fP parameters,
365 allowing applications to use larger color- and pair-numbers.
366 .SH HISTORY
367 SVr3 introduced these functions:
368 \fBslk_clear\fP
369 \fBslk_init\fP
370 \fBslk_label\fP
371 \fBslk_noutrefresh\fP
372 \fBslk_refresh\fP
373 \fBslk_restore\fP
374 \fBslk_set\fP
375 \fBslk_touch\fP
376 .PP
377 SVr4 added these functions:
378 \fBslk_attroff\fP
379 \fBslk_attron\fP
380 \fBslk_attrset\fP
381 \fBslk_start\fP
382 .PP
383 X/Open Curses added these:
384 \fBslk_attr_off\fP
385 \fBslk_attr_on\fP
386 \fBslk_attr_set\fP
387 \fBslk_color\fP
388 \fBslk_wset\fP
389 .SH SEE ALSO
390 \fB\%ncurses\fP(3NCURSES),
391 \fB\%attr\fP(3NCURSES),
392 \fB\%initscr\fP(3NCURSES),
393 \fB\%refresh\fP(3NCURSES),
394 \fB\%curses_variables\fP(3NCURSES)