@@ -89,35 +89,97 @@ const printTextFormat pg_asciiformat_old =
89
89
false
90
90
};
91
91
92
- const printTextFormat pg_utf8format =
93
- {
94
- "unicode" ,
95
- {
96
- /* ─, ┌, ┬, ┐ */
97
- {"\342\224\200" , "\342\224\214" , "\342\224\254" , "\342\224\220" },
98
- /* ─, ├, ┼, ┤ */
99
- {"\342\224\200" , "\342\224\234" , "\342\224\274" , "\342\224\244" },
100
- /* ─, └, ┴, ┘ */
101
- {"\342\224\200" , "\342\224\224" , "\342\224\264" , "\342\224\230" },
102
- /* N/A, │, │, │ */
103
- {"" , "\342\224\202" , "\342\224\202" , "\342\224\202" }
92
+ /* Default unicode linestyle format */
93
+ const printTextFormat pg_utf8format ;
94
+
95
+ typedef struct unicodeStyleRowFormat {
96
+ const char * horizontal ;
97
+ const char * vertical_and_right [2 ];
98
+ const char * vertical_and_left [2 ];
99
+ } unicodeStyleRowFormat ;
100
+
101
+ typedef struct unicodeStyleColumnFormat {
102
+ const char * vertical ;
103
+ const char * vertical_and_horizontal [2 ];
104
+ const char * up_and_horizontal [2 ];
105
+ const char * down_and_horizontal [2 ];
106
+ } unicodeStyleColumnFormat ;
107
+
108
+ typedef struct unicodeStyleBorderFormat {
109
+ const char * up_and_right ;
110
+ const char * vertical ;
111
+ const char * down_and_right ;
112
+ const char * horizontal ;
113
+ const char * down_and_left ;
114
+ const char * left_and_right ;
115
+ } unicodeStyleBorderFormat ;
116
+
117
+ typedef struct unicodeStyleFormat {
118
+ unicodeStyleRowFormat row_style [2 ];
119
+ unicodeStyleColumnFormat column_style [2 ];
120
+ unicodeStyleBorderFormat border_style [2 ];
121
+ const char * header_nl_left ;
122
+ const char * header_nl_right ;
123
+ const char * nl_left ;
124
+ const char * nl_right ;
125
+ const char * wrap_left ;
126
+ const char * wrap_right ;
127
+ bool wrap_right_border ;
128
+ } unicodeStyleFormat ;
129
+
130
+ const unicodeStyleFormat unicode_style = {
131
+ {
132
+ {
133
+ /* ─ */
134
+ "\342\224\200" ,
135
+ /* ├╟ */
136
+ {"\342\224\234" , "\342\225\237" },
137
+ /* ┤╢ */
138
+ {"\342\224\244" , "\342\225\242" },
139
+ },
140
+ {
141
+ /* ═ */
142
+ "\342\225\220" ,
143
+ /* ╞╠ */
144
+ {"\342\225\236" , "\342\225\240" },
145
+ /* ╡╣ */
146
+ {"\342\225\241" , "\342\225\243" },
147
+ },
148
+ },
149
+ {
150
+ {
151
+ /* │ */
152
+ "\342\224\202" ,
153
+ /* ┼╪ */
154
+ {"\342\224\274" , "\342\225\252" },
155
+ /* ┴╧ */
156
+ {"\342\224\264" , "\342\225\247" },
157
+ /* ┬╤ */
158
+ {"\342\224\254" , "\342\225\244" },
159
+ },
160
+ {
161
+ /* ║ */
162
+ "\342\225\221" ,
163
+ /* ╫╬ */
164
+ {"\342\225\253" , "\342\225\254" },
165
+ /* ╨╩ */
166
+ {"\342\225\250" , "\342\225\251" },
167
+ /* ╥╦ */
168
+ {"\342\225\245" , "\342\225\246" },
169
+ },
170
+ },
171
+ {
172
+ /* └│┌─┐┘ */
173
+ {"\342\224\224" , "\342\224\202" , "\342\224\214" , "\342\224\200" , "\342\224\220" , "\342\224\230" },
174
+ /* ╚║╔═╗╝ */
175
+ {"\342\225\232" , "\342\225\221" , "\342\225\224" , "\342\225\220" , "\342\225\227" , "\342\225\235" },
104
176
},
105
- /* │ */
106
- "\342\224\202" ,
107
- /* │ */
108
- "\342\224\202" ,
109
- /* │ */
110
- "\342\224\202" ,
111
177
" " ,
112
- /* ↵ */
113
- "\342\206\265" ,
178
+ "\342\206\265" , /* ↵ */
114
179
" " ,
115
- /* ↵ */
116
- "\342\206\265" ,
117
- /* … */
118
- "\342\200\246" ,
119
- /* … */
120
- "\342\200\246" ,
180
+ "\342\206\265" , /* ↵ */
181
+ "\342\200\246" , /* … */
182
+ "\342\200\246" , /* … */
121
183
true
122
184
};
123
185
@@ -1289,7 +1351,7 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
1289
1351
}
1290
1352
else
1291
1353
/*
1292
- * For border = 2, two more for the pipes (|) at the begging and
1354
+ * For border = 2, two more for the pipes (|) at the beginning and
1293
1355
* at the end of the lines.
1294
1356
*/
1295
1357
swidth = 7 ;
@@ -2952,6 +3014,58 @@ get_line_style(const printTableOpt *opt)
2952
3014
return & pg_asciiformat ;
2953
3015
}
2954
3016
3017
+ void
3018
+ refresh_utf8format (const printTableOpt * opt )
3019
+ {
3020
+ printTextFormat * popt = (printTextFormat * ) & pg_utf8format ;
3021
+
3022
+ const unicodeStyleBorderFormat * border ;
3023
+ const unicodeStyleRowFormat * header ;
3024
+ const unicodeStyleColumnFormat * column ;
3025
+
3026
+ popt -> name = "unicode" ;
3027
+
3028
+ border = & unicode_style .border_style [opt -> unicode_border_linestyle ];
3029
+ header = & unicode_style .row_style [opt -> unicode_header_linestyle ];
3030
+ column = & unicode_style .column_style [opt -> unicode_column_linestyle ];
3031
+
3032
+ popt -> lrule [PRINT_RULE_TOP ].hrule = border -> horizontal ;
3033
+ popt -> lrule [PRINT_RULE_TOP ].leftvrule = border -> down_and_right ;
3034
+ popt -> lrule [PRINT_RULE_TOP ].midvrule = column -> down_and_horizontal [opt -> unicode_border_linestyle ];
3035
+ popt -> lrule [PRINT_RULE_TOP ].rightvrule = border -> down_and_left ;
3036
+
3037
+ popt -> lrule [PRINT_RULE_MIDDLE ].hrule = header -> horizontal ;
3038
+ popt -> lrule [PRINT_RULE_MIDDLE ].leftvrule = header -> vertical_and_right [opt -> unicode_border_linestyle ];
3039
+ popt -> lrule [PRINT_RULE_MIDDLE ].midvrule = column -> vertical_and_horizontal [opt -> unicode_header_linestyle ];
3040
+ popt -> lrule [PRINT_RULE_MIDDLE ].rightvrule = header -> vertical_and_left [opt -> unicode_border_linestyle ];
3041
+
3042
+ popt -> lrule [PRINT_RULE_BOTTOM ].hrule = border -> horizontal ;
3043
+ popt -> lrule [PRINT_RULE_BOTTOM ].leftvrule = border -> up_and_right ;
3044
+ popt -> lrule [PRINT_RULE_BOTTOM ].midvrule = column -> up_and_horizontal [opt -> unicode_border_linestyle ];
3045
+ popt -> lrule [PRINT_RULE_BOTTOM ].rightvrule = border -> left_and_right ;
3046
+
3047
+ /* N/A */
3048
+ popt -> lrule [PRINT_RULE_DATA ].hrule = "" ;
3049
+ popt -> lrule [PRINT_RULE_DATA ].leftvrule = border -> vertical ;
3050
+ popt -> lrule [PRINT_RULE_DATA ].midvrule = column -> vertical ;
3051
+ popt -> lrule [PRINT_RULE_DATA ].rightvrule = border -> vertical ;
3052
+
3053
+ popt -> midvrule_nl = column -> vertical ;
3054
+ popt -> midvrule_wrap = column -> vertical ;
3055
+ popt -> midvrule_blank = column -> vertical ;
3056
+
3057
+ /* Same for all unicode today */
3058
+ popt -> header_nl_left = unicode_style .header_nl_left ;
3059
+ popt -> header_nl_right = unicode_style .header_nl_right ;
3060
+ popt -> nl_left = unicode_style .nl_left ;
3061
+ popt -> nl_right = unicode_style .nl_right ;
3062
+ popt -> wrap_left = unicode_style .wrap_left ;
3063
+ popt -> wrap_right = unicode_style .wrap_right ;
3064
+ popt -> wrap_right_border = unicode_style .wrap_right_border ;
3065
+
3066
+ return ;
3067
+ }
3068
+
2955
3069
/*
2956
3070
* Compute the byte distance to the end of the string or *target_width
2957
3071
* display character positions, whichever comes first. Update *target_width
0 commit comments