From 2375b7ae526c585d17286f9ca5519398e88a11fa Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 29 Jul 2012 21:47:30 +0100 Subject: [PATCH] Show tinyurl errors and usage in chat windows --- src/command.c | 8 +++++++- src/ui.h | 2 ++ src/windows.c | 24 +++++++++++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/command.c b/src/command.c index 30c76b12..bbc77574 100644 --- a/src/command.c +++ b/src/command.c @@ -290,6 +290,9 @@ _cmd_tiny(const char * const inp) GString *error = g_string_new("/tiny, badly formed URL: "); g_string_append(error, url); cons_bad_show(error->str); + if (win_in_chat()) { + win_bad_show(error->str); + } g_string_free(error, TRUE); free(url); } else if (win_in_chat()) { @@ -305,7 +308,10 @@ _cmd_tiny(const char * const inp) free(url); } } else { - cons_show("usage: /tiny url"); + cons_show("Usage: /tiny url"); + if (win_in_chat()) { + win_show("Usage: /tiny url"); + } } return TRUE; diff --git a/src/ui.h b/src/ui.h index eb10fbad..f0811aca 100644 --- a/src/ui.h +++ b/src/ui.h @@ -70,6 +70,8 @@ void win_contact_online(const char * const from, const char * const show, void win_contact_offline(const char * const from, const char * const show, const char * const status); void win_disconnected(void); +void win_show(const char * const msg); +void win_bad_show(const char * const msg); // console window actions void cons_help(void); diff --git a/src/windows.c b/src/windows.c index bfdaca2a..0c6b577f 100644 --- a/src/windows.c +++ b/src/windows.c @@ -261,6 +261,28 @@ win_show_outgoing_msg(const char * const from, const char * const to, } } +void +win_show(const char * const msg) +{ + WINDOW *win = _wins[_curr_prof_win].win; + _win_show_time(win); + wprintw(win, "%s\n", msg); + + dirty = TRUE; +} + +void +win_bad_show(const char * const msg) +{ + WINDOW *win = _wins[_curr_prof_win].win; + _win_show_time(win); + wattron(win, COLOR_PAIR(6)); + wprintw(win, "%s\n", msg); + wattroff(win, COLOR_PAIR(6)); + + dirty = TRUE; +} + void win_contact_online(const char * const from, const char * const show, const char * const status) @@ -362,7 +384,7 @@ cons_help(void) cons_show("/prefs : Show current UI preferences."); cons_show("/connect user@host : Login to jabber."); cons_show("/msg user@host mesg : Send mesg to user."); - cons_show("/tiny url : Send url as tinyurl"); + cons_show("/tiny url : Send url as tinyurl in current chat."); cons_show("/close : Close a chat window."); cons_show("/who : Find out who is online."); cons_show("/ros : List all contacts.");