Skip to content

Commit

Permalink
stop supporting/advertising renderfp #2081
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Aug 21, 2021
1 parent eae4453 commit 3ad6e52
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 63 deletions.
11 changes: 4 additions & 7 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ typedef struct notcurses_options {
// the environment variable TERM is used. Failure to open the terminal
// definition will result in failure to initialize Notcurses.
const char* termtype;
// If non-NULL, notcurses_render() will write each rendered frame to this
// FILE* in addition to outfp. This is used primarily for debugging.
FILE* renderfp;
// Progressively higher log levels result in more logging to stderr. By
// default, nothing is printed to stderr once fullscreen service begins.
ncloglevel_e loglevel;
Expand Down Expand Up @@ -172,10 +169,10 @@ Setting `loglevel` to a value higher than `NCLOGLEVEL_SILENT` will cause
diagnostics to be printed to `stderr`: you could ensure `stderr` is redirected
if you make use of this functionality.
It's probably wise to export `NCOPTION_NO_ALTERNATE_SCREEN` to the user (e.g. via
command line option or environment variable). Developers and motivated users
might appreciate the ability to manipulate `loglevel` and `renderfp`. The
remaining options are typically of use only to application authors.
It's probably wise to export `NCOPTION_NO_ALTERNATE_SCREEN` to the user (e.g.
via command line option or environment variable). Motivated users might
appreciate the ability to manipulate `loglevel`. The remaining options are
typically of use only to application authors.
The Notcurses API draws almost entirely into the virtual buffers of `ncplane`s.
Only upon a call to `notcurses_render` will the visible terminal display be
Expand Down
2 changes: 1 addition & 1 deletion doc/man/man1/notcurses-demo.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ notcurses-demo - Show off some Notcurses features
# SYNOPSIS

**notcurses-demo** [**-h**|**--help**] [**-p** ***path***] [**-d** ***delaymult***]
[**-l** ***loglevel***] [**-f** ***renderfile***] [**-J** ***jsonfile***] [**-m** ***margins***]
[**-l** ***loglevel***] [**-J** ***jsonfile***] [**-m** ***margins***]
[**-V**|**--version**] [**-kc**] ***demospec***

# DESCRIPTION
Expand Down
1 change: 0 additions & 1 deletion doc/man/man3/notcurses_init.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ typedef enum {

typedef struct notcurses_options {
const char* termtype;
FILE* renderfp;
ncloglevel_e loglevel;
int margin_t, margin_r, margin_b, margin_l;
uint64_t flags; // from NCOPTION_* bits
Expand Down
4 changes: 1 addition & 3 deletions include/notcurses/notcurses.h
Original file line number Diff line number Diff line change
Expand Up @@ -898,9 +898,7 @@ typedef struct notcurses_options {
// the environment variable TERM is used. Failure to open the terminal
// definition will result in failure to initialize notcurses.
const char* termtype;
// If non-NULL, notcurses_render() will write each rendered frame to this
// FILE* in addition to outfp. This is used primarily for debugging.
FILE* renderfp;
FILE* renderfp; // deprecated, must be NULL, will be removed for ABI3 FIXME
// Progressively higher log levels result in more logging to stderr. By
// default, nothing is printed to stderr once fullscreen service begins.
ncloglevel_e loglevel;
Expand Down
16 changes: 1 addition & 15 deletions python/notcurses/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Notcurses_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)

GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "|O!sO!isO!O!O!O!K", keywords,
&PyLong_Type, &main_fd_object,
&term_type, &PyLong_Type, &render_fd_object, &log_level,
&term_type, &PyLong_Type, &log_level,
&margins_str,
&PyLong_Type, &margin_top, &PyLong_Type, &margin_right, &PyLong_Type, &margin_bottom, &PyLong_Type, &margin_left,
&flags));
Expand All @@ -91,20 +91,6 @@ Notcurses_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)

options.termtype = term_type;

if (NULL != render_fd_object)
{
long render_fd = GNU_PY_LONG_CHECK(render_fd_object);

FILE *renderfp = fdopen((int)render_fd, "w");
if (NULL == renderfp)
{
PyErr_SetString(PyExc_ValueError, "Failed to open render file descriptor.");
return NULL;
}

options.renderfp = renderfp;
}

options.loglevel = (ncloglevel_e)log_level;

