The R Project SVN R

Rev

Rev 68956 | Rev 83755 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 68956 Rev 74680
Line 1... Line 1...
1
/*
1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  file preferences.c
3
 *  file preferences.c
4
 *  Copyright (C) 2000      Guido Masarotto and Brian Ripley
4
 *  Copyright (C) 2000      Guido Masarotto and Brian Ripley
5
 *                2004-2014 R Core Team
5
 *                2004-2018 R Core Team
6
 *
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
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
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
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  (at your option) any later version.
10
 *  (at your option) any later version.
Line 96... Line 96...
96
{
96
{
97
    p->MDI = ischecked(rb_mdi);
97
    p->MDI = ischecked(rb_mdi);
98
    p->toolbar = ischecked(toolbar);
98
    p->toolbar = ischecked(toolbar);
99
    p->statusbar = ischecked(statusbar);
99
    p->statusbar = ischecked(statusbar);
100
    p->pagerMultiple = ischecked(rb_mwin);
100
    p->pagerMultiple = ischecked(rb_mwin);
101
    strcpy(p->language, gettext(f_lang));
101
    strncpy(p->language, gettext(f_lang), sizeof(p->language)-1);
-
 
102
    p->language[sizeof(p->language)-1] = '\0';
102
    strcpy(p->font, gettext(f_font));
103
    strncpy(p->font, gettext(f_font), sizeof(p->font)-1);
-
 
104
    p->font[sizeof(p->font)-1] = '\0';
103
    p->tt_font = ischecked(tt_font);
105
    p->tt_font = ischecked(tt_font);
104
    p->pointsize = atoi(gettext(d_point));
106
    p->pointsize = atoi(gettext(d_point));
105
    strcpy(p->style, gettext(f_style));
107
    strncpy(p->style, gettext(f_style), sizeof(p->style)-1);
-
 
108
    p->style[sizeof(p->style)-1] = '\0';
106
    p->crows = atoi(gettext(f_crows));
109
    p->crows = atoi(gettext(f_crows));
107
    p->ccols = atoi(gettext(f_ccols));
110
    p->ccols = atoi(gettext(f_ccols));
108
    p->cx = atoi(gettext(f_cx));
111
    p->cx = atoi(gettext(f_cx));
109
    p->cy = atoi(gettext(f_cy));
112
    p->cy = atoi(gettext(f_cy));
110
    p->setWidthOnResize = ischecked(c_resize);
113
    p->setWidthOnResize = ischecked(c_resize);
Line 175... Line 178...
175
	gui->statusbar = ((RguiMDI & RW_STATUSBAR) != 0);
178
	gui->statusbar = ((RguiMDI & RW_STATUSBAR) != 0);
176
	gui->MDI = ((RguiMDI & RW_MDI) != 0);
179
	gui->MDI = ((RguiMDI & RW_MDI) != 0);
177
	gui->pagerMultiple = pagerMultiple;
180
	gui->pagerMultiple = pagerMultiple;
178
	{
181
	{
179
	    const char *p = getenv("LANGUAGE");
182
	    const char *p = getenv("LANGUAGE");
180
	    strcpy(gui->language, p ? p : "");
183
	    strncpy(gui->language, p ? p : "", sizeof(gui->language)-1);
-
 
184
	    gui->language[sizeof(gui->language)-1] = '\0';
181
	}
185
	}
182
 
186
 
183
	/* Font, pointsize, style */
187
	/* Font, pointsize, style */
184
 
188
 
185
	gui->tt_font = FALSE;
189
	gui->tt_font = FALSE;
Line 188... Line 192...
188
	    if ((strlen(fontname) > 1) &&
192
	    if ((strlen(fontname) > 1) &&
189
		(fontname[0] == 'T') && (fontname[1] == 'T')) {
193
		(fontname[0] == 'T') && (fontname[1] == 'T')) {
190
		gui->tt_font = TRUE;
194
		gui->tt_font = TRUE;
191
		for (pf = fontname+2; isspace(*pf) ; pf++);
195
		for (pf = fontname+2; isspace(*pf) ; pf++);
192
	    } else pf = fontname;
196
	    } else pf = fontname;
193
	    strcpy(gui->font, pf);
197
	    strncpy(gui->font, pf, sizeof(gui->font)-1);
-
 
198
	    gui->font[sizeof(gui->font)-1] = '\0';
194
	}
199
	}
195
 
200
 
196
	gui->pointsize = pointsize;
201
	gui->pointsize = pointsize;
197
 
202
 
198
	if (fontsty & Italic) strcpy(gui->style, "italic");
203
	if (fontsty & Italic) strcpy(gui->style, "italic");
