Merge branch 'master' into rexy712
This commit is contained in:
commit
1c4bfb6446
@ -25,6 +25,9 @@ nano \- Nano's ANOther editor, inspired by Pico
|
||||
.B nano
|
||||
.RI [ options "] [[\fB+" line [\fB, column "]] " file ]...
|
||||
.sp
|
||||
.B nano
|
||||
.RI [ options "] [" file [\fB: line [\fB: column "]]]..."
|
||||
.sp
|
||||
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
|
||||
|
||||
.SH DESCRIPTION
|
||||
@ -36,7 +39,11 @@ syntax coloring, line numbering, and soft-wrapping overlong lines.
|
||||
When giving a filename on the command line, the cursor can be put on a
|
||||
specific line by adding the line number with a plus sign (\fB+\fR) before
|
||||
the filename, and even in a specific column by adding it with a comma.
|
||||
(Negative numbers count from the end of the file or line.)
|
||||
Negative numbers count from the end of the file or line.
|
||||
The line and column numbers may also be specified by gluing them with colons
|
||||
after the filename. (When a filename contains a colon followed by digits,
|
||||
escape the colon by preceding it with a triple backslash.)
|
||||
.sp
|
||||
The cursor can be put on the first or last occurrence of a specific string
|
||||
by specifying that string after \fB+/\fR or \fB+?\fR before the filename.
|
||||
The string can be made case sensitive and/or caused to be interpreted as a
|
||||
|
||||
@ -142,12 +142,17 @@ The usual way to invoke @command{nano} is:
|
||||
@blankline
|
||||
|
||||
But it is also possible to specify one or more options (@pxref{Command-line Options}),
|
||||
and to edit several files in a row. Additionally, the cursor
|
||||
can be put on a specific line of a file by adding the line number
|
||||
with a plus sign before the filename, and even in a specific column by
|
||||
adding it with a comma.
|
||||
(Negative numbers count from the end of the file or line.)
|
||||
The cursor can also be put on the first or last occurrence of a specific string
|
||||
and to edit several files in a row.
|
||||
|
||||
The cursor can be put on a specific line of a file by adding
|
||||
the line number with a plus sign before the filename, and even
|
||||
in a specific column by adding it with a comma.
|
||||
Negative numbers count from the end of the file or line.
|
||||
The line and column numbers may also be specified by gluing them with colons
|
||||
after the filename. (When a filename contains a colon followed by digits,
|
||||
escape the colon by preceding it with a triple backslash.)
|
||||
|
||||
The cursor can be put on the first or last occurrence of a specific string
|
||||
by specifying that string after @code{+/} or @code{+?} before the filename.
|
||||
The string can be made case sensitive and/or caused to be interpreted as a
|
||||
regular expression by inserting a @code{c} and/or @code{r} after the plus sign.
|
||||
|
||||
@ -447,7 +447,7 @@ typedef struct syntaxtype {
|
||||
/* The command with which to lint this type of file. */
|
||||
char *formatter;
|
||||
/* The command with which to format/modify/arrange this type of file. */
|
||||
char *tab;
|
||||
char *tabstring;
|
||||
/* What the Tab key should produce; NULL for default behavior. */
|
||||
#ifdef ENABLE_COMMENT
|
||||
char *comment;
|
||||
|
||||
28
src/nano.c
28
src/nano.c
@ -1114,7 +1114,7 @@ void toggle_this(int flag)
|
||||
refresh_needed = TRUE;
|
||||
break;
|
||||
case TABS_TO_SPACES:
|
||||
if (openfile->syntax && openfile->syntax->tab) {
|
||||
if (openfile->syntax && openfile->syntax->tabstring) {
|
||||
statusline(AHEM, _("Current syntax determines Tab"));
|
||||
TOGGLE(flag);
|
||||
return;
|
||||
@ -2213,7 +2213,7 @@ int main(int argc, char **argv)
|
||||
alt_speller = alt_speller_cmdline;
|
||||
}
|
||||
/* Strip leading whitespace from the speller command, if any. */
|
||||
while (alt_speller && *alt_speller && isblank(*alt_speller))
|
||||
while (alt_speller && (*alt_speller == ' ' || *alt_speller == '\t'))
|
||||
memmove(alt_speller, alt_speller + 1, strlen(alt_speller));
|
||||
#endif
|
||||
|
||||
@ -2451,7 +2451,7 @@ int main(int argc, char **argv)
|
||||
#ifndef NANO_TINY
|
||||
int n = 1;
|
||||
|
||||
while (isalpha(argv[optind][n])) {
|
||||
while (isalpha((unsigned char)argv[optind][n])) {
|
||||
switch (argv[optind][n++]) {
|
||||
case 'c': SET(CASE_SENSITIVE); break;
|
||||
case 'C': UNSET(CASE_SENSITIVE); break;
|
||||
@ -2490,8 +2490,26 @@ int main(int argc, char **argv)
|
||||
continue;
|
||||
} else
|
||||
#endif
|
||||
if (!open_buffer(argv[optind++], TRUE))
|
||||
{
|
||||
char *filename = argv[optind++];
|
||||
char *colon = filename + (*filename ? 1 : 0);
|
||||
|
||||
/* Search the filename for a colon. If the colon is preceded by
|
||||
* a backslash, elide the backslash and skip the colon. If there
|
||||
* is a valid number after the colon, chop colon and number off.
|
||||
* The number is later used to place the cursor on that line. */
|
||||
while ((colon = strchr(colon, ':'))) {
|
||||
if (*(colon - 1) == '\\')
|
||||
memmove(colon - 1, colon, strlen(colon) + 1);
|
||||
else if (parse_line_column(colon + 1, &givenline, &givencol))
|
||||
*colon = '\0';
|
||||
else
|
||||
++colon;
|
||||
}
|
||||
|
||||
if (!open_buffer(filename, TRUE))
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If a position was given on the command line, go there. */
|
||||
if (givenline != 0 || givencol != 0)
|
||||
@ -2555,7 +2573,7 @@ int main(int argc, char **argv)
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
if (startup_problem != NULL)
|
||||
statusline(ALERT, startup_problem);
|
||||
statusline(ALERT, "%s", startup_problem);
|
||||
|
||||
#define NOTREBOUND first_sc_for(MMAIN, do_help) && \
|
||||
first_sc_for(MMAIN, do_help)->keycode == 0x07
|
||||
|
||||
@ -674,7 +674,7 @@ void begin_new_syntax(char *ptr)
|
||||
live_syntax->magics = NULL;
|
||||
live_syntax->linter = NULL;
|
||||
live_syntax->formatter = NULL;
|
||||
live_syntax->tab = NULL;
|
||||
live_syntax->tabstring = NULL;
|
||||
#ifdef ENABLE_COMMENT
|
||||
live_syntax->comment = copy_of(GENERAL_COMMENT_CHARACTER);
|
||||
#endif
|
||||
@ -1325,7 +1325,7 @@ bool parse_syntax_commands(char *keyword, char *ptr)
|
||||
pick_up_name("comment", ptr, &live_syntax->comment);
|
||||
#endif
|
||||
} else if (strcmp(keyword, "tabgives") == 0) {
|
||||
pick_up_name("tabgives", ptr, &live_syntax->tab);
|
||||
pick_up_name("tabgives", ptr, &live_syntax->tabstring);
|
||||
} else if (strcmp(keyword, "linter") == 0)
|
||||
pick_up_name("linter", ptr, &live_syntax->linter);
|
||||
else if (strcmp(keyword, "formatter") == 0)
|
||||
|
||||
20
src/text.c
20
src/text.c
@ -65,8 +65,8 @@ void do_mark(void)
|
||||
void do_tab(void)
|
||||
{
|
||||
#ifdef ENABLE_COLOR
|
||||
if (openfile->syntax && openfile->syntax->tab)
|
||||
inject(openfile->syntax->tab, strlen(openfile->syntax->tab));
|
||||
if (openfile->syntax && openfile->syntax->tabstring)
|
||||
inject(openfile->syntax->tabstring, strlen(openfile->syntax->tabstring));
|
||||
else
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
@ -136,8 +136,8 @@ void do_indent(void)
|
||||
indentation = nmalloc(tabsize + 1);
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (openfile->syntax && openfile->syntax->tab)
|
||||
indentation = mallocstrcpy(indentation, openfile->syntax->tab);
|
||||
if (openfile->syntax && openfile->syntax->tabstring)
|
||||
indentation = mallocstrcpy(indentation, openfile->syntax->tabstring);
|
||||
else
|
||||
#endif
|
||||
/* Set the indentation to either a bunch of spaces or a single tab. */
|
||||
@ -175,10 +175,10 @@ size_t length_of_white(const char *text)
|
||||
size_t white_count = 0;
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (openfile->syntax && openfile->syntax->tab) {
|
||||
size_t thelength = strlen(openfile->syntax->tab);
|
||||
if (openfile->syntax && openfile->syntax->tabstring) {
|
||||
size_t thelength = strlen(openfile->syntax->tabstring);
|
||||
|
||||
while (text[white_count] == openfile->syntax->tab[white_count])
|
||||
while (text[white_count] == openfile->syntax->tabstring[white_count])
|
||||
if (++white_count == thelength)
|
||||
return thelength;
|
||||
|
||||
@ -2861,7 +2861,7 @@ void do_linter(void)
|
||||
confirm_margin();
|
||||
#endif
|
||||
edit_refresh();
|
||||
statusline(NOTICE, curlint->msg);
|
||||
statusline(NOTICE, "%s", curlint->msg);
|
||||
bottombars(MLINTER);
|
||||
}
|
||||
|
||||
@ -2893,7 +2893,7 @@ void do_linter(void)
|
||||
beep();
|
||||
napms(600);
|
||||
last_wait = time(NULL);
|
||||
statusline(NOTICE, curlint->msg);
|
||||
statusline(NOTICE, "%s", curlint->msg);
|
||||
}
|
||||
} else if (function == do_page_down || function == to_next_block) {
|
||||
if (curlint->next != NULL)
|
||||
@ -2903,7 +2903,7 @@ void do_linter(void)
|
||||
beep();
|
||||
napms(600);
|
||||
last_wait = time(NULL);
|
||||
statusline(NOTICE, curlint->msg);
|
||||
statusline(NOTICE, "%s", curlint->msg);
|
||||
}
|
||||
} else
|
||||
beep();
|
||||
|
||||
@ -137,7 +137,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
|
||||
while (*str == ' ')
|
||||
str++;
|
||||
|
||||
comma = strpbrk(str, "m,. /;");
|
||||
comma = strpbrk(str, ",.:");
|
||||
|
||||
if (comma == NULL)
|
||||
return parse_num(str, line);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user