mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:23: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)
|
if (y2 <= 0 || x2 <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (ctx->pastemode && key == '\r')
|
||||||
|
key = '\n';
|
||||||
|
|
||||||
if (self->help->active) {
|
if (self->help->active) {
|
||||||
help_onKey(self, key);
|
help_onKey(self, key);
|
||||||
return;
|
return;
|
||||||
|
@ -571,6 +571,9 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx->pastemode && key == '\r')
|
||||||
|
key = '\n';
|
||||||
|
|
||||||
if (ltr || key == '\n') { /* char is printable */
|
if (ltr || key == '\n') { /* char is printable */
|
||||||
input_new_char(self, key, x, y, x2, y2);
|
input_new_char(self, key, x, y, x2, y2);
|
||||||
return;
|
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);
|
force_refresh(self->chatwin->history);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_KEY_C_T:
|
||||||
|
self->chatwin->pastemode ^= 1;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
match = false;
|
match = false;
|
||||||
break;
|
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;
|
match = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
@ -189,6 +189,9 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
|||||||
if (x2 <= 0 || y2 <= 0)
|
if (x2 <= 0 || y2 <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (ctx->pastemode && key == '\r')
|
||||||
|
key = '\n';
|
||||||
|
|
||||||
/* ignore non-menu related input if active */
|
/* ignore non-menu related input if active */
|
||||||
if (self->help->active) {
|
if (self->help->active) {
|
||||||
help_onKey(self, key);
|
help_onKey(self, key);
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
#define T_KEY_C_L 0x0C /* ctrl-l */
|
#define T_KEY_C_L 0x0C /* ctrl-l */
|
||||||
#define T_KEY_C_W 0x17 /* ctrl-w */
|
#define T_KEY_C_W 0x17 /* ctrl-w */
|
||||||
#define T_KEY_C_B 0x02 /* ctrl-b */
|
#define T_KEY_C_B 0x02 /* ctrl-b */
|
||||||
|
#define T_KEY_C_T 0x14 /* ctrl-t */
|
||||||
#define T_KEY_TAB 0x09 /* TAB key */
|
#define T_KEY_TAB 0x09 /* TAB key */
|
||||||
|
|
||||||
#define ONLINE_CHAR "*"
|
#define ONLINE_CHAR "*"
|
||||||
|
@ -237,6 +237,7 @@ struct ChatContext {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t self_is_typing;
|
uint8_t self_is_typing;
|
||||||
|
uint8_t pastemode; /* whether to translate \r to \n */
|
||||||
|
|
||||||
WINDOW *history;
|
WINDOW *history;
|
||||||
WINDOW *linewin;
|
WINDOW *linewin;
|
||||||
|
Loading…
Reference in New Issue
Block a user