graphcurses

Curses 2D graph generator
git clone git://git.christosmarg.xyz/graphcurses.git
Log | Files | Refs | README | LICENSE

commit 4f7246be9ebb6771645a47f8ef471d22dfdfb136
parent cbd8a69495d9846ec8bf6d3376106b4a6cf4f453
Author: Christos Margiolis <christos@margiolis.net>
Date:   Fri, 13 Mar 2020 01:59:47 +0200

changed func pointer to lambda

Diffstat:
Mbin/graphcurses | 0
Mobj/main.o | 0
Msrc/main.cpp | 8++++----
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bin/graphcurses b/bin/graphcurses Binary files differ. diff --git a/obj/main.o b/obj/main.o Binary files differ. diff --git a/src/main.cpp b/src/main.cpp @@ -1,5 +1,6 @@ #include <ncurses.h> #include <iostream> +#include <functional> #include <cmath> #include <matheval.h> @@ -17,7 +18,6 @@ typedef struct float xscale, yscale; } Plane; -typedef float (*YFunc)(float x); void *f = nullptr; void *fd = nullptr; float evalf(float x) {return evaluator_evaluate_x(f, x);} @@ -30,7 +30,7 @@ void init_curses() curs_set(0); keypad(stdscr, true); start_color(); - init_pair(1, COLOR_GREEN, COLOR_BLACK); + init_pair(1, COLOR_WHITE, COLOR_BLACK); init_pair(2, COLOR_YELLOW, COLOR_BLACK); } @@ -108,7 +108,7 @@ void plot(Plane &plane, float x, float y) mvwaddch(stdscr, yp, xp, '.'); } -void draw_graph(Plane &plane, YFunc yfunc) +void draw_graph(Plane &plane, const std::function<float(float)>& yfunc) { float xstep; float ystep; @@ -185,7 +185,7 @@ int main(int argc, char **argv) char *buffer = new char[256]; validate_expression(buffer, plane); delete[] buffer; - YFunc yfunc = evalf; + std::function<float(float)> yfunc = evalf; while (key != 'q') {