Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
progbar.c File Reference
#include <string.h>
#include "internal.h"
Include dependency graph for progbar.c:

Go to the source code of this file.

Functions

ncprogbarncprogbar_create (ncplane *n, const ncprogbar_options *opts)
 
ncplanencprogbar_plane (ncprogbar *n)
 
int ncprogbar_set_progress (ncprogbar *n, double p)
 
double ncprogbar_progress (const ncprogbar *n)
 
void ncprogbar_destroy (ncprogbar *n)
 

Function Documentation

◆ ncprogbar_create()

ncprogbar * ncprogbar_create ( ncplane n,
const ncprogbar_options opts 
)

Definition at line 4 of file progbar.c.

4 {
5 ncprogbar_options default_opts;
6 if(opts == NULL){
7 memset(&default_opts, 0, sizeof(default_opts));
8 opts = &default_opts;
9 }
11 logwarn("invalid flags %016" PRIx64, opts->flags);
12 }
13 ncprogbar* ret = malloc(sizeof(*ret));
14 if(ret == NULL){
16 return NULL;
17 }
18 ret->ncp = n;
19 ret->ulchannel = opts->ulchannel;
20 ret->urchannel = opts->urchannel;
21 ret->blchannel = opts->blchannel;
22 ret->brchannel = opts->brchannel;
24 if(ncplane_set_widget(n, ret, (void(*)(void*))ncprogbar_destroy)){
26 free(ret);
27 return NULL;
28 }
29 return ret;
30}
free(duplicated)
#define logwarn(fmt,...)
Definition logging.h:37
int ncplane_destroy(ncplane *ncp)
Definition notcurses.c:1018
#define NCPROGBAR_OPTION_RETROGRADE
Definition notcurses.h:4203
const struct ncplane_options * opts
Definition notcurses.h:3483
vopts n
Definition notcurses.h:3502
void ncprogbar_destroy(ncprogbar *n)
Definition progbar.c:190
ncplane * ncp
Definition internal.h:225
uint32_t ulchannel
Definition internal.h:227
uint32_t blchannel
Definition internal.h:227
uint32_t urchannel
Definition internal.h:227
uint32_t brchannel
Definition internal.h:227
bool retrograde
Definition internal.h:228
return NULL
Definition termdesc.h:229
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncprogbar_destroy()

void ncprogbar_destroy ( ncprogbar n)

Definition at line 190 of file progbar.c.

190 {
191 if(n){
192 if(ncplane_set_widget(n->ncp, NULL, NULL) == 0){
193 ncplane_destroy(n->ncp);
194 }
195 free(n);
196 }
197}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncprogbar_plane()

ncplane * ncprogbar_plane ( ncprogbar n)

Definition at line 32 of file progbar.c.

32 {
33 return n->ncp;
34}
Here is the caller graph for this function:

◆ ncprogbar_progress()

double ncprogbar_progress ( const ncprogbar n)

Definition at line 186 of file progbar.c.

186 {
187 return n->progress;
188}
Here is the caller graph for this function:

◆ ncprogbar_set_progress()

int ncprogbar_set_progress ( ncprogbar n,
double  p 
)

Definition at line 176 of file progbar.c.

176 {
177//fprintf(stderr, "PROGRESS: %g\n", p);
178 if(p < 0 || p > 1){
179 logerror("invalid progress %g", p);
180 return -1;
181 }
182 n->progress = p;
183 return progbar_redraw(n);
184}
#define logerror(fmt,...)
Definition logging.h:32
Here is the caller graph for this function: