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