Panelize and sort - some fixes



Hello!

I have fixed sorting of the entries in the panelize mode (both after "find 
file" and "external panelize").  Now you don't have to reselect "Sort 
Order" in the menu to "actualize" the desired order - the entries will be 
sorted from the beginning.

I also have fixed a bug that caused incorrect sorting on panels without
"..", which happens in the panelize mode.  The first entry was excluded
from sort, regardless of whether it's ".." or not.  Now it's sorted 
together with other entries.

        * dir.c (do_sort): Correctly handle the case when there is no
        ".." entry (i.e. panelized mode).

        * panelize.c (do_external_panelize): Re-sort the panel according
        to the current settings.

        * find.c (do_find): Re-sort the panel according to the current
        settings when doing panelizing.

---------------------------------
--- dir.c
+++ dir.c
@@ -316,10 +316,12 @@ void
 do_sort (dir_list *list, sortfn *sort, int top, int reverse_f, int case_sensitive_f)
 {
     int i;
+    int dot_dot_found = 0;
     file_entry tmp_fe;
 
     for (i = 0; i < top + 1; i++) {             /* put ".." first in list */
 	if (!strcmp (list->list [i].fname, "..")) {
+	    dot_dot_found = 1;
             if (i > 0) {                        /* swap [i] and [0] */
                 memcpy (&tmp_fe, &(list->list [0]), sizeof (file_entry));
                 memcpy (&(list->list [0]), &(list->list [i]), sizeof (file_entry));
@@ -331,7 +333,8 @@ do_sort (dir_list *list, sortfn *sort, i
 
     reverse = reverse_f ? -1 : 1;
     case_sensitive = case_sensitive_f;
-    qsort (&(list->list) [1], top, sizeof (file_entry), sort);
+    qsort (&(list->list) [dot_dot_found],
+	   top + 1 - dot_dot_found, sizeof (file_entry), sort);
 }
 
 void
--- find.c
+++ find.c
@@ -993,6 +993,7 @@ do_find (void)
 	if (v == B_PANELIZE){
 	    if (dir_and_file_set){
 	        try_to_select (cpanel, NULL);
+		panel_re_sort (cpanel);
 	        paint_panel (cpanel);
 	    }
 	    break;
--- panelize.c
+++ panelize.c
@@ -448,5 +448,6 @@ void do_external_panelize (char *command
 	message (0, _("External panelize"), _("Pipe close failed"));
     close_error_pipe (0, 0);
     try_to_select (cpanel, NULL);
+    panel_re_sort (cpanel);
     paint_panel (cpanel);
 }
---------------------------------

-- 
Regards,
Pavel Roskin




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]