]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_slk.3x
ncurses 6.4 - patch 20231001
[ncurses.git] / man / curs_slk.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 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.62 2023/09/30 20:13:18 tom Exp $
31 .TH curs_slk 3X 2023-09-30 "ncurses 6.4" "Library calls"
32 .ie \n(.g .ds `` \(lq
33 .el       .ds `` ``
34 .ie \n(.g .ds '' \(rq
35 .el       .ds '' ''
36 .de bP
37 .ie n  .IP \(bu 4
38 .el    .IP \(bu 2
39 ..
40 .SH NAME
41 \fB\%slk_init\fP,
42 \fB\%slk_set\fP,
43 \fB\%slk_wset\fP,
44 \fB\%slk_refresh\fP,
45 \fB\%slk_noutrefresh\fP,
46 \fB\%slk_label\fP,
47 \fB\%slk_clear\fP,
48 \fB\%slk_restore\fP,
49 \fB\%slk_touch\fP,
50 \fB\%slk_attron\fP,
51 \fB\%slk_attrset\fP,
52 \fB\%slk_attroff\fP,
53 \fB\%slk_attr_on\fP,
54 \fB\%slk_attr_set\fP,
55 \fB\%slk_attr_off\fP,
56 \fB\%slk_attr\fP,
57 \fB\%slk_color\fP,
58 \fB\%extended_slk_color\fP \-
59 \fIcurses\fR soft label key routines
60 .SH SYNOPSIS
61 .nf
62 \fB#include <curses.h>\fP
63 .PP
64 \fBint slk_init(int \fIfmt\fB);\fR
65 .PP
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
68 .PP
69 \fBchar *slk_label(int \fIlabnum\fB);\fR
70 .PP
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
76 .PP
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
83 \fI/* extension */\fP
84 \fBattr_t slk_attr(void);\fP
85 .PP
86 \fBint slk_color(short \fIpair\fB);\fR
87 \fI/* extension */\fP
88 \fBint extended_slk_color(int \fIpair\fB);\fR
89 .fi
90 .SH DESCRIPTION
91 The \fBslk\fP* functions manipulate the set of soft function-key labels that exist on
92 many terminals.
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
100 characters each.
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
105 mode.
106 .SS Initialization
107 The \fB\%slk_init\fP routine must be called before \fB\%initscr\fP or \fB\%newterm\fP
108 is called.
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:
112 .RS 3
113 .TP 3
114 .B 0
115 indicates a 3\-2\-3 arrangement of
116 the labels.
117 .TP 3
118 .B 1
119 indicates a 4\-4 arrangement
120 .TP 3
121 .B 2
122 indicates the PC-like 4\-4\-4 mode.
123 .TP 3
124 .B 3
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.
128 .RE
129 .SS Labels
130 The \fB\%slk_set\fP routine
131 (and the \fB\%slk_wset\fP routine for the wide-character library)
132 has three parameters:
133 .RS 3
134 .TP 5
135 .I labnum
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);
138 .TP
139 .I label
140 is be the string to put on the label,
141 up to eight
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.
145 .TP
146 .I fmt
147 is either
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
150 label.
151 .RE
152 .PP
153 The \fB\%slk_label\fP routine returns the current label for label number
154 \fIlabnum\fP, with leading and trailing blanks stripped.
155 .SS Screen updates
156 The \fB\%slk_refresh\fP and \fB\%slk_noutrefresh\fP routines correspond to
157 the \fB\%wrefresh\fP and \fB\%wnoutrefresh\fP routines.
158 .PP
159 The \fB\%slk_clear\fP routine clears the soft labels from the screen.
160 .PP
161 The \fB\%slk_restore\fP routine restores the soft labels to the screen
162 after a \fB\%slk_clear\fP has been performed.
163 .PP
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.
166 .SS Video attributes
167 The
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
172 the screen.
173 The default highlight for soft keys is A_STANDOUT (as in
174 System V \fIcurses\fP, which does not document this fact).
175 .SS Colors
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.
179 .PP
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.
183 .
184 .SH RETURN VALUE
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.
188 .PP
189 X/Open defines no error conditions.
190 In this implementation
191 .RS 3
192 .TP 5
193 \fBslk_attr\fP
194 returns the attribute used for the soft keys.
195 .TP 5
196 \fBslk_attroff\fP, \fBslk_attron\fP, \fBslk_clear\fP, \fBslk_noutrefresh\fP, \fBslk_refresh\fP, \fBslk_touch\fP
197 return an error
198 if the terminal or the softkeys were not initialized.
199 .TP 5
200 \fBslk_attrset\fP
201 returns an error
202 if the terminal or the softkeys were not initialized.
203 .TP 5
204 \fBslk_attr_set\fP
205 returns an error
206 if the terminal or the softkeys were not initialized, or
207 the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
208 .TP 5
209 \fBslk_color\fP
210 returns an error
211 if the terminal or the softkeys were not initialized, or
212 the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
213 .TP 5
214 \fBslk_init\fP
215 returns an error
216 if the format parameter is outside the range 0..3.
217 .TP 5
218 \fBslk_label\fP
219 returns \fBNULL\fP on error.
220 .TP 5
221 \fBslk_set\fP
222 returns an 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.
227 .RE
228 .SH HISTORY
229 SVr3 introduced these functions:
230   \fBslk_clear\fP
231   \fBslk_init\fP
232   \fBslk_label\fP
233   \fBslk_noutrefresh\fP
234   \fBslk_refresh\fP
235   \fBslk_restore\fP
236   \fBslk_set\fP
237   \fBslk_touch\fP
238 .PP
239 SVr4 added these functions:
240   \fBslk_attroff\fP
241   \fBslk_attron\fP
242   \fBslk_attrset\fP
243   \fBslk_start\fP
244 .PP
245 X/Open \fIcurses\fP added these:
246   \fBslk_attr_off\fP
247   \fBslk_attr_on\fP
248   \fBslk_attr_set\fP
249   \fBslk_color\fP
250   \fBslk_wset\fP
251 .SH EXTENSIONS
252 X/Open \fIcurses\fP documents the \fIopts\fP argument as reserved for future use,
253 saying that it must be null.
254 This implementation
255 uses that parameter in ABI 6 for the functions which have a color-pair
256 parameter to support extended color pairs.
257 .PP
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.
261 .SH NOTES
262 Most applications would use \fB\%slk_noutrefresh\fP because a
263 \fB\%wrefresh\fP is likely to follow soon.
264 .SH PORTABILITY
265 The XSI \fIcurses\fP standard, Issue 4, described the soft-key functions,
266 with some differences from SVr4 \fIcurses\fP:
267 .bP
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.
273 .IP
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.
276 .IP
277 The third function \%(\fBslk_attr_set\fP) has a color-pair parameter.
278 .bP
279 It added \fBconst\fP qualifiers to parameters (unnecessarily), and
280 .bP
281 It added \fB\%slk_color\fP.
282 .PP
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):
287 .bP
288 \fB\%slk_start\fP has two parameters:
289 .RS
290 .bP
291 \fIng\fP (number of groups) and
292 .bP
293 \fIgp\fP (group pointer).
294 .RE
295 .bP
296 Soft-key groups are an array of \fIng\fP integers.
297 .bP
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.
301 .IP
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.
306 .IP
307 Finally, if there is no \fBfln\fP capability, \fB\%slk_start\fP returns \fBERR\fP.
308 .bP
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.
311 .IP
312 If there are more than 16 elements, \fB\%slk_start\fP returns an error.
313 .bP
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.
317 .PP
318 The function \fB\%slk_attr\fP was added by \fIncurses\fP in 1996.
319 .PP
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.
328 .SH SEE ALSO
329 \fB\%curses\fP(3X),
330 \fB\%curs_attr\fP(3X),
331 \fB\%curs_initscr\fP(3X),
332 \fB\%curs_refresh\fP(3X),
333 \fB\%curs_variables\fP(3X)