diff options
author | Wu Cheng-Han | 2015-05-04 15:53:29 +0800 |
---|---|---|
committer | Wu Cheng-Han | 2015-05-04 15:53:29 +0800 |
commit | 4b0ca55eb79e963523eb6c8197825e9e8ae904e2 (patch) | |
tree | 574f3923af77b37b41dbf1b00bcd7827ef724a28 /public/vendor/codemirror/mode/tcl | |
parent | 61eb11d23c65c9e5c493c67d055f785cbec139e2 (diff) |
First commit, version 0.2.7
Diffstat (limited to 'public/vendor/codemirror/mode/tcl')
-rwxr-xr-x | public/vendor/codemirror/mode/tcl/index.html | 142 | ||||
-rwxr-xr-x | public/vendor/codemirror/mode/tcl/tcl.js | 147 |
2 files changed, 289 insertions, 0 deletions
diff --git a/public/vendor/codemirror/mode/tcl/index.html b/public/vendor/codemirror/mode/tcl/index.html new file mode 100755 index 00000000..ce4ad342 --- /dev/null +++ b/public/vendor/codemirror/mode/tcl/index.html @@ -0,0 +1,142 @@ +<!doctype html> + +<title>CodeMirror: Tcl mode</title> +<meta charset="utf-8"/> +<link rel=stylesheet href="../../doc/docs.css"> + +<link rel="stylesheet" href="../../lib/codemirror.css"> +<link rel="stylesheet" href="../../theme/night.css"> +<script src="../../lib/codemirror.js"></script> +<script src="tcl.js"></script> +<script src="../../addon/scroll/scrollpastend.js"></script> +<div id=nav> + <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> + + <ul> + <li><a href="../../index.html">Home</a> + <li><a href="../../doc/manual.html">Manual</a> + <li><a href="https://github.com/codemirror/codemirror">Code</a> + </ul> + <ul> + <li><a href="../index.html">Language modes</a> + <li><a class=active href="#">Tcl</a> + </ul> +</div> + +<article> +<h2>Tcl mode</h2> +<form><textarea id="code" name="code"> +############################################################################################## +## ## whois.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ## +############################################################################################## +## To use this script you must set channel flag +whois (ie .chanset #chan +whois) ## +############################################################################################## +## ____ __ ########################################### ## +## / __/___ _ ___ _ ___/ /____ ___ ___ ########################################### ## +## / _/ / _ `// _ `// _ // __// _ \ / _ \ ########################################### ## +## /___/ \_, / \_, / \_,_//_/ \___// .__/ ########################################### ## +## /___/ /___/ /_/ ########################################### ## +## ########################################### ## +############################################################################################## +## ## Start Setup. ## ## +############################################################################################## +namespace eval whois { +## change cmdchar to the trigger you want to use ## ## + variable cmdchar "!" +## change command to the word trigger you would like to use. ## ## +## Keep in mind, This will also change the .chanset +/-command ## ## + variable command "whois" +## change textf to the colors you want for the text. ## ## + variable textf "\017\00304" +## change tagf to the colors you want for tags: ## ## + variable tagf "\017\002" +## Change logo to the logo you want at the start of the line. ## ## + variable logo "\017\00304\002\[\00306W\003hois\00304\]\017" +## Change lineout to the results you want. Valid results are channel users modes topic ## ## + variable lineout "channel users modes topic" +############################################################################################## +## ## End Setup. ## ## +############################################################################################## + variable channel "" + setudef flag $whois::command + bind pub -|- [string trimleft $whois::cmdchar]${whois::command} whois::list + bind raw -|- "311" whois::311 + bind raw -|- "312" whois::312 + bind raw -|- "319" whois::319 + bind raw -|- "317" whois::317 + bind raw -|- "313" whois::multi + bind raw -|- "310" whois::multi + bind raw -|- "335" whois::multi + bind raw -|- "301" whois::301 + bind raw -|- "671" whois::multi + bind raw -|- "320" whois::multi + bind raw -|- "401" whois::multi + bind raw -|- "318" whois::318 + bind raw -|- "307" whois::307 +} +proc whois::311 {from key text} { + if {[regexp -- {^[^\s]+\s(.+?)\s(.+?)\s(.+?)\s\*\s\:(.+)$} $text wholematch nick ident host realname]} { + putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Host:${whois::textf} \ + $nick \(${ident}@${host}\) ${whois::tagf}Realname:${whois::textf} $realname" + } +} +proc whois::multi {from key text} { + if {[regexp {\:(.*)$} $text match $key]} { + putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Note:${whois::textf} [subst $$key]" + return 1 + } +} +proc whois::312 {from key text} { + regexp {([^\s]+)\s\:} $text match server + putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Server:${whois::textf} $server" +} +proc whois::319 {from key text} { + if {[regexp {.+\:(.+)$} $text match channels]} { + putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Channels:${whois::textf} $channels" + } +} +proc whois::317 {from key text} { + if {[regexp -- {.*\s(\d+)\s(\d+)\s\:} $text wholematch idle signon]} { + putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Connected:${whois::textf} \ + [ctime $signon] ${whois::tagf}Idle:${whois::textf} [duration $idle]" + } +} +proc whois::301 {from key text} { + if {[regexp {^.+\s[^\s]+\s\:(.*)$} $text match awaymsg]} { + putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Away:${whois::textf} $awaymsg" + } +} +proc whois::318 {from key text} { + namespace eval whois { + variable channel "" + } + variable whois::channel "" +} +proc whois::307 {from key text} { + putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Services:${whois::textf} Registered Nick" +} +proc whois::list {nick host hand chan text} { + if {[lsearch -exact [channel info $chan] "+${whois::command}"] != -1} { + namespace eval whois { + variable channel "" + } + variable whois::channel $chan + putserv "WHOIS $text" + } +} +putlog "\002*Loaded* \017\00304\002\[\00306W\003hois\00304\]\017 \002by \ +Ford_Lawnmower irc.GeekShed.net #Script-Help" +</textarea></form> + <script> + var editor = CodeMirror.fromTextArea(document.getElementById("code"), { + theme: "night", + lineNumbers: true, + indentUnit: 2, + scrollPastEnd: true, + mode: "text/x-tcl" + }); + </script> + + <p><strong>MIME types defined:</strong> <code>text/x-tcl</code>.</p> + + </article> diff --git a/public/vendor/codemirror/mode/tcl/tcl.js b/public/vendor/codemirror/mode/tcl/tcl.js new file mode 100755 index 00000000..056accb2 --- /dev/null +++ b/public/vendor/codemirror/mode/tcl/tcl.js @@ -0,0 +1,147 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +//tcl mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode("tcl", function() { + function parseWords(str) { + var obj = {}, words = str.split(" "); + for (var i = 0; i < words.length; ++i) obj[words[i]] = true; + return obj; + } + var keywords = parseWords("Tcl safe after append array auto_execok auto_import auto_load " + + "auto_mkindex auto_mkindex_old auto_qualify auto_reset bgerror " + + "binary break catch cd close concat continue dde eof encoding error " + + "eval exec exit expr fblocked fconfigure fcopy file fileevent filename " + + "filename flush for foreach format gets glob global history http if " + + "incr info interp join lappend lindex linsert list llength load lrange " + + "lreplace lsearch lset lsort memory msgcat namespace open package parray " + + "pid pkg::create pkg_mkIndex proc puts pwd re_syntax read regex regexp " + + "registry regsub rename resource return scan seek set socket source split " + + "string subst switch tcl_endOfWord tcl_findLibrary tcl_startOfNextWord " + + "tcl_wordBreakAfter tcl_startOfPreviousWord tcl_wordBreakBefore tcltest " + + "tclvars tell time trace unknown unset update uplevel upvar variable " + + "vwait"); + var functions = parseWords("if elseif else and not or eq ne in ni for foreach while switch"); + var isOperatorChar = /[+\-*&%=<>!?^\/\|]/; + function chain(stream, state, f) { + state.tokenize = f; + return f(stream, state); + } + function tokenBase(stream, state) { + var beforeParams = state.beforeParams; + state.beforeParams = false; + var ch = stream.next(); + if ((ch == '"' || ch == "'") && state.inParams) + return chain(stream, state, tokenString(ch)); + else if (/[\[\]{}\(\),;\.]/.test(ch)) { + if (ch == "(" && beforeParams) state.inParams = true; + else if (ch == ")") state.inParams = false; + return null; + } + else if (/\d/.test(ch)) { + stream.eatWhile(/[\w\.]/); + return "number"; + } + else if (ch == "#" && stream.eat("*")) { + return chain(stream, state, tokenComment); + } + else if (ch == "#" && stream.match(/ *\[ *\[/)) { + return chain(stream, state, tokenUnparsed); + } + else if (ch == "#" && stream.eat("#")) { + stream.skipToEnd(); + return "comment"; + } + else if (ch == '"') { + stream.skipTo(/"/); + return "comment"; + } + else if (ch == "$") { + stream.eatWhile(/[$_a-z0-9A-Z\.{:]/); + stream.eatWhile(/}/); + state.beforeParams = true; + return "builtin"; + } + else if (isOperatorChar.test(ch)) { + stream.eatWhile(isOperatorChar); + return "comment"; + } + else { + stream.eatWhile(/[\w\$_{}\xa1-\uffff]/); + var word = stream.current().toLowerCase(); + if (keywords && keywords.propertyIsEnumerable(word)) + return "keyword"; + if (functions && functions.propertyIsEnumerable(word)) { + state.beforeParams = true; + return "keyword"; + } + return null; + } + } + function tokenString(quote) { + return function(stream, state) { + var escaped = false, next, end = false; + while ((next = stream.next()) != null) { + if (next == quote && !escaped) { + end = true; + break; + } + escaped = !escaped && next == "\\"; + } + if (end) state.tokenize = tokenBase; + return "string"; + }; + } + function tokenComment(stream, state) { + var maybeEnd = false, ch; + while (ch = stream.next()) { + if (ch == "#" && maybeEnd) { + state.tokenize = tokenBase; + break; + } + maybeEnd = (ch == "*"); + } + return "comment"; + } + function tokenUnparsed(stream, state) { + var maybeEnd = 0, ch; + while (ch = stream.next()) { + if (ch == "#" && maybeEnd == 2) { + state.tokenize = tokenBase; + break; + } + if (ch == "]") + maybeEnd++; + else if (ch != " ") + maybeEnd = 0; + } + return "meta"; + } + return { + startState: function() { + return { + tokenize: tokenBase, + beforeParams: false, + inParams: false + }; + }, + token: function(stream, state) { + if (stream.eatSpace()) return null; + return state.tokenize(stream, state); + } + }; +}); +CodeMirror.defineMIME("text/x-tcl", "tcl"); + +}); |