• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Viele hassen ihn, manche schwören auf ihn, wir aber möchten unbedingt sehen, welche Bilder Ihr vor Eurem geistigen Auge bzw. vor der Linse Eures iPhone oder iPad sehen könnt, wenn Ihr dieses Wort hört oder lest. Macht mit und beteiligt Euch an unserem Frühjahrsputz ---> Klick

Syntax-Highlighting mit nano/pico

philo

Roter Stettiner
Registriert
13.10.04
Beiträge
973
hallo,

ich habe hier eine Syntax-Highlight Datei und versucht die mit folgender Anleitung einzubinden.

das ist die syntaxdatei:


Code:
# *****************************************************************************
# Copyright (C) 2005 Sven Schneider
# This configuration-file is free software; you can redistribute it and/or 
# modify it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the 
#   Free Software Foundation, Inc.,
#   51 Franklin St, Fifth Floor,
#   Boston, MA  02110-1301  USA
# *****************************************************************************

syntax "opal-file" "\.(sign|impl)$"
# opal-keywords
	# any surrounding
	color brightyellow "==|\*\*|->|\\\\"
	# anywhere but single word
	color brightyellow "\<(ALL|AND|ANDIF|ANY|AS|ASSERT|AXM|COMPLETELY|DERIVE|DFD|DISCRIMINATORS|ELSE|EX|EXTERNAL|FI|FIX|IF|IMPLIES|IN|INHERIT|INJECTIONS|INTERFACE|INTERNAL|LAW|LAZY|LEFTASSOC|LET|MODULE|NOT|OR|ORIF|OTHERWISE|POST|PRE|PRED|PRIORITY|PROPERTIES|REALIZES|REQUIRE|RIGHTASSOC|SELECTORS|SPC|SPEC|SPECIFICATION|THE|THEN|THEORY|THM|UNIQ|WHERE)\>"
	# line start and WS after
	color brightyellow "^FUN\s"
	color brightyellow "^DEF\s"
	color brightyellow "^DATA\s"
	color brightyellow "^TYPE\s"
	color brightyellow "^SORT\s"
	color brightyellow "^SIGNATURE\s"
	color brightyellow "^IMPLEMENTATION\s"
	color brightyellow "^IMPORT\s"
	# WS surrounds
	color brightyellow "\sONLY\s"
	# line ending
	color brightyellow "\sCOMPLETELY$"
