libhl/source/main.c

51 lines
1.0 KiB
C
Raw Normal View History

2023-08-24 06:24:46 -04:00
/* main.c
* Copyright 2023 Anon Anonson, Ognjen 'xolatile' Milan Robovic, Emil Williams
* SPDX Identifier: GPL-3.0-only / NO WARRANTY / NO GUARANTEE */
2023-08-21 09:05:27 -04:00
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
2023-08-28 15:58:20 -04:00
2023-08-23 21:47:09 -04:00
#include "terminal_hl.h"
#define ALLOCATION_CHUNK (10UL)
static char * buffer = NULL;
static size_t buffer_size = 0;
2023-08-28 15:58:20 -04:00
int main(void) {
// Buffer init
buffer = realloc(buffer, ALLOCATION_CHUNK);
do {
if (!((buffer_size + 1) % ALLOCATION_CHUNK)) {
size_t chunks = (buffer_size + 1) / ALLOCATION_CHUNK;
buffer = realloc(buffer, ++chunks * ALLOCATION_CHUNK);
}
buffer[buffer_size] = '\0';
2023-08-21 09:05:27 -04:00
/* TODO handle me */
assert(read(STDIN_FILENO, &buffer[buffer_size], sizeof (*buffer)) != -1);
++buffer_size;
} while (buffer[buffer_size - 1]);
buffer[buffer_size - 1] = '\0';
// Highlight init
2023-08-23 21:37:40 -04:00
terminal_hl_init();
2023-08-19 18:49:10 -04:00
//
2023-08-28 15:03:03 -04:00
#include "syntax/c.h"
//
2023-08-25 19:16:05 -04:00
render_string(buffer, "cterm");
putchar('\n');
2023-08-21 14:07:39 -04:00
fflush(stdout);
//hl_deinit();
2023-08-19 18:49:10 -04:00
free(buffer);
2023-08-27 18:49:36 -04:00
//terminal_hl_deinit();
return 0;
}