mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
mcedit can be invoked with the common filename:lineno syntax.
This commit is contained in:
parent
c1eb75a515
commit
bdf23438af
@ -1,3 +1,8 @@
|
||||
2008-12-18 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
* doc/mcedit.1: Documented the newly added filename:lineno
|
||||
invocation method.
|
||||
|
||||
2008-02-19 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* doc/hu/mc.1.in: Fix description for M-u and M-H. Reported by
|
||||
|
@ -3,7 +3,10 @@
|
||||
mcedit \- Internal file editor of GNU Midnight Commander.
|
||||
.SH USAGE
|
||||
.B mcedit
|
||||
[\-bcCdfhstVx?] [+number] file
|
||||
[\-bcCdfhstVx?] [+lineno] file
|
||||
.PP
|
||||
.B mcedit
|
||||
[\-bcCdfhstVx?] file:lineno[:]
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
mcedit is a link to
|
||||
@ -18,8 +21,8 @@ version of
|
||||
\- standalone editor for X Window System.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.I "+number"
|
||||
Go to the line specified by number (do not put a space between the
|
||||
.I "+lineno"
|
||||
Go to the line specified by number (do not put a space between the
|
||||
.I "+"
|
||||
sign and the number).
|
||||
.TP
|
||||
|
@ -1,3 +1,9 @@
|
||||
2008-12-18 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
* main.c (main): It is now possible to invoke mcedit with
|
||||
filename:lineno[:], so that copy and paste of file locations
|
||||
can be done quickly.
|
||||
|
||||
2008-12-02 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
* tty.c (tty_tgetstr): Fixed a crash because of an uninitialized
|
||||
|
44
src/main.c
44
src/main.c
@ -2055,17 +2055,45 @@ handle_args (int argc, char *argv[])
|
||||
if (!STRNCOMP (base, "mce", 3) || !STRCOMP (base, "vi")) {
|
||||
edit_one_file = "";
|
||||
if (tmp) {
|
||||
if (*tmp == '+' && isdigit ((unsigned char) tmp[1])) {
|
||||
int start_line = atoi (tmp);
|
||||
if (start_line > 0) {
|
||||
char *file = poptGetArg (ctx);
|
||||
if (file) {
|
||||
tmp = file;
|
||||
edit_one_file_start_line = start_line;
|
||||
/*
|
||||
* Check for filename:lineno, followed by an optional colon.
|
||||
* This format is used by many programs (especially compilers)
|
||||
* in error messages and warnings. It is supported so that
|
||||
* users can quickly copy and paste file locations.
|
||||
*/
|
||||
char *end = tmp + strlen (tmp), *p = end;
|
||||
if (p > tmp && p[-1] == ':')
|
||||
p--;
|
||||
while (p > tmp && isdigit ((unsigned char) p[-1]))
|
||||
p--;
|
||||
if (tmp < p && p < end && p[-1] == ':') {
|
||||
struct stat st;
|
||||
gchar *fname = g_strndup (tmp, p - 1 - tmp);
|
||||
/*
|
||||
* Check that the file before the colon actually exists.
|
||||
* If it doesn't exist, revert to the old behavior.
|
||||
*/
|
||||
if (mc_stat (tmp, &st) == -1 && mc_stat (fname, &st) != -1) {
|
||||
edit_one_file = fname;
|
||||
edit_one_file_start_line = atoi (p);
|
||||
} else {
|
||||
g_free (fname);
|
||||
goto try_plus_filename;
|
||||
}
|
||||
} else {
|
||||
try_plus_filename:
|
||||
if (*tmp == '+' && isdigit ((unsigned char) tmp[1])) {
|
||||
int start_line = atoi (tmp);
|
||||
if (start_line > 0) {
|
||||
char *file = poptGetArg (ctx);
|
||||
if (file) {
|
||||
tmp = file;
|
||||
edit_one_file_start_line = start_line;
|
||||
}
|
||||
}
|
||||
}
|
||||
edit_one_file = g_strdup (tmp);
|
||||
}
|
||||
edit_one_file = g_strdup (tmp);
|
||||
}
|
||||
} else if (!STRNCOMP (base, "mcv", 3) || !STRCOMP (base, "view")) {
|
||||
if (tmp)
|
||||
|
Loading…
Reference in New Issue
Block a user