1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

plain renderer: used switch instead of if, else if, else

This commit is contained in:
Witold Filipczyk 2006-05-07 14:39:27 +02:00 committed by Witold Filipczyk
parent 47062531ee
commit 1feab80c13

View File

@ -291,21 +291,8 @@ add_document_line(struct plain_renderer *renderer,
next_char = (line_pos + 1 < width) ? line[line_pos + 1]
: '\0';
/* Do not expand tabs that precede back-spaces; this saves the
* back-space code some trouble. */
if (line_char == ASCII_TAB && next_char != ASCII_BS) {
int tab_width = 7 - ((line_pos + expanded) & 7);
expanded += tab_width;
template->data = ' ';
do
copy_screen_chars(pos++, template, 1);
while (tab_width--);
*template = saved_renderer_template;
} else if (line_char == ASCII_BS) {
switch (line_char) {
case ASCII_BS:
if (!(expanded + line_pos)) {
/* We've backspaced to the start of the line */
continue;
@ -366,7 +353,25 @@ add_document_line(struct plain_renderer *renderer,
/* Handle _^Hx^Hx as both bold and underlined */
if (template->attr)
template->attr |= pos->attr;
} else {
break;
case ASCII_TAB:
/* Do not expand tabs that precede back-spaces; this saves the
* back-space code some trouble. */
if (next_char != ASCII_BS) {
int tab_width = 7 - ((line_pos + expanded) & 7);
expanded += tab_width;
template->data = ' ';
do
copy_screen_chars(pos++, template, 1);
while (tab_width--);
*template = saved_renderer_template;
break;
}
default:
{
int added_chars = 0;
if (document->options.plain_display_links
@ -388,7 +393,7 @@ add_document_line(struct plain_renderer *renderer,
line_pos += added_chars - 1;
pos += added_chars;
} else {
if (!isscreensafe(line_char))
if (!isscreensafe(line_char) && line_char != 27)
line_char = '.';
template->data = line_char;
copy_screen_chars(pos++, template, 1);
@ -401,6 +406,7 @@ add_document_line(struct plain_renderer *renderer,
*template = saved_renderer_template;
}
}
}
mem_free(line);