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.60 2023/09/23 22:49:51 tom Exp $
31 .TH curs_slk 3X 2023-09-23 "ncurses 6.4" "Library calls"
45 \fB\%slk_noutrefresh\fP,
58 \fB\%extended_slk_color\fP \-
59 \fIcurses\fR soft label key routines
62 \fB#include <curses.h>\fP
64 \fBint slk_init(int \fIfmt\fB);\fR
66 \fBint slk_set(int \fIlabnum\fB, const char *\fIlabel\fB, int \fIfmt\fB);\fR
67 \fBint slk_wset(int \fIlabnum\fB, const wchar_t *\fIlabel\fB, int \fIfmt\fB);\fR
69 \fBchar *slk_label(int \fIlabnum\fB);\fR
71 \fBint slk_refresh(void);\fP
72 \fBint slk_noutrefresh(void);\fP
73 \fBint slk_clear(void);\fP
74 \fBint slk_restore(void);\fP
75 \fBint slk_touch(void);\fP
77 \fBint slk_attron(const chtype \fIattrs\fB);\fR
78 \fBint slk_attroff(const chtype \fIattrs\fB);\fR
79 \fBint slk_attrset(const chtype \fIattrs\fB);\fR
80 \fBint slk_attr_on(attr_t \fIattrs\fB, void* \fIopts\fB);\fR
81 \fBint slk_attr_off(const attr_t \fIattrs\fB, void * \fIopts\fB);\fR
82 \fBint slk_attr_set(const attr_t \fIattrs\fB, short \fIpair\fB, void* \fIopts\fB);\fR
84 \fBattr_t slk_attr(void);\fP
86 \fBint slk_color(short \fIpair\fB);\fR
88 \fBint extended_slk_color(int \fIpair\fB);\fR
91 The \fBslk\fP* functions manipulate the set of soft function-key labels that exist on
93 For those terminals that do not have soft labels,
94 \fIcurses\fP takes over the bottom line of \fB\%stdscr\fP, reducing the size of
95 \fB\%stdscr\fP and the variable \fBLINES\fP.
96 \fIcurses\fP standardizes on eight
97 labels of up to eight characters each.
98 In addition to this, the \fIncurses\fP
99 implementation supports a mode where it simulates 12 labels of up to five
101 This is useful for PC-like enduser devices.
102 \fIncurses\fP simulates this mode by taking over up to two lines at
103 the bottom of the screen;
104 it does not try to use any hardware support for this
107 The \fB\%slk_init\fP routine must be called before \fB\%initscr\fP or \fB\%newterm\fP
109 If \fB\%initscr\fP eventually uses a line from \fB\%stdscr\fP to
110 emulate the soft labels,
111 then \fIfmt\fP determines how the labels are arranged on the screen:
115 indicates a 3\-2\-3 arrangement of
119 indicates a 4\-4 arrangement
122 indicates the PC-like 4\-4\-4 mode.
125 is again the PC-like 4\-4\-4 mode,
126 but in addition an index line is generated, helping the user to
127 identify the key numbers easily.
130 The \fB\%slk_set\fP routine
131 (and the \fB\%slk_wset\fP routine for the wide-character library)
132 has three parameters:
136 is the label number, from \fB1\fP to \fB8\fP
137 (12 if \fIfmt\fP in \fB\%slk_init\fP is \fB2\fP or \fB3\fP);
140 is be the string to put on the label,
142 (five if \fIfmt\fP in \fB\%slk_init\fP is \fB2\fP or \fB3\fP)
143 characters in length.
144 A null string or a null pointer sets up a blank label.
148 \fB0\fP, \fB1\fP, or \fB2\fP, indicating whether the label is to be
149 left-justified, centered, or right-justified, respectively, within the
153 The \fB\%slk_label\fP routine returns the current label for label number
154 \fIlabnum\fP, with leading and trailing blanks stripped.
156 The \fB\%slk_refresh\fP and \fB\%slk_noutrefresh\fP routines correspond to
157 the \fB\%wrefresh\fP and \fB\%wnoutrefresh\fP routines.
159 The \fB\%slk_clear\fP routine clears the soft labels from the screen.
161 The \fB\%slk_restore\fP routine restores the soft labels to the screen
162 after a \fB\%slk_clear\fP has been performed.
164 The \fB\%slk_touch\fP routine forces all the soft labels to be output
165 the next time a \fB\%slk_noutrefresh\fP is performed.
168 \fB\%slk_attron\fP, \fB\%slk_attrset\fP, \fB\%slk_attroff\fP and \fB\%slk_attr\fP
169 routines correspond to
170 \fB\%attron\fP, \fB\%attrset\fP, \fB\%attroff\fP and \fB\%attr_get\fP, respectively.
171 They have an effect only if soft labels are simulated on the bottom line of
173 The default highlight for soft keys is A_STANDOUT (as in
174 System V \fIcurses\fP, which does not document this fact).
176 The \fB\%slk_color\fP routine corresponds to \fB\%color_set\fP.
177 It has an effect only
178 if soft labels are simulated on the bottom line of the screen.
180 Because \fB\%slk_color\fP accepts only \fBshort\fP (signed 16-bit integer) values,
181 this implementation provides
182 \fB\%extended_slk_color\fP which accepts an integer value, e.g., 32-bits.
185 These routines return \fBERR\fP upon failure
186 and \fBOK\fP (SVr4 specifies only "an integer value other than \fBERR\fP")
187 upon successful completion.
189 X/Open defines no error conditions.
190 In this implementation
194 returns the attribute used for the soft keys.
196 \fBslk_attroff\fP, \fBslk_attron\fP, \fBslk_clear\fP, \fBslk_noutrefresh\fP, \fBslk_refresh\fP, \fBslk_touch\fP
198 if the terminal or the softkeys were not initialized.
202 if the terminal or the softkeys were not initialized.
206 if the terminal or the softkeys were not initialized, or
207 the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
211 if the terminal or the softkeys were not initialized, or
212 the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
216 if the format parameter is outside the range 0..3.
219 returns \fBNULL\fP on error.
223 if the terminal or the softkeys were not initialized, or
224 the \fIlabnum\fP parameter is outside the range of label counts, or
225 if the format parameter is outside the range 0..2, or if
226 memory for the labels cannot be allocated.
229 SVr3 introduced these functions:
233 \fBslk_noutrefresh\fP
239 SVr4 added these functions:
245 X/Open \fIcurses\fP added these:
252 X/Open \fIcurses\fP documents the \fIopts\fP argument as reserved for future use,
253 saying that it must be null.
255 uses that parameter in ABI 6 for the functions which have a color-pair
256 parameter to support extended color pairs.
258 For functions which modify the color, e.g., \fB\%slk_attr_set\fP,
259 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
260 and used to set the color pair instead of the \fBshort\fP pair parameter.
262 Most applications would use \fB\%slk_noutrefresh\fP because a
263 \fB\%wrefresh\fP is likely to follow soon.
265 The XSI \fIcurses\fP standard, Issue 4, described the soft-key functions,
266 with some differences from SVr4 \fIcurses\fP:
268 It added functions like the SVr4
269 attribute-manipulation functions \fB\%slk_attron\fP,
270 \fB\%slk_attroff\fP, \fB\%slk_attrset\fP,
271 but which use \fBattr_t\fP parameters (rather than \fB\%chtype\fP),
272 along with a reserved \fIopts\fP parameter.
274 Two of these new functions (unlike the SVr4 functions) have no provision
275 for color: \fB\%slk_attr_on\fP and \fB\%slk_attr_off\fP.
277 The third function (\fB\%slk_attr_set\fP) has a color-pair parameter.
279 It added \fBconst\fP qualifiers to parameters (unnecessarily), and
281 It added \fB\%slk_color\fP.
283 Although \fB\%slk_start\fP is declared in the \fIcurses\fP header file,
284 it was not documented by SVr4 other than its presence in a list
285 of libtermlib.so.1 symbols.
286 Reading the source code (i.e., Illumos):
288 \fB\%slk_start\fP has two parameters:
291 \fIng\fP (number of groups) and
293 \fIgp\fP (group pointer).
296 Soft-key groups are an array of \fIng\fP integers.
298 In SVr4, \fB\%slk_init\fP calls \fB\%slk_start\fP passing a null for \fIgp\fP.
299 For this case, \fB\%slk_start\fP uses the number of groups \fIng\fP
300 (3 for the 3-2-3 layout, 2 for the 4-4 layout) which \fB\%slk_init\fP provided.
302 If \fIng\fP is neither 2 or 3,
303 \fB\%slk_start\fP checks the terminfo \fBfln\fP (label_format) capability,
304 interpreting that as a comma-separated list of numbers,
305 e.g., \*(``3,2,3\*('' for the 3-2-3 layout.
307 Finally, if there is no \fBfln\fP capability, \fB\%slk_start\fP returns \fBERR\fP.
309 If \fB\%slk_start\fP is given a non-null \fIgp\fP,
310 it copies the \fIng\fP elements of the group of soft-keys, up to 16.
312 If there are more than 16 elements, \fB\%slk_start\fP returns an error.
314 The format codes \fB2\fP and \fB3\fP for \fB\%slk_init\fP
315 were added by \fIncurses\fP in 1996.
316 PDCurses 2.4 added this feature in 2001.
318 The function \fB\%slk_attr\fP was added by \fIncurses\fP in 1996.
320 X/Open \fIcurses\fP does not specify a limit for the number of colors and
321 color pairs which a terminal can support.
322 However, in its use of \fBshort\fP for the parameters,
323 it carries over SVr4's implementation detail for the compiled
324 terminfo database, which uses signed 16-bit numbers.
325 This implementation provides extended versions of those functions
326 which use \fBint\fP parameters,
327 allowing applications to use larger color- and pair-numbers.
330 \fB\%curs_attr\fP(3X),
331 \fB\%curs_initscr\fP(3X),
332 \fB\%curs_refresh\fP(3X),
333 \fB\%curs_variables\fP(3X)