mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-14 05:33:03 +01:00
Add "/run" to autocompleter and fix example Python script.
This commit is contained in:
parent
4f60d546e6
commit
22ea522baf
@ -20,6 +20,10 @@ def send_fortune(args):
|
||||
count = int(args[0])
|
||||
except ValueError:
|
||||
toxic_api.display("Argument must be a number!")
|
||||
return
|
||||
|
||||
if count < 0 or count > 20:
|
||||
toxic_api.display("Argument is too large!")
|
||||
|
||||
name = toxic_api.get_nick()
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "misc_tools.h"
|
||||
#include "python_api.h"
|
||||
#include "settings.h"
|
||||
#include "toxic_strings.h"
|
||||
#include "windows.h"
|
||||
|
||||
Tox *user_tox;
|
||||
@ -100,6 +101,8 @@ void api_send(const char *msg)
|
||||
self_window = get_active_window();
|
||||
get_time_str(timefrmt, sizeof(timefrmt));
|
||||
|
||||
strncpy((char *) self_window->chatwin->line, msg, sizeof(self_window->chatwin->line));
|
||||
add_line_to_hist(self_window->chatwin);
|
||||
line_info_add(self_window, timefrmt, name, NULL, OUT_MSG, 0, 0, "%s", msg);
|
||||
cqueue_add(self_window->chatwin->cqueue, msg, strlen(msg), OUT_MSG,
|
||||
self_window->chatwin->hst->line_end->id + 1);
|
||||
|
@ -110,6 +110,10 @@ int complete_line(ToxWindow *self, const void *list, int n_items, int size)
|
||||
bool dir_search = !strncmp(ubuf, "/sendfile", strlen("/sendfile"))
|
||||
|| !strncmp(ubuf, "/avatar", strlen("/avatar"));
|
||||
|
||||
#ifdef PYTHON
|
||||
dir_search = dir_search || !strncmp(ubuf, "/run", strlen("/run"));
|
||||
#endif
|
||||
|
||||
/* isolate substring from space behind pos to pos */
|
||||
char tmp[MAX_STR_SIZE];
|
||||
snprintf(tmp, sizeof(tmp), "%s", ubuf);
|
||||
|
22
src/chat.c
22
src/chat.c
@ -65,8 +65,12 @@ static void init_infobox(ToxWindow *self);
|
||||
static void kill_infobox(ToxWindow *self);
|
||||
#endif /* AUDIO */
|
||||
|
||||
#ifdef AUDIO
|
||||
#if defined(AUDIO) && defined(PYTHON)
|
||||
#define AC_NUM_CHAT_COMMANDS 31
|
||||
#elif AUDIO
|
||||
#define AC_NUM_CHAT_COMMANDS 30
|
||||
#elif PYTHON
|
||||
#define AC_NUM_CHAT_COMMANDS 23
|
||||
#else
|
||||
#define AC_NUM_CHAT_COMMANDS 22
|
||||
#endif /* AUDIO */
|
||||
@ -108,6 +112,12 @@ static const char chat_cmd_list[AC_NUM_CHAT_COMMANDS][MAX_CMDNAME_SIZE] = {
|
||||
{ "/video" },
|
||||
|
||||
#endif /* AUDIO */
|
||||
|
||||
#ifdef PYTHON
|
||||
|
||||
{ "/run" },
|
||||
|
||||
#endif /* PYTHON */
|
||||
};
|
||||
|
||||
static void set_self_typingstatus(ToxWindow *self, Tox *m, bool is_typing)
|
||||
@ -931,7 +941,15 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
||||
diff = dir_match(self, m, ctx->line, L"/sendfile");
|
||||
} else if (wcsncmp(ctx->line, L"/avatar \"", wcslen(L"/avatar \"")) == 0) {
|
||||
diff = dir_match(self, m, ctx->line, L"/avatar");
|
||||
} else if (wcsncmp(ctx->line, L"/status ", wcslen(L"/status ")) == 0) {
|
||||
}
|
||||
|
||||
#ifdef PYTHON
|
||||
else if (wcsncmp(ctx->line, L"/run \"", wcslen(L"/run \"")) == 0) {
|
||||
diff = dir_match(self, m, ctx->line, L"/run");
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (wcsncmp(ctx->line, L"/status ", wcslen(L"/status ")) == 0) {
|
||||
const char status_cmd_list[3][8] = {
|
||||
{"online"},
|
||||
{"away"},
|
||||
|
@ -69,8 +69,12 @@ static int max_groupchat_index = 0;
|
||||
extern struct user_settings *user_settings;
|
||||
extern struct Winthread Winthread;
|
||||
|
||||
#ifdef AUDIO
|
||||
#if defined(AUDIO) && defined(PYTHON)
|
||||
#define AC_NUM_GROUP_COMMANDS 25
|
||||
#elif AUDIO
|
||||
#define AC_NUM_GROUP_COMMANDS 24
|
||||
#elif PYTHON
|
||||
#define AC_NUM_GROUP_COMMANDS 21
|
||||
#else
|
||||
#define AC_NUM_GROUP_COMMANDS 20
|
||||
#endif /* AUDIO */
|
||||
@ -97,6 +101,12 @@ static const char group_cmd_list[AC_NUM_GROUP_COMMANDS][MAX_CMDNAME_SIZE] = {
|
||||
{ "/requests" },
|
||||
{ "/status" },
|
||||
{ "/title" },
|
||||
|
||||
#ifdef PYTHON
|
||||
|
||||
{ "/run" },
|
||||
|
||||
#endif /* PYTHON */
|
||||
};
|
||||
|
||||
int init_groupchat_win(ToxWindow *prompt, Tox *m, uint32_t groupnum, uint8_t type)
|
||||
@ -543,7 +553,15 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
||||
TOX_MAX_NAME_LENGTH);
|
||||
} else if (wcsncmp(ctx->line, L"/avatar \"", wcslen(L"/avatar \"")) == 0) {
|
||||
diff = dir_match(self, m, ctx->line, L"/avatar");
|
||||
} else {
|
||||
}
|
||||
|
||||
#ifdef PYTHON
|
||||
else if (wcsncmp(ctx->line, L"/run \"", wcslen(L"/run \"")) == 0) {
|
||||
diff = dir_match(self, m, ctx->line, L"/run");
|
||||
}
|
||||
#endif
|
||||
|
||||
else {
|
||||
diff = complete_line(self, group_cmd_list, AC_NUM_GROUP_COMMANDS, MAX_CMDNAME_SIZE);
|
||||
}
|
||||
|
||||
|
20
src/prompt.c
20
src/prompt.c
@ -49,10 +49,16 @@ extern struct Winthread Winthread;
|
||||
|
||||
extern FriendsList Friends;
|
||||
FriendRequests FrndRequests;
|
||||
#ifdef VIDEO
|
||||
#if defined(PYTHON) && defined(VIDEO)
|
||||
#define AC_NUM_GLOB_COMMANDS 23
|
||||
#elif defined(PYTHON) && defined(AUDIO)
|
||||
#define AC_NUM_GLOB_COMMANDS 21
|
||||
#elif VIDEO
|
||||
#define AC_NUM_GLOB_COMMANDS 22
|
||||
#elif AUDIO
|
||||
#define AC_NUM_GLOB_COMMANDS 20
|
||||
#elif PYTHON
|
||||
#define AC_NUM_GLOB_COMMANDS 19
|
||||
#else
|
||||
#define AC_NUM_GLOB_COMMANDS 18
|
||||
#endif
|
||||
@ -92,6 +98,12 @@ static const char glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE] = {
|
||||
|
||||
#endif /* VIDEO */
|
||||
|
||||
#ifdef PYTHON
|
||||
|
||||
{ "/run" },
|
||||
|
||||
#endif /* PYTHON */
|
||||
|
||||
};
|
||||
|
||||
void kill_prompt_window(ToxWindow *self)
|
||||
@ -214,6 +226,12 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
||||
|
||||
if (wcsncmp(ctx->line, L"/avatar \"", wcslen(L"/avatar \"")) == 0)
|
||||
diff = dir_match(self, m, ctx->line, L"/avatar");
|
||||
|
||||
#ifdef PYTHON
|
||||
else if (wcsncmp(ctx->line, L"/run \"", wcslen(L"/run \"")) == 0)
|
||||
diff = dir_match(self, m, ctx->line, L"/run");
|
||||
#endif
|
||||
|
||||
else if (wcsncmp(ctx->line, L"/status ", wcslen(L"/status ")) == 0) {
|
||||
const char status_cmd_list[3][8] = {
|
||||
{"online"},
|
||||
|
Loading…
Reference in New Issue
Block a user