1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 20:23:25 +01:00

make C-e and C-aa work like they do in bash and fix/format help messages

This commit is contained in:
Jfreegman 2014-02-27 18:55:18 -05:00
parent 6ee1f1ed0f
commit 46b046a209
7 changed files with 40 additions and 38 deletions

View File

@ -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);

View File

@ -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 <n> : Invite friend to a group chat\n");
wprintw(window, " /join : Join a pending group chat\n");
wprintw(window, " /log <bool> : Enable/disable logging\n");
wprintw(window, " /close : Close the current chat window\n");
wprintw(window, " /sendfile <filepath> : Send a file\n");
wprintw(window, " /savefile <n> : 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 <n> : Invite friend to a group chat\n");
wprintw(window, " /join : Join a pending group chat\n");
wprintw(window, " /log <on> or <off> : Enable/disable logging\n");
wprintw(window, " /sendfile <filepath> : Send a file\n");
wprintw(window, " /savefile <n> : 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");

View File

@ -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 <id> <msg> : Add friend with optional message\n");
wprintw(window, " /accept <n> : Accept friend request\n");
wprintw(window, " /connect <ip> <port> <key> : Manually connect to a DHT server\n");
wprintw(window, " /status <type> <msg> : Set status with optional note\n");
wprintw(window, " /note <msg> : Set a personal note\n");
wprintw(window, " /nick <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 <id> <msg> : Add friend with optional message\n");
wprintw(window, " /accept <n> : Accept friend request\n");
wprintw(window, " /connect <ip> <port> <key> : Manually connect to a DHT server\n");
wprintw(window, " /status <type> <msg> : Set status with optional note\n");
wprintw(window, " /note <msg> : Set a personal note\n");
wprintw(window, " /nick <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");

View File

@ -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 <id> <msg> : Add friend with optional message\n");
wprintw(ctx->history, " /status <type> <msg>: Set your status with optional note\n");
wprintw(ctx->history, " /note <msg> : Set a personal note\n");
wprintw(ctx->history, " /nick <nick> : Set your nickname\n");
wprintw(ctx->history, " /groupchat : Create a group chat\n");
wprintw(ctx->history, " /log <bool> : 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 <id> <msg> : Add friend with optional message\n");
wprintw(ctx->history, " /status <type> <msg>: Set your status with optional note\n");
wprintw(ctx->history, " /note <msg> : Set a personal note\n");
wprintw(ctx->history, " /nick <nick> : Set your nickname\n");
wprintw(ctx->history, " /groupchat : Create a group chat\n");
wprintw(ctx->history, " /log <on> or <off> : 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);

View File

@ -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) */

View File

@ -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;
}

View File

@ -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 {