diff options
author | dzwdz | 2023-08-14 18:51:07 +0200 |
---|---|---|
committer | dzwdz | 2023-08-14 18:51:07 +0200 |
commit | 642b5fb0007b64c77d186fcb018d571152ee1d47 (patch) | |
tree | 1c466461f3602d306be309a053edae558ef2568e /src/user/app/vterm/vterm.c | |
parent | 8050069c57b729c18c19b1a03ab6e4bf63b4735e (diff) |
reorganization: first steps
Diffstat (limited to 'src/user/app/vterm/vterm.c')
-rw-r--r-- | src/user/app/vterm/vterm.c | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/user/app/vterm/vterm.c b/src/user/app/vterm/vterm.c deleted file mode 100644 index f365f6b..0000000 --- a/src/user/app/vterm/vterm.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "vterm.h" -#include <camellia/syscalls.h> -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <camellia/compat.h> - -struct point cursor = {0}; - -void in_char(char c) { - switch (c) { - case '\n': - cursor.x = 0; - cursor.y++; - break; - case '\b': - if (cursor.x > 0) cursor.x--; - break; - case '\t': - /* rounds down to nearest multiple of 8 and adds 8 - = adding 1 and rounding up to the nearest multiple of 8 */ - cursor.x = (cursor.x & ~7) + 8; - break; - default: - font_blit(c, cursor.x, cursor.y); - cursor.x++; - } - - if (cursor.x * font.w >= fb.width) { - cursor.x = 0; - cursor.y++; - } - while ((cursor.y + 1) * font.h >= fb.height) scroll(); -} - -int main(void) { - if (fb_setup(&fb, "/kdev/video/") < 0) { - eprintf("fb_setup error"); - return 1; - } - font_load("/init/usr/share/fonts/spleen/spleen-8x16.psfu"); - - static char buf[512]; - struct ufs_request res; - while (!c0_fs_wait(buf, sizeof buf, &res)) { - switch (res.op) { - case VFSOP_OPEN: - // TODO check path - c0_fs_respond(NULL, 0, 0); - break; - - case VFSOP_WRITE: - if (res.flags) { - c0_fs_respond(NULL, -1, 0); - } else { - for (size_t i = 0; i < res.len; i++) - in_char(buf[i]); - dirty_flush(&dirty, &fb); - c0_fs_respond(NULL, res.len, 0); - } - break; - - default: - c0_fs_respond(NULL, -1, 0); - break; - } - } - - return 1; -} |