Merge branch 'master' into rexy712

This commit is contained in:
rexy712 2023-03-30 17:30:43 -07:00
commit 1c4bfb6446
7 changed files with 57 additions and 27 deletions

View File

@ -25,6 +25,9 @@ nano \- Nano's ANOther editor, inspired by Pico
.B nano .B nano
.RI [ options "] [[\fB+" line [\fB, column "]] " file ]... .RI [ options "] [[\fB+" line [\fB, column "]] " file ]...
.sp .sp
.B nano
.RI [ options "] [" file [\fB: line [\fB: column "]]]..."
.sp
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]... .BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
.SH DESCRIPTION .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 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 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. 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 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. 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 The string can be made case sensitive and/or caused to be interpreted as a

View File

@ -142,12 +142,17 @@ The usual way to invoke @command{nano} is:
@blankline @blankline
But it is also possible to specify one or more options (@pxref{Command-line Options}), 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 and to edit several files in a row.
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 The cursor can be put on a specific line of a file by adding
adding it with a comma. the line number with a plus sign before the filename, and even
(Negative numbers count from the end of the file or line.) in a specific column by adding it with a comma.
The cursor can also be put on the first or last occurrence of a specific string 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. 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 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. regular expression by inserting a @code{c} and/or @code{r} after the plus sign.

View File

@ -447,7 +447,7 @@ typedef struct syntaxtype {
/* The command with which to lint this type of file. */ /* The command with which to lint this type of file. */
char *formatter; char *formatter;
/* The command with which to format/modify/arrange this type of file. */ /* 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. */ /* What the Tab key should produce; NULL for default behavior. */
#ifdef ENABLE_COMMENT #ifdef ENABLE_COMMENT
char *comment; char *comment;

View File

@ -1114,7 +1114,7 @@ void toggle_this(int flag)
refresh_needed = TRUE; refresh_needed = TRUE;
break; break;
case TABS_TO_SPACES: case TABS_TO_SPACES:
if (openfile->syntax && openfile->syntax->tab) { if (openfile->syntax && openfile->syntax->tabstring) {
statusline(AHEM, _("Current syntax determines Tab")); statusline(AHEM, _("Current syntax determines Tab"));
TOGGLE(flag); TOGGLE(flag);
return; return;
@ -2213,7 +2213,7 @@ int main(int argc, char **argv)
alt_speller = alt_speller_cmdline; alt_speller = alt_speller_cmdline;
} }
/* Strip leading whitespace from the speller command, if any. */ /* 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)); memmove(alt_speller, alt_speller + 1, strlen(alt_speller));
#endif #endif
@ -2451,7 +2451,7 @@ int main(int argc, char **argv)
#ifndef NANO_TINY #ifndef NANO_TINY
int n = 1; int n = 1;
while (isalpha(argv[optind][n])) { while (isalpha((unsigned char)argv[optind][n])) {
switch (argv[optind][n++]) { switch (argv[optind][n++]) {
case 'c': SET(CASE_SENSITIVE); break; case 'c': SET(CASE_SENSITIVE); break;
case 'C': UNSET(CASE_SENSITIVE); break; case 'C': UNSET(CASE_SENSITIVE); break;
@ -2490,8 +2490,26 @@ int main(int argc, char **argv)
continue; continue;
} else } else
#endif #endif
if (!open_buffer(argv[optind++], TRUE)) {
continue; 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 a position was given on the command line, go there. */
if (givenline != 0 || givencol != 0) if (givenline != 0 || givencol != 0)
@ -2555,7 +2573,7 @@ int main(int argc, char **argv)
#ifdef ENABLE_NANORC #ifdef ENABLE_NANORC
if (startup_problem != NULL) if (startup_problem != NULL)
statusline(ALERT, startup_problem); statusline(ALERT, "%s", startup_problem);
#define NOTREBOUND first_sc_for(MMAIN, do_help) && \ #define NOTREBOUND first_sc_for(MMAIN, do_help) && \
first_sc_for(MMAIN, do_help)->keycode == 0x07 first_sc_for(MMAIN, do_help)->keycode == 0x07

View File

@ -674,7 +674,7 @@ void begin_new_syntax(char *ptr)
live_syntax->magics = NULL; live_syntax->magics = NULL;
live_syntax->linter = NULL; live_syntax->linter = NULL;
live_syntax->formatter = NULL; live_syntax->formatter = NULL;
live_syntax->tab = NULL; live_syntax->tabstring = NULL;
#ifdef ENABLE_COMMENT #ifdef ENABLE_COMMENT
live_syntax->comment = copy_of(GENERAL_COMMENT_CHARACTER); live_syntax->comment = copy_of(GENERAL_COMMENT_CHARACTER);
#endif #endif
@ -1325,7 +1325,7 @@ bool parse_syntax_commands(char *keyword, char *ptr)
pick_up_name("comment", ptr, &live_syntax->comment); pick_up_name("comment", ptr, &live_syntax->comment);
#endif #endif
} else if (strcmp(keyword, "tabgives") == 0) { } 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) } else if (strcmp(keyword, "linter") == 0)
pick_up_name("linter", ptr, &live_syntax->linter); pick_up_name("linter", ptr, &live_syntax->linter);
else if (strcmp(keyword, "formatter") == 0) else if (strcmp(keyword, "formatter") == 0)

View File

@ -65,8 +65,8 @@ void do_mark(void)
void do_tab(void) void do_tab(void)
{ {
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
if (openfile->syntax && openfile->syntax->tab) if (openfile->syntax && openfile->syntax->tabstring)
inject(openfile->syntax->tab, strlen(openfile->syntax->tab)); inject(openfile->syntax->tabstring, strlen(openfile->syntax->tabstring));
else else
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
@ -136,8 +136,8 @@ void do_indent(void)
indentation = nmalloc(tabsize + 1); indentation = nmalloc(tabsize + 1);
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
if (openfile->syntax && openfile->syntax->tab) if (openfile->syntax && openfile->syntax->tabstring)
indentation = mallocstrcpy(indentation, openfile->syntax->tab); indentation = mallocstrcpy(indentation, openfile->syntax->tabstring);
else else
#endif #endif
/* Set the indentation to either a bunch of spaces or a single tab. */ /* 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; size_t white_count = 0;
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
if (openfile->syntax && openfile->syntax->tab) { if (openfile->syntax && openfile->syntax->tabstring) {
size_t thelength = strlen(openfile->syntax->tab); 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) if (++white_count == thelength)
return thelength; return thelength;
@ -2861,7 +2861,7 @@ void do_linter(void)
confirm_margin(); confirm_margin();
#endif #endif
edit_refresh(); edit_refresh();
statusline(NOTICE, curlint->msg); statusline(NOTICE, "%s", curlint->msg);
bottombars(MLINTER); bottombars(MLINTER);
} }
@ -2893,7 +2893,7 @@ void do_linter(void)
beep(); beep();
napms(600); napms(600);
last_wait = time(NULL); last_wait = time(NULL);
statusline(NOTICE, curlint->msg); statusline(NOTICE, "%s", curlint->msg);
} }
} else if (function == do_page_down || function == to_next_block) { } else if (function == do_page_down || function == to_next_block) {
if (curlint->next != NULL) if (curlint->next != NULL)
@ -2903,7 +2903,7 @@ void do_linter(void)
beep(); beep();
napms(600); napms(600);
last_wait = time(NULL); last_wait = time(NULL);
statusline(NOTICE, curlint->msg); statusline(NOTICE, "%s", curlint->msg);
} }
} else } else
beep(); beep();

View File

@ -137,7 +137,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
while (*str == ' ') while (*str == ' ')
str++; str++;
comma = strpbrk(str, "m,. /;"); comma = strpbrk(str, ",.:");
if (comma == NULL) if (comma == NULL)
return parse_num(str, line); return parse_num(str, line);