| View previous topic :: View next topic |
| Author |
Message |
boniek Guru


Joined: 26 Mar 2005 Posts: 373
|
|
| Back to top |
|
 |
ryszardzonk Tux's lil' helper


Joined: 18 Dec 2003 Posts: 138 Location: Rzeszów, POLAND
|
Posted: Sat Dec 02, 2006 11:06 am Post subject: great stuff |
|
|
Thanks for this great stuff of which I take advantage for long time now. My question is however is there someone to make the *.po and ChangeLog file syntax for the greater benefit of human kind One might use this Midnight Commander syntax to help us little people out
mc changelog syntax
| Code: | context default
spellcheck
context linestart \t \n\n
keyword wholeright +() brightmagenta
keyword linestart \t\*\s*: brightcyan
keyword (*): cyan
keyword (*)\{\s\}[*]: cyan
context linestart \s\s\s\s\s\s\s\s \n\n
keyword wholeright +() brightmagenta
keyword \*\s*: brightcyan
keyword (*): cyan
keyword (*)\{\s\}[*]: cyan
keyword whole \* brightcyan
context linestart 19+-+\s \n yellow
keyword <+> brightred
context linestart 20+-+\s \n yellow
keyword <+> brightred
context linestart Mon\s \n yellow
keyword <+> brightred
context linestart Tue\s \n yellow
keyword <+> brightred
context linestart Wed\s \n yellow
keyword <+> brightred
context linestart Thu\s \n yellow
keyword <+> brightred
context linestart Fri\s \n yellow
keyword <+> brightred
context linestart Sat\s \n yellow
keyword <+> brightred
context linestart Sun\s \n yellow
keyword <+> brightred |
*.po syntax
| Code: | context default
keyword linestart msgstr\s\"\"\n\n brightred
keyword linestart msgid brightcyan
keyword linestart msgstr brightcyan
context linestart #,\sfuzzy \n\n brightred
context linestart #: \n white
context linestart #, \n white
keyword c-format yellow
context linestart #~ \n red
context linestart # \n brown
spellcheck
context exclusive linestart msgid \n cyan
spellcheck
keyword \"\n\"
keyword \\" brightgreen
keyword \\\n brightgreen
keyword %% brightgreen
keyword %\[#0\s-\+,\]\[0123456789\]\[.\]\[0123456789\]\[L\]\{eEfgG\} brightgreen
keyword %\[0\s-\+,\]\[0123456789\]\[.\]\[0123456789\]\[hl\]\{diouxX\} brightgreen
keyword %\[hl\]n brightgreen
keyword %\[.\]\[0123456789\]s brightgreen
keyword %[*] brightgreen
keyword %c brightgreen
keyword \\\{0123\}\{01234567\}\{01234567\} brightgreen
keyword \\\\ brightgreen
keyword \\' brightgreen
keyword \\\{abtnvfr\} brightgreen
context exclusive linestart msgstr \n green
spellcheck
keyword \"\n\"
keyword \\" brightgreen
keyword \\\n brightgreen
keyword %% brightgreen
keyword %\[#0\s-\+,\]\[0123456789\]\[.\]\[0123456789\]\[L\]\{eEfgG\} brightgreen
keyword %\[0\s-\+,\]\[0123456789\]\[.\]\[0123456789\]\[hl\]\{diouxX\} brightgreen
keyword %\[hl\]n brightgreen
keyword %\[.\]\[0123456789\]s brightgreen
keyword %[*] brightgreen
keyword %c brightgreen
keyword \\\{0123\}\{01234567\}\{01234567\} brightgreen
keyword \\\\ brightgreen
keyword \\' brightgreen
keyword \\\{abtnvfr\} brightgreen
|
_________________ Sky is not the limit... |
|
| Back to top |
|
 |
laserprinter n00b

Joined: 03 Dec 2006 Posts: 2
|
Posted: Sun Dec 03, 2006 1:09 am Post subject: |
|
|
these are great things, thank you.. _________________ lazy |
|
| Back to top |
|
 |
ryszardzonk Tux's lil' helper


Joined: 18 Dec 2003 Posts: 138 Location: Rzeszów, POLAND
|
Posted: Tue Dec 05, 2006 7:11 am Post subject: solutions? |
|
|
After some time I made this syntax for *.po files. It is in no way complete, but here it comes anyway
| Code: | ## *.po file syntax
##
syntax "po" "\.po$"
color brightblue "\<(msgid|msgstr)\>"
color brightred "\/"
color green "#.*$"
color red "\<fuzzy\>"
color yellow "\<c-format\>"
color yellow "\""
color red "\"\""
color brightyellow "\"\\n\""
color brightmagenta "\<(Project\-Id\-Version|Report\-Msgid\-Bugs\-To|Last\-Translator|Language\-Team|charset)\>"
color cyan "\<(POT\-Creation\-Date|PO\-Revision\-Date|MIME\-Version|Content\-Type|Content\-Transfer\-Encoding)\>"
color yellow "\<(Copyright|(C))\>"
color yellow "[0-9]"
color brightyellow "\<(UTF|ISO|Windows|Mac|IBM)\>\-[0-9]"
color red "#~.*$"
|
ChangeLog syntax. Not quite what you would call perfect but somewhat usable | Code: |
## Changelog file syntax
##
syntax "changelogs" "ChangeLog*"
color green "\+"
color red "\-"
color brightwhite "[0-9]"
color brightblue "[0-9][0-9]\:[0-9][0-9]\:[0-9][0-9]"
color blue "[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]"
color blue "[0-9][0-9][0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]"
color blue "\<(CEST|CET|CST||CDT|EDT)\>"
color yellow "[0-9]\..*$"
color cyan "\*.*$"
color brightblue "\<(pre.*$|beta.*$|rc.*$|release.*$)\>"
color green "#.*$"
icolor brightred "^[[:space:]]*[.0-9A-Z_]*:"
color green "[[:space:]]*[.0-9A-Z_]*[[:space:]]*[.0-9A-Z_]*[[:space:]]<"
color brightyellow "<.*>$"
color brightwhite "commit[[:space:]]*[.0-9A-Z_]*$" |
There must be a better solution than this...
I also had to put include "/usr/share/nano/changelog.nanorc" in end of my /etc/nanorc for it to work...
Edit:I added some more stuff in there. *.po syntax needs highlighting of phrases to catch syntax errors... _________________ Sky is not the limit...
Last edited by ryszardzonk on Fri Dec 08, 2006 7:36 am; edited 9 times in total |
|
| Back to top |
|
 |
bigmauler Apprentice


Joined: 25 Apr 2005 Posts: 171 Location: Seattle, WA
|
Posted: Tue Dec 05, 2006 12:40 pm Post subject: |
|
|
Cool I didn't know nano did this...Nice thread, now my screen is pretty! _________________ 2GHz celeron, 512MB, Gentoo Media/network server
Main rig is a homemade, e7300 with 4GB ram, evga 9800gx2, Asus P5Q SE mobo
My last.fm profile |
|
| Back to top |
|
 |
ryszardzonk Tux's lil' helper


Joined: 18 Dec 2003 Posts: 138 Location: Rzeszów, POLAND
|
Posted: Fri Dec 08, 2006 7:43 am Post subject: nano syntax |
|
|
For convenience I placed all the syntax highlighting stuff to be found here along with few more syntaxes in this package http://bigvo.dyndns.org/nanosyntax.tar.bz2
WARNING: Tested just with the black background _________________ Sky is not the limit... |
|
| Back to top |
|
 |
bladdo Guru


Joined: 19 Jul 2004 Posts: 334 Location: NJ
|
Posted: Sat May 03, 2008 9:05 am Post subject: |
|
|
I know this thread is old but thanks guys, nano just got that much better. _________________ Bladdo formerly >Milo<
bladdo.net - scripting and design
Creator of AIM Bot: Tiny Tiny Bot - the bot that learns
distro: gentoo | window manager: pekwm |
|
| Back to top |
|
 |
Hopeless Veteran


Joined: 05 Aug 2004 Posts: 3041 Location: Ariel
|
Posted: Fri May 09, 2008 2:02 pm Post subject: |
|
|
Seeing as bladdo already necro'd it...
I wrote a little bash wrapper script which uses the `file` command on a file and uses the value to determine what (if any) syntax highlighting to enable in nano via --syntax.
It has a couple of issues though, for one thing you can only use --syntax once on the command line, and all files will end up using the same syntax (so in the script if you pass more than file it'll just start nano normally and let nano decide which highlighting to enable).
Another issue is `file` isn't entirely accurate, most noticeably is that it identifies a lot of diff/patch as C source files if there is a significant comment at the top of the file.
Anyways, here's the script if anyone is interested (and a link); | Code: | #!/bin/bash
NANO="/usr/bin/nano"
for PARAM; do
if [[ -f $PARAM ]]; then
[[ ! $NANOFILE ]] && NANOFILE="${PARAM}" || exec $NANO "$@"
fi
done
case `file -b "${NANOFILE}"` in
*perl*"script text"* )
SYNTAX="--syntax perl"
;;
*python*"script text"* )
SYNTAX="--syntax python"
;;
*ruby*"script text"* )
SYNTAX="--syntax ruby"
;;
*PHP*"script text"* )
SYNTAX="--syntax php"
;;
*"script text"* )
SYNTAX="--syntax sh"
;;
*"diff output text"* )
SYNTAX="--syntax patch"
;;
*C*"program text"*)
SYNTAX="--syntax c"
;;
*"Java program text"* )
SYNTAX="--syntax java"
;;
*"HTML document text"* )
SYNTAX="--syntax html"
;;
esac
exec $NANO ${SYNTAX} "$@"
exit |
It's only really useful for scripts without file extensions (although that alone makes it invaluable to me), and could probably be improved quite a bit, but it does what I want.
It should be easily extendable, too. _________________ "They took Christmas away
Came downstairs for the shiny presents
They took the tree and the stockings, nothing left but coal
Dont look in the closet either, its greedy
Its not in the spirit of the holiday" |
|
| Back to top |
|
 |
steveL Veteran

Joined: 13 Sep 2006 Posts: 1324 Location: The Peanut Gallery
|
Posted: Sun May 11, 2008 11:42 pm Post subject: |
|
|
Nice one Hopeless, I needed this recently as I was installing on a machine with no X, ended up just adding the filename (update) to this syntax highlighting file: http://dev.gentooexperimental.org/~igli/src/bash.nanorc
It works really nicely for BASH, in some places better than kate. Multi-line strings are the only place it falls over, but you still see the first line in orange. |
|
| Back to top |
|
 |
|