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