about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-09-29 15:04:19 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-09-29 15:04:19 +0200
commitb961ad29c764412f5dc873ea71729b639f52aaa8 (patch)
treebc586cd0268b59368987a9b224852dc4faf44ec3
parent0f732466f8979a592e4028a0e16799e653702fc2 (diff)
downloadprofani-tty-b961ad29c764412f5dc873ea71729b639f52aaa8.tar.gz
Allow pasing a jid to info command in chat window
If we pass a jid/nick to `/info` in a chat window we will still get the
output. But on the console window.

Regards https://github.com/profanity-im/profanity/issues/1194
-rw-r--r--src/command/cmd_funcs.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 1a3cca40..52989f84 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -3300,6 +3300,21 @@ cmd_status(ProfWin *window, const char *const command, gchar **args)
     return TRUE;
 }
 
+static void
+_cmd_info_show_conact(char *usr)
+{
+    char *usr_jid = roster_barejid_from_name(usr);
+    if (usr_jid == NULL) {
+        usr_jid = usr;
+    }
+    PContact pcontact = roster_get_contact(usr_jid);
+    if (pcontact) {
+        cons_show_info(pcontact);
+    } else {
+        cons_show("No such contact \"%s\" in roster.", usr);
+    }
+}
+
 gboolean
 cmd_info(ProfWin *window, const char *const command, gchar **args)
 {
@@ -3334,7 +3349,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args)
             break;
         case WIN_CHAT:
             if (usr) {
-                win_println(window, THEME_DEFAULT, '-', "No parameter required when in chat.");
+                _cmd_info_show_conact(usr);
             } else {
                 ProfChatWin *chatwin = (ProfChatWin*)window;
                 assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
@@ -3348,7 +3363,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args)
             break;
         case WIN_PRIVATE:
             if (usr) {
-                win_println(window, THEME_DEFAULT, '-', "No parameter required when in chat.");
+                _cmd_info_show_conact(usr);
             } else {
                 ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
                 assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
@@ -3364,16 +3379,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args)
             break;
         case WIN_CONSOLE:
             if (usr) {
-                char *usr_jid = roster_barejid_from_name(usr);
-                if (usr_jid == NULL) {
-                    usr_jid = usr;
-                }
-                PContact pcontact = roster_get_contact(usr_jid);
-                if (pcontact) {
-                    cons_show_info(pcontact);
-                } else {
-                    cons_show("No such contact \"%s\" in roster.", usr);
-                }
+                _cmd_info_show_conact(usr);
             } else {
                 cons_bad_cmd_usage(command);
             }