Mercurial > vim
comparison src/terminal.c @ 15504:247511eadb7a v8.1.0760
patch 8.1.0760: no proper test for using 'termencoding'
commit https://github.com/vim/vim/commit/617d7ef0462e86ec946d8932e4d157e65bbc9aa8
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 17 13:04:30 2019 +0100
patch 8.1.0760: no proper test for using 'termencoding'
Problem: No proper test for using 'termencoding'.
Solution: Add a screendump test. Fix using double width characters in a
screendump.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 17 Jan 2019 13:15:07 +0100 |
parents | 55ccc2d353bd |
children | d89c5b339c2a |
comparison
equal
deleted
inserted
replaced
15503:65eb414db805 | 15504:247511eadb7a |
---|---|
4029 if (cell.width != prev_cell.width || !same_attr) | 4029 if (cell.width != prev_cell.width || !same_attr) |
4030 { | 4030 { |
4031 if (cell.width == 2) | 4031 if (cell.width == 2) |
4032 { | 4032 { |
4033 fputs("*", fd); | 4033 fputs("*", fd); |
4034 ++pos.col; | |
4035 } | 4034 } |
4036 else | 4035 else |
4037 fputs("+", fd); | 4036 fputs("+", fd); |
4038 | 4037 |
4039 if (same_attr) | 4038 if (same_attr) |
4060 } | 4059 } |
4061 } | 4060 } |
4062 | 4061 |
4063 prev_cell = cell; | 4062 prev_cell = cell; |
4064 } | 4063 } |
4064 | |
4065 if (cell.width == 2) | |
4066 ++pos.col; | |
4065 } | 4067 } |
4066 if (repeat > 0) | 4068 if (repeat > 0) |
4067 fprintf(fd, "@%d", repeat); | 4069 fprintf(fd, "@%d", repeat); |
4068 fputs("\n", fd); | 4070 fputs("\n", fd); |
4069 } | 4071 } |
4101 garray_T ga_text; | 4103 garray_T ga_text; |
4102 garray_T ga_cell; | 4104 garray_T ga_cell; |
4103 char_u *prev_char = NULL; | 4105 char_u *prev_char = NULL; |
4104 int attr = 0; | 4106 int attr = 0; |
4105 cellattr_T cell; | 4107 cellattr_T cell; |
4108 cellattr_T empty_cell; | |
4106 term_T *term = curbuf->b_term; | 4109 term_T *term = curbuf->b_term; |
4107 int max_cells = 0; | 4110 int max_cells = 0; |
4108 int start_row = term->tl_scrollback.ga_len; | 4111 int start_row = term->tl_scrollback.ga_len; |
4109 | 4112 |
4110 ga_init2(&ga_text, 1, 90); | 4113 ga_init2(&ga_text, 1, 90); |
4111 ga_init2(&ga_cell, sizeof(cellattr_T), 90); | 4114 ga_init2(&ga_cell, sizeof(cellattr_T), 90); |
4112 vim_memset(&cell, 0, sizeof(cell)); | 4115 vim_memset(&cell, 0, sizeof(cell)); |
4116 vim_memset(&empty_cell, 0, sizeof(empty_cell)); | |
4113 cursor_pos->row = -1; | 4117 cursor_pos->row = -1; |
4114 cursor_pos->col = -1; | 4118 cursor_pos->col = -1; |
4115 | 4119 |
4116 c = fgetc(fd); | 4120 c = fgetc(fd); |
4117 for (;;) | 4121 for (;;) |
4206 { | 4210 { |
4207 attr = attr * 10 + (c - '0'); | 4211 attr = attr * 10 + (c - '0'); |
4208 c = fgetc(fd); | 4212 c = fgetc(fd); |
4209 } | 4213 } |
4210 hl2vtermAttr(attr, &cell); | 4214 hl2vtermAttr(attr, &cell); |
4215 | |
4216 /* is_bg == 0: fg, is_bg == 1: bg */ | |
4217 for (is_bg = 0; is_bg <= 1; ++is_bg) | |
4218 { | |
4219 if (c == '&') | |
4220 { | |
4221 /* use same color as previous cell */ | |
4222 c = fgetc(fd); | |
4223 } | |
4224 else if (c == '#') | |
4225 { | |
4226 int red, green, blue, index = 0; | |
4227 | |
4228 c = fgetc(fd); | |
4229 red = hex2nr(c); | |
4230 c = fgetc(fd); | |
4231 red = (red << 4) + hex2nr(c); | |
4232 c = fgetc(fd); | |
4233 green = hex2nr(c); | |
4234 c = fgetc(fd); | |
4235 green = (green << 4) + hex2nr(c); | |
4236 c = fgetc(fd); | |
4237 blue = hex2nr(c); | |
4238 c = fgetc(fd); | |
4239 blue = (blue << 4) + hex2nr(c); | |
4240 c = fgetc(fd); | |
4241 if (!isdigit(c)) | |
4242 dump_is_corrupt(&ga_text); | |
4243 while (isdigit(c)) | |
4244 { | |
4245 index = index * 10 + (c - '0'); | |
4246 c = fgetc(fd); | |
4247 } | |
4248 | |
4249 if (is_bg) | |
4250 { | |
4251 cell.bg.red = red; | |
4252 cell.bg.green = green; | |
4253 cell.bg.blue = blue; | |
4254 cell.bg.ansi_index = index; | |
4255 } | |
4256 else | |
4257 { | |
4258 cell.fg.red = red; | |
4259 cell.fg.green = green; | |
4260 cell.fg.blue = blue; | |
4261 cell.fg.ansi_index = index; | |
4262 } | |
4263 } | |
4264 else | |
4265 dump_is_corrupt(&ga_text); | |
4266 } | |
4211 } | 4267 } |
4212 else | 4268 else |
4213 dump_is_corrupt(&ga_text); | 4269 dump_is_corrupt(&ga_text); |
4214 | |
4215 /* is_bg == 0: fg, is_bg == 1: bg */ | |
4216 for (is_bg = 0; is_bg <= 1; ++is_bg) | |
4217 { | |
4218 if (c == '&') | |
4219 { | |
4220 /* use same color as previous cell */ | |
4221 c = fgetc(fd); | |
4222 } | |
4223 else if (c == '#') | |
4224 { | |
4225 int red, green, blue, index = 0; | |
4226 | |
4227 c = fgetc(fd); | |
4228 red = hex2nr(c); | |
4229 c = fgetc(fd); | |
4230 red = (red << 4) + hex2nr(c); | |
4231 c = fgetc(fd); | |
4232 green = hex2nr(c); | |
4233 c = fgetc(fd); | |
4234 green = (green << 4) + hex2nr(c); | |
4235 c = fgetc(fd); | |
4236 blue = hex2nr(c); | |
4237 c = fgetc(fd); | |
4238 blue = (blue << 4) + hex2nr(c); | |
4239 c = fgetc(fd); | |
4240 if (!isdigit(c)) | |
4241 dump_is_corrupt(&ga_text); | |
4242 while (isdigit(c)) | |
4243 { | |
4244 index = index * 10 + (c - '0'); | |
4245 c = fgetc(fd); | |
4246 } | |
4247 | |
4248 if (is_bg) | |
4249 { | |
4250 cell.bg.red = red; | |
4251 cell.bg.green = green; | |
4252 cell.bg.blue = blue; | |
4253 cell.bg.ansi_index = index; | |
4254 } | |
4255 else | |
4256 { | |
4257 cell.fg.red = red; | |
4258 cell.fg.green = green; | |
4259 cell.fg.blue = blue; | |
4260 cell.fg.ansi_index = index; | |
4261 } | |
4262 } | |
4263 else | |
4264 dump_is_corrupt(&ga_text); | |
4265 } | |
4266 } | 4270 } |
4267 else | 4271 else |
4268 dump_is_corrupt(&ga_text); | 4272 dump_is_corrupt(&ga_text); |
4269 | 4273 |
4270 append_cell(&ga_cell, &cell); | 4274 append_cell(&ga_cell, &cell); |
4275 if (cell.width == 2) | |
4276 append_cell(&ga_cell, &empty_cell); | |
4271 } | 4277 } |
4272 else if (c == '@') | 4278 else if (c == '@') |
4273 { | 4279 { |
4274 if (prev_char == NULL) | 4280 if (prev_char == NULL) |
4275 dump_is_corrupt(&ga_text); | 4281 dump_is_corrupt(&ga_text); |