diff options
-rw-r--r-- | src/cmds_command.c | 20 | ||||
-rw-r--r-- | src/color.c | 49 | ||||
-rw-r--r-- | src/color.h | 1 | ||||
-rw-r--r-- | src/doc | 5 | ||||
-rw-r--r-- | src/gram.y | 12 |
5 files changed, 87 insertions, 0 deletions
diff --git a/src/cmds_command.c b/src/cmds_command.c index 2d1a5f2..0e57337 100644 --- a/src/cmds_command.c +++ b/src/cmds_command.c @@ -101,6 +101,7 @@ L"showmaps", L"showrow", L"showrows", L"sort", +L"unformat", L"version", L"w", L"x", @@ -571,6 +572,25 @@ void do_commandmode(struct block * sb) { inputline[0] = L'\0'; #endif + } else if ( ! wcsncmp(inputline, L"unformat", 8) ) { + #ifdef USECOLORS + interp_line[0]=L'\0'; + wchar_t line [BUFFERSIZE]; + wcscpy(line, inputline); + del_range_wchars(line, 0, 7); + swprintf(interp_line, BUFFERSIZE, L"unformat"); + if (p != -1) { + swprintf(interp_line + wcslen(interp_line), BUFFERSIZE, L" %s%d:", coltoa(sr->tlcol), sr->tlrow); + swprintf(interp_line + wcslen(interp_line), BUFFERSIZE, L"%s%d ", coltoa(sr->brcol), sr->brrow); + } + swprintf(interp_line + wcslen(interp_line), BUFFERSIZE, L"%ls", line); + send_to_interp(interp_line); + #else + sc_error("Color support not compiled in"); + chg_mode('.'); + inputline[0] = L'\0'; + #endif + } else if ( ! wcsncmp(inputline, L"color ", 6) ) { #ifdef USECOLORS char line [BUFFERSIZE]; 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) { diff --git a/src/color.h b/src/color.h index 5c28093..1244caf 100644 --- a/src/color.h +++ b/src/color.h @@ -17,6 +17,7 @@ struct dictionary * get_d_colors_param(); void start_default_ucolors(); void set_ucolor(WINDOW * w, struct ucolor * uc); void color_cell(int r, int c, int rf, int cf, char * detail); +void unformat(int r, int c, int rf, int cf); void set_colors_param_dict(); void free_colors_param_dict(); void chg_color(char * str); @@ -667,6 +667,11 @@ Commands for handling cell content: :cellcolor "fg=RED bold=1 underline=1" :cellcolor A2:A6 "fg=CYAN bold=1 underline=1" + :unformat + :unformat {range} + Removes a previous format set over a range. + If not range is specified, it removes the format over current cell. + :redefine_color "{color}" {R} {G} {B} Change the RGB values of the colors defined by ncurses. RGB values range from 0 to 1000. @@ -199,6 +199,7 @@ token S_YANKCOL %token S_IUNMAP %token S_COLOR %token S_CELLCOLOR +%token S_UNFORMAT %token S_REDEFINE_COLOR %token S_SET %token S_FCOPY @@ -581,6 +582,17 @@ command: scxfree($2); } + | S_UNFORMAT var_or_range { +#ifdef USECOLORS + if ( ! atoi(get_conf_value("nocurses"))) unformat($2.left.vp->row, $2.left.vp->col, $2.right.vp->row, $2.right.vp->col); +#endif + } + + | S_UNFORMAT { +#ifdef USECOLORS + if ( ! atoi(get_conf_value("nocurses"))) unformat(currow, curcol, currow, curcol); +#endif + } | S_REDEFINE_COLOR STRING NUMBER NUMBER NUMBER { redefine_color($2, $3, $4, $5); |