diff --git a/src/chat.c b/src/chat.c index 9f6065d..df02d1b 100644 --- a/src/chat.c +++ b/src/chat.c @@ -414,14 +414,14 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key) beep(); } - else if (key == KEY_HOME) { /* HOME key: Move cursor to beginning of line */ + else if (key == KEY_HOME || key == T_KEY_C_A) { /* HOME/C-a key: Move cursor to start of line */ if (ctx->pos > 0) { ctx->pos = 0; wmove(self->window, y2 - CURS_Y_OFFSET, 0); } } - else if (key == KEY_END) { /* END key: move cursor to end of line */ + else if (key == KEY_END || key == T_KEY_C_E) { /* END/C-e key: move cursor to end of line */ if (ctx->pos != ctx->len) { ctx->pos = ctx->len; mv_curs_end(self->window, MAX(0, wcswidth(ctx->line, (CHATBOX_HEIGHT-1)*x2)), y2, x2); diff --git a/src/chat_commands.c b/src/chat_commands.c index f866e42..18d8646 100644 --- a/src/chat_commands.c +++ b/src/chat_commands.c @@ -52,14 +52,14 @@ void cmd_chat_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg wprintw(window, "Chat commands:\n"); wattroff(window, COLOR_PAIR(CYAN) | A_BOLD); - wprintw(window, " /invite : Invite friend to a group chat\n"); - wprintw(window, " /join : Join a pending group chat\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, " /help : Print this message again\n"); - wprintw(window, " /help global : Show a list of global commands\n"); + wprintw(window, " /invite : Invite friend to a group chat\n"); + wprintw(window, " /join : Join a pending group chat\n"); + wprintw(window, " /log or : Enable/disable logging\n"); + wprintw(window, " /sendfile : Send a file\n"); + wprintw(window, " /savefile : Receive a file\n"); + wprintw(window, " /close : Close the current chat window\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 964cb59..2466a08 100644 --- a/src/global_commands.c +++ b/src/global_commands.c @@ -229,9 +229,9 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX if (argc == 0) { if (ctx->log.log_on) - wprintw(window, "Logging for this chat is currently enabled. /log 0 to disable.\n"); + wprintw(window, "Logging for this chat is on. Type \"/log off\" to disable.\n"); else - wprintw(window, "Logging for this chat is currently disabled. /log 1 to enable.\n"); + wprintw(window, "Logging for this chat is off. Type \"/log on\" to enable.\n"); return; } @@ -262,7 +262,7 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX return; } - wprintw(window, "Invalid option: Use 1 or 0 to enable or disable logging.\n"); + wprintw(window, "Invalid option. Use \"/log on\" and \"/log off\" to toggle logging.\n"); } void cmd_myid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) @@ -343,17 +343,17 @@ void cmd_prompt_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*a wprintw(window, "\n\nGlobal commands:\n"); wattroff(window, COLOR_PAIR(CYAN) | A_BOLD); - 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 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, " /help : Print this message again\n"); - wprintw(window, " /clear : Clear the window\n"); - wprintw(window, " /quit or /exit : Exit Toxic\n"); + 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 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, " /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 cc28e45..678657e 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -131,15 +131,15 @@ static void print_groupchat_help(ChatContext *ctx) wprintw(ctx->history, "Group chat commands:\n"); wattroff(ctx->history, COLOR_PAIR(CYAN) | A_BOLD); - wprintw(ctx->history, " /add : Add friend with optional message\n"); - wprintw(ctx->history, " /status : Set your status with optional note\n"); - 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, " /log : Enable/disable logging\n"); - wprintw(ctx->history, " /close : Close the current group chat\n"); - wprintw(ctx->history, " /help : Print this message again\n"); - wprintw(ctx->history, " /help global : Show a list of global commands\n"); + wprintw(ctx->history, " /add : Add friend with optional message\n"); + wprintw(ctx->history, " /status : Set your status with optional note\n"); + 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, " /log or : Enable/disable logging\n"); + wprintw(ctx->history, " /close : Close the current group chat\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"); @@ -410,14 +410,14 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key) beep(); } - else if (key == KEY_HOME) { /* HOME key: Move cursor to beginning of line */ + else if (key == KEY_HOME || key == T_KEY_C_A) { /* HOME/C-a key: Move cursor to start of line */ if (ctx->pos > 0) { ctx->pos = 0; wmove(self->window, y2 - CURS_Y_OFFSET, 0); } } - else if (key == KEY_END) { /* END key: move cursor to end of line */ + else if (key == KEY_END || key == T_KEY_C_E) { /* END/C-e key: move cursor to end of line */ if (ctx->pos != ctx->len) { ctx->pos = ctx->len; mv_curs_end(self->window, MAX(0, wcswidth(ctx->line, (CHATBOX_HEIGHT-1)*x2)), y2, x2); diff --git a/src/log.h b/src/log.h index da50aa2..0556e09 100644 --- a/src/log.h +++ b/src/log.h @@ -21,7 +21,7 @@ */ /* gets the log path by appending to the config dir the name and a pseudo-unique identity */ -void init_logging_session(uint8_t *name, uint8_t *key, ChatContext *ctx) +void init_logging_session(uint8_t *name, uint8_t *key, ChatContext *ctx); /* Adds msg to log_buf with timestamp and name. If buf is full, triggers write_to_log (which sets buf pos to 0) */ diff --git a/src/prompt.c b/src/prompt.c index a1b1e78..fb143ce 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -173,12 +173,12 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key) beep(); } - else if (key == KEY_HOME) { /* HOME key: Move cursor to beginning of line */ + else if (key == KEY_HOME || key == T_KEY_C_A) { /* HOME/C-a key: Move cursor to start of line */ if (prt->pos != 0) prt->pos = 0; } - else if (key == KEY_END) { /* END key: move cursor to end of line */ + else if (key == KEY_END || key == T_KEY_C_E) { /* END/C-e key: move cursor to end of line */ if (prt->pos != prt->len) prt->pos = prt->len; } diff --git a/src/toxic_windows.h b/src/toxic_windows.h index 7cd8e54..ae58cab 100644 --- a/src/toxic_windows.h +++ b/src/toxic_windows.h @@ -54,6 +54,8 @@ #define T_KEY_DISCARD 0x15 /* ctrl-u */ #define T_KEY_NEXT 0x10 /* ctrl-p */ #define T_KEY_PREV 0x0F /* ctrl-o */ +#define T_KEY_C_E 0x05 /* ctrl-e */ +#define T_KEY_C_A 0x01 /* ctrl-a */ /* Curses foreground colours (background is black) */ enum {