Added /win navigation by jid, win title

This commit is contained in:
James Booth
2016-01-07 00:38:17 +00:00
parent 393e690165
commit e5447cf37b
4 changed files with 189 additions and 8 deletions

View File

@@ -114,6 +114,7 @@ static char* _tls_autocomplete(ProfWin *window, const char *const input);
static char* _script_autocomplete(ProfWin *window, const char *const input);
static char* _subject_autocomplete(ProfWin *window, const char *const input);
static char* _console_autocomplete(ProfWin *window, const char *const input);
static char* _win_autocomplete(ProfWin *window, const char *const input);
GHashTable *commands = NULL;
@@ -789,12 +790,30 @@ static struct cmd_t command_defs[] =
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/win <num>")
"/win console",
"/win <num>",
"/win <barejid>",
"/win <nick>",
"/win <roomjid>",
"/win <roomoccupantjid>",
"/win xmlconsole")
CMD_DESC(
"Move to the specified window.")
CMD_ARGS(
{ "<num>", "Window number to display." })
CMD_NOEXAMPLES
{ "console", "Go to the Console window." },
{ "<num>", "Go to specified window number." },
{ "<barejid>", "Go to chat window with contact by JID if open." },
{ "<nick>", "Go to chat window with contact by nickname if open." },
{ "<roomjid>", "Go to chat room window with roomjid if open." },
{ "<roomoccupantjid>", "Go to private chat roomjidoccupant if open." },
{ "xmlconsole", "Go to the XML Console window if open." })
CMD_EXAMPLES(
"/win console",
"/win 4",
"/win friend@chat.org",
"/win Eddie",
"/win bigroom@conference.chat.org",
"/win bigroom@conference.chat.org/bruce")
},
{ "/wins",
@@ -2722,6 +2741,7 @@ cmd_reset_autocomplete(ProfWin *window)
bookmark_autocomplete_reset();
prefs_reset_room_trigger_ac();
win_reset_search_attempts();
}
gboolean
@@ -2957,6 +2977,7 @@ _cmd_complete_parameters(ProfWin *window, const char *const input)
g_hash_table_insert(ac_funcs, "/script", _script_autocomplete);
g_hash_table_insert(ac_funcs, "/subject", _subject_autocomplete);
g_hash_table_insert(ac_funcs, "/console", _console_autocomplete);
g_hash_table_insert(ac_funcs, "/win", _win_autocomplete);
int len = strlen(input);
char parsed[len+1];
@@ -4231,6 +4252,19 @@ _console_autocomplete(ProfWin *window, const char *const input)
return NULL;
}
static char*
_win_autocomplete(ProfWin *window, const char *const input)
{
char *found = NULL;
found = autocomplete_param_with_func(input, "/win", win_autocomplete);
if (found) {
return found;
}
return NULL;
}
static char*
_subject_autocomplete(ProfWin *window, const char *const input)
{

View File

@@ -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;
}
}
ProfWin *focuswin = wins_get_by_num(num);
if (!focuswin) {
cons_show("Window %d does not exist.", num);
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);
} 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;