Fix #3926 - Fix color wrap for long lines in visual mode

This commit is contained in:
pancake 2016-01-10 23:46:33 +01:00
parent 6b752ce77e
commit 9dc6cfa4ea
2 changed files with 41 additions and 41 deletions

View File

@ -536,10 +536,8 @@ R_API void r_cons_visual_write (char *buffer) {
const char *endptr;
char *nl, *ptr = buffer, *pptr;
if (I.null)
return;
if (I.null) return;
memset (&white, ' ', sizeof (white));
while ((nl = strchr (ptr, '\n'))) {
int len = ((int)(size_t)(nl-ptr))+1;
@ -550,23 +548,27 @@ R_API void r_cons_visual_write (char *buffer) {
plen = ptr > buffer ? len : len - 1;
if (alen > cols) {
int olen = len;
endptr = r_str_ansi_chrn (ptr, cols);
endptr++;
len = (endptr-ptr);
len = endptr - ptr;
plen = ptr > buffer ? len : len - 1;
if (lines > 0)
if (lines > 0) {
r_cons_write (pptr, plen);
if (len != olen) {
r_cons_write (Color_RESET,strlen (Color_RESET));
}
}
} else {
if (lines > 0) {
int w = cols - alen;
r_cons_write (pptr, plen);
if (I.blankline && w>0) {
if (w>sizeof (white)-1)
w = sizeof (white)-1;
if (w > sizeof (white) - 1)
w = sizeof (white) - 1;
r_cons_write (white, w);
}
}
// TRICK to empty columns.. maybe buggy in w32
if (r_mem_mem ((const ut8*)ptr, len, (const ut8*)"\x1b[0;0H", 6)) {
lines = I.rows;
@ -578,7 +580,7 @@ R_API void r_cons_visual_write (char *buffer) {
}
/* fill the rest of screen */
if (lines>0) {
if (cols>sizeof (white))
if (cols > sizeof (white))
cols = sizeof (white);
while (--lines >= 0)
r_cons_write (white, cols);

View File

@ -164,40 +164,38 @@ R_API int r_cons_w32_print(const ut8 *ptr, int len, int vmode) {
continue;
} else
if (esc == 2) {
{
int x, y;
const char *ptr2 = NULL;
int i, state = 0;
for (i=0; ptr[i] && state>=0; i++) {
switch (state) {
case 0:
if (ptr[i]==';') {
y = atoi ((const char *)ptr);
state = 1;
ptr2 = (const char *)ptr+i+1;
} else
if (ptr[i] >='0' && ptr[i]<='9') {
// ok
} else state = -1; // END FAIL
break;
case 1:
if (ptr[i]=='H') {
x = atoi (ptr2);
state = -2; // END OK
} else
if (ptr[i] >='0' && ptr[i]<='9') {
// ok
} else state = -1; // END FAIL
break;
}
}
if (state == -2) {
w32_gotoxy (x, y);
ptr += i;
str = ptr + 1;// + i-2;
continue;
int x, y;
const char *ptr2 = NULL;
int i, state = 0;
for (i=0; ptr[i] && state>=0; i++) {
switch (state) {
case 0:
if (ptr[i]==';') {
y = atoi ((const char *)ptr);
state = 1;
ptr2 = (const char *)ptr+i+1;
} else
if (ptr[i] >='0' && ptr[i]<='9') {
// ok
} else state = -1; // END FAIL
break;
case 1:
if (ptr[i]=='H') {
x = atoi (ptr2);
state = -2; // END OK
} else
if (ptr[i] >='0' && ptr[i]<='9') {
// ok
} else state = -1; // END FAIL
break;
}
}
if (state == -2) {
w32_gotoxy (x, y);
ptr += i;
str = ptr + 1;// + i-2;
continue;
}
if (ptr[0]=='0'&&ptr[1]==';'&&ptr[2]=='0') {
// \x1b[0;0H
/** clear screen if gotoxy **/