瀏覽代碼

* If the ANSI file we import does not use the 80 columns, we don't expand

the canvas to 80 columns.
tags/v0.99.beta14
Sam Hocevar sam 19 年之前
父節點
當前提交
ee55871e3f
共有 1 個文件被更改,包括 10 次插入8 次删除
  1. +10
    -8
      cucul/import.c

+ 10
- 8
cucul/import.c 查看文件

@@ -243,7 +243,7 @@ static cucul_canvas_t *import_ansi(void const *data, unsigned int size)
unsigned char const *buffer = (unsigned char const*)data; unsigned char const *buffer = (unsigned char const*)data;
cucul_canvas_t *cv; cucul_canvas_t *cv;
unsigned int i, j, skip, dummy = 0; unsigned int i, j, skip, dummy = 0;
unsigned int width = 80, height = 25;
unsigned int width = 1, height = 1;
int x = 0, y = 0, save_x = 0, save_y = 0; int x = 0, y = 0, save_x = 0, save_y = 0;


cv = cucul_create_canvas(width, height); cv = cucul_create_canvas(width, height);
@@ -262,7 +262,7 @@ static cucul_canvas_t *import_ansi(void const *data, unsigned int size)
skip = 1; skip = 1;


/* Wrap long lines */ /* Wrap long lines */
if((unsigned int)x >= width)
if((unsigned int)x >= 80)
{ {
x = 0; x = 0;
y++; y++;
@@ -379,9 +379,11 @@ static cucul_canvas_t *import_ansi(void const *data, unsigned int size)
x = y = 0; x = y = 0;
break; break;
case 'K': /* EL - Erase In Line */ case 'K': /* EL - Erase In Line */
for(j = x; j < width; j++)
if(width < 80)
cucul_set_canvas_size(cv, width = 80, height);
for(j = x; j < 80; j++)
_cucul_putchar32(cv, j, y, (uint32_t)' '); _cucul_putchar32(cv, j, y, (uint32_t)' ');
x = width;
x = 80;
break; break;
case 'm': /* SGR - Select Graphic Rendition */ case 'm': /* SGR - Select Graphic Rendition */
ansi_parse_grcm(cv, &grcm, argc, argv); ansi_parse_grcm(cv, &grcm, argc, argv);
@@ -396,11 +398,11 @@ static cucul_canvas_t *import_ansi(void const *data, unsigned int size)


/* We're going to paste a character. First make sure the canvas /* We're going to paste a character. First make sure the canvas
* is big enough. */ * is big enough. */
if((unsigned int)x >= width)
cucul_set_canvas_size(cv, width = x + 1, height);

if((unsigned int)y >= height) if((unsigned int)y >= height)
{
height = y + 1;
cucul_set_canvas_size(cv, width, height);
}
cucul_set_canvas_size(cv, width, height = y + 1);


/* Now paste our character */ /* Now paste our character */
_cucul_putchar32(cv, x, y, _cucul_cp437_to_utf32(buffer[i])); _cucul_putchar32(cv, x, y, _cucul_cp437_to_utf32(buffer[i]));


Loading…
取消
儲存