Add Mike F's latest patches for 2.1.0 and new syntax configs for tcl, php and gentoo.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4242 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Chris Allegretta 2008-03-20 04:45:55 +00:00
parent 690e7df997
commit 90ee8ee494
7 changed files with 138 additions and 30 deletions

View File

@ -1,7 +1,16 @@
2008-03-17 Mike Frysinger <vapier@gentoo.org>
* winio.c: Remove unneeded variable in parse_kbinput()
* rcfile.c: relocate check_vitals_mapped() function to just above
where it actually gets used and declare it "static void" in the process
* global.c: only declare nano_justify_msg when justify support is enabled
* php.nanorc: Php syntax highlighting config
* tcl.nanorc: Tcl syntax highlighting config
* gentoo.nanorc: Gentoo syntax highlighting config
2008-03-17 Benno Schulenberg <bensberg@justemail.net>
* global.c - Fix incorrect first line jump messsage, fix
* global.c: Fix incorrect first line jump messsage, fix
more comments to assist translators
* winio.c - Fix shortcut labels not being translated.
* winio.c: Fix shortcut labels not being translated.
2008-03-17 Mike Frysinger <vapier@gentoo.org>
* */.gitignore: Git ignore files for those running a local git

50
doc/syntax/gentoo.nanorc Normal file
View File

@ -0,0 +1,50 @@
## Here is an example for Gentoo ebuilds/eclasses
##
syntax "ebuild" "\.e(build|class)$"
## All the standard portage functions
color brightgreen "^src_(unpack|compile|install|test)" "^pkg_(config|nofetch|setup|(pre|post)(inst|rm))"
## Highlight bash related syntax
color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while|continue|break)\>"
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
color green "-(e|d|f|r|g|u|w|x|L)\>"
color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>"
## Highlight variables ... official portage ones in red, all others in bright red
color brightred "\$\{?[a-zA-Z_0-9]+\}?"
color red "\<(ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|FILESDIR|WORKDIR|(P|R)?DEPEND|PROVIDE|DISTDIR|RESTRICT|USERLAND)\>"
color red "\<(S|D|T|PV|PF|P|PN|A)\>" "\<C(XX)?FLAGS\>" "\<LDFLAGS\>" "\<C(HOST|TARGET|BUILD)\>"
## Highlight portage commands
color magenta "\<use(_(with|enable))?\> [!a-zA-Z0-9_+ -]*" "inherit.*"
color brightblue "\<e(begin|end|conf|install|make|warn|infon?|error|log|patch|new(group|user))\>"
color brightblue "\<die\>" "\<use(_(with|enable))?\>" "\<inherit\>" "\<has\>" "\<(has|best)_version\>" "\<unpack\>"
color brightblue "\<(do|new)(ins|s?bin|doc|lib(|\.so|\.a)|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
color brightblue "\<do(python|sed|dir|hard|sym|html|jar|mo)\>" "\<keepdir\>"
color brightblue "prepall(|docs|info|man|strip)" "prep(info|lib|lib\.(so|a)|man|strip)"
color brightblue "\<(|doc|ins|exe)into\>" "\<f(owners|perms)\>" "\<(exe|ins|dir)opts\>"
## Highlight common commands used in ebuilds
color blue "\<make\>" "\<(cat|cd|chmod|chown|cp|echo|env|export|grep|let|ln|mkdir|mv|rm|sed|set|tar|touch|unset)\>"
## Highlight comments (doesnt work that well)
color yellow "#.*$"
## Highlight strings (doesnt work that well)
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
## Trailing space is bad!
color ,green "[[:space:]]+$"
## Here is an example for Portage control files
##
syntax "/etc/portage" "\.(keywords|mask|unmask|use)$"
## Base text:
color green "^.+$"
## Use flags:
color brightred "[[:space:]]+\+?[a-zA-Z0-9_-]+"
color brightblue "[[:space:]]+-[a-zA-Z0-9_-]+"
## Likely version numbers:
color magenta "-[[:digit:]].*([[:space:]]|$)"
## Accepted arches:
color white "[~-]?\<(alpha|amd64|arm|hppa|ia64|mips|ppc|ppc64|s390|sh|sparc|x86|x86-fbsd)\>"
color white "[[:space:]][~-]?\*"
## Categories:
color cyan "^[[:space:]]*.*/"
## Masking regulators:
color brightmagenta "^[[:space:]]*(=|~|<|<=|=<|>|>=|=>)"
## Comments:
color yellow "#.*$"

30
doc/syntax/php.nanorc Normal file
View File

