sorta kinda working on strings for cmenu. being lazy

This commit is contained in:
Ivar Fatland
2026-07-23 00:18:08 +02:00
parent afda89797a
commit a7507bb431
6 changed files with 157 additions and 8 deletions
+28 -8
View File
@@ -4,6 +4,8 @@
#include <stdint.h>
#include <stdbool.h>
#include "utf.h"
typedef struct Color {
uint8_t r, g, b;
} Color;
@@ -22,23 +24,41 @@ typedef enum Key {
Count_Key
} Key;
typedef uint32_t CodePoint;
bool KeyPressed(Key key);
bool InputGetNextPrintable(CodePoint const *out_key);
typedef struct Cell {
CodePoint character;
Color foreground;
Color background;
} Cell;
typedef struct Window {
int const width;
int const height;
CodePoint *characters;
Color *foreground;
Color *background;
int width;
int height;
Cell *cells;
} Window;
Window *WindowCreate();
typedef struct PlatformState {
Window *prev;
Window *curr;
} PlatformState;
// Options for the backend. These options don't necessarily apply for all platforms.
typedef struct PlatformOpts {
float window_width_fraction; // decide the width of the window as a fraction of the total resolution. for gui backends
float window_height_fraction; // decide the height of the window as a fraction of the total resolution. for gui backends
} PlatformOpts;
PlatformOpts WindowCreateOptsDefault();
Window *WindowCreate(PlatformOpts opts);
void WindowClear(Window *window, Color color);
void WindowFlip(Window *window);
void PlatformInit(PlatformOpts opts);
int PlatformGetWidth();
int PlatformGetHeight();
// TODO: the platform layer would really update the keys being pressed, and
// receive a diff in the form of actions. print this line from here and change
// colors at these points.