| 9212 |
ripley |
1 |
/*
|
|
|
2 |
* R : A Computer Language for Statistical Data Analysis
|
|
|
3 |
* file preferences.c
|
| 64657 |
ripley |
4 |
* Copyright (C) 2000 Guido Masarotto and Brian Ripley
|
| 86636 |
kalibera |
5 |
* 2004-2024 R Core Team
|
| 9212 |
ripley |
6 |
*
|
|
|
7 |
* This program is free software; you can redistribute it and/or modify
|
|
|
8 |
* it under the terms of the GNU General Public License as published by
|
|
|
9 |
* the Free Software Foundation; either version 2 of the License, or
|
|
|
10 |
* (at your option) any later version.
|
|
|
11 |
*
|
|
|
12 |
* This program is distributed in the hope that it will be useful,
|
|
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
15 |
* GNU General Public License for more details.
|
|
|
16 |
*
|
|
|
17 |
* You should have received a copy of the GNU General Public License
|
| 42300 |
ripley |
18 |
* along with this program; if not, a copy is available at
|
| 68956 |
ripley |
19 |
* https://www.R-project.org/Licenses/
|
| 9212 |
ripley |
20 |
*/
|
| 42300 |
ripley |
21 |
|
| 9212 |
ripley |
22 |
#ifdef HAVE_CONFIG_H
|
|
|
23 |
#include <config.h>
|
|
|
24 |
#endif
|
|
|
25 |
|
| 32888 |
ripley |
26 |
#include "win-nls.h"
|
|
|
27 |
|
| 9212 |
ripley |
28 |
#ifdef Win32
|
|
|
29 |
#define USE_MDI 1
|
|
|
30 |
#endif
|
|
|
31 |
|
| 36901 |
ripley |
32 |
#define WIN32_LEAN_AND_MEAN 1
|
| 9212 |
ripley |
33 |
#include <windows.h>
|
|
|
34 |
#include <ctype.h> /* isspace */
|
|
|
35 |
#include "graphapp/ga.h"
|
| 28991 |
murdoch |
36 |
#include "graphapp/graphapp.h"
|
| 37592 |
murdoch |
37 |
#include "opt.h"
|
| 9212 |
ripley |
38 |
#include "console.h"
|
|
|
39 |
#include "consolestructs.h"
|
|
|
40 |
#include "rui.h"
|
| 37592 |
murdoch |
41 |
#include "preferences.h"
|
| 40717 |
ripley |
42 |
#include <Fileio.h>
|
| 46842 |
ripley |
43 |
void R_fixbackslash(char *s);
|
| 9212 |
ripley |
44 |
|
| 39274 |
ripley |
45 |
#define gettext GA_gettext
|
|
|
46 |
|
| 49486 |
murdoch |
47 |
extern char fontname[LF_FACESIZE+4]; /* from console.c */
|
| 24577 |
ripley |
48 |
extern int consolex, consoley; /* from console.c */
|
| 9212 |
ripley |
49 |
extern int pagerMultiple, haveusedapager; /* from pager.c */
|
| 28991 |
murdoch |
50 |
void editorsetfont(font f);
|
| 9212 |
ripley |
51 |
|
| 37592 |
murdoch |
52 |
static void showDialog(Gui gui);
|
| 9212 |
ripley |
53 |
|
| 42529 |
ripley |
54 |
extern __declspec(dllimport) const char *ColorName[]; /* from graphapp/rgb.c */
|
| 9212 |
ripley |
55 |
|
| 43800 |
ripley |
56 |
static int cmatch(const char *col, const char **list)
|
| 9212 |
ripley |
57 |
{
|
|
|
58 |
int i=0;
|
| 41794 |
ripley |
59 |
const char **pos = list;
|
| 9212 |
ripley |
60 |
while(*pos != NULL) {
|
|
|
61 |
if(strcmpi(*pos, col) == 0) return(i);
|
|
|
62 |
i++; pos++;
|
|
|
63 |
}
|
|
|
64 |
return(-1);
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
|
| 41793 |
ripley |
68 |
static const char *StyleList[] = {"normal", "bold", "italic", NULL};
|
|
|
69 |
static const char *PointsList[] = {"6", "7", "8", "9", "10", "11", "12", "14", "16", "18", "20", "22", "24", "26", "28", "32", "36", NULL};
|
| 44984 |
ripley |
70 |
static const char *FontsList[] = {"Courier", "Courier New", "FixedSys", "FixedFont", "Lucida Console", "Consolas", "Terminal", "BatangChe", "DotumChe", "GulimChe", "MingLiU", "MS Gothic", "MS Mincho", "NSimSun", NULL};
|
| 46784 |
murdoch |
71 |
static const char *GuiElementNames[numGuiColors+1] = {"background", "normaltext", "usertext",
|
|
|
72 |
"pagerbg", "pagertext", "highlight",
|
|
|
73 |
"dataeditbg", "dataedittext", "dataedituser",
|
| 86636 |
kalibera |
74 |
"editorbg", "editortext", "dataeditnbg", NULL};
|
| 51948 |
murdoch |
75 |
static const char *BlinkList[] = {"None", "Partial", "Full"};
|
| 9212 |
ripley |
76 |
static window wconfig;
|
| 37592 |
murdoch |
77 |
static button bApply, bSave, bLoad, bOK, bCancel;
|
| 37744 |
ripley |
78 |
static label l_mdi, l_mwin, l_font, l_point, l_style, l_lang, l_crows, l_ccols,
|
| 24606 |
ripley |
79 |
l_cx, l_cy, l_prows, l_pcols, l_grx, l_gry,
|
| 51948 |
murdoch |
80 |
l_cols, l_cbb, l_cbl, l_blink;
|
| 36461 |
murdoch |
81 |
static radiogroup g_mwin;
|
| 9212 |
ripley |
82 |
static radiobutton rb_mdi, rb_sdi, rb_mwin, rb_swin;
|
| 46784 |
murdoch |
83 |
static listbox f_font, f_style, d_point, guielement, guicolor;
|
| 37860 |
ripley |
84 |
static checkbox toolbar, statusbar, tt_font, c_resize, c_buff;
|
| 24606 |
ripley |
85 |
static field f_crows, f_ccols, f_prows, f_pcols, f_cx, f_cy, f_cbb,f_cbl,
|
| 51948 |
murdoch |
86 |
f_grx, f_gry, f_lang, f_blink;
|
| 46784 |
murdoch |
87 |
static textbox guisample;
|
|
|
88 |
static font samplefont = NULL;
|
|
|
89 |
static int samplePointsize = 10;
|
|
|
90 |
static int sampleStyle = Plain;
|
|
|
91 |
static int sampleFontNum;
|
| 9212 |
ripley |
92 |
|
| 46784 |
murdoch |
93 |
static rgb dialogColors[numGuiColors];
|
| 9212 |
ripley |
94 |
|
| 37592 |
murdoch |
95 |
static void getChoices(Gui p)
|
| 9212 |
ripley |
96 |
{
|
|
|
97 |
p->MDI = ischecked(rb_mdi);
|
|
|
98 |
p->toolbar = ischecked(toolbar);
|
|
|
99 |
p->statusbar = ischecked(statusbar);
|
|
|
100 |
p->pagerMultiple = ischecked(rb_mwin);
|
| 74680 |
kalibera |
101 |
strncpy(p->language, gettext(f_lang), sizeof(p->language)-1);
|
|
|
102 |
p->language[sizeof(p->language)-1] = '\0';
|
|
|
103 |
strncpy(p->font, gettext(f_font), sizeof(p->font)-1);
|
|
|
104 |
p->font[sizeof(p->font)-1] = '\0';
|
| 9212 |
ripley |
105 |
p->tt_font = ischecked(tt_font);
|
|
|
106 |
p->pointsize = atoi(gettext(d_point));
|
| 74680 |
kalibera |
107 |
strncpy(p->style, gettext(f_style), sizeof(p->style)-1);
|
|
|
108 |
p->style[sizeof(p->style)-1] = '\0';
|
| 9212 |
ripley |
109 |
p->crows = atoi(gettext(f_crows));
|
|
|
110 |
p->ccols = atoi(gettext(f_ccols));
|
| 24577 |
ripley |
111 |
p->cx = atoi(gettext(f_cx));
|
|
|
112 |
p->cy = atoi(gettext(f_cy));
|
| 9212 |
ripley |
113 |
p->setWidthOnResize = ischecked(c_resize);
|
| 37860 |
ripley |
114 |
p->buffered = ischecked(c_buff);
|
| 11595 |
ripley |
115 |
p->cbb = atoi(gettext(f_cbb));
|
|
|
116 |
p->cbl = atoi(gettext(f_cbl));
|
| 9212 |
ripley |
117 |
p->prows = atoi(gettext(f_prows));
|
|
|
118 |
p->pcols = atoi(gettext(f_pcols));
|
| 24606 |
ripley |
119 |
p->grx = atoi(gettext(f_grx));
|
|
|
120 |
p->gry = atoi(gettext(f_gry));
|
| 51948 |
murdoch |
121 |
p->cursor_blink = getlistitem(f_blink);
|
| 46784 |
murdoch |
122 |
dialogColors[cmatch(gettext(guielement),GuiElementNames)] = nametorgb(gettext(guicolor));
|
|
|
123 |
for (int i=0; i<numGuiColors; i++)
|
|
|
124 |
p->guiColors[i] = dialogColors[i];
|
| 37592 |
murdoch |
125 |
/* MDIsize is not currently a choice in the dialog, only in the Rconsole file */
|
| 53863 |
murdoch |
126 |
p->warning[0] = 0;
|
| 9212 |
ripley |
127 |
}
|
|
|
128 |
|
| 43958 |
murdoch |
129 |
void getDefaults(Gui gui)
|
| 37592 |
murdoch |
130 |
{
|
| 43958 |
murdoch |
131 |
gui->crows = 25;
|
|
|
132 |
gui->ccols = 80;
|
|
|
133 |
gui->cx = gui->cy = 0;
|
|
|
134 |
gui->grx = Rwin_graphicsx;
|
|
|
135 |
gui->gry = Rwin_graphicsy;
|
| 51948 |
murdoch |
136 |
gui->cursor_blink = 1; /* partial */
|
| 46784 |
murdoch |
137 |
gui->guiColors[consolebg] = White;
|
|
|
138 |
gui->guiColors[consolefg] = DarkBlue;
|
|
|
139 |
gui->guiColors[consoleuser] = gaRed;
|
|
|
140 |
gui->guiColors[pagerbg] = White;
|
|
|
141 |
gui->guiColors[pagerfg] = DarkBlue;
|
|
|
142 |
gui->guiColors[pagerhighlight] = DarkRed;
|
|
|
143 |
gui->guiColors[dataeditbg] = White;
|
|
|
144 |
gui->guiColors[dataeditfg] = DarkBlue;
|
|
|
145 |
gui->guiColors[dataedituser] = gaRed;
|
|
|
146 |
gui->guiColors[editorbg] = White;
|
|
|
147 |
gui->guiColors[editorfg] = Black;
|
| 86636 |
kalibera |
148 |
gui->guiColors[dataeditnbg] = White;
|
| 43958 |
murdoch |
149 |
gui->prows = 25;
|
|
|
150 |
gui->pcols = 80;
|
|
|
151 |
gui->pagerMultiple = 0;
|
|
|
152 |
gui->cbb = 65000;
|
|
|
153 |
gui->cbl = 8000;
|
|
|
154 |
gui->setWidthOnResize = 1;
|
|
|
155 |
strcpy(gui->font, "Courier New");
|
|
|
156 |
strcpy(gui->style, "normal");
|
|
|
157 |
gui->tt_font = 1;
|
|
|
158 |
gui->pointsize = 10;
|
|
|
159 |
strcpy(gui->language, "");
|
|
|
160 |
gui->buffered = 1;
|
| 52072 |
murdoch |
161 |
gui->warning[0] = 0;
|
| 45070 |
ripley |
162 |
|
| 43958 |
murdoch |
163 |
#ifdef USE_MDI
|
| 37592 |
murdoch |
164 |
gui->toolbar = ((RguiMDI & RW_TOOLBAR) != 0);
|
|
|
165 |
gui->statusbar = ((RguiMDI & RW_STATUSBAR) != 0);
|
|
|
166 |
gui->MDI = ((RguiMDI & RW_MDI) != 0);
|
| 45070 |
ripley |
167 |
|
| 43958 |
murdoch |
168 |
gui->MDIsize = rect(0, 0, 0, 0);
|
|
|
169 |
#endif
|
|
|
170 |
}
|
| 37592 |
murdoch |
171 |
|
| 43958 |
murdoch |
172 |
void getActive(Gui gui)
|
|
|
173 |
{
|
|
|
174 |
rect r;
|
|
|
175 |
ConsoleData p;
|
|
|
176 |
if (RConsole && (p = (ConsoleData) getdata(RConsole))) {
|
| 37592 |
murdoch |
177 |
|
| 43958 |
murdoch |
178 |
gui->toolbar = ((RguiMDI & RW_TOOLBAR) != 0);
|
|
|
179 |
gui->statusbar = ((RguiMDI & RW_STATUSBAR) != 0);
|
|
|
180 |
gui->MDI = ((RguiMDI & RW_MDI) != 0);
|
|
|
181 |
gui->pagerMultiple = pagerMultiple;
|
|
|
182 |
{
|
|
|
183 |
const char *p = getenv("LANGUAGE");
|
| 74680 |
kalibera |
184 |
strncpy(gui->language, p ? p : "", sizeof(gui->language)-1);
|
|
|
185 |
gui->language[sizeof(gui->language)-1] = '\0';
|
| 43958 |
murdoch |
186 |
}
|
| 37592 |
murdoch |
187 |
|
| 45070 |
ripley |
188 |
/* Font, pointsize, style */
|
| 37592 |
murdoch |
189 |
|
| 43958 |
murdoch |
190 |
gui->tt_font = FALSE;
|
|
|
191 |
{
|
|
|
192 |
const char *pf;
|
|
|
193 |
if ((strlen(fontname) > 1) &&
|
|
|
194 |
(fontname[0] == 'T') && (fontname[1] == 'T')) {
|
|
|
195 |
gui->tt_font = TRUE;
|
|
|
196 |
for (pf = fontname+2; isspace(*pf) ; pf++);
|
|
|
197 |
} else pf = fontname;
|
| 74680 |
kalibera |
198 |
strncpy(gui->font, pf, sizeof(gui->font)-1);
|
|
|
199 |
gui->font[sizeof(gui->font)-1] = '\0';
|
| 43958 |
murdoch |
200 |
}
|
| 37592 |
murdoch |
201 |
|
| 43958 |
murdoch |
202 |
gui->pointsize = pointsize;
|
| 37592 |
murdoch |
203 |
|
| 43958 |
murdoch |
204 |
if (fontsty & Italic) strcpy(gui->style, "italic");
|
|
|
205 |
else if (fontsty & Bold) strcpy(gui->style, "Bold");
|
|
|
206 |
else strcpy(gui->style, "normal");
|
| 37592 |
murdoch |
207 |
|
| 45070 |
ripley |
208 |
/* Console size, set widthonresize */
|
| 43958 |
murdoch |
209 |
gui->crows = ROWS;
|
|
|
210 |
gui->ccols = COLS;
|
|
|
211 |
r = GetCurrentWinPos(RConsole);
|
|
|
212 |
gui->cx = r.x;
|
|
|
213 |
gui->cy = r.y;
|
|
|
214 |
gui->setWidthOnResize = setWidthOnResize;
|
|
|
215 |
gui->cbb = p->lbuf->dim;
|
|
|
216 |
gui->cbl = p->lbuf->ms;
|
|
|
217 |
gui->buffered = consolebuffered;
|
|
|
218 |
|
| 45070 |
ripley |
219 |
/* Pager size */
|
| 43958 |
murdoch |
220 |
gui->prows = pagerrow;
|
|
|
221 |
gui->pcols = pagercol;
|
|
|
222 |
|
| 45070 |
ripley |
223 |
/* Graphics window */
|
| 43958 |
murdoch |
224 |
gui->grx = Rwin_graphicsx;
|
|
|
225 |
gui->gry = Rwin_graphicsy;
|
|
|
226 |
|
| 51948 |
murdoch |
227 |
/* Cursor blink */
|
|
|
228 |
gui->cursor_blink = p->cursor_blink;
|
|
|
229 |
|
| 45070 |
ripley |
230 |
/* Font colours */
|
| 46784 |
murdoch |
231 |
for (int i=0; i<numGuiColors; i++)
|
|
|
232 |
gui->guiColors[i] = guiColors[i];
|
| 43958 |
murdoch |
233 |
|
| 45070 |
ripley |
234 |
/* MDIsize is not currently a choice in the dialog, only in the Rconsole file, so is not set here */
|
| 52072 |
murdoch |
235 |
gui->warning[0] = 0;
|
| 43958 |
murdoch |
236 |
} else
|
| 45070 |
ripley |
237 |
getDefaults(gui);
|
| 37592 |
murdoch |
238 |
}
|
|
|
239 |
|
|
|
240 |
static int has_changed(Gui a, Gui b)
|
| 9212 |
ripley |
241 |
{
|
| 46784 |
murdoch |
242 |
Rboolean colorchange = FALSE;
|
|
|
243 |
if (a)
|
|
|
244 |
for (int i=0; i<numGuiColors; i++)
|
|
|
245 |
colorchange |= a->guiColors[i] != b->guiColors[i];
|
|
|
246 |
|
|
|
247 |
return !a || colorchange ||
|
| 45070 |
ripley |
248 |
a->MDI != b->MDI ||
|
| 9212 |
ripley |
249 |
a->toolbar != b->toolbar ||
|
|
|
250 |
a->statusbar != b->statusbar ||
|
|
|
251 |
a->pagerMultiple != b->pagerMultiple ||
|
| 37744 |
ripley |
252 |
strcmp(a->language, b->language) ||
|
| 9212 |
ripley |
253 |
strcmp(a->font, b->font) ||
|
|
|
254 |
a->tt_font != b->tt_font ||
|
|
|
255 |
a->pointsize != b->pointsize ||
|
|
|
256 |
strcmp(a->style, b->style) ||
|
|
|
257 |
a->crows != b->crows ||
|
|
|
258 |
a->ccols != b->ccols ||
|
| 24577 |
ripley |
259 |
a->cx != b->cx ||
|
|
|
260 |
a->cy != b->cy ||
|
| 11595 |
ripley |
261 |
a->cbb != b->cbb ||
|
|
|
262 |
a->cbl != b->cbl ||
|
| 9212 |
ripley |
263 |
a->setWidthOnResize != b->setWidthOnResize ||
|
|
|
264 |
a->prows != b->prows ||
|
|
|
265 |
a->pcols != b->pcols ||
|
| 24606 |
ripley |
266 |
a->grx != b->grx ||
|
| 51948 |
murdoch |
267 |
a->gry != b->gry ||
|
|
|
268 |
a->cursor_blink != b->cursor_blink;
|
| 9212 |
ripley |
269 |
}
|
|
|
270 |
|
|
|
271 |
|
| 44201 |
ripley |
272 |
static void cleanup(void)
|
| 9212 |
ripley |
273 |
{
|
|
|
274 |
hide(wconfig);
|
| 24606 |
ripley |
275 |
delobj(l_mdi); delobj(rb_mdi); delobj(rb_sdi);
|
|
|
276 |
delobj(toolbar); delobj(statusbar);
|
| 36461 |
murdoch |
277 |
delobj(l_mwin); delobj(g_mwin); delobj(rb_mwin); delobj(rb_swin);
|
| 37744 |
ripley |
278 |
delobj(l_lang); delobj(f_lang);
|
| 24606 |
ripley |
279 |
delobj(l_font); delobj(f_font); delobj(tt_font);
|
| 9212 |
ripley |
280 |
delobj(l_point); delobj(d_point);
|
|
|
281 |
delobj(l_style); delobj(f_style);
|
|
|
282 |
delobj(l_crows); delobj(f_crows); delobj(l_ccols); delobj(f_ccols);
|
| 37860 |
ripley |
283 |
delobj(c_resize); delobj(c_buff);
|
| 24577 |
ripley |
284 |
delobj(l_cx); delobj(f_cx); delobj(l_cy); delobj(f_cy);
|
| 11595 |
ripley |
285 |
delobj(l_cbb); delobj(f_cbb); delobj(l_cbl); delobj(f_cbl);
|
| 51948 |
murdoch |
286 |
delobj(l_blink); delobj(f_blink);
|
| 9212 |
ripley |
287 |
delobj(l_prows); delobj(f_prows); delobj(l_pcols); delobj(f_pcols);
|
| 24606 |
ripley |
288 |
delobj(l_grx); delobj(f_grx); delobj(l_gry); delobj(f_gry);
|
| 9212 |
ripley |
289 |
delobj(l_cols);
|
| 46784 |
murdoch |
290 |
delobj(guielement); delobj(guicolor); delobj(guisample);
|
| 28991 |
murdoch |
291 |
delobj(bApply); delobj(bSave); delobj(bOK); delobj(bCancel);
|
| 9212 |
ripley |
292 |
delobj(wconfig);
|
|
|
293 |
}
|
|
|
294 |
|
| 37626 |
murdoch |
295 |
void applyGUI(Gui newGUI)
|
| 9212 |
ripley |
296 |
{
|
|
|
297 |
rect r = getrect(RConsole);
|
|
|
298 |
ConsoleData p = (ConsoleData) getdata(RConsole);
|
|
|
299 |
int havenewfont = 0;
|
| 37626 |
murdoch |
300 |
struct structGUI curGUI;
|
| 9212 |
ripley |
301 |
|
| 45070 |
ripley |
302 |
getActive(&curGUI);
|
|
|
303 |
|
| 37626 |
murdoch |
304 |
if(!has_changed(&curGUI, newGUI)) return;
|
| 9212 |
ripley |
305 |
|
| 37626 |
murdoch |
306 |
if(newGUI->MDI != curGUI.MDI || newGUI->toolbar != curGUI.toolbar ||
|
|
|
307 |
newGUI->statusbar != curGUI.statusbar)
|
| 33901 |
ripley |
308 |
askok(G_("The overall console properties cannot be changed\non a running console.\n\nSave the preferences and restart Rgui to apply them.\n"));
|
| 9212 |
ripley |
309 |
|
| 37744 |
ripley |
310 |
if(strcmp(newGUI->language, curGUI.language)) {
|
|
|
311 |
char *buf = malloc(50);
|
| 88761 |
kalibera |
312 |
if (!buf)
|
|
|
313 |
R_ShowMessage(G_("Not enough memory"));
|
|
|
314 |
else {
|
|
|
315 |
askok(G_("The language for menus cannot be changed on a\n running console.\n\nSave the preferences and restart Rgui to apply to menus.\n"));
|
|
|
316 |
snprintf(buf, 50, "LANGUAGE=%s", newGUI->language);
|
|
|
317 |
putenv(buf);
|
|
|
318 |
/* no free here: storage remains in use */
|
|
|
319 |
}
|
| 37744 |
ripley |
320 |
}
|
| 24606 |
ripley |
321 |
|
| 45070 |
ripley |
322 |
|
| 9212 |
ripley |
323 |
/* Set a new font? */
|
| 37626 |
murdoch |
324 |
if(strcmp(newGUI->font, curGUI.font) ||
|
|
|
325 |
newGUI->pointsize != curGUI.pointsize ||
|
|
|
326 |
strcmp(newGUI->style, curGUI.style))
|
| 9212 |
ripley |
327 |
{
|
| 24606 |
ripley |
328 |
char msg[LF_FACESIZE + 128];
|
| 9212 |
ripley |
329 |
int sty = Plain;
|
| 24606 |
ripley |
330 |
|
| 37626 |
murdoch |
331 |
if(newGUI->tt_font) strcpy(fontname, "TT "); else strcpy(fontname, "");
|
|
|
332 |
strcat(fontname, newGUI->font);
|
|
|
333 |
if (!strcmp(newGUI->style, "bold")) sty = Bold;
|
|
|
334 |
if (!strcmp(newGUI->style, "italic")) sty = Italic;
|
|
|
335 |
pointsize = newGUI->pointsize;
|
| 9212 |
ripley |
336 |
fontsty = sty;
|
| 33755 |
ripley |
337 |
|
| 9212 |
ripley |
338 |
/* Don't delete font: open pagers may be using it */
|
| 83514 |
kalibera |
339 |
/* keep in step with setconsoleoptions() in console.c */
|
| 9212 |
ripley |
340 |
if (strcmp(fontname, "FixedFont"))
|
| 83514 |
kalibera |
341 |
consolefn = gnewfont(NULL, fontname, fontsty | FixedWidth,
|
|
|
342 |
pointsize, 0.0, 1);
|
| 9212 |
ripley |
343 |
else consolefn = FixedFont;
|
|
|
344 |
if (!consolefn) {
|
| 83514 |
kalibera |
345 |
/* This is unlikely to happen: it will find some match */
|
| 62583 |
ripley |
346 |
snprintf(msg, LF_FACESIZE + 128,
|
|
|
347 |
G_("Font %s-%d-%d not found.\nUsing system fixed font"),
|
|
|
348 |
fontname, fontsty | FixedWidth, pointsize);
|
| 9212 |
ripley |
349 |
R_ShowMessage(msg);
|
|
|
350 |
consolefn = FixedFont;
|
|
|
351 |
}
|
| 33755 |
ripley |
352 |
/* if (!ghasfixedwidth(consolefn)) {
|
| 45070 |
ripley |
353 |
sprintf(msg,
|
|
|
354 |
G_("Font %s-%d-%d has variable width.\nUsing system fixed font"),
|
|
|
355 |
fontname, fontsty, pointsize);
|
|
|
356 |
R_ShowMessage(msg);
|
|
|
357 |
consolefn = FixedFont;
|
|
|
358 |
} */
|
| 9212 |
ripley |
359 |
p->f = consolefn;
|
|
|
360 |
FH = fontheight(p->f);
|
|
|
361 |
FW = fontwidth(p->f);
|
|
|
362 |
havenewfont = 1;
|
|
|
363 |
}
|
|
|
364 |
|
|
|
365 |
/* resize console, possibly with new font */
|
| 37626 |
murdoch |
366 |
if (consoler != newGUI->crows || consolec != newGUI->ccols || havenewfont) {
|
| 9212 |
ripley |
367 |
char buf[20];
|
| 37626 |
murdoch |
368 |
consoler = newGUI->crows;
|
|
|
369 |
consolec = newGUI->ccols;
|
| 9212 |
ripley |
370 |
r.width = (consolec + 1) * FW;
|
|
|
371 |
r.height = (consoler + 1) * FH;
|
|
|
372 |
resize(RConsole, r);
|
| 62583 |
ripley |
373 |
snprintf(buf, 20, "%d", ROWS); settext(f_crows, buf);
|
|
|
374 |
snprintf(buf, 20, "%d", COLS); settext(f_ccols, buf);
|
| 9212 |
ripley |
375 |
}
|
| 37626 |
murdoch |
376 |
if (p->lbuf->dim != newGUI->cbb || p->lbuf->ms != newGUI->cbl)
|
|
|
377 |
xbufgrow(p->lbuf, newGUI->cbb, newGUI->cbl);
|
| 24606 |
ripley |
378 |
|
| 9212 |
ripley |
379 |
/* Set colours and redraw */
|
| 46784 |
murdoch |
380 |
for (int i=0; i<numGuiColors; i++)
|
|
|
381 |
p->guiColors[i] = guiColors[i] = newGUI->guiColors[i];
|
| 9212 |
ripley |
382 |
drawconsole(RConsole, r);
|
| 45070 |
ripley |
383 |
if(haveusedapager &&
|
| 37626 |
murdoch |
384 |
(newGUI->prows != curGUI.prows || newGUI->pcols != curGUI.pcols))
|
| 33901 |
ripley |
385 |
askok(G_("Changes in pager size will not apply to any open pagers"));
|
| 37626 |
murdoch |
386 |
pagerrow = newGUI->prows;
|
|
|
387 |
pagercol = newGUI->pcols;
|
| 9212 |
ripley |
388 |
|
| 37626 |
murdoch |
389 |
if(newGUI->pagerMultiple != pagerMultiple) {
|
| 24606 |
ripley |
390 |
if(!haveusedapager ||
|
| 33901 |
ripley |
391 |
askokcancel(G_("Do not change pager type if any pager is open\nProceed?"))
|
| 24606 |
ripley |
392 |
== YES)
|
| 37626 |
murdoch |
393 |
pagerMultiple = newGUI->pagerMultiple;
|
| 9212 |
ripley |
394 |
if(pagerMultiple) {
|
|
|
395 |
check(rb_mwin); uncheck(rb_swin);
|
|
|
396 |
} else {check(rb_swin); uncheck(rb_mwin);}
|
|
|
397 |
}
|
| 24606 |
ripley |
398 |
|
| 37626 |
murdoch |
399 |
setWidthOnResize = newGUI->setWidthOnResize;
|
| 37860 |
ripley |
400 |
consolebuffered = newGUI->buffered;
|
| 45070 |
ripley |
401 |
|
| 43951 |
murdoch |
402 |
Rwin_graphicsx = newGUI->grx;
|
|
|
403 |
Rwin_graphicsy = newGUI->gry;
|
| 51948 |
murdoch |
404 |
|
|
|
405 |
p->cursor_blink = newGUI->cursor_blink;
|
| 9212 |
ripley |
406 |
}
|
|
|
407 |
|
| 44201 |
ripley |
408 |
static void do_apply(void)
|
| 37626 |
murdoch |
409 |
{
|
|
|
410 |
struct structGUI newGUI;
|
|
|
411 |
|
|
|
412 |
getChoices(&newGUI);
|
|
|
413 |
applyGUI(&newGUI);
|
|
|
414 |
}
|
|
|
415 |
|
| 9212 |
ripley |
416 |
static void save(button b)
|
|
|
417 |
{
|
|
|
418 |
char *file, buf[256], *p;
|
|
|
419 |
FILE *fp;
|
|
|
420 |
|
| 34079 |
ripley |
421 |
setuserfilter("All files (*.*)\0*.*\0\0");
|
| 74680 |
kalibera |
422 |
strncpy(buf, getenv("R_USER"), sizeof(buf)-1);
|
|
|
423 |
buf[sizeof(buf)-1] = '\0';
|
| 46842 |
ripley |
424 |
R_fixbackslash(buf);
|
| 33901 |
ripley |
425 |
file = askfilesavewithdir(G_("Select directory for file 'Rconsole'"),
|
| 9212 |
ripley |
426 |
"Rconsole", buf);
|
|
|
427 |
if(!file) return;
|
| 74680 |
kalibera |
428 |
strncpy(buf, file, sizeof(buf)-1);
|
|
|
429 |
buf[sizeof(buf)-1] = '\0';
|
| 9212 |
ripley |
430 |
p = buf + strlen(buf) - 2;
|
|
|
431 |
if(!strncmp(p, ".*", 2)) *p = '\0';
|
| 24606 |
ripley |
432 |
|
| 40700 |
ripley |
433 |
fp = R_fopen(buf, "w");
|
| 9212 |
ripley |
434 |
if(fp == NULL) {
|
| 24606 |
ripley |
435 |
MessageBox(0, "Cannot open file to fp",
|
| 9212 |
ripley |
436 |
"Configuration Save Error",
|
|
|
437 |
MB_TASKMODAL | MB_ICONSTOP | MB_OK);
|
|
|
438 |
return;
|
|
|
439 |
}
|
|
|
440 |
|
|
|
441 |
fprintf(fp, "%s\n%s\n%s\n\n%s\n%s\n",
|
|
|
442 |
"# Optional parameters for the console and the pager",
|
|
|
443 |
"# The system-wide copy is in rwxxxx/etc.",
|
|
|
444 |
"# A user copy can be installed in `R_USER'.",
|
|
|
445 |
"## Style",
|
|
|
446 |
"# This can be `yes' (for MDI) or `no' (for SDI).");
|
|
|
447 |
fprintf(fp, "MDI = %s\n", ischecked(rb_mdi)?"yes":"no");
|
|
|
448 |
fprintf(fp, "%s\n%s%s\n%s%s\n\n",
|
|
|
449 |
"# the next two are only relevant for MDI",
|
|
|
450 |
"toolbar = ", ischecked(toolbar)?"yes":"no",
|
|
|
451 |
"statusbar = ", ischecked(statusbar)?"yes":"no");
|
|
|
452 |
|
|
|
453 |
fprintf(fp, "%s\n%s\n%s\n%s\n%s\n",
|
|
|
454 |
"## Font.",
|
|
|
455 |
"# Please use only fixed width font.",
|
|
|
456 |
"# If font=FixedFont the system fixed font is used; in this case",
|
|
|
457 |
"# points and style are ignored. If font begins with \"TT \", only",
|
|
|
458 |
"# True Type fonts are searched for.");
|
| 24606 |
ripley |
459 |
fprintf(fp, "font = %s%s\npoints = %s\nstyle = %s # Style can be normal, bold, italic\n\n\n",
|
|
|
460 |
ischecked(tt_font)?"TT ":"",
|
| 9212 |
ripley |
461 |
gettext(f_font),
|
| 24606 |
ripley |
462 |
gettext(d_point),
|
| 9212 |
ripley |
463 |
gettext(f_style));
|
|
|
464 |
fprintf(fp, "# Dimensions (in characters) of the console.\n");
|
| 24606 |
ripley |
465 |
fprintf(fp, "rows = %s\ncolumns = %s\n",
|
| 11595 |
ripley |
466 |
gettext(f_crows), gettext(f_ccols));
|
| 9212 |
ripley |
467 |
fprintf(fp, "# Dimensions (in characters) of the internal pager.\n");
|
| 24606 |
ripley |
468 |
fprintf(fp, "pgrows = %s\npgcolumns = %s\n",
|
| 11595 |
ripley |
469 |
gettext(f_prows), gettext(f_pcols));
|
| 9212 |
ripley |
470 |
fprintf(fp, "# should options(width=) be set to the console width?\n");
|
|
|
471 |
fprintf(fp, "setwidthonresize = %s\n\n",
|
|
|
472 |
ischecked(c_resize) ? "yes" : "no");
|
| 45351 |
ripley |
473 |
fprintf(fp, "# memory limits for the console scrolling buffer, in chars and lines\n");
|
| 24606 |
ripley |
474 |
fprintf(fp, "bufbytes = %s\nbuflines = %s\n\n",
|
| 11595 |
ripley |
475 |
gettext(f_cbb), gettext(f_cbl));
|
| 24577 |
ripley |
476 |
fprintf(fp, "# Initial position of the console (pixels, relative to the workspace for MDI)\n");
|
| 24606 |
ripley |
477 |
fprintf(fp, "xconsole = %s\nyconsole = %s\n\n",
|
| 24577 |
ripley |
478 |
gettext(f_cx), gettext(f_cy));
|
|
|
479 |
fprintf(fp, "%s\n%s\n%s\n%s\n%s\n%s\n\n",
|
|
|
480 |
"# Dimension of MDI frame in pixels",
|
|
|
481 |
"# Format (w*h+xorg+yorg) or use -ve w and h for offsets from right bottom",
|
|
|
482 |
"# This will come up maximized if w==0",
|
|
|
483 |
"# MDIsize = 0*0+0+0",
|
|
|
484 |
"# MDIsize = 1000*800+100+0",
|
|
|
485 |
"# MDIsize = -50*-50+50+50 # 50 pixels space all round");
|
| 9212 |
ripley |
486 |
fprintf(fp, "%s\n%s\n%s\npagerstyle = %s\n\n\n",
|
|
|
487 |
"# The internal pager can displays help in a single window",
|
|
|
488 |
"# or in multiple windows (one for each topic)",
|
|
|
489 |
"# pagerstyle can be set to `singlewindow' or `multiplewindows'",
|
|
|
490 |
ischecked(rb_mwin) ? "multiplewindows" : "singlewindow");
|
|
|
491 |
|
|
|
492 |
fprintf(fp, "## Colours for console and pager(s)\n# (see rwxxxx/etc/rgb.txt for the known colours).\n");
|
| 46784 |
murdoch |
493 |
for (int i=0; i<numGuiColors; i++)
|
|
|
494 |
fprintf(fp, "%s = %s\n", GuiElementNames[i], rgbtoname(dialogColors[i]));
|
| 24606 |
ripley |
495 |
fprintf(fp, "\n\n%s\n%s\nxgraphics = %s\nygraphics = %s\n",
|
|
|
496 |
"## Initial position of the graphics window",
|
|
|
497 |
"## (pixels, <0 values from opposite edge)",
|
|
|
498 |
gettext(f_grx), gettext(f_gry));
|
| 37744 |
ripley |
499 |
fprintf(fp, "\n\n%s\nlanguage = %s\n",
|
|
|
500 |
"## Language for messages",
|
|
|
501 |
gettext(f_lang));
|
| 37860 |
ripley |
502 |
fprintf(fp, "\n\n## Default setting for console buffering: 'yes' or 'no'\n");
|
|
|
503 |
fprintf(fp, "buffered = %s\n",
|
|
|
504 |
ischecked(c_buff) ? "yes" : "no");
|
| 51948 |
murdoch |
505 |
fprintf(fp, "\n\n%s\ncursor_blink = %s\n",
|
|
|
506 |
"## Console cursor blink",
|
|
|
507 |
BlinkList[getlistitem(f_blink)]);
|
| 9212 |
ripley |
508 |
fclose(fp);
|
|
|
509 |
}
|
|
|
510 |
|
| 37592 |
murdoch |
511 |
static void load(button b) /* button callback */
|
|
|
512 |
{
|
|
|
513 |
char *optf, buf[256];
|
| 45070 |
ripley |
514 |
struct structGUI newGUI;
|
| 37592 |
murdoch |
515 |
|
|
|
516 |
setuserfilter("All files (*.*)\0*.*\0\0");
|
| 74680 |
kalibera |
517 |
strncpy(buf, getenv("R_USER"), sizeof(buf)-1);
|
|
|
518 |
buf[sizeof(buf)-1] = '\0';
|
| 46842 |
ripley |
519 |
R_fixbackslash(buf);
|
| 37592 |
murdoch |
520 |
optf = askfilenamewithdir(G_("Select 'Rconsole' file"), "Rconsole", buf);
|
|
|
521 |
if(!optf) return;
|
| 45070 |
ripley |
522 |
|
| 37592 |
murdoch |
523 |
getChoices(&newGUI);
|
|
|
524 |
if (loadRconsole(&newGUI, optf)) {
|
| 52072 |
murdoch |
525 |
if (strlen(newGUI.warning)) askok(newGUI.warning);
|
| 37592 |
murdoch |
526 |
cleanup();
|
|
|
527 |
showDialog(&newGUI);
|
|
|
528 |
}
|
|
|
529 |
}
|
|
|
530 |
|
| 41808 |
ripley |
531 |
int loadRconsole(Gui gui, const char *optf)
|
| 37592 |
murdoch |
532 |
{
|
|
|
533 |
int ok, done, cfgerr;
|
| 45070 |
ripley |
534 |
char *opt[2];
|
|
|
535 |
|
| 37592 |
murdoch |
536 |
if (!optopenfile(optf)) {
|
| 45070 |
ripley |
537 |
return 0; /* this should not happen unless there are permission problems, etc */
|
| 37592 |
murdoch |
538 |
}
|
|
|
539 |
cfgerr = 0;
|
|
|
540 |
while ((ok = optread(opt, '='))) {
|
|
|
541 |
done = 0;
|
|
|
542 |
if (ok == 2) {
|
|
|
543 |
if (!strcmp(opt[0], "font")) {
|
|
|
544 |
if(strlen(opt[1]) > 127) opt[1][127] = '\0';
|
|
|
545 |
gui->tt_font = FALSE;
|
|
|
546 |
{
|
| 43800 |
ripley |
547 |
const char *pf;
|
| 37592 |
murdoch |
548 |
if ((strlen(opt[1]) > 1) &&
|
|
|
549 |
(opt[1][0] == 'T') && (opt[1][1] == 'T')) {
|
|
|
550 |
gui->tt_font = TRUE;
|
|
|
551 |
for (pf = opt[1]+2; isspace(*pf) ; pf++);
|
|
|
552 |
} else pf = opt[1];
|
| 74680 |
kalibera |
553 |
strncpy(gui->font, pf, sizeof(gui->font)-1);
|
|
|
554 |
gui->font[sizeof(gui->font)-1] = '\0';
|
| 37592 |
murdoch |
555 |
}
|
|
|
556 |
done = 1;
|
|
|
557 |
}
|
|
|
558 |
if (!strcmp(opt[0], "points")) {
|
|
|
559 |
gui->pointsize = atoi(opt[1]);
|
|
|
560 |
done = 1;
|
|
|
561 |
}
|
|
|
562 |
if (!strcmp(opt[0], "style")) {
|
| 74680 |
kalibera |
563 |
strncpy(gui->style, opt[1], sizeof(gui->style)-1);
|
|
|
564 |
gui->style[sizeof(gui->style)-1] = 0;
|
| 45070 |
ripley |
565 |
done = 1;
|
| 37592 |
murdoch |
566 |
}
|
|
|
567 |
if (!strcmp(opt[0], "rows")) {
|
|
|
568 |
gui->crows = atoi(opt[1]);
|
|
|
569 |
done = 1;
|
|
|
570 |
}
|
|
|
571 |
if (!strcmp(opt[0], "columns")) {
|
|
|
572 |
gui->ccols = atoi(opt[1]);
|
|
|
573 |
done = 1;
|
|
|
574 |
}
|
|
|
575 |
if (!strcmp(opt[0], "xconsole")) {
|
|
|
576 |
gui->cx = atoi(opt[1]);
|
|
|
577 |
done = 1;
|
|
|
578 |
}
|
|
|
579 |
if (!strcmp(opt[0], "yconsole")) {
|
|
|
580 |
gui->cy = atoi(opt[1]);
|
|
|
581 |
done = 1;
|
|
|
582 |
}
|
|
|
583 |
if (!strcmp(opt[0], "xgraphics")) {
|
|
|
584 |
gui->grx = atoi(opt[1]);
|
|
|
585 |
done = 1;
|
|
|
586 |
}
|
|
|
587 |
if (!strcmp(opt[0], "ygraphics")) {
|
|
|
588 |
gui->gry = atoi(opt[1]);
|
|
|
589 |
done = 1;
|
|
|
590 |
}
|
| 51948 |
murdoch |
591 |
if (!strcmp(opt[0], "cursor_blink")) {
|
|
|
592 |
int i;
|
|
|
593 |
for (i = 0; i < 3; i++) {
|
|
|
594 |
if (!strcmp(opt[1], BlinkList[i])) {
|
|
|
595 |
gui->cursor_blink = i;
|
|
|
596 |
done = 1;
|
|
|
597 |
break;
|
|
|
598 |
}
|
|
|
599 |
}
|
|
|
600 |
}
|
| 37592 |
murdoch |
601 |
if (!strcmp(opt[0], "pgrows")) {
|
|
|
602 |
gui->prows = atoi(opt[1]);
|
|
|
603 |
done = 1;
|
|
|
604 |
}
|
|
|
605 |
if (!strcmp(opt[0], "pgcolumns")) {
|
|
|
606 |
gui->pcols = atoi(opt[1]);
|
|
|
607 |
done = 1;
|
|
|
608 |
}
|
|
|
609 |
if (!strcmp(opt[0], "pagerstyle")) {
|
|
|
610 |
if (!strcmp(opt[1], "singlewindow"))
|
|
|
611 |
gui->pagerMultiple = 0;
|
|
|
612 |
else
|
|
|
613 |
gui->pagerMultiple = 1;
|
|
|
614 |
done = 1;
|
|
|
615 |
}
|
|
|
616 |
if (!strcmp(opt[0], "bufbytes")) {
|
|
|
617 |
gui->cbb = atoi(opt[1]);
|
|
|
618 |
done = 1;
|
|
|
619 |
}
|
|
|
620 |
if (!strcmp(opt[0], "buflines")) {
|
|
|
621 |
gui->cbl = atoi(opt[1]);
|
|
|
622 |
done = 1;
|
|
|
623 |
}
|
|
|
624 |
#ifdef USE_MDI
|
|
|
625 |
if (!strcmp(opt[0], "MDI")) {
|
|
|
626 |
if (!strcmp(opt[1], "yes"))
|
|
|
627 |
gui->MDI = 1;
|
|
|
628 |
else if (!strcmp(opt[1], "no"))
|
|
|
629 |
gui->MDI = 0;
|
|
|
630 |
done = 1;
|
|
|
631 |
}
|
|
|
632 |
if (!strcmp(opt[0], "toolbar")) {
|
|
|
633 |
if (!strcmp(opt[1], "yes"))
|
|
|
634 |
gui->toolbar = 1;
|
|
|
635 |
else if (!strcmp(opt[1], "no"))
|
|
|
636 |
gui->toolbar = 0;
|
|
|
637 |
done = 1;
|
|
|
638 |
}
|
|
|
639 |
if (!strcmp(opt[0], "statusbar")) {
|
|
|
640 |
if (!strcmp(opt[1], "yes"))
|
|
|
641 |
gui->statusbar = 1;
|
|
|
642 |
else if (!strcmp(opt[1], "no"))
|
|
|
643 |
gui->statusbar = 0;
|
|
|
644 |
done = 1;
|
|
|
645 |
}
|
|
|
646 |
if (!strcmp(opt[0], "MDIsize")) { /* wxh+x+y */
|
|
|
647 |
int x=0, y=0, w=0, h=0, sign;
|
|
|
648 |
char *p = opt[1];
|
|
|
649 |
|
|
|
650 |
if(*p == '-') {sign = -1; p++;} else sign = +1;
|
|
|
651 |
for(w=0; isdigit(*p); p++) w = 10*w + (*p - '0');
|
|
|
652 |
w *= sign;
|
|
|
653 |
p++;
|
|
|
654 |
|
|
|
655 |
if(*p == '-') {sign = -1; p++;} else sign = +1;
|
|
|
656 |
for(h=0; isdigit(*p); p++) h = 10*h + (*p - '0');
|
|
|
657 |
h *= sign;
|
|
|
658 |
|
|
|
659 |
if(*p == '-') sign = -1; else sign = +1;
|
|
|
660 |
p++;
|
|
|
661 |
for(x=0; isdigit(*p); p++) x = 10*x + (*p - '0');
|
|
|
662 |
x *= sign;
|
|
|
663 |
if(*p == '-') sign = -1; else sign = +1;
|
|
|
664 |
p++;
|
|
|
665 |
for(y=0; isdigit(*p); p++) y = 10*y + (*p - '0');
|
|
|
666 |
y *= sign;
|
|
|
667 |
|
|
|
668 |
gui->MDIsize = rect(x, y, w, h);
|
| 45070 |
ripley |
669 |
|
| 37592 |
murdoch |
670 |
done = 1;
|
|
|
671 |
}
|
|
|
672 |
#endif
|
| 46784 |
murdoch |
673 |
for (int i=0; i<numGuiColors; i++)
|
|
|
674 |
if (!strcmp(opt[0], GuiElementNames[i])) {
|
|
|
675 |
if (!strcmpi(opt[1], "Windows"))
|
|
|
676 |
gui->guiColors[i] = myGetSysColor(COLOR_WINDOW);
|
|
|
677 |
else gui->guiColors[i] = nametorgb(opt[1]);
|
|
|
678 |
if (gui->guiColors[i] != Transparent)
|
|
|
679 |
done = 1;
|
|
|
680 |
}
|
| 37592 |
murdoch |
681 |
if (!strcmp(opt[0], "setwidthonresize")) {
|
|
|
682 |
if (!strcmp(opt[1], "yes"))
|
|
|
683 |
gui->setWidthOnResize = 1;
|
|
|
684 |
else if (!strcmp(opt[1], "no"))
|
|
|
685 |
gui->setWidthOnResize = 0;
|
|
|
686 |
done = 1;
|
|
|
687 |
}
|
| 37744 |
ripley |
688 |
if (!strcmp(opt[0], "language")) {
|
| 74680 |
kalibera |
689 |
strncpy(gui->language, opt[1], sizeof(gui->language)-1);
|
|
|
690 |
gui->language[sizeof(gui->language)-1] = '\0';
|
| 45070 |
ripley |
691 |
done = 1;
|
| 37744 |
ripley |
692 |
}
|
| 37860 |
ripley |
693 |
if (!strcmp(opt[0], "buffered")) {
|
|
|
694 |
if (!strcmp(opt[1], "yes"))
|
|
|
695 |
gui->buffered = 1;
|
|
|
696 |
else if (!strcmp(opt[1], "no"))
|
| 45070 |
ripley |
697 |
gui->buffered = 0;
|
|
|
698 |
done = 1;
|
| 37860 |
ripley |
699 |
}
|
| 37744 |
ripley |
700 |
} else if (ok == 3) { /* opt[1] == "" */
|
|
|
701 |
if (!strcmp(opt[0], "language")) {
|
| 45070 |
ripley |
702 |
strcpy(gui->language, opt[1]);
|
|
|
703 |
done = 1;
|
| 37744 |
ripley |
704 |
}
|
| 37592 |
murdoch |
705 |
}
|
| 52072 |
murdoch |
706 |
if (!done)
|
|
|
707 |
snprintf(gui->warning, sizeof(gui->warning),
|
|
|
708 |
G_("Ignored '%s' at line %d of file %s"),
|
|
|
709 |
opt[0], optline(), optfile());
|
| 37592 |
murdoch |
710 |
}
|
|
|
711 |
return !cfgerr;
|
|
|
712 |
}
|
|
|
713 |
|
| 28991 |
murdoch |
714 |
static void apply(button b) /* button callback */
|
|
|
715 |
{
|
|
|
716 |
do_apply(); /* to be used outside button callbacks */
|
|
|
717 |
}
|
|
|
718 |
|
| 9212 |
ripley |
719 |
static void cancel(button b)
|
|
|
720 |
{
|
|
|
721 |
cleanup();
|
|
|
722 |
show(RConsole);
|
|
|
723 |
}
|
|
|
724 |
|
| 28991 |
murdoch |
725 |
static void ok(button b)
|
| 9212 |
ripley |
726 |
{
|
| 45070 |
ripley |
727 |
do_apply();
|
| 9212 |
ripley |
728 |
cleanup();
|
|
|
729 |
show(RConsole);
|
|
|
730 |
}
|
|
|
731 |
|
|
|
732 |
static void cMDI(button b)
|
|
|
733 |
{
|
|
|
734 |
enable(toolbar);
|
|
|
735 |
enable(statusbar);
|
|
|
736 |
}
|
|
|
737 |
|
|
|
738 |
static void cSDI(button b)
|
|
|
739 |
{
|
|
|
740 |
disable(toolbar);
|
|
|
741 |
disable(statusbar);
|
|
|
742 |
}
|
|
|
743 |
|
| 46784 |
murdoch |
744 |
static rgb whichbg[numGuiColors] = { consolebg, consolebg, consolebg,
|
|
|
745 |
pagerbg, pagerbg, pagerbg,
|
|
|
746 |
dataeditbg, dataeditbg, dataeditbg,
|
| 86636 |
kalibera |
747 |
editorbg, editorbg, dataeditnbg };
|
| 46784 |
murdoch |
748 |
static rgb whichfg[numGuiColors] = { consolefg, consolefg, consoleuser,
|
|
|
749 |
pagerfg, pagerfg, pagerhighlight,
|
|
|
750 |
dataeditfg, dataeditfg, dataedituser,
|
| 86636 |
kalibera |
751 |
editorfg, editorfg, dataeditfg };
|
| 46784 |
murdoch |
752 |
static void clickColor(control c, int argument)
|
|
|
753 |
{
|
|
|
754 |
int element = cmatch(gettext(guielement), GuiElementNames);
|
|
|
755 |
dialogColors[element] = nametorgb(ColorName[argument]);
|
|
|
756 |
setforeground(guisample, dialogColors[whichfg[element]]);
|
|
|
757 |
setbackground(guisample, dialogColors[whichbg[element]]);
|
|
|
758 |
}
|
|
|
759 |
|
|
|
760 |
static void changeElement(control c, int argument)
|
|
|
761 |
{
|
|
|
762 |
int newcolor = rgbtonum(dialogColors[argument]);
|
|
|
763 |
setlistitem(guicolor, newcolor);
|
|
|
764 |
clickColor(guicolor, newcolor);
|
|
|
765 |
}
|
|
|
766 |
|
|
|
767 |
static void changeFont(control c)
|
|
|
768 |
{
|
| 49486 |
murdoch |
769 |
char fontname[LF_FACESIZE+4];
|
| 46784 |
murdoch |
770 |
|
|
|
771 |
if (samplefont) delobj(samplefont);
|
|
|
772 |
|
|
|
773 |
if(ischecked(tt_font)) strcpy(fontname, "TT "); else strcpy(fontname, "");
|
|
|
774 |
|
| 49486 |
murdoch |
775 |
if (sampleFontNum >= 0) {
|
|
|
776 |
strcat(fontname, FontsList[sampleFontNum]);
|
|
|
777 |
} else
|
|
|
778 |
strcat(fontname, gettext(f_font));
|
|
|
779 |
|
| 46784 |
murdoch |
780 |
samplefont = gnewfont(NULL, fontname, sampleStyle, samplePointsize, 0.0, 1);
|
|
|
781 |
settextfont(guisample, samplefont);
|
|
|
782 |
clickColor(c, getlistitem(guicolor));
|
|
|
783 |
}
|
|
|
784 |
|
|
|
785 |
static void scrollFont(scrollbar s, int position)
|
|
|
786 |
{
|
|
|
787 |
sampleFontNum = position;
|
|
|
788 |
changeFont(s);
|
|
|
789 |
}
|
|
|
790 |
|
|
|
791 |
static void scrollPoints(scrollbar s, int position)
|
|
|
792 |
{
|
|
|
793 |
samplePointsize = atoi(PointsList[position]);
|
|
|
794 |
changeFont(s);
|
|
|
795 |
}
|
|
|
796 |
|
|
|
797 |
static void scrollStyle(scrollbar s, int position)
|
|
|
798 |
{
|
|
|
799 |
sampleStyle = Plain;
|
|
|
800 |
if (!strcmp(gettext(f_style), "bold")) sampleStyle = Bold;
|
|
|
801 |
if (!strcmp(gettext(f_style), "italic")) sampleStyle = Italic;
|
|
|
802 |
changeFont(s);
|
|
|
803 |
}
|
|
|
804 |
|
| 37592 |
murdoch |
805 |
static void showDialog(Gui gui)
|
| 9212 |
ripley |
806 |
{
|
| 37592 |
murdoch |
807 |
char buf[100];
|
| 45070 |
ripley |
808 |
|
| 33901 |
ripley |
809 |
wconfig = newwindow(G_("Rgui Configuration Editor"), rect(0, 0, 550, 450),
|
| 9212 |
ripley |
810 |
Titlebar | Centered | Modal);
|
| 18082 |
ripley |
811 |
setbackground(wconfig, dialog_bg());
|
| 33901 |
ripley |
812 |
l_mdi = newlabel("Single or multiple windows",
|
| 45070 |
ripley |
813 |
rect(10, 10, 140, 20), AlignLeft);
|
| 11516 |
ripley |
814 |
rb_mdi = newradiobutton("MDI", rect(150, 10 , 70, 20), cMDI);
|
|
|
815 |
rb_sdi = newradiobutton("SDI", rect(220, 10 , 70, 20), cSDI);
|
| 9212 |
ripley |
816 |
|
| 24606 |
ripley |
817 |
|
| 9212 |
ripley |
818 |
toolbar = newcheckbox("MDI toolbar", rect(300, 10, 100, 20), NULL);
|
| 37592 |
murdoch |
819 |
if(gui->toolbar) check(toolbar);
|
| 24606 |
ripley |
820 |
statusbar = newcheckbox("MDI statusbar", rect(420, 10, 130, 20), NULL);
|
| 37592 |
murdoch |
821 |
if(gui->statusbar) check(statusbar);
|
|
|
822 |
if(gui->MDI) {
|
| 9212 |
ripley |
823 |
check(rb_mdi); cMDI(rb_mdi);
|
|
|
824 |
} else {
|
|
|
825 |
check(rb_sdi); cSDI(rb_sdi);
|
|
|
826 |
}
|
|
|
827 |
|
| 37744 |
ripley |
828 |
l_mwin = newlabel("Pager style", rect(10, 40, 90, 20), AlignLeft);
|
| 36461 |
murdoch |
829 |
g_mwin = newradiogroup();
|
| 37744 |
ripley |
830 |
rb_mwin = newradiobutton("multiple windows", rect(150, 40, 150, 20), NULL);
|
|
|
831 |
rb_swin = newradiobutton("single window", rect(150, 60 , 150, 20), NULL);
|
| 37592 |
murdoch |
832 |
if(gui->pagerMultiple) check(rb_mwin); else check(rb_swin);
|
| 9212 |
ripley |
833 |
|
| 45070 |
ripley |
834 |
l_lang = newlabel("Language for menus\nand messages",
|
| 37744 |
ripley |
835 |
rect(320, 40, 130, 40), AlignLeft);
|
|
|
836 |
f_lang = newfield(gui->language, rect(450, 45, 60, 20));
|
|
|
837 |
|
| 9212 |
ripley |
838 |
/* Font, pointsize, style */
|
|
|
839 |
|
|
|
840 |
l_font = newlabel("Font", rect(10, 100, 40, 20), AlignLeft);
|
| 24606 |
ripley |
841 |
|
| 46784 |
murdoch |
842 |
f_font = newdropfield(FontsList, rect(50, 100, 120, 20), scrollFont);
|
|
|
843 |
tt_font = newcheckbox("TrueType only", rect(180, 100, 110, 20), changeFont);
|
| 37592 |
murdoch |
844 |
if (gui->tt_font) check(tt_font);
|
| 37920 |
murdoch |
845 |
settext(f_font, gui->font);
|
| 9212 |
ripley |
846 |
|
| 31370 |
ripley |
847 |
l_point = newlabel("size", rect(310, 100, 30, 20), AlignLeft);
|
| 46784 |
murdoch |
848 |
d_point = newdropfield(PointsList, rect(345, 100, 50, 20), scrollPoints);
|
| 62583 |
ripley |
849 |
snprintf(buf, 100, "%d", gui->pointsize);
|
| 37920 |
murdoch |
850 |
settext(d_point, buf);
|
| 9212 |
ripley |
851 |
l_style = newlabel("style", rect(410, 100, 40, 20), AlignLeft);
|
| 46784 |
murdoch |
852 |
f_style = newdroplist(StyleList, rect(450, 100, 80, 20), scrollStyle);
|
| 37592 |
murdoch |
853 |
setlistitem(f_style, cmatch(gui->style, StyleList));
|
| 9212 |
ripley |
854 |
|
|
|
855 |
/* Console size, set widthonresize */
|
| 24606 |
ripley |
856 |
l_crows = newlabel("Console rows", rect(10, 150, 100, 20), AlignLeft);
|
| 62583 |
ripley |
857 |
snprintf(buf, 100, "%d", gui->crows);
|
| 24606 |
ripley |
858 |
f_crows = newfield(buf, rect(110, 150, 30, 20));
|
| 9212 |
ripley |
859 |
l_ccols = newlabel("columns", rect(150, 150, 60, 20), AlignLeft);
|
| 62583 |
ripley |
860 |
snprintf(buf, 100, "%d", gui->ccols);
|
| 9212 |
ripley |
861 |
f_ccols = newfield(buf, rect(220, 150, 30, 20));
|
| 24606 |
ripley |
862 |
l_cx = newlabel("Initial left", rect(270, 150, 70, 20), AlignLeft);
|
| 62583 |
ripley |
863 |
snprintf(buf, 100, "%d", gui->cx);
|
| 24606 |
ripley |
864 |
f_cx = newfield(buf, rect(350, 150, 40, 20));
|
|
|
865 |
l_cy = newlabel("top", rect(430, 150, 30, 20), AlignLeft);
|
| 62583 |
ripley |
866 |
snprintf(buf, 100, "%d", gui->cy);
|
| 24606 |
ripley |
867 |
f_cy = newfield(buf, rect(480, 150, 40, 20));
|
| 9212 |
ripley |
868 |
|
| 24606 |
ripley |
869 |
c_resize = newcheckbox("set options(width) on resize?",
|
| 37860 |
ripley |
870 |
rect(20, 175, 200, 20), NULL);
|
| 37592 |
murdoch |
871 |
if(gui->setWidthOnResize) check(c_resize);
|
| 24606 |
ripley |
872 |
|
| 45351 |
ripley |
873 |
l_cbb = newlabel("buffer chars", rect(270, 175, 70, 20), AlignLeft);
|
| 62583 |
ripley |
874 |
snprintf(buf, 100, "%d", gui->cbb);
|
| 24606 |
ripley |
875 |
f_cbb = newfield(buf, rect(350, 175, 60, 20));
|
| 31370 |
ripley |
876 |
l_cbl = newlabel("lines", rect(430, 175, 50, 20), AlignLeft);
|
| 62583 |
ripley |
877 |
snprintf(buf, 100, "%d", gui->cbl);
|
| 24606 |
ripley |
878 |
f_cbl = newfield(buf, rect(480, 175, 40, 20));
|
|
|
879 |
|
| 37860 |
ripley |
880 |
c_buff = newcheckbox("buffer console by default?",
|
|
|
881 |
rect(20, 190, 200, 20), NULL);
|
|
|
882 |
if(gui->buffered) check(c_buff);
|
|
|
883 |
|
| 51948 |
murdoch |
884 |
/* Cursor blink */
|
|
|
885 |
|
|
|
886 |
l_blink = newlabel("Cursor blink", rect(270, 200,100, 30), AlignLeft);
|
|
|
887 |
f_blink = newdroplist(BlinkList, rect(350, 200, 80, 20), NULL);
|
|
|
888 |
setlistitem(f_blink, gui->cursor_blink);
|
|
|
889 |
|
| 9212 |
ripley |
890 |
/* Pager size */
|
| 51948 |
murdoch |
891 |
l_prows = newlabel("Pager rows", rect(10, 230, 100, 20), AlignLeft);
|
| 62583 |
ripley |
892 |
snprintf(buf, 100, "%d", gui->prows);
|
| 51948 |
murdoch |
893 |
f_prows = newfield(buf, rect(110, 230, 30, 20));
|
|
|
894 |
l_pcols = newlabel("columns", rect(150, 230, 60, 20), AlignLeft);
|
| 62583 |
ripley |
895 |
snprintf(buf, 100, "%d", gui->pcols);
|
| 51948 |
murdoch |
896 |
f_pcols = newfield(buf, rect(220, 230, 30, 20));
|
| 9212 |
ripley |
897 |
|
| 24606 |
ripley |
898 |
/* Graphics window */
|
| 26503 |
murdoch |
899 |
l_grx = newlabel("Graphics windows: initial left",
|
| 51948 |
murdoch |
900 |
rect(10, 270, 190, 20), AlignLeft);
|
| 62583 |
ripley |
901 |
snprintf(buf, 100, "%d", gui->grx);
|
| 51948 |
murdoch |
902 |
f_grx = newfield(buf, rect(200, 270, 40, 20));
|
|
|
903 |
l_gry = newlabel("top", rect(270, 270, 30, 20), AlignLeft);
|
| 62583 |
ripley |
904 |
snprintf(buf, 100, "%d", gui->gry);
|
| 51948 |
murdoch |
905 |
f_gry = newfield(buf, rect(300, 270, 40, 20));
|
| 24606 |
ripley |
906 |
|
| 9212 |
ripley |
907 |
/* Font colours */
|
| 24606 |
ripley |
908 |
l_cols = newlabel("Console and Pager Colours",
|
| 51948 |
murdoch |
909 |
rect(10, 310, 520, 20), AlignCenter);
|
| 46784 |
murdoch |
910 |
|
| 51948 |
murdoch |
911 |
guielement = newlistbox(GuiElementNames, rect(50, 330, 100, 80), changeElement, NULL);
|
|
|
912 |
guicolor = newlistbox(ColorName, rect(205, 330, 100, 80), clickColor, NULL);
|
|
|
913 |
guisample = newrichtextarea("Sample text", rect(350, 330, 150, 55));
|
| 46784 |
murdoch |
914 |
|
|
|
915 |
for (int i=0; i<numGuiColors; i++)
|
|
|
916 |
dialogColors[i] = gui->guiColors[i];
|
|
|
917 |
|
|
|
918 |
setlistitem(guielement, 0);
|
|
|
919 |
changeElement(guielement, 0);
|
|
|
920 |
sampleFontNum = cmatch(gettext(f_font), FontsList);
|
|
|
921 |
samplePointsize = atoi(gettext(d_point));
|
|
|
922 |
scrollStyle(f_style, 0); /* the 0 is ignored */
|
| 24606 |
ripley |
923 |
|
| 42690 |
ripley |
924 |
bApply = newbutton("Apply", rect(50, 410, 70, 25), apply);
|
|
|
925 |
bSave = newbutton("Save...", rect(130, 410, 70, 25), save);
|
|
|
926 |
bLoad = newbutton("Load...", rect(210, 410, 70, 25), load);
|
|
|
927 |
bOK = newbutton("OK", rect(350, 410, 70, 25), ok);
|
|
|
928 |
bCancel = newbutton("Cancel", rect(430, 410, 70, 25), cancel);
|
| 9212 |
ripley |
929 |
show(wconfig);
|
|
|
930 |
}
|
| 37592 |
murdoch |
931 |
|
| 84952 |
kalibera |
932 |
void Rgui_configure(void)
|
| 37592 |
murdoch |
933 |
{
|
| 45070 |
ripley |
934 |
struct structGUI curGUI;
|
|
|
935 |
|
| 37592 |
murdoch |
936 |
getActive(&curGUI);
|
|
|
937 |
showDialog(&curGUI);
|
|
|
938 |
}
|