@ -0,0 +1,30 @@
## Here is an example for PHP
##
syntax "php" "\.php[2345s~]?$"
## php markings
color brightgreen "(<\?(php)?|\?>)"
## functions
color white "\<[a-z_]*\("
## types
color green "\<(var|float|global|double|bool|char|int|enum|const)\>"
## structure
color brightyellow "\<(class|new|private|public|function|for|foreach|if|while|do|else|elseif|case|default|switch)\>"
## control flow
color magenta "\<(goto|continue|break|return)\>"
## strings
color brightyellow "<[^= ]*>" ""(\.|[^"])*""
## comments
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
#color blue start="<" end=">"
#color red "&[^;[[:space:]]]*;"
## Trailing whitespace
color ,green "[[:space:]]+$"

16
doc/syntax/tcl.nanorc Normal file
View File

@ -0,0 +1,16 @@
syntax "tcl" "\.tcl$"
## Standard Tcl [info commands]
color green "\<(after|append|array|auto_execok|auto_import|auto_load|auto_load_index|auto_qualify|binary|break|case|catch|cd|clock|close|concat|continue|encoding|eof|error|eval|exec|exit|expr|fblocked|fconfigure|fcopy|file|fileevent|flush|for|foreach|format|gets|glob|global|history|if|incr|info|interp|join|lappend|lindex|linsert|list|llength|load|lrange|lreplace|lsearch|lset|lsort|namespace|open|package|pid|puts|pwd|read|regexp|regsub|rename|return|scan|seek|set|socket|source|split|string|subst|switch|tclLog|tell|time|trace|unknown|unset|update|uplevel|upvar|variable|vwait|while)\>"
## Basic Tcl sub commands.
color green "\<(array anymore|array donesearch|array exists|array get|array names|array nextelement|array set|array size|array startsearch|array statistics|array unset)\>"
color green "\<(string bytelength|string compare|string equal|string first|string index|string is|string last|string length|string map|string match|string range|string repeat|string replace|string to|string tolower|string totitle|string toupper|string trim|string trimleft|string trimright|string will|string wordend|string wordstart)\>"
## Extended TclX [info commands]
color green "\<(alarm|auto_load_pkg|bsearch|catclose|catgets|catopen|ccollate|cconcat|cequal|chgrp|chmod|chown|chroot|cindex|clength|cmdtrace|commandloop|crange|csubstr|ctoken|ctype|dup|echo|execl|fcntl|flock|fork|fstat|ftruncate|funlock|host_info|id|infox|keyldel|keylget|keylkeys|keylset|kill|lassign|lcontain|lempty|lgets|link|lmatch|loadlibindex|loop|lvarcat|lvarpop|lvarpush|max|min|nice|pipe|profile|random|readdir|replicate|scancontext|scanfile|scanmatch|select|server_accept|server_create|signal|sleep|sync|system|tclx_findinit|tclx_fork|tclx_load_tndxs|tclx_sleep|tclx_system|tclx_wait|times|translit|try_eval|umask|wait)\>"
## Syntax.
color brightblue "proc[[:space:]]" "(\{|\})"
color green "(\(|\)|\;|`|\\|\$|<|>|!|=|&|\|)"
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?"
color ,green "[[:space:]]+$"
color ,magenta "^([[:space:]]+|)#.*"

View File

@ -501,7 +501,9 @@ void shortcut_init(bool unjustify)
;
const char *nano_writeout_msg =
N_("Write the current file to disk");
#ifndef DISABLE_JUSTIFY
const char *nano_justify_msg = N_("Justify the current paragraph");
#endif
const char *nano_insert_msg =
N_("Insert another file into the current one");
const char *nano_whereis_msg =
@ -658,7 +660,9 @@ void shortcut_init(bool unjustify)
#endif
exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
add_to_funcs(do_exit, MBROWSER|MHELP, exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
add_to_funcs(do_exit, MHELP, exit_msg, IFSCHELP(nano_exit_msg), FALSE, VIEW);
add_to_funcs(do_exit, MBROWSER, exit_msg, IFSCHELP(nano_exitbrowser_msg), FALSE, VIEW);
/* TRANSLATORS: Try to keep this at most 10 characters. */
add_to_funcs(do_writeout_void, MMAIN, N_("WriteOut"),

View File

@ -690,6 +690,32 @@ void parse_colors(char *ptr, bool icase)
}
#endif /* ENABLE_COLOR */
/* Check whether the user has unmapped every shortcut for a
sequence we consider 'vital', like the exit function */
static void check_vitals_mapped(void)
{
subnfunc *f;
int v;
#define VITALS 5
void *vitals[VITALS] = { do_exit, do_exit, (void *) cancel_msg, (void *) cancel_msg, (void *) cancel_msg };
int inmenus[VITALS] = { MMAIN, MHELP, MWHEREIS, MREPLACE, MGOTOLINE };
for (v = 0; v < VITALS; v++) {
for (f = allfuncs; f != NULL; f = f->next) {
if (f->scfunc == vitals[v] && f->menus & inmenus[v]) {
const sc *s = first_sc_for(inmenus[v], f->scfunc);
if (!s) {
rcfile_error(N_("Fatal error: no keys mapped for function \"%s\""),
f->desc);
fprintf(stderr, N_("Exiting. Please use nano with the -I option if needed to adjust your nanorc settings\n"));
exit(1);
}
break;
}
}
}
}
/* Parse the rcfile, once it has been opened successfully at rcstream,
* and close it afterwards. If syntax_only is TRUE, only allow the file
* to contain color syntax commands: syntax, color, and icolor. */
@ -1022,30 +1048,4 @@ void do_rcfile(void)
#endif
}
/* Check whether the user has unmapped every shortcut for a
sequence we consider 'vital', like the exit function */
int check_vitals_mapped(void)
{
subnfunc *f;
int v;
#define VITALS 5
void *vitals[VITALS] = { do_exit, do_exit, (void *) cancel_msg, (void *) cancel_msg, (void *) cancel_msg };
int inmenus[VITALS] = { MMAIN, MHELP, MWHEREIS, MREPLACE, MGOTOLINE };
for (v = 0; v < VITALS; v++) {
for (f = allfuncs; f != NULL; f = f->next) {
if (f->scfunc == vitals[v] && f->menus & inmenus[v]) {
const sc *s = first_sc_for(inmenus[v], f->scfunc);
if (!s) {
rcfile_error(N_("Fatal error: no keys mapped for function \"%s\""),
f->desc);
fprintf(stderr, N_("Exiting. Please use nano with the -I option if needed to adjust your nanorc settings\n"));
exit(1);
}
break;
}
}
}
}
#endif /* ENABLE_NANORC */

View File

@ -329,7 +329,6 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
*meta_key = FALSE;
*func_key = FALSE;
const sc *s;
/* Read in a character. */
while ((kbinput = get_input(win, 1)) == NULL);