]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_slk.3x
ncurses 6.2 - patch 20200926
[ncurses.git] / man / curs_slk.3x
1 .\"***************************************************************************
2 .\" Copyright 2018,2020 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.36 2020/02/02 23:34:34 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 \fBint slk_wset(int \fP\fIlabnum\fP\fB, const wchar_t *\fP\fIlabel\fP\fB, int \fP\fIfmt\fP\fB);\fR
67 .sp
68 \fBchar *slk_label(int \fP\fIlabnum\fP\fB);\fR
69 .sp
70 \fBint slk_refresh(void);\fR
71 .br
72 \fBint slk_noutrefresh(void);\fR
73 .br
74 \fBint slk_clear(void);\fR
75 .br
76 \fBint slk_restore(void);\fR
77 .br
78 \fBint slk_touch(void);\fR
79 .sp
80 \fBint slk_attron(const chtype \fP\fIattrs\fP\fB);\fR
81 .br
82 \fBint slk_attroff(const chtype \fP\fIattrs\fP\fB);\fR
83 .br
84 \fBint slk_attrset(const chtype \fP\fIattrs\fP\fB);\fR
85 .br
86 \fBint slk_attr_on(attr_t \fP\fIattrs\fP\fB, void* \fP\fIopts\fP\fB);\fR
87 .br
88 \fBint slk_attr_off(const attr_t \fP\fIattrs\fP\fB, void * \fP\fIopts\fP\fB);\fR
89 .br
90 \fBint slk_attr_set(const attr_t \fP\fIattrs\fP\fB, short \fP\fIpair\fP\fB, void* \fP\fIopts\fP\fB);\fR
91 .sp
92 \fBattr_t slk_attr(void);\fR
93 .sp
94 \fBint slk_color(short \fP\fIpair\fP\fB);\fR
95 .br
96 /* extension */
97 .br
98 \fBint extended_slk_color(int \fP\fIpair\fP\fB);\fR
99 .SH DESCRIPTION
100 The slk* functions manipulate the set of soft function-key labels that exist on
101 many terminals.
102 For those terminals that do not have soft labels,
103 \fBcurses\fR takes over the bottom line of \fBstdscr\fR, reducing the size of
104 \fBstdscr\fR and the variable \fBLINES\fR.
105 \fBcurses\fR standardizes on eight
106 labels of up to eight characters each.
107 In addition to this, the ncurses
108 implementation supports a mode where it simulates 12 labels of up to five
109 characters each.
110 This is useful for PC-like enduser devices.
111 ncurses simulates this mode by taking over up to two lines at
112 the bottom of the screen;
113 it does not try to use any hardware support for this
114 mode.
115 .SS Initialization
116 .PP
117 The \fBslk_init\fR routine must be called before \fBinitscr\fR or \fBnewterm\fR
118 is called.
119 If \fBinitscr\fR eventually uses a line from \fBstdscr\fR to
120 emulate the soft labels,
121 then \fIfmt\fR determines how the labels are arranged on the screen:
122 .RS 3
123 .TP 3
124 .B 0
125 indicates a 3\-2\-3 arrangement of
126 the labels.
127 .TP 3
128 .B 1
129 indicates a 4\-4 arrangement
130 .TP 3
131 .B 2
132 indicates the PC-like 4\-4\-4 mode.
133 .TP 3
134 .B 3
135 is again the PC-like 4\-4\-4 mode,
136 but in addition an index line is generated, helping the user to
137 identify the key numbers easily.
138 .RE
139 .SS Labels
140 .PP
141 The \fBslk_set\fR routine
142 (and the \fBslk_wset\fR routine for the wide-character library)
143 has three parameters:
144 .RS 3
145 .TP 5
146 .I labnum
147 is the label number, from \fB1\fR to \fB8\fR
148 (12 for \fIfmt\fP in \fBslk_init\fP is \fB2\fP or \fB3\fP);
149 .TP
150 .I label
151 is be the string to put on the label,
152 up to eight
153 (five for \fIfmt\fP in \fBslk_init\fP is \fB2\fP or \fB3\fP)
154 characters in length.
155 A null string or a null pointer sets up a blank label.
156 .TP
157 .I fmt
158 is either
159 \fB0\fR, \fB1\fR, or \fB2\fR, indicating whether the label is to be
160 left-justified, centered, or right-justified, respectively, within the
161 label.
162 .RE
163 .PP
164 The \fBslk_label\fR routine returns the current label for label number
165 \fIlabnum\fR, with leading and trailing blanks stripped.
166 .SS Screen updates
167 .PP
168 The \fBslk_refresh\fR and \fBslk_noutrefresh\fR routines correspond to
169 the \fBwrefresh\fR and \fBwnoutrefresh\fR routines.
170 .PP
171 The \fBslk_clear\fR routine clears the soft labels from the screen.
172 .PP
173 The \fBslk_restore\fR routine restores the soft labels to the screen
174 after a \fBslk_clear\fR has been performed.
175 .PP
176 The \fBslk_touch\fR routine forces all the soft labels to be output
177 the next time a \fBslk_noutrefresh\fR is performed.
178 .SS Video attributes
179 .PP
180 The
181 \fBslk_attron\fR, \fBslk_attrset\fR, \fBslk_attroff\fR and \fBslk_attr\fR
182 routines correspond to
183 \fBattron\fR, \fBattrset\fR, \fBattroff\fR and \fBattr_get\fR, respectively.
184 They have an effect only if soft labels are simulated on the bottom line of
185 the screen.
186 The default highlight for soft keys is A_STANDOUT (as in
187 System V curses, which does not document this fact).
188 .SS Colors
189 .PP
190 The \fBslk_color\fR routine corresponds to \fBcolor_set\fR.
191 It has an effect only
192 if soft labels are simulated on the bottom line of the screen.
193 .PP
194 Because \fBslk_color\fR accepts only \fBshort\fP (signed 16-bit integer) values,
195 this implementation provides 
196 \fBextended_slk_color\fR which accepts an integer value, e.g., 32-bits.
197 .
198 .SH RETURN VALUE
199 These routines return \fBERR\fR upon failure
200 and \fBOK\fP (SVr4 specifies only "an integer value other than \fBERR\fR")
201 upon successful completion.
202 .PP
203 X/Open defines no error conditions.
204 In this implementation
205 .RS 3
206 .TP 5
207 \fBslk_attr\fR
208 returns the attribute used for the soft keys.
209 .TP 5
210 .na
211 .hy 0
212 \fBslk_attroff\fP, \fBslk_attron\fP, \fBslk_clear\fP, \fBslk_noutrefresh\fP, \fBslk_refresh\fP, \fBslk_touch\fP
213 .ad
214 .hy
215 return an error
216 if the terminal or the softkeys were not initialized.
217 .TP 5
218 \fBslk_attrset\fP
219 returns an error
220 if the terminal or the softkeys were not initialized.
221 .TP 5
222 \fBslk_attr_set\fP
223 returns an error
224 if the terminal or the softkeys were not initialized, or
225 the color pair is outside the range 0..COLOR_PAIRS\-1.
226 .TP 5
227 \fBslk_color\fP
228 returns an error
229 if the terminal or the softkeys were not initialized, or
230 the color pair is outside the range 0..COLOR_PAIRS\-1.
231 .TP 5
232 \fBslk_init\fR
233 returns an error
234 if the format parameter is outside the range 0..3.
235 .TP 5
236 \fBslk_label\fR
237 returns \fBNULL\fR on error.
238 .TP 5
239 \fBslk_set\fP
240 returns an error
241 if the terminal or the softkeys were not initialized, or
242 the \fIlabnum\fP parameter is outside the range of label counts, or
243 if the format parameter is outside the range 0..2, or if
244 memory for the labels cannot be allocated.
245 .RE
246 .SH HISTORY
247 SVr3 introduced these functions:
248   slk_clear
249   slk_init
250   slk_label
251   slk_noutrefresh
252   slk_refresh
253   slk_restore
254   slk_set
255   slk_touch
256 .PP
257 SVr4 added these functions:
258   slk_attroff
259   slk_attron
260   slk_attrset
261   slk_start
262 .PP
263 X/Open Curses added these:
264   slk_attr_off
265   slk_attr_on
266   slk_attr_set
267   slk_color
268   slk_wset
269 .SH EXTENSIONS
270 .PP
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\fR because a
282 \fBwrefresh\fR 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\fR,
289 \fBslk_attroff\fR, \fBslk_attrset\fR,
290 but which use \fBattr_t\fR 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\fR qualifiers to parameters (unnecessarily), and
299 .bP
300 It added \fBslk_color\fP.
301 .PP
302 The format codes \fB2\fR and \fB3\fR for \fBslk_init\fR and the
303 function \fBslk_attr\fR are specific to ncurses.
304 .PP
305 X/Open Curses does not specify a limit for the number of colors and
306 color pairs which a terminal can support.
307 However, in its use of \fBshort\fP for the parameters,
308 it carries over SVr4's implementation detail for the compiled
309 terminfo database, which uses signed 16-bit numbers.
310 This implementation provides extended versions of those functions
311 which use \fBshort\fP parameters,
312 allowing applications to use larger color- and pair-numbers.
313 .SH SEE ALSO
314 \fBcurses\fR(3X),
315 \fBcurs_attr\fR(3X),
316 \fBcurs_initscr\fR(3X),
317 \fBcurs_refresh\fR(3X),
318 \fBcurs_variables\fR(3X).