summaryrefslogtreecommitdiff
path: root/src/terminal.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-17 13:04:30 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-17 13:04:30 +0100
commit617d7ef0462e86ec946d8932e4d157e65bbc9aa8 (patch)
treef538527764f013bbdd634868e30d717aa6df8a26 /src/terminal.c
parent83a52171ba00b2b9fd2d1d22a07e38fc9fc69c1e (diff)
downloadvim-git-617d7ef0462e86ec946d8932e4d157e65bbc9aa8.tar.gz
patch 8.1.0760: no proper test for using 'termencoding'v8.1.0760
Problem: No proper test for using 'termencoding'. Solution: Add a screendump test. Fix using double width characters in a screendump.
Diffstat (limited to 'src/terminal.c')
-rw-r--r--src/terminal.c98
1 files changed, 52 insertions, 46 deletions
diff --git a/src/terminal.c b/src/terminal.c
index dbb8f2cb1..09b607269 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -4031,7 +4031,6 @@ f_term_dumpwrite(typval_T *argvars, typval_T *rettv UNUSED)
if (cell.width == 2)
{
fputs("*", fd);
- ++pos.col;
}
else
fputs("+", fd);
@@ -4062,6 +4061,9 @@ f_term_dumpwrite(typval_T *argvars, typval_T *rettv UNUSED)
prev_cell = cell;
}
+
+ if (cell.width == 2)
+ ++pos.col;
}
if (repeat > 0)
fprintf(fd, "@%d", repeat);
@@ -4103,6 +4105,7 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
char_u *prev_char = NULL;
int attr = 0;
cellattr_T cell;
+ cellattr_T empty_cell;
term_T *term = curbuf->b_term;
int max_cells = 0;
int start_row = term->tl_scrollback.ga_len;
@@ -4110,6 +4113,7 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
ga_init2(&ga_text, 1, 90);
ga_init2(&ga_cell, sizeof(cellattr_T), 90);
vim_memset(&cell, 0, sizeof(cell));
+ vim_memset(&empty_cell, 0, sizeof(empty_cell));
cursor_pos->row = -1;
cursor_pos->col = -1;
@@ -4208,66 +4212,68 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
c = fgetc(fd);
}
hl2vtermAttr(attr, &cell);
- }
- else
- dump_is_corrupt(&ga_text);
- /* is_bg == 0: fg, is_bg == 1: bg */
- for (is_bg = 0; is_bg <= 1; ++is_bg)
- {
- if (c == '&')
- {
- /* use same color as previous cell */
- c = fgetc(fd);
- }
- else if (c == '#')
+ /* is_bg == 0: fg, is_bg == 1: bg */
+ for (is_bg = 0; is_bg <= 1; ++is_bg)
{
- int red, green, blue, index = 0;
-
- c = fgetc(fd);
- red = hex2nr(c);
- c = fgetc(fd);
- red = (red << 4) + hex2nr(c);
- c = fgetc(fd);
- green = hex2nr(c);
- c = fgetc(fd);
- green = (green << 4) + hex2nr(c);
- c = fgetc(fd);
- blue = hex2nr(c);
- c = fgetc(fd);
- blue = (blue << 4) + hex2nr(c);
- c = fgetc(fd);
- if (!isdigit(c))
- dump_is_corrupt(&ga_text);
- while (isdigit(c))
+ if (c == '&')
{
- index = index * 10 + (c - '0');
+ /* use same color as previous cell */
c = fgetc(fd);
}
-
- if (is_bg)
+ else if (c == '#')
{
- cell.bg.red = red;
- cell.bg.green = green;
- cell.bg.blue = blue;
- cell.bg.ansi_index = index;
+ int red, green, blue, index = 0;
+
+ c = fgetc(fd);
+ red = hex2nr(c);
+ c = fgetc(fd);
+ red = (red << 4) + hex2nr(c);
+ c = fgetc(fd);
+ green = hex2nr(c);
+ c = fgetc(fd);
+ green = (green << 4) + hex2nr(c);
+ c = fgetc(fd);
+ blue = hex2nr(c);
+ c = fgetc(fd);
+ blue = (blue << 4) + hex2nr(c);
+ c = fgetc(fd);
+ if (!isdigit(c))
+ dump_is_corrupt(&ga_text);
+ while (isdigit(c))
+ {
+ index = index * 10 + (c - '0');
+ c = fgetc(fd);
+ }
+
+ if (is_bg)
+ {
+ cell.bg.red = red;
+ cell.bg.green = green;
+ cell.bg.blue = blue;
+ cell.bg.ansi_index = index;
+ }
+ else
+ {
+ cell.fg.red = red;
+ cell.fg.green = green;
+ cell.fg.blue = blue;
+ cell.fg.ansi_index = index;
+ }
}
else
- {
- cell.fg.red = red;
- cell.fg.green = green;
- cell.fg.blue = blue;
- cell.fg.ansi_index = index;
- }
+ dump_is_corrupt(&ga_text);
}
- else
- dump_is_corrupt(&ga_text);
}
+ else
+ dump_is_corrupt(&ga_text);
}
else
dump_is_corrupt(&ga_text);
append_cell(&ga_cell, &cell);
+ if (cell.width == 2)
+ append_cell(&ga_cell, &empty_cell);
}
else if (c == '@')
{