1 /****************************************************************************
2 * Copyright 2020 Thomas E. Dickey *
3 * Copyright 1998-2013,2014 Free Software Foundation, Inc. *
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: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
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. *
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 *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
32 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
33 * and: Juergen Pfeifer 1996-on *
34 * and: Thomas E. Dickey *
35 ****************************************************************************/
39 * Write SLK window to the (virtual) screen.
41 #include <curses.priv.h>
44 #define CUR SP_TERMTYPE
47 MODULE_ID("$Id: lib_slkrefr.c,v 1.31 2020/02/02 23:34:34 tom Exp $")
49 #ifdef USE_TERM_DRIVER
50 #define NumLabels InfoOf(SP_PARM).numlabels
52 #define NumLabels num_labels
56 * Paint the info line for the PC style SLK emulation.
59 slk_paint_info(WINDOW *win)
61 SCREEN *sp = _nc_screen_of(win);
63 if (win && sp && (sp->slk_format == 4)) {
66 (void) mvwhline(win, 0, 0, 0, getmaxx(win));
69 for (i = 0; i < sp->_slk->maxlab; i++) {
70 mvwprintw(win, 0, sp->_slk->ent[i].ent_x, "F%d", i + 1);
76 * Write the soft labels to the soft-key window.
79 slk_intern_refresh(SCREEN *sp)
96 for (i = 0; i < slk->labcnt; i++) {
97 if (slk->dirty || slk->ent[i].dirty) {
98 if (slk->ent[i].visible) {
99 if (numlab > 0 && SLK_STDFMT(fmt)) {
100 #ifdef USE_TERM_DRIVER
101 CallDriver_2(sp, td_hwlabel, i + 1, slk->ent[i].form_text);
103 if (i < num_labels) {
104 NCURSES_PUTP2("plab_norm",
107 slk->ent[i].form_text));
112 slk_paint_info(slk->win);
113 wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
114 (void) wattrset(slk->win, (int) AttrOf(slk->attr));
115 waddstr(slk->win, slk->ent[i].form_text);
116 /* if we simulate SLK's, it's looking much more
117 natural to use the current ATTRIBUTE also
118 for the label window */
119 (void) wattrset(slk->win, (int) WINDOW_ATTRS(StdScreen(sp)));
122 slk->ent[i].dirty = FALSE;
128 #ifdef USE_TERM_DRIVER
129 CallDriver_1(sp, td_hwlabelOnOff, slk->hidden ? FALSE : TRUE);
132 NCURSES_PUTP2("label_off", label_off);
134 NCURSES_PUTP2("label_on", label_on);
141 * Refresh the soft labels.
144 NCURSES_SP_NAME(slk_noutrefresh) (NCURSES_SP_DCL0)
146 T((T_CALLED("slk_noutrefresh(%p)"), (void *) SP_PARM));
148 if (SP_PARM == 0 || SP_PARM->_slk == 0)
150 if (SP_PARM->_slk->hidden)
152 slk_intern_refresh(SP_PARM);
154 returnCode(wnoutrefresh(SP_PARM->_slk->win));
159 slk_noutrefresh(void)
161 return NCURSES_SP_NAME(slk_noutrefresh) (CURRENT_SCREEN);
166 * Refresh the soft labels.
169 NCURSES_SP_NAME(slk_refresh) (NCURSES_SP_DCL0)
171 T((T_CALLED("slk_refresh(%p)"), (void *) SP_PARM));
173 if (SP_PARM == 0 || SP_PARM->_slk == 0)
175 if (SP_PARM->_slk->hidden)
177 slk_intern_refresh(SP_PARM);
179 returnCode(wrefresh(SP_PARM->_slk->win));
186 return NCURSES_SP_NAME(slk_refresh) (CURRENT_SCREEN);