#include #include #include #include #include #include "hl.h" #define ALLOCATION_CHUNK (10UL) static char * buffer = NULL; static size_t buffer_size = 0; int main(int argc, char * * argv) { UNUSED(argc); UNUSED(argv); // Buffer init buffer = realloc(buffer, ALLOCATION_CHUNK); do { if (!((buffer_size + 1) % ALLOCATION_CHUNK)) { /* Linear incremental reallocation (advanced)! */ size_t chunks = (buffer_size + 1) / ALLOCATION_CHUNK; buffer = realloc(buffer, ++chunks * ALLOCATION_CHUNK); } buffer[buffer_size] = '\0'; /* 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 terminal_hl_init(); // #include "hl_c.inc"; // render_string(buffer, "cterm"); putchar('\n'); fflush(stdout); //hl_deinit(); free(buffer); return 0; }