From d83ef1d8bec698e954f4fac3e0e7309bd022562f Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Wed, 26 Feb 2014 19:45:11 -0500 Subject: [PATCH] update help messages --- src/chat_commands.c | 17 ++++++++++------- src/global_commands.c | 13 ++++++++----- src/groupchat.c | 18 +++++++++++------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/chat_commands.c b/src/chat_commands.c index 9fdedb3..f866e42 100644 --- a/src/chat_commands.c +++ b/src/chat_commands.c @@ -30,6 +30,7 @@ #include "toxic_windows.h" #include "misc_tools.h" #include "friendlist.h" +#include "execute.h" extern ToxWindow *prompt; @@ -40,23 +41,25 @@ extern uint8_t max_file_senders_index; void cmd_chat_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) { + if (argc == 1) { + if (!strcmp(argv[1], "global")) { + execute(window, self, m, "/help", GLOBAL_COMMAND_MODE); + return; + } + } + wattron(window, COLOR_PAIR(CYAN) | A_BOLD); wprintw(window, "Chat commands:\n"); wattroff(window, COLOR_PAIR(CYAN) | A_BOLD); - wprintw(window, " /status : Set your status with optional note\n"); - wprintw(window, " /note : Set a personal note\n"); - wprintw(window, " /nick : Set your nickname\n"); wprintw(window, " /invite : Invite friend to a group chat\n"); - wprintw(window, " /me : Do an action\n"); - wprintw(window, " /myid : Print your ID\n"); wprintw(window, " /join : Join a pending group chat\n"); - wprintw(window, " /clear : Clear the screen\n"); + wprintw(window, " /log : Enable/disable logging\n"); wprintw(window, " /close : Close the current chat window\n"); wprintw(window, " /sendfile : Send a file\n"); wprintw(window, " /savefile : Receive a file\n"); - wprintw(window, " /quit or /exit : Exit Toxic\n"); wprintw(window, " /help : Print this message again\n"); + wprintw(window, " /help global : Show a list of global commands\n"); wattron(window, COLOR_PAIR(CYAN) | A_BOLD); wprintw(window, " * Argument messages must be enclosed in quotation marks.\n\n"); diff --git a/src/global_commands.c b/src/global_commands.c index 981d6d1..964cb59 100644 --- a/src/global_commands.c +++ b/src/global_commands.c @@ -211,7 +211,7 @@ void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg return; } - if (init_groupchat_win(prompt, m, groupnum, NULL) == -1) { + if (init_groupchat_win(prompt, m, groupnum) == -1) { wprintw(window, "Group chat window failed to initialize.\n"); tox_del_groupchat(m, groupnum); return; @@ -228,8 +228,11 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX ChatContext *ctx = self->chatwin; if (argc == 0) { - uint8_t *s = ctx->log.log_on ? "enabled" : "disabled"; - wprintw(window, "Logging for this chat is currently %s\n", s); + if (ctx->log.log_on) + wprintw(window, "Logging for this chat is currently enabled. /log 0 to disable.\n"); + else + wprintw(window, "Logging for this chat is currently disabled. /log 1 to enable.\n"); + return; } @@ -343,14 +346,14 @@ void cmd_prompt_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*a wprintw(window, " /add : Add friend with optional message\n"); wprintw(window, " /accept : Accept friend request\n"); wprintw(window, " /connect : Manually connect to a DHT server\n"); - wprintw(window, " /status : Set your status with optional note\n"); + wprintw(window, " /status : Set status with optional note\n"); wprintw(window, " /note : Set a personal note\n"); wprintw(window, " /nick : Set your nickname\n"); wprintw(window, " /groupchat : Create a group chat\n"); wprintw(window, " /myid : Print your ID\n"); - wprintw(window, " /quit or /exit : Exit Toxic\n"); wprintw(window, " /help : Print this message again\n"); wprintw(window, " /clear : Clear the window\n"); + wprintw(window, " /quit or /exit : Exit Toxic\n"); wattron(window, COLOR_PAIR(CYAN) | A_BOLD); wprintw(window, " * Argument messages must be enclosed in quotation marks.\n"); diff --git a/src/groupchat.c b/src/groupchat.c index 3abe7b9..0cb67fe 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -136,11 +136,10 @@ static void print_groupchat_help(ChatContext *ctx) wprintw(ctx->history, " /note : Set a personal note\n"); wprintw(ctx->history, " /nick : Set your nickname\n"); wprintw(ctx->history, " /groupchat : Create a group chat\n"); - wprintw(ctx->history, " /myid : Print your ID\n"); - wprintw(ctx->history, " /clear : Clear the screen\n"); + wprintw(ctx->history, " /log : Enable/disable logging\n"); wprintw(ctx->history, " /close : Close the current group chat\n"); - wprintw(ctx->history, " /quit or /exit : Exit Toxic\n"); wprintw(ctx->history, " /help : Print this message again\n"); + wprintw(ctx->history, " /help global : Show a list of global commands\n"); wattron(ctx->history, COLOR_PAIR(CYAN) | A_BOLD); wprintw(ctx->history, " * Argument messages must be enclosed in quotation marks.\n"); @@ -539,12 +538,17 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key) if (strcmp(line, "/close") == 0) { close_groupchat(self, m, self->num); return; - } else if (strcmp(line, "/help") == 0) - print_groupchat_help(ctx); - else if (strncmp(line, "/me ", strlen("/me ")) == 0) + } 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(ctx); + + } else if (strncmp(line, "/me ", strlen("/me ")) == 0) { send_group_action(self, ctx, m, line + strlen("/me ")); - else + } else { execute(ctx->history, self, m, line, GROUPCHAT_COMMAND_MODE); + } } else if (!string_is_empty(line)) { if (tox_group_message_send(m, self->num, line, strlen(line) + 1) == -1) { wattron(ctx->history, COLOR_PAIR(RED));