1
0
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Tarted up console

This commit is contained in:
James Booth 2012-02-19 00:43:35 +00:00
parent 355f2a68fd
commit d151b2d088
3 changed files with 55 additions and 8 deletions

View File

@ -61,11 +61,11 @@ int jabber_connect(char *user, char *passwd)
int connect_status = xmpp_connect_client(_conn, NULL, 0, _jabber_conn_handler, _ctx);
if (connect_status == 0) {
cons_show("Connecting...");
cons_good_show("Connecting...");
_conn_status = CONNECTING;
}
else {
cons_show("XMPP connection failure");
cons_bad_show("XMPP connection failure");
_conn_status = DISCONNECTED;
}
@ -154,7 +154,7 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn,
sprintf(line, "%s logged in successfully.", xmpp_conn_get_jid(conn));
title_bar_connected();
cons_show(line);
cons_good_show(line);
status_bar_print_message(xmpp_conn_get_jid(conn));
status_bar_refresh();
@ -170,7 +170,7 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn,
_conn_status = CONNECTED;
}
else {
cons_show("Login failed.");
cons_bad_show("Login failed.");
log_msg(CONN, "disconnected");
xmpp_stop(ctx);
_conn_status = DISCONNECTED;
@ -189,7 +189,7 @@ static int _roster_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanz
log_msg(CONN, "ERROR: query failed");
else {
query = xmpp_stanza_get_child_by_name(stanza, "query");
cons_show("Roster:");
cons_highlight_show("Roster:");
for (item = xmpp_stanza_get_children(query); item;
item = xmpp_stanza_get_next(item)) {
if ((name = xmpp_stanza_get_attribute(item, "name"))) {

View File

@ -24,6 +24,7 @@ void gui_init(void)
init_pair(3, COLOR_WHITE, COLOR_BLUE);
init_pair(4, COLOR_CYAN, COLOR_BLUE);
init_pair(5, COLOR_CYAN, COLOR_BLACK);
init_pair(6, COLOR_RED, COLOR_BLACK);
}
refresh();
@ -180,8 +181,11 @@ void cons_help(void)
char tstmp[80];
get_time(tstmp);
wprintw(_wins[0].win,
" [%s] Help:\n", tstmp);
wprintw(_wins[0].win, " [%s] ", tstmp);
wattron(_wins[0].win, A_BOLD);
wprintw(_wins[0].win, "Help:\n");
wattroff(_wins[0].win, A_BOLD);
wprintw(_wins[0].win,
" [%s] Commands:\n", tstmp);
wprintw(_wins[0].win,
@ -204,6 +208,43 @@ void cons_help(void)
" [%s] F2-10 : Chat windows.\n", tstmp);
}
void cons_good_show(char *msg)
{
char tstmp[80];
get_time(tstmp);
wprintw(_wins[0].win, " [%s] ", tstmp);
wattron(_wins[0].win, A_BOLD);
wattron(_wins[0].win, COLOR_PAIR(2));
wprintw(_wins[0].win, "%s\n", msg);
wattroff(_wins[0].win, A_BOLD);
wattroff(_wins[0].win, COLOR_PAIR(2));
}
void cons_bad_show(char *msg)
{
char tstmp[80];
get_time(tstmp);
wprintw(_wins[0].win, " [%s] ", tstmp);
wattron(_wins[0].win, A_BOLD);
wattron(_wins[0].win, COLOR_PAIR(6));
wprintw(_wins[0].win, "%s\n", msg);
wattroff(_wins[0].win, A_BOLD);
wattroff(_wins[0].win, COLOR_PAIR(6));
}
void cons_highlight_show(char *msg)
{
char tstmp[80];
get_time(tstmp);
wprintw(_wins[0].win, " [%s] ", tstmp);
wattron(_wins[0].win, A_BOLD);
wprintw(_wins[0].win, "%s\n", msg);
wattroff(_wins[0].win, A_BOLD);
}
void cons_show(char *msg)
{
char tstmp[80];
@ -252,7 +293,10 @@ static void _create_windows(void)
char tstmp[80];
get_time(tstmp);
wprintw(cons.win, " [%s] Welcome to Profanity.\n", tstmp);
wprintw(cons.win, " [%s] ", tstmp);
wattron(cons.win, A_BOLD);
wprintw(cons.win, "Welcome to Profanity.\n");
wattroff(cons.win, A_BOLD);
touchwin(cons.win);
wrefresh(cons.win);
_wins[0] = cons;

View File

@ -40,6 +40,9 @@ void cons_bad_command(char *cmd);
void cons_bad_connect(void);
void cons_bad_message(void);
void cons_show(char *cmd);
void cons_good_show(char *cmd);
void cons_bad_show(char *cmd);
void cons_highlight_show(char *cmd);
// status bar actions
void status_bar_refresh(void);