edit line offset patch



Sorry, that patch got ditched in some
subdirectory with a .obj extension.

I'll try again. Any advice would be
appreciated.

See attached.

--
Peace and Cheer.
--- mc-4.6.1/src/cmd.c	2005-05-27 07:19:18.000000000 -0700
+++ mc-4.6.1-editlineoffset/src/cmd.c	2005-08-19 10:52:25.533495864 -0700
@@ -135,7 +135,7 @@ view_file_at_line (const char *filename,
 	    if (!viewer)
 		viewer = "view";
 	}
-	execute_with_vfs_arg (viewer, filename);
+	execute_with_vfs_arg (viewer, filename, NULL );
     }
     return move_dir;
 }
@@ -266,6 +266,7 @@ filtered_view_cmd (void)
 void do_edit_at_line (const char *what, int start_line)
 {
     static const char *editor = NULL;
+    static char *extra_argument = NULL;
 
 #ifdef USE_INTERNAL_EDIT
     if (use_internal_edit){
@@ -280,7 +281,13 @@ void do_edit_at_line (const char *what, 
 	if (!editor)
 	    editor = get_default_editor ();
     }
-    execute_with_vfs_arg (editor, what);
+    if ( start_line )
+	extra_argument = g_strdup_printf ( "+%i", start_line );
+    execute_with_vfs_arg (editor, what, extra_argument );
+    if ( extra_argument ) {
+	g_free ( extra_argument );
+	extra_argument = NULL;
+    }
     update_panels (UP_OPTIMIZE, UP_KEEPSEL);
     repaint_screen ();
 }
--- mc-4.6.1/src/execute.h	2004-11-18 09:47:55.000000000 -0800
+++ mc-4.6.1-editlineoffset/src/execute.h	2005-08-08 18:27:36.000000000 -0700
@@ -18,6 +18,6 @@ void toggle_panels (void);
 void suspend_cmd (void);
 
 /* Execute command on a filename that can be on VFS */
-void execute_with_vfs_arg (const char *command, const char *filename);
+void execute_with_vfs_arg (const char *command, const char *filename, const char *extra_argument );
 
 #endif /* !MC_EXECUTE_H */
--- mc-4.6.1/src/execute.c	2005-05-27 07:19:18.000000000 -0700
+++ mc-4.6.1-editlineoffset/src/execute.c	2005-08-08 18:34:11.000000000 -0700
@@ -87,7 +87,7 @@ pre_exec (void)
 
 
 static void
-do_execute (const char *shell, const char *command, int flags)
+do_execute (const char *shell, const char *command, int flags, const char *extra_argument )
 {
 #ifdef HAVE_SUBSHELL_SUPPORT
     char *new_dir = NULL;
@@ -120,7 +120,7 @@ do_execute (const char *shell, const cha
 #endif				/* !USE_VFS */
     } else
 #endif				/* HAVE_SUBSHELL_SUPPORT */
-	my_system (flags, shell, command);
+	my_system (flags, shell, command, extra_argument);
 
     if (!(flags & EXECUTE_INTERNAL)) {
 	if ((pause_after_run == pause_always
@@ -184,13 +184,13 @@ shell_execute (const char *command, int 
 #ifdef HAVE_SUBSHELL_SUPPORT
     if (use_subshell)
 	if (subshell_state == INACTIVE)
-	    do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
+	    do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL, NULL);
 	else
 	    message (1, MSG_ERROR,
 		     _(" The shell is already running a command "));
     else
 #endif				/* HAVE_SUBSHELL_SUPPORT */
-	do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
+	do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL, NULL);
 
     g_free (cmd);
 }
@@ -199,7 +199,7 @@ shell_execute (const char *command, int 
 void
 exec_shell (void)
 {
-    do_execute (shell, 0, 0);
+    do_execute (shell, 0, 0, NULL);
 }
 
 
@@ -244,7 +244,7 @@ toggle_panels (void)
 		     _("Type `exit' to return to the Midnight Commander"));
 	    fprintf (stderr, "\n\r\n\r");
 
-	    my_system (EXECUTE_INTERNAL, shell, NULL);
+	    my_system (EXECUTE_INTERNAL, shell, NULL, NULL);
 	} else
 	    get_key_code (0);
     }
@@ -330,7 +330,7 @@ suspend_cmd (void)
  * Errors are reported to the user.
  */
 void
-execute_with_vfs_arg (const char *command, const char *filename)
+execute_with_vfs_arg (const char *command, const char *filename, const char *extra_argument )
 {
     char *localcopy;
     char *fn;
@@ -339,7 +339,7 @@ execute_with_vfs_arg (const char *comman
 
     /* Simplest case, this file is local */
     if (!filename || vfs_file_is_local (filename)) {
-	do_execute (command, filename, EXECUTE_INTERNAL);
+	do_execute (command, filename, EXECUTE_INTERNAL, extra_argument);
 	return;
     }
 
@@ -362,7 +362,7 @@ execute_with_vfs_arg (const char *comman
     fn = g_strdup (filename);
     mc_stat (localcopy, &st);
     mtime = st.st_mtime;
-    do_execute (command, localcopy, EXECUTE_INTERNAL);
+    do_execute (command, localcopy, EXECUTE_INTERNAL, extra_argument);
     mc_stat (localcopy, &st);
     mc_ungetlocalcopy (fn, localcopy, mtime != st.st_mtime);
     g_free (localcopy);
--- mc-4.6.1/src/util.h	2005-01-13 11:20:47.000000000 -0800
+++ mc-4.6.1-editlineoffset/src/util.h	2005-08-08 18:35:04.000000000 -0700
@@ -124,7 +124,7 @@ void check_error_pipe (void);
 int close_error_pipe (int error, const char *text);
 
 /* Process spawning */
-int my_system (int flags, const char *shell, const char *command);
+int my_system (int flags, const char *shell, const char *command, const char *extra_argument);
 void save_stop_handler (void);
 extern struct sigaction startup_handler;
 


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