diff options
author | James Booth <boothj5@gmail.com> | 2013-10-05 23:34:49 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-10-05 23:34:49 +0100 |
commit | 89fea389ca1272ef626dd1a5003ffd4991f9f388 (patch) | |
tree | 0a5d5ce029568b405f53fedafc2298b0693304cf /src | |
parent | 3512114cf1bfeb05a4412b93d85c27b5abd66e19 (diff) | |
parent | 738be65edc17d44a3305866a4a19b8729c133e5b (diff) | |
download | profani-tty-89fea389ca1272ef626dd1a5003ffd4991f9f388.tar.gz |
Merge branch 'master' into otr
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/core.c | 14 | ||||
-rw-r--r-- | src/ui/statusbar.c | 25 | ||||
-rw-r--r-- | src/ui/ui.h | 1 | ||||
-rw-r--r-- | src/ui/windows.c | 2 |
4 files changed, 39 insertions, 3 deletions
diff --git a/src/ui/core.c b/src/ui/core.c index 86d216ad..5502f972 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -596,6 +596,7 @@ ui_switch_win(const int i) if (i == 1) { title_bar_title(); + status_bar_current(1); status_bar_active(1); } else { PContact contact = roster_get_contact(new_current->from); @@ -608,7 +609,8 @@ ui_switch_win(const int i) } else { title_bar_set_recipient(new_current->from); } - title_bar_draw();; + title_bar_draw(); + status_bar_current(i); status_bar_active(i); } wins_refresh_current(); @@ -628,6 +630,7 @@ ui_next_win(void) if (i == 1) { title_bar_title(); + status_bar_current(1); status_bar_active(1); } else { PContact contact = roster_get_contact(new_current->from); @@ -640,7 +643,8 @@ ui_next_win(void) } else { title_bar_set_recipient(new_current->from); } - title_bar_draw();; + title_bar_draw(); + status_bar_current(i); status_bar_active(i); } wins_refresh_current(); @@ -659,6 +663,7 @@ ui_previous_win(void) if (i == 1) { title_bar_title(); + status_bar_current(1); status_bar_active(1); } else { PContact contact = roster_get_contact(new_current->from); @@ -671,7 +676,8 @@ ui_previous_win(void) } else { title_bar_set_recipient(new_current->from); } - title_bar_draw();; + title_bar_draw(); + status_bar_current(i); status_bar_active(i); } wins_refresh_current(); @@ -689,6 +695,7 @@ ui_close_current(void) int current_index = wins_get_current_num(); status_bar_inactive(current_index); wins_close_current(); + status_bar_current(1); status_bar_active(1); title_bar_title(); } @@ -697,6 +704,7 @@ void ui_close_win(int index) { wins_close_by_num(index); + status_bar_current(1); status_bar_active(1); title_bar_title(); diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index e7456adc..16bd31c9 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -39,12 +39,14 @@ static WINDOW *status_bar; static char *message = NULL; // 1 2 3 4 5 6 7 8 9 0 > static char _active[34] = "[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]"; +static char *bracket = "- -"; static int is_active[12]; static GHashTable *remaining_active; static int is_new[12]; static GHashTable *remaining_new; static int dirty; static GDateTime *last_time; +static int current; static void _status_bar_update_time(void); static void _update_win_statuses(void); @@ -66,11 +68,13 @@ create_status_bar(void) } remaining_active = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); remaining_new = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); + current = 1; 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 - 34, _active); + mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); wattroff(status_bar, COLOUR_STATUS_BRACKET); if (last_time != NULL) @@ -116,6 +120,7 @@ status_bar_resize(void) werase(status_bar); wattron(status_bar, COLOUR_STATUS_BRACKET); mvwprintw(status_bar, 0, cols - 34, _active); + mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); wattroff(status_bar, COLOUR_STATUS_BRACKET); _update_win_statuses(); @@ -144,6 +149,23 @@ status_bar_set_all_inactive(void) } void +status_bar_current(int i) +{ + if (i == 0) { + current = 10; + } else if (i > 10) { + current = 11; + } else { + current = i; + } + int cols = getmaxx(stdscr); + wattron(status_bar, COLOUR_STATUS_BRACKET); + mvwprintw(status_bar, 0, cols - 34, _active); + mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); + wattroff(status_bar, COLOUR_STATUS_BRACKET); +} + +void status_bar_inactive(const int win) { int true_win = win; @@ -263,6 +285,7 @@ status_bar_print_message(const char * const msg) wattron(status_bar, COLOUR_STATUS_BRACKET); mvwprintw(status_bar, 0, cols - 34, _active); + mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); wattroff(status_bar, COLOUR_STATUS_BRACKET); _update_win_statuses(); @@ -291,6 +314,7 @@ status_bar_clear(void) wattron(status_bar, COLOUR_STATUS_BRACKET); mvwprintw(status_bar, 0, cols - 34, _active); + mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); wattroff(status_bar, COLOUR_STATUS_BRACKET); dirty = TRUE; @@ -310,6 +334,7 @@ status_bar_clear_message(void) wattron(status_bar, COLOUR_STATUS_BRACKET); mvwprintw(status_bar, 0, cols - 34, _active); + mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); wattroff(status_bar, COLOUR_STATUS_BRACKET); _update_win_statuses(); diff --git a/src/ui/ui.h b/src/ui/ui.h index 4cde751e..4d4ead7b 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -228,6 +228,7 @@ void status_bar_active(const int win); void status_bar_new(const int win); void status_bar_update_time(void); void status_bar_set_all_inactive(void); +void status_bar_current(int i); // input window actions wint_t inp_get_char(char *input, int *size); diff --git a/src/ui/windows.c b/src/ui/windows.c index 684e98fd..87b61ab1 100644 --- a/src/ui/windows.c +++ b/src/ui/windows.c @@ -413,6 +413,8 @@ wins_tidy(void) } windows = new_windows; + current = 1; + ui_switch_win(1); return TRUE; } else { return FALSE; |