--- lbbs/src/str_process.c 2025/06/13 10:52:07 1.13 +++ lbbs/src/str_process.c 2025/06/14 11:15:46 1.16 @@ -63,7 +63,7 @@ int split_line(const char *buffer, int m } (*p_display_len)++; - // \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 if (c == '\n') { i++; @@ -92,7 +92,7 @@ long split_data_lines(const char *p_buf, // Exceed max_line_cnt if (line_cnt + 1 >= line_offsets_count) { - log_error("Line count %d reaches limit %d\n", line_cnt + 1, line_offsets_count); + // log_error("Line count %d reaches limit %d\n", line_cnt + 1, line_offsets_count); return line_cnt; } @@ -103,3 +103,34 @@ long split_data_lines(const char *p_buf, return line_cnt; } + +int ctrl_seq_filter(char *buffer) +{ + int i; + int j; + + for (i = 0, j = 0; buffer[i] != '\0'; i++) + { + if (buffer[i] == '\r' || buffer[i] == '\7') // skip + { + continue; + } + + if (buffer[i] == '\033' && buffer[i + 1] == '[') // Skip control sequence + { + i += 2; + while (buffer[i] != '\0' && buffer[i] != 'm') + { + i++; + } + continue; + } + + buffer[j] = buffer[i]; + j++; + } + + buffer[j] = '\0'; + + return j; +}