Proposed patch: Alt-O on files to select current directory



Hello, Miguel and everybody!

I'm sorry, I was too busy to do anything about the issue with Alt-O,
even to argue about it.  But I'd like to fix the current code a bit to
make it less annoying to me.

Alt-O on a file makes the inactive panel change to the parent directory
of the one in the active panel.  It would be great to move selection on
the inactive panel to select the entry corresponding to the current
directory on the active panel.

This way, I could use Alt-O, Tab, Enter to emulate the behavior of Alt-O
in mc 4.6.0.  Also, I could press Tab and use Alt-O or cursor keys to
navigate directories with similar names.

Miguel, since you wanted the old behavior, I'd like you to see the patch
so you don't complain again that I broke something you liked.

ChangeLog:

	* screen.c (chdir_other_panel): When used on a file
	entry, move selection on the inactive panel to select
	the entry for the current directory on the active panel.

-- 
Regards,
Pavel Roskin

--- src/screen.c
+++ src/screen.c
@@ -2017,18 +2017,22 @@ static void
 chdir_other_panel (WPanel *panel)
 {
     char *new_dir;
+    char *sel_entry = NULL;
     
     if (get_other_type () != view_listing) {
 	set_display_type (get_other_index (), view_listing);
     }
 
-    if (!S_ISDIR (panel->dir.list [panel->selected].st.st_mode))
+    if (!S_ISDIR (panel->dir.list [panel->selected].st.st_mode)) {
         new_dir = concat_dir_and_file (panel->cwd, "..");
-    else
+	sel_entry = strrchr(panel->cwd, PATH_SEP);
+    } else
         new_dir = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
 
     change_panel ();
     do_cd (new_dir, cd_exact);
+    if (sel_entry)
+	try_to_select (current_panel, sel_entry);
     change_panel ();
  
     move_down (panel);


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