diff options
author | Andrés <andmarti@gmail.com> | 2021-03-14 09:20:37 -0300 |
---|---|---|
committer | Andrés <andmarti@gmail.com> | 2021-03-14 09:20:37 -0300 |
commit | e2ab6de106528c1674686e0081a541df99afc574 (patch) | |
tree | f35172d2bc9c8a27728c31911fe5b12b9c233f54 | |
parent | c4372c31ce07f6fce8b41486f6b8ba2956965a96 (diff) |
added new underline_grid config value to show a nicer grid
-rw-r--r-- | src/color.c | 4 | ||||
-rw-r--r-- | src/conf.c | 1 | ||||
-rwxr-xr-x | src/doc | 3 | ||||
-rwxr-xr-x | src/gram.y | 14 | ||||
-rw-r--r-- | src/tui.c | 26 |
5 files changed, 37 insertions, 11 deletions
diff --git a/src/color.c b/src/color.c index 547c67b..5b4bf66 100644 --- a/src/color.c +++ b/src/color.c @@ -115,9 +115,9 @@ void start_default_ucolors() { ucolors[ CELL_SELECTION_SC ].bg = BLUE; ucolors[ NUMB ].fg = CYAN; ucolors[ NUMB ].bg = DEFAULT_COLOR; - ucolors[ STRG ].fg = BLUE; + ucolors[ STRG ].fg = BLACK; ucolors[ STRG ].bg = DEFAULT_COLOR; - ucolors[ STRG ].bold = 1; + ucolors[ STRG ].bold = 0; ucolors[ DATEF ].fg = YELLOW; ucolors[ DATEF ].bg = DEFAULT_COLOR; ucolors[ EXPRESSION ].fg = RED; @@ -84,6 +84,7 @@ void store_default_config_values() { put(user_conf_d, "version", "0"); put(user_conf_d, "help", "0"); put(user_conf_d, "input_bar_bottom", "0"); + put(user_conf_d, "underline_grid", "0"); #ifdef AUTOBACKUP put(user_conf_d, "autobackup", "0"); // 0:noautobackup, n>0: backup every n in seconds #endif @@ -1151,6 +1151,9 @@ Commands for handling cell content: 'input_bar_bottom' [default off] Place the input bar at the bottom of the screen. + 'underline_grid' [default off] + Underline cells to make a nicer grid + 'truncate' [default off] If cell content exceedes column width it gets replaced by asterisks '*'. If truncate is set, the content is cut off at the end of the cell. @@ -244,6 +244,7 @@ token S_YANKCOL %token K_OVERLAP %token K_NOOVERLAP %token K_INPUT_BAR_BOTTOM +%token K_UNDERLINE_GRID %token K_TRUNCATE %token K_NOTRUNCATE %token K_QUIT_AFTERLOAD @@ -1061,15 +1062,18 @@ setitem : | K_OVERLAP '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "overlap=0", TRUE); else parse_str(user_conf_d, "overlap=1", TRUE); } | K_OVERLAP { parse_str(user_conf_d, "overlap=1", TRUE); } - | K_INPUT_BAR_BOTTOM '=' NUMBER { - if ($3 == 0) parse_str(user_conf_d, "input_bar_bottom=0", TRUE); - else parse_str(user_conf_d, "input_bar_bottom=1", TRUE); - ui_mv_bottom_bar(); - } + | K_INPUT_BAR_BOTTOM '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "input_bar_bottom=0", TRUE); + else parse_str(user_conf_d, "input_bar_bottom=1", TRUE); + ui_mv_bottom_bar(); } | K_INPUT_BAR_BOTTOM { parse_str(user_conf_d, "input_bar_bottom=1", TRUE); ui_mv_bottom_bar(); } + | K_UNDERLINE_GRID '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "underline_grid=0", TRUE); + else parse_str(user_conf_d, "underline_grid=1", TRUE); } + | K_UNDERLINE_GRID { parse_str(user_conf_d, "underline_grid=1", TRUE); + } + | K_NOOVERLAP { parse_str(user_conf_d, "overlap=0", TRUE); } | K_TRUNCATE '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "truncate=0", TRUE); @@ -845,9 +845,10 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) { // Clean format #ifdef USECOLORS + if ((*p) && (*p)->cellerror) { // cellerror ui_set_ucolor(win, &ucolors[CELL_ERROR], ucolors[CELL_ERROR].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); - } else if ((*p) && (*p)->v < 0) { // cell negative + } else if ((*p) && (*p)->v < 0) { // cell negative ui_set_ucolor(win, &ucolors[CELL_NEGATIVE], ucolors[CELL_NEGATIVE].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); } else if ((*p) && (*p)->expr) { ui_set_ucolor(win, &ucolors[EXPRESSION], ucolors[EXPRESSION].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); @@ -948,7 +949,6 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) { } - // repaint a blank cell, because of in range, or because we have a coloured empty cell! if ( !(*p) || (( !((*p)->flags & is_valid) && !(*p)->label ) && !((*p)->cellerror == CELLERROR)) ) { if ( (currow == row && curcol == col) || @@ -966,6 +966,15 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) { #endif } + #ifdef USECOLORS + if (has_colors() && atoi(get_conf_value("underline_grid"))) { + attr_t attr; + short color; + wattr_get(win, &attr, &color, NULL); + wattr_set(win, attr | A_UNDERLINE, color, NULL); + } + #endif + // new implementation for wide char support cchar_t cht[fieldlen]; wchar_t w; @@ -979,19 +988,28 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) { i+= wcwidth(w); } - // we print text and number + // we print text and number } else { pad_and_align(text, num, fwidth[col], align, (*p)->pad, out); if (col == mxcol && wcswidth(out, wcslen(out)) > fwidth[col]) out[ count_width_widestring(out, fwidth[col]) ] = L'\0'; + #ifdef USECOLORS + if (has_colors() && atoi(get_conf_value("underline_grid"))) { + attr_t attr; + short color; + wattr_get(win, &attr, &color, NULL); + wattr_set(win, attr | A_UNDERLINE, color, NULL); + } + #endif + mvwprintw(win, row + 1 - offscr_sc_rows - q_row_hidden, c, "%ls", out); wclrtoeol(win); } // clean format #ifndef USECOLORS - wattroff(win, A_REVERSE); + wattroff(win, A_REVERSE); #endif } } |