mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 21:33:02 +01:00
Add paste-mode to allow multiline text pasting
Ctrl-T toggles paste mode. Useful when pasting multiline text because it avoids triggering an enter keypress after linebreaks. Instead, every \r is translated to \n which is again translated to a pilcrow (see previous commit). The pasted text can then be sent as a whole instead of splitting up in multiple messages.
This commit is contained in:
parent
e6f839f9ac
commit
04576fea7e
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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 "*"
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user