progbar: remove egcs options

This commit is contained in:
nick black 2020-12-13 07:50:16 -05:00 committed by Nick Black
parent c3b5069eae
commit d56ea8b5e7
5 changed files with 7 additions and 20 deletions

View File

@ -1,6 +1,9 @@
This document attempts to list user-visible changes and any major internal This document attempts to list user-visible changes and any major internal
rearrangements of Notcurses. rearrangements of Notcurses.
* 2.1.1 (not yet released)
* Progress bars via `ncprogbar`. Standard widget API.
* 2.1.0 (2020-12-13) * 2.1.0 (2020-12-13)
* `cell` has been renamed `nccell`. The old name has been kept as an alias, * `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. but ought be considered deprecated. It will be removed in Notcurses 3.0.

View File

@ -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 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 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`. 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 // 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. // Return a reference to the ncprogbar's underlying ncplane.
#define NCPROGBAR_OPTION_RETROGRADE 0x0001u // proceed left/down #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 { typedef struct ncprogbar_options {
// channels for the maximum and minimum points. linear interpolation will be // channels for the maximum and minimum points. linear interpolation will be
// applied across the domain between these two. // applied across the domain between these two.
uint64_t maxchannels; uint64_t maxchannels;
uint64_t minchannels; 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; uint64_t flags;
} ncprogbar_options; } ncprogbar_options;
struct ncplane* ncprogbar_plane(struct ncprogbar* n); struct ncplane* ncprogbar_plane(struct ncprogbar* n);
// Set the progress bar's completion, a double 0 <= 'p' <= 1. // Set the progress bar's completion, a double 0 <= 'p' <= 1.

View File

@ -18,7 +18,6 @@ struct ncprogbar;
typedef struct ncprogbar_options { typedef struct ncprogbar_options {
uint64_t maxchannels; uint64_t maxchannels;
uint64_t minchannels; uint64_t minchannels;
const char egcs;
uint64_t flags; uint64_t flags;
} ncprogbar_options; } ncprogbar_options;
``` ```

View File

@ -3037,12 +3037,6 @@ typedef struct ncprogbar_options {
// and max must either be RGB, or both default, and alphas must match. // and max must either be RGB, or both default, and alphas must match.
uint64_t maxchannels; uint64_t maxchannels;
uint64_t minchannels; 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; uint64_t flags;
} ncprogbar_options; } ncprogbar_options;

View File

@ -59,7 +59,9 @@ progbar_redraw(ncprogbar* n){
} }
while(progress > 0 && progress < range){ while(progress > 0 && progress < range){
// FIXME lerp min->max // 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; progress += delt;
} }
return 0; return 0;