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
master
David Lawrence Ramsey 2005-05-16 18:38:16 +00:00
parent 6e925cf330
commit 775eeba38a
4 changed files with 53 additions and 22 deletions

View File

@ -13,6 +13,10 @@ CVS code -
nanogetstr(), and do_statusbar_input(). (DLR) nanogetstr(), and do_statusbar_input(). (DLR)
- Update the Free Software Foundation's mailing address in - Update the Free Software Foundation's mailing address in
various comments. (DLR) 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.c:
cut_line() cut_line()
- Set placewewant properly after cutting a line, to avoid a - Set placewewant properly after cutting a line, to avoid a

View File

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

View File

@ -9,7 +9,7 @@
@smallbook @smallbook
@set EDITION 0.1 @set EDITION 0.1
@set VERSION 1.3.7 @set VERSION 1.3.7
@set UPDATED 26 Mar 2005 @set UPDATED 16 May 2005
@dircategory Editors @dircategory Editors
@direntry @direntry
@ -91,7 +91,7 @@ internationalization support, and filename tab completion.
@node Overview, Command Line Options, Introduction, Introduction @node Overview, Command Line Options, Introduction, Introduction
@section Overview @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 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 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: @code{nano} takes the following options from the command line:
@table @code @table @code
@item +LINE @item +LINE,COLUMN
Start at line number LINE instead of the default of line 1. Start at line number LINE and column number COLUMN instead of the
default of line 1, column 1.
@item -? @item -?
Same as @code{-h, --help}. Same as @code{-h, --help}.

View File

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