Tidied showing user on message win

This commit is contained in:
James Booth
2012-02-26 18:35:40 +00:00
parent 00f7ce628f
commit 9807c15b3f

View File

@@ -33,6 +33,7 @@ static void _create_windows(void);
static int _find_win(char *contact); static int _find_win(char *contact);
static void _current_window_refresh(); static void _current_window_refresh();
static void _win_show_time(int win); static void _win_show_time(int win);
static void _win_show_user(int win, char *user, int colour);
void gui_init(void) void gui_init(void)
{ {
@@ -116,21 +117,6 @@ char *win_get_recipient(void)
return recipient; return recipient;
} }
static void _win_show_time(int win)
{
char tstmp[80];
get_time(tstmp);
wattron(_wins[win].win, COLOR_PAIR(5));
wprintw(_wins[win].win, " [");
wattroff(_wins[win].win, COLOR_PAIR(5));
wprintw(_wins[win].win, "%s", tstmp);
wattron(_wins[win].win, COLOR_PAIR(5));
wprintw(_wins[win].win, "] ");
wattroff(_wins[win].win, COLOR_PAIR(5));
}
void win_show_incomming_msg(char *from, char *message) void win_show_incomming_msg(char *from, char *message)
{ {
char from_cpy[strlen(from) + 1]; char from_cpy[strlen(from) + 1];
@@ -138,54 +124,20 @@ void win_show_incomming_msg(char *from, char *message)
char *short_from = strtok(from_cpy, "/"); char *short_from = strtok(from_cpy, "/");
int win = _find_win(short_from); int win = _find_win(short_from);
_win_show_time(win); _win_show_time(win);
_win_show_user(win, short_from, 1);
// print user
wattron(_wins[win].win, A_DIM);
wprintw(_wins[win].win, "<");
wattroff(_wins[win].win, A_DIM);
wattron(_wins[win].win, COLOR_PAIR(2));
wattron(_wins[win].win, A_BOLD);
wprintw(_wins[win].win, "%s", short_from);
wattroff(_wins[win].win, COLOR_PAIR(2));
wattroff(_wins[win].win, A_BOLD);
wattron(_wins[win].win, A_DIM);
wprintw(_wins[win].win, "> ");
wattroff(_wins[win].win, A_DIM);
// print message
wprintw(_wins[win].win, "%s\n", message); wprintw(_wins[win].win, "%s\n", message);
// update window
status_bar_active(win); status_bar_active(win);
} }
void win_show_outgoing_msg(char *from, char *to, char *message) void win_show_outgoing_msg(char *from, char *to, char *message)
{ {
int win = _find_win(to); int win = _find_win(to);
_win_show_time(win); _win_show_time(win);
_win_show_user(win, from, 0);
// print user
wattron(_wins[win].win, A_DIM);
wprintw(_wins[win].win, "<");
wattroff(_wins[win].win, A_DIM);
wattron(_wins[win].win, A_BOLD);
wprintw(_wins[win].win, "%s", from);
wattroff(_wins[win].win, A_BOLD);
wattron(_wins[win].win, A_DIM);
wprintw(_wins[win].win, "> ");
wattroff(_wins[win].win, A_DIM);
// print message
wprintw(_wins[win].win, "%s\n", message); wprintw(_wins[win].win, "%s\n", message);
// update window
status_bar_active(win); status_bar_active(win);
} }
@@ -366,6 +318,40 @@ static int _find_win(char *contact)
return i; return i;
} }
static void _win_show_time(int win)
{
char tstmp[80];
get_time(tstmp);
wattron(_wins[win].win, COLOR_PAIR(5));
wprintw(_wins[win].win, " [");
wattroff(_wins[win].win, COLOR_PAIR(5));
wprintw(_wins[win].win, "%s", tstmp);
wattron(_wins[win].win, COLOR_PAIR(5));
wprintw(_wins[win].win, "] ");
wattroff(_wins[win].win, COLOR_PAIR(5));
}
static void _win_show_user(int win, char *user, int colour)
{
wattron(_wins[win].win, A_DIM);
wprintw(_wins[win].win, "<");
wattroff(_wins[win].win, A_DIM);
if (colour)
wattron(_wins[win].win, COLOR_PAIR(2));
wattron(_wins[win].win, A_BOLD);
wprintw(_wins[win].win, "%s", user);
if (colour)
wattroff(_wins[win].win, COLOR_PAIR(2));
wattroff(_wins[win].win, A_BOLD);
wattron(_wins[win].win, A_DIM);
wprintw(_wins[win].win, "> ");
wattroff(_wins[win].win, A_DIM);
}
static void _current_window_refresh() static void _current_window_refresh()
{ {
touchwin(_wins[_curr_win].win); touchwin(_wins[_curr_win].win);