AMC merge patch #1



Hi,

I've started with merging most important features from AMC into 4.6.0.
I was a bit surprised how many of AMC features are already included in 4.6,
but don't worry, enough left out so here comes it.
Expect some more patches soon, one for my extfs changes, and one for FTP.
The patch is available here, but also included in thsi mail for easier
discussion:
	http://mplayerhq.hu/~arpi/amc/amc-1.[diff|txt]


Changes included in patch: (all merged in from AMC version mc-4.1.35-A12pre)

- mcedit: CTRL+S toggles syntax hiliting [CK_Toggle_Syntax]
- file select/unselect dialog: ['fileflag' in src/cmd.c]
  *   ->  select all matching files (current mc behaviour)
  /*  ->  select all matching dirs & files (amc behaviour)
  */  ->  select matching dirs only (current mc behaviour)
- "cd dirname\ with\ space" now works in commandline [src/command.c]
  (think 'cd ctrl+enter' on dir)
- "cd Foo*" now works (allow wildcards in "cd" command) [src/command.c]
- new option: [src/file.c, src/setup.c]
  /* Beep never (0), after 2+ file ops (1), or after any file ops (2) */
  int op_beep_when_finished = 0;
- ESC+SHIFT+1..9,0 keys mapped to F11..F19,F20 (english keymap only) [src/key.c]
- new options: [src/main.c, src/setup.c]
  /* Command prompt type: 0=no_prompt  1=CWD  2=get_from_subshell */
  int command_prompt_type = 2;
  /* Allow subshell to change MC's CWD */
  int allow_subshell_chdir = 1;
- ALT+\\ mapped to quick_chdir_command(aka. dir hotlist) instead of Unselect
- new option: [src/subshell.c, src/setup.c]
  /* Don't allow ctrl+o (panels ON) if shell already dunning a command: */
  int subshell_blocks_ctrlo=1;


diff -Naur mc-2003-01-24-21.orig/edit/edit.c mc-2003-01-24-21.patched/edit/edit.c
--- mc-2003-01-24-21.orig/edit/edit.c	Mon Dec 23 11:19:07 2002
+++ mc-2003-01-24-21.patched/edit/edit.c	Sat Jan 25 14:28:53 2003
@@ -2485,6 +2485,11 @@
 	edit_insert_file_cmd (edit);
 	break;
 
+    case CK_Toggle_Syntax:
+	option_syntax_highlighting^=1;
+	edit->force |= REDRAW_PAGE;
+	break;
+
     case CK_Find:
 	edit_search_cmd (edit, 0);
 	break;
diff -Naur mc-2003-01-24-21.orig/edit/editcmddef.h mc-2003-01-24-21.patched/edit/editcmddef.h
--- mc-2003-01-24-21.orig/edit/editcmddef.h	Tue Jan 22 06:07:21 2002
+++ mc-2003-01-24-21.patched/edit/editcmddef.h	Sat Jan 25 14:32:07 2003
@@ -104,6 +104,8 @@
 #define CK_Check_Save_And_Quit	457
 #define CK_Maximize		458
 
+#define CK_Toggle_Syntax	480
+
 /* macro */
 #define CK_Begin_Record_Macro	501
 #define CK_End_Record_Macro	502
diff -Naur mc-2003-01-24-21.orig/edit/editkeys.c mc-2003-01-24-21.patched/edit/editkeys.c
--- mc-2003-01-24-21.orig/edit/editkeys.c	Wed Dec 25 23:53:25 2002
+++ mc-2003-01-24-21.patched/edit/editkeys.c	Sat Jan 25 14:31:29 2003
@@ -53,6 +53,7 @@
     '\t', CK_Tab,
     XCTRL ('u'), CK_Undo,
     KEY_IC, CK_Toggle_Insert,
+    XCTRL ('s'), CK_Toggle_Syntax,
     XCTRL ('o'), CK_Shell,
     KEY_F (3), CK_Mark,
     KEY_F (13), CK_Column_Mark,
diff -Naur mc-2003-01-24-21.orig/src/cmd.c mc-2003-01-24-21.patched/src/cmd.c
--- mc-2003-01-24-21.orig/src/cmd.c	Sat Jan 25 13:46:00 2003
+++ mc-2003-01-24-21.patched/src/cmd.c	Sat Jan 25 14:49:05 2003
@@ -515,6 +515,7 @@
     int i;
     int c;
     int dirflag = 0;
+    int fileflag = 1;
 
     reg_exp = input_dialog (_(" Select "), "", easy_patterns ? "*" : ".");
     if (!reg_exp)
@@ -527,8 +528,9 @@
         dirflag = 1;
         reg_exp_t++;
     }
