diff --git a/src/chat.c b/src/chat.c index a6c1044..fd31c19 100644 --- a/src/chat.c +++ b/src/chat.c @@ -892,6 +892,9 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) if (y2 <= 0 || x2 <= 0) return; + if (ctx->pastemode && key == '\r') + key = '\n'; + if (self->help->active) { help_onKey(self, key); return; diff --git a/src/groupchat.c b/src/groupchat.c index dd8178a..1c07981 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -571,6 +571,9 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) return; } + if (ctx->pastemode && key == '\r') + key = '\n'; + if (ltr || key == '\n') { /* char is printable */ input_new_char(self, key, x, y, x2, y2); return; diff --git a/src/input.c b/src/input.c index b1b95a8..df24156 100644 --- a/src/input.c +++ b/src/input.c @@ -262,6 +262,10 @@ bool input_handle(ToxWindow *self, wint_t key, int x, int y, int mx_x, int mx_y) force_refresh(self->chatwin->history); break; + case T_KEY_C_T: + self->chatwin->pastemode ^= 1; + break; + default: match = false; break; @@ -278,6 +282,5 @@ bool input_handle(ToxWindow *self, wint_t key, int x, int y, int mx_x, int mx_y) match = true; } - return match; } diff --git a/src/prompt.c b/src/prompt.c index 2488d94..4fbc8c6 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -189,6 +189,9 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) if (x2 <= 0 || y2 <= 0) return; + if (ctx->pastemode && key == '\r') + key = '\n'; + /* ignore non-menu related input if active */ if (self->help->active) { help_onKey(self, key); diff --git a/src/toxic.h b/src/toxic.h index 5f7bd88..affa748 100644 --- a/src/toxic.h +++ b/src/toxic.h @@ -70,6 +70,7 @@ #define T_KEY_C_L 0x0C /* ctrl-l */ #define T_KEY_C_W 0x17 /* ctrl-w */ #define T_KEY_C_B 0x02 /* ctrl-b */ +#define T_KEY_C_T 0x14 /* ctrl-t */ #define T_KEY_TAB 0x09 /* TAB key */ #define ONLINE_CHAR "*" diff --git a/src/windows.h b/src/windows.h index 8c576a5..c2a0760 100644 --- a/src/windows.h +++ b/src/windows.h @@ -237,6 +237,7 @@ struct ChatContext { #endif uint8_t self_is_typing; + uint8_t pastemode; /* whether to translate \r to \n */ WINDOW *history; WINDOW *linewin;