Deleted Added
full compact
lib_slk.c (166124) lib_slk.c (176187)
1/****************************************************************************
1/****************************************************************************
2 * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
2 * Copyright (c) 1998-2005,2008 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: *

--- 29 unchanged lines hidden (view full) ---

40 * Soft key routines.
41 */
42
43#include <curses.priv.h>
44
45#include <ctype.h>
46#include <term.h> /* num_labels, label_*, plab_norm */
47
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: *

--- 29 unchanged lines hidden (view full) ---

40 * Soft key routines.
41 */
42
43#include <curses.priv.h>
44
45#include <ctype.h>
46#include <term.h> /* num_labels, label_*, plab_norm */
47
48MODULE_ID("$Id: lib_slk.c,v 1.30 2005/01/08 21:56:36 tom Exp $")
48MODULE_ID("$Id: lib_slk.c,v 1.31 2008/01/12 20:21:00 tom Exp $")
49
50/*
51 * We'd like to move these into the screen context structure, but cannot,
52 * because slk_init() is called before initscr()/newterm().
53 */
54NCURSES_EXPORT_VAR(int)
55_nc_slk_format = 0; /* one more than format specified in slk_init() */
56
57/*
58 * Paint the info line for the PC style SLK emulation.
49
50/*
51 * We'd like to move these into the screen context structure, but cannot,
52 * because slk_init() is called before initscr()/newterm().
53 */
54NCURSES_EXPORT_VAR(int)
55_nc_slk_format = 0; /* one more than format specified in slk_init() */
56
57/*
58 * Paint the info line for the PC style SLK emulation.
59 *
60 */
61static void
62slk_paint_info(WINDOW *win)
63{
64 if (win && SP->slk_format == 4) {
65 int i;
66
67 mvwhline(win, 0, 0, 0, getmaxx(win));

--- 46 unchanged lines hidden (view full) ---

114 */
115 if ((no_color_video & 1) == 0)
116 SetAttr(SP->_slk->attr, A_STANDOUT);
117 else
118 SetAttr(SP->_slk->attr, A_REVERSE);
119
120 SP->_slk->maxlab = ((num_labels > 0)
121 ? num_labels
59 */
60static void
61slk_paint_info(WINDOW *win)
62{
63 if (win && SP->slk_format == 4) {
64 int i;
65
66 mvwhline(win, 0, 0, 0, getmaxx(win));

--- 46 unchanged lines hidden (view full) ---

113 */
114 if ((no_color_video & 1) == 0)
115 SetAttr(SP->_slk->attr, A_STANDOUT);
116 else
117 SetAttr(SP->_slk->attr, A_REVERSE);
118
119 SP->_slk->maxlab = ((num_labels > 0)
120 ? num_labels
122 : MAX_SKEY(_nc_slk_format));
121 : MAX_SKEY(_nc_globals.slk_format));
123 SP->_slk->maxlen = ((num_labels > 0)
124 ? label_width * label_height
122 SP->_slk->maxlen = ((num_labels > 0)
123 ? label_width * label_height
125 : MAX_SKEY_LEN(_nc_slk_format));
126 SP->_slk->labcnt = ((SP->_slk->maxlab < MAX_SKEY(_nc_slk_format))
127 ? MAX_SKEY(_nc_slk_format)
124 : MAX_SKEY_LEN(_nc_globals.slk_format));
125 SP->_slk->labcnt = ((SP->_slk->maxlab < MAX_SKEY(_nc_globals.slk_format))
126 ? MAX_SKEY(_nc_globals.slk_format)
128 : SP->_slk->maxlab);
129
130 if (SP->_slk->maxlen <= 0
131 || SP->_slk->labcnt <= 0
132 || (SP->_slk->ent = typeCalloc(slk_ent,
133 (unsigned) SP->_slk->labcnt)) == NULL)
134 returnCode(slk_failed());
135

--- 7 unchanged lines hidden (view full) ---

143
144 if ((SP->_slk->ent[i].form_text = (char *) _nc_doalloc(0, used)) == 0)
145 returnCode(slk_failed());
146 memset(SP->_slk->ent[i].form_text, 0, used);
147
148 memset(SP->_slk->ent[i].form_text, ' ', max_length);
149 SP->_slk->ent[i].visible = (i < SP->_slk->maxlab);
150 }
127 : SP->_slk->maxlab);
128
129 if (SP->_slk->maxlen <= 0
130 || SP->_slk->labcnt <= 0
131 || (SP->_slk->ent = typeCalloc(slk_ent,
132 (unsigned) SP->_slk->labcnt)) == NULL)
133 returnCode(slk_failed());
134

--- 7 unchanged lines hidden (view full) ---

142
143 if ((SP->_slk->ent[i].form_text = (char *) _nc_doalloc(0, used)) == 0)
144 returnCode(slk_failed());
145 memset(SP->_slk->ent[i].form_text, 0, used);
146
147 memset(SP->_slk->ent[i].form_text, ' ', max_length);
148 SP->_slk->ent[i].visible = (i < SP->_slk->maxlab);
149 }
151 if (_nc_slk_format >= 3) { /* PC style */
150 if (_nc_globals.slk_format >= 3) { /* PC style */
152 int gap = (cols - 3 * (3 + 4 * max_length)) / 2;
153
154 if (gap < 1)
155 gap = 1;
156
157 for (i = x = 0; i < SP->_slk->maxlab; i++) {
158 SP->_slk->ent[i].ent_x = x;
159 x += max_length;
160 x += (i == 3 || i == 7) ? gap : 1;
161 }
162 slk_paint_info(stwin);
163 } else {
151 int gap = (cols - 3 * (3 + 4 * max_length)) / 2;
152
153 if (gap < 1)
154 gap = 1;
155
156 for (i = x = 0; i < SP->_slk->maxlab; i++) {
157 SP->_slk->ent[i].ent_x = x;
158 x += max_length;
159 x += (i == 3 || i == 7) ? gap : 1;
160 }
161 slk_paint_info(stwin);
162 } else {
164 if (_nc_slk_format == 2) { /* 4-4 */
163 if (_nc_globals.slk_format == 2) { /* 4-4 */
165 int gap = cols - (SP->_slk->maxlab * max_length) - 6;
166
167 if (gap < 1)
168 gap = 1;
169 for (i = x = 0; i < SP->_slk->maxlab; i++) {
170 SP->_slk->ent[i].ent_x = x;
171 x += max_length;
172 x += (i == 3) ? gap : 1;
173 }
174 } else {
164 int gap = cols - (SP->_slk->maxlab * max_length) - 6;
165
166 if (gap < 1)
167 gap = 1;
168 for (i = x = 0; i < SP->_slk->maxlab; i++) {
169 SP->_slk->ent[i].ent_x = x;
170 x += max_length;
171 x += (i == 3) ? gap : 1;
172 }
173 } else {
175 if (_nc_slk_format == 1) { /* 1 -> 3-2-3 */
174 if (_nc_globals.slk_format == 1) { /* 1 -> 3-2-3 */
176 int gap = (cols - (SP->_slk->maxlab * max_length) - 5)
177 / 2;
178
179 if (gap < 1)
180 gap = 1;
181 for (i = x = 0; i < SP->_slk->maxlab; i++) {
182 SP->_slk->ent[i].ent_x = x;
183 x += max_length;

--- 7 unchanged lines hidden (view full) ---

191 if ((SP->_slk->win = stwin) == NULL) {
192 returnCode(slk_failed());
193 }
194
195 /* We now reset the format so that the next newterm has again
196 * per default no SLK keys and may call slk_init again to
197 * define a new layout. (juergen 03-Mar-1999)
198 */
175 int gap = (cols - (SP->_slk->maxlab * max_length) - 5)
176 / 2;
177
178 if (gap < 1)
179 gap = 1;
180 for (i = x = 0; i < SP->_slk->maxlab; i++) {
181 SP->_slk->ent[i].ent_x = x;
182 x += max_length;

--- 7 unchanged lines hidden (view full) ---

190 if ((SP->_slk->win = stwin) == NULL) {
191 returnCode(slk_failed());
192 }
193
194 /* We now reset the format so that the next newterm has again
195 * per default no SLK keys and may call slk_init again to
196 * define a new layout. (juergen 03-Mar-1999)
197 */
199 SP->slk_format = _nc_slk_format;
200 _nc_slk_format = 0;
198 SP->slk_format = _nc_globals.slk_format;
199 _nc_globals.slk_format = 0;
201 returnCode(res);
202}
203
204/*
205 * Restore the soft labels on the screen.
206 */
207NCURSES_EXPORT(int)
208slk_restore(void)

--- 12 unchanged lines hidden ---
200 returnCode(res);
201}
202
203/*
204 * Restore the soft labels on the screen.
205 */
206NCURSES_EXPORT(int)
207slk_restore(void)

--- 12 unchanged lines hidden ---