mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[plain] one level of indentation less
This commit is contained in:
parent
d43028a0cf
commit
b1317c3e46
@ -857,98 +857,96 @@ fixup_tables(struct plain_renderer *renderer)
|
||||
struct line *next_line = y < renderer->lineno - 1 ? &renderer->document->data[y + 1] : NULL;
|
||||
|
||||
for (x = 0; x < line->length; x++) {
|
||||
int dir;
|
||||
#ifdef CONFIG_UTF8
|
||||
unicode_val_T ch = line->chars[x].data;
|
||||
unicode_val_T prev_char, next_char, up_char, down_char;
|
||||
#else
|
||||
unsigned char ch = line->chars[x].data;
|
||||
unsigned char prev_char, next_char, up_char, down_char;
|
||||
#endif
|
||||
if (ch == '+' || ch == '-' || ch == '|') {
|
||||
int dir;
|
||||
#ifdef CONFIG_UTF8
|
||||
unicode_val_T prev_char = x > 0 ? line->chars[x - 1].data : ' ';
|
||||
unicode_val_T next_char = x < line->length - 1 ? line->chars[x + 1].data : ' ';
|
||||
unicode_val_T up_char = (prev_line && x < prev_line->length) ? prev_line->chars[x].data : ' ';
|
||||
unicode_val_T down_char = (next_line && x < next_line->length) ? next_line->chars[x].data : ' ';
|
||||
#else
|
||||
unsigned char prev_char = x > 0 ? line->chars[x - 1].data : ' ';
|
||||
unsigned char next_char = x < line->length - 1 ? line->chars[x + 1].data : ' ';
|
||||
unsigned char up_char = (prev_line && x < prev_line->length) ? prev_line->chars[x].data : ' ';
|
||||
unsigned char down_char = (next_line && x < next_line->length) ? next_line->chars[x].data : ' ';
|
||||
#endif
|
||||
switch (ch) {
|
||||
case '+':
|
||||
dir = 0;
|
||||
if (up_char == '|' || up_char == BORDER_SVLINE) dir |= 1;
|
||||
if (next_char == '-' || next_char == BORDER_SHLINE) dir |= 2;
|
||||
if (down_char == '|' || down_char == BORDER_SVLINE) dir |= 4;
|
||||
if (prev_char == '-' || prev_char == BORDER_SHLINE) dir |= 8;
|
||||
if (ch != '+' && ch != '-' && ch != '|') {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (dir) {
|
||||
case 15:
|
||||
line->chars[x].data = BORDER_SCROSS;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 13:
|
||||
line->chars[x].data = BORDER_SLTEE;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 7:
|
||||
line->chars[x].data = BORDER_SRTEE;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 6:
|
||||
line->chars[x].data = BORDER_SULCORNER;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 12:
|
||||
line->chars[x].data = BORDER_SURCORNER;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 3:
|
||||
line->chars[x].data = BORDER_SDLCORNER;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 9:
|
||||
line->chars[x].data = BORDER_SDRCORNER;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 11:
|
||||
line->chars[x].data = BORDER_SUTEE;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 14:
|
||||
line->chars[x].data = BORDER_SDTEE;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
prev_char = x > 0 ? line->chars[x - 1].data : ' ';
|
||||
next_char = x < line->length - 1 ? line->chars[x + 1].data : ' ';
|
||||
up_char = (prev_line && x < prev_line->length) ? prev_line->chars[x].data : ' ';
|
||||
down_char = (next_line && x < next_line->length) ? next_line->chars[x].data : ' ';
|
||||
|
||||
switch (ch) {
|
||||
case '+':
|
||||
dir = 0;
|
||||
if (up_char == '|' || up_char == BORDER_SVLINE) dir |= 1;
|
||||
if (next_char == '-' || next_char == BORDER_SHLINE) dir |= 2;
|
||||
if (down_char == '|' || down_char == BORDER_SVLINE) dir |= 4;
|
||||
if (prev_char == '-' || prev_char == BORDER_SHLINE) dir |= 8;
|
||||
|
||||
switch (dir) {
|
||||
case 15:
|
||||
line->chars[x].data = BORDER_SCROSS;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case '-':
|
||||
if (prev_char == BORDER_SHLINE || prev_char == BORDER_SCROSS || prev_char == '+' || prev_char == '|'
|
||||
|| prev_char == BORDER_SULCORNER || prev_char == BORDER_SDLCORNER || prev_char == BORDER_SRTEE
|
||||
|| prev_char == BORDER_SUTEE || prev_char == BORDER_SDTEE) {
|
||||
line->chars[x].data = BORDER_SHLINE;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
}
|
||||
case 13:
|
||||
line->chars[x].data = BORDER_SLTEE;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case '|':
|
||||
if (up_char == BORDER_SVLINE || up_char == '+' || up_char == '|' || up_char == BORDER_SULCORNER
|
||||
|| up_char == BORDER_SURCORNER || up_char == BORDER_SCROSS || up_char == BORDER_SRTEE || up_char == BORDER_SLTEE
|
||||
|| up_char == BORDER_SDTEE) {
|
||||
if (next_char == '-') {
|
||||
line->chars[x].data = BORDER_SRTEE;
|
||||
} else if (prev_char == BORDER_SHLINE || prev_char == '-') {
|
||||
line->chars[x].data = BORDER_SLTEE;
|
||||
} else {
|
||||
line->chars[x].data = BORDER_SVLINE;
|
||||
}
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
}
|
||||
case 7:
|
||||
line->chars[x].data = BORDER_SRTEE;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 6:
|
||||
line->chars[x].data = BORDER_SULCORNER;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 12:
|
||||
line->chars[x].data = BORDER_SURCORNER;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 3:
|
||||
line->chars[x].data = BORDER_SDLCORNER;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 9:
|
||||
line->chars[x].data = BORDER_SDRCORNER;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 11:
|
||||
line->chars[x].data = BORDER_SUTEE;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
case 14:
|
||||
line->chars[x].data = BORDER_SDTEE;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '-':
|
||||
if (prev_char == BORDER_SHLINE || prev_char == BORDER_SCROSS || prev_char == '+' || prev_char == '|'
|
||||
|| prev_char == BORDER_SULCORNER || prev_char == BORDER_SDLCORNER || prev_char == BORDER_SRTEE
|
||||
|| prev_char == BORDER_SUTEE || prev_char == BORDER_SDTEE) {
|
||||
line->chars[x].data = BORDER_SHLINE;
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
}
|
||||
break;
|
||||
case '|':
|
||||
if (up_char == BORDER_SVLINE || up_char == '+' || up_char == '|' || up_char == BORDER_SULCORNER
|
||||
|| up_char == BORDER_SURCORNER || up_char == BORDER_SCROSS || up_char == BORDER_SRTEE || up_char == BORDER_SLTEE
|
||||
|| up_char == BORDER_SDTEE) {
|
||||
if (next_char == '-') {
|
||||
line->chars[x].data = BORDER_SRTEE;
|
||||
} else if (prev_char == BORDER_SHLINE || prev_char == '-') {
|
||||
line->chars[x].data = BORDER_SLTEE;
|
||||
} else {
|
||||
line->chars[x].data = BORDER_SVLINE;
|
||||
}
|
||||
line->chars[x].attr = SCREEN_ATTR_FRAME;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user