if (NULL != margins_str)
Expand Down
1 change: 0 additions & 1 deletion rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ use libnotcurses_sys::*;
fn main() {
let options = ffi::notcurses_options {
termtype: null(),
renderfp: null_mut(),
loglevel: 0,
margin_t: 0,
margin_r: 0,
Expand Down
1 change: 0 additions & 1 deletion rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
//! fn main() {
//! let options = ffi::notcurses_options {
//! termtype: null(),
//! renderfp: null_mut(),
//! loglevel: 0,
//! margin_t: 0,
//! margin_r: 0,
Expand Down
1 change: 0 additions & 1 deletion rust/src/notcurses/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ impl NcOptions {
) -> Self {
Self {
termtype: null(),
renderfp: null_mut(),
loglevel,
margin_t: margin_t as i32,
margin_r: margin_r as i32,
Expand Down
30 changes: 2 additions & 28 deletions src/demo/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ usage(const char* exe, int status){
if(n) ncdirect_set_fg_rgb8(n, 0x80, 0xff, 0x80);
fprintf(out, "%s ", exe);
const char* options[] = { "-hVkc", "-m margins", "-p path", "-l loglevel",
"-d mult", "-J jsonfile", "-f renderfile", "demospec",
"-d mult", "-J jsonfile", "demospec",
NULL };
for(const char** op = options ; *op ; ++op){
usage_option(out, n, *op);
Expand All @@ -145,7 +145,6 @@ usage(const char* exe, int status){
"-k", "keep screen; do not switch to alternate",
"-d", "delay multiplier (non-negative float)",
"-J", "emit JSON summary to file",
"-f", "render to file (in addition to stdout)",
"-c", "constant PRNG seed, useful for benchmarking",
"-m", "margin, or 4 comma-separated margins",
NULL
Expand Down Expand Up @@ -243,7 +242,6 @@ ext_demos(struct notcurses* nc, const char* spec){
static const char*
handle_opts(int argc, char** argv, notcurses_options* opts, FILE** json_output){
bool constant_seed = false;
char *renderfile = NULL;
*json_output = NULL;
int c;
const struct option longopts[] = {
Expand All @@ -252,7 +250,7 @@ handle_opts(int argc, char** argv, notcurses_options* opts, FILE** json_output){
{ .name = NULL, .has_arg = 0, .flag = NULL, .val = 0, },
};
int lidx;
while((c = getopt_long(argc, argv, "VhckJ:l:r:d:f:p:m:", longopts, &lidx)) != EOF){
while((c = getopt_long(argc, argv, "VhckJ:l:d:p:m:", longopts, &lidx)) != EOF){
switch(c){
case 'h':
usage(*argv, EXIT_SUCCESS);
Expand Down Expand Up @@ -297,21 +295,9 @@ handle_opts(int argc, char** argv, notcurses_options* opts, FILE** json_output){
case 'k':
opts->flags |= NCOPTION_NO_ALTERNATE_SCREEN;
break;
case 'f':
if(opts->renderfp){
fprintf(stderr, "-f may only be supplied once\n");
usage(*argv, EXIT_FAILURE);
}
if((opts->renderfp = fopen(optarg, "wb")) == NULL){
usage(*argv, EXIT_FAILURE);
}
break;
case 'p':
datadir = optarg;
break;
case 'r':
renderfile = optarg;
break;
case 'd':{
float f;
if(sscanf(optarg, "%f", &f) != 1){
Expand All @@ -334,13 +320,6 @@ handle_opts(int argc, char** argv, notcurses_options* opts, FILE** json_output){
if(!constant_seed){
srand(time(NULL)); // a classic blunder lol
}
if(renderfile){
opts->renderfp = fopen(renderfile, "wb");
if(opts->renderfp == NULL){
fprintf(stderr, "Error opening %s for write\n", renderfile);
usage(*argv, EXIT_FAILURE);
}
}
if(optind < argc - 1){
fprintf(stderr, "Extra argument: %s\n", argv[optind + 1]);
usage(*argv, EXIT_FAILURE);
Expand Down Expand Up @@ -588,11 +567,6 @@ int main(int argc, char** argv){
if(notcurses_stop(nc)){
return EXIT_FAILURE;
}
if(nopts.renderfp){
if(fclose(nopts.renderfp)){
fprintf(stderr, "Warning: error closing renderfile\n");
}
}
struct ncdirect* ncd = ncdirect_init(NULL, stdout, 0);
if(!ncd){
return EXIT_FAILURE;
Expand Down
1 change: 0 additions & 1 deletion src/lib/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ typedef struct notcurses {
ncstats stashed_stats; // retain across a context reset, for closing banner

FILE* ttyfp; // FILE* for writing rasterized data
FILE* renderfp; // debugging FILE* to which renderings are written
tinfo tcache; // terminfo cache
pthread_mutex_t pilelock; // guards pile list, locks resize in render
bool suppress_banner; // from notcurses_options
Expand Down
1 change: 0 additions & 1 deletion src/lib/notcurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,6 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
reset_stats(&ret->stats.s);
reset_stats(&ret->stashed_stats);
ret->ttyfp = outfp;
ret->renderfp = opts->renderfp;
memset(&ret->rstate, 0, sizeof(ret->rstate));
memset(&ret->palette_damage, 0, sizeof(ret->palette_damage));
memset(&ret->palette, 0, sizeof(ret->palette));
Expand Down
3 changes: 0 additions & 3 deletions src/lib/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,9 +1266,6 @@ raster_and_write(notcurses* nc, ncpile* p, fbuf* f){
unblock_signals(&oldmask);
rasterize_sprixels_post(nc, p);
//fprintf(stderr, "%lu/%lu %lu/%lu %lu/%lu %d\n", nc->stats.defaultelisions, nc->stats.defaultemissions, nc->stats.fgelisions, nc->stats.fgemissions, nc->stats.bgelisions, nc->stats.bgemissions, ret);
if(nc->renderfp){
fprintf(nc->renderfp, "%s\n", (const char*)nc->rstate.f.buf);
}
if(ret < 0){
return ret;
}
Expand Down

0 comments on commit 3ad6e52

Please sign in to comment.