extern "C" { #include #include #include } #include #include "text_input.h" void draw_lines_from_center() { KDCoordinate width = SCREEN_WIDTH; KDCoordinate height = SCREEN_HEIGHT; KDColor c = 0xFF; KDPoint center = KDPointMake(width/2, height/2); int step = 2; for (KDCoordinate x=0; xapproximate(plotContext); KDCoordinate j = ((y-yMin)/(yMax-yMin)*screenHeight); KDPoint currentPoint = KDPointMake(i,screenHeight-j); if (i>0) { KDDrawLine(previousPoint, currentPoint, 0xFF); } previousPoint = currentPoint; } } void funnyPlot() { Expression * e = Expression::parse((char *)"1/x"); plot(e, 1.0f, 4.0f, 0.0f, 1.0f); delete e; } static void clear_screen() { KDRect r; r.x = 0; r.y = 0; r.width = SCREEN_WIDTH; r.height = SCREEN_HEIGHT; KDFillRect(r, 0x00); } static void interactive_expression_parsing() { while (1) { char * text_input = get_text(); clear_screen(); Expression * e = Expression::parse(text_input); if (e) { ExpressionLayout * l = e->createLayout(nullptr); if (l) { l->draw(KDPointMake(0,10)); delete l; } delete e; } else { KDDrawString("PARSING ERROR", KDPointMake(10,10)); } // We dealocate the memory allocated by get_text; free(text_input); } } void ion_app() { interactive_expression_parsing(); while (1) { ion_sleep(); } }