about summary refs log tree commit diff stats
path: root/src/command/commands.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-01-07 00:38:17 +0000
committerJames Booth <boothj5@gmail.com>2016-01-07 00:38:17 +0000
commite5447cf37b949286ee0f497ee820ca096e23b0f1 (patch)
tree861a40bc32d12257393a72d0d058c87cab621959 /src/command/commands.c
parent393e69016575c0e0dc3669f43b916b3742866cf3 (diff)
downloadprofani-tty-e5447cf37b949286ee0f497ee820ca096e23b0f1.tar.gz
Added /win navigation by jid, win title
Diffstat (limited to 'src/command/commands.c')
-rw-r--r--src/command/commands.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 6674dce2..e94c9e3c 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -44,6 +44,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <langinfo.h>
+#include <ctype.h>
 
 #include "chat_session.h"
 #include "command/commands.h"
@@ -1059,13 +1060,31 @@ cmd_wins(ProfWin *window, const char *const command, gchar **args)
 gboolean
 cmd_win(ProfWin *window, const char *const command, gchar **args)
 {
-    int num = atoi(args[0]);
+    gboolean is_num = TRUE;
+    int i = 0;
+    for (i = 0; i < strlen(args[0]); i++) {
+        if (!isdigit(args[0][i])) {
+            is_num = FALSE;
+            break;
+        }
+    }
+
+    if (is_num) {
+        int num = atoi(args[0]);
 
-    ProfWin *focuswin = wins_get_by_num(num);
-    if (!focuswin) {
-        cons_show("Window %d does not exist.", num);
+        ProfWin *focuswin = wins_get_by_num(num);
+        if (!focuswin) {
+            cons_show("Window %d does not exist.", num);
+        } else {
+            ui_focus_win(focuswin);
+        }
     } else {
-        ui_focus_win(focuswin);
+        ProfWin *focuswin = wins_get_by_string(args[0]);
+        if (!focuswin) {
+            cons_show("Window \"%s\" does not exist.", args[0]);
+        } else {
+            ui_focus_win(focuswin);
+        }
     }
 
     return TRUE;