Skip to content

Commit

Permalink
Allow customizing background color for row and column names in data e…
Browse files Browse the repository at this point in the history
…ditor

on Windows.


git-svn-id: https://svn.r-project.org/R/trunk@86636 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
kalibera committed May 28, 2024
1 parent b396f25 commit d65ee81
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/gnuwin32/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* file console.c
* Copyright (C) 1998--2003 Guido Masarotto and Brian Ripley
* Copyright (C) 2004-8 The R Foundation
* Copyright (C) 2004-2023 The R Core Team
* Copyright (C) 2004-2024 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -314,7 +314,8 @@ rgb guiColors[numGuiColors] = {
White, Black, gaRed, /* consolebg, consolefg, consoleuser, */
White, Black, gaRed, /* pagerbg, pagerfg, pagerhighlight, */
White, Black, gaRed, /* dataeditbg, dataeditfg, dataedituser */
White, Black /* editorbg, editorfg */
White, Black, /* editorbg, editorfg */
White /* dataeditnbg */
};

extern int R_HistorySize; /* from Defn.h */
Expand Down
2 changes: 2 additions & 0 deletions src/gnuwin32/guicolors.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* R : A Computer Language for Statistical Data Analysis
* file consolestructs.h
* Copyright (C) 2008 The R Foundation
* Copyright (C) 2024 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -27,6 +28,7 @@ typedef enum {
pagerbg, pagerfg, pagerhighlight,
dataeditbg, dataeditfg, dataedituser,
editorbg, editorfg,
dataeditnbg,
numGuiColors
} GuiColorIndex;

Expand Down
9 changes: 5 additions & 4 deletions src/gnuwin32/preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* R : A Computer Language for Statistical Data Analysis
* file preferences.c
* Copyright (C) 2000 Guido Masarotto and Brian Ripley
* 2004-2023 R Core Team
* 2004-2024 R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -71,7 +71,7 @@ static const char *FontsList[] = {"Courier", "Courier New", "FixedSys", "FixedFo
static const char *GuiElementNames[numGuiColors+1] = {"background", "normaltext", "usertext",
"pagerbg", "pagertext", "highlight",
"dataeditbg", "dataedittext", "dataedituser",
"editorbg", "editortext", NULL};
"editorbg", "editortext", "dataeditnbg", NULL};
static const char *BlinkList[] = {"None", "Partial", "Full"};
static window wconfig;
static button bApply, bSave, bLoad, bOK, bCancel;
Expand Down Expand Up @@ -145,6 +145,7 @@ void getDefaults(Gui gui)
gui->guiColors[dataedituser] = gaRed;
gui->guiColors[editorbg] = White;
gui->guiColors[editorfg] = Black;
gui->guiColors[dataeditnbg] = White;
gui->prows = 25;
gui->pcols = 80;
gui->pagerMultiple = 0;
Expand Down Expand Up @@ -739,11 +740,11 @@ static void cSDI(button b)
static rgb whichbg[numGuiColors] = { consolebg, consolebg, consolebg,
pagerbg, pagerbg, pagerbg,
dataeditbg, dataeditbg, dataeditbg,
editorbg, editorbg };
editorbg, editorbg, dataeditnbg };
static rgb whichfg[numGuiColors] = { consolefg, consolefg, consoleuser,
pagerfg, pagerfg, pagerhighlight,
dataeditfg, dataeditfg, dataedituser,
editorfg, editorfg };
editorfg, editorfg, dataeditfg };
static void clickColor(control c, int argument)
{
int element = cmatch(gettext(guielement), GuiElementNames);
Expand Down
10 changes: 6 additions & 4 deletions src/library/utils/src/windows/dataentry.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
* Copyright (C) 1998--2023 The R Core Team
* Copyright (C) 1998--2024 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -590,7 +590,7 @@ static void drawcol(DEstruct DE, int whichcol)

find_coords(DE, 0, col, &src_x, &src_y);
cleararea(DE, src_x, src_y, bw, DE->windowHeight, DE->p->guiColors[dataeditbg]);
cleararea(DE, src_x, src_y, bw, DE->box_h, bbg);
cleararea(DE, src_x, src_y, bw, DE->box_h, DE->p->guiColors[dataeditnbg]);
for (i = 0; i < DE->nhigh; i++)
drawrectangle(DE, src_x, DE->hwidth + i * DE->box_h, bw, DE->box_h, 1, 1);

Expand Down Expand Up @@ -618,7 +618,8 @@ static void drawrow(DEstruct DE, int whichrow)

find_coords(DE, row, 0, &src_x, &src_y);
cleararea(DE, src_x, src_y, DE->windowWidth, DE->box_h,
(whichrow > 0) ? DE->p->guiColors[dataeditbg] : bbg);
(whichrow > 0) ? DE->p->guiColors[dataeditbg] :
DE->p->guiColors[dataeditnbg]);
drawrectangle(DE, src_x, src_y, DE->boxw[0], DE->box_h, 1, 1);

snprintf(rlab, 15, DE->labform, whichrow);
Expand Down Expand Up @@ -938,7 +939,8 @@ static void printstring(DEstruct DE, const char *ibuf, int buflen,
find_coords(DE, row, col, &x_pos, &y_pos);
if (col == 0) bw = DE->boxw[0]; else bw = BOXW(col+DE->colmin-1);
cleararea(DE, x_pos + 1, y_pos + 1, bw - 1, DE->box_h - 1,
(row==0 || col==0) ? bbg:DE->p->guiColors[dataeditbg]);
(row==0 || col==0) ?
DE->p->guiColors[dataeditnbg]:DE->p->guiColors[dataeditbg]);
fw = min(BUFSIZE, (bw - 8)/(DE->p->fw));
bufw = min(fw, buflen);
strncpy(buf, ibuf, bufw);
Expand Down

0 comments on commit d65ee81

Please sign in to comment.