mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-24 05:46:21 +00:00
Refactored title bar status
This commit is contained in:
61
title_bar.c
61
title_bar.c
@@ -27,8 +27,12 @@
|
|||||||
|
|
||||||
static WINDOW *title_bar;
|
static WINDOW *title_bar;
|
||||||
static char *current_title = NULL;
|
static char *current_title = NULL;
|
||||||
|
static int connected = FALSE;
|
||||||
static int dirty;
|
static int dirty;
|
||||||
|
|
||||||
|
void _title_bar_draw_title(void);
|
||||||
|
void _title_bar_draw_status(void);
|
||||||
|
|
||||||
void create_title_bar(void)
|
void create_title_bar(void)
|
||||||
{
|
{
|
||||||
int rows, cols;
|
int rows, cols;
|
||||||
@@ -49,38 +53,14 @@ void title_bar_title(void)
|
|||||||
|
|
||||||
void title_bar_connected(void)
|
void title_bar_connected(void)
|
||||||
{
|
{
|
||||||
int rows, cols;
|
connected = TRUE;
|
||||||
getmaxyx(stdscr, rows, cols);
|
_title_bar_draw_status();
|
||||||
|
|
||||||
wattron(title_bar, COLOR_PAIR(4));
|
|
||||||
mvwaddch(title_bar, 0, cols - 14, '[');
|
|
||||||
wattroff(title_bar, COLOR_PAIR(4));
|
|
||||||
|
|
||||||
mvwprintw(title_bar, 0, cols - 13, " ...online ");
|
|
||||||
|
|
||||||
wattron(title_bar, COLOR_PAIR(4));
|
|
||||||
mvwaddch(title_bar, 0, cols - 2, ']');
|
|
||||||
wattroff(title_bar, COLOR_PAIR(4));
|
|
||||||
|
|
||||||
dirty = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void title_bar_disconnected(void)
|
void title_bar_disconnected(void)
|
||||||
{
|
{
|
||||||
int rows, cols;
|
connected = FALSE;
|
||||||
getmaxyx(stdscr, rows, cols);
|
_title_bar_draw_status();
|
||||||
|
|
||||||
wattron(title_bar, COLOR_PAIR(4));
|
|
||||||
mvwaddch(title_bar, 0, cols - 14, '[');
|
|
||||||
wattroff(title_bar, COLOR_PAIR(4));
|
|
||||||
|
|
||||||
mvwprintw(title_bar, 0, cols - 13, " ..offline ");
|
|
||||||
|
|
||||||
wattron(title_bar, COLOR_PAIR(4));
|
|
||||||
mvwaddch(title_bar, 0, cols - 2, ']');
|
|
||||||
wattroff(title_bar, COLOR_PAIR(4));
|
|
||||||
|
|
||||||
dirty = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void title_bar_refresh(void)
|
void title_bar_refresh(void)
|
||||||
@@ -99,6 +79,11 @@ void title_bar_show(const char * const title)
|
|||||||
|
|
||||||
current_title = (char *) malloc((strlen(title) + 1) * sizeof(char));
|
current_title = (char *) malloc((strlen(title) + 1) * sizeof(char));
|
||||||
strcpy(current_title, title);
|
strcpy(current_title, title);
|
||||||
|
_title_bar_draw_title();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _title_bar_draw_title(void)
|
||||||
|
{
|
||||||
wmove(title_bar, 0, 0);
|
wmove(title_bar, 0, 0);
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 45; i++)
|
for (i = 0; i < 45; i++)
|
||||||
@@ -108,3 +93,23 @@ void title_bar_show(const char * const title)
|
|||||||
dirty = TRUE;
|
dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _title_bar_draw_status(void)
|
||||||
|
{
|
||||||
|
int rows, cols;
|
||||||
|
getmaxyx(stdscr, rows, cols);
|
||||||
|
|
||||||
|
wattron(title_bar, COLOR_PAIR(4));
|
||||||
|
mvwaddch(title_bar, 0, cols - 14, '[');
|
||||||
|
wattroff(title_bar, COLOR_PAIR(4));
|
||||||
|
|
||||||
|
if (connected == TRUE)
|
||||||
|
mvwprintw(title_bar, 0, cols - 13, " ...online ");
|
||||||
|
else
|
||||||
|
mvwprintw(title_bar, 0, cols - 13, " ..offline ");
|
||||||
|
|
||||||
|
wattron(title_bar, COLOR_PAIR(4));
|
||||||
|
mvwaddch(title_bar, 0, cols - 2, ']');
|
||||||
|
wattroff(title_bar, COLOR_PAIR(4));
|
||||||
|
|
||||||
|
dirty = TRUE;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user