-    if (reg_exp_t [strlen(reg_exp_t) - 1] == PATH_SEP){
+    if ((*reg_exp_t) && reg_exp_t [strlen(reg_exp_t) - 1] == PATH_SEP){
         dirflag = 1;
+	fileflag = 0;
         reg_exp_t [strlen(reg_exp_t) - 1] = 0;
     }
 
@@ -539,7 +541,7 @@
 	    if (!dirflag)
                 continue;
         } else {
-            if (dirflag)
+            if (!fileflag)
                 continue;
 	}
 	c = regexp_match (reg_exp_t, cpanel->dir.list [i].fname, match_file);
@@ -562,6 +564,7 @@
     int i;
     int c;
     int dirflag = 0;
+    int fileflag = 1;
 
     reg_exp = input_dialog (_(" Unselect "),"", easy_patterns ? "*" : ".");
     if (!reg_exp)
@@ -574,8 +577,9 @@
         dirflag = 1;
 	reg_exp_t ++;
     }
-    if (reg_exp_t [strlen(reg_exp_t) - 1] == PATH_SEP){
+    if ((*reg_exp_t) && reg_exp_t [strlen(reg_exp_t) - 1] == PATH_SEP){
         dirflag = 1;
+	fileflag = 0;
         reg_exp_t [strlen(reg_exp_t) - 1] = 0;
     }
     for (i = 0; i < cpanel->count; i++){
@@ -585,7 +589,7 @@
 	    if (!dirflag)
 	        continue;
         } else {
-            if (dirflag)
+            if (!fileflag)
                 continue;
         }
 	c = regexp_match (reg_exp_t, cpanel->dir.list [i].fname, match_file);
diff -Naur mc-2003-01-24-21.orig/src/command.c mc-2003-01-24-21.patched/src/command.c
--- mc-2003-01-24-21.orig/src/command.c	Thu Nov 14 08:27:08 2002
+++ mc-2003-01-24-21.patched/src/command.c	Sat Jan 25 15:05:02 2003
@@ -41,6 +41,27 @@
 /* This holds the command line */
 WInput *cmdline;
 
+/* Wildcard matching routine by A'rpi/ESP-team */
+static int wildcard_cmp_names(char *n,char *m){
+next:
+  if(m[0]=='*'){
+    int i;
+    m++;
+    if(m[0]==0) return 1;
+    while(n[0]){
+      if(wildcard_cmp_names(n,m)) return 1;
+      n++;
+    }
+    return 0;
+  }
+  if(n[0]==m[0] || (m[0]=='?' && n[0])){
+    if(n[0]==0) return 1;
+    n++;m++;
+    goto next;
+  }
+  return 0;
+}
+
 /*Tries variable substitution, and if a variable CDPATH
 of the form e.g. CDPATH=".:~:/usr" exists, we try then all the paths which
 are mentioned there. Also, we do not support such extraordinary things as
@@ -93,8 +114,37 @@
         }
     }
     *r = 0;
-    
+
     result = do_cd (q, cd_parse_command);
+
+    if(!result && strchr(q,92)){
+      // quoted dirname
+      char *q2=g_malloc(strlen(q)+1);
+      char *s=q;
+      char *d=q2;
+      int c;
+      do{
+        c=*s++;
+        if(c==92 || c=='%') c=*s++;
+        *d++=c;
+      } while(c);
+      free(q);
+      q=q2;
+      result = do_cd (q, cd_parse_command);
+    }
+    
+    if(!result && (strchr(q,'*')||strchr(q,'?'))){
+	// wildcarded dirname
+	int i;
+        for (i = 0; i < cpanel->count; i++)
+    	    if(S_ISDIR(cpanel->dir.list [i].buf.st_mode)){
+		if(wildcard_cmp_names(cpanel->dir.list [i].fname,q)){
+		    // found it!!!
+		    result = do_cd (cpanel->dir.list [i].fname, cd_parse_command);
+		    if(result) break;
+		}
+	    }
+    }
 
     /* CDPATH handling */
     if (*q != PATH_SEP && !result) {
diff -Naur mc-2003-01-24-21.orig/src/file.c mc-2003-01-24-21.patched/src/file.c
--- mc-2003-01-24-21.orig/src/file.c	Thu Dec 26 21:10:39 2002
+++ mc-2003-01-24-21.patched/src/file.c	Sat Jan 25 16:11:43 2003
@@ -107,6 +107,9 @@
 /* If on, default for "No" in delete operations */
 int safe_delete = 0;
 
+/* Beep never (0), after 2+ file ops (1), or after any file ops (2) */
+int op_beep_when_finished = 0;
+
 /* This is a hard link cache */
 struct link {
     struct link *next;
@@ -2150,6 +2153,10 @@
 	g_free (ctx->dest_mask);
 	ctx->dest_mask = NULL;
     }
+
+    if( (op_beep_when_finished==2) || (!only_one && op_beep_when_finished==1) )
+        SLtt_beep();
+
 #ifdef WITH_BACKGROUND
     /* Let our parent know we are saying bye bye */
     if (we_are_background) {
diff -Naur mc-2003-01-24-21.orig/src/key.c mc-2003-01-24-21.patched/src/key.c
--- mc-2003-01-24-21.orig/src/key.c	Sat Dec 28 06:11:40 2002
+++ mc-2003-01-24-21.patched/src/key.c	Sat Jan 25 15:24:09 2003
@@ -675,6 +675,18 @@
 	                c = KEY_F (c-'0');
 		    else if (c == ' ')
 			c = ESC_CHAR;
+                    else switch (c){
+                        case '!': c = KEY_F(11);break;
+                        case '@': c = KEY_F(12);break;
+                        case '#': c = KEY_F(13);break;
+                        case '$': c = KEY_F(14);break;
+                        case '%': c = KEY_F(15);break;
+                        case '^': c = KEY_F(16);break;
+                        case '&': c = KEY_F(17);break;
+                        case '*': c = KEY_F(18);break;
+                        case '(': c = KEY_F(19);break;
+                        case ')': c = KEY_F(20);break;
+                    }
 		    pending_keys = seq_append = NULL;
 		    this = NULL;
 		    return correct_key_code (c);
diff -Naur mc-2003-01-24-21.orig/src/main.c mc-2003-01-24-21.patched/src/main.c
--- mc-2003-01-24-21.orig/src/main.c	Sat Jan 25 13:46:00 2003
+++ mc-2003-01-24-21.patched/src/main.c	Sat Jan 25 15:40:09 2003
@@ -227,6 +227,12 @@
    are tagged files */
 int confirm_view_dir = 0;
 
+/* Command prompt type: 0=no_prompt  1=CWD  2=get_from_subshell */
+int command_prompt_type = 2;
+
+/* Allow subshell to change MC's CWD */
+int allow_subshell_chdir = 1;
+
 /* This flag indicates if the pull down menus by default drop down */
 int drop_menus = 0;
 
@@ -462,6 +468,7 @@
 void
 do_possible_cd (char *new_dir)
 {
+    if(!allow_subshell_chdir) return;
     if (!do_cd (new_dir, cd_exact))
 	message (1, _("Warning"),
 		 _(" The Commander can't change to the directory that \n"
@@ -543,6 +550,7 @@
 	    fflush (stdout);
 	    mc_raw_mode ();
 	    getch ();
+//            get_key_code(0);
 	}
 	if (console_flag) {
 	    if (output_lines && keybar_visible) {
@@ -867,8 +875,18 @@
     if (current_dlg == midnight_dlg && command_prompt) {
 	int prompt_len;
 
-	prompt = strip_ctrl_codes (subshell_prompt);
-	prompt_len = strlen (prompt);
+	if(command_prompt_type==0){
+	    prompt = (geteuid () == 0) ? "# " : "$ ";
+	} else
+	if(command_prompt_type==1){
+	    prompt = cpanel->cwd;
+	} else
+	if(command_prompt_type==2){
+	    prompt = strip_ctrl_codes (subshell_prompt);
+	} else
+	    prompt = "C:\\> ";
+        prompt_len = strlen (prompt);
+        if(command_prompt_type==1) ++prompt_len;
 
 	/* Check for prompts too big */
 	if (COLS > 8 && prompt_len > COLS - 8) {
@@ -1027,7 +1045,7 @@
     {' ', N_("&Quick cd          M-c"), 'Q', quick_cd_cmd},
     {' ', "", ' ', 0},
     {' ', N_("select &Group      M-+"), 'G', select_cmd},
-    {' ', N_("u&Nselect group    M-\\"), 'N', unselect_cmd},
+    {' ', N_("u&Nselect group    M--"), 'N', unselect_cmd},
     {' ', N_("reverse selec&Tion M-*"), 'T', reverse_selection_cmd},
     {' ', "", ' ', 0},
     {' ', N_("e&Xit              F10"), 'X', quit_cmd}
@@ -1479,6 +1497,7 @@
 
     /* To access the directory hotlist */
     {XCTRL ('\\'), quick_chdir_cmd},
+    {ALT('\\'), quick_chdir_cmd },
 
     /* Suspend */
     {XCTRL ('z'), suspend_cmd},
diff -Naur mc-2003-01-24-21.orig/src/screen.c mc-2003-01-24-21.patched/src/screen.c
--- mc-2003-01-24-21.orig/src/screen.c	Tue Jan 21 03:25:51 2003
+++ mc-2003-01-24-21.patched/src/screen.c	Sat Jan 25 15:45:50 2003
@@ -2100,7 +2100,7 @@
     { ALT('u'),   directory_history_next },
     { ALT('+'),	  select_cmd },
     { KEY_KP_ADD, select_cmd },
-    { ALT('\\'),  unselect_cmd },
+//    { ALT('\\'),  unselect_cmd },
     { ALT('-'),	  unselect_cmd },
     { KEY_KP_SUBTRACT, unselect_cmd },
     { ALT('*'),	  reverse_selection_cmd },
diff -Naur mc-2003-01-24-21.orig/src/setup.c mc-2003-01-24-21.patched/src/setup.c
--- mc-2003-01-24-21.orig/src/setup.c	Sat Jan 25 13:46:00 2003
+++ mc-2003-01-24-21.patched/src/setup.c	Sat Jan 25 16:13:25 2003
@@ -58,6 +58,11 @@
 
 extern int num_history_items_recorded;
 
+extern int subshell_blocks_ctrlo;
+extern int command_prompt_type;
+extern int allow_subshell_chdir;
+extern int op_beep_when_finished;
+
 char *profile_name;		/* .mc/ini */
 char *global_profile_name;	/* mc.lib */
 
@@ -124,6 +129,7 @@
     { "xterm_title", &xterm_title },
     { "output_lines", &output_lines },
     { "command_prompt", &command_prompt },
+    { "command_prompt_type", &command_prompt_type },
     { "menubar_visible", &menubar_visible },
     { "show_mini_info", &show_mini_info },
     { "permission_mode", &permission_mode },
@@ -154,6 +160,7 @@
     { "confirm_execute", &confirm_execute },
     { "confirm_exit", &confirm_exit },
     { "safe_delete", &safe_delete },
+    { "beep_when_finished", &op_beep_when_finished },
     { "mouse_repeat_rate", &mou_auto_repeat },
     { "double_click_speed", &double_click_speed },
 #ifndef HAVE_CHARSET
@@ -178,6 +185,8 @@
     { "alternate_plus_minus", &alternate_plus_minus },
     { "only_leading_plus_minus", &only_leading_plus_minus },
     { "show_output_starts_shell", &output_starts_shell },
+    { "allow_subshell_chdir", &allow_subshell_chdir },
+    { "subshell_blocks_ctrlo", &subshell_blocks_ctrlo },
     { "panel_scroll_pages", &panel_scroll_pages },
     { "xtree_mode", &xtree_mode },
     { "num_history_items_recorded", &num_history_items_recorded },
diff -Naur mc-2003-01-24-21.orig/src/subshell.c mc-2003-01-24-21.patched/src/subshell.c
--- mc-2003-01-24-21.orig/src/subshell.c	Sat Jan 25 13:46:00 2003
+++ mc-2003-01-24-21.patched/src/subshell.c	Sat Jan 25 15:58:50 2003
@@ -100,6 +100,9 @@
 TRUE;
 #endif
 
+/* Don't allow ctrl+o (panels ON) if shell already dunning a command: */
+int subshell_blocks_ctrlo=1;
+
 /* File descriptor of the pseudoterminal used by the subshell */
 int subshell_pty = 0;
 
@@ -937,7 +940,7 @@
     fd_set read_set;	/* For `select' */
     int maxfdp;
     int bytes;		/* For the return value from `read' */
-    int i;		/* Loop counter */
+    int i,j;		/* Loop counter */
     
     struct timeval wtime; /* Maximum time we wait for the subshell */
     struct timeval *wptr;
@@ -1039,7 +1042,19 @@
 		    exit (1);
 		}
 
-		for (i=0; i<bytes; ++i)
+		if(subshell_blocks_ctrlo){
+		    if (pty_buffer[0] == subshell_switch_key &&
+                	subshell_ready==TRUE){
+		    	    subshell_state = INACTIVE;
+		    	    return TRUE;
+                	}
+		    // remove ctrl+o codes from buffer:
+		    for (i=0,j=0; i<bytes; ++i)
+			if (pty_buffer[i] != subshell_switch_key)
+                    	    pty_buffer[j++]=pty_buffer[i];
+		    bytes=j;
+                } else {
+		  for (i=0; i<bytes; ++i)
 		    if (pty_buffer[i] == subshell_switch_key)
 		    {
 			write (subshell_pty, pty_buffer, i);
@@ -1047,9 +1062,10 @@
 			    subshell_state = INACTIVE;
 			return TRUE;
 		    }
-
+                }
 		write (subshell_pty, pty_buffer, bytes);
-		subshell_ready = FALSE;
+	        subshell_ready = FALSE;
+
 	    } else {
 		return FALSE;
 	    }



A'rpi / Astral & ESP-team

--
Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu



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