summaryrefslogtreecommitdiffstats
path: root/src/color.c
diff options
context:
space:
mode:
authorandmarti1424 <andmarti@gmail.com>2017-03-11 12:32:37 -0300
committerandmarti1424 <andmarti@gmail.com>2017-03-11 12:32:37 -0300
commit5f8dbad33d5edbe7cc7c5afbaf689ea54772110c (patch)
treeffb4e8abe0543c5958c3ca78da69eb2eea019963 /src/color.c
parent0c362d29f7dee9657adc0865e97420ebfa205f6e (diff)
new :unformat command
Diffstat (limited to 'src/color.c')
-rw-r--r--src/color.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/color.c b/src/color.c
index f8ead1a..bbb8eab 100644
--- a/src/color.c
+++ b/src/color.c
@@ -319,6 +319,55 @@ void color_cell(int r, int c, int rf, int cf, char * str) {
return;
}
+void unformat(int r, int c, int rf, int cf) {
+ if (any_locked_cells(r, c, rf, cf)) {
+ sc_error("Locked cells encountered. Nothing changed");
+ return;
+ }
+
+ // if we are not loading the file
+ if (! loading) {
+ modflg++;
+ #ifdef UNDO
+ create_undo_action();
+ #endif
+ }
+
+ // we remove format in the range
+ struct ent * n;
+ int i, j;
+ for (i=r; i<=rf; i++) {
+ for (j=c; j<=cf; j++) {
+
+ // action
+ if ( (n = *ATBL(tbl, i, j)) && n->ucolor != NULL) {
+ if (! loading) {
+ #ifdef UNDO
+ copy_to_undostruct(i, j, i, j, 'd');
+ #endif
+ }
+
+ free(n->ucolor);
+ n->ucolor = NULL;
+
+ if (! loading) {
+ #ifdef UNDO
+ copy_to_undostruct(i, j, i, j, 'a');
+ #endif
+ }
+ }
+
+ }
+ }
+ if (! loading) {
+ #ifdef UNDO
+ end_undo_action();
+ #endif
+ update(TRUE);
+ }
+ return;
+}
+
// this function receives two ucolors variables and returns 1 if both have the same values
// returns 0 otherwise
int same_ucolor(struct ucolor * u, struct ucolor * v) {