1curs_slk(3X) curs_slk(3X)
2
3
4
6 slk_init, slk_set, slk_wset, slk_refresh, slk_noutrefresh, slk_label,
7 slk_clear, slk_restore, slk_touch, slk_attron, slk_attrset,
8 slk_attroff, slk_attr_on, slk_attr_set, slk_attr_off, slk_attr,
9 slk_color, extended_slk_color - curses soft label routines
10
12 #include <curses.h>
13
14 int slk_init(int fmt);
15
16 int slk_set(int labnum, const char *label, int fmt);
17 int slk_wset(int labnum, const wchar_t *label, int fmt);
18
19 char *slk_label(int labnum);
20
21 int slk_refresh(void);
22 int slk_noutrefresh(void);
23 int slk_clear(void);
24 int slk_restore(void);
25 int slk_touch(void);
26
27 int slk_attron(const chtype attrs);
28 int slk_attroff(const chtype attrs);
29 int slk_attrset(const chtype attrs);
30 int slk_attr_on(attr_t attrs, void* opts);
31 int slk_attr_off(const attr_t attrs, void * opts);
32 int slk_attr_set(const attr_t attrs, short pair, void* opts);
33 /* extension */
34 attr_t slk_attr(void);
35
36 int slk_color(short pair);
37 /* extension */
38 int extended_slk_color(int pair);
39
41 The slk* functions manipulate the set of soft function-key labels that
42 exist on many terminals. For those terminals that do not have soft la‐
43 bels, curses takes over the bottom line of stdscr, reducing the size of
44 stdscr and the variable LINES. curses standardizes on eight labels of
45 up to eight characters each. In addition to this, the ncurses imple‐
46 mentation supports a mode where it simulates 12 labels of up to five
47 characters each. This is useful for PC-like enduser devices. ncurses
48 simulates this mode by taking over up to two lines at the bottom of the
49 screen; it does not try to use any hardware support for this mode.
50
51 Initialization
52 The slk_init routine must be called before initscr or newterm is
53 called. If initscr eventually uses a line from stdscr to emulate the
54 soft labels, then fmt determines how the labels are arranged on the
55 screen:
56
57 0 indicates a 3-2-3 arrangement of the labels.
58
59 1 indicates a 4-4 arrangement
60
61 2 indicates the PC-like 4-4-4 mode.
62
63 3 is again the PC-like 4-4-4 mode, but in addition an index line is
64 generated, helping the user to identify the key numbers easily.
65
66 Labels
67 The slk_set routine (and the slk_wset routine for the wide-character
68 library) has three parameters:
69
70 labnum
71 is the label number, from 1 to 8 (12 if fmt in slk_init is 2 or
72 3);
73
74 label
75 is be the string to put on the label, up to eight (five if fmt
76 in slk_init is 2 or 3) characters in length. A null string or
77 a null pointer sets up a blank label.
78
79 fmt is either 0, 1, or 2, indicating whether the label is to be
80 left-justified, centered, or right-justified, respectively,
81 within the label.
82
83 The slk_label routine returns the current label for label number lab‐
84 num, with leading and trailing blanks stripped.
85
86 Screen updates
87 The slk_refresh and slk_noutrefresh routines correspond to the wrefresh
88 and wnoutrefresh routines.
89
90 The slk_clear routine clears the soft labels from the screen.
91
92 The slk_restore routine restores the soft labels to the screen after a
93 slk_clear has been performed.
94
95 The slk_touch routine forces all the soft labels to be output the next
96 time a slk_noutrefresh is performed.
97
98 Video attributes
99 The slk_attron, slk_attrset, slk_attroff and slk_attr routines corre‐
100 spond to attron, attrset, attroff and attr_get, respectively. They
101 have an effect only if soft labels are simulated on the bottom line of
102 the screen. The default highlight for soft keys is A_STANDOUT (as in
103 System V curses, which does not document this fact).
104
105 Colors
106 The slk_color routine corresponds to color_set. It has an effect only
107 if soft labels are simulated on the bottom line of the screen.
108
109 Because slk_color accepts only short (signed 16-bit integer) values,
110 this implementation provides extended_slk_color which accepts an inte‐
111 ger value, e.g., 32-bits.
112
114 These routines return ERR upon failure and OK (SVr4 specifies only "an
115 integer value other than ERR") upon successful completion.
116
117 X/Open defines no error conditions. In this implementation
118
119 slk_attr
120 returns the attribute used for the soft keys.
121
122 slk_attroff, slk_attron, slk_clear, slk_noutrefresh, slk_refresh,
123 slk_touch
124 return an error if the terminal or the softkeys were not ini‐
125 tialized.
126
127 slk_attrset
128 returns an error if the terminal or the softkeys were not ini‐
129 tialized.
130
131 slk_attr_set
132 returns an error if the terminal or the softkeys were not ini‐
133 tialized, or the color pair is outside the range 0..COL‐
134 OR_PAIRS-1.
135
136 slk_color
137 returns an error if the terminal or the softkeys were not ini‐
138 tialized, or the color pair is outside the range 0..COL‐
139 OR_PAIRS-1.
140
141 slk_init
142 returns an error if the format parameter is outside the range
143 0..3.
144
145 slk_label
146 returns NULL on error.
147
148 slk_set
149 returns an error if the terminal or the softkeys were not ini‐
150 tialized, or the labnum parameter is outside the range of label
151 counts, or if the format parameter is outside the range 0..2,
152 or if memory for the labels cannot be allocated.
153
155 SVr3 introduced these functions:
156 slk_clear
157 slk_init
158 slk_label
159 slk_noutrefresh
160 slk_refresh
161 slk_restore
162 slk_set
163 slk_touch
164
165 SVr4 added these functions:
166 slk_attroff
167 slk_attron
168 slk_attrset
169 slk_start
170
171 X/Open Curses added these:
172 slk_attr_off
173 slk_attr_on
174 slk_attr_set
175 slk_color
176 slk_wset
177
179 X/Open Curses documents the opts argument as reserved for future use,
180 saying that it must be null. This implementation uses that parameter
181 in ABI 6 for the functions which have a color-pair parameter to support
182 extended color pairs.
183
184 For functions which modify the color, e.g., slk_attr_set, if opts is
185 set it is treated as a pointer to int, and used to set the color
186 pair instead of the short pair parameter.
187
189 Most applications would use slk_noutrefresh because a wrefresh is like‐
190 ly to follow soon.
191
193 The XSI Curses standard, Issue 4, described the soft-key functions,
194 with some differences from SVr4 curses:
195
196 • It added functions like the SVr4 attribute-manipulation functions
197 slk_attron, slk_attroff, slk_attrset, but which use attr_t parame‐
198 ters (rather than chtype), along with a reserved opts parameter.
199
200 Two of these new functions (unlike the SVr4 functions) have no pro‐
201 vision for color: slk_attr_on and slk_attr_off.
202
203 The third function (slk_attr_set) has a color-pair parameter.
204
205 • It added const qualifiers to parameters (unnecessarily), and
206
207 • It added slk_color.
208
209 Although slk_start is declared in the curses header file, it was not
210 documented by SVr4 other than its presence in a list of libtermlib.so.1
211 symbols. Reading the source code (i.e., Illumos):
212
213 • slk_start has two parameters:
214
215 • ng (number of groups) and
216
217 • gp (group pointer).
218
219 • Soft-key groups are an array of ng integers.
220
221 • In SVr4, slk_init calls slk_start passing a null for gp. For this
222 case, slk_start uses the number of groups ng (3 for the 3-2-3 lay‐
223 out, 2 for the 4-4 layout) which slk_init provided.
224
225 If ng is neither 2 or 3, slk_start checks the terminfo fln (la‐
226 bel_format) capability, interpreting that as a comma-separated list
227 of numbers, e.g., “3,2,3” for the 3-2-3 layout.
228
229 Finally, if there is no fln capability, slk_start returns ERR.
230
231 • If slk_start is given a non-null gp, it copies the ng elements of
232 the group of soft-keys, up to 16.
233
234 If there are more than 16 elements, slk_start returns an error.
235
236 • The format codes 2 and 3 for slk_init were added by ncurses in
237 1996. PDCurses 2.4 added this feature in 2001.
238
239 The function slk_attr was added by ncurses in 1996.
240
241 X/Open Curses does not specify a limit for the number of colors and
242 color pairs which a terminal can support. However, in its use of short
243 for the parameters, it carries over SVr4's implementation detail for
244 the compiled terminfo database, which uses signed 16-bit numbers. This
245 implementation provides extended versions of those functions which use
246 int parameters, allowing applications to use larger color- and pair-
247 numbers.
248
250 curses(3X), curs_attr(3X), curs_initscr(3X), curs_refresh(3X),
251 curs_variables(3X).
252
253
254
255 curs_slk(3X)