--- git/mc.org/src/main.c	2009-07-19 11:25:40.000000000 +0200
+++ git/mc/src/main.c	2009-08-16 17:20:03.000000000 +0200
@@ -654,7 +654,9 @@
 int
 do_cd (const char *new_dir, enum cd_enum exact)
 {
-    return (do_panel_cd (current_panel, new_dir, exact));
+    int r = do_panel_cd (current_panel, new_dir, exact);
+    sync_other_panel_relative(current_panel);
+    return r;
 }
 
 void
--- git/mc.org/src/panel.h	2009-05-10 17:39:09.000000000 +0200
+++ git/mc/src/panel.h	2009-08-16 17:25:40.000000000 +0200
@@ -57,7 +57,9 @@
     int      exec_first;	/* Show executable top in list? */
     int      split;		/* Split panel to allow two columns */
     int      is_panelized;	/* Flag: special filelisting, can't reload */
+    int      is_locked; 	/* toggle if other dir should sync */
     int      frame_size;	/* half or full frame */
+    int      sort_index;    /* Current Sort Index */
     sortfn   *sort_type;	/* Sort type */
     char     *filter;		/* File name filter */
 
@@ -120,5 +122,6 @@
 void directory_history_next (WPanel *panel);
 void directory_history_prev (WPanel *panel);
 void directory_history_list (WPanel *panel);
+void sync_other_panel_relative(WPanel *panel);
 
 #endif
--- git/mc.org/src/screen.c	2009-05-10 17:39:09.000000000 +0200
+++ git/mc/src/screen.c	2009-08-16 17:32:43.000000000 +0200
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <unistd.h>
 
 #include "global.h"
@@ -49,6 +50,7 @@
 #include "profile.h"
 #include "execute.h"
 #include "widget.h"
+#include "command.h"    /* cmdline for backspace navigation */
 #include "menu.h"		/* menubar_visible */
 #include "main-widgets.h"
 #include "main.h"		/* the_menubar */
@@ -102,6 +104,10 @@
 /* The hook list for the select file function */
 Hook *select_file_hook = 0;
 
+/* the timer for the commandline focus */ 
+time_t cmdline_focus;  
+
+
 static cb_ret_t panel_callback (Widget *, widget_msg_t msg, int parm);
 static int panel_event (Gpm_Event *event, void *);
 static void paint_frame (WPanel *panel);
@@ -792,10 +798,67 @@
     }
 }
 
