mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
remove the majority of notcurses_check_pixel_support() calls #1469
This commit is contained in:
parent
ca4a1c7fd8
commit
0d7a5a5ef8
9
NEWS.md
9
NEWS.md
@ -2,6 +2,15 @@ This document attempts to list user-visible changes and any major internal
|
||||
rearrangements of Notcurses.
|
||||
|
||||
* 2.3.5 (not yet released)
|
||||
* Happy day! The terminal interrogation routines in the initialization code
|
||||
have been completely revamped. The first outcome of this is that Sixel
|
||||
parameters are now opportunistically read at startup, and thus there is
|
||||
no longer any need to call `notcurses_check_pixel_support()` before
|
||||
using `NCBLIT_PIXEL`. If it's there, it'll be used; if not, it'll degrade
|
||||
or fail. Indeed, this function will likely be removed for ABI3. The new
|
||||
routines rely on the terminal answering the Send Device Attributes escape;
|
||||
if it does not, Notcurses may refuse to start, or even hang. Please report
|
||||
a bug if you run into this.
|
||||
* `CELL_ALPHA_*` macros are now `NCALPHA_*`. The former will remain
|
||||
`#define`d until ABI3.
|
||||
|
||||
|
@ -264,7 +264,7 @@ to breaking under incorrect `TERM` values. If you're not using `xterm`, your
|
||||
|
||||
* **Q:** How about *arbitrary image manipulation here* functionality? **A:** I'm not going to beat ImageMagick et al. on image manipulation, but you can load an `ncvisual` from RGBA memory using `ncvisual_from_rgba()`.
|
||||
|
||||
* **Q:** My program locks up when I run `notcurses_check_pixel_support()`. **A**: Detecting bitmap support requires interrogating the terminal. If the terminal doesn't reply to standard interrogations, send upstream a patch, or use a different terminal. Generally, only old and unsupported terminal emulators exhibit this behavior.
|
||||
* **Q:** My program locks up during initialization. **A**: Notcurses interrogates the terminal. If the terminal doesn't reply to standard interrogations, file a Notcurses bug, send upstream a patch, or use a different terminal. Generally, only old and unsupported terminal emulators exhibit this behavior.
|
||||
|
||||
* **Q:** How do I mix Rendered and Direct mode? **A:** You really don't want to. You can stream a subprocess to a plane with the `ncsubproc` widget.
|
||||
|
||||
|
6
USAGE.md
6
USAGE.md
@ -942,10 +942,8 @@ ncplane_dim_x(const struct ncplane* n){
|
||||
|
||||
// Retrieve pixel geometry for the display region ('pxy', 'pxx'), each cell
|
||||
// ('celldimy', 'celldimx'), and the maximum displayable bitmap ('maxbmapy',
|
||||
// 'maxbmapx'). Note that this will call notcurses_check_pixel_support(),
|
||||
// possibly leading to an interrogation of the terminal. If bitmaps are not
|
||||
// supported, 'maxbmapy' and 'maxbmapx' will be 0. Any of the geometry
|
||||
// arguments may be NULL.
|
||||
// 'maxbmapx'). If bitmaps are not supported, 'maxbmapy' and 'maxbmapx' will
|
||||
// be 0. Any of the geometry arguments may be NULL.
|
||||
void ncplane_pixelgeom(struct ncplane* n, int* restrict pxy, int* restrict pxx,
|
||||
int* restrict celldimy, int* restrict celldimx,
|
||||
int* restrict maxbmapy, int* restrict maxbmapx);
|
||||
|
@ -87,8 +87,7 @@ quadrants and halfblocks, respectively. **notcurses_canbraille** returns
|
||||
these functions return **true** unless UTF-8 encoding is in use.
|
||||
|
||||
**notcurses_check_pixel_support** returns 1 if bitmap support (via any
|
||||
mechanism) is detected; **NCBLIT_PIXEL** can be used after such a return.
|
||||
It returns 0 a lack of bitmap support was confirmed, and -1 on error.
|
||||
mechanism) has been detected, and otherwise 0.
|
||||
|
||||
# NOTES
|
||||
|
||||
|
@ -363,10 +363,7 @@ plane when scrolling is enabled).
|
||||
return the size of the plane in pixels. **celldimy** and **celldimx** return
|
||||
the size of a cell in pixels (these ought be the same across planes).
|
||||
**maxbmapy** and **maxbmapx** describe the largest bitmap which can be
|
||||
displayed in the plane. This function transitively calls
|
||||
**notcurses_check_pixel_support**, possibly leading to terminal interrogation
|
||||
(see **notcurses_capabilities(3)** for why this may be undesirable). Any
|
||||
parameter (save **n**) may be **NULL**.
|
||||
displayed in the plane. Any parameter (save **n**) may be **NULL**.
|
||||
|
||||
When a plane is blitted to using **ncvisual_render** and **NCBLIT_PIXEL** (see
|
||||
**notcurses_visual(3)**), it ceases to accept cell-based output. The sprixel
|
||||
|
@ -254,14 +254,6 @@ information.
|
||||
# PIXEL BLITTING
|
||||
|
||||
Some terminals support pixel-based output via one of a number of protocols.
|
||||
Checking for bitmap support requires interrogating the terminal and reading a
|
||||
response. This takes time, and will never complete if the terminal doesn't
|
||||
respond. Notcurses will not do so without an explicit request from the client
|
||||
code. Before **NCBLIT_PIXEL** can be used, it is thus necessary to call
|
||||
**notcurses_check_pixel_support**. If this function has not successfully
|
||||
returned, attempts to use **NCBLIT_PIXEL** will fall back to cell-based
|
||||
blitting (or fail, if **NCVISUAL_OPTION_NODEGRADE** is used).
|
||||
|
||||
**NCBLIT_PIXEL** has some stringent requirements on the type of planes it can
|
||||
be used with; it is usually best to let **ncvisual_render** create the backing
|
||||
plane by providing a **NULL** value for **n**. If you must bring your own
|
||||
|
@ -246,9 +246,7 @@ API bool ncdirect_canopen_images(const struct ncdirect* n)
|
||||
API bool ncdirect_canutf8(const struct ncdirect* n)
|
||||
__attribute__ ((nonnull (1)));
|
||||
|
||||
// This function must successfully return before NCBLIT_PIXEL is available.
|
||||
// Returns -1 on error, 0 for no support, or 1 if pixel output is supported.
|
||||
// Must not be called concurrently with either input or rasterization.
|
||||
// Can we blit pixel-accurate bitmaps?
|
||||
API int ncdirect_check_pixel_support(struct ncdirect* n)
|
||||
__attribute__ ((nonnull (1)));
|
||||
|
||||
|
@ -1122,10 +1122,8 @@ ncplane_dim_x(const struct ncplane* n){
|
||||
|
||||
// Retrieve pixel geometry for the display region ('pxy', 'pxx'), each cell
|
||||
// ('celldimy', 'celldimx'), and the maximum displayable bitmap ('maxbmapy',
|
||||
// 'maxbmapx'). Note that this will call notcurses_check_pixel_support(),
|
||||
// possibly leading to an interrogation of the terminal. If bitmaps are not
|
||||
// supported, 'maxbmapy' and 'maxbmapx' will be 0. Any of the geometry
|
||||
// arguments may be NULL.
|
||||
// 'maxbmapx'). If bitmaps are not supported, 'maxbmapy' and 'maxbmapx' will
|
||||
// be 0. Any of the geometry arguments may be NULL.
|
||||
API void ncplane_pixelgeom(struct ncplane* n, int* RESTRICT pxy, int* RESTRICT pxx,
|
||||
int* RESTRICT celldimy, int* RESTRICT celldimx,
|
||||
int* RESTRICT maxbmapy, int* RESTRICT maxbmapx)
|
||||
@ -1292,9 +1290,7 @@ API bool notcurses_cansextant(const struct notcurses* nc)
|
||||
API bool notcurses_canbraille(const struct notcurses* nc)
|
||||
__attribute__ ((nonnull (1)));
|
||||
|
||||
// This function must successfully return before NCBLIT_PIXEL is available.
|
||||
// Returns -1 on error, 0 for no support, or 1 if pixel output is supported.
|
||||
// Must not be called concurrently with either input or rasterization.
|
||||
// Can we blit pixel-accurate bitmaps?
|
||||
API int notcurses_check_pixel_support(struct notcurses* nc)
|
||||
__attribute__ ((nonnull (1)));
|
||||
|
||||
|
@ -578,7 +578,6 @@ display_thread(void* vmarshal){
|
||||
struct marshal* m = vmarshal;
|
||||
drawpalette(m->nc);
|
||||
if(ncdirect_canopen_images(m->nc)){
|
||||
ncdirect_check_pixel_support(m->nc);
|
||||
if(m->logo){
|
||||
if(ncdirect_render_image(m->nc, m->logo, NCALIGN_CENTER,
|
||||
NCBLIT_PIXEL, NCSCALE_SCALE_HIRES) == 0){
|
||||
|
@ -37,7 +37,6 @@ int main(void){
|
||||
if(nc == NULL){
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
notcurses_check_pixel_support(nc);
|
||||
notcurses_debug_caps(nc, mstream);
|
||||
if(fclose(mstream)){
|
||||
notcurses_stop(nc);
|
||||
|
@ -405,7 +405,7 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
|
||||
if(ti->color_registers >= 64){
|
||||
setup_sixel_bitmaps(ti);
|
||||
}
|
||||
if(!nocbreak){
|
||||
if(nocbreak){
|
||||
if(fd >= 0){
|
||||
if(tcsetattr(fd, TCSANOW, &ti->tpreserved)){
|
||||
ncinputlayer_stop(&ti->input);
|
||||
|
@ -266,7 +266,6 @@ int main(int argc, char* const * argv){
|
||||
blitter,
|
||||
scale,
|
||||
};
|
||||
ctx.nc.check_pixel_support();
|
||||
keep_working = true;
|
||||
for(auto s = 0u ; s < procs ; ++s){
|
||||
threads.emplace_back(std::thread(ncls_thread, &ctx));
|
||||
|
Loading…
x
Reference in New Issue
Block a user