Skip to content

Malwarize/ctermui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

57 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CTERMUI

terminal UI library in C

ctermui_logo

get started

you have to initiate screen struct

ctermui_screen_t screen = ctermui_screen_init();

we to get root layout ready also

ctermui_layout_t root = ctermui_layout_new_root(
  CTERMUI_HORIZONTAL, screen->width, screen->height
);

you have to add component to layout

float xvalues[SIZE];
float yvalues[SIZE];
generate_data(xvalues, yvalues);
ctermui_component_t plt = ctermui_new_scatter_plot(
        "scatter_plot",
        xvalues,
        yvalues,
        SIZE,
        CTERMUI_BRIGHT_CYAN,
        CTERMUI_EMPTY,
        CTERMUI_BRIGHT_RED,
        '*',
        1
);

after the screen, component and layout we have to attach them

ctermui_layout_add_component(root, plt);
ctermui_screen_set_layout_root(screen, root);

start the screen loop

ctermui_screen_loop_start(screen, periodic, n);

the periodic function is function called every n ms

void periodic(ctermui_screen_t *screen_p) {
    ctermui_screen_t screen = *screen_p;
    ctermui_layout_t root = screen->root;
    ctermui_component_t c = root->component[0];
    ScatterPlot *plt = (ScatterPlot *) c->core_component;
    float xvalues[SIZE];
    float yvalues[SIZE];
    if (screen->loop_count % 100 == 0) {

        for (int i = 0; i < SIZE; i++) {
            plt->xvalues[i]++;
            plt->yvalues[i] = sin(plt->xvalues[i]);
        }
        ctermui_screen_refresh_layout(screen, root);
    }
}

Examples

button navigation

btn_selection.mp4

system usage

usage.mp4

star wars

star_wars.mp4

scatter plot

scatter_plot.mp4

progress bar

progress_bar.mp4

bar chart

barcharts.mp4

About

๐Ÿ—” terminal UI library for C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published