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

Changes to status bar for unlimited windows - WIP

This commit is contained in:
James Booth 2013-08-28 00:50:15 +01:00
parent b5eb095820
commit 9ef7e2d233
5 changed files with 78 additions and 55 deletions

View File

@ -1822,7 +1822,7 @@ _cmd_about(gchar **args, struct cmd_help_t help)
cons_show("");
cons_about();
if (ui_current_win_type() != WIN_CONSOLE) {
status_bar_new(0);
status_bar_new(1);
}
return TRUE;
}
@ -2124,7 +2124,7 @@ _cmd_who(gchar **args, struct cmd_help_t help)
}
if (win_type != WIN_CONSOLE && win_type != WIN_MUC) {
status_bar_new(0);
status_bar_new(1);
}
return TRUE;

View File

@ -1338,7 +1338,7 @@ void
cons_alert(void)
{
if (ui_current_win_type() != WIN_CONSOLE) {
status_bar_new(0);
status_bar_new(1);
}
}

View File

@ -85,7 +85,7 @@ ui_init(void)
refresh();
create_title_bar();
create_status_bar();
status_bar_active(0);
status_bar_active(1);
create_input_window();
wins_init();
cons_about();
@ -574,9 +574,9 @@ ui_switch_win(const int i)
new_current->unread = 0;
if (i == 0) {
if (i == 1) {
title_bar_title();
status_bar_active(0);
status_bar_active(1);
} else {
PContact contact = roster_get_contact(new_current->from);
if (contact != NULL) {
@ -607,7 +607,7 @@ ui_close_current(void)
int current_index = wins_get_current_num();
wins_close_current();
status_bar_inactive(current_index);
status_bar_active(0);
status_bar_active(1);
title_bar_title();
}
@ -616,7 +616,7 @@ ui_close_win(int index)
{
wins_close_by_num(index);
status_bar_inactive(index);
status_bar_active(0);
status_bar_active(1);
title_bar_title();
wins_refresh_current();
@ -797,7 +797,7 @@ ui_print_system_msg_from_recipient(const char * const from, const char *message)
} else {
num = 0;
window = wins_get_console();
status_bar_active(0);
status_bar_active(1);
}
}

View File

@ -526,35 +526,35 @@ _handle_alt_key(char *input, int *size, int key)
switch (key)
{
case '1':
ui_switch_win(0);
break;
case '2':
ui_switch_win(1);
break;
case '3':
case '2':
ui_switch_win(2);
break;
case '4':
case '3':
ui_switch_win(3);
break;
case '5':
case '4':
ui_switch_win(4);
break;
case '6':
case '5':
ui_switch_win(5);
break;
case '7':
case '6':
ui_switch_win(6);
break;
case '8':
case '7':
ui_switch_win(7);
break;
case '9':
case '8':
ui_switch_win(8);
break;
case '0':
case '9':
ui_switch_win(9);
break;
case '0':
ui_switch_win(0);
break;
case 263:
case 127:
input[*size] = '\0';

View File

@ -37,9 +37,10 @@
static WINDOW *status_bar;
static char *message = NULL;
static char _active[31] = "[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]";
static int is_active[10];
static int is_new[10];
// 1 2 3 4 5 6 7 8 9 0 >
static char _active[34] = "[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]";
static int is_active[12];
static int is_new[12];
static int dirty;
static GDateTime *last_time;
@ -51,9 +52,9 @@ create_status_bar(void)
int rows, cols, i;
getmaxyx(stdscr, rows, cols);
is_active[0] = TRUE;
is_new[0] = FALSE;
for (i = 1; i < 10; i++) {
is_active[1] = TRUE;
is_new[1] = FALSE;
for (i = 2; i < 12; i++) {
is_active[i] = FALSE;
is_new[i] = FALSE;
}
@ -61,7 +62,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 - 31, _active);
mvwprintw(status_bar, 0, cols - 34, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
if (last_time != NULL)
@ -105,10 +106,10 @@ status_bar_resize(void)
wbkgd(status_bar, COLOUR_STATUS_TEXT);
werase(status_bar);
wattron(status_bar, COLOUR_STATUS_BRACKET);
mvwprintw(status_bar, 0, cols - 31, _active);
mvwprintw(status_bar, 0, cols - 34, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
for(i = 0; i < 10; i++) {
for(i = 1; i < 12; i++) {
if (is_new[i])
status_bar_new(i);
else if (is_active[i])
@ -127,14 +128,18 @@ status_bar_resize(void)
void
status_bar_inactive(const int win)
{
is_active[win] = FALSE;
is_new[win] = FALSE;
int true_win = win;
if (true_win == 0) {
true_win = 10;
}
is_active[true_win] = FALSE;
is_new[true_win] = FALSE;
int active_pos = 1 + (win * 3);
int active_pos = 1 + ((true_win-1) * 3);
int cols = getmaxx(stdscr);
mvwaddch(status_bar, 0, cols - 31 + active_pos, ' ');
mvwaddch(status_bar, 0, cols - 34 + active_pos, ' ');
dirty = TRUE;
}
@ -142,18 +147,27 @@ status_bar_inactive(const int win)
void
status_bar_active(const int win)
{
is_active[win] = TRUE;
is_new[win] = FALSE;
int true_win = win;
if (true_win == 0) {
true_win = 10;
}
is_active[true_win] = TRUE;
is_new[true_win] = FALSE;
int active_pos = 1 + (win * 3);
int active_pos = 1 + ((true_win-1) * 3);
int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_ACTIVE);
if (win+1 < 10)
mvwprintw(status_bar, 0, cols - 31 + active_pos, "%d", win+1);
else
mvwprintw(status_bar, 0, cols - 31 + active_pos, "0");
if (true_win == 10) {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "0");
} else if (true_win > 10) {
mvwprintw(status_bar, 0, cols - 34 + active_pos, ">");
} else {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "%d", true_win);
}
wattroff(status_bar, COLOUR_STATUS_ACTIVE);
dirty = TRUE;
@ -162,19 +176,28 @@ status_bar_active(const int win)
void
status_bar_new(const int win)
{
is_active[win] = TRUE;
is_new[win] = TRUE;
int true_win = win;
if (true_win == 0) {
true_win = 10;
}
is_active[true_win] = TRUE;
is_new[true_win] = TRUE;
int active_pos = 1 + (win * 3);
int active_pos = 1 + ((true_win-1) * 3);
int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_NEW);
wattron(status_bar, A_BLINK);
if (win+1 < 10)
mvwprintw(status_bar, 0, cols - 31 + active_pos, "%d", win+1);
else
mvwprintw(status_bar, 0, cols - 31 + active_pos, "0");
if (true_win == 10) {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "0");
} else if (true_win > 10) {
mvwprintw(status_bar, 0, cols - 34 + active_pos, ">");
} else {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "%d", true_win);
}
wattroff(status_bar, COLOUR_STATUS_NEW);
wattroff(status_bar, A_BLINK);
@ -203,11 +226,11 @@ status_bar_print_message(const char * const msg)
int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_BRACKET);
mvwprintw(status_bar, 0, cols - 31, _active);
mvwprintw(status_bar, 0, cols - 34, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
int i;
for(i = 0; i < 10; i++) {
for(i = 1; i < 12; i++) {
if (is_new[i])
status_bar_new(i);
else if (is_active[i])
@ -226,9 +249,9 @@ status_bar_clear(void)
}
int i;
is_active[0] = TRUE;
is_new[0] = FALSE;
for (i = 1; i < 10; i++) {
is_active[1] = TRUE;
is_new[1] = FALSE;
for (i = 2; i < 12; i++) {
is_active[i] = FALSE;
is_new[i] = FALSE;
}
@ -238,7 +261,7 @@ status_bar_clear(void)
int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_BRACKET);
mvwprintw(status_bar, 0, cols - 31, _active);
mvwprintw(status_bar, 0, cols - 34, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
dirty = TRUE;
@ -257,11 +280,11 @@ status_bar_clear_message(void)
int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_BRACKET);
mvwprintw(status_bar, 0, cols - 31, _active);
mvwprintw(status_bar, 0, cols - 34, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
int i;
for(i = 0; i < 10; i++) {
for(i = 1; i < 12; i++) {
if (is_new[i])
status_bar_new(i);
else if (is_active[i])