Merge branch 'terminology-1.4'

This commit is contained in:
Boris Faure 2019-05-03 23:28:34 +02:00
commit 766c3bfebc
2 changed files with 21 additions and 18 deletions

View File

@ -1033,34 +1033,37 @@ _getsel_cb(void *data,
if (buf) if (buf)
{ {
char *s = ev->data; char *s = ev->data;
size_t i, pos = 0; int i, j, pos = 0, prev_i;
/* apparently we have to convert \n into \r in terminal land. */ /* apparently we have to convert \n into \r in terminal land. */
for (i = 0; i < ev->len && s[i]; i++) for (i = 0; i < (int)ev->len && s[i];)
{ {
Eina_Unicode g = 0;
prev_i = i;
g = eina_unicode_utf8_next_get(s, &i);
/* Skip escape codes as a security measure */ /* Skip escape codes as a security measure */
if ((s[i] < '\n') || if ((g < '\n') ||
((s[i] > '\n') && (s[i] < ' '))) ((g > '\n') && (g < ' ')))
{ {
continue; continue;
} }
buf[pos] = s[i]; for (j = prev_i; j < i; j++)
if (buf[pos] == '\n') buf[pos++] = s[j];
buf[pos] = '\r'; if (g == '\n')
pos++; buf[pos++] = '\r';
} }
if (pos) if (pos)
{ {
if (sd->pty->bracketed_paste)
termpty_write(sd->pty, "\x1b[200~",
sizeof("\x1b[200~") - 1);
if (sd->pty->bracketed_paste) termpty_write(sd->pty, buf, pos);
termpty_write(sd->pty, "\x1b[200~",
sizeof("\x1b[200~") - 1);
termpty_write(sd->pty, buf, pos); if (sd->pty->bracketed_paste)
termpty_write(sd->pty, "\x1b[201~",
if (sd->pty->bracketed_paste) sizeof("\x1b[201~") - 1);
termpty_write(sd->pty, "\x1b[201~",
sizeof("\x1b[201~") - 1);
} }
free(buf); free(buf);

View File

@ -302,7 +302,7 @@ _fd_read_do(Termpty *ty, Ecore_Fd_Handler *fd_handler, Eina_Bool false_on_empty)
j = 0; j = 0;
for (i = 0; i < len;) for (i = 0; i < len;)
{ {
int g = 0, prev_i = i; Eina_Unicode g = 0, prev_i = i;
if (buf[i]) if (buf[i])
{ {