mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 11:12:06 +03:00
* editcmd.c: Implement pasting the output of any external
command. * editmenu.c: Add menu entries for that. * editcmddef.h: Add new command CK_ExtCmd.
This commit is contained in:
parent
a3708077d1
commit
bdc56f331b
@ -1,3 +1,10 @@
|
||||
2003-05-30 Michal Szwaczko <mikey@scene.pl>
|
||||
|
||||
* editcmd.c: Implement pasting the output of any external
|
||||
command.
|
||||
* editmenu.c: Add menu entries for that.
|
||||
* editcmddef.h: Add new command CK_ExtCmd.
|
||||
|
||||
2003-04-04 Adam Byrtek <alpha@debian.org>
|
||||
|
||||
* edit.c: Move edit_modification() before actions to provide
|
||||
|
@ -2565,6 +2565,9 @@ int edit_execute_cmd (WEdit * edit, int command, int char_for_insertion)
|
||||
case CK_Sort:
|
||||
edit_sort_cmd (edit);
|
||||
break;
|
||||
case CK_ExtCmd:
|
||||
edit_ext_cmd (edit);
|
||||
break;
|
||||
case CK_Mail:
|
||||
edit_mail_dialog (edit);
|
||||
break;
|
||||
@ -2580,6 +2583,7 @@ int edit_execute_cmd (WEdit * edit, int command, int char_for_insertion)
|
||||
case CK_Ctags:
|
||||
case CK_Terminal:
|
||||
case CK_Terminal_App:
|
||||
case CK_ExtCmd:
|
||||
#endif
|
||||
case CK_Complete:
|
||||
case CK_Cancel:
|
||||
|
@ -232,6 +232,7 @@ void edit_move_display (WEdit * e, long line);
|
||||
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);
|
||||
|
@ -2347,6 +2347,33 @@ int edit_sort_cmd (WEdit * edit)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
edit_ext_cmd (WEdit *edit)
|
||||
{
|
||||
char *exp;
|
||||
int e;
|
||||
|
||||
exp =
|
||||
input_dialog (_("Paste output of external command"),
|
||||
_("Enter shell command(s):"), NULL);
|
||||
|
||||
if (!exp)
|
||||
return 1;
|
||||
|
||||
e = system (catstrs (exp, " ", " > ", home_dir, TEMP_FILE, 0));
|
||||
|
||||
if (e) {
|
||||
edit_error_dialog (_("External command"),
|
||||
get_sys_error (_("Cannot execute command")));
|
||||
return -1;
|
||||
}
|
||||
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
|
||||
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 */
|
||||
|
@ -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 */
|
||||
|
@ -69,6 +69,7 @@ static const long cooledit_key_map[] = {
|
||||
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,
|
||||
@ -112,6 +113,7 @@ static long const emacs_key_map[] = {
|
||||
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,
|
||||
|
@ -205,6 +205,12 @@ menu_sort_cmd (void)
|
||||
menu_cmd (CK_Sort);
|
||||
}
|
||||
|
||||
static void
|
||||
menu_ext_cmd (void)
|
||||
{
|
||||
menu_cmd (CK_ExtCmd);
|
||||
}
|
||||
|
||||
static void
|
||||
menu_date_cmd (void)
|
||||
{
|
||||
@ -353,6 +359,7 @@ static menu_entry CmdMenu[] =
|
||||
{' ', 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}
|
||||
};
|
||||
@ -376,6 +383,7 @@ static menu_entry CmdMenuEmacs[] =
|
||||
{' ', 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}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user