mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
turn off bitmap support if TIOCGWINSZ doesn't supply pixel info #1805
This commit is contained in:
parent
2d9438cdb2
commit
8d3c042640
@ -959,7 +959,7 @@ const struct blitset* lookup_blitset(const tinfo* tcache, ncblitter_e setid, boo
|
||||
}
|
||||
}
|
||||
// without bitmap support, NCBLIT_PIXEL decays to NCBLIT_3x2
|
||||
if(!tcache->bitmap_supported && setid == NCBLIT_PIXEL){
|
||||
if(!tcache->pixel_draw && setid == NCBLIT_PIXEL){
|
||||
if(may_degrade){
|
||||
setid = NCBLIT_3x2;
|
||||
}else{
|
||||
|
@ -63,7 +63,7 @@ tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
|
||||
capyn(get_escape(ti, ESCAPE_BGOP)));
|
||||
fprintf(debugfp, "%srows: %u cols: %u rpx: %u cpx: %u (%dx%d)\n",
|
||||
indent, rows, cols, ti->cellpixy, ti->cellpixx, rows * ti->cellpixy, cols * ti->cellpixx);
|
||||
if(!ti->bitmap_supported){
|
||||
if(!ti->pixel_init){
|
||||
fprintf(debugfp, "%sdidn't detect bitmap graphics support\n", indent);
|
||||
}else if(ti->sixel_maxy){
|
||||
fprintf(debugfp, "%smax sixel size: %dx%d colorregs: %u\n",
|
||||
|
@ -1311,7 +1311,7 @@ int ncdirect_flush(const ncdirect* nc){
|
||||
}
|
||||
|
||||
int ncdirect_check_pixel_support(const ncdirect* n){
|
||||
if(n->tcache.bitmap_supported){
|
||||
if(n->tcache.pixel_draw){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -254,6 +254,9 @@ int update_term_dimensions(int fd, int* rows, int* cols, tinfo* tcache,
|
||||
if(tcache){
|
||||
tcache->cellpixy = ws.ws_row ? ws.ws_ypixel / ws.ws_row : 0;
|
||||
tcache->cellpixx = ws.ws_col ? ws.ws_xpixel / ws.ws_col : 0;
|
||||
if(tcache->cellpixy == 0 || tcache->cellpixx == 0){
|
||||
tcache->pixel_init = NULL; // disable support
|
||||
}
|
||||
}
|
||||
if(tcache->sixel_maxy_pristine){
|
||||
tcache->sixel_maxy = tcache->sixel_maxy_pristine;
|
||||
@ -984,7 +987,7 @@ recursive_lock_init(pthread_mutex_t *lock){
|
||||
}
|
||||
|
||||
int notcurses_check_pixel_support(const notcurses* nc){
|
||||
if(nc->tcache.bitmap_supported){
|
||||
if(nc->tcache.pixel_init){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -6,7 +6,6 @@
|
||||
// we found Sixel support -- set up the API
|
||||
static inline void
|
||||
setup_sixel_bitmaps(tinfo* ti, int fd){
|
||||
ti->bitmap_supported = true;
|
||||
ti->pixel_init = sixel_init;
|
||||
ti->pixel_draw = sixel_draw;
|
||||
ti->pixel_remove = NULL;
|
||||
@ -20,7 +19,6 @@ setup_sixel_bitmaps(tinfo* ti, int fd){
|
||||
|
||||
static inline void
|
||||
setup_kitty_bitmaps(tinfo* ti, int fd){
|
||||
ti->bitmap_supported = true;
|
||||
ti->pixel_wipe = kitty_wipe;
|
||||
ti->pixel_destroy = kitty_destroy;
|
||||
ti->pixel_remove = kitty_remove;
|
||||
|
@ -116,7 +116,22 @@ typedef struct tinfo {
|
||||
// bg_collides_default is either 0x0000000 or (if in use) 0x1RRGGBB.
|
||||
uint32_t bg_collides_default;
|
||||
|
||||
// sprixel support. there are several different sprixel protocols, of
|
||||
// bitmap support. if we support bitmaps, pixel_draw will be non-NULL
|
||||
// wipe out a cell's worth of pixels from within a sprixel. for sixel, this
|
||||
// means leaving out the pixels (and likely resizes the string). for kitty,
|
||||
// this means dialing down their alpha to 0 (in equivalent space).
|
||||
int (*pixel_wipe)(struct sprixel* s, int y, int x);
|
||||
// perform the inverse of pixel_wipe, restoring an annihilated sprixcell.
|
||||
int (*pixel_rebuild)(struct sprixel* s, int y, int x, uint8_t* auxvec);
|
||||
int (*pixel_remove)(int id, FILE* out); // kitty only, issue actual delete command
|
||||
int (*pixel_init)(const struct tinfo*, int fd); // called when support is detected
|
||||
int (*pixel_draw)(const struct ncpile* p, struct sprixel* s, FILE* out);
|
||||
// execute move (erase old graphic, place at new location) if non-NULL
|
||||
int (*pixel_move)(const struct ncpile* p, struct sprixel* s, FILE* out);
|
||||
int (*pixel_destroy)(const struct notcurses* nc, const struct ncpile* p, FILE* out, struct sprixel* s);
|
||||
int (*pixel_shutdown)(int fd); // called during context shutdown
|
||||
int (*pixel_clear_all)(int fd); // called during startup, kitty only
|
||||
// sprixel parameters. there are several different sprixel protocols, of
|
||||
// which we support sixel and kitty. the kitty protocol is used based
|
||||
// on TERM heuristics. otherwise, we attempt to detect sixel support, and
|
||||
// query the details of the implementation.
|
||||
@ -130,26 +145,11 @@ typedef struct tinfo {
|
||||
// so kitty graphics (which don't force a scroll) never deal with this.
|
||||
int sixel_maxy; // maximum working sixel height
|
||||
int sixel_maxy_pristine; // maximum theoretical sixel height, as queried
|
||||
int (*pixel_destroy)(const struct notcurses* nc, const struct ncpile* p, FILE* out, struct sprixel* s);
|
||||
// wipe out a cell's worth of pixels from within a sprixel. for sixel, this
|
||||
// means leaving out the pixels (and likely resizes the string). for kitty,
|
||||
// this means dialing down their alpha to 0 (in equivalent space).
|
||||
int (*pixel_wipe)(struct sprixel* s, int y, int x);
|
||||
// perform the inverse of pixel_wipe, restoring an annihilated sprixcell.
|
||||
int (*pixel_rebuild)(struct sprixel* s, int y, int x, uint8_t* auxvec);
|
||||
int (*pixel_remove)(int id, FILE* out); // kitty only, issue actual delete command
|
||||
int (*pixel_init)(const struct tinfo*, int fd); // called when support is detected
|
||||
int (*pixel_draw)(const struct ncpile* p, struct sprixel* s, FILE* out);
|
||||
// execute move (erase old graphic, place at new location) if non-NULL
|
||||
int (*pixel_move)(const struct ncpile* p, struct sprixel* s, FILE* out);
|
||||
int (*pixel_shutdown)(int fd); // called during context shutdown
|
||||
int (*pixel_clear_all)(int fd); // called during startup, kitty only
|
||||
int sprixel_scale_height; // sprixel must be a multiple of this many rows
|
||||
const char* termname; // terminal name from environment variables/init
|
||||
char* termversion; // terminal version (freeform) from query responses
|
||||
struct termios tpreserved; // terminal state upon entry
|
||||
ncinputlayer input; // input layer
|
||||
bool bitmap_supported; // do we support bitmaps (post pixel_query_done)?
|
||||
|
||||
// mlterm resets the cursor (i.e. makes it visible) any time you print
|
||||
// a sprixel. we work around this spiritedly unorthodox decision. it
|
||||
|
@ -8,8 +8,7 @@ TEST_CASE("Bitmaps") {
|
||||
auto n_ = notcurses_stdplane(nc_);
|
||||
REQUIRE(n_);
|
||||
|
||||
if(notcurses_check_pixel_support(nc_) <= 0){
|
||||
CHECK(0 == nc_->tcache.bitmap_supported);
|
||||
if(!notcurses_check_pixel_support(nc_)){
|
||||
CHECK(!notcurses_stop(nc_));
|
||||
return;
|
||||
}
|
||||
@ -17,7 +16,7 @@ TEST_CASE("Bitmaps") {
|
||||
SUBCASE("SprixelTermValues") {
|
||||
CHECK(0 < nc_->tcache.cellpixy);
|
||||
CHECK(0 < nc_->tcache.cellpixx);
|
||||
CHECK(nc_->tcache.bitmap_supported);
|
||||
CHECK(nc_->tcache.pixel_init);
|
||||
}
|
||||
|
||||
SUBCASE("SprixelMinimize") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user