1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added console to statusbar window list

This commit is contained in:
James Booth 2012-11-24 20:41:27 +00:00
parent d30d31b57d
commit 4e94654122
2 changed files with 42 additions and 39 deletions

View File

@ -37,9 +37,9 @@
static WINDOW *status_bar;
static char *message = NULL;
static char _active[29] = "[ ][ ][ ][ ][ ][ ][ ][ ][ ]";
static int is_active[9];
static int is_new[9];
static char _active[31] = "[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]";
static int is_active[10];
static int is_new[10];
static int dirty;
static GDateTime *last_time;
@ -51,7 +51,9 @@ create_status_bar(void)
int rows, cols, i;
getmaxyx(stdscr, rows, cols);
for (i = 0; i < 9; i++) {
is_active[0] = TRUE;
is_new[0] = FALSE;
for (i = 1; i < 10; i++) {
is_active[i] = FALSE;
is_new[i] = FALSE;
}
@ -59,7 +61,7 @@ create_status_bar(void)
status_bar = newwin(1, cols, rows-2, 0);
wbkgd(status_bar, COLOUR_STATUS_TEXT);
wattron(status_bar, COLOUR_STATUS_BRACKET);
mvwprintw(status_bar, 0, cols - 28, _active);
mvwprintw(status_bar, 0, cols - 31, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
last_time = g_date_time_new_now_local();
@ -99,18 +101,18 @@ status_bar_resize(void)
wbkgd(status_bar, COLOUR_STATUS_TEXT);
wclear(status_bar);
wattron(status_bar, COLOUR_STATUS_BRACKET);
mvwprintw(status_bar, 0, cols - 28, _active);
mvwprintw(status_bar, 0, cols - 31, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
for(i = 0; i < 9; i++) {
for(i = 0; i < 10; i++) {
if (is_new[i])
status_bar_new(i+1);
status_bar_new(i);
else if (is_active[i])
status_bar_active(i+1);
status_bar_active(i);
}
if (message != NULL)
mvwprintw(status_bar, 0, 9, message);
mvwprintw(status_bar, 0, 10, message);
last_time = g_date_time_new_now_local();
dirty = TRUE;
@ -119,16 +121,14 @@ status_bar_resize(void)
void
status_bar_inactive(const int win)
{
is_active[win-1] = FALSE;
is_new[win-1] = FALSE;
is_active[win] = FALSE;
is_new[win] = FALSE;
int active_pos = 1 + ((win -1) * 3);
int active_pos = 1 + (win * 3);
int cols = getmaxx(stdscr);
mvwaddch(status_bar, 0, cols - 28 + active_pos, ' ');
if (win == 9)
mvwaddch(status_bar, 0, cols - 28 + active_pos + 1, ' ');
mvwaddch(status_bar, 0, cols - 31 + active_pos, ' ');
dirty = TRUE;
}
@ -136,18 +136,18 @@ status_bar_inactive(const int win)
void
status_bar_active(const int win)
{
is_active[win-1] = TRUE;
is_new[win-1] = FALSE;
is_active[win] = TRUE;
is_new[win] = FALSE;
int active_pos = 1 + ((win -1) * 3);
int active_pos = 1 + (win * 3);
int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_ACTIVE);
if (win < 9)
mvwprintw(status_bar, 0, cols - 28 + active_pos, "%d", win+1);
if (win < 10)
mvwprintw(status_bar, 0, cols - 31 + active_pos, "%d", win+1);
else
mvwprintw(status_bar, 0, cols - 28 + active_pos, "0");
mvwprintw(status_bar, 0, cols - 31 + active_pos, "0");
wattroff(status_bar, COLOUR_STATUS_ACTIVE);
dirty = TRUE;
@ -156,19 +156,19 @@ status_bar_active(const int win)
void
status_bar_new(const int win)
{
is_active[win-1] = TRUE;
is_new[win-1] = TRUE;
is_active[win] = TRUE;
is_new[win] = TRUE;
int active_pos = 1 + ((win -1) * 3);
int active_pos = 1 + (win * 3);
int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_NEW);
wattron(status_bar, A_BLINK);
if (win < 9)
mvwprintw(status_bar, 0, cols - 28 + active_pos, "%d", win+1);
if (win < 10)
mvwprintw(status_bar, 0, cols - 31 + active_pos, "%d", win+1);
else
mvwprintw(status_bar, 0, cols - 28 + active_pos, "0");
mvwprintw(status_bar, 0, cols - 31 + active_pos, "0");
wattroff(status_bar, COLOUR_STATUS_NEW);
wattroff(status_bar, A_BLINK);
@ -194,20 +194,20 @@ status_bar_print_message(const char * const msg)
message = (char *) malloc((strlen(msg) + 1) * sizeof(char));
strcpy(message, msg);
mvwprintw(status_bar, 0, 9, message);
mvwprintw(status_bar, 0, 10, message);
int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_BRACKET);
mvwprintw(status_bar, 0, cols - 28, _active);
mvwprintw(status_bar, 0, cols - 31, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
int i;
for(i = 0; i < 9; i++) {
for(i = 0; i < 10; i++) {
if (is_new[i])
status_bar_new(i+1);
status_bar_new(i);
else if (is_active[i])
status_bar_active(i+1);
status_bar_active(i);
}
dirty = TRUE;
@ -222,7 +222,9 @@ status_bar_clear(void)
}
int i;
for (i = 0; i < 9; i++) {
is_active[0] = TRUE;
is_new[0] = FALSE;
for (i = 1; i < 10; i++) {
is_active[i] = FALSE;
is_new[i] = FALSE;
}
@ -232,7 +234,7 @@ status_bar_clear(void)
int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_BRACKET);
mvwprintw(status_bar, 0, cols - 28, _active);
mvwprintw(status_bar, 0, cols - 31, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
dirty = TRUE;
@ -251,15 +253,15 @@ status_bar_clear_message(void)
int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_BRACKET);
mvwprintw(status_bar, 0, cols - 28, _active);
mvwprintw(status_bar, 0, cols - 31, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
int i;
for(i = 0; i < 9; i++) {
for(i = 0; i < 10; i++) {
if (is_new[i])
status_bar_new(i+1);
status_bar_new(i);
else if (is_active[i])
status_bar_active(i+1);
status_bar_active(i);
}
dirty = TRUE;

View File

@ -114,6 +114,7 @@ gui_init(void)
create_title_bar();
create_status_bar();
status_bar_active(0);
create_input_window();
_create_windows();