mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
Cell: overlap RGB and palette indices #884
This commit is contained in:
parent
d3d8051f36
commit
52103af364
@ -368,6 +368,7 @@ target_include_directories(notcurses-demo
|
|||||||
target_link_libraries(notcurses-demo
|
target_link_libraries(notcurses-demo
|
||||||
PRIVATE
|
PRIVATE
|
||||||
notcurses
|
notcurses
|
||||||
|
unistring
|
||||||
${MATH_LIBRARIES}
|
${MATH_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -510,10 +510,10 @@ typedef struct cell {
|
|||||||
// (values 0--0x7f), or an offset into a per-ncplane attached pool of
|
// (values 0--0x7f), or an offset into a per-ncplane attached pool of
|
||||||
// varying-length UTF-8 grapheme clusters. This pool may thus be up to 32MB.
|
// varying-length UTF-8 grapheme clusters. This pool may thus be up to 32MB.
|
||||||
uint32_t gcluster; // 4B -> 4B
|
uint32_t gcluster; // 4B -> 4B
|
||||||
// NCSTYLE_* attributes (16 bits) + 8 foreground palette index bits + 8
|
// 8 bits of zero + 8 reserved bits + NCSTYLE_* attributes (16 bits).
|
||||||
// background palette index bits. palette index bits are used only if the
|
// (attrword & 0xff000000): reserved, *must be zero*
|
||||||
// corresponding default color bit *is not* set, and the corresponding
|
// (attrword & 0x00ff0000): reserved
|
||||||
// palette index bit *is* set.
|
// (attrword & 0x0000ffff): NCSTYLE_* booleans
|
||||||
uint32_t attrword; // + 4B -> 8B
|
uint32_t attrword; // + 4B -> 8B
|
||||||
// (channels & 0x8000000000000000ull): part of a wide glyph
|
// (channels & 0x8000000000000000ull): part of a wide glyph
|
||||||
// (channels & 0x4000000000000000ull): foreground is *not* "default color"
|
// (channels & 0x4000000000000000ull): foreground is *not* "default color"
|
||||||
@ -567,16 +567,16 @@ API int cell_duplicate(struct ncplane* n, cell* targ, const cell* c);
|
|||||||
// Release resources held by the cell 'c'.
|
// Release resources held by the cell 'c'.
|
||||||
API void cell_release(struct ncplane* n, cell* c);
|
API void cell_release(struct ncplane* n, cell* c);
|
||||||
|
|
||||||
#define NCSTYLE_MASK 0xffff0000ul
|
#define NCSTYLE_MASK 0x0000fffful
|
||||||
#define NCSTYLE_STANDOUT 0x00800000ul
|
#define NCSTYLE_STANDOUT 0x00000080ul
|
||||||
#define NCSTYLE_UNDERLINE 0x00400000ul
|
#define NCSTYLE_UNDERLINE 0x00000040ul
|
||||||
#define NCSTYLE_REVERSE 0x00200000ul
|
#define NCSTYLE_REVERSE 0x00000020ul
|
||||||
#define NCSTYLE_BLINK 0x00100000ul
|
#define NCSTYLE_BLINK 0x00000010ul
|
||||||
#define NCSTYLE_DIM 0x00080000ul
|
#define NCSTYLE_DIM 0x00000008ul
|
||||||
#define NCSTYLE_BOLD 0x00040000ul
|
#define NCSTYLE_BOLD 0x00000004ul
|
||||||
#define NCSTYLE_INVIS 0x00020000ul
|
#define NCSTYLE_INVIS 0x00000002ul
|
||||||
#define NCSTYLE_PROTECT 0x00010000ul
|
#define NCSTYLE_PROTECT 0x00000001ul
|
||||||
#define NCSTYLE_ITALIC 0x01000000ul
|
#define NCSTYLE_ITALIC 0x00000100ul
|
||||||
#define NCSTYLE_NONE 0
|
#define NCSTYLE_NONE 0
|
||||||
|
|
||||||
// Set the specified style bits for the cell 'c', whether they're actively
|
// Set the specified style bits for the cell 'c', whether they're actively
|
||||||
@ -1718,9 +1718,7 @@ API void ncplane_erase(struct ncplane* n);
|
|||||||
// since we can't blend default colors. Likewise, if 'c2' is a default color,
|
// since we can't blend default colors. Likewise, if 'c2' is a default color,
|
||||||
// it will not be used (unless 'blends' is 0).
|
// it will not be used (unless 'blends' is 0).
|
||||||
//
|
//
|
||||||
// Palette-indexed colors do not blend, and since we need the attrword to store
|
// Palette-indexed colors do not blend. Do not pass me palette-indexed channels!
|
||||||
// them, we just don't fuck wit' 'em here. Do not pass me palette-indexed
|
|
||||||
// channels! I will eat them.
|
|
||||||
static inline unsigned
|
static inline unsigned
|
||||||
channels_blend(unsigned c1, unsigned c2, unsigned* blends){
|
channels_blend(unsigned c1, unsigned c2, unsigned* blends){
|
||||||
if(channel_alpha(c2) == CELL_ALPHA_TRANSPARENT){
|
if(channel_alpha(c2) == CELL_ALPHA_TRANSPARENT){
|
||||||
@ -1848,14 +1846,14 @@ cell_set_fg_palindex(cell* cl, int idx){
|
|||||||
cl->channels |= CELL_FGDEFAULT_MASK;
|
cl->channels |= CELL_FGDEFAULT_MASK;
|
||||||
cl->channels |= CELL_FG_PALETTE;
|
cl->channels |= CELL_FG_PALETTE;
|
||||||
cell_set_fg_alpha(cl, CELL_ALPHA_OPAQUE);
|
cell_set_fg_alpha(cl, CELL_ALPHA_OPAQUE);
|
||||||
cl->attrword &= 0xffff00ff;
|
cl->channels &= 0xff000000ffffffffull;
|
||||||
cl->attrword |= (idx << 8u);
|
cl->channels |= ((uint64_t)idx << 32u);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned
|
static inline unsigned
|
||||||
cell_fg_palindex(const cell* cl){
|
cell_fg_palindex(const cell* cl){
|
||||||
return (cl->attrword & 0x0000ff00) >> 8u;
|
return (cl->channels & 0xff00000000ull) >> 32u;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the r, g, and b cell for the background component of this 64-bit
|
// Set the r, g, and b cell for the background component of this 64-bit
|
||||||
@ -1888,14 +1886,14 @@ cell_set_bg_palindex(cell* cl, int idx){
|
|||||||
cl->channels |= CELL_BGDEFAULT_MASK;
|
cl->channels |= CELL_BGDEFAULT_MASK;
|
||||||
cl->channels |= CELL_BG_PALETTE;
|
cl->channels |= CELL_BG_PALETTE;
|
||||||
cell_set_bg_alpha(cl, CELL_ALPHA_OPAQUE);
|
cell_set_bg_alpha(cl, CELL_ALPHA_OPAQUE);
|
||||||
cl->attrword &= 0xffffff00;
|
cl->channels &= 0xffffffffff000000;
|
||||||
cl->attrword |= idx;
|
cl->channels |= idx;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned
|
static inline unsigned
|
||||||
cell_bg_palindex(const cell* cl){
|
cell_bg_palindex(const cell* cl){
|
||||||
return cl->attrword & 0x000000ff;
|
return (cl->channels & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the foreground using the "default foreground color"?
|
// Is the foreground using the "default foreground color"?
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "demo.h"
|
#include "demo.h"
|
||||||
|
#include <unictype.h>
|
||||||
|
|
||||||
// planes as of unicode 13.0:
|
// planes as of unicode 13.0:
|
||||||
// 0: BMP
|
// 0: BMP
|
||||||
@ -15,11 +16,12 @@ allglyphs(struct notcurses* nc, struct ncplane* column, int legendy){
|
|||||||
// some of these cause major problems with Kitty, if not others, due to
|
// some of these cause major problems with Kitty, if not others, due to
|
||||||
// heavy duty beating on freetype FIXME reenable when reasonable
|
// heavy duty beating on freetype FIXME reenable when reasonable
|
||||||
const int valid_planes[] = {
|
const int valid_planes[] = {
|
||||||
0, 1, /*2,*/ 3, 14,
|
0, 1,/* 2, 3, 14,*/
|
||||||
/*15, 16,*/ -1
|
/*15, 16,*/ -1
|
||||||
};
|
};
|
||||||
struct ncplane* std = notcurses_stdplane(nc);
|
struct ncplane* std = notcurses_stdplane(nc);
|
||||||
const int dimx = ncplane_dim_x(column);
|
const int dimx = ncplane_dim_x(column);
|
||||||
|
ncplane_set_base(column, " ", 0, 0);
|
||||||
for(const int* plane = valid_planes ; *plane >= 0 ; ++plane){
|
for(const int* plane = valid_planes ; *plane >= 0 ; ++plane){
|
||||||
for(long int c = 0 ; c < 0x10000l ; ++c){
|
for(long int c = 0 ; c < 0x10000l ; ++c){
|
||||||
const char32_t wc = *plane * 0x10000l + c;
|
const char32_t wc = *plane * 0x10000l + c;
|
||||||
@ -28,6 +30,9 @@ allglyphs(struct notcurses* nc, struct ncplane* column, int legendy){
|
|||||||
if(wc >= 0xd800 && wc <= 0xdfff){
|
if(wc >= 0xd800 && wc <= 0xdfff){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(uc_bidi_category(wc)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(wcwidth(w[0]) >= 1){
|
if(wcwidth(w[0]) >= 1){
|
||||||
int x;
|
int x;
|
||||||
if(ncplane_putwegc(column, w, NULL) < 0){
|
if(ncplane_putwegc(column, w, NULL) < 0){
|
||||||
|
Loading…
Reference in New Issue
Block a user