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