mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
[sixel] call sprite_sixel_init at proper time #1436
This commit is contained in:
parent
1f4ece224b
commit
33d408b4a3
1
NEWS.md
1
NEWS.md
@ -6,6 +6,7 @@ rearrangements of Notcurses.
|
|||||||
Kitty pixel graphics protocol.
|
Kitty pixel graphics protocol.
|
||||||
* Added `notcurses_debug_caps()` to dump terminal properties, both those
|
* Added `notcurses_debug_caps()` to dump terminal properties, both those
|
||||||
reported and those inferred, to a `FILE*`.
|
reported and those inferred, to a `FILE*`.
|
||||||
|
* Added `NCOPTION_NO_CLEAR_BITMAPS` option for `notcurses_init()`.
|
||||||
|
|
||||||
* 2.2.3 (2021-03-08)
|
* 2.2.3 (2021-03-08)
|
||||||
* Implemented **EXPERIMENTAL** `NCBLIT_PIXEL` for terminals reporting Sixel
|
* Implemented **EXPERIMENTAL** `NCBLIT_PIXEL` for terminals reporting Sixel
|
||||||
|
6
USAGE.md
6
USAGE.md
@ -91,6 +91,12 @@ typedef enum {
|
|||||||
// doing something weird (setting a locale not based on LANG).
|
// doing something weird (setting a locale not based on LANG).
|
||||||
#define NCOPTION_INHIBIT_SETLOCALE 0x0001
|
#define NCOPTION_INHIBIT_SETLOCALE 0x0001
|
||||||
|
|
||||||
|
// We typically try to clear any preexisting bitmaps. If we ought *not* try
|
||||||
|
// to do this, pass NCOPTION_NO_CLEAR_BITMAPS. Note that they might still
|
||||||
|
// get cleared even if this is set, and they might not get cleared even if
|
||||||
|
// this is not set. It's a tough world out there.
|
||||||
|
#define NCOPTION_NO_CLEAR_BITMAPS 0x0002ull
|
||||||
|
|
||||||
// We typically install a signal handler for SIGWINCH that generates a resize
|
// We typically install a signal handler for SIGWINCH that generates a resize
|
||||||
// event in the notcurses_getc() queue. Set to inhibit this handler.
|
// event in the notcurses_getc() queue. Set to inhibit this handler.
|
||||||
#define NCOPTION_NO_WINCH_SIGHANDLER 0x0004
|
#define NCOPTION_NO_WINCH_SIGHANDLER 0x0004
|
||||||
|
@ -12,6 +12,7 @@ notcurses_init - initialize a notcurses instance
|
|||||||
|
|
||||||
```c
|
```c
|
||||||
#define NCOPTION_INHIBIT_SETLOCALE 0x0001ull
|
#define NCOPTION_INHIBIT_SETLOCALE 0x0001ull
|
||||||
|
#define NCOPTION_NO_CLEAR_BITMAPS 0x0002ull
|
||||||
#define NCOPTION_NO_WINCH_SIGHANDLER 0x0004ull
|
#define NCOPTION_NO_WINCH_SIGHANDLER 0x0004ull
|
||||||
#define NCOPTION_NO_QUIT_SIGHANDLERS 0x0008ull
|
#define NCOPTION_NO_QUIT_SIGHANDLERS 0x0008ull
|
||||||
#define NCOPTION_SUPPRESS_BANNERS 0x0020ull
|
#define NCOPTION_SUPPRESS_BANNERS 0x0020ull
|
||||||
@ -110,6 +111,10 @@ zero. The following flags are defined:
|
|||||||
the **LANG** environment variable. Your program should call **setlocale(3)**
|
the **LANG** environment variable. Your program should call **setlocale(3)**
|
||||||
itself, usually as one of the first lines.
|
itself, usually as one of the first lines.
|
||||||
|
|
||||||
|
* **NCOPTION_NO_CLEAR_BITMAPS**: On entry, make no special attempt to clear any
|
||||||
|
preexisting bitmaps. Note that they might still get cleared even if this is
|
||||||
|
set, and they might not get cleared even if this is not set.
|
||||||
|
|
||||||
* **NCOPTION_NO_WINCH_SIGHANDLER**: A signal handler will usually be installed
|
* **NCOPTION_NO_WINCH_SIGHANDLER**: A signal handler will usually be installed
|
||||||
for **SIGWINCH** and **SIGCONT**, resulting in **NCKEY_RESIZE** events
|
for **SIGWINCH** and **SIGCONT**, resulting in **NCKEY_RESIZE** events
|
||||||
being generated on input. With this flag, the handler will not be
|
being generated on input. With this flag, the handler will not be
|
||||||
|
@ -832,7 +832,11 @@ typedef enum {
|
|||||||
// doing something weird (setting a locale not based on LANG).
|
// doing something weird (setting a locale not based on LANG).
|
||||||
#define NCOPTION_INHIBIT_SETLOCALE 0x0001ull
|
#define NCOPTION_INHIBIT_SETLOCALE 0x0001ull
|
||||||
|
|
||||||
// NCOPTION_VERIFY_PIXEL was removed in 2.2.3. It ought be repurposed. FIXME.
|
// We typically try to clear any preexisting bitmaps. If we ought *not* try
|
||||||
|
// to do this, pass NCOPTION_NO_CLEAR_BITMAPS. Note that they might still
|
||||||
|
// get cleared even if this is set, and they might not get cleared even if
|
||||||
|
// this is not set. It's a tough world out there.
|
||||||
|
#define NCOPTION_NO_CLEAR_BITMAPS 0x0002ull
|
||||||
|
|
||||||
// We typically install a signal handler for SIGWINCH that generates a resize
|
// We typically install a signal handler for SIGWINCH that generates a resize
|
||||||
// event in the notcurses_getc() queue. Set to inhibit this handler.
|
// event in the notcurses_getc() queue. Set to inhibit this handler.
|
||||||
|
@ -393,7 +393,7 @@ place_infoplane(struct ncdirect* ncd, int planeheight){
|
|||||||
}
|
}
|
||||||
struct notcurses_options opts = {
|
struct notcurses_options opts = {
|
||||||
.flags = NCOPTION_SUPPRESS_BANNERS | NCOPTION_INHIBIT_SETLOCALE
|
.flags = NCOPTION_SUPPRESS_BANNERS | NCOPTION_INHIBIT_SETLOCALE
|
||||||
| NCOPTION_NO_ALTERNATE_SCREEN,
|
| NCOPTION_NO_ALTERNATE_SCREEN | NCOPTION_NO_CLEAR_BITMAPS,
|
||||||
.margin_t = cury,
|
.margin_t = cury,
|
||||||
.margin_b = dimy - (cury + planeheight),
|
.margin_b = dimy - (cury + planeheight),
|
||||||
};
|
};
|
||||||
|
@ -321,7 +321,7 @@ typedef struct tinfo {
|
|||||||
// means leaving out the pixels (and likely resizes the string). for kitty,
|
// means leaving out the pixels (and likely resizes the string). for kitty,
|
||||||
// this means dialing down their alpha to 0 (in equivalent space).
|
// this means dialing down their alpha to 0 (in equivalent space).
|
||||||
int (*pixel_cell_wipe)(const struct notcurses* nc, sprixel* s, int y, int x);
|
int (*pixel_cell_wipe)(const struct notcurses* nc, sprixel* s, int y, int x);
|
||||||
int (*pixel_init)(const struct notcurses* nc);
|
int (*pixel_init)(int fd);
|
||||||
bool pixel_query_done; // have we yet performed pixel query?
|
bool pixel_query_done; // have we yet performed pixel query?
|
||||||
bool sextants; // do we have (good, vetted) Unicode 13 sextant support?
|
bool sextants; // do we have (good, vetted) Unicode 13 sextant support?
|
||||||
bool braille; // do we have Braille support? (linux console does not)
|
bool braille; // do we have Braille support? (linux console does not)
|
||||||
@ -730,8 +730,8 @@ sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int placey, int pl
|
|||||||
int parse_start);
|
int parse_start);
|
||||||
API int sprite_wipe_cell(const notcurses* nc, sprixel* s, int y, int x);
|
API int sprite_wipe_cell(const notcurses* nc, sprixel* s, int y, int x);
|
||||||
int sprite_kitty_annihilate(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s);
|
int sprite_kitty_annihilate(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s);
|
||||||
int sprite_kitty_init(const notcurses* nc);
|
int sprite_kitty_init(int fd);
|
||||||
int sprite_sixel_init(const notcurses* nc);
|
int sprite_sixel_init(int fd);
|
||||||
int sprite_sixel_annihilate(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s);
|
int sprite_sixel_annihilate(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s);
|
||||||
int sprite_init(const notcurses* nc);
|
int sprite_init(const notcurses* nc);
|
||||||
|
|
||||||
|
@ -285,6 +285,6 @@ int kitty_blit(ncplane* nc, int linesize, const void* data,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sprite_kitty_init(const notcurses* nc){
|
int sprite_kitty_init(int fd){
|
||||||
return tty_emit("\e_Ga=d\e\\", nc->ttyfd);
|
return tty_emit("\e_Ga=d\e\\", fd);
|
||||||
}
|
}
|
||||||
|
@ -1037,9 +1037,11 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if(ret->ttyfd >= 0){
|
if(ret->ttyfd >= 0){
|
||||||
if(sprite_init(ret)){
|
if(!(opts->flags & NCOPTION_NO_CLEAR_BITMAPS)){
|
||||||
free_plane(ret->stdplane);
|
if(sprite_init(ret)){
|
||||||
goto err;
|
free_plane(ret->stdplane);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(ret->tcache.smkx && tty_emit(ret->tcache.smkx, ret->ttyfd)){
|
if(ret->tcache.smkx && tty_emit(ret->tcache.smkx, ret->ttyfd)){
|
||||||
free_plane(ret->stdplane);
|
free_plane(ret->stdplane);
|
||||||
|
@ -551,9 +551,9 @@ int sixel_blit(ncplane* nc, int linesize, const void* data,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sprite_sixel_init(const notcurses* nc){
|
int sprite_sixel_init(int fd){
|
||||||
// \e[?8452: DECSDM private "sixel scrolling" mode keeps the sixel from
|
// \e[?8452: DECSDM private "sixel scrolling" mode keeps the sixel from
|
||||||
// scrolling, but puts it at the current cursor location (as opposed to
|
// scrolling, but puts it at the current cursor location (as opposed to
|
||||||
// the upper left corner of the screen).
|
// the upper left corner of the screen).
|
||||||
return tty_emit("\e[?8452h", nc->ttyfd);
|
return tty_emit("\e[?8452h", fd);
|
||||||
}
|
}
|
||||||
|
@ -77,5 +77,5 @@ int sprite_init(const notcurses* nc){
|
|||||||
if(!nc->tcache.pixel_init){
|
if(!nc->tcache.pixel_init){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return nc->tcache.pixel_init(nc);
|
return nc->tcache.pixel_init(nc->ttyfd);
|
||||||
}
|
}
|
||||||
|
@ -384,6 +384,7 @@ int query_term(tinfo* ti, int fd){
|
|||||||
if(ti->sixel_supported){
|
if(ti->sixel_supported){
|
||||||
query_sixel_details(ti, fd);
|
query_sixel_details(ti, fd);
|
||||||
}
|
}
|
||||||
|
ti->pixel_init(fd);
|
||||||
if(flags & O_NONBLOCK){
|
if(flags & O_NONBLOCK){
|
||||||
fcntl(fd, F_SETFL, flags);
|
fcntl(fd, F_SETFL, flags);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user