X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fascii.c;h=f899c976782bfc7829275a0a6c52d8a3947eb480;hb=0b676d85cb983fa0e719de9300935d2c8b549b14;hp=ff5b1ba826588fb2ae35fd00f25fed5546ee10ac;hpb=214ed115df21d414f1a785a090d74e8b2525108a;p=pspp diff --git a/src/output/ascii.c b/src/output/ascii.c index ff5b1ba826..f899c97678 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -60,8 +60,16 @@ #define H TABLE_HORZ #define V TABLE_VERT -#define N_BOX (RENDER_N_LINES * RENDER_N_LINES \ - * RENDER_N_LINES * RENDER_N_LINES) +enum + { + ASCII_LINE_NONE, + ASCII_LINE_SINGLE, + ASCII_LINE_DOUBLE, + ASCII_N_LINES + }; + +#define N_BOX (ASCII_N_LINES * ASCII_N_LINES \ + * ASCII_N_LINES * ASCII_N_LINES) static const ucs4_t ascii_box_chars[N_BOX] = { @@ -125,18 +133,43 @@ static const ucs4_t unicode_box_chars[N_BOX] = 0x2566, 0x256c, 0x256c, }; -static inline int -make_box_index (int left, int right, int top, int bottom) +static int +ascii_line_from_render_line (int render_line) { - int start_side = left; - int end_side = right; - if (render_direction_rtl ()) + switch (render_line) { - start_side = right; - end_side = left; + case RENDER_LINE_NONE: + return ASCII_LINE_NONE; + + case RENDER_LINE_SINGLE: + case RENDER_LINE_DASHED: + case RENDER_LINE_THICK: + case RENDER_LINE_THIN: + return ASCII_LINE_SINGLE; + + case RENDER_LINE_DOUBLE: + return ASCII_LINE_DOUBLE; + + default: + return ASCII_LINE_NONE; } - return ((end_side * RENDER_N_LINES + bottom) * RENDER_N_LINES + start_side) * RENDER_N_LINES + top; +} + +static int +make_box_index (int left_, int right_, int top_, int bottom_) +{ + bool rtl = render_direction_rtl (); + int left = ascii_line_from_render_line (rtl ? right_ : left_); + int right = ascii_line_from_render_line (rtl ? left_ : right_); + int top = ascii_line_from_render_line (top_); + int bottom = ascii_line_from_render_line (bottom_); + + int idx = right; + idx = idx * ASCII_N_LINES + bottom; + idx = idx * ASCII_N_LINES + left; + idx = idx * ASCII_N_LINES + top; + return idx; } /* How to emphasize text. */