mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-28 07:58:00 -04:00
selection: replace \r\n with \n in pasted text
This commit is contained in:
parent
bb0ce50b24
commit
3ca6f9fe0b
1 changed files with 16 additions and 0 deletions
16
selection.c
16
selection.c
|
|
@ -517,6 +517,14 @@ text_from_clipboard(struct terminal *term, uint32_t serial,
|
||||||
} else if (amount == 0)
|
} else if (amount == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* Replace \r\n with \n */
|
||||||
|
for (size_t i = 0; i < amount - 1; i++) {
|
||||||
|
if (text[i] == '\r' && text[i + 1] == '\n') {
|
||||||
|
memmove(&text[i], &text[i + 1], amount - i - 1);
|
||||||
|
amount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cb(text, amount, user);
|
cb(text, amount, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -645,6 +653,14 @@ text_from_primary(
|
||||||
} else if (amount == 0)
|
} else if (amount == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* Replace \r\n with \n */
|
||||||
|
for (size_t i = 0; i < amount - 1; i++) {
|
||||||
|
if (text[i] == '\r' && text[i + 1] == '\n') {
|
||||||
|
memmove(&text[i], &text[i + 1], amount - i - 1);
|
||||||
|
amount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cb(text, amount, user);
|
cb(text, amount, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue