diff options
author | James Booth <boothj5@gmail.com> | 2012-02-12 22:20:21 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-02-12 22:20:21 +0000 |
commit | 9e63c4a0f6510149aa8253b9f9b57e072d860b9e (patch) | |
tree | d9a584f69d26a1d79afa7212889465f5ea0b9b0d | |
parent | af467928711057ef9d13d17f88576d24d44d4ee5 (diff) | |
download | profani-tty-9e63c4a0f6510149aa8253b9f9b57e072d860b9e.tar.gz |
Renamed input_bar -> status_bar
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | command.c | 4 | ||||
-rw-r--r-- | input_bar.c | 60 | ||||
-rw-r--r-- | input_win.c | 2 | ||||
-rw-r--r-- | profanity.c | 2 | ||||
-rw-r--r-- | status_bar.c | 60 | ||||
-rw-r--r-- | windows.c | 12 | ||||
-rw-r--r-- | windows.h | 16 |
8 files changed, 80 insertions, 80 deletions
diff --git a/Makefile b/Makefile index 7366a54a..b53e0a35 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CC = gcc WARNS = -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-but-set-variable LIBS = -lxml2 -lssl -lresolv -lncurses -lstrophe CFLAGS = -O3 $(WARNS) $(LIBS) -OBJS = log.o windows.o title_bar.o input_bar.o input_win.o jabber.o \ +OBJS = log.o windows.o title_bar.o status_bar.o input_win.o jabber.o \ profanity.o util.o command.o main.o profanity: $(OBJS) @@ -11,7 +11,7 @@ profanity: $(OBJS) log.o: log.h windows.o: windows.h util.h title_bar.o: windows.h -input_bar.o: windows.h util.h +status_bar.o: windows.h util.h input_win.o: windows.h jabber.o: jabber.h log.h windows.h profanity.o: log.h windows.h jabber.h command.h diff --git a/command.c b/command.c index fea201ec..a20520f0 100644 --- a/command.c +++ b/command.c @@ -24,11 +24,11 @@ int handle_start_command(char *cmd) char *user; user = strndup(cmd+9, strlen(cmd)-9); - inp_bar_get_password(); + status_bar_get_password(); char passwd[20]; inp_get_password(passwd); - inp_bar_print_message(user); + status_bar_print_message(user); jabber_connect(user, passwd); result = START_MAIN; } else { diff --git a/input_bar.c b/input_bar.c deleted file mode 100644 index 69807f96..00000000 --- a/input_bar.c +++ /dev/null @@ -1,60 +0,0 @@ -#include <ncurses.h> -#include "windows.h" -#include "util.h" - -static WINDOW *inp_bar; - -void create_input_bar(void) -{ - int rows, cols; - getmaxyx(stdscr, rows, cols); - - inp_bar = newwin(1, cols, rows-2, 0); - wbkgd(inp_bar, COLOR_PAIR(3)); - wrefresh(inp_bar); -} - -void inp_bar_inactive(int win) -{ - mvwaddch(inp_bar, 0, 30 + win, ' '); - if (win == 9) - mvwaddch(inp_bar, 0, 30 + win + 1, ' '); - wrefresh(inp_bar); -} - -void inp_bar_active(int win) -{ - mvwprintw(inp_bar, 0, 30 + win, "%d", win+1); - touchwin(inp_bar); - wrefresh(inp_bar); -} - -void inp_bar_get_password(void) -{ - mvwprintw(inp_bar, 0, 1, "Enter password:"); - wrefresh(inp_bar); -} - -void inp_bar_print_message(char *msg) -{ - mvwprintw(inp_bar, 0, 9, msg); - wrefresh(inp_bar); -} - -void inp_bar_update_time(void) -{ - char bar_time[8]; - char tstmp[80]; - get_time(tstmp); - sprintf(bar_time, "[%s]", tstmp); - - mvwprintw(inp_bar, 0, 1, bar_time); - wrefresh(inp_bar); - inp_put_back(); -} - -void inp_bar_clear(void) -{ - wclear(inp_bar); - wrefresh(inp_bar); -} diff --git a/input_win.c b/input_win.c index 30df10a9..0e3e8b16 100644 --- a/input_win.c +++ b/input_win.c @@ -82,7 +82,7 @@ void inp_get_password(char *passwd) mvwgetstr(inp_win, 0, 1, passwd); wmove(inp_win, 0, 1); echo(); - inp_bar_clear(); + status_bar_clear(); } void inp_put_back(void) diff --git a/profanity.c b/profanity.c index ddbef953..8548b2c8 100644 --- a/profanity.c +++ b/profanity.c @@ -51,7 +51,7 @@ static void _profanity_event_loop(int *ch, char *cmd, int *size) { usleep(1); - inp_bar_update_time(); + status_bar_update_time(); // handle incoming messages jabber_process_events(); diff --git a/status_bar.c b/status_bar.c new file mode 100644 index 00000000..dc855416 --- /dev/null +++ b/status_bar.c @@ -0,0 +1,60 @@ +#include <ncurses.h> +#include "windows.h" +#include "util.h" + +static WINDOW *status_bar; + +void create_status_bar(void) +{ + int rows, cols; + getmaxyx(stdscr, rows, cols); + + status_bar = newwin(1, cols, rows-2, 0); + wbkgd(status_bar, COLOR_PAIR(3)); + wrefresh(status_bar); +} + +void status_bar_inactive(int win) +{ + mvwaddch(status_bar, 0, 30 + win, ' '); + if (win == 9) + mvwaddch(status_bar, 0, 30 + win + 1, ' '); + wrefresh(status_bar); +} + +void status_bar_active(int win) +{ + mvwprintw(status_bar, 0, 30 + win, "%d", win+1); + touchwin(status_bar); + wrefresh(status_bar); +} + +void status_bar_get_password(void) +{ + mvwprintw(status_bar, 0, 1, "Enter password:"); + wrefresh(status_bar); +} + +void status_bar_print_message(char *msg) +{ + mvwprintw(status_bar, 0, 9, msg); + wrefresh(status_bar); +} + +void status_bar_update_time(void) +{ + char bar_time[8]; + char tstmp[80]; + get_time(tstmp); + sprintf(bar_time, "[%s]", tstmp); + + mvwprintw(status_bar, 0, 1, bar_time); + wrefresh(status_bar); + inp_put_back(); +} + +void status_bar_clear(void) +{ + wclear(status_bar); + wrefresh(status_bar); +} diff --git a/windows.c b/windows.c index b8ecd799..7d62658e 100644 --- a/windows.c +++ b/windows.c @@ -28,7 +28,7 @@ void gui_init(void) refresh(); create_title_bar(); - create_input_bar(); + create_status_bar(); create_input_window(); _create_windows(); @@ -67,7 +67,7 @@ void win_close_win(void) wclear(_wins[_curr_win].win); // set it as inactive in the status bar - inp_bar_inactive(_curr_win); + status_bar_inactive(_curr_win); // go back to console window touchwin(_wins[0].win); @@ -117,7 +117,7 @@ void win_show_incomming_msg(char *from, char *message) wprintw(_wins[i].win, line); // signify active window in status bar - inp_bar_active(i); + status_bar_active(i); // if its the current window, draw it if (_curr_win == i) { @@ -131,7 +131,7 @@ void win_show_incomming_msg(char *from, char *message) wprintw(_wins[i].win, line); // signify active window in status bar - inp_bar_active(i); + status_bar_active(i); // if its the current window, draw it if (_curr_win == i) { @@ -167,7 +167,7 @@ void win_show_outgoing_msg(char *from, char *to, char *message) wprintw(_wins[i].win, line); // signify active window in status bar - inp_bar_active(i); + status_bar_active(i); // if its the current window, draw it if (_curr_win == i) { @@ -181,7 +181,7 @@ void win_show_outgoing_msg(char *from, char *to, char *message) wprintw(_wins[i].win, line); // signify active window in status bar - inp_bar_active(i); + status_bar_active(i); // if its the current window, draw it if (_curr_win == i) { diff --git a/windows.h b/windows.h index 33581a0d..1087a677 100644 --- a/windows.h +++ b/windows.h @@ -14,16 +14,16 @@ void gui_close(void); // create windows void create_title_bar(void); -void create_input_bar(void); +void create_status_bar(void); void create_input_window(void); -// input bar actions -void inp_bar_clear(void); -void inp_bar_get_password(void); -void inp_bar_print_message(char *msg); -void inp_bar_inactive(int win); -void inp_bar_active(int win); -void inp_bar_update_time(void); +// status bar actions +void status_bar_clear(void); +void status_bar_get_password(void); +void status_bar_print_message(char *msg); +void status_bar_inactive(int win); +void status_bar_active(int win); +void status_bar_update_time(void); // input window actions void inp_get_command_str(char *cmd); |