]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_slk.3x
ncurses 6.4 - patch 20231125
[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.66 2023/11/25 14:31:07 tom Exp $
31 .TH curs_slk 3X 2023-11-25 "ncurses 6.4" "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 \fIfmt\fP);
74 \fBint slk_wset(int \fIlabnum\fP, const wchar_t *\fIlabel\fP, int \fIfmt\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 The \fBslk\fP* functions manipulate the set
99 of soft function-key labels that exist on many terminals.
100 For those terminals that do not have soft labels,
101 \fIcurses\fP takes over the bottom line of \fB\%stdscr\fP, reducing the size of
102 \fB\%stdscr\fP and the variable \fBLINES\fP.
103 \fIcurses\fP standardizes on eight
104 labels of up to eight characters each.
105 In addition to this, the \fIncurses\fP
106 implementation supports a mode where it simulates 12 labels of up to five
107 characters each.
108 This is useful for PC-like enduser devices.
109 \fIncurses\fP simulates this mode by taking over up to two lines at
110 the bottom of the screen;
111 it does not try to use any hardware support for this
112 mode.
113 .SS Initialization
114 The \fB\%slk_init\fP routine must be called
115 before \fB\%initscr\fP or \fB\%newterm\fP
116 is called.
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 .RS 3
121 .TP 3
122 .B 0
123 indicates a 3\-2\-3 arrangement of
124 the labels.
125 .TP 3
126 .B 1
127 indicates a 4\-4 arrangement
128 .TP 3
129 .B 2
130 indicates the PC-like 4\-4\-4 mode.
131 .TP 3
132 .B 3
133 is again the PC-like 4\-4\-4 mode,
134 but in addition an index line is generated, helping the user to
135 identify the key numbers easily.
136 .RE
137 .SS Labels
138 The \fB\%slk_set\fP routine
139 (and the \fB\%slk_wset\fP routine for the wide-character library)
140 has three parameters:
141 .RS 3
142 .TP 5
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 null string or a null pointer sets up a blank label.
153 .TP
154 .I fmt
155 is either
156 \fB0\fP, \fB1\fP, or \fB2\fP, indicating whether the label is to be
157 left-justified, centered, or right-justified, respectively, within the
158 label.
159 .RE
160 .PP
161 The \fB\%slk_label\fP routine returns the current label for label number
162 \fIlabnum\fP, with leading and trailing blanks stripped.
163 .SS Screen updates
164 The \fB\%slk_refresh\fP and \fB\%slk_noutrefresh\fP routines correspond to
165 the \fB\%wrefresh\fP and \fB\%wnoutrefresh\fP routines.
166 .PP
167 The \fB\%slk_clear\fP routine clears the soft labels from the screen.
168 .PP
169 The \fB\%slk_restore\fP routine restores the soft labels to the screen
170 after a \fB\%slk_clear\fP has been performed.
171 .PP
172 The \fB\%slk_touch\fP routine forces all the soft labels to be output
173 the next time a \fB\%slk_noutrefresh\fP is performed.
174 .SS Video attributes
175 The
176 \fB\%slk_attron\fP, \fB\%slk_attrset\fP, \fB\%slk_attroff\fP and \fB\%slk_attr\fP
177 routines correspond to
178 \fB\%attron\fP, \fB\%attrset\fP, \fB\%attroff\fP and \fB\%attr_get\fP, respectively.
179 They have an effect only if soft labels are simulated on the bottom line of
180 the screen.
181 The default highlight for soft keys is A_STANDOUT (as in
182 System V \fIcurses\fP, which does not document this fact).
183 .SS Colors
184 The \fB\%slk_color\fP routine corresponds to \fB\%color_set\fP.
185 It has an effect only
186 if soft labels are simulated on the bottom line of the screen.
187 .PP
188 Because \fB\%slk_color\fP accepts
189 only \fBshort\fP (signed 16-bit integer) values,
190 this implementation provides
191 \fB\%extended_slk_color\fP which accepts an integer value, e.g., 32-bits.
192 .
193 .SH RETURN VALUE
194 These routines return \fBERR\fP upon failure
195 and \fBOK\fP (SVr4 specifies only "an integer value other than \fBERR\fP")
196 upon successful completion.
197 .PP
198 X/Open defines no error conditions.
199 In this implementation
200 .RS 3
201 .TP 5
202 \fBslk_attr\fP
203 returns the attribute used for the soft keys.
204 .TP 5
205 \fBslk_attroff\fP, \fBslk_attron\fP, \fBslk_clear\fP, \fBslk_noutrefresh\fP, \fBslk_refresh\fP, \fBslk_touch\fP
206 return an error
207 if the terminal or the softkeys were not initialized.
208 .TP 5
209 \fBslk_attrset\fP
210 returns an error
211 if the terminal or the softkeys were not initialized.
212 .TP 5
213 \fBslk_attr_set\fP
214 returns an error
215 if the terminal or the softkeys were not initialized, or
216 the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
217 .TP 5
218 \fBslk_color\fP
219 returns an error
220 if the terminal or the softkeys were not initialized, or
221 the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
222 .TP 5
223 \fBslk_init\fP
224 returns an error
225 if the format parameter is outside the range 0..3.
226 .TP 5
227 \fBslk_label\fP
228 returns \fBNULL\fP on error.
229 .TP 5
230 \fBslk_set\fP
231 returns an error
232 if the terminal or the softkeys were not initialized, or
233 the \fIlabnum\fP parameter is outside the range of label counts, or
234 if the format parameter is outside the range 0..2, or if
235 memory for the labels cannot be allocated.
236 .RE
237 .SH NOTES
238 Most applications would use \fB\%slk_noutrefresh\fP because a
239 \fB\%wrefresh\fP is likely to follow soon.
240 .SH EXTENSIONS
241 X/Open \fIcurses\fP documents the \fIopts\fP argument
242 as reserved for future use,
243 saying that it must be null.
244 This implementation
245 uses that parameter in ABI 6 for the functions which have a color-pair
246 parameter to support extended color pairs.
247 .PP
248 For  functions  which modify the color, e.g., \fB\%slk_attr_set\fP,
249 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
250 and used to  set  the  color pair instead of the \fBshort\fP pair parameter.
251 .SH PORTABILITY
252 The XSI \fIcurses\fP standard, Issue 4, described the soft-key functions,
253 with some differences from SVr4 \fIcurses\fP:
254 .bP
255 It added functions like the SVr4
256 attribute-manipulation functions \fB\%slk_attron\fP,
257 \fB\%slk_attroff\fP, \fB\%slk_attrset\fP,
258 but which use \fBattr_t\fP parameters (rather than \fB\%chtype\fP),
259 along with a reserved \fIopts\fP parameter.
260 .IP
261 Two of these new functions (unlike the SVr4 functions) have no provision
262 for color: \fB\%slk_attr_on\fP and \fB\%slk_attr_off\fP.
263 .IP
264 The third function \%(\fBslk_attr_set\fP) has a color-pair parameter.
265 .bP
266 It added \fBconst\fP qualifiers to parameters (unnecessarily), and
267 .bP
268 It added \fB\%slk_color\fP.
269 .PP
270 Although \fB\%slk_start\fP is declared in the \fIcurses\fP header file,
271 it was not documented by SVr4 other than its presence in a list
272 of libtermlib.so.1 symbols.
273 Reading the source code (i.e., Illumos):
274 .bP
275 \fB\%slk_start\fP has two parameters:
276 .RS
277 .bP
278 \fIng\fP (number of groups) and
279 .bP
280 \fIgp\fP (group pointer).
281 .RE
282 .bP
283 Soft-key groups are an array of \fIng\fP integers.
284 .bP
285 In SVr4, \fB\%slk_init\fP calls \fB\%slk_start\fP passing a null for \fIgp\fP.
286 For this case, \fB\%slk_start\fP uses the number of groups \fIng\fP
287 (3 for the 3-2-3 layout, 2 for the 4-4 layout) which \fB\%slk_init\fP provided.
288 .IP
289 If \fIng\fP is neither 2 or 3,
290 \fB\%slk_start\fP checks the terminfo \fBfln\fP (label_format) capability,
291 interpreting that as a comma-separated list of numbers,
292 e.g., \*(``3,2,3\*('' for the 3-2-3 layout.
293 .IP
294 Finally, if there is no \fBfln\fP capability,
295 \fB\%slk_start\fP returns \fBERR\fP.
296 .bP
297 If \fB\%slk_start\fP is given a non-null \fIgp\fP,
298 it copies the \fIng\fP elements of the group of soft-keys, up to 16.
299 .IP
300 If there are more than 16 elements, \fB\%slk_start\fP returns an error.
301 .bP
302 The format codes \fB2\fP and \fB3\fP for \fB\%slk_init\fP
303 were added by \fIncurses\fP in 1996.
304 PDCurses 2.4 added this feature in 2001.
305 .PP
306 The function \fB\%slk_attr\fP was added by \fIncurses\fP in 1996.
307 .PP
308 X/Open \fIcurses\fP does not specify a limit for the number of colors and
309 color pairs which a terminal can support.
310 However, in its use of \fBshort\fP for the parameters,
311 it carries over SVr4's implementation detail for the compiled
312 terminfo database, which uses signed 16-bit numbers.
313 This implementation provides extended versions of those functions
314 which use \fBint\fP parameters,
315 allowing applications to use larger color- and pair-numbers.
316 .SH HISTORY
317 SVr3 introduced these functions:
318   \fBslk_clear\fP
319   \fBslk_init\fP
320   \fBslk_label\fP
321   \fBslk_noutrefresh\fP
322   \fBslk_refresh\fP
323   \fBslk_restore\fP
324   \fBslk_set\fP
325   \fBslk_touch\fP
326 .PP
327 SVr4 added these functions:
328   \fBslk_attroff\fP
329   \fBslk_attron\fP
330   \fBslk_attrset\fP
331   \fBslk_start\fP
332 .PP
333 X/Open \fIcurses\fP added these:
334   \fBslk_attr_off\fP
335   \fBslk_attr_on\fP
336   \fBslk_attr_set\fP
337   \fBslk_color\fP
338   \fBslk_wset\fP
339 .SH SEE ALSO
340 \fB\%curses\fP(3X),
341 \fB\%curs_attr\fP(3X),
342 \fB\%curs_initscr\fP(3X),
343 \fB\%curs_refresh\fP(3X),
344 \fB\%curs_variables\fP(3X)