@@ -55,7 +55,7 @@ set_view_attr(struct view *view, enum line_type type)
55
55
56
56
static bool
57
57
draw_chars (struct view * view , enum line_type type , const char * string , int length ,
58
- int max_width , bool use_tilde )
58
+ int max_width , bool use_tilde , int tab_size )
59
59
{
60
60
int len = 0 ;
61
61
int col = 0 ;
@@ -67,6 +67,8 @@ draw_chars(struct view *view, enum line_type type, const char *string, int lengt
67
67
68
68
if (length == -1 )
69
69
length = strlen (string );
70
+ if (!tab_size )
71
+ tab_size = opt_tab_size ;
70
72
71
73
if (opt_iconv_out != ICONV_NONE ) {
72
74
string = encoding_iconv (opt_iconv_out , string , length );
@@ -75,7 +77,7 @@ draw_chars(struct view *view, enum line_type type, const char *string, int lengt
75
77
length = strlen (string );
76
78
}
77
79
78
- len = utf8_length (& string , length , skip , & col , max_width , & trimmed , use_tilde , opt_tab_size );
80
+ len = utf8_length (& string , length , skip , & col , max_width , & trimmed , use_tilde , tab_size );
79
81
80
82
set_view_attr (view , type );
81
83
if (len > 0 )
@@ -101,7 +103,7 @@ draw_space(struct view *view, enum line_type type, int max, int spaces)
101
103
while (spaces > 0 ) {
102
104
int len = MIN (spaces , sizeof (space ) - 1 );
103
105
104
- if (draw_chars (view , type , space , -1 , len , false))
106
+ if (draw_chars (view , type , space , -1 , len , false, 0 ))
105
107
return true;
106
108
spaces -= len ;
107
109
}
@@ -110,18 +112,18 @@ draw_space(struct view *view, enum line_type type, int max, int spaces)
110
112
}
111
113
112
114
static bool
113
- draw_text_expanded (struct view * view , enum line_type type , const char * string , int length , int max_width , bool use_tilde )
115
+ draw_text_expanded (struct view * view , enum line_type type , const char * string , int length , int max_width , bool use_tilde , int tab_size )
114
116
{
115
117
static char text [SIZEOF_STR ];
116
118
117
119
if (length == -1 )
118
120
length = strlen (string );
119
121
120
122
do {
121
- size_t pos = string_expand (text , sizeof (text ), string , length , opt_tab_size );
123
+ size_t pos = string_expand (text , sizeof (text ), string , length , tab_size );
122
124
size_t col = view -> col ;
123
125
124
- if (draw_chars (view , type , text , -1 , max_width , use_tilde ))
126
+ if (draw_chars (view , type , text , -1 , max_width , use_tilde , tab_size ))
125
127
return true;
126
128
string += pos ;
127
129
length -= pos ;
@@ -132,15 +134,15 @@ draw_text_expanded(struct view *view, enum line_type type, const char *string, i
132
134
}
133
135
134
136
static inline bool
135
- draw_textn (struct view * view , enum line_type type , const char * string , int length )
137
+ draw_textn (struct view * view , enum line_type type , const char * string , int length , int tab_size )
136
138
{
137
- return draw_text_expanded (view , type , string , length , VIEW_MAX_LEN (view ), false);
139
+ return draw_text_expanded (view , type , string , length , VIEW_MAX_LEN (view ), false, tab_size );
138
140
}
139
141
140
142
bool
141
- draw_text (struct view * view , enum line_type type , const char * string )
143
+ draw_text (struct view * view , enum line_type type , const char * string , int tab_size )
142
144
{
143
- return draw_textn (view , type , string , -1 );
145
+ return draw_textn (view , type , string , -1 , tab_size );
144
146
}
145
147
146
148
static bool
@@ -157,14 +159,14 @@ draw_text_overflow(struct view *view, const char *text, enum line_type type,
157
159
int trimmed = false;
158
160
size_t len = utf8_length (& tmp , -1 , 0 , & text_width , max , & trimmed , false, 1 );
159
161
160
- if (draw_text_expanded (view , type , text , -1 , text_width , max < overflow ))
162
+ if (draw_text_expanded (view , type , text , -1 , text_width , max < overflow , opt_tab_size ))
161
163
return true;
162
164
163
165
text += len ;
164
166
type = LINE_OVERFLOW ;
165
167
}
166
168
167
- if (* text && draw_text (view , type , text ))
169
+ if (* text && draw_text (view , type , text , 0 ))
168
170
return true;
169
171
170
172
return VIEW_MAX_LEN (view ) <= 0 ;
@@ -177,7 +179,7 @@ draw_formatted(struct view *view, enum line_type type, const char *format, ...)
177
179
int retval ;
178
180
179
181
FORMAT_BUFFER (text , sizeof (text ), format , retval , true );
180
- return retval >= 0 ? draw_text (view , type , text ) : VIEW_MAX_LEN (view ) <= 0 ;
182
+ return retval >= 0 ? draw_text (view , type , text , 0 ) : VIEW_MAX_LEN (view ) <= 0 ;
181
183
}
182
184
183
185
bool
@@ -227,7 +229,7 @@ draw_field(struct view *view, enum line_type type, const char *text, int width,
227
229
}
228
230
}
229
231
230
- return draw_chars (view , type , text , -1 , max - 1 , trim )
232
+ return draw_chars (view , type , text , -1 , max - 1 , trim , 0 )
231
233
|| draw_space (view , type , max - (view -> col - col ), max );
232
234
}
233
235
@@ -333,17 +335,17 @@ draw_lineno_custom(struct view *view, struct view_column *column, unsigned int l
333
335
text = number ;
334
336
}
335
337
if (text )
336
- draw_chars (view , LINE_LINE_NUMBER , text , -1 , max , true);
338
+ draw_chars (view , LINE_LINE_NUMBER , text , -1 , max , true, 0 );
337
339
else
338
340
draw_space (view , LINE_LINE_NUMBER , max , digits3 );
339
341
340
342
switch (opt_line_graphics ) {
341
343
case GRAPHIC_ASCII :
342
- return draw_chars (view , LINE_DEFAULT , "| " , -1 , 2 , false);
344
+ return draw_chars (view , LINE_DEFAULT , "| " , -1 , 2 , false, 0 );
343
345
case GRAPHIC_DEFAULT :
344
346
return draw_graphic (view , LINE_DEFAULT , & separator , 1 , true);
345
347
case GRAPHIC_UTF_8 :
346
- return draw_chars (view , LINE_DEFAULT , "│ " , -1 , 2 , false);
348
+ return draw_chars (view , LINE_DEFAULT , "│ " , -1 , 2 , false, 0 );
347
349
}
348
350
349
351
return false;
@@ -381,7 +383,7 @@ draw_refs(struct view *view, struct view_column *column, const struct ref *refs)
381
383
if (draw_formatted (view , type , "%s%s%s" , format -> start , ref -> name , format -> end ))
382
384
return true;
383
385
384
- if (draw_text (view , LINE_DEFAULT , " " ))
386
+ if (draw_text (view , LINE_DEFAULT , " " , 0 ))
385
387
return true;
386
388
}
387
389
@@ -415,15 +417,15 @@ draw_graph_utf8(void *view, const struct graph *graph, const struct graph_symbol
415
417
{
416
418
const char * chars = graph -> symbol_to_utf8 (symbol );
417
419
418
- return draw_text (view , get_graph_color (color_id ), chars + !!first );
420
+ return draw_text (view , get_graph_color (color_id ), chars + !!first , 0 );
419
421
}
420
422
421
423
static bool
422
424
draw_graph_ascii (void * view , const struct graph * graph , const struct graph_symbol * symbol , int color_id , bool first )
423
425
{
424
426
const char * chars = graph -> symbol_to_ascii (symbol );
425
427
426
- return draw_text (view , get_graph_color (color_id ), chars + !!first );
428
+ return draw_text (view , get_graph_color (color_id ), chars + !!first , 0 );
427
429
}
428
430
429
431
static bool
@@ -444,7 +446,7 @@ draw_graph(struct view *view, const struct graph *graph, const struct graph_canv
444
446
};
445
447
446
448
graph -> foreach_symbol (graph , canvas , fns [opt_line_graphics ], view );
447
- return draw_text (view , LINE_DEFAULT , " " );
449
+ return draw_text (view , LINE_DEFAULT , " " , 0 );
448
450
}
449
451
450
452
static bool
@@ -534,7 +536,7 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno)
534
536
continue ;
535
537
536
538
case VIEW_COLUMN_SECTION :
537
- if (draw_text (view , column -> opt .section .type , column -> opt .section .text ))
539
+ if (draw_text (view , column -> opt .section .type , column -> opt .section .text , 0 ))
538
540
return true;
539
541
continue ;
540
542
@@ -549,13 +551,13 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno)
549
551
const char * text = column_data .text ;
550
552
size_t indent = 0 ;
551
553
552
- if (line -> wrapped && draw_text (view , LINE_DELIMITER , "+" ))
554
+ if (line -> wrapped && draw_text (view , LINE_DELIMITER , "+" , 0 ))
553
555
return true;
554
556
555
557
if (line -> graph_indent ) {
556
558
indent = get_graph_indent (text );
557
559
558
- if (draw_text_expanded (view , LINE_DEFAULT , text , -1 , indent , false))
560
+ if (draw_text_expanded (view , LINE_DEFAULT , text , -1 , indent , false, opt_tab_size ))
559
561
return true;
560
562
text += indent ;
561
563
}
@@ -580,13 +582,13 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno)
580
582
indent = 0 ;
581
583
}
582
584
583
- if (draw_textn (view , cell -> type , text , length ))
585
+ if (draw_textn (view , cell -> type , text , length , opt_tab_size ))
584
586
return true;
585
587
586
588
text += length ;
587
589
}
588
590
589
- } else if (draw_text (view , type , text )) {
591
+ } else if (draw_text (view , type , text , opt_tab_size )) {
590
592
return true;
591
593
}
592
594
}
0 commit comments