some cmenu changes

This commit is contained in:
2026-08-29 22:26:35 +02:00
parent 260364ea16
commit 3f682063a6
10 changed files with 28 additions and 6897 deletions
Binary file not shown.
Binary file not shown.
-6814
View File
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -1,2 +1,5 @@
tag:
run:
tcc -run main.c
tags:
ctags --langmap=c:.c.h --languages=c -R .
+7 -4
View File
@@ -1,9 +1,12 @@
#include "str.h"
#include "str.c"
// Opens a fuzzy finding window with the given array of strings.
// Returns the index of the picked element.
// Returns -1 on no selection.
int picker(char const *strings, int strings_len, char const *prompt) {
int picker(String strings[], int strings_len, char const *prompt) {
}
int main(int const argc, char const *argv[]) {
return 0;
}
+2 -4
View File
@@ -4,8 +4,6 @@
#include <stdint.h>
#include <stdbool.h>
#include "utf.h"
typedef struct Color {
uint8_t r, g, b;
} Color;
@@ -25,10 +23,10 @@ typedef enum Key {
} Key;
bool KeyPressed(Key key);
bool InputGetNextPrintable(CodePoint const *out_key);
bool InputGetNextPrintable(char const *out_key);
typedef struct Cell {
CodePoint character;
char character;
Color foreground;
Color background;
} Cell;
+14
View File
@@ -41,3 +41,17 @@ bool StringSub(String string, int start, int end, String *out_substr) {
return start_ok && end_ok;
}
String StringFromCString(unsigned char const *s) {
size_t size = 0;
while (s[size] != '\0') { size++; }
return (String) {
.buffer=s,
.size=size,
};
}
typedef struct String {
unsigned char const *buffer;
size_t size;
} String;
+1
View File
@@ -8,3 +8,4 @@ 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);
-65
View File
@@ -1,65 +0,0 @@
#include <stddef.h>
#include "utf.h"
#include "str.h"
typedef struct Utf8Parser {
String str;
} Utf8Parser;
bool Utf8ParserNextCodePoint(Utf8Parser *this, CodePoint *out_codepoint) {
uitn8_t const flag_1_bytes = 0;
uint8_t const mask_1_bytes = 1 << 7;
uint8_t const flag_continuation = mask_1_bytes;
uint8_t const mask_continuation = (1 << 7) | (1 << 6);
uint8_t const flag_2_bytes = mask_continuation;
uint8_t const mask_2_bytes = (1 << 7) | (1 << 6) | (1 << 5);
uint8_t const flag_3_bytes = mask_2_bytes;
uint8_t const mask_3_bytes = (1 << 7) | (1 << 6) | (1 << 5) | (1 << 4);
uint8_t const flag_4_bytes = mask_3_bytes;
uint8_t const mask_4_bytes = (1 << 7) | (1 << 6) | (1 << 5) | (1 << 4) | (1 << 3);
if (this->str.size == 0) {
*out_codepoint = 0;
return false;
}
if ((this->str.buffer[0] & mask_1_bytes) == flag_1_bytes) {
*out_codepoint = (CodePoint) str[0];
bool ok = StringSub(this->str, 1, -1, &this->str);
assert(ok && "has to be ok since the size is not 0");
return ok;
} else
}
// max must be less than or equal to the capacity of target.
bool CodePointsFromUtf8String(
uint8_t const *str,
CodePoint *target,
int max
) {
for (size_t i = 0; str[i] != '\0' && max > 0;) {
if ((str[i] & mask_1_bytes) == flag_1_bytes) {
*target = (CodePoint) str[i];
target += 1;
max -= 1;
i += 1;
} else
if ((str[i] & mask_2_bytes) == flag_2_bytes) {
} else
if ((str[i] & mask_3_bytes) == flag_3_bytes) {
} else
if ((str[i] & mask_4_bytes) == flag_4_bytes) {
} else {
false;
}
}
return true;
}
-9
View File
@@ -1,9 +0,0 @@
#ifndef UTF
#define UTF
typedef uint32_t CodePoint;
int CodePointsFromUtf8String(char const *str, CodePoint *target, unsigned int max);
#endif // UTF