summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandmarti1424 <scim.spreadsheet@gmail.com>2016-03-31 20:30:44 -0300
committerandmarti1424 <scim.spreadsheet@gmail.com>2016-03-31 20:30:44 -0300
commite70fbbca48b9f8761f5c102355fd83494ef37a43 (patch)
tree03d68ee4ef55cafa94e37e1b0e10b174ba759319
parent65a61050376390c2bd702b22e8e12c934db9664c (diff)
Added 256 color support. Now colors can be redifined to different RGB values.
-rw-r--r--src/cmds_command.c4
-rw-r--r--src/color.c25
-rw-r--r--src/doc6
-rw-r--r--src/gram.y5
4 files changed, 39 insertions, 1 deletions
diff --git a/src/cmds_command.c b/src/cmds_command.c
index 63ad14a..5d2a1ca 100644
--- a/src/cmds_command.c
+++ b/src/cmds_command.c
@@ -84,6 +84,7 @@ static char * valid_commands[] = {
"q!",
"quit!",
"quit",
+"redefine_color"
"refresh",
"set",
"showcol",
@@ -298,6 +299,9 @@ void do_commandmode(struct block * sb) {
}
send_to_interp(cline);
+ } else if ( ! strncmp(inputline, "redefine_color", 14) ) {
+ send_to_interp(inputline);
+
} else if ( ! strncmp(inputline, "load", 4) ) {
char cline [BUFFERSIZE];
int force_rewrite = 0;
diff --git a/src/color.c b/src/color.c
index 93d64ca..9fc4ceb 100644
--- a/src/color.c
+++ b/src/color.c
@@ -323,7 +323,7 @@ void color_cell(int r, int c, int rf, int cf, char * str) {
// returns 0 otherwise
int same_ucolor(struct ucolor * u, struct ucolor * v) {
if (u == NULL || v == NULL) return 0;
-
+
if (u->fg != v->fg) return 0;
if (u->bg != v->bg) return 0;
if (u->bold != v->bold) return 0;
@@ -336,3 +336,26 @@ int same_ucolor(struct ucolor * u, struct ucolor * v) {
return 1;
}
+int redefine_color(char * color, int r, int g, int b) {
+ void winchg();
+
+#ifdef USECOLORS
+ if (
+ ! atoi(get_conf_value("nocurses")) &&
+ has_colors() &&
+ can_change_color()
+ ) {
+ int c = atoi(get(d_colors_param, color));
+ int res = init_color(c, r, g, b);
+ if (res == 0) {
+ winchg();
+ scinfo("Color %s redefined to %d %d %d.", color, r, g, b);
+ return 0;
+ }
+ }
+
+#endif
+ scinfo("Could not redefine color");
+ return -1;
+}
+
diff --git a/src/doc b/src/doc
index 502563c..f1609ba 100644
--- a/src/doc
+++ b/src/doc
@@ -546,6 +546,12 @@ Commands for handling cell content:
Ex.: :cellcolor "bg=CYAN fg=WHITE"
:cellcolor "fg=RED bold=1 underline=1"
+ :redefine_color <str> <number> <number> <number>
+ This command is used for changing RGB values of the colors defined by ncurses.
+ For this, ncurses shall be built with --enable-ext-colors and your terminal shall support 256 colors.
+ One for example is TERM=xterm-256color
+ Example of use: :redefine_color "RED" 700 100 100
+
:lock Use this command to lock the current cell or a range of cells, i.e. make them immune to any type of editing. A locked cell can't be changed in any way until it is unlocked.
:unlock This command is the opposite of the :lock command and thus unlocks a locked cell and makes it editable.
diff --git a/src/gram.y b/src/gram.y
index b68d50a..35d9521 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -187,6 +187,7 @@ token S_YANKCOL
%token S_IUNMAP
%token S_COLOR
%token S_CELLCOLOR
+%token S_REDEFINE_COLOR
%token K_ERROR
%token K_INVALID
@@ -482,6 +483,10 @@ command:
scxfree($3);
}
+ | S_REDEFINE_COLOR STRING NUMBER NUMBER NUMBER {
+ redefine_color($2, $3, $4, $5);
+ scxfree($2); }
+
| S_PAD NUMBER COL ':' COL { pad($2, 0, $3, maxrow, $5); }
| S_PAD NUMBER COL { pad($2, 0, $3, maxrow, $3); }
| S_PAD NUMBER var_or_range { pad($2, $3.left.vp->row, $3.left.vp->col, $3.right.vp->row, $3.right.vp->col); }