diff --git a/src/screen.c b/src/screen.c
index fd7a043..a375913 100644
a
|
b
|
static struct { |
427 | 427 | const char *title; |
428 | 428 | int use_in_gui; |
429 | 429 | const char *(*string_fn)(file_entry *, int); |
430 | | sortfn *sort_routine; /* This field is currently unused. */ |
| 430 | sortfn *sort_routine; /* used by mouse_sort_col() */ |
431 | 431 | } formats [] = { |
432 | 432 | { "name", 12, 1, J_LEFT_FIT, N_("Name"), 1, string_file_name, (sortfn *) sort_name }, |
433 | 433 | { "size", 7, 0, J_RIGHT, N_("Size"), 1, string_file_size, (sortfn *) sort_size }, |
… |
… |
show_dir (WPanel *panel) |
826 | 826 | addstr (">"); |
827 | 827 | widget_move (&panel->widget, 0, panel->widget.cols - 3); |
828 | 828 | addstr ("v"); |
| 829 | widget_move (&panel->widget, 0, panel->widget.cols - 4); |
| 830 | addstr ("."); |
829 | 831 | |
830 | 832 | if (!show_mini_info) { |
831 | 833 | if (panel->marked == 0) { |
… |
… |
mark_if_marking (WPanel *panel, Gpm_Event *event) |
2480 | 2482 | return 0; |
2481 | 2483 | } |
2482 | 2484 | |
| 2485 | /* Determine which column was clicked, and sort the panel on |
| 2486 | * that column, or reverse sort on that column if already |
| 2487 | * sorted on that column. |
| 2488 | */ |
| 2489 | static void |
| 2490 | mouse_sort_col(Gpm_Event *event, WPanel *panel) |
| 2491 | { |
| 2492 | int x = event->x; |
| 2493 | int pos = 0; |
| 2494 | int found = 0; |
| 2495 | const char *name; |
| 2496 | sortfn *col_sort_type = NULL; |
| 2497 | format_e *format = panel->format; |
| 2498 | while (format) { |
| 2499 | pos += format->field_len; |
| 2500 | if ( x < pos + 1) { |
| 2501 | /* found column */ |
| 2502 | name = format->title; |
| 2503 | found = 1; |
| 2504 | break; |
| 2505 | } |
| 2506 | format = format->next; |
| 2507 | } |
| 2508 | if (found) { |
| 2509 | int i; |
| 2510 | for (i=0; i < ELEMENTS(formats); i++) { |
| 2511 | if ( !strcmp(name,formats[i].title) && formats[i].sort_routine ) { |
| 2512 | col_sort_type = formats[i].sort_routine; |
| 2513 | break; |
| 2514 | } |
| 2515 | } |
| 2516 | if (col_sort_type) { |
| 2517 | if (panel->sort_type == col_sort_type) { |
| 2518 | /* reverse the sort if clicked column is already the sorted column */ |
| 2519 | panel->reverse = panel->reverse ? 0 : 1; |
| 2520 | } |
| 2521 | else { |
| 2522 | panel->reverse = 0; /* new sort is forced to be ascending */ |
| 2523 | } |
| 2524 | panel_set_sort_order(panel, col_sort_type); |
| 2525 | } |
| 2526 | } |
| 2527 | } |
| 2528 | |
2483 | 2529 | /* |
2484 | 2530 | * Mouse callback of the panel minus repainting. |
2485 | 2531 | * If the event is redirected to the menu, *redir is set to 1. |
… |
… |
do_panel_event (Gpm_Event *event, WPanel *panel, int *redir) |
2521 | 2567 | return MOU_NORMAL; |
2522 | 2568 | } |
2523 | 2569 | |
| 2570 | /* "." button show/hide hidden files */ |
| 2571 | if (event->type & GPM_DOWN && event->x == panel->widget.cols - 3 |
| 2572 | && event->y == 1) { |
| 2573 | toggle_show_hidden(); |
| 2574 | return MOU_NORMAL; |
| 2575 | } |
| 2576 | |
| 2577 | /* sort on clicked column */ |
| 2578 | if (event->type & GPM_DOWN && event->y == 2) { |
| 2579 | mouse_sort_col(event,panel); |
| 2580 | } |
| 2581 | |
2524 | 2582 | /* rest of the upper frame, the menu is invisible - call menu */ |
2525 | 2583 | if (event->type & GPM_DOWN && event->y == 1 && !menubar_visible) { |
2526 | 2584 | *redir = 1; |