Re: Patch for switching to subshel in editor and viewer



Hi, Walery!

> Ok, now Ctrl-O and '!' reuse the same core.

I applied a patch a few day ago where Ctrl-O in the viewer uses the same
code as the panels (view_other_cmd), whereas '!' works as it worked before
(it forces the shell even if the subshell is not supports).  I think it's
the most consistent and backwards-compatible behavior.

> > What's wrong with `F11 s'?  Is it really so important to access the same
> > shell used by MC as subshell?
>
> Yes, it may be important.
> For instance if you want to see output of the previous command
> of if you continue to do the same task in the subshell.

I agree.  Indeed, it's better to have the same Ctrl-O behavior in all
three modes (panels, viewer, editor),

> > And why Ctrl-Shift-O?  This won't work on remote terminals at all.  Maybe
> > it's better to redefine "Open" to another key in the editor?  Can you
> > check what is the "traditional" key to open a new file?  GNOME uses F3,
> > but how about Far.
>
> Fixed. "Open file" is rebinded to F18
> (anyway IMHO this is not used very often).

This choice seems random to me.  There is a good reason why it's not used
often - because it's easier to select the file on the panel.  I'm removing
the shortcut completely, both in the intuitive and in the emacs mode.

> Now Ctrl-O is also used here for invoking subshell.

You are doing it on a very low level.  My implementation uses a new
action, CK_Shell.

> Well, all problems are fixed.
> Now we have the same keys in all modes of operation.
> Also we invoke the same subshell.
> Also this will work in the remote terminals.
> I see no obstacles for including this into CVS.

I'm applying my patch, but it does what you want.

ChangeLog:
	* edit_key_translator.c (cooledit_key_map): Use Ctrl-O for
	subshell, not for "Open file...".
	(emacs_key_map): Likewise.
	* edit.c: Handle CK_Shell.
	* editcmddef.h: Define CK_Shell.
	* editmenu.c (FileMenu): Remove C-o from the "Open file..."
	item.
	(FileMenuEmacs): Likewise.

The message "&Open file..." is new.  It should be translated.

There is one problem - exiting from the subshell while in the viewer and
editor is not handled gracefully.  I don't think that MC should exit if a
modified file is loaded in the editor just because the user typed "exit"
in the subshell.

-- 
Regards,
Pavel Roskin

-------------------------------------------
--- edit/edit_key_translator.c
+++ edit/edit_key_translator.c
@@ -47,7 +47,7 @@
      KEY_PPAGE, CK_Page_Up, KEY_NPAGE, CK_Page_Down, KEY_LEFT, CK_Left,
      KEY_RIGHT, CK_Right, KEY_UP, CK_Up, KEY_DOWN, CK_Down, ALT ('\t'), CK_Return, ALT ('\n'), CK_Return,
      KEY_HOME, CK_Home, KEY_END, CK_End, '\t', CK_Tab, XCTRL ('u'), CK_Undo, KEY_IC, CK_Toggle_Insert,
-     XCTRL ('o'), CK_Load, KEY_F (3), CK_Mark, KEY_F (13), CK_Column_Mark, KEY_F (5), CK_Copy,
+     XCTRL ('o'), CK_Shell, KEY_F (3), CK_Mark, KEY_F (13), CK_Column_Mark, KEY_F (5), CK_Copy,
      KEY_F (6), CK_Move, KEY_F (8), CK_Remove, KEY_F (12), CK_Save_As,
      KEY_F (2), CK_Save, XCTRL ('n'), CK_New,
      XCTRL ('l'), CK_Refresh, ESC_CHAR, CK_Exit, KEY_F (10), CK_Exit,
@@ -70,7 +70,7 @@
      KEY_PPAGE, CK_Page_Up, KEY_NPAGE, CK_Page_Down, KEY_LEFT, CK_Left,
      KEY_RIGHT, CK_Right, KEY_UP, CK_Up, KEY_DOWN, CK_Down, ALT ('\t'), CK_Return, ALT ('\n'), CK_Return,
      KEY_HOME, CK_Home, KEY_END, CK_End, '\t', CK_Tab, XCTRL ('u'), CK_Undo, KEY_IC, CK_Toggle_Insert,
-     XCTRL ('o'), CK_Load, KEY_F (3), CK_Mark, KEY_F (13), CK_Column_Mark, KEY_F (5), CK_Copy,
+     XCTRL ('o'), CK_Shell, KEY_F (3), CK_Mark, KEY_F (13), CK_Column_Mark, KEY_F (5), CK_Copy,
      KEY_F (6), CK_Move, KEY_F (8), CK_Remove, KEY_F (12), CK_Save_As,
      KEY_F (2), CK_Save, ALT ('p'), CK_Paragraph_Format,

--- gtkedit/edit.c
+++ gtkedit/edit.c
@@ -2612,6 +2612,9 @@ int edit_execute_cmd (WEdit * edit, int
     case CK_Mail:
 	edit_mail_dialog (edit);
 	break;
+    case CK_Shell:
+	view_other_cmd ();
+	break;
 #endif

 /* These commands are not handled and must be handled by the user application */
--- gtkedit/editcmddef.h
+++ gtkedit/editcmddef.h
@@ -142,6 +142,8 @@
 #define CK_Selection_History	704

 #ifdef MIDNIGHT			/* cooledit now has its own full-featured script editor and executor */
+#define CK_Shell		801
+
 /*
    Process a block through a shell command: CK_Pipe_Block(i) executes shell_cmd[i].
    shell_cmd[i] must process the file ~/cooledit.block and output ~/cooledit.block
--- gtkedit/editmenu.c
+++ gtkedit/editmenu.c
@@ -125,7 +125,7 @@ void edit_user_menu_cmd (void)

 static menu_entry FileMenu[] =
 {
-    {' ', N_("&Open/load...     C-o"), 'O', menu_load_cmd},
+    {' ', N_("&Open file..."),         'O', menu_load_cmd},
     {' ', N_("&New              C-n"), 'N', menu_new_cmd},
     {' ', "", ' ', 0},
     {' ', N_("&Save              F2"), 'S', menu_save_cmd},
@@ -144,7 +144,7 @@ static menu_entry FileMenu[] =

 static menu_entry FileMenuEmacs[] =
 {
-    {' ', N_("&Open/load...     C-o"), 'O', menu_load_cmd},
+    {' ', N_("&Open file..."),         'O', menu_load_cmd},
     {' ', N_("&New            C-x k"), 'N', menu_new_cmd},
     {' ', "", ' ', 0},
     {' ', N_("&Save              F2"), 'S', menu_save_cmd},
-------------------------------------------





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