From d56ea8b5e77c65a693890680c0bfb9f8e433a377 Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 13 Dec 2020 07:50:16 -0500 Subject: [PATCH] progbar: remove egcs options --- NEWS.md | 3 +++ USAGE.md | 13 +------------ doc/man/man3/notcurses_progbar.3.md | 1 - include/notcurses/notcurses.h | 6 ------ src/lib/progbar.c | 4 +++- 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/NEWS.md b/NEWS.md index 737ee377e..d5156abc5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ This document attempts to list user-visible changes and any major internal rearrangements of Notcurses. +* 2.1.1 (not yet released) + * Progress bars via `ncprogbar`. Standard widget API. + * 2.1.0 (2020-12-13) * `cell` has been renamed `nccell`. The old name has been kept as an alias, but ought be considered deprecated. It will be removed in Notcurses 3.0. diff --git a/USAGE.md b/USAGE.md index 6649981e2..16dced778 100644 --- a/USAGE.md +++ b/USAGE.md @@ -2380,10 +2380,6 @@ lower values. The procession will take place along the longer dimension (at the time of each redraw), with the horizontal length scaled by 2 for purposes of comparison. I.e. for a plane of 20 rows and 50 columns, the progress will be to the right (50 > 40) or left with `OPTION_RETROGRADE`. -If `NCPROGBAR_OPTION_LOCK_ORIENTATION` is provided, the initial orientation -is locked in, despite any resizes. It locks horizontal progression by -default; `NCPROGBAR_OPTION_FORCE_VERTICAL` locks vertical progression. These -are recommended if you provide custom EGCs. ``` // Takes ownership of the ncplane 'n', which will be destroyed by @@ -2392,22 +2388,15 @@ struct ncprogbar* ncprogbar_create(struct ncplane* n, const ncprogbar_options* o // Return a reference to the ncprogbar's underlying ncplane. #define NCPROGBAR_OPTION_RETROGRADE 0x0001u // proceed left/down -#define NCPROGBAR_OPTION_LOCK_ORIENTATION 0x0002u // lock in orientation -#define NCPROGBAR_OPTION_FORCE_VERTICAL 0x0003u // lock in vert typedef struct ncprogbar_options { // channels for the maximum and minimum points. linear interpolation will be // applied across the domain between these two. uint64_t maxchannels; uint64_t minchannels; - // provide NULL for default (geometric) glyphs. otherwise, provide one or - // more EGCs to be used for the progress bar. the last EGC provided will be - // at the head of the progress. the first will be used for the entirety of - // the tail. i.e. "▃▅🭂🭍" might yield "▃▃▃▃▅🭂🭍". note that such a set of EGCs - // would not work well for a vertical progress bar. - const char egcs; uint64_t flags; } ncprogbar_options; + struct ncplane* ncprogbar_plane(struct ncprogbar* n); // Set the progress bar's completion, a double 0 <= 'p' <= 1. diff --git a/doc/man/man3/notcurses_progbar.3.md b/doc/man/man3/notcurses_progbar.3.md index 213dad7b6..25e0f8228 100644 --- a/doc/man/man3/notcurses_progbar.3.md +++ b/doc/man/man3/notcurses_progbar.3.md @@ -18,7 +18,6 @@ struct ncprogbar; typedef struct ncprogbar_options { uint64_t maxchannels; uint64_t minchannels; - const char egcs; uint64_t flags; } ncprogbar_options; ``` diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index d9081ab54..40e4c1922 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -3037,12 +3037,6 @@ typedef struct ncprogbar_options { // and max must either be RGB, or both default, and alphas must match. uint64_t maxchannels; uint64_t minchannels; - // provide NULL for default (geometric) glyphs. otherwise, provide one or - // more EGCs to be used for the progress bar. the last EGC provided will be - // at the head of the progress. the first will be used for the entirety of - // the tail. i.e. "▃▅🭂🭍" might yield "▃▃▃▃▅🭂🭍". note that such a set of EGCs - // would not work well for a vertical progress bar. - const char egcs; uint64_t flags; } ncprogbar_options; diff --git a/src/lib/progbar.c b/src/lib/progbar.c index 1f8728658..c3df8f0a0 100644 --- a/src/lib/progbar.c +++ b/src/lib/progbar.c @@ -59,7 +59,9 @@ progbar_redraw(ncprogbar* n){ } while(progress > 0 && progress < range){ // FIXME lerp min->max - ncplane_putchar_yx(ncprogbar_plane(n), 0, progress, 'X'); + if(ncplane_putegc_yx(ncprogbar_plane(n), 0, progress, "█", NULL) <= 0){ + return -1; + } progress += delt; } return 0;