feat: Add hard-coded invisible color 254 #94

Merged
glen merged 1 commits from invis_color into main 2023-07-26 05:23:11 +00:00
4 changed files with 64 additions and 38 deletions

View File

@ -4018,6 +4018,18 @@ teapot
fteapot
\family default
set up a default palette appropriate for their respective capabilities.
Currently, the color number 254 is treated specially: when the foreground
is set to this color, the contents of the cell are not drawn into the cell
at all.
So color 254 is a hard-coded
\begin_inset Quotes eld
\end_inset
invisible
\begin_inset Quotes erd
\end_inset
or zero-alpha color.
Hopefully, a future enhancement will allow one to display, edit, save,
and restore the palette.
\end_layout
@ -10467,7 +10479,15 @@ noprefix "false"
\end_inset
) or making its foreground and background the same color, etc.
) or using the hard-coded
\begin_inset Quotes eld
\end_inset
invisible
\begin_inset Quotes erd
\end_inset
color number 254, etc.
\end_layout
\begin_layout Subsection

View File

@ -30,6 +30,7 @@ extern const char FloatFormat_Char[];
typedef unsigned char ColorNum;
#define NO_COLOR_SET 0
#define MAX_MAX_COLORS UCHAR_MAX
#define INVISIBLE_COLOR (UCHAR_MAX - 1)
#define COLOR_FORMAT "%hhu"
typedef enum

View File

@ -606,19 +606,22 @@ void redraw_sheet(Sheet *sheet)
if (sc.bold) wattron(stdscr, A_BOLD);
if (sc.underline) wattron(stdscr, A_UNDERLINE);
short nextcp = hashcp;
if (hashcp == usecp) {
chtype blank = (chtype)' ';
if (hashcp == usecp && fg != INVISIBLE_COLOR) {
(void)mvwaddstr(stdscr, (int)(height + sheet->oriy),
(int)(width + sheet->orix),
buf+cutoff);
} else { // Alternate colors to simulate hash
chtype next_char = (chtype)buf[cutoff];
if (fg == INVISIBLE_COLOR) next_char = blank;
(void)mvwaddch(stdscr, (int)(height + sheet->oriy),
(int)(width + sheet->orix),
(chtype)buf[cutoff]);
(int)(width + sheet->orix), next_char);
for (size_t ix = cutoff+1; buf[ix]; ++ix) {
wcolor_set(stdscr, nextcp, NULL);
if (nextcp == hashcp) nextcp = usecp;
else nextcp = hashcp;
(void)waddch(stdscr, (chtype)buf[ix]);
next_char = fg == INVISIBLE_COLOR ? blank : (chtype)buf[ix];
(void)waddch(stdscr, next_char);
}
}
for (fill=mbslen(buf+cutoff); fill<realsize; ++fill) {

View File

@ -194,6 +194,7 @@ class TeapotTable {open : {public Fl_Table}}
fl_push_clip(xx+3, yy+3, W-6, H-6);
ColorNum fgcn = sc.aspect[FOREGROUND];
if (fgcn == NO_COLOR_SET) fgcn = DefaultCN[FOREGROUND];
if (fgcn != INVISIBLE_COLOR) {
Fl_Color cellfg = ((Fl_Color *)(cursheet->palette))[fgcn];
if (sc.dim) cellfg = fl_color_average(cellfg, cellbg, 0.6f);
fl_color(cellfg);
@ -230,6 +231,7 @@ class TeapotTable {open : {public Fl_Table}}
adj == LEFT ? FL_ALIGN_LEFT : FL_ALIGN_CENTER,
NULL, 0);
if (sc.underline) fl_xyline(xx, yy+H-7, xx+W);
}
fl_pop_clip();
return;