moved code from header to source files

This commit is contained in:
2026-01-09 05:04:35 +05:00
parent 50940e5190
commit 3f75902aa0
20 changed files with 1304 additions and 1207 deletions

View File

@@ -3,7 +3,7 @@
#include <assert.h>
#include "tim.h"
static int cp_to_utf8(int32_t cp, char* s) {
static i32 cp_to_utf8(i32 cp, char* s) {
assert(cp > 0 && cp < 0x110000);
if (cp < 0x80) {
@@ -29,33 +29,33 @@ static int cp_to_utf8(int32_t cp, char* s) {
return -1;
}
static int cursor_pos() {
static i32 cursor_pos() {
write(STDOUT_FILENO, S("\33[6n"));
char buf[64] = {0};
int n = read(STDIN_FILENO, buf, 64);
i32 n = read(STDIN_FILENO, buf, 64);
if (n < 6 || buf[0] != '\33' || buf[n - 1] != 'R') {
return -1;
}
int r = atoi(buf + 2);
int c = atoi(buf + 4 + (r > 9));
i32 r = atoi(buf + 2);
i32 c = atoi(buf + 4 + (r > 9));
return c;
}
int main(int argc, char** argv) {
i32 main(i32 argc, char** argv) {
assert(argc == 2);
(void)tim_run;
FILE* f = fopen(argv[1], "w");
assert(f);
init_terminal();
tim_init_terminal();
for (int i = 32; i < 0x110000; i++) {
for (i32 i = 32; i < 0x110000; i++) {
write(STDOUT_FILENO, S("\33[0;0H"));
char buf[5] = {0};
int n = cp_to_utf8(i, buf);
i32 n = cp_to_utf8(i, buf);
write(STDOUT_FILENO, buf, n);
int w = cursor_pos() - 1;
i32 w = cursor_pos() - 1;
if (w) {
fprintf(f, "u+%06x %d %s\n", i, w, buf);
} else {
@@ -63,7 +63,7 @@ int main(int argc, char** argv) {
}
}
reset_terminal();
tim_reset_terminal();
fclose(f);
}