[PATCH] mc-ext revisited

Michal Szwaczko mikey at wirelabs.lublin.pl
Sun May 25 23:19:42 UTC 2003


Ooops, the previous post was too fast.
Forgot to attach the code ;-)
Sorry. 
The patch included.
-- 
[ Michał 'Mikey' Szwaczko  | GPG Key#:0x653CBD53 ]
[ Developer/Troubleshooter | GNU Generation Now! ]
[ Fear is good. Paranoia is better.              ]
-------------- next part --------------
diff -Nur mc-4.6.0-orig/edit/edit.c mc-4.6.0/edit/edit.c
--- mc-4.6.0-orig/edit/edit.c	Mon Dec 23 11:13:35 2002
+++ mc-4.6.0/edit/edit.c	Mon May 26 00:52:42 2003
@@ -2558,6 +2558,9 @@
     case CK_Sort:
 	edit_sort_cmd (edit);
 	break;
+    case CK_ExtCmd:
+	edit_ext_cmd (edit);
+	break;
     case CK_Mail:
 	edit_mail_dialog (edit);
 	break;
@@ -2573,6 +2576,7 @@
     case CK_Ctags:
     case CK_Terminal:
     case CK_Terminal_App:
+    case CK_ExtCmd:
 #endif
     case CK_Complete:
     case CK_Cancel:
diff -Nur mc-4.6.0-orig/edit/edit.h mc-4.6.0/edit/edit.h
--- mc-4.6.0-orig/edit/edit.h	Mon Jan 27 17:00:12 2003
+++ mc-4.6.0/edit/edit.h	Mon May 26 00:56:59 2003
@@ -221,6 +221,7 @@
 void edit_word_wrap (WEdit * edit);
 unsigned char *edit_get_block (WEdit * edit, long start, long finish, int *l);
 int edit_sort_cmd (WEdit * edit);
+int edit_ext_cmd (WEdit * edit);
 void edit_help_cmd (WEdit * edit);
 void edit_left_word_move (WEdit * edit, int s);
 void edit_right_word_move (WEdit * edit, int s);
diff -Nur mc-4.6.0-orig/edit/editcmd.c mc-4.6.0/edit/editcmd.c
--- mc-4.6.0-orig/edit/editcmd.c	Thu Dec 19 14:01:34 2002
+++ mc-4.6.0/edit/editcmd.c	Mon May 26 00:56:26 2003
@@ -2304,6 +2304,32 @@
     return 0;
 }
 
+int edit_ext_cmd (WEdit * edit) 
+{
+     char *exp;
+     int e;
+ 
+     exp = ""; 
+     exp = input_dialog(_(" Paste output of external command "),
+     _(" Enter shell command(s): "),exp);
+
+     if (!exp) return 1;
+	
+	e = system (catstrs (exp, " "," > ", home_dir, TEMP_FILE, 0));
+	
+     if (e) {
+	    edit_error_dialog (_(" External "), 
+	    get_sys_error (_(" Error trying to execute command ")));
+	    return -1;
+     }
+
+     edit->force |= REDRAW_COMPLETELY;
+
+     edit_printf(edit,catstrs("sh> ",exp,"\n",0));
+     edit_insert_file (edit, catstrs (home_dir, TEMP_FILE, 0));
+     return 0;
+}
+
 /* if block is 1, a block must be highlighted and the shell command
    processes it. If block is 0 the shell command is a straight system
    command, that just produces some output which is to be inserted */
diff -Nur mc-4.6.0-orig/edit/editcmddef.h mc-4.6.0/edit/editcmddef.h
--- mc-4.6.0-orig/edit/editcmddef.h	Mon Jan 21 18:49:57 2002
+++ mc-4.6.0/edit/editcmddef.h	Mon May 26 00:52:52 2003
@@ -92,6 +92,7 @@
 #define CK_Match_Bracket	421
 #define CK_Terminal		422
 #define CK_Terminal_App		423
+#define CK_ExtCmd		424
 
 #define CK_User_Menu		425
 /* application control */
diff -Nur mc-4.6.0-orig/edit/editkeys.c mc-4.6.0/edit/editkeys.c
--- mc-4.6.0-orig/edit/editkeys.c	Wed Dec 25 23:53:07 2002
+++ mc-4.6.0/edit/editkeys.c	Mon May 26 00:53:51 2003
@@ -72,6 +72,7 @@
     XCTRL ('f'), CK_Save_Block,
     KEY_F (1), CK_Help,
     ALT ('t'), CK_Sort,
+    ALT ('u'), CK_ExtCmd,
     ALT ('m'), CK_Mail,
     XCTRL ('z'), CK_Word_Left,
     XCTRL ('x'), CK_Word_Right,
@@ -118,6 +119,7 @@
     KEY_F (2), CK_Save,
     ALT ('p'), CK_Paragraph_Format,
     ALT ('t'), CK_Sort,
+    ALT ('u'), CK_ExtCmd,
     XCTRL ('a'), CK_Home,
     XCTRL ('e'), CK_End,
     XCTRL ('b'), CK_Left,
diff -Nur mc-4.6.0-orig/edit/editmenu.c mc-4.6.0/edit/editmenu.c
--- mc-4.6.0-orig/edit/editmenu.c	Tue Jan 28 21:13:20 2003
+++ mc-4.6.0/edit/editmenu.c	Mon May 26 01:01:23 2003
@@ -204,7 +204,11 @@
 {
     menu_cmd (CK_Sort);
 }
-
+static void 
+menu_ext_cmd (void)
+{
+    menu_cmd (CK_ExtCmd);
+}
 static void
 menu_date_cmd (void)
 {
@@ -373,6 +377,7 @@
     {' ', N_("Format p&aragraph        M-p"), 'A', menu_format_paragraph},
     {' ', N_("'ispell' s&pell check    C-p"), 'P', menu_ispell_cmd},
     {' ', N_("Sor&t...                 M-t"), 'T', menu_sort_cmd},
+    {' ', N_("Paste o&utput of ...     M-u"), 'U', menu_ext_cmd},
     {' ', N_("E&xternal Formatter      F19"), 'C', menu_c_form_cmd},
     {' ', N_("&Mail...                    "), 'M', menu_mail_cmd}
 };
@@ -396,6 +401,7 @@
     {' ', N_("Format p&aragraph        M-p"), 'a', menu_format_paragraph},
     {' ', N_("'ispell' s&pell check    M-$"), 'P', menu_ispell_cmd},
     {' ', N_("Sor&t...                 M-t"), 'T', menu_sort_cmd},
+    {' ', N_("Paste o&utput of ...     M-u"), 'U', menu_ext_cmd},
     {' ', N_("E&xternal Formatter      F19"), 'C', menu_c_form_cmd},
     {' ', N_("&Mail...                    "), 'M', menu_mail_cmd}
 };


More information about the mc-devel mailing list