diff --git a/cmenu/platform.h b/cmenu/platform.h index 2447e92..9f4f105 100644 --- a/cmenu/platform.h +++ b/cmenu/platform.h @@ -11,18 +11,15 @@ typedef struct Color { #define WHITE ((Color){255,255,255}) #define BLACK ((Color){0,0,0}) -typedef enum Key { - Key_backspace, - Key_ctrl, - Key_enter, - Key_h, - Key_n, - Key_p, - Key_y, - Count_Key -} Key; +typedef enum Action { + Action_Backspace, + Action_Select, + Action_Next, + Action_Previous, + Count_Action +} Action; -bool KeyPressed(Key key); +bool ActionPressed(Action key); bool InputGetNextPrintable(char const *out_key); typedef struct Cell { diff --git a/cmenu/str.c b/cmenu/str.c index d97c919..385c583 100644 --- a/cmenu/str.c +++ b/cmenu/str.c @@ -42,6 +42,8 @@ bool StringSub(String string, int start, int end, String *out_substr) { return start_ok && end_ok; } +// TODO: foobar + String StringFromCString(unsigned char const *s) { size_t size = 0; while (s[size] != '\0') { size++; } @@ -50,8 +52,3 @@ String StringFromCString(unsigned char const *s) { .size=size, }; } -typedef struct String { - unsigned char const *buffer; - size_t size; -} String; - diff --git a/cmenu/str.h b/cmenu/str.h index 5ef5720..183d842 100644 --- a/cmenu/str.h +++ b/cmenu/str.h @@ -1,4 +1,7 @@ +#ifndef STRING_HEADER +#define STRING_HEADER #include +#include typedef struct String { unsigned char const *buffer; @@ -8,4 +11,5 @@ typedef struct String { #define STRING(content) ((String){.buffer=#content, .size=sizeof(#content)-1}) bool StringSub(String string, int start, int end, String *out_substr); -String StringFromCString(char const *s); +String StringFromCString(unsigned char const *s); +#endif// STRING_HEADER