mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 20:23:01 +01:00
improve /help system and add startup welcome message
This commit is contained in:
parent
10d0e99d72
commit
6754741f37
@ -1,4 +1,4 @@
|
|||||||
TOXIC_VERSION = 0.4.3
|
TOXIC_VERSION = 0.4.4
|
||||||
REV = $(shell git rev-list HEAD --count)
|
REV = $(shell git rev-list HEAD --count)
|
||||||
VERSION = $(TOXIC_VERSION)_r$(REV)
|
VERSION = $(TOXIC_VERSION)_r$(REV)
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ CFLAGS += $(USER_CFLAGS)
|
|||||||
LDFLAGS = $(USER_LDFLAGS)
|
LDFLAGS = $(USER_LDFLAGS)
|
||||||
|
|
||||||
OBJ = chat.o chat_commands.o configdir.o dns.o execute.o file_senders.o
|
OBJ = chat.o chat_commands.o configdir.o dns.o execute.o file_senders.o
|
||||||
OBJ += friendlist.o global_commands.o groupchat.o line_info.o input.o
|
OBJ += friendlist.o global_commands.o groupchat.o line_info.o input.o help.o
|
||||||
OBJ += log.o misc_tools.o prompt.o settings.o toxic.o toxic_strings.o windows.o
|
OBJ += log.o misc_tools.o prompt.o settings.o toxic.o toxic_strings.o windows.o
|
||||||
|
|
||||||
# Variables for audio support
|
# Variables for audio support
|
||||||
|
28
src/chat.c
28
src/chat.c
@ -35,6 +35,7 @@
|
|||||||
#include "line_info.h"
|
#include "line_info.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "help.h"
|
||||||
|
|
||||||
#ifdef _SUPPORT_AUDIO
|
#ifdef _SUPPORT_AUDIO
|
||||||
#include "audio_call.h"
|
#include "audio_call.h"
|
||||||
@ -119,13 +120,14 @@ void kill_chat_window(ToxWindow *self, Tox *m)
|
|||||||
delwin(ctx->history);
|
delwin(ctx->history);
|
||||||
delwin(self->window);
|
delwin(self->window);
|
||||||
delwin(statusbar->topline);
|
delwin(statusbar->topline);
|
||||||
del_window(self);
|
|
||||||
disable_chatwin(f_num);
|
disable_chatwin(f_num);
|
||||||
|
|
||||||
free(ctx->log);
|
free(ctx->log);
|
||||||
free(ctx->hst);
|
free(ctx->hst);
|
||||||
free(ctx);
|
free(ctx);
|
||||||
|
free(self->help);
|
||||||
free(statusbar);
|
free(statusbar);
|
||||||
|
del_window(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onMessage(ToxWindow *self, Tox *m, int32_t num, const uint8_t *msg, uint16_t len)
|
static void chat_onMessage(ToxWindow *self, Tox *m, int32_t num, const uint8_t *msg, uint16_t len)
|
||||||
@ -648,6 +650,11 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
|||||||
if (x2 <= 0)
|
if (x2 <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (self->help->active) {
|
||||||
|
help_onKey(self, key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ltr) { /* char is printable */
|
if (ltr) { /* char is printable */
|
||||||
input_new_char(self, key, x, y, x2, y2);
|
input_new_char(self, key, x, y, x2, y2);
|
||||||
|
|
||||||
@ -836,6 +843,10 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
|
|||||||
draw_infobox(self);
|
draw_infobox(self);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (self->help->active) {
|
||||||
|
wrefresh(self->window);
|
||||||
|
help_onDraw(self);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onInit(ToxWindow *self, Tox *m)
|
static void chat_onInit(ToxWindow *self, Tox *m)
|
||||||
@ -878,7 +889,6 @@ static void chat_onInit(ToxWindow *self, Tox *m)
|
|||||||
if (friends[self->num].logging_on)
|
if (friends[self->num].logging_on)
|
||||||
log_enable(self->name, friends[self->num].pub_key, ctx->log);
|
log_enable(self->name, friends[self->num].pub_key, ctx->log);
|
||||||
|
|
||||||
execute(ctx->history, self, m, "/help", CHAT_COMMAND_MODE);
|
|
||||||
execute(ctx->history, self, m, "/log", GLOBAL_COMMAND_MODE);
|
execute(ctx->history, self, m, "/log", GLOBAL_COMMAND_MODE);
|
||||||
|
|
||||||
scrollok(ctx->history, 0);
|
scrollok(ctx->history, 0);
|
||||||
@ -934,17 +944,15 @@ ToxWindow new_chat(Tox *m, int32_t friendnum)
|
|||||||
strcpy(ret.name, name);
|
strcpy(ret.name, name);
|
||||||
|
|
||||||
ChatContext *chatwin = calloc(1, sizeof(ChatContext));
|
ChatContext *chatwin = calloc(1, sizeof(ChatContext));
|
||||||
memset(chatwin, 0, sizeof(ChatContext));
|
|
||||||
|
|
||||||
StatusBar *stb = calloc(1, sizeof(StatusBar));
|
StatusBar *stb = calloc(1, sizeof(StatusBar));
|
||||||
memset(stb, 0, sizeof(StatusBar));
|
Help *help = calloc(1, sizeof(Help));
|
||||||
|
|
||||||
if (stb != NULL && chatwin != NULL) {
|
if (stb == NULL || chatwin == NULL || help == NULL)
|
||||||
ret.chatwin = chatwin;
|
|
||||||
ret.stb = stb;
|
|
||||||
} else {
|
|
||||||
exit_toxic_err("failed in new_chat", FATALERR_MEMORY);
|
exit_toxic_err("failed in new_chat", FATALERR_MEMORY);
|
||||||
}
|
|
||||||
|
ret.chatwin = chatwin;
|
||||||
|
ret.stb = stb;
|
||||||
|
ret.help = help;
|
||||||
|
|
||||||
ret.num = friendnum;
|
ret.num = friendnum;
|
||||||
|
|
||||||
|
@ -38,61 +38,6 @@ extern ToxicFriend friends[MAX_FRIENDS_NUM];
|
|||||||
extern FileSender file_senders[MAX_FILES];
|
extern FileSender file_senders[MAX_FILES];
|
||||||
extern uint8_t max_file_senders_index;
|
extern uint8_t max_file_senders_index;
|
||||||
|
|
||||||
void cmd_chat_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
|
||||||
{
|
|
||||||
struct history *hst = self->chatwin->hst;
|
|
||||||
line_info_clear(hst);
|
|
||||||
struct line_info *start = hst->line_start;
|
|
||||||
|
|
||||||
if (argc == 1) {
|
|
||||||
if (!strcmp(argv[1], "global")) {
|
|
||||||
execute(window, self, m, "/help", GLOBAL_COMMAND_MODE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t *msg = "Chat commands:";
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
|
||||||
|
|
||||||
#ifdef _SUPPORT_AUDIO
|
|
||||||
#define NUMLINES 16
|
|
||||||
#else
|
|
||||||
#define NUMLINES 9
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t lines[NUMLINES][MAX_STR_SIZE] = {
|
|
||||||
|
|
||||||
#ifdef _SUPPORT_AUDIO
|
|
||||||
{ " /call : Audio call" },
|
|
||||||
{ " /cancel : Cancel call" },
|
|
||||||
{ " /answer : Answer incomming call" },
|
|
||||||
{ " /reject : Reject incoming call" },
|
|
||||||
{ " /hangup : Hangup active call" },
|
|
||||||
{ " /sdev <type> <id> : Change active device" },
|
|
||||||
{ " /mute <type> : Mute active device if in call" },
|
|
||||||
{ " /sense <value> : VAD sensitivity treshold" },
|
|
||||||
#endif /* _SUPPORT_AUDIO */
|
|
||||||
{ " /invite <n> : Invite friend to a group chat" },
|
|
||||||
{ " /join : Join a pending group chat" },
|
|
||||||
{ " /log <on> or <off> : Enable/disable logging" },
|
|
||||||
{ " /sendfile <filepath> : Send a file" },
|
|
||||||
{ " /savefile <n> : Receive a file" },
|
|
||||||
{ " /close : Close the current chat window" },
|
|
||||||
{ " /help : Print this message again" },
|
|
||||||
{ " /help global : Show a list of global commands" },
|
|
||||||
};
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < NUMLINES; ++i)
|
|
||||||
line_info_add(self, NULL, NULL, NULL, lines[i], SYS_MSG, 0, 0);
|
|
||||||
|
|
||||||
msg = " * Use Page Up/Page Down to scroll chat history\n";
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
|
||||||
|
|
||||||
hst->line_start = start;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
uint8_t *errmsg;
|
uint8_t *errmsg;
|
||||||
|
@ -26,13 +26,11 @@
|
|||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "toxic.h"
|
#include "toxic.h"
|
||||||
|
|
||||||
void cmd_chat_help(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
|
||||||
void cmd_groupinvite(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_groupinvite(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_join_group(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_join_group(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_savefile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_savefile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_sendfile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_sendfile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
|
|
||||||
|
|
||||||
#ifdef _SUPPORT_AUDIO
|
#ifdef _SUPPORT_AUDIO
|
||||||
void cmd_call(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_call(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_answer(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_answer(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
|
@ -60,7 +60,6 @@ static struct cmd_func global_commands[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct cmd_func chat_commands[] = {
|
static struct cmd_func chat_commands[] = {
|
||||||
{ "/help", cmd_chat_help },
|
|
||||||
{ "/invite", cmd_groupinvite },
|
{ "/invite", cmd_groupinvite },
|
||||||
{ "/join", cmd_join_group },
|
{ "/join", cmd_join_group },
|
||||||
{ "/savefile", cmd_savefile },
|
{ "/savefile", cmd_savefile },
|
||||||
|
@ -30,10 +30,10 @@
|
|||||||
|
|
||||||
#ifdef _SUPPORT_AUDIO
|
#ifdef _SUPPORT_AUDIO
|
||||||
#define GLOBAL_NUM_COMMANDS 16
|
#define GLOBAL_NUM_COMMANDS 16
|
||||||
#define CHAT_NUM_COMMANDS 13
|
#define CHAT_NUM_COMMANDS 12
|
||||||
#else
|
#else
|
||||||
#define GLOBAL_NUM_COMMANDS 14
|
#define GLOBAL_NUM_COMMANDS 14
|
||||||
#define CHAT_NUM_COMMANDS 5
|
#define CHAT_NUM_COMMANDS 4
|
||||||
#endif /* _SUPPORT_AUDIO */
|
#endif /* _SUPPORT_AUDIO */
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -285,10 +285,7 @@ static void delete_friend(Tox *m, int32_t f_num)
|
|||||||
/* activates delete friend popup */
|
/* activates delete friend popup */
|
||||||
static void del_friend_activate(ToxWindow *self, Tox *m, int32_t f_num)
|
static void del_friend_activate(ToxWindow *self, Tox *m, int32_t f_num)
|
||||||
{
|
{
|
||||||
int x2, y2;
|
|
||||||
getmaxyx(self->window, y2, x2);
|
|
||||||
pendingdelete.popup = newwin(3, 22 + TOXIC_MAX_NAME_LENGTH, 8, 8);
|
pendingdelete.popup = newwin(3, 22 + TOXIC_MAX_NAME_LENGTH, 8, 8);
|
||||||
|
|
||||||
pendingdelete.active = true;
|
pendingdelete.active = true;
|
||||||
pendingdelete.num = f_num;
|
pendingdelete.num = f_num;
|
||||||
}
|
}
|
||||||
@ -373,7 +370,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
|||||||
uint64_t cur_time = get_unix_time();
|
uint64_t cur_time = get_unix_time();
|
||||||
struct tm cur_loc_tm = *localtime((const time_t*)&cur_time);
|
struct tm cur_loc_tm = *localtime((const time_t*)&cur_time);
|
||||||
|
|
||||||
bool fix_statuses = x2 != self->x; /* true if window x axis has changed */
|
bool fix_statuses = x2 != self->x; /* true if window max x value has changed */
|
||||||
|
|
||||||
wattron(self->window, COLOR_PAIR(CYAN));
|
wattron(self->window, COLOR_PAIR(CYAN));
|
||||||
wprintw(self->window, " Open a chat window with the");
|
wprintw(self->window, " Open a chat window with the");
|
||||||
@ -396,7 +393,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
|||||||
wattroff(self->window, A_BOLD);
|
wattroff(self->window, A_BOLD);
|
||||||
wprintw(self->window, "%d/%d \n\n", nf, num_friends);
|
wprintw(self->window, "%d/%d \n\n", nf, num_friends);
|
||||||
|
|
||||||
if ((y2 - FLIST_OFST) <= 0) /* don't allow division by zero */
|
if ((y2 - FLIST_OFST) <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int selected_num = 0;
|
int selected_num = 0;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#include "groupchat.h"
|
#include "groupchat.h"
|
||||||
#include "prompt.h"
|
#include "prompt.h"
|
||||||
|
#include "help.h"
|
||||||
|
|
||||||
extern char *DATA_FILE;
|
extern char *DATA_FILE;
|
||||||
extern ToxWindow *prompt;
|
extern ToxWindow *prompt;
|
||||||
@ -384,51 +385,7 @@ void cmd_note(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
|||||||
|
|
||||||
void cmd_prompt_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_prompt_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
struct history *hst = self->chatwin->hst;
|
help_init_menu(self);
|
||||||
line_info_clear(hst);
|
|
||||||
struct line_info *start = hst->line_start;
|
|
||||||
|
|
||||||
uint8_t *msg = "Global commands:";
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
|
||||||
|
|
||||||
#ifdef _SUPPORT_AUDIO
|
|
||||||
#define NUMLINES 14
|
|
||||||
#else
|
|
||||||
#define NUMLINES 12
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t lines[NUMLINES][MAX_STR_SIZE] = {
|
|
||||||
|
|
||||||
{ " /add <id> <msg> : Add friend with optional message" },
|
|
||||||
{ " /accept <n> : Accept friend request" },
|
|
||||||
{ " /connect <ip> <port> <key> : Manually connect to a DHT node" },
|
|
||||||
{ " /status <type> <msg> : Set status with optional note" },
|
|
||||||
{ " /note <msg> : Set a personal note" },
|
|
||||||
{ " /nick <nick> : Set your nickname" },
|
|
||||||
{ " /log <on> or <off> : Enable/disable logging" },
|
|
||||||
{ " /groupchat : Create a group chat" },
|
|
||||||
{ " /myid : Print your ID" },
|
|
||||||
{ " /help : Print this message again" },
|
|
||||||
{ " /clear : Clear window history" },
|
|
||||||
{ " /quit or /exit : Exit Toxic" },
|
|
||||||
#ifdef _SUPPORT_AUDIO
|
|
||||||
{ " /lsdev <type> : List devices where type: in|out" },
|
|
||||||
{ " /sdev <type> <id> : Set active device" },
|
|
||||||
#endif /* _SUPPORT_AUDIO */
|
|
||||||
|
|
||||||
};
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < NUMLINES; ++i)
|
|
||||||
line_info_add(self, NULL, NULL, NULL, lines[i], SYS_MSG, 0, 0);
|
|
||||||
|
|
||||||
msg = " * Argument messages must be enclosed in quotation marks.";
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
|
||||||
msg = " * Use ctrl-o and ctrl-p to navigate through the tabs.";
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
|
||||||
line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 0, 0);
|
|
||||||
|
|
||||||
hst->line_start = start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_quit(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_quit(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "line_info.h"
|
#include "line_info.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "help.h"
|
||||||
|
|
||||||
extern char *DATA_FILE;
|
extern char *DATA_FILE;
|
||||||
|
|
||||||
@ -96,10 +97,11 @@ void kill_groupchat_window(ToxWindow *self)
|
|||||||
delwin(ctx->history);
|
delwin(ctx->history);
|
||||||
delwin(ctx->sidebar);
|
delwin(ctx->sidebar);
|
||||||
delwin(self->window);
|
delwin(self->window);
|
||||||
del_window(self);
|
|
||||||
free(ctx->log);
|
free(ctx->log);
|
||||||
free(ctx->hst);
|
free(ctx->hst);
|
||||||
free(ctx);
|
free(ctx);
|
||||||
|
free(self->help);
|
||||||
|
del_window(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_groupchat(ToxWindow *self, Tox *m, int groupnum)
|
static void close_groupchat(ToxWindow *self, Tox *m, int groupnum)
|
||||||
@ -124,47 +126,6 @@ static void close_groupchat(ToxWindow *self, Tox *m, int groupnum)
|
|||||||
kill_groupchat_window(self);
|
kill_groupchat_window(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_groupchat_help(ToxWindow *self)
|
|
||||||
{
|
|
||||||
struct history *hst = self->chatwin->hst;
|
|
||||||
line_info_clear(hst);
|
|
||||||
struct line_info *start = hst->line_start;
|
|
||||||
|
|
||||||
uint8_t *msg = "Group chat commands:";
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
|
||||||
|
|
||||||
#define NUMLINES 9
|
|
||||||
|
|
||||||
uint8_t lines[NUMLINES][MAX_STR_SIZE] = {
|
|
||||||
|
|
||||||
{ " /add <id> <msg> : Add friend with optional message" },
|
|
||||||
{ " /status <type> <msg>: Set your status with optional note" },
|
|
||||||
{ " /note <msg> : Set a personal note" },
|
|
||||||
{ " /nick <nick> : Set your nickname" },
|
|
||||||
{ " /groupchat : Create a group chat" },
|
|
||||||
{ " /log <on> or <off> : Enable/disable logging" },
|
|
||||||
{ " /close : Close the current group chat" },
|
|
||||||
{ " /help : Print this message again" },
|
|
||||||
{ " /help global : Show a list of global commands" },
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < NUMLINES; ++i)
|
|
||||||
line_info_add(self, NULL, NULL, NULL, lines[i], SYS_MSG, 0, 0);
|
|
||||||
|
|
||||||
msg = " * Use Page Up/Page Down keys to scroll chat history";
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
|
||||||
msg = " * Scroll peer list with the ctrl-] and ctrl-[ keys.";
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
|
|
||||||
msg = " * Notice, some friends will be missing names while finding peers";
|
|
||||||
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, 0);
|
|
||||||
line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 0, 0);
|
|
||||||
|
|
||||||
hst->line_start = start;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int peernum,
|
static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int peernum,
|
||||||
const uint8_t *msg, uint16_t len)
|
const uint8_t *msg, uint16_t len)
|
||||||
{
|
{
|
||||||
@ -393,6 +354,11 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
|||||||
if (x2 <= 0)
|
if (x2 <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (self->help->active) {
|
||||||
|
help_onKey(self, key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ltr) { /* char is printable */
|
if (ltr) { /* char is printable */
|
||||||
input_new_char(self, key, x, y, x2, y2);
|
input_new_char(self, key, x, y, x2, y2);
|
||||||
return;
|
return;
|
||||||
@ -450,12 +416,6 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
|||||||
if (strcmp(line, "/close") == 0) {
|
if (strcmp(line, "/close") == 0) {
|
||||||
close_groupchat(self, m, self->num);
|
close_groupchat(self, m, self->num);
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(line, "/help") == 0) {
|
|
||||||
if (strcmp(line, "help global") == 0)
|
|
||||||
execute(ctx->history, self, m, "/help", GLOBAL_COMMAND_MODE);
|
|
||||||
else
|
|
||||||
print_groupchat_help(self);
|
|
||||||
|
|
||||||
} else if (strncmp(line, "/me ", strlen("/me ")) == 0) {
|
} else if (strncmp(line, "/me ", strlen("/me ")) == 0) {
|
||||||
send_group_action(self, ctx, m, line + strlen("/me "));
|
send_group_action(self, ctx, m, line + strlen("/me "));
|
||||||
} else {
|
} else {
|
||||||
@ -525,6 +485,11 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
|
|||||||
getyx(self->window, y, x);
|
getyx(self->window, y, x);
|
||||||
int new_x = ctx->start ? x2 - 1 : ctx->pos;
|
int new_x = ctx->start ? x2 - 1 : ctx->pos;
|
||||||
wmove(self->window, y + 1, new_x);
|
wmove(self->window, y + 1, new_x);
|
||||||
|
|
||||||
|
if (self->help->active) {
|
||||||
|
wrefresh(self->window);
|
||||||
|
help_onDraw(self);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void groupchat_onInit(ToxWindow *self, Tox *m)
|
static void groupchat_onInit(ToxWindow *self, Tox *m)
|
||||||
@ -548,7 +513,6 @@ static void groupchat_onInit(ToxWindow *self, Tox *m)
|
|||||||
memset(ctx->log, 0, sizeof(struct chatlog));
|
memset(ctx->log, 0, sizeof(struct chatlog));
|
||||||
|
|
||||||
line_info_init(ctx->hst);
|
line_info_init(ctx->hst);
|
||||||
print_groupchat_help(self);
|
|
||||||
|
|
||||||
if (user_settings->autolog == AUTOLOG_ON)
|
if (user_settings->autolog == AUTOLOG_ON)
|
||||||
log_enable(self->name, NULL, ctx->log);
|
log_enable(self->name, NULL, ctx->log);
|
||||||
@ -577,11 +541,14 @@ ToxWindow new_group_chat(Tox *m, int groupnum)
|
|||||||
snprintf(ret.name, sizeof(ret.name), "Room #%d", groupnum);
|
snprintf(ret.name, sizeof(ret.name), "Room #%d", groupnum);
|
||||||
|
|
||||||
ChatContext *chatwin = calloc(1, sizeof(ChatContext));
|
ChatContext *chatwin = calloc(1, sizeof(ChatContext));
|
||||||
|
Help *help = calloc(1, sizeof(Help));
|
||||||
|
|
||||||
if (chatwin == NULL)
|
if (chatwin == NULL || help == NULL)
|
||||||
exit_toxic_err("failed in new_group_chat", FATALERR_MEMORY);
|
exit_toxic_err("failed in new_group_chat", FATALERR_MEMORY);
|
||||||
|
|
||||||
ret.chatwin = chatwin;
|
ret.chatwin = chatwin;
|
||||||
|
ret.help = help;
|
||||||
|
|
||||||
ret.num = groupnum;
|
ret.num = groupnum;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
277
src/help.c
Normal file
277
src/help.c
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
/* help.c
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 Toxic All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This file is part of Toxic.
|
||||||
|
*
|
||||||
|
* Toxic is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Toxic is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Toxic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "windows.h"
|
||||||
|
#include "toxic.h"
|
||||||
|
#include "help.h"
|
||||||
|
#include "misc_tools.h"
|
||||||
|
|
||||||
|
#define HELP_MENU_HEIGHT 7
|
||||||
|
#define HELP_MENU_WIDTH 26
|
||||||
|
|
||||||
|
void help_init_menu(ToxWindow *self)
|
||||||
|
{
|
||||||
|
if (self->help->win)
|
||||||
|
delwin(self->help->win);
|
||||||
|
|
||||||
|
int y2, x2;
|
||||||
|
getmaxyx(self->window, y2, x2);
|
||||||
|
|
||||||
|
if (y2 < HELP_MENU_HEIGHT || x2 < HELP_MENU_WIDTH)
|
||||||
|
return;
|
||||||
|
|
||||||
|
self->help->win = newwin(HELP_MENU_HEIGHT, HELP_MENU_WIDTH, 3, 3);
|
||||||
|
self->help->active = true;
|
||||||
|
self->help->type = HELP_MENU;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void help_exit(ToxWindow *self)
|
||||||
|
{
|
||||||
|
delwin(self->help->win);
|
||||||
|
memset(self->help, 0, sizeof(Help));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void help_init_window(ToxWindow *self, int height, int width)
|
||||||
|
{
|
||||||
|
if (self->help->win)
|
||||||
|
delwin(self->help->win);
|
||||||
|
|
||||||
|
int y2, x2;
|
||||||
|
getmaxyx(stdscr, y2, x2);
|
||||||
|
|
||||||
|
height = MIN(height, y2);
|
||||||
|
width = MIN(width, x2);
|
||||||
|
|
||||||
|
self->help->win = newwin(height, width, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void help_draw_menu(ToxWindow *self)
|
||||||
|
{
|
||||||
|
WINDOW *win = self->help->win;
|
||||||
|
|
||||||
|
wmove(win, 1, 1);
|
||||||
|
|
||||||
|
wattron(win, A_BOLD | COLOR_PAIR(RED));
|
||||||
|
wprintw(win, " Help Menu\n");
|
||||||
|
wattroff(win, A_BOLD | COLOR_PAIR(RED));
|
||||||
|
|
||||||
|
wattron(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, " G");
|
||||||
|
wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, "lobal commands\n");
|
||||||
|
|
||||||
|
wattron(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, " C");
|
||||||
|
wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, "hat commands\n");
|
||||||
|
|
||||||
|
wattron(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, " K");
|
||||||
|
wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, "ey bindings\n");
|
||||||
|
|
||||||
|
wprintw(win, " E");
|
||||||
|
wattron(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, "x");
|
||||||
|
wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, "it menu\n");
|
||||||
|
|
||||||
|
box(win, ACS_VLINE, ACS_HLINE);
|
||||||
|
wrefresh(win);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void help_draw_bottom_menu(WINDOW *win)
|
||||||
|
{
|
||||||
|
int y2, x2;
|
||||||
|
getmaxyx(win, y2, x2);
|
||||||
|
wmove(win, y2 - 2, 1);
|
||||||
|
|
||||||
|
wattron(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, " M");
|
||||||
|
wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, "ain menu |");
|
||||||
|
|
||||||
|
wprintw(win, " E");
|
||||||
|
wattron(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, "x");
|
||||||
|
wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||||
|
wprintw(win, "it");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void help_draw_global(ToxWindow *self)
|
||||||
|
{
|
||||||
|
WINDOW *win = self->help->win;
|
||||||
|
|
||||||
|
wmove(win, 1, 1);
|
||||||
|
|
||||||
|
wattron(win, A_BOLD | COLOR_PAIR(RED));
|
||||||
|
wprintw(win, "Global Commands:\n");
|
||||||
|
wattroff(win, A_BOLD | COLOR_PAIR(RED));
|
||||||
|
|
||||||
|
wprintw(win, " /add <id> <msg> : Add friend with optional message\n");
|
||||||
|
wprintw(win, " /accept <n> : Accept friend request\n");
|
||||||
|
wprintw(win, " /connect <ip> <port> <key> : Manually connect to a DHT node\n");
|
||||||
|
wprintw(win, " /status <type> <msg> : Set status with optional note\n");
|
||||||
|
wprintw(win, " /note <msg> : Set a personal note\n");
|
||||||
|
wprintw(win, " /nick <nick> : Set your nickname\n");
|
||||||
|
wprintw(win, " /log <on> or <off> : Enable/disable logging\n");
|
||||||
|
wprintw(win, " /groupchat : Create a group chat\n");
|
||||||
|
wprintw(win, " /myid : Print your ID\n");
|
||||||
|
wprintw(win, " /clear : Clear window history\n");
|
||||||
|
wprintw(win, " /close : Close the current chat window\n");
|
||||||
|
wprintw(win, " /quit or /exit : Exit Toxic\n");
|
||||||
|
|
||||||
|
#ifdef _SUPPORT_AUDIO
|
||||||
|
wattron(win, A_BOLD);
|
||||||
|
wprintw(win, "\n Audio:\n");
|
||||||
|
wattroff(win, A_BOLD);
|
||||||
|
|
||||||
|
wprintw(win, " /lsdev <type> : List devices where type: in|out\n");
|
||||||
|
wprintw(win, " /sdev <type> <id> : Set active device\n");
|
||||||
|
#endif /* _SUPPORT_AUDIO */
|
||||||
|
|
||||||
|
help_draw_bottom_menu(win);
|
||||||
|
|
||||||
|
box(win, ACS_VLINE, ACS_HLINE);
|
||||||
|
wrefresh(win);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void help_draw_chat(ToxWindow *self)
|
||||||
|
{
|
||||||
|
WINDOW *win = self->help->win;
|
||||||
|
|
||||||
|
wmove(win, 1, 1);
|
||||||
|
|
||||||
|
wattron(win, A_BOLD | COLOR_PAIR(RED));
|
||||||
|
wprintw(win, "Chat Commands:\n");
|
||||||
|
wattroff(win, A_BOLD | COLOR_PAIR(RED));
|
||||||
|
|
||||||
|
wprintw(win, " /invite <n> : Invite friend to a group chat\n");
|
||||||
|
wprintw(win, " /join : Join a pending group chat\n");
|
||||||
|
wprintw(win, " /sendfile <path> : Send a file\n");
|
||||||
|
wprintw(win, " /savefile <n> : Receive a file\n");
|
||||||
|
|
||||||
|
#ifdef _SUPPORT_AUDIO
|
||||||
|
wattron(win, A_BOLD);
|
||||||
|
wprintw(win, "\n Audio:\n");
|
||||||
|
wattroff(win, A_BOLD);
|
||||||
|
|
||||||
|
wprintw(win, " /call : Audio call\n");
|
||||||
|
wprintw(win, " /cancel : Cancel call\n");
|
||||||
|
wprintw(win, " /answer : Answer incomming call\n");
|
||||||
|
wprintw(win, " /reject : Reject incoming call\n");
|
||||||
|
wprintw(win, " /hangup : Hangup active call\n");
|
||||||
|
wprintw(win, " /sdev <type> <id> : Change active device\n");
|
||||||
|
wprintw(win, " /mute <type> : Mute active device if in call\n");
|
||||||
|
wprintw(win, " /sense <n> : VAD sensitivity treshold\n");
|
||||||
|
#endif /* _SUPPORT_AUDIO */
|
||||||
|
|
||||||
|
help_draw_bottom_menu(win);
|
||||||
|
|
||||||
|
box(win, ACS_VLINE, ACS_HLINE);
|
||||||
|
wrefresh(win);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void help_draw_keys(ToxWindow *self)
|
||||||
|
{
|
||||||
|
WINDOW *win = self->help->win;
|
||||||
|
|
||||||
|
wmove(win, 1, 1);
|
||||||
|
|
||||||
|
wattron(win, A_BOLD | COLOR_PAIR(RED));
|
||||||
|
wprintw(win, "Key bindings:\n");
|
||||||
|
wattroff(win, A_BOLD | COLOR_PAIR(RED));
|
||||||
|
|
||||||
|
wprintw(win, " Ctrl+O / Ctrl+P : Navigate through the windows/tabs\n");
|
||||||
|
wprintw(win, " Page Up / Page Down : Scroll window history one line\n");
|
||||||
|
wprintw(win, " Ctrl+F / Ctrl+V : Scroll window history half a page\n");
|
||||||
|
wprintw(win, " Ctrl+H : Move to the bottom of window history\n");
|
||||||
|
wprintw(win, " Ctrl+[ / Ctrl+] : Scroll peer list in groupchats\n");
|
||||||
|
|
||||||
|
help_draw_bottom_menu(win);
|
||||||
|
|
||||||
|
box(win, ACS_VLINE, ACS_HLINE);
|
||||||
|
wrefresh(win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void help_onKey(ToxWindow *self, wint_t key)
|
||||||
|
{
|
||||||
|
switch(key) {
|
||||||
|
case 'x':
|
||||||
|
case T_KEY_ESC:
|
||||||
|
help_exit(self);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
#ifdef _SUPPORT_AUDIO
|
||||||
|
help_init_window(self, 19, 80);
|
||||||
|
#else
|
||||||
|
help_init_window(self, 9, 80);
|
||||||
|
#endif
|
||||||
|
self->help->type = HELP_CHAT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'g':
|
||||||
|
help_init_window(self, 21, 80);
|
||||||
|
self->help->type = HELP_GLOBAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'k':
|
||||||
|
help_init_window(self, 10, 80);
|
||||||
|
self->help->type = HELP_KEYS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'm':
|
||||||
|
help_init_menu(self);
|
||||||
|
self->help->type = HELP_MENU;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void help_onDraw(ToxWindow *self)
|
||||||
|
{
|
||||||
|
curs_set(0);
|
||||||
|
wclear(self->help->win);
|
||||||
|
|
||||||
|
switch(self->help->type) {
|
||||||
|
case HELP_MENU:
|
||||||
|
help_draw_menu(self);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case HELP_CHAT:
|
||||||
|
help_draw_chat(self);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HELP_GLOBAL:
|
||||||
|
help_draw_global(self);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HELP_KEYS:
|
||||||
|
help_draw_keys(self);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HELP_GROUP:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
41
src/help.h
Normal file
41
src/help.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/* help.h
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 Toxic All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This file is part of Toxic.
|
||||||
|
*
|
||||||
|
* Toxic is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Toxic is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Toxic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _help_h
|
||||||
|
#define _help_h
|
||||||
|
|
||||||
|
#include "toxic.h"
|
||||||
|
#include "windows.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
HELP_MENU,
|
||||||
|
HELP_GLOBAL,
|
||||||
|
HELP_CHAT,
|
||||||
|
HELP_GROUP,
|
||||||
|
HELP_KEYS,
|
||||||
|
} HELP_TYPES;
|
||||||
|
|
||||||
|
void help_onDraw(ToxWindow *self);
|
||||||
|
void help_init_menu(ToxWindow *self);
|
||||||
|
void help_onKey(ToxWindow *self, wint_t key);
|
||||||
|
|
||||||
|
#endif /* #define _help_h */
|
36
src/prompt.c
36
src/prompt.c
@ -34,6 +34,7 @@
|
|||||||
#include "line_info.h"
|
#include "line_info.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "help.h"
|
||||||
|
|
||||||
uint8_t pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE] = {0};
|
uint8_t pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE] = {0};
|
||||||
uint8_t num_frnd_requests = 0;
|
uint8_t num_frnd_requests = 0;
|
||||||
@ -132,6 +133,12 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
|||||||
if (x2 <= 0)
|
if (x2 <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* ignore non-menu related input if active */
|
||||||
|
if (self->help->active) {
|
||||||
|
help_onKey(self, key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ltr) { /* char is printable */
|
if (ltr) { /* char is printable */
|
||||||
input_new_char(self, key, x, y, x2, y2);
|
input_new_char(self, key, x, y, x2, y2);
|
||||||
return;
|
return;
|
||||||
@ -247,6 +254,11 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
|
|||||||
getyx(self->window, y, x);
|
getyx(self->window, y, x);
|
||||||
int new_x = ctx->start ? x2 - 1 : ctx->pos;
|
int new_x = ctx->start ? x2 - 1 : ctx->pos;
|
||||||
wmove(self->window, y + 1, new_x);
|
wmove(self->window, y + 1, new_x);
|
||||||
|
|
||||||
|
if (self->help->active) {
|
||||||
|
wrefresh(self->window);
|
||||||
|
help_onDraw(self);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum , uint8_t status)
|
static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum , uint8_t status)
|
||||||
@ -351,6 +363,23 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
|
|||||||
statusbar->topline = subwin(self->window, 2, x2, 0, 0);
|
statusbar->topline = subwin(self->window, 2, x2, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_welcome_msg(ToxWindow *self)
|
||||||
|
{
|
||||||
|
ChatContext *ctx = self->chatwin;
|
||||||
|
|
||||||
|
line_info_add(self, NULL, NULL, NULL, " |_ _|____ _(_) ___ ", SYS_MSG, 1, BLUE);
|
||||||
|
line_info_add(self, NULL, NULL, NULL, " | |/ _ \\ \\/ / |/ __|", SYS_MSG, 1, BLUE);
|
||||||
|
line_info_add(self, NULL, NULL, NULL, " | | (_) > <| | (__ ", SYS_MSG, 1, BLUE);
|
||||||
|
line_info_add(self, NULL, NULL, NULL, " |_|\\___/_/\\_\\_|\\___|", SYS_MSG, 1, BLUE);
|
||||||
|
line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 0, 0);
|
||||||
|
|
||||||
|
uint8_t *msg = "Welcome to Toxic, a free open source messenger client for Tox. Type /help for a"\
|
||||||
|
" list of commands and key bindings. Further help may be found via the man page.";
|
||||||
|
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, 0);
|
||||||
|
line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 1, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static void prompt_onInit(ToxWindow *self, Tox *m)
|
static void prompt_onInit(ToxWindow *self, Tox *m)
|
||||||
{
|
{
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
@ -378,9 +407,10 @@ static void prompt_onInit(ToxWindow *self, Tox *m)
|
|||||||
log_enable(self->name, myid, ctx->log);
|
log_enable(self->name, myid, ctx->log);
|
||||||
}
|
}
|
||||||
|
|
||||||
execute(ctx->history, self, m, "/help", GLOBAL_COMMAND_MODE);
|
|
||||||
scrollok(ctx->history, 0);
|
scrollok(ctx->history, 0);
|
||||||
wmove(self->window, y2 - CURS_Y_OFFSET, 0);
|
wmove(self->window, y2 - CURS_Y_OFFSET, 0);
|
||||||
|
|
||||||
|
print_welcome_msg(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
ToxWindow new_prompt(void)
|
ToxWindow new_prompt(void)
|
||||||
@ -401,12 +431,14 @@ ToxWindow new_prompt(void)
|
|||||||
|
|
||||||
ChatContext *chatwin = calloc(1, sizeof(ChatContext));
|
ChatContext *chatwin = calloc(1, sizeof(ChatContext));
|
||||||
StatusBar *stb = calloc(1, sizeof(StatusBar));
|
StatusBar *stb = calloc(1, sizeof(StatusBar));
|
||||||
|
Help *help = calloc(1, sizeof(Help));
|
||||||
|
|
||||||
if (stb == NULL || chatwin == NULL)
|
if (stb == NULL || chatwin == NULL || help == NULL)
|
||||||
exit_toxic_err("failed in new_prompt", FATALERR_MEMORY);
|
exit_toxic_err("failed in new_prompt", FATALERR_MEMORY);
|
||||||
|
|
||||||
ret.chatwin = chatwin;
|
ret.chatwin = chatwin;
|
||||||
ret.stb = stb;
|
ret.stb = stb;
|
||||||
|
ret.help = help;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SIGWINCH
|
|
||||||
#define SIGWINCH 28
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SIGINT
|
|
||||||
#define SIGINT 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -106,6 +98,7 @@ void exit_toxic_success(Tox *m)
|
|||||||
line_info_cleanup(prompt->chatwin->hst);
|
line_info_cleanup(prompt->chatwin->hst);
|
||||||
free(DATA_FILE);
|
free(DATA_FILE);
|
||||||
free(prompt->stb);
|
free(prompt->stb);
|
||||||
|
free(prompt->help);
|
||||||
free(prompt->chatwin->log);
|
free(prompt->chatwin->log);
|
||||||
free(prompt->chatwin->hst);
|
free(prompt->chatwin->hst);
|
||||||
free(prompt->chatwin);
|
free(prompt->chatwin);
|
||||||
|
@ -27,6 +27,14 @@
|
|||||||
#define TOXICVER "NOVER_" /* Use the -D flag to set this */
|
#define TOXICVER "NOVER_" /* Use the -D flag to set this */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SIGWINCH
|
||||||
|
#define SIGWINCH 28
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SIGINT
|
||||||
|
#define SIGINT 2
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
|
|
||||||
@ -42,6 +50,7 @@
|
|||||||
#define TIME_STR_SIZE 16
|
#define TIME_STR_SIZE 16
|
||||||
|
|
||||||
/* ASCII key codes */
|
/* ASCII key codes */
|
||||||
|
#define T_KEY_ESC 0X1B /* esc key */
|
||||||
#define T_KEY_KILL 0x0B /* ctrl-k */
|
#define T_KEY_KILL 0x0B /* ctrl-k */
|
||||||
#define T_KEY_DISCARD 0x15 /* ctrl-u */
|
#define T_KEY_DISCARD 0x15 /* ctrl-u */
|
||||||
#define T_KEY_NEXT 0x10 /* ctrl-p */
|
#define T_KEY_NEXT 0x10 /* ctrl-p */
|
||||||
|
@ -72,6 +72,7 @@ typedef struct ToxWindow ToxWindow;
|
|||||||
typedef struct StatusBar StatusBar;
|
typedef struct StatusBar StatusBar;
|
||||||
typedef struct PromptBuf PromptBuf;
|
typedef struct PromptBuf PromptBuf;
|
||||||
typedef struct ChatContext ChatContext;
|
typedef struct ChatContext ChatContext;
|
||||||
|
typedef struct Help Help;
|
||||||
|
|
||||||
struct ToxWindow {
|
struct ToxWindow {
|
||||||
void(*onKey)(ToxWindow *, Tox *, wint_t, bool);
|
void(*onKey)(ToxWindow *, Tox *, wint_t, bool);
|
||||||
@ -119,7 +120,6 @@ struct ToxWindow {
|
|||||||
bool active;
|
bool active;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
/* window type identifiers */
|
|
||||||
bool is_chat;
|
bool is_chat;
|
||||||
bool is_groupchat;
|
bool is_groupchat;
|
||||||
bool is_prompt;
|
bool is_prompt;
|
||||||
@ -131,6 +131,7 @@ struct ToxWindow {
|
|||||||
|
|
||||||
ChatContext *chatwin;
|
ChatContext *chatwin;
|
||||||
StatusBar *stb;
|
StatusBar *stb;
|
||||||
|
Help *help;
|
||||||
|
|
||||||
WINDOW *window;
|
WINDOW *window;
|
||||||
};
|
};
|
||||||
@ -194,6 +195,12 @@ struct ChatContext {
|
|||||||
WINDOW *sidebar;
|
WINDOW *sidebar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Help {
|
||||||
|
WINDOW *win;
|
||||||
|
int type;
|
||||||
|
bool active;
|
||||||
|
};
|
||||||
|
|
||||||
ToxWindow *init_windows(Tox *m);
|
ToxWindow *init_windows(Tox *m);
|
||||||
void draw_active_window(Tox *m);
|
void draw_active_window(Tox *m);
|
||||||
int add_window(Tox *m, ToxWindow w);
|
int add_window(Tox *m, ToxWindow w);
|
||||||
|
Loading…
Reference in New Issue
Block a user