mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
move remainder of debug_caps into notcurses-info #1793
This commit is contained in:
parent
5998b965c4
commit
383678da4e
5
NEWS.md
5
NEWS.md
@ -2,7 +2,10 @@ This document attempts to list user-visible changes and any major internal
|
||||
rearrangements of Notcurses.
|
||||
|
||||
* 2.3.6 (not yet released)
|
||||
* Remove `NCSTYLE_{INVIS,BLINK,STANDOUT}` with extreme prejudice.
|
||||
* Remove `NCSTYLE_{INVIS,BLINK,STANDOUT}` with extreme prejudice. They
|
||||
remain defined for now, but will be removed for ABI3.
|
||||
* Deprecated `notcurses_debug_caps()`, which no longer generates output.
|
||||
Hey, I explicitly commented that its output was "subject to change".
|
||||
|
||||
* 2.3.5 (2021-06-23)
|
||||
* Happy day! The terminal interrogation routines in the initialization code
|
||||
|
@ -663,6 +663,7 @@ API int nccell_duplicate(struct ncplane* n, nccell* targ, const nccell* c);
|
||||
// Release resources held by the nccell 'c'.
|
||||
API void nccell_release(struct ncplane* n, nccell* c);
|
||||
|
||||
// FIXME for abi3, flatten these back down and recover the contiguous bits
|
||||
#define NCSTYLE_MASK 0x07ffu
|
||||
#define NCSTYLE_UNDERCURL 0x0400u
|
||||
#define NCSTYLE_STRUCK 0x0200u
|
||||
@ -3819,11 +3820,6 @@ API void ncreader_destroy(struct ncreader* n, char** contents);
|
||||
API void notcurses_debug(const struct notcurses* nc, FILE* debugfp)
|
||||
__attribute__ ((nonnull (1, 2)));
|
||||
|
||||
// Dump selected configuration capabilities to 'debugfp'. Output is freeform,
|
||||
// newline-delimited, and subject to change.
|
||||
API void notcurses_debug_caps(const struct notcurses* nc, FILE* debugfp)
|
||||
__attribute__ ((nonnull (1, 2)));
|
||||
|
||||
// DEPRECATED MATERIAL, GOING AWAY IN ABI3
|
||||
|
||||
__attribute__ ((deprecated)) static inline int
|
||||
@ -4358,6 +4354,9 @@ API int notcurses_render_to_file(struct notcurses* nc, FILE* fp)
|
||||
|
||||
typedef nccell cell; // FIXME backwards-compat, remove in ABI3
|
||||
|
||||
API void notcurses_debug_caps(const struct notcurses* nc, FILE* debugfp)
|
||||
__attribute__ ((deprecated)) __attribute__ ((nonnull (1, 2)));
|
||||
|
||||
#define CELL_ALPHA_HIGHCONTRAST NCALPHA_HIGHCONTRAST
|
||||
#define CELL_ALPHA_TRANSPARENT NCALPHA_TRANSPARENT
|
||||
#define CELL_ALPHA_BLEND NCALPHA_BLEND
|
||||
|
@ -793,7 +793,6 @@ pub use ffi::{
|
||||
notcurses_cursor_enable,
|
||||
notcurses_cursor_yx,
|
||||
notcurses_debug,
|
||||
notcurses_debug_caps,
|
||||
notcurses_detected_terminal,
|
||||
notcurses_drop_planes,
|
||||
notcurses_getc,
|
||||
|
@ -299,17 +299,6 @@ impl Nc {
|
||||
}
|
||||
}
|
||||
|
||||
/// Dumps selected configuration capabilities to 'debugfp'.
|
||||
///
|
||||
/// Output is freeform, and subject to change.
|
||||
///
|
||||
/// *C style function: [notcurses_debug_caps()][crate::notcurses_debug_caps].*
|
||||
pub fn debug_caps(&self, debugfp: &mut NcFile) {
|
||||
unsafe {
|
||||
crate::notcurses_debug_caps(self, debugfp.as_nc_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the name of the detected terminal.
|
||||
///
|
||||
/// *C style function: [notcurses_detected_terminal()][crate::notcurses_detected_terminal].*
|
||||
|
@ -30,7 +30,6 @@
|
||||
// fm notcurses_cursor_enable
|
||||
// f notcurses_cursor_yx
|
||||
// fmt notcurses_debug
|
||||
// fm notcurses_debug_caps
|
||||
//~f notcurses_detected_terminal
|
||||
// fmt notcurses_drop_planes
|
||||
// fm notcurses_getc
|
||||
|
@ -21,8 +21,25 @@ writen(int fd, const void* buf, size_t len){
|
||||
return w;
|
||||
}
|
||||
|
||||
static inline wchar_t
|
||||
capbool(const tinfo* ti, bool cap){
|
||||
if(ti->caps.utf8){
|
||||
return cap ? L'✓' : L'✖';
|
||||
}else{
|
||||
return cap ? '+' : '-';
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
unicodedumper(FILE* fp, tinfo* ti){
|
||||
unicodedumper(const struct notcurses* nc, FILE* fp, tinfo* ti, const char* indent){
|
||||
fprintf(fp, "%sutf8%lc quad%lc sex%lc braille%lc images%lc videos%lc\n",
|
||||
indent,
|
||||
capbool(ti, ti->caps.utf8),
|
||||
capbool(ti, ti->caps.quadrants),
|
||||
capbool(ti, ti->caps.sextants),
|
||||
capbool(ti, ti->caps.braille),
|
||||
capbool(ti, notcurses_canopen_images(nc)),
|
||||
capbool(ti, notcurses_canopen_videos(nc)));
|
||||
if(ti->caps.utf8){
|
||||
fprintf(fp, " {%ls} {%ls} ⎧%.122ls⎫ ⎧█ ⎫ 🯰🯱\n",
|
||||
NCHALFBLOCKS, NCQUADBLOCKS, NCSEXBLOCKS);
|
||||
@ -50,6 +67,20 @@ unicodedumper(FILE* fp, tinfo* ti){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
tinfo_debug_bitmaps(const tinfo* ti, FILE* fp, const char* indent){
|
||||
if(!ti->pixel_draw){
|
||||
fprintf(fp, "%sdidn't detect bitmap graphics support\n", indent);
|
||||
}else if(ti->sixel_maxy){
|
||||
fprintf(fp, "%smax sixel size: %dx%d colorregs: %u\n",
|
||||
indent, ti->sixel_maxy, ti->sixel_maxx, ti->color_registers);
|
||||
}else if(ti->color_registers){
|
||||
fprintf(fp, "%ssixel colorregs: %u\n", indent, ti->color_registers);
|
||||
}else{
|
||||
fprintf(fp, "%srgba pixel graphics supported\n", indent);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tinfo_debug_style(const tinfo* ti, FILE* fp, const char* name, int esc, int deesc){
|
||||
const char* code = get_escape(ti, esc);
|
||||
@ -63,6 +94,33 @@ tinfo_debug_style(const tinfo* ti, FILE* fp, const char* name, int esc, int dees
|
||||
}
|
||||
}
|
||||
|
||||
static inline wchar_t
|
||||
capyn(const tinfo* ti, const char* cap){
|
||||
return capbool(ti, cap);
|
||||
}
|
||||
|
||||
static void
|
||||
tinfo_debug_caps(const tinfo* ti, FILE* debugfp, const char* indent){
|
||||
fprintf(debugfp, "%srgb%lc ccc%lc af%lc ab%lc appsync%lc u7%lc cup%lc vpa%lc hpa%lc sgr%lc sgr0%lc op%lc fgop%lc bgop%lc\n",
|
||||
indent,
|
||||
capbool(ti, ti->caps.rgb),
|
||||
capbool(ti, ti->caps.can_change_colors),
|
||||
capyn(ti, get_escape(ti, ESCAPE_SETAF)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_SETAB)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_BSU)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_DSRCPR)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_CUP)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_VPA)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_HPA)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_SGR)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_SGR0)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_OP)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_FGOP)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_BGOP)));
|
||||
fprintf(debugfp, "%sbackground of 0x%06lx is %sconsidered transparent\n", indent, ti->bg_collides_default & 0xfffffful,
|
||||
(ti->bg_collides_default & 0x01000000) ? "" : "not ");
|
||||
}
|
||||
|
||||
static void
|
||||
tinfo_debug_styles(const tinfo* ti, FILE* debugfp, const char* indent){
|
||||
fprintf(debugfp, "%s", indent);
|
||||
@ -95,9 +153,11 @@ int main(void){
|
||||
if(nc == NULL){
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
notcurses_debug_caps(nc, mstream);
|
||||
tinfo_debug_styles(&nc->tcache, mstream, " ");
|
||||
unicodedumper(mstream, &nc->tcache);
|
||||
const char indent[] = " ";
|
||||
tinfo_debug_caps(&nc->tcache, mstream, indent);
|
||||
tinfo_debug_styles(&nc->tcache, mstream, indent);
|
||||
tinfo_debug_bitmaps(&nc->tcache, mstream, indent);
|
||||
unicodedumper(nc, mstream, &nc->tcache, indent);
|
||||
if(fclose(mstream)){
|
||||
notcurses_stop(nc);
|
||||
fprintf(stderr, "Error closing memstream after %zuB\n", len);
|
||||
|
@ -2,71 +2,10 @@
|
||||
|
||||
int loglevel = NCLOGLEVEL_SILENT;
|
||||
|
||||
static inline wchar_t
|
||||
capbool(const tinfo* ti, bool cap){
|
||||
if(ti->caps.utf8){
|
||||
return cap ? L'✓' : L'✖';
|
||||
}else{
|
||||
return cap ? '+' : '-';
|
||||
}
|
||||
}
|
||||
|
||||
static inline wchar_t
|
||||
capyn(const tinfo* ti, const char* cap){
|
||||
return capbool(ti, cap);
|
||||
}
|
||||
|
||||
static void
|
||||
tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
|
||||
unsigned images, unsigned videos){
|
||||
const char indent[] = " ";
|
||||
fprintf(debugfp, "%srgb%lc ccc%lc af%lc ab%lc appsync%lc u7%lc cup%lc vpa%lc hpa%lc sgr%lc sgr0%lc op%lc fgop%lc bgop%lc\n",
|
||||
indent,
|
||||
capbool(ti, ti->caps.rgb),
|
||||
capbool(ti, ti->caps.can_change_colors),
|
||||
capyn(ti, get_escape(ti, ESCAPE_SETAF)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_SETAB)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_BSU)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_DSRCPR)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_CUP)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_VPA)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_HPA)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_SGR)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_SGR0)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_OP)),
|
||||
capyn(ti, get_escape(ti, ESCAPE_FGOP)),
|
||||
capyn(ti, 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->pixel_draw){
|
||||
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",
|
||||
indent, ti->sixel_maxy, ti->sixel_maxx, ti->color_registers);
|
||||
}else if(ti->color_registers){
|
||||
fprintf(debugfp, "%ssixel colorregs: %u\n", indent, ti->color_registers);
|
||||
}else{
|
||||
fprintf(debugfp, "%srgba pixel graphics supported\n", indent);
|
||||
}
|
||||
fprintf(debugfp, "%sutf8%lc quad%lc sex%lc braille%lc images%lc videos%lc\n",
|
||||
indent,
|
||||
capbool(ti, ti->caps.utf8),
|
||||
capbool(ti, ti->caps.quadrants),
|
||||
capbool(ti, ti->caps.sextants),
|
||||
capbool(ti, ti->caps.braille),
|
||||
capbool(ti, images),
|
||||
capbool(ti, videos));
|
||||
fprintf(debugfp, "%sbackground of 0x%06lx is %sconsidered transparent\n", indent, ti->bg_collides_default & 0xfffffful,
|
||||
(ti->bg_collides_default & 0x01000000) ? "" : "not ");
|
||||
}
|
||||
|
||||
void notcurses_debug_caps(const notcurses* nc, FILE* debugfp){
|
||||
int rows, cols;
|
||||
notcurses_stddim_yx_const(nc, &rows, &cols);
|
||||
bool images, videos;
|
||||
images = notcurses_canopen_images(nc);
|
||||
videos = notcurses_canopen_videos(nc);
|
||||
tinfo_debug_caps(&nc->tcache, debugfp, rows, cols, images, videos);
|
||||
// FIXME deprecated, remove for ABI3
|
||||
(void)nc;
|
||||
(void)debugfp;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -886,10 +886,11 @@ init_banner(const notcurses* nc){
|
||||
nc->tcache.termversion ? nc->tcache.termversion : "");
|
||||
term_fg_palindex(nc, stdout, 12 % nc->tcache.caps.colors);
|
||||
if(nc->tcache.cellpixy && nc->tcache.cellpixx){
|
||||
printf("\n %d rows (%dpx) %d cols (%dpx) (%sB) %zuB crend %d colors",
|
||||
printf("\n %d rows (%dpx) %d cols (%dpx) %dx%d %zuB crend %d colors",
|
||||
nc->stdplane->leny, nc->tcache.cellpixy,
|
||||
nc->stdplane->lenx, nc->tcache.cellpixx,
|
||||
bprefix(nc->stats.fbbytes, 1, prefixbuf, 0),
|
||||
nc->stdplane->leny * nc->tcache.cellpixy,
|
||||
nc->stdplane->lenx * nc->tcache.cellpixx,
|
||||
sizeof(struct crender), nc->tcache.caps.colors);
|
||||
}else{
|
||||
printf("\n %d rows %d cols (%sB) %zuB crend %d colors",
|
||||
|
Loading…
x
Reference in New Issue
Block a user