Line 403... Line 408...
403
{
408
{
404
    char *file, buf[256], *p;
409
    char *file, buf[256], *p;
405
    FILE *fp;
410
    FILE *fp;
406
 
411
 
407
    setuserfilter("All files (*.*)\0*.*\0\0");
412
    setuserfilter("All files (*.*)\0*.*\0\0");
408
    strcpy(buf, getenv("R_USER"));
413
    strncpy(buf, getenv("R_USER"), sizeof(buf)-1);
-
 
414
    buf[sizeof(buf)-1] = '\0';
409
    R_fixbackslash(buf);
415
    R_fixbackslash(buf);
410
    file = askfilesavewithdir(G_("Select directory for file 'Rconsole'"),
416
    file = askfilesavewithdir(G_("Select directory for file 'Rconsole'"),
411
			      "Rconsole", buf);
417
			      "Rconsole", buf);
412
    if(!file) return;
418
    if(!file) return;
413
    strcpy(buf, file);
419
    strncpy(buf, file, sizeof(buf)-1);
-
 
420
    buf[sizeof(buf)-1] = '\0';
414
    p = buf + strlen(buf) - 2;
421
    p = buf + strlen(buf) - 2;
415
    if(!strncmp(p, ".*", 2)) *p = '\0';
422
    if(!strncmp(p, ".*", 2)) *p = '\0';
416
 
423
 
417
    fp = R_fopen(buf, "w");
424
    fp = R_fopen(buf, "w");
418
    if(fp == NULL) {
425
    if(fp == NULL) {
Line 496... Line 503...
496
{
503
{
497
    char *optf, buf[256];
504
    char *optf, buf[256];
498
    struct structGUI newGUI;
505
    struct structGUI newGUI;
499
 
506
 
500
    setuserfilter("All files (*.*)\0*.*\0\0");
507
    setuserfilter("All files (*.*)\0*.*\0\0");
501
    strcpy(buf, getenv("R_USER"));
508
    strncpy(buf, getenv("R_USER"), sizeof(buf)-1);
-
 
509
    buf[sizeof(buf)-1] = '\0';
502
    R_fixbackslash(buf);
510
    R_fixbackslash(buf);
503
    optf = askfilenamewithdir(G_("Select 'Rconsole' file"), "Rconsole", buf);
511
    optf = askfilenamewithdir(G_("Select 'Rconsole' file"), "Rconsole", buf);
504
    if(!optf) return;
512
    if(!optf) return;
505
 
513
 
506
    getChoices(&newGUI);
514
    getChoices(&newGUI);
Line 531... Line 539...
531
		    if ((strlen(opt[1]) > 1) &&
539
		    if ((strlen(opt[1]) > 1) &&
532
			(opt[1][0] == 'T') && (opt[1][1] == 'T')) {
540
			(opt[1][0] == 'T') && (opt[1][1] == 'T')) {
533
			gui->tt_font = TRUE;
541
			gui->tt_font = TRUE;
534
			for (pf = opt[1]+2; isspace(*pf) ; pf++);
542
			for (pf = opt[1]+2; isspace(*pf) ; pf++);
535
		    } else pf = opt[1];
543
		    } else pf = opt[1];
536
		    strcpy(gui->font, pf);
544
		    strncpy(gui->font, pf, sizeof(gui->font)-1);
-
 
545
		    gui->font[sizeof(gui->font)-1] = '\0';
537
		}
546
		}
538
		done = 1;
547
		done = 1;
539
	    }
548
	    }
540
	    if (!strcmp(opt[0], "points")) {
549
	    if (!strcmp(opt[0], "points")) {
541
		gui->pointsize = atoi(opt[1]);
550
		gui->pointsize = atoi(opt[1]);
542
		done = 1;
551
		done = 1;
543
	    }
552
	    }
544
	    if (!strcmp(opt[0], "style")) {
553
	    if (!strcmp(opt[0], "style")) {
545
		strcpy(gui->style, opt[1]);
554
		strncpy(gui->style, opt[1], sizeof(gui->style)-1);
-
 
555
		gui->style[sizeof(gui->style)-1] = 0;
546
		done = 1;
556
		done = 1;
547
	    }
557
	    }
548
	    if (!strcmp(opt[0], "rows")) {
558
	    if (!strcmp(opt[0], "rows")) {
549
		gui->crows = atoi(opt[1]);
559
		gui->crows = atoi(opt[1]);
550
		done = 1;
560
		done = 1;
Line 665... Line 675...
665
		else if (!strcmp(opt[1], "no"))
675
		else if (!strcmp(opt[1], "no"))
666
		    gui->setWidthOnResize = 0;
676
		    gui->setWidthOnResize = 0;
667
		done = 1;
677
		done = 1;
668
	    }
678
	    }
669
	    if (!strcmp(opt[0], "language")) {
679
	    if (!strcmp(opt[0], "language")) {
670
		strcpy(gui->language, opt[1]);
680
		strncpy(gui->language, opt[1], sizeof(gui->language)-1);
-
 
681
		gui->language[sizeof(gui->language)-1] = '\0';
671
		done = 1;
682
		done = 1;
672
	    }
683
	    }
673
	    if (!strcmp(opt[0], "buffered")) {
684
	    if (!strcmp(opt[0], "buffered")) {
674
		if (!strcmp(opt[1], "yes"))
685
		if (!strcmp(opt[1], "yes"))
675
		    gui->buffered = 1;
686
		    gui->buffered = 1;