1
1

add the ability to open a file on a specified column as well as a

specified line, by allowing an argument of the form +LINE,COLUMN


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2514 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
David Lawrence Ramsey 2005-05-16 18:38:16 +00:00
родитель 6e925cf330
Коммит 775eeba38a
4 изменённых файлов: 53 добавлений и 22 удалений

Просмотреть файл

@ -13,6 +13,10 @@ CVS code -
nanogetstr(), and do_statusbar_input(). (DLR)
- Update the Free Software Foundation's mailing address in
various comments. (DLR)
- Add the ability to open a file on a specified column as well
as a specified line, by allowing an argument of the form
+LINE,COLUMN. Changes to main(), nano.1, and nano.texi. (DLR,
suggested by PFTank)
- cut.c:
cut_line()
- Set placewewant properly after cutting a line, to avoid a

Просмотреть файл

@ -6,7 +6,7 @@
.\" Public License for copying conditions. There is NO warranty.
.\"
.\" $Id$
.TH NANO 1 "version 1.3.7" "March 26, 2005"
.TH NANO 1 "version 1.3.7" "May 16, 2005"
.\" Please adjust this date whenever revising the manpage.
.\"
@ -15,7 +15,7 @@ nano \- Nano's ANOther editor, an enhanced free Pico clone
.SH SYNOPSIS
.B nano
.I [\+LINE]\ [options]\ [file]
.I [\+LINE,COLUMN]\ [options]\ [file]
.br
.SH DESCRIPTION
@ -32,9 +32,9 @@ replace" and "go to line number".
.SH OPTIONS
.TP
.B \+\fILINE\fP
Places cursor at line number \fILINE\fP on startup, instead of the
default of line 1.
.B \+\fILINE\fP,\fICOLUMN\fP]
Places cursor at line number \fILINE\fP and column number \fICOLUMN\fP
on startup, instead of the default of line 1, column 1.
.TP
.B \-?
Same as \fB-h (\-\-help)\fP.

Просмотреть файл

@ -9,7 +9,7 @@
@smallbook
@set EDITION 0.1
@set VERSION 1.3.7
@set UPDATED 26 Mar 2005
@set UPDATED 16 May 2005
@dircategory Editors
@direntry
@ -91,7 +91,7 @@ internationalization support, and filename tab completion.
@node Overview, Command Line Options, Introduction, Introduction
@section Overview
@code{nano} +LINE [GNU long option] [option] [ @var{file ...} ]
@code{nano} +LINE,COLUMN [GNU long option] [option] [ @var{file ...} ]
The original goal for @code{nano} was a complete bug-for-bug compatible
emulation of Pico, but @code{nano}'s main goal is to be as compatible as
@ -106,8 +106,9 @@ Email bug reports to @email{nano@@nano-editor.org}.
@code{nano} takes the following options from the command line:
@table @code
@item +LINE
Start at line number LINE instead of the default of line 1.
@item +LINE,COLUMN
Start at line number LINE and column number COLUMN instead of the
default of line 1, column 1.
@item -?
Same as @code{-h, --help}.

Просмотреть файл

@ -1002,7 +1002,7 @@ void print1opt_full(const char *shortflag
void usage(void)
{
#ifdef HAVE_GETOPT_LONG
printf(_("Usage: nano [+LINE] [GNU long option] [option] [file]\n\n"));
printf(_("Usage: nano [+LINE,COLUMN] [GNU long option] [option] [file]\n\n"));
printf(_("Option\t\tLong option\t\tMeaning\n"));
#else
printf(_("Usage: nano [+LINE] [option] [file]\n\n"));
@ -1010,7 +1010,7 @@ void usage(void)
#endif
print1opt("-h, -?", "--help", N_("Show this message"));
print1opt(_("+LINE"), "", N_("Start at line number LINE"));
print1opt(_("+LINE,COLUMN"), "", N_("Start at line LINE, column COLUMN"));
#ifndef NANO_SMALL
print1opt("-A", "--smarthome", N_("Enable smart home key"));
print1opt("-B", "--backup", N_("Backup existing files on save"));
@ -3961,8 +3961,10 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
int main(int argc, char **argv)
{
int optchr;
int startline = 0;
int startline = 1;
/* Line to try and start at. */
ssize_t startcol = 1;
/* Column to try and start at. */
#ifndef DISABLE_WRAPJUSTIFY
bool fill_flag_used = FALSE;
/* Was the fill option used? */
@ -4421,10 +4423,16 @@ int main(int argc, char **argv)
fprintf(stderr, "Main: open file\n");
#endif
/* If there's a +LINE flag here, it is the first non-option
* argument, and it is followed by at least one other argument, the
* filename it applies to. */
/* If there's a +LINE or +LINE,COLUMN flag here, it is the first
* non-option argument, and it is followed by at least one other
* argument, the filename it applies to. */
if (0 < optind && optind < argc - 1 && argv[optind][0] == '+') {
char *comma = strchr(&argv[optind][1], ',');
if (comma != NULL)
parse_num(&argv[optind][comma - argv[optind] + 1],
&startcol);
startline = atoi(&argv[optind][1]);
optind++;
}
@ -4436,17 +4444,32 @@ int main(int argc, char **argv)
/* Read all the files after the first one on the command line into
* new buffers. */
{
int i = optind + 1, iline = 0;
int i = optind + 1, iline = 1;
ssize_t icol = 1;
for (; i < argc; i++) {
/* If there's a +LINE flag here, it is followed by at least
* one other argument, the filename it applies to. */
if (i < argc - 1 && argv[i][0] == '+' && iline == 0) {
/* If there's a +LINE or +LINE,COLUMN flag here, it is
* followed by at least one other argument, the filename it
* applies to. */
if (i < argc - 1 && argv[i][0] == '+' && iline == 1 &&
icol == 1) {
char *comma = strchr(&argv[i][1], ',');
if (comma != NULL)
parse_num(&argv[i][comma - argv[i] + 1], &icol);
iline = atoi(&argv[i][1]);
} else {
load_buffer(argv[i]);
if (iline > 0) {
if (iline > 1) {
do_gotoline(iline, FALSE);
iline = 0;
iline = 1;
}
if (icol > 1) {
current_x = actual_x(current->data, icol - 1);
icol = 1;
}
}
}
@ -4485,9 +4508,12 @@ int main(int argc, char **argv)
titlebar(NULL);
display_main_list();
if (startline > 0)
if (startline > 1)
do_gotoline(startline, FALSE);
if (startcol > 1)
current_x = actual_x(current->data, startcol - 1);
#ifndef NANO_SMALL
/* Return here after a SIGWINCH. */
sigsetjmp(jmpbuf, 1);