diff --git a/app/app.cpp b/app/app.cpp index d1c9814da..1a8854e54 100644 --- a/app/app.cpp +++ b/app/app.cpp @@ -73,7 +73,7 @@ static void interactive_expression_parsing() { } delete e; } else { - KDDrawString("PARSING ERROR", KDPointMake(10,10)); + KDDrawString("PARSING ERROR", KDPointMake(10,10), 0); } // We dealocate the memory allocated by get_text; free(text_input); diff --git a/app/utils.cpp b/app/utils.cpp index f0e1c16d4..62ef83a00 100644 --- a/app/utils.cpp +++ b/app/utils.cpp @@ -30,8 +30,8 @@ static void print_prompt(char* text, int index) { KDSize font_size = KDStringSize(tmp); KDDrawLine(KDPointMake(0, SCREEN_HEIGHT - PROMPT_HEIGHT), KDPointMake(SCREEN_WIDTH, SCREEN_HEIGHT - PROMPT_HEIGHT), 0xff); - KDDrawString(text, KDPointMake(0, SCREEN_HEIGHT - (PROMPT_HEIGHT / 2))); - KDDrawInverseChar(text[index], KDPointMake(index * font_size.width, SCREEN_HEIGHT - (PROMPT_HEIGHT / 2))); + KDDrawString(text, KDPointMake(0, SCREEN_HEIGHT - (PROMPT_HEIGHT / 2)), 0); + KDDrawChar(text[index], KDPointMake(index * font_size.width, SCREEN_HEIGHT - (PROMPT_HEIGHT / 2)), true); } char* get_text() { diff --git a/kandinsky/include/kandinsky/text.h b/kandinsky/include/kandinsky/text.h index 7a88d3051..955fc0755 100644 --- a/kandinsky/include/kandinsky/text.h +++ b/kandinsky/include/kandinsky/text.h @@ -3,9 +3,8 @@ #include -void KDDrawChar(char character, KDPoint p); -void KDDrawInverseChar(char character, KDPoint p); -void KDDrawString(const char * text, KDPoint p); +void KDDrawChar(char character, KDPoint p, uint8_t inverse); +void KDDrawString(const char * text, KDPoint p, uint8_t inverse); KDSize KDStringSize(char * text); #endif diff --git a/kandinsky/src/text.c b/kandinsky/src/text.c index 0563743d0..9520b0890 100644 --- a/kandinsky/src/text.c +++ b/kandinsky/src/text.c @@ -3,26 +3,21 @@ #include #include "font.h" -void KDDrawChar(char character, KDPoint p) { +void KDDrawChar(char character, KDPoint p, uint8_t inverse) { for (int j=0; j #include "string_layout.h" -StringLayout::StringLayout(const char * string, size_t length) : +StringLayout::StringLayout(const char * string, size_t length, uint8_t inverse) : ExpressionLayout() { assert(string[length] == 0); // Assert NULL-termination m_string = (char *)malloc(sizeof(char)*(length+1)); memcpy(m_string, string, (length+1)); + m_inverse = inverse; } StringLayout::~StringLayout() { @@ -18,7 +19,7 @@ ExpressionLayout * StringLayout::child(uint16_t index) { } void StringLayout::render(KDPoint point) { - KDDrawString(m_string, point); + KDDrawString(m_string, point, m_inverse); } KDPoint StringLayout::positionOfChild(ExpressionLayout * child) { diff --git a/poincare/src/layout/string_layout.h b/poincare/src/layout/string_layout.h index 0c5de9546..edaed8e3b 100644 --- a/poincare/src/layout/string_layout.h +++ b/poincare/src/layout/string_layout.h @@ -6,7 +6,10 @@ class StringLayout : public ExpressionLayout { public: - StringLayout(const char * string, size_t length); + // Here the inverse is a uint8_t instead of a bool, because the size of a bool is + // not standardized, thus since we call a foreign C function with this value we want to be + // sure about compatibility. + StringLayout(const char * string, size_t length, uint8_t inverse=0); ~StringLayout(); protected: void render(KDPoint point) override; @@ -15,6 +18,7 @@ class StringLayout : public ExpressionLayout { KDPoint positionOfChild(ExpressionLayout * child) override; private: char * m_string; + bool m_inverse; }; #endif diff --git a/quiz/src/runner.c b/quiz/src/runner.c index bb76367cb..7fc170be2 100644 --- a/quiz/src/runner.c +++ b/quiz/src/runner.c @@ -6,7 +6,7 @@ void print(char * message) { static int line_y = 0; int line_height = KDStringSize("M").height; - KDDrawString(message, (KDPoint){.x = 0, .y = line_y}); + KDDrawString(message, (KDPoint){.x = 0, .y = line_y}, 0); line_y += line_height; if (line_y > SCREEN_HEIGHT) { line_y = 0;