# opal-misc
color red "\<(true|false)\>"
# opal-sorts
color red "\<(aEntry|agent|align|anchor|ans|arg|arg1|arg2|array|arrowWhere|bag|bitmap|bool|bstree|byte|callback|canvasEditor|capStyle|channel|char|childstat|codom|codomFrom|codomTo|color|colorModel|com|composeOp|config|configCom|cursor|dArray|data|data1|data11|data2|data21|data3|data31|data4|data41|dataFrom|dataTo|defaultPrio|denotation|device|dist|distOut|dom|domFrom|domTo|drawing|dyn|emitter|env|event|eventInfo|file|filemode|filestat|filetype|first|first1|first2|first3|fission|fmt|font|from|from1|from2|funct|group|groupid|heap|iconfig|image|in|inData|index|inode|input|int|inter|interdom|interpreter|iseq|items|joinStyle|justifyHow|long|manager|managerRequest|map|mapEntry|mark|mid|modifier|nat|natMap|OBJECT|option|orient|out|outData|output|packOp|pair|parser|permission|point|positionRequest|process|procstat|quad|range|real|regulator|rel|relief|res|res1|res2|result|role|sap|script|scroller|scrollView|scrollWindow|searchOpt|second|seekMode|selector|semaphor|seq|seqEntry|set|setEntry|short|sigaction|sighandler|sigmask|signal|size|sizeRequest|some|sreal|state|stateId|stateRequest|string|subrel|tag|textEditor|time|to|tree|triple|union|user|userid|version|view|void|wconfig|wconfigCom|wday|widget|window|wrapStyle)\>"
# opal-structures
color cyan "\<(ABORT|AcceleratorC|AcceleratorF|AEntry|AEntryNE|AnonPair|AnonQuadruple|AnonTriple|Array|ArrayConv|ArrayFilter|ArrayFold|ArrayMap|ArrayReduce|Arrays|Bag|BagConv|BagFilter|BagFold|BagMap|BagReduce|Bags|BasicIO|Basics|BinFile|BinStream|Bitset|BitsetConv|BitsetFilter|BitsetFold|BitsetMap|BitsetReduce|Bool|BOOL|BoolConv|BSTree|BSTreeCompare|BSTreeConv|BSTreeFilter|BSTreeIndex|BSTreeMap|BSTreeMapEnv|BSTreeReduce|BSTreeZip|BTUnion|BTUnionConv|Byte|CAST|Char|CharConv|Com|ComAction|ComAgent|ComAgentConv|ComCheck|ComCheckWin|ComCheckWinData|ComChoice|ComCompose|ComConv|Commands|ComMap|ComPairCompose|Compose|ComposePar|ComSemaphor|ComSeqAction|ComSeqMap|ComSeqReduce|ComService|ComServiceConv|ComState|ComStateWith|ComTimeout|ComTripleCompose|Control|DArray|DArrayConv|DArrayFilter|DArrayFold|DArrayMap|DArrayReduce|DEBUG|Denotation|DENOTATION|Distributor|Dyn|DynConv|Env|EQUALITY|File|FileConv|FileName|FileSystem|FileSystemConv|FileSystemFun|Fmt|FmtArray|FmtBasicTypes|FmtDebug|FmtMap|FmtOption|FmtPair|FmtSeq|FmtSet|Funct|FunctConv|Greek|Heap|HeapCompare|HeapConv|HeapFilter|HeapIndex|HeapMap|HeapMapEnv|HeapReduce|HeapZip|Identity|IndexingOfTrees|InducedRel|INLINE|Int|IntConv|ISeq|ISeqConv|ISeqFilter|ISeqIndex|ISeqMap|ISeqMapEnv|ISeqSort|ISeqUnreduce|ISeqZip|JavaCatch|JavaCheck|JavaNull|JavaNullArray|JavaVM|Latin1|LineFormat|Long|Map|MapByBST|MapByBSTCompose|MapByBSTConv|MapByBSTFilter|MapByBSTInvert|MapByBSTMap|MapByBSTReduce|MapByOS|MapByOSCompose|MapByOSConv|MapByOSFilter|MapByOSInvert|MapByOSMap|MapByOSReduce|MapCompose|MapConv|MapEntry|MapEntryNE|MapFilter|MapInvert|MapMap|MapNotForUserPurpose|MapReduce|Maps|MaxStrongComp|MONITOR|Nat|NatConv|NatMap|NatMapConv|NatMapFilter|NatMapMap|NatMapNotForUserPurpose|NatMapReduce|NatMaps|NatSets|Option|OptionCompare|OptionConv|OptionMap|OrderingByInjection|OrderingByLess|Pair|PairCompare|PairConv|PairMap|ParserL|ParserLBasic|ParserLCombinator|ParserLCompose|ParserLMap|Predicate|PrintableChar|Process|ProcessArgs|ProcessComInterrupt|ProcessConnect|ProcessConv|ProcessCtrl|ProcessCtrlConv|ProcessCtrlFun|ProcessInterrupt|ProcessMonitor|Quadruple|QuadrupleConv|QuadrupleMap|Random|ReadLine|Real|RealConv|Rel|RelCmp|RelCmpConv|RelCompose|RelConv|RelFilter|RelHomog|RelInvert|RelMap|RelNotForUserPurpose|RelReduce|Seq|SeqCompare|SeqConv|SeqEntry|SeqEntryNE|SeqFilter|SeqFold|SeqIndex|SeqMap|SeqMapEnv|SeqOfSeq|SeqReduce|Seqs|SeqSort|SeqZip|Set|SetByBST|SetByBSTConstr|SetByBSTConv|SetByBSTFilter|SetByBSTFold|SetByBSTMap|SetByBSTMapEnv|SetByBSTOfSetByBST|SetByBSTReduce|SetByPred|SetByPredConstr|SetByPredConv|SetByPredFilter|SetConstr|SetConv|SetEntry|SetEntryNE|SetFilter|SetFold|SetMap|SetMapEnv|SetOfSet|SetReduce|Sets|SetTopSort|Short|Signal|SignalConv|SmallReal|Stream|String|StringConv|StringFilter|StringFold|StringFormat|StringIndex|StringMap|StringMapSeq|StringReduce|Strings|StringScan|Subrel|SubrelConv|Tcl|Time|TimeConv|Tk|Tree|TreeCompare|TreeConv|TreeFilter|TreeIndex|TreeMap|TreeMapEnv|TreeReduce|TreeZip|Triple|TripleConv|TripleMap|Union2|Union2Conv|Union3|Union3Conv|Union4|Union4Conv|UnixFailures|UserAndGroup|UserAndGroupConv|UserAndGroupFun|Void|VoidConv|Wait|WaitConv|WinAppl|WinButton|WinCanvas|WinCanvasEditor|WinConfig|Windows|WinEmitter|WinEvent|WinImage|WinInternal|WinMenu|WinRegulator|WinScrollbar|WinScroller|WinSelector|WinTag|WinTclTk|WinText|WinTextEditor|WinView|WinWindow)\>"
# brackets and colons
color brightred "(\(|\)|\[|\]|\}|\{|,)"
# denotations
color green "\"[^\"]*\""
# comment
color brightblue "--\s.*"
color brightblue start="/\*" end="\*/"

