diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-10-16 19:14:45 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-10-16 19:14:45 +0000 |
| commit | 3ca6f9fe0b61995d4b1b88b57c6306e9bb066980 (patch) | |
| tree | bf9fafa911a4215cd2770faba5992bfd1085c717 /selection.c | |
| parent | README: link to PKGBUILD (diff) | |
selection: replace \r\n with \n in pasted text
Diffstat (limited to 'selection.c')
| -rw-r--r-- | selection.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/selection.c b/selection.c index 72e56ec0..d5b89dba 100644 --- a/selection.c +++ b/selection.c @@ -517,6 +517,14 @@ text_from_clipboard(struct terminal *term, uint32_t serial, } else if (amount == 0) 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); } @@ -645,6 +653,14 @@ text_from_primary( } else if (amount == 0) 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); } |
