| 63 |
} |
} |
| 64 |
(*p_display_len)++; |
(*p_display_len)++; |
| 65 |
|
|
| 66 |
// \n is regarded as 1 character wide in terminal editor, which is different from Web version |
// \n is regarded as 1 character wide in terminal editor, which is different from Web version |
| 67 |
if (c == '\n') |
if (c == '\n') |
| 68 |
{ |
{ |
| 69 |
i++; |
i++; |
| 103 |
|
|
| 104 |
return line_cnt; |
return line_cnt; |
| 105 |
} |
} |
| 106 |
|
|
| 107 |
|
int ctrl_seq_filter(char *buffer) |
| 108 |
|
{ |
| 109 |
|
int i; |
| 110 |
|
int j; |
| 111 |
|
char c; |
| 112 |
|
|
| 113 |
|
for (i = 0, j = 0; buffer[i] != '\0'; i++) |
| 114 |
|
{ |
| 115 |
|
c = buffer[i]; |
| 116 |
|
|
| 117 |
|
if (c == '\r' || c == '\7') // skip |
| 118 |
|
{ |
| 119 |
|
continue; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
if (c == '\033' && buffer[i + 1] == '[') // Skip control sequence |
| 123 |
|
{ |
| 124 |
|
i += 2; |
| 125 |
|
while (buffer[i] != '\0' && buffer[i] != 'm') |
| 126 |
|
{ |
| 127 |
|
i++; |
| 128 |
|
} |
| 129 |
|
continue; |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
buffer[j] = buffer[i]; |
| 133 |
|
j++; |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
buffer[j] = '\0'; |
| 137 |
|
|
| 138 |
|
return j; |
| 139 |
|
} |