feat: Add hard-coded invisible color 254 (#94)
Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: #94
This commit is contained in:
parent
00859ecbd2
commit
13f9457e98
@ -4018,6 +4018,18 @@ teapot
|
|||||||
fteapot
|
fteapot
|
||||||
\family default
|
\family default
|
||||||
set up a default palette appropriate for their respective capabilities.
|
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,
|
Hopefully, a future enhancement will allow one to display, edit, save,
|
||||||
and restore the palette.
|
and restore the palette.
|
||||||
\end_layout
|
\end_layout
|
||||||
@ -10467,7 +10479,15 @@ noprefix "false"
|
|||||||
|
|
||||||
\end_inset
|
\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
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Subsection
|
\begin_layout Subsection
|
||||||
|
@ -30,6 +30,7 @@ extern const char FloatFormat_Char[];
|
|||||||
typedef unsigned char ColorNum;
|
typedef unsigned char ColorNum;
|
||||||
#define NO_COLOR_SET 0
|
#define NO_COLOR_SET 0
|
||||||
#define MAX_MAX_COLORS UCHAR_MAX
|
#define MAX_MAX_COLORS UCHAR_MAX
|
||||||
|
#define INVISIBLE_COLOR (UCHAR_MAX - 1)
|
||||||
#define COLOR_FORMAT "%hhu"
|
#define COLOR_FORMAT "%hhu"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -606,19 +606,22 @@ void redraw_sheet(Sheet *sheet)
|
|||||||
if (sc.bold) wattron(stdscr, A_BOLD);
|
if (sc.bold) wattron(stdscr, A_BOLD);
|
||||||
if (sc.underline) wattron(stdscr, A_UNDERLINE);
|
if (sc.underline) wattron(stdscr, A_UNDERLINE);
|
||||||
short nextcp = hashcp;
|
short nextcp = hashcp;
|
||||||
if (hashcp == usecp) {
|
chtype blank = (chtype)' ';
|
||||||
|
if (hashcp == usecp && fg != INVISIBLE_COLOR) {
|
||||||
(void)mvwaddstr(stdscr, (int)(height + sheet->oriy),
|
(void)mvwaddstr(stdscr, (int)(height + sheet->oriy),
|
||||||
(int)(width + sheet->orix),
|
(int)(width + sheet->orix),
|
||||||
buf+cutoff);
|
buf+cutoff);
|
||||||
} else { // Alternate colors to simulate hash
|
} 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),
|
(void)mvwaddch(stdscr, (int)(height + sheet->oriy),
|
||||||
(int)(width + sheet->orix),
|
(int)(width + sheet->orix), next_char);
|
||||||
(chtype)buf[cutoff]);
|
|
||||||
for (size_t ix = cutoff+1; buf[ix]; ++ix) {
|
for (size_t ix = cutoff+1; buf[ix]; ++ix) {
|
||||||
wcolor_set(stdscr, nextcp, NULL);
|
wcolor_set(stdscr, nextcp, NULL);
|
||||||
if (nextcp == hashcp) nextcp = usecp;
|
if (nextcp == hashcp) nextcp = usecp;
|
||||||
else nextcp = hashcp;
|
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) {
|
for (fill=mbslen(buf+cutoff); fill<realsize; ++fill) {
|
||||||
|
@ -194,42 +194,44 @@ class TeapotTable {open : {public Fl_Table}}
|
|||||||
fl_push_clip(xx+3, yy+3, W-6, H-6);
|
fl_push_clip(xx+3, yy+3, W-6, H-6);
|
||||||
ColorNum fgcn = sc.aspect[FOREGROUND];
|
ColorNum fgcn = sc.aspect[FOREGROUND];
|
||||||
if (fgcn == NO_COLOR_SET) fgcn = DefaultCN[FOREGROUND];
|
if (fgcn == NO_COLOR_SET) fgcn = DefaultCN[FOREGROUND];
|
||||||
Fl_Color cellfg = ((Fl_Color *)(cursheet->palette))[fgcn];
|
if (fgcn != INVISIBLE_COLOR) {
|
||||||
if (sc.dim) cellfg = fl_color_average(cellfg, cellbg, 0.6f);
|
Fl_Color cellfg = ((Fl_Color *)(cursheet->palette))[fgcn];
|
||||||
fl_color(cellfg);
|
if (sc.dim) cellfg = fl_color_average(cellfg, cellbg, 0.6f);
|
||||||
Fl_Font cellfont = FL_HELVETICA;
|
fl_color(cellfg);
|
||||||
if (sc.bold) cellfont |= FL_BOLD;
|
Fl_Font cellfont = FL_HELVETICA;
|
||||||
if (sc.italic) cellfont |= FL_ITALIC;
|
if (sc.bold) cellfont |= FL_BOLD;
|
||||||
fl_font(cellfont, fontsize);
|
if (sc.italic) cellfont |= FL_ITALIC;
|
||||||
|
fl_font(cellfont, fontsize);
|
||||||
|
|
||||||
size_t ulen = printvalue(s, sizeof(s), 0, quote, sc.fform,
|
size_t ulen = printvalue(s, sizeof(s), 0, quote, sc.fform,
|
||||||
sc.precision, cursheet, test);
|
sc.precision, cursheet, test);
|
||||||
ptrdiff_t len = ulen;
|
ptrdiff_t len = ulen;
|
||||||
ptrdiff_t nlen = len;
|
ptrdiff_t nlen = len;
|
||||||
int ww = 0, hh = 0;
|
int ww = 0, hh = 0;
|
||||||
fl_measure(s, ww, hh, 0);
|
fl_measure(s, ww, hh, 0);
|
||||||
while (ww > W-6) {
|
while (ww > W-6) {
|
||||||
char *dc = mbspos(s+nlen, -1);
|
char *dc = mbspos(s+nlen, -1);
|
||||||
nlen = dc - s;
|
nlen = dc - s;
|
||||||
s[nlen] = (char)0;
|
s[nlen] = (char)0;
|
||||||
ww = 0;
|
ww = 0;
|
||||||
fl_measure(s, ww, hh, 0);
|
fl_measure(s, ww, hh, 0);
|
||||||
|
}
|
||||||
|
if (nlen < len) {
|
||||||
|
if (nlen < 1) { s[0] = '\#'; s[1] = (char)0; }
|
||||||
|
else if (nlen < 6) for (int i = 0; s[i]; i++) s[i] = '\#';
|
||||||
|
else {
|
||||||
|
char *ov = mbspos(s+nlen-1, -5);
|
||||||
|
if (ov < s) ov = s;
|
||||||
|
strncpy(ov, "...\#\#", sizeof(s) - nlen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Adjust adj = sc.adjust;
|
||||||
|
fl_draw(s, xx+3, yy+3, W-6, H-6,
|
||||||
|
adj == RIGHT ? FL_ALIGN_RIGHT :
|
||||||
|
adj == LEFT ? FL_ALIGN_LEFT : FL_ALIGN_CENTER,
|
||||||
|
NULL, 0);
|
||||||
|
if (sc.underline) fl_xyline(xx, yy+H-7, xx+W);
|
||||||
}
|
}
|
||||||
if (nlen < len) {
|
|
||||||
if (nlen < 1) { s[0] = '\#'; s[1] = (char)0; }
|
|
||||||
else if (nlen < 6) for (int i = 0; s[i]; i++) s[i] = '\#';
|
|
||||||
else {
|
|
||||||
char *ov = mbspos(s+nlen-1, -5);
|
|
||||||
if (ov < s) ov = s;
|
|
||||||
strncpy(ov, "...\#\#", sizeof(s) - nlen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Adjust adj = sc.adjust;
|
|
||||||
fl_draw(s, xx+3, yy+3, W-6, H-6,
|
|
||||||
adj == RIGHT ? FL_ALIGN_RIGHT :
|
|
||||||
adj == LEFT ? FL_ALIGN_LEFT : FL_ALIGN_CENTER,
|
|
||||||
NULL, 0);
|
|
||||||
if (sc.underline) fl_xyline(xx, yy+H-7, xx+W);
|
|
||||||
fl_pop_clip();
|
fl_pop_clip();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user