1 |
|
|
/* $OpenBSD: lib_slkrefr.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */ |
2 |
|
|
|
3 |
|
|
/**************************************************************************** |
4 |
|
|
* Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * |
5 |
|
|
* * |
6 |
|
|
* Permission is hereby granted, free of charge, to any person obtaining a * |
7 |
|
|
* copy of this software and associated documentation files (the * |
8 |
|
|
* "Software"), to deal in the Software without restriction, including * |
9 |
|
|
* without limitation the rights to use, copy, modify, merge, publish, * |
10 |
|
|
* distribute, distribute with modifications, sublicense, and/or sell * |
11 |
|
|
* copies of the Software, and to permit persons to whom the Software is * |
12 |
|
|
* furnished to do so, subject to the following conditions: * |
13 |
|
|
* * |
14 |
|
|
* The above copyright notice and this permission notice shall be included * |
15 |
|
|
* in all copies or substantial portions of the Software. * |
16 |
|
|
* * |
17 |
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
18 |
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
19 |
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
20 |
|
|
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
21 |
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
22 |
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
23 |
|
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
24 |
|
|
* * |
25 |
|
|
* Except as contained in this notice, the name(s) of the above copyright * |
26 |
|
|
* holders shall not be used in advertising or otherwise to promote the * |
27 |
|
|
* sale, use or other dealings in this Software without prior written * |
28 |
|
|
* authorization. * |
29 |
|
|
****************************************************************************/ |
30 |
|
|
|
31 |
|
|
/**************************************************************************** |
32 |
|
|
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * |
33 |
|
|
* and: Eric S. Raymond <esr@snark.thyrsus.com> * |
34 |
|
|
* and: Juergen Pfeifer 1996-on * |
35 |
|
|
* and: Thomas E. Dickey * |
36 |
|
|
****************************************************************************/ |
37 |
|
|
|
38 |
|
|
/* |
39 |
|
|
* lib_slkrefr.c |
40 |
|
|
* Write SLK window to the (virtual) screen. |
41 |
|
|
*/ |
42 |
|
|
#include <curses.priv.h> |
43 |
|
|
#include <term.h> /* num_labels, label_*, plab_norm */ |
44 |
|
|
|
45 |
|
|
MODULE_ID("$Id: lib_slkrefr.c,v 1.5 2010/01/12 23:22:06 nicm Exp $") |
46 |
|
|
|
47 |
|
|
/* |
48 |
|
|
* Paint the info line for the PC style SLK emulation. |
49 |
|
|
*/ |
50 |
|
|
static void |
51 |
|
|
slk_paint_info(WINDOW *win) |
52 |
|
|
{ |
53 |
|
|
SCREEN *sp = _nc_screen_of(win); |
54 |
|
|
|
55 |
|
|
if (win && sp && (sp->slk_format == 4)) { |
56 |
|
|
int i; |
57 |
|
|
|
58 |
|
|
mvwhline(win, 0, 0, 0, getmaxx(win)); |
59 |
|
|
wmove(win, 0, 0); |
60 |
|
|
|
61 |
|
|
for (i = 0; i < sp->_slk->maxlab; i++) { |
62 |
|
|
mvwprintw(win, 0, sp->_slk->ent[i].ent_x, "F%d", i + 1); |
63 |
|
|
} |
64 |
|
|
} |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
/* |
68 |
|
|
* Write the soft labels to the soft-key window. |
69 |
|
|
*/ |
70 |
|
|
static void |
71 |
|
|
slk_intern_refresh(SLK * slk) |
72 |
|
|
{ |
73 |
|
|
int i; |
74 |
|
|
int fmt = SP->slk_format; |
75 |
|
|
|
76 |
|
|
for (i = 0; i < slk->labcnt; i++) { |
77 |
|
|
if (slk->dirty || slk->ent[i].dirty) { |
78 |
|
|
if (slk->ent[i].visible) { |
79 |
|
|
if (num_labels > 0 && SLK_STDFMT(fmt)) { |
80 |
|
|
if (i < num_labels) { |
81 |
|
|
TPUTS_TRACE("plab_norm"); |
82 |
|
|
putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text)); |
83 |
|
|
} |
84 |
|
|
} else { |
85 |
|
|
if (fmt == 4) |
86 |
|
|
slk_paint_info(slk->win); |
87 |
|
|
wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x); |
88 |
|
|
if (SP->_slk) { |
89 |
|
|
wattrset(slk->win, AttrOf(SP->_slk->attr)); |
90 |
|
|
} |
91 |
|
|
waddstr(slk->win, slk->ent[i].form_text); |
92 |
|
|
/* if we simulate SLK's, it's looking much more |
93 |
|
|
natural to use the current ATTRIBUTE also |
94 |
|
|
for the label window */ |
95 |
|
|
wattrset(slk->win, WINDOW_ATTRS(stdscr)); |
96 |
|
|
} |
97 |
|
|
} |
98 |
|
|
slk->ent[i].dirty = FALSE; |
99 |
|
|
} |
100 |
|
|
} |
101 |
|
|
slk->dirty = FALSE; |
102 |
|
|
|
103 |
|
|
if (num_labels > 0) { |
104 |
|
|
if (slk->hidden) { |
105 |
|
|
TPUTS_TRACE("label_off"); |
106 |
|
|
putp(label_off); |
107 |
|
|
} else { |
108 |
|
|
TPUTS_TRACE("label_on"); |
109 |
|
|
putp(label_on); |
110 |
|
|
} |
111 |
|
|
} |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
/* |
115 |
|
|
* Refresh the soft labels. |
116 |
|
|
*/ |
117 |
|
|
NCURSES_EXPORT(int) |
118 |
|
|
slk_noutrefresh(void) |
119 |
|
|
{ |
120 |
|
|
T((T_CALLED("slk_noutrefresh()"))); |
121 |
|
|
|
122 |
|
|
if (SP == NULL || SP->_slk == NULL) |
123 |
|
|
returnCode(ERR); |
124 |
|
|
if (SP->_slk->hidden) |
125 |
|
|
returnCode(OK); |
126 |
|
|
slk_intern_refresh(SP->_slk); |
127 |
|
|
|
128 |
|
|
returnCode(wnoutrefresh(SP->_slk->win)); |
129 |
|
|
} |
130 |
|
|
|
131 |
|
|
/* |
132 |
|
|
* Refresh the soft labels. |
133 |
|
|
*/ |
134 |
|
|
NCURSES_EXPORT(int) |
135 |
|
|
slk_refresh(void) |
136 |
|
|
{ |
137 |
|
|
T((T_CALLED("slk_refresh()"))); |
138 |
|
|
|
139 |
|
|
if (SP == NULL || SP->_slk == NULL) |
140 |
|
|
returnCode(ERR); |
141 |
|
|
if (SP->_slk->hidden) |
142 |
|
|
returnCode(OK); |
143 |
|
|
slk_intern_refresh(SP->_slk); |
144 |
|
|
|
145 |
|
|
returnCode(wrefresh(SP->_slk->win)); |
146 |
|
|
} |