@@ -368,6 +368,8 @@ static panel_field_t panel_fields[] = {
368
368
369
369
static char * panel_sort_up_char = NULL ;
370
370
static char * panel_sort_down_char = NULL ;
371
+ static int panel_sort_up_indicator_width = 0 ;
372
+ static int panel_sort_down_indicator_width = 0 ;
371
373
372
374
static char * panel_hiddenfiles_show_char = NULL ;
373
375
static char * panel_hiddenfiles_hide_char = NULL ;
@@ -1579,11 +1581,18 @@ panel_paint_sort_info (const WPanel *panel)
1579
1581
{
1580
1582
if (* panel -> sort_field -> hotkey != '\0' )
1581
1583
{
1582
- const char * sort_sign =
1583
- panel -> sort_info .reverse ? panel_sort_up_char : panel_sort_down_char ;
1584
1584
char * str ;
1585
1585
1586
- str = g_strdup_printf ("%s%s" , sort_sign , Q_ (panel -> sort_field -> hotkey ));
1586
+ if (panel -> sort_info .reverse )
1587
+ {
1588
+ str = g_strdup_printf ("%s%s" , panel_sort_up_char , Q_ (panel -> sort_field -> hotkey ));
1589
+ panel_sort_up_indicator_width = str_term_width1 (str );
1590
+ }
1591
+ else
1592
+ {
1593
+ str = g_strdup_printf ("%s%s" , panel_sort_down_char , Q_ (panel -> sort_field -> hotkey ));
1594
+ panel_sort_down_indicator_width = str_term_width1 (str );
1595
+ }
1587
1596
widget_gotoyx (panel , 1 , 1 );
1588
1597
tty_print_string (str );
1589
1598
g_free (str );
@@ -4000,6 +4009,17 @@ mouse_sort_col (WPanel *panel, int x)
4000
4009
const char * lc_sort_name = NULL ;
4001
4010
panel_field_t * col_sort_format = NULL ;
4002
4011
4012
+ const int sort_indicator_width =
4013
+ panel -> sort_info .reverse ? panel_sort_up_indicator_width : panel_sort_down_indicator_width ;
4014
+
4015
+ // Clicking the sort order indicator itself should reverse the current sort order
4016
+ if (x >= 2 && x < 2 + sort_indicator_width )
4017
+ {
4018
+ panel -> sort_info .reverse = !panel -> sort_info .reverse ;
4019
+ panel_set_sort_order (panel , panel -> sort_field );
4020
+ return ;
4021
+ }
4022
+
4003
4023
for (format = panel -> format ; format != NULL ; format = g_slist_next (format ))
4004
4024
{
4005
4025
format_item_t * fi = (format_item_t * ) format -> data ;
0 commit comments