mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 19:53:01 +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])
|
count = int(args[0])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
toxic_api.display("Argument must be a number!")
|
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()
|
name = toxic_api.get_nick()
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "misc_tools.h"
|
#include "misc_tools.h"
|
||||||
#include "python_api.h"
|
#include "python_api.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "toxic_strings.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
Tox *user_tox;
|
Tox *user_tox;
|
||||||
@ -100,6 +101,8 @@ void api_send(const char *msg)
|
|||||||
self_window = get_active_window();
|
self_window = get_active_window();
|
||||||
get_time_str(timefrmt, sizeof(timefrmt));
|
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);
|
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,
|
cqueue_add(self_window->chatwin->cqueue, msg, strlen(msg), OUT_MSG,
|
||||||
self_window->chatwin->hst->line_end->id + 1);
|
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"))
|
bool dir_search = !strncmp(ubuf, "/sendfile", strlen("/sendfile"))
|
||||||
|| !strncmp(ubuf, "/avatar", strlen("/avatar"));
|
|| !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 */
|
/* isolate substring from space behind pos to pos */
|
||||||
char tmp[MAX_STR_SIZE];
|
char tmp[MAX_STR_SIZE];
|
||||||
snprintf(tmp, sizeof(tmp), "%s", ubuf);
|
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);
|
static void kill_infobox(ToxWindow *self);
|
||||||
#endif /* AUDIO */
|
#endif /* AUDIO */
|
||||||
|
|
||||||
#ifdef AUDIO
|
#if defined(AUDIO) && defined(PYTHON)
|
||||||
|
#define AC_NUM_CHAT_COMMANDS 31
|
||||||
|
#elif AUDIO
|
||||||
#define AC_NUM_CHAT_COMMANDS 30
|
#define AC_NUM_CHAT_COMMANDS 30
|
||||||
|
#elif PYTHON
|
||||||
|
#define AC_NUM_CHAT_COMMANDS 23
|
||||||
#else
|
#else
|
||||||
#define AC_NUM_CHAT_COMMANDS 22
|
#define AC_NUM_CHAT_COMMANDS 22
|
||||||
#endif /* AUDIO */
|
#endif /* AUDIO */
|
||||||
@ -108,6 +112,12 @@ static const char chat_cmd_list[AC_NUM_CHAT_COMMANDS][MAX_CMDNAME_SIZE] = {
|
|||||||
{ "/video" },
|
{ "/video" },
|
||||||
|
|
||||||
#endif /* AUDIO */
|
#endif /* AUDIO */
|
||||||
|
|
||||||
|
#ifdef PYTHON
|
||||||
|
|
||||||
|
{ "/run" },
|
||||||
|
|
||||||
|
#endif /* PYTHON */
|
||||||
};
|
};
|
||||||
|
|
||||||
static void set_self_typingstatus(ToxWindow *self, Tox *m, bool is_typing)
|
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");
|
diff = dir_match(self, m, ctx->line, L"/sendfile");
|
||||||
} else if (wcsncmp(ctx->line, L"/avatar \"", wcslen(L"/avatar \"")) == 0) {
|
} else if (wcsncmp(ctx->line, L"/avatar \"", wcslen(L"/avatar \"")) == 0) {
|
||||||
diff = dir_match(self, m, ctx->line, L"/avatar");
|
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] = {
|
const char status_cmd_list[3][8] = {
|
||||||
{"online"},
|
{"online"},
|
||||||
{"away"},
|
{"away"},
|
||||||
|
@ -69,8 +69,12 @@ static int max_groupchat_index = 0;
|
|||||||
extern struct user_settings *user_settings;
|
extern struct user_settings *user_settings;
|
||||||
extern struct Winthread Winthread;
|
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
|
#define AC_NUM_GROUP_COMMANDS 24
|
||||||
|
#elif PYTHON
|
||||||
|
#define AC_NUM_GROUP_COMMANDS 21
|
||||||
#else
|
#else
|
||||||
#define AC_NUM_GROUP_COMMANDS 20
|
#define AC_NUM_GROUP_COMMANDS 20
|
||||||
#endif /* AUDIO */
|
#endif /* AUDIO */
|
||||||
@ -97,6 +101,12 @@ static const char group_cmd_list[AC_NUM_GROUP_COMMANDS][MAX_CMDNAME_SIZE] = {
|
|||||||
{ "/requests" },
|
{ "/requests" },
|
||||||
{ "/status" },
|
{ "/status" },
|
||||||
{ "/title" },
|
{ "/title" },
|
||||||
|
|
||||||
|
#ifdef PYTHON
|
||||||
|
|
||||||
|
{ "/run" },
|
||||||
|
|
||||||
|
#endif /* PYTHON */
|
||||||
};
|
};
|
||||||
|
|
||||||
int init_groupchat_win(ToxWindow *prompt, Tox *m, uint32_t groupnum, uint8_t type)
|
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);
|
TOX_MAX_NAME_LENGTH);
|
||||||
} else if (wcsncmp(ctx->line, L"/avatar \"", wcslen(L"/avatar \"")) == 0) {
|
} else if (wcsncmp(ctx->line, L"/avatar \"", wcslen(L"/avatar \"")) == 0) {
|
||||||
diff = dir_match(self, m, ctx->line, L"/avatar");
|
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);
|
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;
|
extern FriendsList Friends;
|
||||||
FriendRequests FrndRequests;
|
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
|
#define AC_NUM_GLOB_COMMANDS 22
|
||||||
#elif AUDIO
|
#elif AUDIO
|
||||||
#define AC_NUM_GLOB_COMMANDS 20
|
#define AC_NUM_GLOB_COMMANDS 20
|
||||||
|
#elif PYTHON
|
||||||
|
#define AC_NUM_GLOB_COMMANDS 19
|
||||||
#else
|
#else
|
||||||
#define AC_NUM_GLOB_COMMANDS 18
|
#define AC_NUM_GLOB_COMMANDS 18
|
||||||
#endif
|
#endif
|
||||||
@ -92,6 +98,12 @@ static const char glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE] = {
|
|||||||
|
|
||||||
#endif /* VIDEO */
|
#endif /* VIDEO */
|
||||||
|
|
||||||
|
#ifdef PYTHON
|
||||||
|
|
||||||
|
{ "/run" },
|
||||||
|
|
||||||
|
#endif /* PYTHON */
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void kill_prompt_window(ToxWindow *self)
|
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)
|
if (wcsncmp(ctx->line, L"/avatar \"", wcslen(L"/avatar \"")) == 0)
|
||||||
diff = dir_match(self, m, ctx->line, L"/avatar");
|
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) {
|
else if (wcsncmp(ctx->line, L"/status ", wcslen(L"/status ")) == 0) {
|
||||||
const char status_cmd_list[3][8] = {
|
const char status_cmd_list[3][8] = {
|
||||||
{"online"},
|
{"online"},
|
||||||
|
Loading…
Reference in New Issue
Block a user