graphcurses

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

commit 55fe7e2f3236deff73a17b1ce4919dd9e5c36a8d
parent 4f7246be9ebb6771645a47f8ef471d22dfdfb136
Author: Christos Margiolis <christos@margiolis.net>
Date:   Fri, 13 Mar 2020 03:25:13 +0200

pending 'f' fix

Diffstat:
MREADME.md | 1+
Mbin/graphcurses | 0
Mobj/main.o | 0
Msrc/main.cpp | 20++++++--------------
4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/README.md b/README.md @@ -19,3 +19,4 @@ A simple ncurses graph generator. * *(Perhaps)* add derivative calculator * Fix axes plotting bug * Add point numbering on axes +* Fix function disappearing when pressing 'f' 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 @@ -142,8 +142,9 @@ void shift(Plane &plane, float xshift = 0.0f, float yshift = 0.0f) plane.ymax += yshift; } -void validate_expression(char *buffer, Plane &plane) +void validate_expression(Plane &plane) { + char *buffer = new char[256]; getfunc(buffer, plane); while (!(f = evaluator_create(buffer))) { @@ -151,7 +152,7 @@ void validate_expression(char *buffer, Plane &plane) getfunc(buffer, plane); refresh(); } - + delete[] buffer; } void handle_key(int key, Plane &plane) @@ -165,12 +166,7 @@ void handle_key(int key, Plane &plane) case '+': handle_zoom(plane, 1.0f/1.05f); break; case '-': handle_zoom(plane, 1.05f); break; case 'r': restore_zoom(plane); break; - case 'f': // don't repeat - { - char *buffer = new char[256]; - validate_expression(buffer, plane); - delete[] buffer; - } break; + case 'f': validate_expression(plane); break; } } @@ -178,14 +174,10 @@ int main(int argc, char **argv) { Plane plane; restore_zoom(plane); - int key = 0; - init_curses(); - - char *buffer = new char[256]; - validate_expression(buffer, plane); - delete[] buffer; + validate_expression(plane); std::function<float(float)> yfunc = evalf; + int key = 0; while (key != 'q') {