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
|
||||
\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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -194,42 +194,44 @@ 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];
|
||||
Fl_Color cellfg = ((Fl_Color *)(cursheet->palette))[fgcn];
|
||||
if (sc.dim) cellfg = fl_color_average(cellfg, cellbg, 0.6f);
|
||||
fl_color(cellfg);
|
||||
Fl_Font cellfont = FL_HELVETICA;
|
||||
if (sc.bold) cellfont |= FL_BOLD;
|
||||
if (sc.italic) cellfont |= FL_ITALIC;
|
||||
fl_font(cellfont, fontsize);
|
||||
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);
|
||||
Fl_Font cellfont = FL_HELVETICA;
|
||||
if (sc.bold) cellfont |= FL_BOLD;
|
||||
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);
|
||||
ptrdiff_t len = ulen;
|
||||
ptrdiff_t nlen = len;
|
||||
int ww = 0, hh = 0;
|
||||
fl_measure(s, ww, hh, 0);
|
||||
while (ww > W-6) {
|
||||
char *dc = mbspos(s+nlen, -1);
|
||||
nlen = dc - s;
|
||||
s[nlen] = (char)0;
|
||||
ww = 0;
|
||||
fl_measure(s, ww, hh, 0);
|
||||
ptrdiff_t len = ulen;
|
||||
ptrdiff_t nlen = len;
|
||||
int ww = 0, hh = 0;
|
||||
fl_measure(s, ww, hh, 0);
|
||||
while (ww > W-6) {
|
||||
char *dc = mbspos(s+nlen, -1);
|
||||
nlen = dc - s;
|
||||
s[nlen] = (char)0;
|
||||
ww = 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();
|
||||
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user