]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_slk.3x
ncurses 6.0 - patch 20170923
[ncurses.git] / man / curs_slk.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2016,2017 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_slk.3x,v 1.31 2017/03/31 11:09:28 tom Exp $
30 .TH curs_slk 3X ""
31 .de bP
32 .IP \(bu 4
33 ..
34 .na
35 .hy 0
36 .SH NAME
37 \fBslk_init\fR,
38 \fBslk_set\fR,
39 \fBslk_wset\fR,
40 \fBslk_refresh\fR,
41 \fBslk_noutrefresh\fR,
42 \fBslk_label\fR,
43 \fBslk_clear\fR,
44 \fBslk_restore\fR,
45 \fBslk_touch\fR,
46 \fBslk_attron\fR,
47 \fBslk_attrset\fR,
48 \fBslk_attroff\fR,
49 \fBslk_attr_on\fR,
50 \fBslk_attr_set\fR,
51 \fBslk_attr_off\fR,
52 \fBslk_attr\fR,
53 \fBslk_color\fR,
54 \fBextended_slk_color\fR \- \fBcurses\fR soft label routines
55 .ad
56 .hy
57 .SH SYNOPSIS
58 \fB#include <curses.h>\fR
59 .sp
60 \fBint slk_init(int \fP\fIfmt\fP\fB);\fR
61 .sp
62 \fBint slk_set(int \fP\fIlabnum\fP\fB, const char *\fP\fIlabel\fP\fB, int \fP\fIfmt\fP\fB);\fR
63 .br
64 \fBint slk_wset(int \fP\fIlabnum\fP\fB, const wchar_t *\fP\fIlabel\fP\fB, int \fP\fIfmt\fP\fB);\fR
65 .sp
66 \fBchar *slk_label(int \fP\fIlabnum\fP\fB);\fR
67 .sp
68 \fBint slk_refresh(void);\fR
69 .br
70 \fBint slk_noutrefresh(void);\fR
71 .br
72 \fBint slk_clear(void);\fR
73 .br
74 \fBint slk_restore(void);\fR
75 .br
76 \fBint slk_touch(void);\fR
77 .sp
78 \fBint slk_attron(const chtype \fP\fIattrs\fP\fB);\fR
79 .br
80 \fBint slk_attroff(const chtype \fP\fIattrs\fP\fB);\fR
81 .br
82 \fBint slk_attrset(const chtype \fP\fIattrs\fP\fB);\fR
83 .br
84 \fBint slk_attr_on(attr_t \fP\fIattrs\fP\fB, void* \fP\fIopts\fP\fB);\fR
85 .br
86 \fBint slk_attr_off(const attr_t \fP\fIattrs\fP\fB, void * \fP\fIopts\fP\fB);\fR
87 .br
88 \fBint slk_attr_set(const attr_t \fP\fIattrs\fP\fB, short \fP\fIpair\fP\fB, void* \fP\fIopts\fP\fB);\fR
89 .sp
90 \fBattr_t slk_attr(void);\fR
91 .sp
92 \fBint slk_color(short \fP\fIpair\fP\fB);\fR
93 .br
94 /* extension */
95 .br
96 \fBint extended_slk_color(int \fP\fIpair\fP\fB);\fR
97 .SH DESCRIPTION
98 The slk* functions manipulate the set of soft function-key labels that exist on
99 many terminals.
100 For those terminals that do not have soft labels,
101 \fBcurses\fR takes over the bottom line of \fBstdscr\fR, reducing the size of
102 \fBstdscr\fR and the variable \fBLINES\fR.
103 \fBcurses\fR standardizes on eight
104 labels of up to eight characters each.
105 In addition to this, the ncurses
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 ncurses 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 .PP
115 The \fBslk_init\fR routine must be called before \fBinitscr\fR or \fBnewterm\fR
116 is called.
117 If \fBinitscr\fR eventually uses a line from \fBstdscr\fR to
118 emulate the soft labels,
119 then \fIfmt\fR 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 .PP
139 The \fBslk_set\fR routine
140 (and the \fBslk_wset\fR routine for the wide-character library)
141 has three parameters:
142 .RS 3
143 .TP 5
144 .I labnum
145 is the label number, from \fB1\fR to \fB8\fR
146 (12 for \fIfmt\fP in \fBslk_init\fP is \fB2\fP or \fB3\fP);
147 .TP
148 .I label
149 is be the string to put on the label,
150 up to eight
151 (five for \fIfmt\fP in \fBslk_init\fP is \fB2\fP or \fB3\fP)
152 characters in length.
153 A null string or a null pointer sets up a blank label.
154 .TP
155 .I fmt
156 is either
157 \fB0\fR, \fB1\fR, or \fB2\fR, indicating whether the label is to be
158 left-justified, centered, or right-justified, respectively, within the
159 label.
160 .RE
161 .PP
162 The \fBslk_label\fR routine returns the current label for label number
163 \fIlabnum\fR, with leading and trailing blanks stripped.
164 .SS Screen updates
165 .PP
166 The \fBslk_refresh\fR and \fBslk_noutrefresh\fR routines correspond to
167 the \fBwrefresh\fR and \fBwnoutrefresh\fR routines.
168 .PP
169 The \fBslk_clear\fR routine clears the soft labels from the screen.
170 .PP
171 The \fBslk_restore\fR routine restores the soft labels to the screen
172 after a \fBslk_clear\fR has been performed.
173 .PP
174 The \fBslk_touch\fR routine forces all the soft labels to be output
175 the next time a \fBslk_noutrefresh\fR is performed.
176 .SS Video attributes
177 .PP
178 The \fBslk_attron\fR, \fBslk_attrset\fR, \fBslk_attroff\fR and \fBslk_attr\fR
179 routines correspond to \fBattron\fR, \fBattrset\fR, \fBattroff\fR and \fBattr_get\fR.
180 They have an effect only if soft labels are simulated on the bottom line of
181 the screen.
182 The default highlight for soft keys is A_STANDOUT (as in
183 System V curses, which does not document this fact).
184 .SS Colors
185 .PP
186 The \fBslk_color\fR routine corresponds to \fBcolor_set\fR.
187 It has an effect only
188 if soft labels are simulated on the bottom line of the screen.
189 .PP
190 Because \fBslk_color\fR accepts only \fBshort\fP (signed 16-bit integer) values,
191 this implementation provides 
192 \fBextended_slk_color\fR which accepts an integer value, e.g., 32-bits.
193 .
194 .SH RETURN VALUE
195 These routines return \fBERR\fR upon failure and OK (SVr4 specifies only "an
196 integer value other than \fBERR\fR") 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\fR
203 returns the attribute used for the soft keys.
204 .TP 5
205 .na
206 .hy 0
207 \fBslk_attroff\fP, \fBslk_attron\fP, \fBslk_clear\fP, \fBslk_noutrefresh\fP, \fBslk_refresh\fP, \fBslk_touch\fP
208 .ad
209 .hy
210 return an error
211 if the terminal or the softkeys were not initialized.
212 .TP 5
213 \fBslk_attrset\fP
214 returns an error
215 if the terminal or the softkeys were not initialized.
216 .TP 5
217 \fBslk_attr_set\fP
218 returns an error
219 if the terminal or the softkeys were not initialized, or
220 the color pair is outside the range 0..COLOR_PAIRS\-1.
221 .TP 5
222 \fBslk_color\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_init\fR
228 returns an error
229 if the format parameter is outside the range 0..3.
230 .TP 5
231 \fBslk_label\fR
232 returns \fBNULL\fR on error.
233 .TP 5
234 \fBslk_set\fP
235 returns an error
236 if the terminal or the softkeys were not initialized, or
237 the \fIlabnum\fP parameter is outside the range of label counts, or
238 if the format parameter is outside the range 0..2, or if
239 memory for the labels cannot be allocated.
240 .RE
241 .SH EXTENSIONS
242 .PP
243 X/Open Curses documents the \fIopts\fP argument as reserved for future use,
244 saying that it must be null.
245 This implementation 
246 uses that parameter in ABI 6 for the functions which have a color-pair
247 parameter to support extended color pairs.
248 .PP
249 For  functions  which modify the color, e.g., \fBslk_attr_set\fP,
250 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
251 and used to  set  the  color pair instead of the \fBshort\fP pair parameter.
252 .SH NOTES
253 Most applications would use \fBslk_noutrefresh\fR because a
254 \fBwrefresh\fR is likely to follow soon.
255 .SH PORTABILITY
256 The XSI Curses standard, Issue 4, described the soft-key functions,
257 with some differences from SVr4 curses:
258 .bP
259 It added functions like the SVr4
260 attribute-manipulation functions \fBslk_attron\fR,
261 \fBslk_attroff\fR, \fBslk_attrset\fR,
262 but which use \fBattr_t\fR parameters (rather than \fBchtype\fP),
263 along with a reserved \fIopts\fP parameter.
264 .IP
265 Two of these new functions (unlike the SVr4 functions) have no provision
266 for color: \fBslk_attr_on\fP and \fBslk_attr_off\fP.
267 .IP
268 The third function (\fBslk_attr_set\fP) has a color-pair parameter.
269 .bP
270 It added \fBconst\fR qualifiers to parameters (unnecessarily), and
271 .bP
272 It added \fBslk_color\fP.
273 .PP
274 The format codes \fB2\fR and \fB3\fR for \fBslk_init\fR and the
275 function \fBslk_attr\fR are specific to ncurses.
276 .PP
277 X/Open Curses does not specify a limit for the number of colors and
278 color pairs which a terminal can support.
279 However, in its use of \fBshort\fP for the parameters,
280 it carries over SVr4's implementation detail for the compiled
281 terminfo database, which uses signed 16-bit numbers.
282 This implementation provides extended versions of those functions
283 which use \fBshort\fP parameters,
284 allowing applications to use larger color- and pair-numbers.
285 .SH SEE ALSO
286 \fBcurses\fR(3X),
287 \fBcurs_attr\fR(3X),
288 \fBcurs_initscr\fR(3X),
289 \fBcurs_refresh\fR(3X),
290 \fBcurs_variables\fR(3X).