und hier noch eine Beispieldatei:

Code:
IMPLEMENTATION Absy

IMPORT Denotation COMPLETELY
       Bool COMPLETELY
       BoolConv COMPLETELY
       Nat COMPLETELY
       NatConv COMPLETELY
       Seq COMPLETELY
       SeqConv COMPLETELY
       SeqMap COMPLETELY
       SeqReduce COMPLETELY

DATA absy == -- Wurzelknoten: defs enthaelt nur def()
             prog(defs:seq[absy],attr:attr)
             -- Funktionen: arglist nur arg; type nur natType oder boolType; expr nur natConst, boolConst, var, apply oder cond
             def(name:denotation, arglist:seq[absy], type:absy, expr:absy,attr:attr)
             -- Argument in der Funktionsdefinition: type wie def
             arg(name:denotation, type:absy,attr:attr)
             -- Der Typ "nat"
             natType(attr:attr)
             -- Der Typ "bool"
             boolType(attr:attr)
             -- Konstante fuer nat
             natConst(value:nat,attr:attr)
             -- Konstante fuer bool
             boolConst(value:bool,attr:attr)
             -- Variable in einem Ausdruck
             var(name:denotation,attr:attr)
             -- Funktionsanwendung: arglist wie expr in def
             apply(name:denotation, arglist:seq[absy],attr:attr)
             -- IF THEN ELSE FI Konstrukt: ifPart und thenPart wie expr in def, elsePart wie expr in def oder undef
             cond(ifPart:absy, thenPart:absy, elsePart:absy,attr:attr)
             -- Platzhalter fuer leeren ELSE-Teil
             undef(attr:attr)
DATA attr == attr(pos:pos)

FUN ` : absy -> denotation

DEF `(prog(d,_)) == ("prog(" ++ (`(`)(d)))  ++ ")"
DEF `(def(n,al,t,e,_)) == "function(" ++ n ++ "," ++ (`(`)(al)) ++ "," ++ `(t) ++ "," ++ `(e) ++ ")"
DEF `(arg(n,t,_)) == "arg(" ++ n ++ "," ++ `(t) ++ ")"
DEF `(natType(_)) == "natType"
DEF `(boolType(_)) == "boolType"
DEF `(natConst(v,_)) == "natConst(" ++ (`(v)) ++ ")"
DEF `(boolConst(v,_)) == "boolConst(" ++ (`(v)) ++ ")"
DEF `(var(n,_)) == "var(" ++ n ++ ")"
DEF `(apply(n,al,_)) == "apply(" ++ n ++ "," ++ (`(`)(al)) ++ ")"
DEF `(cond(ip,tp,undef(_),_)) == "cond(" ++ `(ip) ++ "," ++ `(tp) ++ ")"
DEF `(cond(ip,tp,ep,_)) == "cond(" ++ `(ip) ++ "," ++ `(tp) ++ "," ++ `(ep) ++ ")"
DEF `(undef(_)) == "ERROR - '(undef) should not be reached"

bekomme das einfach nicht hin. Im editor bleibt alles schwarz weiss :(
danke und gruss
philo
 

philo

Roter Stettiner
Registriert
13.10.04
Beiträge
973
philo schrieb:
hallo,

ich habe hier eine Syntax-Highlight Datei und versucht die mit folgender Anleitung einzubinden.

...

bekomme das einfach nicht hin. Im editor bleibt alles schwarz weiss :(
danke und gruss
philo

habe mich inzwischen mal wieder versucht. komischerweise startet jetzt weder nano noch pico. es kommt ein "bus error".

habe die aktuelle version von nano kompliert und installiert und obwohl auf der Seite steht, dass seit Version 1.2 highlighting unterstütz wird, sehe ich keine Farben.
er schein dir ~/.nanorc gar nicht einzulesen und auch nano --help zeigt keine syntax version an.
 

rotesosse

Gast
emacs tuts doch auch oder?
(M-x syntax-highlight)
--- ich weiss aber nicht, ob das auch fuer die Shell-Version gilt
--- auf jeden Fall geht's in Linux-Konsolen

aber ich muss zugeben die kleinen
Viecher (pico, nano) haben ihren Reiz.