| File src/ui/fileview.c changed (mode: 100644) (index 38f776ead..84badae62) |
| ... |
... |
static void draw_line_number(const column_data_t *cdt, int column); |
| 126 |
126 |
static int is_primary_colored_column_id(int id); |
static int is_primary_colored_column_id(int id); |
| 127 |
127 |
static int is_primary_column_id(int id); |
static int is_primary_column_id(int id); |
| 128 |
128 |
static cchar_t prepare_col_color(const view_t *view, int is_primary_colored, |
static cchar_t prepare_col_color(const view_t *view, int is_primary_colored, |
| 129 |
|
int line_nr, const column_data_t *cdt, int real_id); |
|
|
129 |
|
int line_nr, const column_data_t *cdt, int real_id, int filling); |
| 130 |
130 |
static void mix_in_common_colors(col_attr_t *col, const view_t *view, |
static void mix_in_common_colors(col_attr_t *col, const view_t *view, |
| 131 |
131 |
dir_entry_t *entry, int line_color); |
dir_entry_t *entry, int line_color); |
| 132 |
132 |
static void mix_in_file_hi(const view_t *view, dir_entry_t *entry, int type_hi, |
static void mix_in_file_hi(const view_t *view, dir_entry_t *entry, int type_hi, |
| |
| ... |
... |
column_line_print(const char buf[], int offset, AlignType align, |
| 1182 |
1182 |
|
|
| 1183 |
1183 |
const int numbers_visible = (offset == 0 && cdt->number_width > 0); |
const int numbers_visible = (offset == 0 && cdt->number_width > 0); |
| 1184 |
1184 |
const int padding = (cfg.extra_padding != 0); |
const int padding = (cfg.extra_padding != 0); |
|
1185 |
|
const int filling = (info->id == FILL_COLUMN_ID); |
| 1185 |
1186 |
|
|
| 1186 |
1187 |
const int is_primary_colored = is_primary_colored_column_id(info->id); |
const int is_primary_colored = is_primary_colored_column_id(info->id); |
| 1187 |
1188 |
const cchar_t line_attrs = |
const cchar_t line_attrs = |
| 1188 |
|
prepare_col_color(view, is_primary_colored, 0, cdt, info->real_id); |
|
|
1189 |
|
prepare_col_color(view, is_primary_colored, 0, cdt, info->real_id, filling); |
| 1189 |
1190 |
|
|
| 1190 |
1191 |
/* Non-empty prefix contains tree pseudo-graphics. */ |
/* Non-empty prefix contains tree pseudo-graphics. */ |
| 1191 |
1192 |
const int is_treeable_column = is_primary_column_id(info->id); |
const int is_treeable_column = is_primary_column_id(info->id); |
| |
| ... |
... |
column_line_print(const char buf[], int offset, AlignType align, |
| 1222 |
1223 |
buf += extra_prefix; |
buf += extra_prefix; |
| 1223 |
1224 |
|
|
| 1224 |
1225 |
checked_wmove(view->win, cdt->current_line, final_offset - extra_prefix); |
checked_wmove(view->win, cdt->current_line, final_offset - extra_prefix); |
| 1225 |
|
cchar_t cch = prepare_col_color(view, 0, 0, cdt, /*real_id=*/-1); |
|
|
1226 |
|
cchar_t cch = |
|
1227 |
|
prepare_col_color(view, 0, 0, cdt, /*real_id=*/-1, /*filling=*/0); |
| 1226 |
1228 |
wprinta(view->win, print_buf, &cch, 0); |
wprinta(view->win, print_buf, &cch, 0); |
| 1227 |
1229 |
} |
} |
| 1228 |
1230 |
|
|
| |
| ... |
... |
column_line_print(const char buf[], int offset, AlignType align, |
| 1248 |
1250 |
/* Draw match highlighting if there is any. */ |
/* Draw match highlighting if there is any. */ |
| 1249 |
1251 |
int match_from = (cdt->custom_match ? cdt->match_from : info->match_from); |
int match_from = (cdt->custom_match ? cdt->match_from : info->match_from); |
| 1250 |
1252 |
int match_to = (cdt->custom_match ? cdt->match_to : info->match_to); |
int match_to = (cdt->custom_match ? cdt->match_to : info->match_to); |
| 1251 |
|
if(info->id != FILL_COLUMN_ID && match_from != match_to) |
|
|
1253 |
|
if(!filling && match_from != match_to) |
| 1252 |
1254 |
{ |
{ |
| 1253 |
1255 |
/* Calculate number of screen characters before the match. */ |
/* Calculate number of screen characters before the match. */ |
| 1254 |
1256 |
size_t match_start_col = utf8_nstrsw(print_buf, match_from); |
size_t match_start_col = utf8_nstrsw(print_buf, match_from); |
| |
| ... |
... |
column_line_print(const char buf[], int offset, AlignType align, |
| 1262 |
1264 |
/* Use a given prefix value at most once. */ |
/* Use a given prefix value at most once. */ |
| 1263 |
1265 |
*cdt->prefix_len = 0; |
*cdt->prefix_len = 0; |
| 1264 |
1266 |
|
|
| 1265 |
|
if(info->id != FILL_COLUMN_ID) |
|
|
1267 |
|
if(!filling) |
| 1266 |
1268 |
{ |
{ |
| 1267 |
|
/* Any match for this column has already been consumed, so reset it in |
|
| 1268 |
|
* preparation of processing the next column. */ |
|
|
1269 |
|
/* Custom match and color for this cell have already been consumed, so reset |
|
1270 |
|
* them in preparation for processing the next column. */ |
| 1269 |
1271 |
cdt->custom_match = 0; |
cdt->custom_match = 0; |
|
1272 |
|
cdt->custom_color = 0; |
| 1270 |
1273 |
} |
} |
| 1271 |
1274 |
} |
} |
| 1272 |
1275 |
|
|
| |
| ... |
... |
draw_line_number(const column_data_t *cdt, int column) |
| 1289 |
1292 |
num); |
num); |
| 1290 |
1293 |
|
|
| 1291 |
1294 |
checked_wmove(view->win, cdt->current_line, column); |
checked_wmove(view->win, cdt->current_line, column); |
| 1292 |
|
cchar_t cch = prepare_col_color(view, 0, 1, cdt, /*real_id=*/-1); |
|
|
1295 |
|
cchar_t cch = |
|
1296 |
|
prepare_col_color(view, 0, 1, cdt, /*real_id=*/-1, /*filling=*/0); |
| 1293 |
1297 |
wprinta(view->win, num_str, &cch, 0); |
wprinta(view->win, num_str, &cch, 0); |
| 1294 |
1298 |
} |
} |
| 1295 |
1299 |
|
|
| |
| ... |
... |
is_primary_column_id(int id) |
| 1362 |
1366 |
* used for drawing on a window. */ |
* used for drawing on a window. */ |
| 1363 |
1367 |
static cchar_t |
static cchar_t |
| 1364 |
1368 |
prepare_col_color(const view_t *view, int is_primary_colored, int line_nr, |
prepare_col_color(const view_t *view, int is_primary_colored, int line_nr, |
| 1365 |
|
const column_data_t *cdt, int real_id) |
|
|
1369 |
|
const column_data_t *cdt, int real_id, int filling) |
| 1366 |
1370 |
{ |
{ |
| 1367 |
1371 |
const col_scheme_t *const cs = ui_view_get_cs(view); |
const col_scheme_t *const cs = ui_view_get_cs(view); |
| 1368 |
1372 |
col_attr_t col = ui_get_win_color(view, cs); |
col_attr_t col = ui_get_win_color(view, cs); |
| |
| ... |
... |
prepare_col_color(const view_t *view, int is_primary_colored, int line_nr, |
| 1395 |
1399 |
const int line_color = with_line_hi ? cdt->line_hi_group : -1; |
const int line_color = with_line_hi ? cdt->line_hi_group : -1; |
| 1396 |
1400 |
mix_in_common_colors(&col, view, cdt->entry, line_color); |
mix_in_common_colors(&col, view, cdt->entry, line_color); |
| 1397 |
1401 |
|
|
|
1402 |
|
if(!filling && cdt->custom_color) |
|
1403 |
|
{ |
|
1404 |
|
cs_mix_colors(&col, &cdt->custom_hi); |
|
1405 |
|
} |
|
1406 |
|
|
| 1398 |
1407 |
if(is_current) |
if(is_current) |
| 1399 |
1408 |
{ |
{ |
| 1400 |
1409 |
int color = (view == curr_view || !cdt->is_main) ? CURR_LINE_COLOR |
int color = (view == curr_view || !cdt->is_main) ? CURR_LINE_COLOR |
| File tests/lua/api_viewcolumns.c changed (mode: 100644) (index 7d81a8bb1..6a362ff26) |
| ... |
... |
TEST(columns_are_used) |
| 131 |
131 |
curr_stats.vlua = NULL; |
curr_stats.vlua = NULL; |
| 132 |
132 |
} |
} |
| 133 |
133 |
|
|
|
134 |
|
TEST(columns_and_colors) |
|
135 |
|
{ |
|
136 |
|
opt_handlers_setup(); |
|
137 |
|
lwin.columns = columns_create(); |
|
138 |
|
curr_stats.vlua = vlua; |
|
139 |
|
|
|
140 |
|
GLUA_EQ(vlua, "", |
|
141 |
|
"function bad_type()" |
|
142 |
|
" return { text = 'table', color = { } }" |
|
143 |
|
"end"); |
|
144 |
|
GLUA_EQ(vlua, "", |
|
145 |
|
"function bad_user_data()" |
|
146 |
|
" return { text = 'udata', color = vifm.currview() }" |
|
147 |
|
"end"); |
|
148 |
|
GLUA_EQ(vlua, "", |
|
149 |
|
"function good(info)" |
|
150 |
|
" return { text = info.entry.name, color = vifm.color.new {} }" |
|
151 |
|
"end"); |
|
152 |
|
GLUA_EQ(vlua, "true", |
|
153 |
|
"print(vifm.addcolumntype { name = 'BadType', handler = bad_type })"); |
|
154 |
|
GLUA_EQ(vlua, "true", |
|
155 |
|
"print(vifm.addcolumntype { name = 'BadUserData'," |
|
156 |
|
" handler = bad_user_data })"); |
|
157 |
|
GLUA_EQ(vlua, "true", |
|
158 |
|
"print(vifm.addcolumntype { name = 'Good', handler = good })"); |
|
159 |
|
|
|
160 |
|
process_set_args("viewcolumns=10{BadType},10{BadUserData},10{Good}", 0, 1); |
|
161 |
|
|
|
162 |
|
dir_entry_t entry = { .name = "name", .origin = "origin" }; |
|
163 |
|
column_data_t cdt = { .view = &lwin, .entry = &entry }; |
|
164 |
|
|
|
165 |
|
columns_set_line_print_func(&column_line_print); |
|
166 |
|
columns_format_line(lwin.columns, &cdt, MAX_WIDTH); |
|
167 |
|
assert_string_equal(" table udata name ", print_buffer); |
|
168 |
|
|
|
169 |
|
opt_handlers_teardown(); |
|
170 |
|
curr_stats.vlua = NULL; |
|
171 |
|
} |
|
172 |
|
|
| 134 |
173 |
TEST(symlinks, IF(not_windows)) |
TEST(symlinks, IF(not_windows)) |
| 135 |
174 |
{ |
{ |
| 136 |
175 |
assert_success(make_symlink("something", SANDBOX_PATH "/symlink")); |
assert_success(make_symlink("something", SANDBOX_PATH "/symlink")); |