+/* draw the sort controls and return the remaining place */ 
+static void 
+update_sort_index (WPanel *panel)
+{ 
+    for( panel->sort_index=0; panel->sort_index<SORT_TYPES_TOTAL; panel->sort_index++)
+        if ( (sortfn *)sort_orders[panel->sort_index].sort_fn == (sortfn *)panel->sort_type )
+            break;
+}
+
+/* draw the sort controls and return the remaining place */ 
+static int 
+show_dir_sort (WPanel *panel, int offset)
+{ 
+    int i, numch; 
+    if (!panel->active) 
+	return offset; 
+    //sort_blanks 
+    attrset (NORMAL_COLOR); 
+    widget_move (&panel->widget, 0, panel->widget.cols - (offset)); 
+    addstr (" "); //before buttons
+    widget_move (&panel->widget, 0, panel->widget.cols - (offset+4)); 
+    addstr (" "); //hotlist 
+ 
+    // sort controls 
+    widget_move (&panel->widget, 0, panel->widget.cols - (offset+1)); 
+    addstr (">"); //next sort 
+    widget_move (&panel->widget, 0, panel->widget.cols - (offset+2)); 
+    addstr ("<"); //prev sort
+    widget_move (&panel->widget, 0, panel->widget.cols - (offset+3)); 
+    if(panel->reverse) 
+       addstr ("-"); //reversed sort 
+    else 
+       addstr ("+"); //no reversed sort 
+     
+    //sort order display 
+    update_sort_index(panel);
+    //get name length 
+    numch = 0; 
+    for(i=0;i<12&&sort_orders[panel->sort_index].sort_name[i]!=0;i++) 
+	numch++; 
+    offset=offset+4+numch; 
+    widget_move (&panel->widget, 0, panel->widget.cols - (offset)); 
+     
+    //output name to panel 
+    attrset (NORMAL_COLOR); 
+    for(i=0;i<numch;i++){ 
+	if(sort_orders[panel->sort_index].sort_name[i]!='&') 
+	    addch(sort_orders[panel->sort_index].sort_name[i]); 
+    } 
+    //calculate dir delta 
+    attrset (REVERSE_COLOR); 
+    return offset; 
+     
+} 
+
+
 static void
 show_dir (WPanel *panel)
 {
-    int len;
+    int  offset = 0; 
+    int  len = 0;     
 
     set_colors (panel);
     draw_double_box (panel->widget.parent,
@@ -812,11 +875,13 @@
 
     if (panel->active)
 	attrset (REVERSE_COLOR);
+	
+	offset = show_dir_sort(panel,4); //< "v" +1 
 
     widget_move (&panel->widget, 0, 3);
 
     addch (' ');
-    len = min (max (panel->widget.cols - 9, 0), panel->widget.cols); 
+    len = min (max (panel->widget.cols - (offset+4), 0), panel->widget.cols);
     addstr (str_term_trim (strip_home_and_password (panel->cwd), len));
     addch (' ');
 
@@ -826,6 +891,11 @@
     addstr (">");
     widget_move (&panel->widget, 0, panel->widget.cols - 3);
     addstr ("v");
+    if (panel->is_locked){
+      widget_move (&panel->widget, 0, panel->widget.cols - 4);
+      addstr ("=");
+    }
+    
 
     if (!show_mini_info) {
 	if (panel->marked == 0) {
@@ -1129,6 +1199,7 @@
     panel->searching = 0;
     panel->dirs_marked = 0;
     panel->is_panelized = 0;
+    panel->is_locked = 0;
     panel->format = 0;
     panel->status_format = 0;
     panel->format_modified = 1;
@@ -2151,6 +2222,65 @@
     return 1;
 }
 
+void
+sync_other_panel_relative(WPanel *panel)
+{
+    if(!panel->is_locked) return;
+
+    char *cwd = current_panel->cwd;
+    char *owd = other_panel->cwd;
+    char *rwd = NULL;
+    char *csel_entry = NULL,*osel_entry = NULL;
+    char *cending = NULL, *oending = NULL;
+    char *opath = NULL, *cpath = NULL;
+    int direction = 0;
+    int autounlock = 1; // read from config?
+    struct stat buf;
+    csel_entry = strrchr(cwd, PATH_SEP);
+    osel_entry = strrchr(owd, PATH_SEP);
+    cending = concat_dir_and_file (osel_entry, csel_entry + 1);
+    oending = concat_dir_and_file (csel_entry, osel_entry + 1);
+    cpath   = concat_dir_and_file (owd, csel_entry + 1);
+    opath   = concat_dir_and_file (cwd, osel_entry + 1);
+
+    if(strcmp(cwd+strlen(cwd)-strlen(cending), cending)==0)
+      direction=1;
+    if(strcmp(owd+strlen(owd)-strlen(oending), oending)==0)
+      direction=-1;
+
+    free(cending);
+    free(oending);
+
+    if(!direction && mc_stat(cpath, &buf)!=-1 && S_ISDIR(buf.st_mode) )
+      direction=1;
+
+    if(!direction && mc_stat(opath, &buf)!=-1 && S_ISDIR(buf.st_mode) )
+      direction=-1;
+
+    free(cpath);
+    free(opath);
+
+    if(direction <0)
+      rwd = concat_dir_and_file (owd, "..");
+    else
+      rwd = concat_dir_and_file (owd, csel_entry+1); //no double slash
+
+    if(autounlock && strcmp(cwd,rwd)==0){
+      free(rwd);
+      panel->is_locked = 0;
+      return;
+    }
+
+    change_panel ();
+    do_cd (rwd, cd_exact);
+    try_to_select (current_panel, selection (panel)->fname);
+    change_panel ();
+
+    free(rwd);
+
+
+}
+
 static int
 do_enter (WPanel *panel)
 {
@@ -2264,6 +2394,7 @@
 static void cmd_select(WPanel *wp) { (void) wp;select_cmd(); }
 static void cmd_unselect(WPanel *wp) { (void) wp;unselect_cmd(); }
 static void cmd_reverse_selection(WPanel *wp) { (void) wp;reverse_selection_cmd(); }
+static void toggle_panel_locked(WPanel *wp) { (void) wp;wp->is_locked = !wp->is_locked; other_panel->is_locked=0; /*if(wp->is_locked) sync_other_panel(wp);*/}
 
 static const panel_key_map panel_keymap [] = {
     { KEY_DOWN,   move_down },
@@ -2303,6 +2434,7 @@
     { ALT('i'),   sync_other_panel },
     { ALT('l'),   chdir_to_readlink },
     { ALT('H'),   directory_history_list },
+    { ALT('L'),   toggle_panel_locked },
     { KEY_F(13),  cmd_view_simple },
     { KEY_F(14),  cmd_edit_new },
     { KEY_F(15),  cmd_copy_local },
@@ -2352,8 +2484,29 @@
     if (key == KEY_RIGHT)
 	return move_right (panel, key);
 
+    if (key == KEY_BACKSPACE){ 
+       if(  (cmdline && cmdline->buffer && strlen(cmdline->buffer)) 
+          || panel->searching ){ 
+           cmdline_focus = time(NULL); 
+           if(panel->searching) { 
+               do_search (panel, key); 
+               return MSG_HANDLED; 
+           } 
+           return MSG_NOT_HANDLED; 
+       } 
+       if(cmdline_focus){ 
+           if(time(NULL) - cmdline_focus <= 1 ){ 
+               cmdline_focus = time(NULL); 
+               return MSG_NOT_HANDLED; 
+           } 
+           cmdline_focus = 0; 
+       } 
+       ctrl_prev_page (panel); 
+       return MSG_HANDLED;        
+    }  
+
     if (is_abort_char (key)) {
-	panel->searching = 0;
+    panel->searching = 0;
 	display_mini_info (panel);
 	return MSG_HANDLED;
     }
@@ -2521,6 +2674,34 @@
 	return MOU_NORMAL;
     }
 
+    /* "$" change positive*/ 
+    if (event->type & GPM_DOWN && event->x == panel->widget.cols - 4 
+	&& event->y == 1) { 
+	panel->sort_index++; 
+	if ( panel->sort_index>=SORT_TYPES_TOTAL  ) panel->sort_index = 0; 
+	sortfn *sort_order = (sortfn *) sort_orders[panel->sort_index].sort_fn; 
+	panel_set_sort_order (panel, sort_order); 
+	return MOU_NORMAL; 
+    } 
+
+    /* "$" change negative*/ 
+    if (event->type & GPM_DOWN && event->x == panel->widget.cols - 5 
+	&& event->y == 1) { 
+	panel->sort_index--; 
+	if ( panel->sort_index<0  ) panel->sort_index = SORT_TYPES_TOTAL-1; 
+	sortfn *sort_order = (sortfn *) sort_orders[panel->sort_index].sort_fn; 
+	panel_set_sort_order (panel, sort_order); 
+	return MOU_NORMAL; 
+    } 
+ 
+    /* "-+" sort reverse */ 
+    if (event->type & GPM_DOWN && event->x == panel->widget.cols - 6 
+	&& event->y == 1) { 
+	panel->reverse = !panel->reverse; 
+	panel_re_sort (panel); 
+	return MOU_NORMAL; 
+    } 
+
     /* rest of the upper frame, the menu is invisible - call menu */
     if (event->type & GPM_DOWN && event->y == 1 && !menubar_visible) {
 	*redir = 1;
