Apply patch from Daniel Richard G. to add support for +NNN command line arguments and for recognising filename:line:column: format on the command line (thanks).
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2262 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
e5c09b7a6a
commit
753e2936d8
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2008-02-16 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||
|
||||
* doc/geany.html, doc/geany.txt:
|
||||
Fix slightly wrong documentation for show_editor_scrollbars.
|
||||
* THANKS, doc/geany.1.in, doc/geany.html, doc/geany.txt, src/main.c:
|
||||
Apply patch from Daniel Richard G. to add support for +NNN command
|
||||
line arguments and for recognising filename:line:column: format on
|
||||
the command line (thanks).
|
||||
|
||||
|
||||
2008-02-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||
|
||||
* tagmanager/python.c: Fix parsing bug when there is text after the
|
||||
|
1
THANKS
1
THANKS
@ -40,6 +40,7 @@ Sebastian Kraft <kraft(dot)sebastian(at)googlemail(dot)com> - new Geany icon
|
||||
Catalin Marinas <catalin(dot)marinas(at)gmail(dot)com> - newline strips trailing spaces patch
|
||||
Bo Lorentsen <bl(at)lue(dot)dk> - project session patch
|
||||
Yura Siamashka <yurand2(at)gmail(dot)com> - many patches
|
||||
Daniel Richard G. <skunk(at)iskunk(dot)org> - some patches
|
||||
|
||||
Translators:
|
||||
------------
|
||||
|
@ -3,7 +3,7 @@
|
||||
Geany \(em a small and lightweight IDE
|
||||
.SH "SYNOPSIS"
|
||||
.PP
|
||||
\fBgeany\fR [\fBoption\fP] [\fBfiles ...\fP]
|
||||
\fBgeany\fR [\fBoption\fP] [\fP+number\fP] [\fBfiles ...\fP]
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
Geany is a small and fast editor with basic features of an integrated development environment.
|
||||
@ -13,55 +13,65 @@ many supported filetypes like C(++), Java, PHP, HTML, DocBook, Perl and more.
|
||||
.PP
|
||||
Homepage: http://geany.uvena.de
|
||||
.SH "OPTIONS"
|
||||
.IP "\fB\fP \fB\-\-column\fP " 10
|
||||
.IP "\fB\fP \fBfiles ...\fP " 10
|
||||
A space-separated list of filenames. Absolute and relative filenames can be used. Geany also
|
||||
recognises line and column information when appended to the filename with colons, e.g.
|
||||
"geany foo.bar:10:5" will open the file foo.bar and place the cursor in line 10 at column 5.
|
||||
.IP "\fB\fP \fB\+number\fP " 10
|
||||
Set initial line
|
||||
.I number
|
||||
for the first opened file (same as --line, do not put a space
|
||||
between the + sign and the number). E.g. "geany +7 foo.bar" will open the file foo.bar and
|
||||
place the cursor in line 7.
|
||||
.IP "\fB\fP \fB\-\-column\fP " 10
|
||||
Set initial column number for the first opened file (useful in conjunction with --line).
|
||||
.IP "\fB-c\fP \fB\-\-config\fP " 10
|
||||
.IP "\fB-c\fP, \fB\-\-config\fP " 10
|
||||
Use an alternate configuration directory. Default configuration directory is
|
||||
~/.geany/ and there resides geany.conf and some template files.
|
||||
.IP "\fB-d\fP \fB\-\-debug\fP " 10
|
||||
.IP "\fB-d\fP, \fB\-\-debug\fP " 10
|
||||
Run Geany in debug mode, which means being verbose and printing lots of information.
|
||||
.IP "\fB\fP \fB\-\-ft\-names\fP " 10
|
||||
.IP "\fB\fP, \fB\-\-ft\-names\fP " 10
|
||||
Print a list of Geany's internal filetype names (useful snippets configuration).
|
||||
.IP "\fB-g\fP \fB\-\-generate\-tags\fP " 10
|
||||
.IP "\fB-g\fP, \fB\-\-generate\-tags\fP " 10
|
||||
Generate a global tags file (see documentation).
|
||||
.IP "\fB-P\fP \fB\-\-no\-preprocessing\fP " 10
|
||||
.IP "\fB-P\fP, \fB\-\-no\-preprocessing\fP " 10
|
||||
Don't preprocess C/C++ files when generating tags.
|
||||
.IP "\fB-i\fP \fB\-\-new-instance\fP " 10
|
||||
.IP "\fB-i\fP, \fB\-\-new-instance\fP " 10
|
||||
Don't open files in a running instance, force opening a new instance.
|
||||
Only available if Geany was compiled with support for Sockets.
|
||||
.IP "\fB-l\fP \fB\-\-line\fP " 10
|
||||
.IP "\fB-l\fP, \fB\-\-line\fP " 10
|
||||
Set initial line number for the first opened file.
|
||||
.IP "\fB-m\fP \fB\-\-no-msgwin\fP " 10
|
||||
.IP "\fB-m\fP, \fB\-\-no-msgwin\fP " 10
|
||||
Don't show the message window. Use this option if you don't need compiler messages
|
||||
or VTE support.
|
||||
.IP "\fB-n\fP \fB\-\-no-ctags\fP " 10
|
||||
.IP "\fB-n\fP, \fB\-\-no-ctags\fP " 10
|
||||
Don't load symbol completion and call tip data. Use this option, if you don't want to use them.
|
||||
For more information please see documentation.
|
||||
.IP "\fB-p\fP \fB\-\-no-plugins\fP " 10
|
||||
.IP "\fB-p\fP, \fB\-\-no-plugins\fP " 10
|
||||
Don't load plugin support.
|
||||
.IP "\fB\fP \fB\-\-print-prefix\fP " 10
|
||||
.IP "\fB\fP \fB\-\-print-prefix\fP " 10
|
||||
Print installation prefix, the data directory, the lib directory and the locale directory (in
|
||||
this order) to stdout, each per line. This is mainly intended for plugin authors to detect
|
||||
installation paths.
|
||||
.IP "\fB-s\fP \fB\-\-no-session\fP " 10
|
||||
.IP "\fB-s\fP, \fB\-\-no-session\fP " 10
|
||||
Don't load the previous session's files.
|
||||
.IP "\fB-t\fP \fB\-\-no-terminal\fP " 10
|
||||
.IP "\fB-t\fP, \fB\-\-no-terminal\fP " 10
|
||||
Don't load terminal support. Use this option, if you don't want to load the virtual terminal
|
||||
emulator widget at startup. If you don't have libvte.so.4 installed, then terminal-support is
|
||||
automatically disabled. Only available if Geany was compiled with support for VTE.
|
||||
.IP "\fB\fP \fB\-\-vte-lib\fP " 10
|
||||
.IP "\fB\fP \fB\-\-vte-lib\fP " 10
|
||||
Specify explicitly the path including filename or only the filename to the VTE library, e.g.
|
||||
/usr/lib/libvte.so or libvte.so. This option is only needed, when the autodetection doesn't
|
||||
work. Only available if Geany was compiled with support for VTE.
|
||||
.IP "\fB-v\fP \fB\-\-version\fP " 10
|
||||
.IP "\fB-v\fP, \fB\-\-version\fP " 10
|
||||
Show version information and exit.
|
||||
.IP "\fB-?\fP \fB\-\-help\fP " 10
|
||||
.IP "\fB-?\fP, \fB\-\-help\fP " 10
|
||||
Show help information and exit.
|
||||
.PP
|
||||
Geany supports all generic GTK options, a list is available on the help screen.
|
||||
.SH "AUTHOR"
|
||||
.PP
|
||||
This manual page was written by the Geany develoepr team. Permission is
|
||||
This manual page was written by the Geany developer team. Permission is
|
||||
granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2.
|
||||
.PP
|
||||
|
@ -6,7 +6,7 @@
|
||||
<meta name="generator" content="Docutils 0.4.1: http://docutils.sourceforge.net/" />
|
||||
<title>Geany</title>
|
||||
<meta name="authors" content="Enrico Tröger Nick Treleaven Frank Lanitz" />
|
||||
<meta name="date" content="2008-02-15" />
|
||||
<meta name="date" content="2008-02-16" />
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
@ -133,7 +133,7 @@ dt {
|
||||
<br />Nick Treleaven
|
||||
<br />Frank Lanitz</td></tr>
|
||||
<tr><th class="docinfo-name">Date:</th>
|
||||
<td>2008-02-15</td></tr>
|
||||
<td>2008-02-16</td></tr>
|
||||
<tr><th class="docinfo-name">Version:</th>
|
||||
<td>0.14</td></tr>
|
||||
</tbody>
|
||||
@ -436,6 +436,13 @@ Return:</p>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><em>none</em></td>
|
||||
<td>+number</td>
|
||||
<td>Set initial line number for the first opened file
|
||||
(same as --line, do not put a space between the + sign
|
||||
and the number). E.g. "geany +7 foo.bar" will open the
|
||||
file foo.bar and place the cursor in line 7.</td>
|
||||
</tr>
|
||||
<tr><td><em>none</em></td>
|
||||
<td>--column</td>
|
||||
<td>Set initial column number for the first opened file.</td>
|
||||
</tr>
|
||||
@ -527,7 +534,11 @@ available if Geany was compiled with support for VTE.</td>
|
||||
<td>[files ...]</td>
|
||||
<td>Open all given files at startup. This option causes
|
||||
Geany to ignore loading stored files from the last
|
||||
session (if enabled).</td>
|
||||
session (if enabled).
|
||||
Geany also recognises line and column information when
|
||||
appended to the filename with colons, e.g.
|
||||
"geany foo.bar:10:5" will open the file foo.bar and
|
||||
place the cursor in line 10 at column 5.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -3391,7 +3402,7 @@ USE OR PERFORMANCE OF THIS SOFTWARE.</p>
|
||||
<div class="footer">
|
||||
<hr class="footer" />
|
||||
<a class="reference" href="geany.txt">View document source</a>.
|
||||
Generated on: 2008-02-16 11:18 UTC.
|
||||
Generated on: 2008-02-16 11:20 UTC.
|
||||
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
|
||||
</div>
|
||||
|
@ -177,6 +177,11 @@ Command line options
|
||||
============ ======================= =================================================
|
||||
Short option Long option Function
|
||||
============ ======================= =================================================
|
||||
*none* +number Set initial line number for the first opened file
|
||||
(same as --line, do not put a space between the + sign
|
||||
and the number). E.g. "geany +7 foo.bar" will open the
|
||||
file foo.bar and place the cursor in line 7.
|
||||
|
||||
*none* --column Set initial column number for the first opened file.
|
||||
|
||||
-c dir_name --config=directory_name Use an alternate configuration directory. Default
|
||||
@ -234,6 +239,10 @@ Short option Long option Function
|
||||
*none* [files ...] Open all given files at startup. This option causes
|
||||
Geany to ignore loading stored files from the last
|
||||
session (if enabled).
|
||||
Geany also recognises line and column information when
|
||||
appended to the filename with colons, e.g.
|
||||
"geany foo.bar:10:5" will open the file foo.bar and
|
||||
place the cursor in line 10 at column 5.
|
||||
============ ======================= =================================================
|
||||
|
||||
Geany supports all generic GTK options, a list is available on the
|
||||
|
89
src/main.c
89
src/main.c
@ -112,6 +112,7 @@ static gboolean print_prefix = FALSE;
|
||||
#ifdef HAVE_PLUGINS
|
||||
static gboolean no_plugins = FALSE;
|
||||
#endif
|
||||
static gboolean dummy = FALSE;
|
||||
|
||||
// in alphabetical order of short options
|
||||
static GOptionEntry entries[] =
|
||||
@ -139,6 +140,7 @@ static GOptionEntry entries[] =
|
||||
{ "vte-lib", 0, 0, G_OPTION_ARG_FILENAME, &lib_vte, N_("Filename of libvte.so"), NULL },
|
||||
#endif
|
||||
{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Show version and exit"), NULL },
|
||||
{ "dummy", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &dummy, NULL, NULL }, // for +NNN line number arguments
|
||||
{ NULL, 0, 0, 0, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
@ -365,6 +367,58 @@ gchar *get_argv_filename(const gchar *filename)
|
||||
}
|
||||
|
||||
|
||||
/* get a :line:column specifier from the end of a filename (if present),
|
||||
* return the line/column values, and remove the specifier from the string
|
||||
* (Note that *line and *column must both be set to -1 initially) */
|
||||
static void get_line_and_column_from_filename(gchar *filename, gint *line, gint *column)
|
||||
{
|
||||
gsize i;
|
||||
gint colon_count = 0;
|
||||
gboolean have_number = FALSE;
|
||||
gsize len;
|
||||
|
||||
g_assert(*line == -1 && *column == -1);
|
||||
|
||||
if (! NZV(filename))
|
||||
return;
|
||||
|
||||
len = strlen(filename);
|
||||
for (i = len - 1; i >= 1; i--)
|
||||
{
|
||||
gboolean is_colon = filename[i] == ':';
|
||||
gboolean is_digit = g_ascii_isdigit(filename[i]);
|
||||
|
||||
if (! is_colon && ! is_digit)
|
||||
break;
|
||||
|
||||
if (is_colon)
|
||||
{
|
||||
if (++colon_count > 1)
|
||||
break; /* bail on 2+ colons in a row */
|
||||
}
|
||||
else
|
||||
colon_count = 0;
|
||||
|
||||
if (is_digit)
|
||||
have_number = TRUE;
|
||||
|
||||
if (is_colon && have_number)
|
||||
{
|
||||
gint number = atoi(&filename[i + 1]);
|
||||
|
||||
filename[i] = '\0';
|
||||
have_number = FALSE;
|
||||
|
||||
*column = *line;
|
||||
*line = number;
|
||||
}
|
||||
|
||||
if (*column >= 0)
|
||||
break; /* line and column are set, so we're done */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void setup_paths()
|
||||
{
|
||||
gchar *data_dir;
|
||||
@ -424,6 +478,23 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GOptionContext *context;
|
||||
gint i;
|
||||
|
||||
// first initialise cl_options fields with default values
|
||||
cl_options.load_session = TRUE;
|
||||
cl_options.goto_line = -1;
|
||||
cl_options.goto_column = -1;
|
||||
|
||||
// the GLib option parser can't handle the +NNN (line number) option,
|
||||
// so we grab that here and replace it with a no-op */
|
||||
for (i = 1; i < (*argc); i++)
|
||||
{
|
||||
if ((*argv)[i][0] != '+')
|
||||
continue;
|
||||
|
||||
cl_options.goto_line = atoi((*argv)[i] + 1);
|
||||
(*argv)[i] = "--dummy";
|
||||
}
|
||||
|
||||
context = g_option_context_new(_("[FILES...]"));
|
||||
g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
|
||||
@ -432,11 +503,6 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
|
||||
g_option_context_parse(context, argc, argv, &error);
|
||||
g_option_context_free(context);
|
||||
|
||||
// first initialise cl_options fields with default values
|
||||
cl_options.load_session = TRUE;
|
||||
cl_options.goto_line = -1;
|
||||
cl_options.goto_column = -1;
|
||||
|
||||
if (error != NULL)
|
||||
{
|
||||
g_printerr("Geany: %s\n", error->message);
|
||||
@ -520,8 +586,6 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
|
||||
|
||||
if (ft_names)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("Geany's internal filetype names:\n");
|
||||
filetypes_init_types();
|
||||
for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
|
||||
@ -597,6 +661,17 @@ static gboolean open_cl_files(gint argc, gchar **argv)
|
||||
{
|
||||
gchar *filename = get_argv_filename(argv[i]);
|
||||
|
||||
if (filename != NULL)
|
||||
{
|
||||
gint line = -1, column = -1;
|
||||
|
||||
get_line_and_column_from_filename(filename, &line, &column);
|
||||
if (line >= 0)
|
||||
cl_options.goto_line = line;
|
||||
if (column >= 0)
|
||||
cl_options.goto_column = column;
|
||||
}
|
||||
|
||||
if (filename != NULL &&
|
||||
g_file_test(filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user