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