diff options
| author | verdant <im@verdant.ee> | 2026-07-21 19:01:48 +0800 |
|---|---|---|
| committer | verdant <im@verdant.ee> | 2026-07-21 19:01:48 +0800 |
| commit | f77177e2f3ae27c48151a297dd0a4b36101038a2 (patch) | |
| tree | 87de2e4ccba7b1ef17f0d1719ea6c966eb524cf9 /display.h | |
| parent | 015263141def1a33649fdb0e85c8c137a7d522f2 (diff) | |
| download | sf-f77177e2f3ae27c48151a297dd0a4b36101038a2.tar.gz sf-f77177e2f3ae27c48151a297dd0a4b36101038a2.zip | |
Add display handing functions
Add these functions for initializing and drawing status bar,
progress bar and status information
Diffstat (limited to 'display.h')
| -rw-r--r-- | display.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/display.h b/display.h new file mode 100644 index 0000000..6cc82f3 --- /dev/null +++ b/display.h @@ -0,0 +1,43 @@ +#ifndef SF_DISPLAY_H +#define SF_DISPLAY_H + +#include <ncurses.h> +#include <stdlib.h> + +#include "log.h" +#include "mem.h" + +#define COLOR_PAIR_STATUS_BAR 1 +#define COLOR_PAIR_PROGRESS 2 +#define COLOR_PAIR_TEXT_INFO 3 +#define COLOR_PAIR_FM_DIR 4 +#define COLOR_PAIR_BORDER 5 + +#define STAT_INFO_WIDTH 15 +#define BAR_LABEL_WIDTH 7 +#define STAT_BAR_HEIGHT 1 + +#include "wm.h" + +void color_pair_init(); +terminal *ncurses_init(); + +static inline WINDOW *get_root_win(const terminal *t) { + if (!t) { + log_write(LOG_ERR, "get_root_win: terminal is NULL"); + return NULL; + } + if (t->w_count <= 0 || !t->windows[0]) { + log_write(LOG_ERR, "get_root_win: windows[0] is not allocated"); + return NULL; + } + return t->windows[0]->win; +} + +#define ROOT_WIN get_root_win(t) + +void draw_stat_bar(terminal *t, const char *sys_version); + +void wprintw_colorful(WINDOW *w, int attr, const char *format, ...); + +#endif /* SF_DISPLAY_H */ |
