1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
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: *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
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. *
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 *
28 .\"***************************************************************************
30 .\" $Id: curs_slk.3x,v 1.67 2023/12/16 21:18:45 tom Exp $
31 .TH curs_slk 3X 2023-12-16 "ncurses 6.4" "Library calls"
52 \fB\%slk_noutrefresh\fP,
65 \fB\%extended_slk_color\fP \-
66 \fIcurses\fR soft label key routines
69 \fB#include <curses.h>
71 \fBint slk_init(int \fIfmt\fP);
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);
76 \fBchar *slk_label(int \fIlabnum\fP);
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);
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);
91 \fBattr_t slk_attr(void);
93 \fBint slk_color(short \fIpair\fP);
95 \fBint extended_slk_color(int \fIpair\fP);
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.
104 \fIcurses\fP uses eight labels of up to eight characters each.
107 furthermore supports a mode comprising twelve labels of up to five
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
115 \fB\%slk_init\fP must be called before \fB\%initscr\fP or
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.
122 indicates a 3\-2\-3 arrangement of
126 indicates a 4\-4 arrangement
129 indicates the PC-like 4\-4\-4 mode.
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.
137 Populate the labels with normal strings
139 or wide-character strings
141 Each function takes three parameters.
142 .TP 8 \" "labnum" + 2n
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);
148 is be the string to put on the label,
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.
166 within the 8 (5) character cells housing it.
168 \fB\%slk_label\fP obtains the string assigned to label number
170 with any leading and trailing blanks stripped.
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
177 The \fB\%slk_clear\fP routine clears the soft labels from the screen.
179 The \fB\%slk_restore\fP routine restores the soft labels to the screen
180 after a \fB\%slk_clear\fP has been performed.
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"
191 routines correspond to
198 They have an effect only if soft labels are simulated on the bottom line
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).
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.
208 Because \fB\%slk_color\fP accepts
210 (signed 16-bit integer)
212 this implementation provides
213 \fB\%extended_slk_color\fP,
214 which accepts an \fIint\fP value of at least 32 bits.
216 Routines that return an integer return \fBERR\fP upon failure and
219 \*(``an integer value other than \fBERR\fP\*('')
220 upon successful completion.
222 X/Open Curses defines no error conditions.
224 In this implementation
228 returns the attribute used for the soft keys.
230 \fBslk_attroff\fP, \fBslk_attron\fP, \fBslk_clear\fP, \fBslk_noutrefresh\fP, \fBslk_refresh\fP, \fBslk_touch\fP
232 if the terminal or the softkeys were not initialized.
236 if the terminal or the softkeys were not initialized.
240 if the terminal or the softkeys were not initialized, or
241 the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
245 if the terminal or the softkeys were not initialized, or
246 the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
250 if the format parameter is outside the range 0..3.
253 returns \fBNULL\fP on error.
257 if the terminal or the softkeys were not initialized, or
258 the \fIlabnum\fP parameter is outside the range of label counts, or
259 if the format parameter is outside the range 0..2, or if
260 memory for the labels cannot be allocated.
263 Most applications would use \fB\%slk_noutrefresh\fP because a
264 \fB\%wrefresh\fP is likely to follow soon.
266 X/Open Curses documents the \fIopts\fP argument
267 as reserved for future use,
268 saying that it must be null.
270 uses that parameter in ABI 6 for the functions which have a color pair
271 parameter to support extended color pairs.
273 For functions which modify the color,
275 \fB\%slk_attr_set\fP,
276 if \fIopts\fP is set it is treated as a pointer to \fIint\fP,
277 and used to set the color pair instead of the \fIshort\fP pair
280 X/Open Curses, Issue 4, describes these functions,
281 with some differences from SVr4 \fIcurses\fP:
283 X/Open added functions like the SVr4 attribute-manipulation functions
288 but which use \fI\%attr_t\fP parameters
289 (rather than \fI\%chtype\fP),
290 along with a reserved \fIopts\fP parameter.
292 Two of these new functions
293 (unlike the SVr4 functions)
294 have no provision for color:
295 \fB\%slk_attr_on\fP and \fB\%slk_attr_off\fP.
297 The third function \%(\fBslk_attr_set\fP) has a color pair parameter.
299 It added \fIconst\fP qualifiers to parameters (unnecessarily),
302 It added \fB\%slk_color\fP.
304 Although \fB\%slk_start\fP is declared in the \fIcurses\fP header file,
305 it was not documented by SVr4 other than its presence in a list
306 of libtermlib.so.1 symbols.
307 Reading the source code (i.e., Illumos):
309 \fB\%slk_start\fP has two parameters:
312 \fIng\fP (number of groups) and
314 \fIgp\fP (group pointer).
317 Soft-key groups are an array of \fIng\fP integers.
319 In SVr4, \fB\%slk_init\fP calls \fB\%slk_start\fP passing a null for \fIgp\fP.
320 For this case, \fB\%slk_start\fP uses the number of groups \fIng\fP
321 (3 for the 3-2-3 layout, 2 for the 4-4 layout) which \fB\%slk_init\fP provided.
323 If \fIng\fP is neither 2 or 3,
324 \fB\%slk_start\fP checks the terminfo \fBfln\fP (label_format) capability,
325 interpreting that as a comma-separated list of numbers,
326 e.g., \*(``3,2,3\*('' for the 3-2-3 layout.
328 Finally, if there is no \fBfln\fP capability,
329 \fB\%slk_start\fP returns \fBERR\fP.
331 If \fB\%slk_start\fP is given a non-null \fIgp\fP,
332 it copies the \fIng\fP elements of the group of soft-keys, up to 16.
334 If there are more than 16 elements, \fB\%slk_start\fP returns an error.
336 The format codes \fB2\fP and \fB3\fP for \fB\%slk_init\fP
337 were added by \fI\%ncurses\fP in 1996.
338 PDCurses 2.4 added this feature in 2001.
340 The function \fB\%slk_attr\fP was added by \fI\%ncurses\fP in 1996.
342 X/Open Curses does not specify a limit for the number of colors and
343 color pairs which a terminal can support.
344 However, in its use of \fIshort\fP for the parameters,
345 it carries over SVr4's implementation detail for the compiled
346 terminfo database, which uses signed 16-bit numbers.
347 This implementation provides extended versions of those functions
348 which use \fIint\fP parameters,
349 allowing applications to use larger color- and pair-numbers.
351 SVr3 introduced these functions:
355 \fBslk_noutrefresh\fP
361 SVr4 added these functions:
367 X/Open Curses added these:
375 \fB\%curs_attr\fP(3X),
376 \fB\%curs_initscr\fP(3X),
377 \fB\%curs_refresh\fP(3X),
378 \fB\%curs_variables\fP(3X)