From b3e874a179f370fececc8098ae61d230cc215ed4 Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 3 Apr 2020 00:58:10 -0400 Subject: [PATCH] ncplot: fold minx, maxx into rangex --- include/notcurses/notcurses.h | 13 +++++++++++-- src/input/keyplot.cpp | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 3f6f7a9cd..ee7a1ea8d 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -2529,19 +2529,28 @@ typedef struct ncplot_options { ncgridgeom_e gridtype; // independent variable can either be a contiguous range, or a finite set // of keys. for a time range, say the previous hour sampled with second - // resolution, the independent variable would be the range [0..3960). - int64_t minx, maxx; + // resolution, the independent variable would be the range [0..3600): 3600. + uint64_t rangex; // y axis min and max. set the two equal (to any stand-in value; 0 is // recommended) for autodiscovery of range. int64_t miny, maxy; bool exponentialy; // is y-axis exponential? } ncplot_options; +// Use the provided plane 'n' for plotting according to the options 'opts'. +// The plot will make free use of the entirety of the plane. API struct ncplot* ncplot_create(struct ncplane* n, const ncplot_options* opts); // Return a reference to the ncplot's underlying ncplane. API struct ncplane* ncplot_plane(struct ncplot* n); +// Add to or set the value corresponding to this x. If x is beyond the current +// x window, the x window is advanced to include x, and values passing beyond +// the window are lost. The first call will place the initial window. The plot +// will be redrawn, but notcurses_render() is not called. +API int ncplot_add_sample(struct ncplot* n, uint64_t x, int64_t y); +API int ncplot_set_sample(struct ncplot* n, uint64_t x, int64_t y); + API void ncplot_destroy(struct ncplot* n); #undef API diff --git a/src/input/keyplot.cpp b/src/input/keyplot.cpp index 0fc88821a..0d0e1e00f 100644 --- a/src/input/keyplot.cpp +++ b/src/input/keyplot.cpp @@ -9,6 +9,10 @@ int main(void){ if(!nc.mouse_enable()){ return EXIT_FAILURE; } + std::unique_ptr n(nc.get_stdplane ()); + struct ncplot_options popts{}; + struct ncplot* plot = ncplot_create(*n, &popts); // FIXME + ncplot_destroy(plot); return EXIT_SUCCESS; }