mirror of
https://github.com/MidnightCommander/mc
synced 2025-02-22 10:14:14 +03:00
Added indicators for current sort type and sort direction.
Added parameters into skin-files for showing sort indicator. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
9766359a1b
commit
08e6e1caf4
@ -75,3 +75,7 @@
|
||||
|
||||
[viewer]
|
||||
viewunderline=brightred;blue
|
||||
|
||||
[widget-common]
|
||||
sort-sign-up = '
|
||||
sort-sign-down = ,
|
||||
|
@ -75,3 +75,7 @@
|
||||
|
||||
[viewer]
|
||||
viewunderline=brightred;blue
|
||||
|
||||
[widget-common]
|
||||
sort-sign-up = '
|
||||
sort-sign-down = ,
|
||||
|
@ -1719,6 +1719,8 @@ do_nc (void)
|
||||
midnight_colors[2] = mc_skin_color_get("dialog", "hotnormal");
|
||||
midnight_colors[3] = mc_skin_color_get("dialog", "hotfocus");
|
||||
|
||||
panel_init();
|
||||
|
||||
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback,
|
||||
"[main]", NULL, DLG_WANT_IDLE);
|
||||
|
||||
@ -1764,6 +1766,7 @@ do_nc (void)
|
||||
done_mc ();
|
||||
}
|
||||
destroy_dlg (midnight_dlg);
|
||||
panel_deinit();
|
||||
current_panel = 0;
|
||||
done_mc_profile ();
|
||||
}
|
||||
|
@ -154,4 +154,7 @@ const panel_field_t *panel_get_field_by_title_hotkey(const char *);
|
||||
gsize panel_get_num_of_user_possible_fields(void);
|
||||
const char **panel_get_user_possible_fields(gsize *);
|
||||
|
||||
void panel_init(void);
|
||||
void panel_deinit(void);
|
||||
|
||||
#endif
|
||||
|
73
src/screen.c
73
src/screen.c
@ -115,6 +115,9 @@ static void paint_frame (WPanel *panel);
|
||||
static const char *panel_format (WPanel *panel);
|
||||
static const char *mini_status_format (WPanel *panel);
|
||||
|
||||
static char *panel_sort_up_sign = NULL;
|
||||
static char *panel_sort_down_sign = NULL;
|
||||
|
||||
/* This macro extracts the number of available lines in a panel */
|
||||
#define llines(p) (p->widget.lines-3 - (show_mini_info ? 2 : 0))
|
||||
|
||||
@ -1308,11 +1311,43 @@ panel_reload (WPanel *panel)
|
||||
recalculate_panel_summary (panel);
|
||||
}
|
||||
|
||||
static void
|
||||
panel_paint_sort_info(WPanel *panel)
|
||||
{
|
||||
struct hotkey_t hk;
|
||||
const char *sort_sign = (panel->reverse) ? panel_sort_down_sign : panel_sort_up_sign;
|
||||
char *str, *hotkey;
|
||||
gsize len=6;
|
||||
|
||||
/* get hotkey from field description */
|
||||
hk = parse_hotkey (_(panel->current_sort_field->title_hotkey));
|
||||
if (hk.hotkey) {
|
||||
hotkey = g_strdup(hk.hotkey);
|
||||
} else {
|
||||
/* if field don't have hotkey - use first char of field name */
|
||||
hotkey = g_strdup(panel->current_sort_field->id);
|
||||
hotkey[1] = '\0';
|
||||
}
|
||||
release_hotkey (hk);
|
||||
|
||||
/* transform to lower case */
|
||||
str = hotkey;
|
||||
str_tolower (hotkey, &str, &len);
|
||||
|
||||
str = g_strdup_printf("%s%s",sort_sign, hotkey);
|
||||
g_free(hotkey);
|
||||
|
||||
widget_move (&panel->widget, 1, 1);
|
||||
tty_print_string (str);
|
||||
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
static void
|
||||
paint_frame (WPanel *panel)
|
||||
{
|
||||
int side, width;
|
||||
char *txt = NULL;
|
||||
GString *format_txt;
|
||||
|
||||
if (!panel->split)
|
||||
adjust_top_file (panel);
|
||||
@ -1334,18 +1369,24 @@ paint_frame (WPanel *panel)
|
||||
else
|
||||
width = panel->widget.cols - 2;
|
||||
|
||||
format_txt = g_string_new("");
|
||||
for (format = panel->format; format; format = format->next){
|
||||
if (format->string_fn){
|
||||
if (panel->filter && !strcmp (format->id, "name")) {
|
||||
txt = g_strdup_printf ("%s [%s]", format->title, panel->filter);
|
||||
} else {
|
||||
txt = g_strdup (format->title);
|
||||
g_string_set_size(format_txt, 0);
|
||||
|
||||
if (panel->list_type == list_long && strcmp (format->id, panel->current_sort_field->id) == 0)
|
||||
g_string_append (format_txt, (panel->reverse) ? panel_sort_down_sign : panel_sort_up_sign);
|
||||
|
||||
g_string_append (format_txt, format->title);
|
||||
if (strcmp (format->id, "name") == 0 && panel->filter && *panel->filter) {
|
||||
g_string_append (format_txt, " [");
|
||||
g_string_append (format_txt, panel->filter);
|
||||
g_string_append (format_txt, "]");
|
||||
}
|
||||
|
||||
tty_setcolor (MARKED_COLOR);
|
||||
tty_print_string (str_fit_to_term (format->title, format->field_len,
|
||||
tty_print_string (str_fit_to_term (format_txt->str, format->field_len,
|
||||
J_CENTER_LEFT));
|
||||
g_free(txt);
|
||||
width -= format->field_len;
|
||||
} else {
|
||||
tty_setcolor (NORMAL_COLOR);
|
||||
@ -1353,10 +1394,14 @@ paint_frame (WPanel *panel)
|
||||
width--;
|
||||
}
|
||||
}
|
||||
g_string_free(format_txt, TRUE);
|
||||
|
||||
if (width > 0)
|
||||
tty_draw_hline (-1, -1, ' ', width);
|
||||
}
|
||||
|
||||
if (panel->list_type != list_long)
|
||||
panel_paint_sort_info(panel);
|
||||
}
|
||||
|
||||
static const char *
|
||||
@ -3323,3 +3368,17 @@ panel_get_user_possible_fields(gsize *array_size)
|
||||
ret[index++] = g_strdup(_(panel_fields[i].title_hotkey));
|
||||
return (const char**) ret;
|
||||
}
|
||||
|
||||
void
|
||||
panel_init(void)
|
||||
{
|
||||
panel_sort_up_sign = mc_config_get_string(mc_skin__default.config,"widget-common","sort-sign-up","'");
|
||||
panel_sort_down_sign = mc_config_get_string(mc_skin__default.config,"widget-common","sort-sign-down",",");
|
||||
}
|
||||
|
||||
void
|
||||
panel_deinit(void)
|
||||
{
|
||||
g_free(panel_sort_up_sign);
|
||||
g_free(panel_sort_down_sign);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user