diff --git a/src/search.c b/src/search.c index 79b315b2..387011ce 100644 --- a/src/search.c +++ b/src/search.c @@ -77,6 +77,13 @@ void search_init(bool replacing, bool keep_the_answer) char *thedefault; /* What will be searched for when the user typed nothing. */ +#ifdef ENABLE_HISTORIES + /* If nothing was searched for yet during this run of nano, but + * there is a search history, take the most recent item. */ + if (*last_search == '\0' && searchbot->prev != NULL) + last_search = mallocstrcpy(last_search, searchbot->prev->data); +#endif + /* When starting a new search, clear the current answer. */ if (!keep_the_answer) answer = mallocstrcpy(answer, NULL); diff --git a/syntax/c.nanorc b/syntax/c.nanorc index 8cb81b15..76cf9c9d 100644 --- a/syntax/c.nanorc +++ b/syntax/c.nanorc @@ -7,27 +7,32 @@ comment "//" # Constants. color brightred "\<[A-Z_][0-9A-Z_]+\>" # Labels. -color brightmagenta "^[[:space:]]*[A-Z_a-z]+:[[:space:]]*$" +###color brightmagenta "^[[:space:]]*[A-Z_a-z]+:[[:space:]]*$" -color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto|static|const|struct|union|typedef|extern|(un)?signed|inline)\>" -color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>" -color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|override|using|mutable|volatile|register|explicit)\>" +color green "\<(float|double|bool|true|false|char|int|short|long|sizeof|align(as|of)|decltype|typeid|enum|void|auto|static|const|struct|union|typedef|extern|(un)?signed|inline|constexpr|thread_local|restrict|_Complex|_Bool|_Imaginary|_Atomic|_Thread_local|_Noreturn|_Align(as|of))\>" +color green "\<((s?size)|ptrdiff|(u?int((_(fast|least))?(8|16|32|64)|ptr|max))|wchar|char(16|32))_t\>" +color green "\<(class|namespace|template|public|protected|private|typename|this|nullptr|friend|virtual|override|final|noexcept|using|mutable|volatile|register|explicit|export)\>" color brightyellow "\<(for|if|while|do|else|case|default|switch)\>" -color brightyellow "\<(try|throw|catch|operator|new|delete)\>" +color brightyellow "\<(try|throw|catch|operator|new|delete|(static|dynamic|const|reinterpret)_cast|static_assert|_Static_assert)\>" color magenta "\<(goto|continue|break|return)\>" -color brightcyan "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)" color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'" +color brightgreen "\<(_Pragma|__has_include|_Generic)\>" # GCC builtins. color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" # Strings. In general you will want your strings and comments to come last, # because highlighting rules are applied in the order they are read in. -color brightyellow ""([^"]|\\")*"" "<[^[:blank:]=]*>" +color brightyellow ""([^"]|\\")*"" # Multiline strings. This regex is VERY resource intensive, # and sometimes colours things that shouldn't be coloured. ###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*"" +# Preprocessor directives. +color brightgreen "#[[:space:]]*include[[:space:]]+((<[^>]*>)|("[^"]*"))" +color brightcyan start="^[[:space:]]*#[[:space:]]*(define|undef|if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$" +color brightcyan "^[[:space:]]*#[[:space:]]*(else|endif|include(_next)?)\>" + # Comments. color brightblue "//.*" color brightblue start="/\*" end="\*/" diff --git a/syntax/default.nanorc b/syntax/default.nanorc index 665f54e4..5c543040 100644 --- a/syntax/default.nanorc +++ b/syntax/default.nanorc @@ -15,3 +15,6 @@ color brightred "(GNU )?nano [1-9]\.[0-9]\.[^[:space:][:punct:]]+" # Email addresses. color magenta "<[[:alnum:address@hidden:alnum:].-]+\.[[:alpha:]]{2,}>" + +## Trailing whitespace. +color ,green "[[:space:]]+$"