7
if (typeof exports == "object" && typeof module == "object")
8
mod(require("../../lib/codemirror"));
9
else if (typeof define == "function" && define.amd)
10
define(["../../lib/codemirror"], mod);
13
})(function(CodeMirror) {
16
CodeMirror.defineMIME("text/mirc", "mirc");
17
CodeMirror.defineMode("mirc", function() {
18
function parseWords(str) {
19
var obj = {}, words = str.split(" ");
20
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
23
var specials = parseWords("$! $$ $& $? $+ $abook $abs $active $activecid " +
24
"$activewid $address $addtok $agent $agentname $agentstat $agentver " +
25
"$alias $and $anick $ansi2mirc $aop $appactive $appstate $asc $asctime " +
26
"$asin $atan $avoice $away $awaymsg $awaytime $banmask $base $bfind " +
27
"$binoff $biton $bnick $bvar $bytes $calc $cb $cd $ceil $chan $chanmodes " +
28
"$chantypes $chat $chr $cid $clevel $click $cmdbox $cmdline $cnick $color " +
29
"$com $comcall $comchan $comerr $compact $compress $comval $cos $count " +
30
"$cr $crc $creq $crlf $ctime $ctimer $ctrlenter $date $day $daylight " +
31
"$dbuh $dbuw $dccignore $dccport $dde $ddename $debug $decode $decompress " +
32
"$deltok $devent $dialog $did $didreg $didtok $didwm $disk $dlevel $dll " +
33
"$dllcall $dname $dns $duration $ebeeps $editbox $emailaddr $encode $error " +
34
"$eval $event $exist $feof $ferr $fgetc $file $filename $filtered $finddir " +
35
"$finddirn $findfile $findfilen $findtok $fline $floor $fopen $fread $fserve " +
36
"$fulladdress $fulldate $fullname $fullscreen $get $getdir $getdot $gettok $gmt " +
37
"$group $halted $hash $height $hfind $hget $highlight $hnick $hotline " +
38
"$hotlinepos $ial $ialchan $ibl $idle $iel $ifmatch $ignore $iif $iil " +
39
"$inelipse $ini $inmidi $inpaste $inpoly $input $inrect $inroundrect " +
40
"$insong $instok $int $inwave $ip $isalias $isbit $isdde $isdir $isfile " +
41
"$isid $islower $istok $isupper $keychar $keyrpt $keyval $knick $lactive " +
42
"$lactivecid $lactivewid $left $len $level $lf $line $lines $link $lock " +
43
"$lock $locked $log $logstamp $logstampfmt $longfn $longip $lower $ltimer " +
44
"$maddress $mask $matchkey $matchtok $md5 $me $menu $menubar $menucontext " +
45
"$menutype $mid $middir $mircdir $mircexe $mircini $mklogfn $mnick $mode " +
46
"$modefirst $modelast $modespl $mouse $msfile $network $newnick $nick $nofile " +
47
"$nopath $noqt $not $notags $notify $null $numeric $numok $oline $onpoly " +
48
"$opnick $or $ord $os $passivedcc $pic $play $pnick $port $portable $portfree " +
49
"$pos $prefix $prop $protect $puttok $qt $query $rand $r $rawmsg $read $readomo " +
50
"$readn $regex $regml $regsub $regsubex $remove $remtok $replace $replacex " +
51
"$reptok $result $rgb $right $round $scid $scon $script $scriptdir $scriptline " +
52
"$sdir $send $server $serverip $sfile $sha1 $shortfn $show $signal $sin " +
53
"$site $sline $snick $snicks $snotify $sock $sockbr $sockerr $sockname " +
54
"$sorttok $sound $sqrt $ssl $sreq $sslready $status $strip $str $stripped " +
55
"$syle $submenu $switchbar $tan $target $ticks $time $timer $timestamp " +
56
"$timestampfmt $timezone $tip $titlebar $toolbar $treebar $trust $ulevel " +
57
"$ulist $upper $uptime $url $usermode $v1 $v2 $var $vcmd $vcmdstat $vcmdver " +
58
"$version $vnick $vol $wid $width $wildsite $wildtok $window $wrap $xor");
59
var keywords = parseWords("abook ajinvite alias aline ame amsg anick aop auser autojoin avoice " +
60
"away background ban bcopy beep bread break breplace bset btrunc bunset bwrite " +
61
"channel clear clearall cline clipboard close cnick color comclose comopen " +
62
"comreg continue copy creq ctcpreply ctcps dcc dccserver dde ddeserver " +
63
"debug dec describe dialog did didtok disable disconnect dlevel dline dll " +
64
"dns dqwindow drawcopy drawdot drawfill drawline drawpic drawrect drawreplace " +
65
"drawrot drawsave drawscroll drawtext ebeeps echo editbox emailaddr enable " +
66
"events exit fclose filter findtext finger firewall flash flist flood flush " +
67
"flushini font fopen fseek fsend fserve fullname fwrite ghide gload gmove " +
68
"gopts goto gplay gpoint gqreq groups gshow gsize gstop gtalk gunload hadd " +
69
"halt haltdef hdec hdel help hfree hinc hload hmake hop hsave ial ialclear " +
70
"ialmark identd if ignore iline inc invite iuser join kick linesep links list " +
71
"load loadbuf localinfo log mdi me menubar mkdir mnick mode msg nick noop notice " +
72
"notify omsg onotice part partall pdcc perform play playctrl pop protect pvoice " +
73
"qme qmsg query queryn quit raw reload remini remote remove rename renwin " +
74
"reseterror resetidle return rlevel rline rmdir run ruser save savebuf saveini " +
75
"say scid scon server set showmirc signam sline sockaccept sockclose socklist " +
76
"socklisten sockmark sockopen sockpause sockread sockrename sockudp sockwrite " +
77
"sound speak splay sreq strip switchbar timer timestamp titlebar tnick tokenize " +
78
"toolbar topic tray treebar ulist unload unset unsetall updatenl url uwho " +
79
"var vcadd vcmd vcrem vol while whois window winhelp write writeint if isalnum " +
80
"isalpha isaop isavoice isban ischan ishop isignore isin isincs isletter islower " +
81
"isnotify isnum ison isop isprotect isreg isupper isvoice iswm iswmcs " +
82
"elseif else goto menu nicklist status title icon size option text edit " +
83
"button check radio box scroll list combo link tab item");
84
var functions = parseWords("if elseif else and not or eq ne in ni for foreach while switch");
85
var isOperatorChar = /[+\-*&%=<>!?^\/\|]/;
86
function chain(stream, state, f) {
88
return f(stream, state);
90
function tokenBase(stream, state) {
91
var beforeParams = state.beforeParams;
92
state.beforeParams = false;
93
var ch = stream.next();
94
if (/[\[\]{}\(\),\.]/.test(ch)) {
95
if (ch == "(" && beforeParams) state.inParams = true;
96
else if (ch == ")") state.inParams = false;
99
else if (/\d/.test(ch)) {
100
stream.eatWhile(/[\w\.]/);
103
else if (ch == "\\") {
108
else if (ch == "/" && stream.eat("*")) {
109
return chain(stream, state, tokenComment);
111
else if (ch == ";" && stream.match(/ *\( *\(/)) {
112
return chain(stream, state, tokenUnparsed);
114
else if (ch == ";" && !state.inParams) {
118
else if (ch == '"') {
122
else if (ch == "$") {
123
stream.eatWhile(/[$_a-z0-9A-Z\.:]/);
124
if (specials && specials.propertyIsEnumerable(stream.current().toLowerCase())) {
128
state.beforeParams = true;
132
else if (ch == "%") {
133
stream.eatWhile(/[^,\s()]/);
134
state.beforeParams = true;
137
else if (isOperatorChar.test(ch)) {
138
stream.eatWhile(isOperatorChar);
142
stream.eatWhile(/[\w\$_{}]/);
143
var word = stream.current().toLowerCase();
144
if (keywords && keywords.propertyIsEnumerable(word))
146
if (functions && functions.propertyIsEnumerable(word)) {
147
state.beforeParams = true;
153
function tokenComment(stream, state) {
154
var maybeEnd = false, ch;
155
while (ch = stream.next()) {
156
if (ch == "/" && maybeEnd) {
157
state.tokenize = tokenBase;
160
maybeEnd = (ch == "*");
164
function tokenUnparsed(stream, state) {
165
var maybeEnd = 0, ch;
166
while (ch = stream.next()) {
167
if (ch == ";" && maybeEnd == 2) {
168
state.tokenize = tokenBase;
179
startState: function() {
186
token: function(stream, state) {
187
if (stream.eatSpace()) return null;
188
return state.tokenize(stream, state);