From 90ee8ee494228cdc11d3c5282442655c253a04c8 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Thu, 20 Mar 2008 04:45:55 +0000 Subject: [PATCH] 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 --- ChangeLog | 13 ++++++++-- doc/syntax/gentoo.nanorc | 50 ++++++++++++++++++++++++++++++++++++++ doc/syntax/php.nanorc | 30 +++++++++++++++++++++++ doc/syntax/tcl.nanorc | 16 +++++++++++++ src/global.c | 6 ++++- src/rcfile.c | 52 ++++++++++++++++++++-------------------- src/winio.c | 1 - 7 files changed, 138 insertions(+), 30 deletions(-) create mode 100644 doc/syntax/gentoo.nanorc create mode 100644 doc/syntax/php.nanorc create mode 100644 doc/syntax/tcl.nanorc diff --git a/ChangeLog b/ChangeLog index 58b5963d..eb2a8166 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,16 @@ +2008-03-17 Mike Frysinger + * 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 - * 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 * */.gitignore: Git ignore files for those running a local git diff --git a/doc/syntax/gentoo.nanorc b/doc/syntax/gentoo.nanorc new file mode 100644 index 00000000..6e3470b8 --- /dev/null +++ b/doc/syntax/gentoo.nanorc @@ -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)\>" "\" "\" "\" +## Highlight portage commands +color magenta "\ [!a-zA-Z0-9_+ -]*" "inherit.*" +color brightblue "\" +color brightblue "\" "\" "\" "\" "\<(has|best)_version\>" "\" +color brightblue "\<(do|new)(ins|s?bin|doc|lib(|\.so|\.a)|man|info|exe|initd|confd|envd|pam|menu|icon)\>" +color brightblue "\" "\" +color brightblue "prepall(|docs|info|man|strip)" "prep(info|lib|lib\.(so|a)|man|strip)" +color brightblue "\<(|doc|ins|exe)into\>" "\" "\<(exe|ins|dir)opts\>" +## Highlight common commands used in ebuilds +color blue "\" "\<(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 "#.*$" diff --git a/doc/syntax/php.nanorc b/doc/syntax/php.nanorc new file mode 100644 index 00000000..8ef495f6 --- /dev/null +++ b/doc/syntax/php.nanorc @@ -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:]]+$" diff --git a/doc/syntax/tcl.nanorc b/doc/syntax/tcl.nanorc new file mode 100644 index 00000000..15526c1a --- /dev/null +++ b/doc/syntax/tcl.nanorc @@ -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:]]+|)#.*" diff --git a/src/global.c b/src/global.c index cb26c26a..49633589 100644 --- a/src/global.c +++ b/src/global.c @@ -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"), diff --git a/src/rcfile.c b/src/rcfile.c index 253a321d..5714d063 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -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 */ diff --git a/src/winio.c b/src/winio.c index a692b0b9..cd699c45 100644 --- a/src/winio.c +++ b/src/winio.c @@ -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); -- 2.39.5