mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Ticket #3117: Launching editor with CK_Edit shouldn't pass line number.
When pressing F4 to start the editor, a "+1" argument is passed to open the file at the first line. For some editor this is absolutely unnecessary since they open the file there anyways. For some others (at least "joe", but probably others too) this is harmful: joe has a convenience feature that by default it opens the file where it was last open, unless of course overridden from command line. Currently mc forces joe to open the file at the first line, although opening it where it was last open would be much more desired. The right solution would be to consult mc.lib only when opening the viewer/editor through the "word search in files (M-?)" feature, and not when F3/F4 is pressed on a file, in the latter case $VIEWER or $EDITOR should simply be launched with the filename but no additional parameters. Initial step: minor refactoring: (do_edit_at_line): rename to edit_file_at_line. (edit_file_at_line): changed type of arguments from int to gboolean. (view_file_at_line): likewise. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
f949a29422
commit
9d83d55d84
@ -49,7 +49,7 @@
|
||||
#endif
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
|
||||
#include "src/filemanager/cmd.h" /* do_edit_at_line(), view_other_cmd() */
|
||||
#include "src/filemanager/cmd.h" /* edit_file_at_line(), view_other_cmd() */
|
||||
#include "src/filemanager/panel.h"
|
||||
#include "src/filemanager/layout.h" /* Needed for get_current_index and get_other_panel */
|
||||
|
||||
@ -2883,7 +2883,7 @@ dview_edit (WDiff * dview, diff_place_t ord)
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
tmp_vpath = vfs_path_from_str (dview->file[ord]);
|
||||
do_edit_at_line (tmp_vpath, use_internal_edit, linenum);
|
||||
edit_file_at_line (tmp_vpath, use_internal_edit != 0, linenum);
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
h->modal = h_modal;
|
||||
|
@ -157,7 +157,7 @@ do_view_cmd (gboolean normal)
|
||||
|
||||
file_idx = current_panel->selected;
|
||||
filename_vpath = vfs_path_from_str (current_panel->dir.list[file_idx].fname);
|
||||
view_file (filename_vpath, normal, use_internal_view);
|
||||
view_file (filename_vpath, normal, use_internal_view != 0);
|
||||
vfs_path_free (filename_vpath);
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ do_edit (const vfs_path_t * what_vpath)
|
||||
if (what_vpath != NULL && *(vfs_path_get_by_index (what_vpath, 0)->path) != '\0')
|
||||
load_file_position (what_vpath, &line, &column, &offset, NULL);
|
||||
}
|
||||
do_edit_at_line (what_vpath, use_internal_edit, line);
|
||||
edit_file_at_line (what_vpath, use_internal_edit != 0, line);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -623,7 +623,8 @@ set_basic_panel_listing_to (int panel_index, int listing_mode)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
view_file_at_line (const vfs_path_t * filename_vpath, int plain_view, int internal, long start_line)
|
||||
view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view, gboolean internal,
|
||||
long start_line)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
|
||||
@ -703,7 +704,7 @@ view_file_at_line (const vfs_path_t * filename_vpath, int plain_view, int intern
|
||||
*/
|
||||
|
||||
gboolean
|
||||
view_file (const vfs_path_t * filename_vpath, int plain_view, int internal)
|
||||
view_file (const vfs_path_t * filename_vpath, gboolean plain_view, gboolean internal)
|
||||
{
|
||||
long line = 0;
|
||||
|
||||
@ -742,12 +743,12 @@ view_file_cmd (void)
|
||||
input_expand_dialog (_("View file"), _("Filename:"),
|
||||
MC_HISTORY_FM_VIEW_FILE, selection (current_panel)->fname,
|
||||
INPUT_COMPLETE_FILENAMES);
|
||||
if (!filename)
|
||||
if (filename == NULL)
|
||||
return;
|
||||
|
||||
vpath = vfs_path_from_str (filename);
|
||||
g_free (filename);
|
||||
view_file (vpath, 0, use_internal_view);
|
||||
view_file (vpath, FALSE, use_internal_view != 0);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
|
||||
@ -789,7 +790,7 @@ view_filtered_cmd (void)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
do_edit_at_line (const vfs_path_t * what_vpath, gboolean internal, long start_line)
|
||||
edit_file_at_line (const vfs_path_t * what_vpath, gboolean internal, long start_line)
|
||||
{
|
||||
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
@ -849,7 +850,7 @@ edit_cmd_force_internal (void)
|
||||
|
||||
fname = vfs_path_from_str (selection (current_panel)->fname);
|
||||
if (regex_command (fname, "Edit") == 0)
|
||||
do_edit_at_line (fname, TRUE, 0);
|
||||
edit_file_at_line (fname, TRUE, 1);
|
||||
vfs_path_free (fname);
|
||||
}
|
||||
#endif
|
||||
|
@ -52,14 +52,14 @@ void help_cmd (void);
|
||||
void smart_dirsize_cmd (void);
|
||||
void single_dirsize_cmd (void);
|
||||
void dirsizes_cmd (void);
|
||||
gboolean view_file_at_line (const vfs_path_t * filename_vpath, int plain_view, int internal,
|
||||
long start_line);
|
||||
gboolean view_file (const vfs_path_t * filename_vpath, int normal, int internal);
|
||||
gboolean view_file_at_line (const vfs_path_t * filename_vpath, gboolean plain_view,
|
||||
gboolean internal, long start_line);
|
||||
gboolean view_file (const vfs_path_t * filename_vpath, gboolean normal, gboolean internal);
|
||||
void view_cmd (void);
|
||||
void view_file_cmd (void);
|
||||
void view_raw_cmd (void);
|
||||
void view_filtered_cmd (void);
|
||||
void do_edit_at_line (const vfs_path_t * what_vpath, gboolean internal, long start_line);
|
||||
void edit_file_at_line (const vfs_path_t * what_vpath, gboolean internal, long start_line);
|
||||
void edit_cmd (void);
|
||||
void edit_cmd_new (void);
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "src/history.h" /* MC_HISTORY_SHARED_SEARCH */
|
||||
|
||||
#include "dir.h"
|
||||
#include "cmd.h" /* view_file_at_line */
|
||||
#include "cmd.h" /* view_file_at_line() */
|
||||
#include "midnight.h" /* current_panel */
|
||||
#include "boxes.h"
|
||||
#include "panelize.h"
|
||||
@ -1433,9 +1433,9 @@ find_do_view_edit (gboolean unparsed_view, gboolean edit, char *dir, char *file)
|
||||
|
||||
fullname_vpath = vfs_path_build_filename (dir, filename, (char *) NULL);
|
||||
if (edit)
|
||||
do_edit_at_line (fullname_vpath, use_internal_edit, line);
|
||||
edit_file_at_line (fullname_vpath, use_internal_edit != 0, line);
|
||||
else
|
||||
view_file_at_line (fullname_vpath, unparsed_view ? 1 : 0, use_internal_view, line);
|
||||
view_file_at_line (fullname_vpath, unparsed_view, use_internal_view != 0, line);
|
||||
vfs_path_free (fullname_vpath);
|
||||
g_free (fullname);
|
||||
}
|
||||
|
@ -1000,7 +1000,7 @@ mc_maybe_editor_or_viewer (void)
|
||||
if (mc_run_param0 != NULL && *(char *) mc_run_param0 != '\0')
|
||||
vpath = prepend_cwd_on_local ((char *) mc_run_param0);
|
||||
|
||||
ret = view_file (vpath, 0, 1);
|
||||
ret = view_file (vpath, FALSE, TRUE);
|
||||
vfs_path_free (vpath);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user