blob: fbc718115434467fb0f897c26d1077c4c09ed3b9 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2018-2023,2024 Thomas E. Dickey *
3.\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $Id: curs_slk.3x,v 1.71 2024/04/20 18:54:36 tom Exp $
31.TH curs_slk 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
32.ie \n(.g \{\
33.ds `` \(lq
34.ds '' \(rq
35.\}
36.el \{\
37.ie t .ds `` ``
38.el .ds `` ""
39.ie t .ds '' ''
40.el .ds '' ""
41.\}
42.
43.de bP
44.ie n .IP \(bu 4
45.el .IP \(bu 2
46..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053047.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040048\fB\%slk_init\fP,
49\fB\%slk_set\fP,
50\fB\%slk_wset\fP,
51\fB\%slk_refresh\fP,
52\fB\%slk_noutrefresh\fP,
53\fB\%slk_label\fP,
54\fB\%slk_clear\fP,
55\fB\%slk_restore\fP,
56\fB\%slk_touch\fP,
57\fB\%slk_attron\fP,
58\fB\%slk_attrset\fP,
59\fB\%slk_attroff\fP,
60\fB\%slk_attr_on\fP,
61\fB\%slk_attr_set\fP,
62\fB\%slk_attr_off\fP,
63\fB\%slk_attr\fP,
64\fB\%slk_color\fP,
65\fB\%extended_slk_color\fP \-
66\fIcurses\fR soft label key routines
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053067.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040068.nf
69\fB#include <curses.h>
70.PP
71\fBint slk_init(int \fIfmt\fP);
72.PP
73\fBint slk_set(int \fIlabnum\fP, const char *\fIlabel\fP, int \fIalign\fP);
74\fBint slk_wset(int \fIlabnum\fP, const wchar_t *\fIlabel\fP, int \fIalign\fP);
75.PP
76\fBchar *slk_label(int \fIlabnum\fP);
77.PP
78\fBint slk_refresh(void);
79\fBint slk_noutrefresh(void);
80\fBint slk_clear(void);
81\fBint slk_restore(void);
82\fBint slk_touch(void);
83.PP
84\fBint slk_attron(const chtype \fIattrs\fP);
85\fBint slk_attroff(const chtype \fIattrs\fP);
86\fBint slk_attrset(const chtype \fIattrs\fP);
87\fBint slk_attr_on(attr_t \fIattrs\fP, void *\fIopts\fP);
88\fBint slk_attr_off(const attr_t \fIattrs\fP, void *\fIopts\fP);
89\fBint slk_attr_set(const attr_t \fIattrs\fP, short \fIpair\fP, void*\fIopts\fP);
90\fI/* extension */
91\fBattr_t slk_attr(void);
92.PP
93\fBint slk_color(short \fIpair\fP);
94\fI/* extension */
95\fBint extended_slk_color(int \fIpair\fP);
96.fi
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053097.SH DESCRIPTION
micky3879b9f5e72025-07-08 18:04:53 -040098These functions manipulate the soft function key labels that some
99hardware terminals support.
Steve Kondikae271bc2015-11-15 02:50:53 +0100100For those terminals that do not have soft labels,
micky3879b9f5e72025-07-08 18:04:53 -0400101\fIcurses\fP takes over the bottom line of \fB\%stdscr\fP,
102reducing its vertical size and the value of \fBLINES\fP by one.
103By default,
104\fIcurses\fP uses eight labels of up to eight characters each.
105.PP
106\fI\%ncurses\fP
107furthermore supports a mode comprising twelve labels of up to five
108characters each,
109following a convention associated with the IBM PC/AT keyboard.
110\fI\%ncurses\fP simulates this mode by taking over up to two lines at
Steve Kondikae271bc2015-11-15 02:50:53 +0100111the bottom of the screen;
112it does not try to use any hardware support for this
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530113mode.
micky3879b9f5e72025-07-08 18:04:53 -0400114.SS Initialization
115\fB\%slk_init\fP must be called before \fB\%initscr\fP or
116\fB\%newterm\fP.
117If \fB\%initscr\fP eventually uses a line from \fB\%stdscr\fP to
Steve Kondikae271bc2015-11-15 02:50:53 +0100118emulate the soft labels,
micky3879b9f5e72025-07-08 18:04:53 -0400119then \fIfmt\fP determines how the labels are arranged on the screen.
Steve Kondikae271bc2015-11-15 02:50:53 +0100120.TP 3
121.B 0
122indicates a 3\-2\-3 arrangement of
123the labels.
124.TP 3
125.B 1
126indicates a 4\-4 arrangement
127.TP 3
128.B 2
129indicates the PC-like 4\-4\-4 mode.
130.TP 3
131.B 3
132is again the PC-like 4\-4\-4 mode,
micky3879b9f5e72025-07-08 18:04:53 -0400133but in addition an index line is generated,
134helping the user to associate each label with its numbered function key.
135\fBLINES\fP and the vertical size of \fB\%stdscr\fP are further reduced.
136.SS Labels
137Populate the labels with normal strings
138(\fB\%slk_set\fP)
139or wide-character strings
140(\fB\%slk_wset\fP).
141Each function takes three parameters.
142.TP 8 \" "labnum" + 2n
Steve Kondikae271bc2015-11-15 02:50:53 +0100143.I labnum
micky3879b9f5e72025-07-08 18:04:53 -0400144is the label number, from \fB1\fP to \fB8\fP
145(12 if \fIfmt\fP in \fB\%slk_init\fP is \fB2\fP or \fB3\fP);
Steve Kondikae271bc2015-11-15 02:50:53 +0100146.TP
147.I label
148is be the string to put on the label,
149up to eight
micky3879b9f5e72025-07-08 18:04:53 -0400150(five if \fIfmt\fP in \fB\%slk_init\fP is \fB2\fP or \fB3\fP)
Steve Kondikae271bc2015-11-15 02:50:53 +0100151characters in length.
micky3879b9f5e72025-07-08 18:04:53 -0400152A empty string or a null pointer sets up a blank label.
Steve Kondikae271bc2015-11-15 02:50:53 +0100153.TP
micky3879b9f5e72025-07-08 18:04:53 -0400154.I align
155is
156.BR 0 ,
157.BR 1 ,
158or
159.BR 2 ,
160aligning
161.I label
162to the left,
163center,
164or right,
165respectively,
166within the 8 (5) character cells housing it.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530167.PP
micky3879b9f5e72025-07-08 18:04:53 -0400168\fB\%slk_label\fP obtains the string assigned to label number
169\fIlabnum\fP,
170with any leading and trailing blanks stripped.
171.SS "Screen Updates"
172\fB\%slk_refresh\fP and \fB\%slk_noutrefresh\fP affect the soft key
173label lines as \fB\%wrefresh\fP and \fB\%wnoutrefresh\fP do the
174.I curses
175window.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530176.PP
micky3879b9f5e72025-07-08 18:04:53 -0400177The \fB\%slk_clear\fP routine clears the soft labels from the screen.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530178.PP
micky3879b9f5e72025-07-08 18:04:53 -0400179The \fB\%slk_restore\fP routine restores the soft labels to the screen
180after a \fB\%slk_clear\fP has been performed.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530181.PP
micky3879b9f5e72025-07-08 18:04:53 -0400182The \fB\%slk_touch\fP routine forces all the soft labels to be output
183the next time a \fB\%slk_noutrefresh\fP is performed.
184.SS "Video Attributes"
185The
186\fB\%slk_attron\fP,
187\fB\%slk_attrset\fP,
188\fB\%slk_attroff\fP,
189and
190\fB\%slk_attr\fP
191routines correspond to
192\fB\%attron\fP,
193\fB\%attrset\fP,
194\fB\%attroff\fP,
195and
196\fB\%attr_get\fP,
197respectively.
198They have an effect only if soft labels are simulated on the bottom line
199of the screen.
200The default highlight for soft key labels is \fB\%A_STANDOUT\fP
201(as in System\ V \fIcurses\fP,
202which does not document this fact).
203.SS Colors
204The \fB\%slk_color\fP routine corresponds to \fB\%color_set\fP.
Steve Kondikae271bc2015-11-15 02:50:53 +0100205It has an effect only
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530206if soft labels are simulated on the bottom line of the screen.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530207.PP
micky3879b9f5e72025-07-08 18:04:53 -0400208Because \fB\%slk_color\fP accepts
209only \fIshort\fP
210(signed 16-bit integer)
211values,
212this implementation provides
213\fB\%extended_slk_color\fP,
214which accepts an \fIint\fP value of at least 32 bits.
215.SH RETURN VALUE
216Routines that return an integer return \fBERR\fP upon failure and
217\fBOK\fP
218(SVr4 specifies only
219\*(``an integer value other than \fBERR\fP\*('')
220upon successful completion.
221.PP
222X/Open Curses defines no error conditions.
223.PP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530224In this implementation
micky3879b9f5e72025-07-08 18:04:53 -0400225.RS 3
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530226.TP 5
micky3879b9f5e72025-07-08 18:04:53 -0400227\fBslk_attr\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530228returns the attribute used for the soft keys.
229.TP 5
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530230\fBslk_attroff\fP, \fBslk_attron\fP, \fBslk_clear\fP, \fBslk_noutrefresh\fP, \fBslk_refresh\fP, \fBslk_touch\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530231return an error
232if the terminal or the softkeys were not initialized.
233.TP 5
234\fBslk_attrset\fP
235returns an error
236if the terminal or the softkeys were not initialized.
237.TP 5
238\fBslk_attr_set\fP
239returns an error
240if the terminal or the softkeys were not initialized, or
micky3879b9f5e72025-07-08 18:04:53 -0400241the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530242.TP 5
243\fBslk_color\fP
244returns an error
245if the terminal or the softkeys were not initialized, or
micky3879b9f5e72025-07-08 18:04:53 -0400246the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530247.TP 5
micky3879b9f5e72025-07-08 18:04:53 -0400248\fBslk_init\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530249returns an error
250if the format parameter is outside the range 0..3.
251.TP 5
micky3879b9f5e72025-07-08 18:04:53 -0400252\fBslk_label\fP
253returns \fBNULL\fP on error.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530254.TP 5
255\fBslk_set\fP
256returns an error
257if the terminal or the softkeys were not initialized, or
258the \fIlabnum\fP parameter is outside the range of label counts, or
259if the format parameter is outside the range 0..2, or if
260memory for the labels cannot be allocated.
261.RE
262.SH NOTES
micky3879b9f5e72025-07-08 18:04:53 -0400263Most applications would use \fB\%slk_noutrefresh\fP because a
264\fB\%wrefresh\fP is likely to follow soon.
265.SH EXTENSIONS
266X/Open Curses documents the \fIopts\fP argument
267as reserved for future use,
268saying that it must be null.
269This implementation
270uses that parameter in ABI 6 for the functions which have a color pair
271parameter to support extended color pairs.
272.PP
273For functions which modify the color,
274e.g.,
275\fB\%slk_attr_set\fP,
276if \fIopts\fP is set it is treated as a pointer to \fIint\fP,
277and used to set the color pair instead of the \fIshort\fP pair
278parameter.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530279.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400280X/Open Curses,
281Issue 4 describes these functions,
282with some differences from SVr4 \fIcurses\fP:
283.bP
284X/Open added functions like the SVr4 attribute-manipulation functions
285\fB\%slk_attron\fP,
286\fB\%slk_attroff\fP,
287and
288\fB\%slk_attrset\fP,
289but which use \fI\%attr_t\fP parameters
290(rather than \fI\%chtype\fP),
291along with a reserved \fIopts\fP parameter.
292.IP
293Two of these new functions
294(unlike the SVr4 functions)
295have no provision for color:
296\fB\%slk_attr_on\fP and \fB\%slk_attr_off\fP.
297.IP
298The third function \%(\fBslk_attr_set\fP) has a color pair parameter.
299.bP
300It added \fIconst\fP qualifiers to parameters (unnecessarily),
301and
302.bP
303It added \fB\%slk_color\fP.
304.PP
305Although \fB\%slk_start\fP is declared in the \fIcurses\fP header file,
306it was not documented by SVr4 other than its presence in a list
307of libtermlib.so.1 symbols.
308Reading the source code (i.e., Illumos):
309.bP
310\fB\%slk_start\fP has two parameters:
311.RS
312.bP
313\fIng\fP (number of groups) and
314.bP
315\fIgp\fP (group pointer).
316.RE
317.bP
318Soft-key groups are an array of \fIng\fP integers.
319.bP
320In SVr4, \fB\%slk_init\fP calls \fB\%slk_start\fP passing a null for \fIgp\fP.
321For this case, \fB\%slk_start\fP uses the number of groups \fIng\fP
322(3 for the 3-2-3 layout, 2 for the 4-4 layout) which \fB\%slk_init\fP provided.
323.IP
324If \fIng\fP is neither 2 or 3,
325\fB\%slk_start\fP checks the terminfo \fBfln\fP (label_format) capability,
326interpreting that as a comma-separated list of numbers,
327e.g., \*(``3,2,3\*('' for the 3-2-3 layout.
328.IP
329Finally, if there is no \fBfln\fP capability,
330\fB\%slk_start\fP returns \fBERR\fP.
331.bP
332If \fB\%slk_start\fP is given a non-null \fIgp\fP,
333it copies the \fIng\fP elements of the group of soft-keys, up to 16.
334.IP
335If there are more than 16 elements, \fB\%slk_start\fP returns an error.
336.bP
337The format codes \fB2\fP and \fB3\fP for \fB\%slk_init\fP
338were added by \fI\%ncurses\fP in 1996.
339PDCurses 2.4 added this feature in 2001.
340.PP
341The function \fB\%slk_attr\fP was added by \fI\%ncurses\fP in 1996.
342.PP
343X/Open Curses does not specify a limit for the number of colors and
344color pairs which a terminal can support.
345However, in its use of \fIshort\fP for the parameters,
346it carries over SVr4's implementation detail for the compiled
347terminfo database, which uses signed 16-bit numbers.
348This implementation provides extended versions of those functions
349which use \fIint\fP parameters,
350allowing applications to use larger color- and pair-numbers.
351.SH HISTORY
352SVr3 introduced these functions:
353 \fBslk_clear\fP
354 \fBslk_init\fP
355 \fBslk_label\fP
356 \fBslk_noutrefresh\fP
357 \fBslk_refresh\fP
358 \fBslk_restore\fP
359 \fBslk_set\fP
360 \fBslk_touch\fP
361.PP
362SVr4 added these functions:
363 \fBslk_attroff\fP
364 \fBslk_attron\fP
365 \fBslk_attrset\fP
366 \fBslk_start\fP
367.PP
368X/Open Curses added these:
369 \fBslk_attr_off\fP
370 \fBslk_attr_on\fP
371 \fBslk_attr_set\fP
372 \fBslk_color\fP
373 \fBslk_wset\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530374.SH SEE ALSO
micky3879b9f5e72025-07-08 18:04:53 -0400375\fB\%curses\fP(3X),
376\fB\%curs_attr\fP(3X),
377\fB\%curs_initscr\fP(3X),
378\fB\%curs_refresh\fP(3X),
379\fB\%curs_variables\fP(3X)