diff options
-rw-r--r-- | main.c | 7 | ||||
-rw-r--r-- | status_bar.c | 30 | ||||
-rw-r--r-- | title_bar.c | 27 | ||||
-rw-r--r-- | windows.c | 21 |
4 files changed, 54 insertions, 31 deletions
diff --git a/main.c b/main.c index 2d9c44b7..50a9f1a5 100644 --- a/main.c +++ b/main.c @@ -4,13 +4,14 @@ int main(void) { - int exit_status = LOGIN_FAIL; + int exit_status; + log_init(); gui_init(); - while (exit_status == LOGIN_FAIL) { + do { exit_status = profanity_start(); - } + } while (exit_status == LOGIN_FAIL); gui_close(); log_close(); diff --git a/status_bar.c b/status_bar.c index 66eb3f9a..0f98d481 100644 --- a/status_bar.c +++ b/status_bar.c @@ -14,7 +14,9 @@ void create_status_bar(void) status_bar = newwin(1, cols, rows-2, 0); wbkgd(status_bar, COLOR_PAIR(3)); + wattron(status_bar, COLOR_PAIR(4)); mvwprintw(status_bar, 0, cols - 29, _active); + wattroff(status_bar, COLOR_PAIR(4)); wrefresh(status_bar); } @@ -28,27 +30,27 @@ void status_bar_refresh(void) void status_bar_inactive(int win) { - _active[1 + ((win - 1) * 3)] = ' '; - if (win == 9) - _active[1 + ((win -1) * 3)] = ' '; - + int active_pos = 1 + ((win -1) * 3); + int rows, cols; getmaxyx(stdscr, rows, cols); - mvwprintw(status_bar, 0, cols - 29, _active); + + mvwaddch(status_bar, 0, cols - 29 + active_pos, ' '); + if (win == 9) + mvwaddch(status_bar, 0, cols - 29 + active_pos + 1, ' '); } void status_bar_active(int win) { - if (win < 9) { - _active[1 + ((win -1) * 3)] = (char)( ((int)'0') + (win + 1)); - } else { - _active[25] = '1'; - _active[26] = '0'; - } - + int active_pos = 1 + ((win -1) * 3); + int rows, cols; getmaxyx(stdscr, rows, cols); - mvwprintw(status_bar, 0, cols - 29, _active); + + if (win < 9) + mvwprintw(status_bar, 0, cols - 29 + active_pos, "%d", win+1); + else + mvwprintw(status_bar, 0, cols - 29 + active_pos, "10"); } void status_bar_get_password(void) @@ -67,7 +69,9 @@ void status_bar_clear(void) int rows, cols; getmaxyx(stdscr, rows, cols); + wattron(status_bar, COLOR_PAIR(4)); mvwprintw(status_bar, 0, cols - 29, _active); + wattroff(status_bar, COLOR_PAIR(4)); } static void _status_bar_update_time(void) diff --git a/title_bar.c b/title_bar.c index e19a5053..e26e2cd8 100644 --- a/title_bar.c +++ b/title_bar.c @@ -19,8 +19,16 @@ void title_bar_connected(void) { int rows, cols; getmaxyx(stdscr, rows, cols); - - mvwprintw(title_bar, 0, cols - 14, "[ ...online ]"); + + 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)); } void title_bar_disconnected(void) @@ -28,7 +36,15 @@ void title_bar_disconnected(void) int rows, cols; getmaxyx(stdscr, rows, cols); - mvwprintw(title_bar, 0, cols - 14, "[ ..offline ]"); + 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)); } void title_bar_refresh(void) @@ -40,7 +56,10 @@ void title_bar_refresh(void) void title_bar_show(char *title) { - wclear(title_bar); + wmove(title_bar, 0, 0); + int i; + for (i = 0; i < 45; i++) + waddch(title_bar, ' '); mvwprintw(title_bar, 0, 0, " %s", title); } diff --git a/windows.c b/windows.c index fb94cbbc..ea6c5b03 100644 --- a/windows.c +++ b/windows.c @@ -15,16 +15,15 @@ void gui_init(void) initscr(); cbreak(); keypad(stdscr, TRUE); - - start_color(); - init_color(COLOR_WHITE, 1000, 1000, 1000); - init_pair(1, COLOR_WHITE, COLOR_BLACK); - init_pair(2, COLOR_GREEN, COLOR_BLACK); - init_color(COLOR_BLUE, 0, 0, 250); - init_pair(3, COLOR_WHITE, COLOR_BLUE); - attron(A_BOLD); - attron(COLOR_PAIR(1)); + if (has_colors()) { + start_color(); + + init_pair(1, COLOR_WHITE, COLOR_BLACK); + init_pair(2, COLOR_GREEN, COLOR_BLACK); + init_pair(3, COLOR_WHITE, COLOR_BLUE); + init_pair(4, COLOR_CYAN, COLOR_BLUE); + } refresh(); @@ -60,7 +59,7 @@ void win_switch_to(int i) _curr_win = i; if (i == 0) { - title_bar_show("Profanity. Type /help for help information"); + title_bar_show("Profanity. Type /help for help information."); } else { title_bar_show(_wins[i].from); } @@ -77,7 +76,7 @@ void win_close_win(void) // go back to console window _curr_win = 0; - title_bar_show("Profanity. Type /help for help information"); + title_bar_show("Profanity. Type /help for help information."); } int win_in_chat(void) |