From 0dee6475bd7f78ed6966b29ef248fd210e1081c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Sun, 1 Jul 2012 21:25:41 -0400 Subject: [PATCH] terminal: Insert newlines when copying multiple lines --- clients/terminal.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clients/terminal.c b/clients/terminal.c index 62bb020a..504e3c25 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -849,7 +849,12 @@ terminal_send_selection(struct terminal *terminal, int fd) if (!attr.attr.s) continue; len = strnlen((char *) p_row[col].byte, 4); - fwrite(p_row[col].byte, 1, len, fp); + if (len > 0) + fwrite(p_row[col].byte, 1, len, fp); + if (len == 0 || col == terminal->width - 1) { + fwrite("\n", 1, 1, fp); + break; + } } } fclose(fp);