From ab6f4ac8186aaaf48f1f92f8c221961163a01b89 Mon Sep 17 00:00:00 2001 From: witekfl Date: Sat, 4 Mar 2006 20:33:53 +0100 Subject: [PATCH] Lines filled with spaces --- src/viewer/dump/dump.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/viewer/dump/dump.c b/src/viewer/dump/dump.c index 6a5330cb..6179f6f6 100644 --- a/src/viewer/dump/dump.c +++ b/src/viewer/dump/dump.c @@ -423,6 +423,7 @@ dump_to_file_16(struct document *document, int fd) int bptr = 0; unsigned char *buf = mem_alloc(D_BUF); unsigned char color = 0; + int width = get_opt_int("document.dump.width"); if (!buf) return -1; @@ -430,6 +431,7 @@ dump_to_file_16(struct document *document, int fd) int white = 0; int x; + write_color_16(color, fd, buf, &bptr); for (x = 0; x < document->data[y].length; x++) { unsigned char c; unsigned char attr = document->data[y].chars[x].attr; @@ -464,6 +466,10 @@ dump_to_file_16(struct document *document, int fd) if (write_char(c, fd, buf, &bptr)) goto fail; } + for (;x < width; x++) { + if (write_char(' ', fd, buf, &bptr)) + goto fail; + } /* Print end of line. */ if (write_char('\n', fd, buf, &bptr)) @@ -521,7 +527,7 @@ write_color_256(unsigned char *str, unsigned char color, int fd, unsigned char * unsigned char bufor[16]; unsigned char *data = bufor; - snprintf(bufor, 16, "\033[;%s;5;%dm", str, color); + snprintf(bufor, 16, "\033[%s;5;%dm", str, color); while(*data) { if (write_char(*data++, fd, buf, bptr)) return -1; } @@ -536,12 +542,15 @@ dump_to_file_256(struct document *document, int fd) unsigned char *buf = mem_alloc(D_BUF); unsigned char foreground = 0; unsigned char background = 0; + int width = get_opt_int("document.dump.width"); if (!buf) return -1; for (y = 0; y < document->height; y++) { int white = 0; int x; + write_color_256("38", foreground, fd, buf, &bptr); + write_color_256("48", background, fd, buf, &bptr); for (x = 0; x < document->data[y].length; x++) { unsigned char c; @@ -584,6 +593,10 @@ dump_to_file_256(struct document *document, int fd) if (write_char(c, fd, buf, &bptr)) goto fail; } + for (;x < width; x++) { + if (write_char(' ', fd, buf, &bptr)) + goto fail; + } /* Print end of line. */ if (write_char('\n', fd, buf, &bptr))