mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
plain renderer: used switch instead of if, else if, else
This commit is contained in:
parent
47062531ee
commit
1feab80c13
@ -291,21 +291,8 @@ add_document_line(struct plain_renderer *renderer,
|
|||||||
next_char = (line_pos + 1 < width) ? line[line_pos + 1]
|
next_char = (line_pos + 1 < width) ? line[line_pos + 1]
|
||||||
: '\0';
|
: '\0';
|
||||||
|
|
||||||
/* Do not expand tabs that precede back-spaces; this saves the
|
switch (line_char) {
|
||||||
* back-space code some trouble. */
|
case ASCII_BS:
|
||||||
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) {
|
|
||||||
if (!(expanded + line_pos)) {
|
if (!(expanded + line_pos)) {
|
||||||
/* We've backspaced to the start of the line */
|
/* We've backspaced to the start of the line */
|
||||||
continue;
|
continue;
|
||||||
@ -366,39 +353,58 @@ add_document_line(struct plain_renderer *renderer,
|
|||||||
/* Handle _^Hx^Hx as both bold and underlined */
|
/* Handle _^Hx^Hx as both bold and underlined */
|
||||||
if (template->attr)
|
if (template->attr)
|
||||||
template->attr |= pos->attr;
|
template->attr |= pos->attr;
|
||||||
} else {
|
break;
|
||||||
int added_chars = 0;
|
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);
|
||||||
|
|
||||||
if (document->options.plain_display_links
|
expanded += tab_width;
|
||||||
&& isalpha(line_char) && isalpha(next_char)) {
|
|
||||||
/* We only want to check for a URI if there are
|
template->data = ' ';
|
||||||
* at least two consecutive alphabetic
|
do
|
||||||
* characters, or if we are at the very start of
|
copy_screen_chars(pos++, template, 1);
|
||||||
* the line. It improves performance a bit.
|
while (tab_width--);
|
||||||
* --Zas */
|
|
||||||
added_chars = print_document_link(renderer,
|
*template = saved_renderer_template;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
int added_chars = 0;
|
||||||
|
|
||||||
|
if (document->options.plain_display_links
|
||||||
|
&& isalpha(line_char) && isalpha(next_char)) {
|
||||||
|
/* We only want to check for a URI if there are
|
||||||
|
* at least two consecutive alphabetic
|
||||||
|
* characters, or if we are at the very start of
|
||||||
|
* the line. It improves performance a bit.
|
||||||
|
* --Zas */
|
||||||
|
added_chars = print_document_link(renderer,
|
||||||
lineno, line,
|
lineno, line,
|
||||||
line_pos,
|
line_pos,
|
||||||
width,
|
width,
|
||||||
expanded,
|
expanded,
|
||||||
pos);
|
pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (added_chars) {
|
||||||
|
line_pos += added_chars - 1;
|
||||||
|
pos += added_chars;
|
||||||
|
} else {
|
||||||
|
if (!isscreensafe(line_char) && line_char != 27)
|
||||||
|
line_char = '.';
|
||||||
|
template->data = line_char;
|
||||||
|
copy_screen_chars(pos++, template, 1);
|
||||||
|
|
||||||
|
/* Detect copy of nul chars to screen, this
|
||||||
|
* should not occur. --Zas */
|
||||||
|
assert(line_char);
|
||||||
|
}
|
||||||
|
|
||||||
|
*template = saved_renderer_template;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (added_chars) {
|
|
||||||
line_pos += added_chars - 1;
|
|
||||||
pos += added_chars;
|
|
||||||
} else {
|
|
||||||
if (!isscreensafe(line_char))
|
|
||||||
line_char = '.';
|
|
||||||
template->data = line_char;
|
|
||||||
copy_screen_chars(pos++, template, 1);
|
|
||||||
|
|
||||||
/* Detect copy of nul chars to screen, this
|
|
||||||
* should not occur. --Zas */
|
|
||||||
assert(line_char);
|
|
||||||
}
|
|
||||||
|
|
||||||
*template = saved_renderer_template;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user