@@ -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,14 +1581,22 @@ 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
- char * str ;
1584
+ char str [BUF_TINY ];
1585
1585
1586
- str = g_strdup_printf ("%s%s" , sort_sign , Q_ (panel -> sort_field -> hotkey ));
1586
+ if (panel -> sort_info .reverse )
1587
+ {
1588
+ g_snprintf (str , sizeof (str ), "%s%s" , panel_sort_up_char ,
1589
+ Q_ (panel -> sort_field -> hotkey ));
1590
+ panel_sort_up_indicator_width = str_term_width1 (str );
1591
+ }
1592
+ else
1593
+ {
1594
+ g_snprintf (str , sizeof (str ), "%s%s" , panel_sort_down_char ,
1595
+ Q_ (panel -> sort_field -> hotkey ));
1596
+ panel_sort_down_indicator_width = str_term_width1 (str );
1597
+ }
1587
1598
widget_gotoyx (panel , 1 , 1 );
1588
1599
tty_print_string (str );
1589
- g_free (str );
1590
1600
}
1591
1601
}
1592
1602
@@ -4000,6 +4010,17 @@ mouse_sort_col (WPanel *panel, int x)
4000
4010
const char * lc_sort_name = NULL ;
4001
4011
panel_field_t * col_sort_format = NULL ;
4002
4012
4013
+ const int sort_indicator_width =
4014
+ panel -> sort_info .reverse ? panel_sort_up_indicator_width : panel_sort_down_indicator_width ;
4015
+
4016
+ // Clicking the sort order indicator itself should reverse the current sort order
4017
+ if (x >= 2 && x < 2 + sort_indicator_width )
4018
+ {
4019
+ panel -> sort_info .reverse = !panel -> sort_info .reverse ;
4020
+ panel_set_sort_order (panel , panel -> sort_field );
4021
+ return ;
4022
+ }
4023
+
4003
4024
for (format = panel -> format ; format != NULL ; format = g_slist_next (format ))
4004
4025
{
4005
4026
format_item_t * fi = (format_item_t * ) format -> data ;
0 commit comments