codemirror
Advanced tools
Comparing version 4.0.3 to 4.1.0
@@ -34,3 +34,3 @@ (function(mod) { | ||
var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left; | ||
var bot = -cm.display.scroller.offsetHeight; | ||
var minH = cm.display.scroller.offsetHeight + 30; | ||
for (var i = 0; i < val.length; i++) { | ||
@@ -46,3 +46,3 @@ var elt = document.createElement("div"); | ||
elt.className = "CodeMirror-ruler" + (cls ? " " + cls : ""); | ||
elt.style.cssText = "left: " + (left + col * cw) + "px; top: -50px; bottom: " + bot + "px"; | ||
elt.style.cssText = "left: " + (left + col * cw) + "px; top: -50px; bottom: -20px; min-height: " + minH + "px"; | ||
cm.display.lineSpace.insertBefore(elt, cm.display.cursorDiv); | ||
@@ -49,0 +49,0 @@ } |
@@ -13,2 +13,4 @@ (function(mod) { | ||
var Pos = CodeMirror.Pos; | ||
CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) { | ||
@@ -30,4 +32,4 @@ if (old != CodeMirror.Init && old) | ||
function charsAround(cm, pos) { | ||
var str = cm.getRange(CodeMirror.Pos(pos.line, pos.ch - 1), | ||
CodeMirror.Pos(pos.line, pos.ch + 1)); | ||
var str = cm.getRange(Pos(pos.line, pos.ch - 1), | ||
Pos(pos.line, pos.ch + 1)); | ||
return str.length == 2 ? str : null; | ||
@@ -49,3 +51,3 @@ } | ||
var cur = ranges[i].head; | ||
cm.replaceRange("", CodeMirror.Pos(cur.line, cur.ch - 1), CodeMirror.Pos(cur.line, cur.ch + 1)); | ||
cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1)); | ||
} | ||
@@ -64,7 +66,14 @@ } | ||
return CodeMirror.Pass; | ||
var next = cm.getRange(cur, CodeMirror.Pos(cur.line, cur.ch + 1)); | ||
var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1)); | ||
if (!range.empty()) | ||
curType = "surround"; | ||
else if (left == right && next == right) | ||
curType = "skip"; | ||
else if (left == right && next == right) { | ||
if (cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == left + left + left) | ||
curType = "skipThree"; | ||
else | ||
curType = "skip"; | ||
} else if (left == right && cur.ch > 1 && | ||
cm.getRange(Pos(cur.line, cur.ch - 2), cur) == left + left && | ||
(cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != left)) | ||
curType = "addFour"; | ||
else if (left == right && CodeMirror.isWordChar(next)) | ||
@@ -80,13 +89,21 @@ return CodeMirror.Pass; | ||
if (type == "skip") { | ||
cm.execCommand("goCharRight"); | ||
} else if (type == "surround") { | ||
var sels = cm.getSelections(); | ||
for (var i = 0; i < sels.length; i++) | ||
sels[i] = left + sels[i] + right; | ||
cm.replaceSelections(sels, "around"); | ||
} else if (type == "both") { | ||
cm.replaceSelection(left + right, null); | ||
cm.execCommand("goCharLeft"); | ||
} | ||
cm.operation(function() { | ||
if (type == "skip") { | ||
cm.execCommand("goCharRight"); | ||
} else if (type == "skipThree") { | ||
for (var i = 0; i < 3; i++) | ||
cm.execCommand("goCharRight"); | ||
} else if (type == "surround") { | ||
var sels = cm.getSelections(); | ||
for (var i = 0; i < sels.length; i++) | ||
sels[i] = left + sels[i] + right; | ||
cm.replaceSelections(sels, "around"); | ||
} else if (type == "both") { | ||
cm.replaceSelection(left + right, null); | ||
cm.execCommand("goCharLeft"); | ||
} else if (type == "addFour") { | ||
cm.replaceSelection(left + left + left + left, "before"); | ||
cm.execCommand("goCharRight"); | ||
} | ||
}); | ||
}; | ||
@@ -98,3 +115,3 @@ if (left != right) map["'" + right + "'"] = function(cm) { | ||
if (!range.empty() || | ||
cm.getRange(range.head, CodeMirror.Pos(range.head.line, range.head.ch + 1)) != right) | ||
cm.getRange(range.head, Pos(range.head.line, range.head.ch + 1)) != right) | ||
return CodeMirror.Pass; | ||
@@ -101,0 +118,0 @@ } |
@@ -25,2 +25,3 @@ (function(mod) { | ||
var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config); | ||
if (found == null) return null; | ||
return {from: Pos(where.line, pos), to: found && found.pos, | ||
@@ -30,7 +31,15 @@ match: found && found.ch == match.charAt(0), forward: dir > 0}; | ||
// bracketRegex is used to specify which type of bracket to scan | ||
// should be a regexp, e.g. /[[\]]/ | ||
// | ||
// Note: If "where" is on an open bracket, then this bracket is ignored. | ||
// | ||
// Returns false when no bracket was found, null when it reached | ||
// maxScanLines and gave up | ||
function scanForBracket(cm, where, dir, style, config) { | ||
var maxScanLen = (config && config.maxScanLineLength) || 10000; | ||
var maxScanLines = (config && config.maxScanLines) || 500; | ||
var maxScanLines = (config && config.maxScanLines) || 1000; | ||
var stack = [], re = /[(){}[\]]/; | ||
var stack = []; | ||
var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/; | ||
var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1) | ||
@@ -54,2 +63,3 @@ : Math.max(cm.firstLine() - 1, where.line - maxScanLines); | ||
} | ||
return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null; | ||
} | ||
@@ -63,7 +73,6 @@ | ||
var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config); | ||
if (match && cm.getLine(match.from.line).length <= maxHighlightLen && | ||
match.to && cm.getLine(match.to.line).length <= maxHighlightLen) { | ||
if (match && cm.getLine(match.from.line).length <= maxHighlightLen) { | ||
var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket"; | ||
marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style})); | ||
if (match.to) | ||
if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen) | ||
marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style})); | ||
@@ -106,8 +115,8 @@ } | ||
CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);}); | ||
CodeMirror.defineExtension("findMatchingBracket", function(pos, strict){ | ||
return findMatchingBracket(this, pos, strict); | ||
CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config){ | ||
return findMatchingBracket(this, pos, strict, config); | ||
}); | ||
CodeMirror.defineExtension("scanForBracket", function(pos, dir, style){ | ||
return scanForBracket(this, pos, dir, style); | ||
CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){ | ||
return scanForBracket(this, pos, dir, style, config); | ||
}); | ||
}); |
@@ -34,3 +34,3 @@ (function(mod) { | ||
var st = token.state.state; | ||
var st = inner.state.state; | ||
if (st == "pseudo" || token.type == "variable-3") { | ||
@@ -37,0 +37,0 @@ add(pseudoClasses); |
@@ -56,3 +56,4 @@ (function(mod) { | ||
if (completion.hint) completion.hint(this.cm, data, completion); | ||
else this.cm.replaceRange(getText(completion), completion.from||data.from, completion.to||data.to); | ||
else this.cm.replaceRange(getText(completion), completion.from || data.from, | ||
completion.to || data.to, "complete"); | ||
CodeMirror.signal(data, "pick", completion); | ||
@@ -104,2 +105,3 @@ this.close(); | ||
if (!data || !data.list.length) return done(); | ||
if (completion.widget) completion.widget.close(); | ||
completion.widget = new Widget(completion, data); | ||
@@ -106,0 +108,0 @@ } |
@@ -21,18 +21,27 @@ (function(mod) { | ||
var result = [], replaceToken = false, prefix; | ||
var isTag = token.string.charAt(0) == "<"; | ||
if (!inner.state.tagName || isTag) { // Tag completion | ||
if (isTag) { | ||
prefix = token.string.slice(1); | ||
replaceToken = true; | ||
} | ||
var tag = /\btag\b/.test(token.type), tagName = tag && /^\w/.test(token.string), tagStart; | ||
if (tagName) { | ||
var before = cm.getLine(cur.line).slice(Math.max(0, token.start - 2), token.start); | ||
var tagType = /<\/$/.test(before) ? "close" : /<$/.test(before) ? "open" : null; | ||
if (tagType) tagStart = token.start - (tagType == "close" ? 2 : 1); | ||
} else if (tag && token.string == "<") { | ||
tagType = "open"; | ||
} else if (tag && token.string == "</") { | ||
tagType = "close"; | ||
} | ||
if (!tag && !inner.state.tagName || tagType) { | ||
if (tagName) | ||
prefix = token.string; | ||
replaceToken = tagType; | ||
var cx = inner.state.context, curTag = cx && tags[cx.tagName]; | ||
var childList = cx ? curTag && curTag.children : tags["!top"]; | ||
if (childList) { | ||
if (childList && tagType != "close") { | ||
for (var i = 0; i < childList.length; ++i) if (!prefix || childList[i].lastIndexOf(prefix, 0) == 0) | ||
result.push("<" + childList[i]); | ||
} else { | ||
for (var name in tags) if (tags.hasOwnProperty(name) && name != "!top" && (!prefix || name.lastIndexOf(prefix, 0) == 0)) | ||
result.push("<" + name); | ||
} else if (tagType != "close") { | ||
for (var name in tags) | ||
if (tags.hasOwnProperty(name) && name != "!top" && name != "!attrs" && (!prefix || name.lastIndexOf(prefix, 0) == 0)) | ||
result.push("<" + name); | ||
} | ||
if (cx && (!prefix || ("/" + cx.tagName).lastIndexOf(prefix, 0) == 0)) | ||
if (cx && (!prefix || tagType == "close" && cx.tagName.lastIndexOf(prefix, 0) == 0)) | ||
result.push("</" + cx.tagName + ">"); | ||
@@ -42,3 +51,12 @@ } else { | ||
var curTag = tags[inner.state.tagName], attrs = curTag && curTag.attrs; | ||
if (!attrs) return; | ||
var globalAttrs = tags["!attrs"]; | ||
if (!attrs && !globalAttrs) return; | ||
if (!attrs) { | ||
attrs = globalAttrs; | ||
} else if (globalAttrs) { // Combine tag-local and global attributes | ||
var set = {}; | ||
for (var nm in globalAttrs) if (globalAttrs.hasOwnProperty(nm)) set[nm] = globalAttrs[nm]; | ||
for (var nm in attrs) if (attrs.hasOwnProperty(nm)) set[nm] = attrs[nm]; | ||
attrs = set; | ||
} | ||
if (token.type == "string" || token.string == "=") { // A value | ||
@@ -71,3 +89,3 @@ var before = cm.getRange(Pos(cur.line, Math.max(0, cur.ch - 60)), | ||
list: result, | ||
from: replaceToken ? Pos(cur.line, token.start) : cur, | ||
from: replaceToken ? Pos(cur.line, tagStart == null ? token.start : tagStart) : cur, | ||
to: replaceToken ? Pos(cur.line, token.end) : cur | ||
@@ -74,0 +92,0 @@ }; |
@@ -17,2 +17,3 @@ // Depends on csslint.js from https://github.com/stubbornella/csslint | ||
var found = []; | ||
if (!window.CSSLint) return found; | ||
var results = CSSLint.verify(text), messages = results.messages, message = null; | ||
@@ -19,0 +20,0 @@ for ( var i = 0; i < messages.length; i++) { |
@@ -22,2 +22,3 @@ (function(mod) { | ||
function validator(text, options) { | ||
if (!window.JSHINT) return []; | ||
JSHINT(text, options); | ||
@@ -24,0 +25,0 @@ var errors = JSHINT.data().errors, result = []; |
@@ -56,2 +56,10 @@ (function(mod) { | ||
function ensureDiff(dv) { | ||
if (dv.diffOutOfDate) { | ||
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue()); | ||
dv.diffOutOfDate = false; | ||
CodeMirror.signal(dv.edit, "updateDiff", dv.diff); | ||
} | ||
} | ||
function registerUpdate(dv) { | ||
@@ -69,7 +77,3 @@ var edit = {from: 0, to: 0, marked: []}; | ||
} | ||
if (dv.diffOutOfDate) { | ||
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue()); | ||
dv.diffOutOfDate = false; | ||
CodeMirror.signal(dv.edit, "updateDiff", dv.diff); | ||
} | ||
ensureDiff(dv); | ||
if (dv.showDifferences) { | ||
@@ -170,3 +174,3 @@ updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes); | ||
mark.clear(); | ||
} else { | ||
} else if (mark.parent) { | ||
editor.removeLineClass(mark, "background", classes.chunk); | ||
@@ -368,6 +372,6 @@ editor.removeLineClass(mark, "background", classes.start); | ||
rightChunks: function() { | ||
return this.right && getChunks(this.right.diff); | ||
return this.right && getChunks(this.right); | ||
}, | ||
leftChunks: function() { | ||
return this.left && getChunks(this.left.diff); | ||
return this.left && getChunks(this.left); | ||
} | ||
@@ -423,5 +427,6 @@ }; | ||
function getChunks(diff) { | ||
function getChunks(dv) { | ||
ensureDiff(dv); | ||
var collect = []; | ||
iterateChunks(diff, function(topOrig, botOrig, topEdit, botEdit) { | ||
iterateChunks(dv.diff, function(topOrig, botOrig, topEdit, botEdit) { | ||
collect.push({origFrom: topOrig, origTo: botOrig, | ||
@@ -428,0 +433,0 @@ editFrom: topEdit, editTo: botEdit}); |
@@ -26,3 +26,4 @@ // Utility function that allows modes to be combined. The mode given | ||
basePos: 0, baseCur: null, | ||
overlayPos: 0, overlayCur: null | ||
overlayPos: 0, overlayCur: null, | ||
lineSeen: null | ||
}; | ||
@@ -40,2 +41,8 @@ }, | ||
token: function(stream, state) { | ||
if (stream.sol() || stream.string != state.lineSeen || | ||
Math.min(state.basePos, state.overlayPos) < stream.start) { | ||
state.lineSeen = stream.string; | ||
state.basePos = state.overlayPos = stream.start; | ||
} | ||
if (stream.start == state.basePos) { | ||
@@ -51,3 +58,2 @@ state.baseCur = base.token(stream, state.base); | ||
stream.pos = Math.min(state.basePos, state.overlayPos); | ||
if (stream.eol()) state.basePos = state.overlayPos = 0; | ||
@@ -54,0 +60,0 @@ if (state.overlayCur == null) return state.baseCur; |
@@ -142,2 +142,3 @@ window.CodeMirror = {}; | ||
var stream = new CodeMirror.StringStream(lines[i]); | ||
if (!stream.string && mode.blankLine) mode.blankLine(); | ||
while (!stream.eol()) { | ||
@@ -144,0 +145,0 @@ var style = mode.token(stream, state); |
@@ -60,2 +60,3 @@ (function(mod) { | ||
var stream = new CodeMirror.StringStream(lines[i]); | ||
if (!stream.string && mode.blankLine) mode.blankLine(); | ||
while (!stream.eol()) { | ||
@@ -62,0 +63,0 @@ var style = mode.token(stream, state); |
@@ -110,2 +110,3 @@ /* Just enough of CodeMirror to run runMode under node.js */ | ||
var stream = new exports.StringStream(lines[i]); | ||
if (!stream.string && mode.blankLine) mode.blankLine(); | ||
while (!stream.eol()) { | ||
@@ -112,0 +113,0 @@ var style = mode.token(stream, state); |
@@ -19,17 +19,17 @@ // Define search commands. Depends on dialog.js or another | ||
function searchOverlay(query, caseInsensitive) { | ||
var startChar; | ||
if (typeof query == "string") { | ||
startChar = query.charAt(0); | ||
query = new RegExp("^" + query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), | ||
caseInsensitive ? "i" : ""); | ||
} else { | ||
query = new RegExp("^(?:" + query.source + ")", query.ignoreCase ? "i" : ""); | ||
} | ||
if (typeof query == "string") | ||
query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g"); | ||
else if (!query.global) | ||
query = new RegExp(query.source, query.ignoreCase ? "gi" : "g"); | ||
return {token: function(stream) { | ||
if (stream.match(query)) return "searching"; | ||
while (!stream.eol()) { | ||
stream.next(); | ||
if (startChar && !caseInsensitive) | ||
stream.skipTo(startChar) || stream.skipToEnd(); | ||
if (stream.match(query, false)) break; | ||
query.lastIndex = stream.pos; | ||
var match = query.exec(stream.string); | ||
if (match && match.index == stream.pos) { | ||
stream.pos += match[0].length; | ||
return "searching"; | ||
} else if (match) { | ||
stream.pos = match.index; | ||
} else { | ||
stream.skipToEnd(); | ||
} | ||
@@ -36,0 +36,0 @@ }}; |
@@ -55,6 +55,18 @@ // A rough approximation of Sublime Text's keybindings | ||
cmds[map[ctrl + "Up"] = "scrollLineUp"] = function(cm) { | ||
cm.scrollTo(null, cm.getScrollInfo().top - cm.defaultTextHeight()); | ||
var info = cm.getScrollInfo(); | ||
if (!cm.somethingSelected()) { | ||
var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local"); | ||
if (cm.getCursor().line >= visibleBottomLine) | ||
cm.execCommand("goLineUp"); | ||
} | ||
cm.scrollTo(null, info.top - cm.defaultTextHeight()); | ||
}; | ||
cmds[map[ctrl + "Down"] = "scrollLineDown"] = function(cm) { | ||
cm.scrollTo(null, cm.getScrollInfo().top + cm.defaultTextHeight()); | ||
var info = cm.getScrollInfo(); | ||
if (!cm.somethingSelected()) { | ||
var visibleTopLine = cm.lineAtHeight(info.top, "local")+1; | ||
if (cm.getCursor().line <= visibleTopLine) | ||
cm.execCommand("goLineDown"); | ||
} | ||
cm.scrollTo(null, info.top + cm.defaultTextHeight()); | ||
}; | ||
@@ -61,0 +73,0 @@ |
@@ -176,3 +176,2 @@ (function(mod) { | ||
(function() { | ||
function words(str) { | ||
@@ -255,2 +254,3 @@ var obj = {}, words = str.split(" "); | ||
function def(mimes, mode) { | ||
if (typeof mimes == "string") mimes = [mimes]; | ||
var words = []; | ||
@@ -300,3 +300,3 @@ function add(obj) { | ||
}); | ||
CodeMirror.defineMIME("text/x-java", { | ||
def("text/x-java", { | ||
name: "clike", | ||
@@ -318,3 +318,3 @@ keywords: words("abstract assert boolean break byte case catch char class const continue default " + | ||
}); | ||
CodeMirror.defineMIME("text/x-csharp", { | ||
def("text/x-csharp", { | ||
name: "clike", | ||
@@ -345,3 +345,3 @@ keywords: words("abstract as base break case catch checked class const continue" + | ||
}); | ||
CodeMirror.defineMIME("text/x-scala", { | ||
def("text/x-scala", { | ||
name: "clike", | ||
@@ -440,4 +440,3 @@ keywords: words( | ||
}); | ||
}()); | ||
}); |
@@ -19,2 +19,3 @@ (function(mod) { | ||
propertyKeywords = parserConfig.propertyKeywords || {}, | ||
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {}, | ||
colorKeywords = parserConfig.colorKeywords || {}, | ||
@@ -95,3 +96,3 @@ valueKeywords = parserConfig.valueKeywords || {}, | ||
stream.next(); // Must be '(' | ||
if (!stream.match(/\s*[\"\']/, false)) | ||
if (!stream.match(/\s*[\"\')]/, false)) | ||
state.tokenize = tokenString(")"); | ||
@@ -175,5 +176,9 @@ else | ||
if (type == "word") { | ||
if (propertyKeywords.hasOwnProperty(stream.current().toLowerCase())) { | ||
var word = stream.current().toLowerCase(); | ||
if (propertyKeywords.hasOwnProperty(word)) { | ||
override = "property"; | ||
return "maybeprop"; | ||
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) { | ||
override = "string-2"; | ||
return "maybeprop"; | ||
} else if (allowNested) { | ||
@@ -450,7 +455,7 @@ override = stream.match(/^\s*:/, false) ? "property" : "tag"; | ||
"voice-volume", "volume", "white-space", "widows", "width", "word-break", | ||
"word-spacing", "word-wrap", "z-index", "zoom", | ||
"word-spacing", "word-wrap", "z-index", | ||
// SVG-specific | ||
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color", | ||
"flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events", | ||
"color-interpolation", "color-interpolation-filters", "color-profile", | ||
"color-interpolation", "color-interpolation-filters", | ||
"color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering", | ||
@@ -461,5 +466,13 @@ "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke", | ||
"baseline-shift", "dominant-baseline", "glyph-orientation-horizontal", | ||
"glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode" | ||
"glyph-orientation-vertical", "text-anchor", "writing-mode" | ||
], propertyKeywords = keySet(propertyKeywords_); | ||
var nonStandardPropertyKeywords = [ | ||
"scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color", | ||
"scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color", | ||
"scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside", | ||
"searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button", | ||
"searchfield-results-decoration", "zoom" | ||
], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords); | ||
var colorKeywords_ = [ | ||
@@ -584,3 +597,4 @@ "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", | ||
var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_).concat(colorKeywords_).concat(valueKeywords_); | ||
var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_) | ||
.concat(nonStandardPropertyKeywords).concat(colorKeywords_).concat(valueKeywords_); | ||
CodeMirror.registerHelper("hintWords", "css", allWords); | ||
@@ -614,2 +628,3 @@ | ||
propertyKeywords: propertyKeywords, | ||
nonStandardPropertyKeywords: nonStandardPropertyKeywords, | ||
colorKeywords: colorKeywords, | ||
@@ -637,2 +652,3 @@ valueKeywords: valueKeywords, | ||
propertyKeywords: propertyKeywords, | ||
nonStandardPropertyKeywords: nonStandardPropertyKeywords, | ||
colorKeywords: colorKeywords, | ||
@@ -678,2 +694,3 @@ valueKeywords: valueKeywords, | ||
propertyKeywords: propertyKeywords, | ||
nonStandardPropertyKeywords: nonStandardPropertyKeywords, | ||
colorKeywords: colorKeywords, | ||
@@ -680,0 +697,0 @@ valueKeywords: valueKeywords, |
@@ -119,2 +119,5 @@ (function() { | ||
"}"); | ||
MT("empty_url", | ||
"[def @import] [tag url]() [tag screen];"); | ||
})(); |
@@ -361,3 +361,3 @@ /*jshint unused:true, eqnull:true, curly:true, bitwise:true */ | ||
case "attribute": return "attribute"; | ||
case "boolean": return "special"; | ||
case "boolean": return "atom"; | ||
case "builtin": return "builtin"; | ||
@@ -364,0 +364,0 @@ case "close_paren": return null; |
@@ -172,2 +172,3 @@ (function(mod) { | ||
electricChars: "{}):", | ||
fold: "brace", | ||
blockCommentStart: "/*", | ||
@@ -174,0 +175,0 @@ blockCommentEnd: "*/", |
@@ -11,5 +11,2 @@ (function(mod) { | ||
(function() { | ||
"use strict"; | ||
// full haml mode. This handled embeded ruby and html fragments too | ||
@@ -79,3 +76,3 @@ CodeMirror.defineMode("haml", function(config) { | ||
state.tokenize = ruby; | ||
return null; | ||
return state.tokenize(stream, state); | ||
} | ||
@@ -88,6 +85,6 @@ | ||
state.tokenize = rubyInQuote(")"); | ||
return null; | ||
return state.tokenize(stream, state); | ||
} else if (ch == "{") { | ||
state.tokenize = rubyInQuote("}"); | ||
return null; | ||
return state.tokenize(stream, state); | ||
} | ||
@@ -162,4 +159,2 @@ } | ||
CodeMirror.defineMIME("text/x-haml", "haml"); | ||
})(); | ||
}); |
@@ -31,3 +31,3 @@ (function() { | ||
MT("htmlCode", | ||
"[tag <h1>]Title[tag </h1>]"); | ||
"[tag&bracket <][tag h1][tag&bracket >]Title[tag&bracket </][tag h1][tag&bracket >]"); | ||
@@ -34,0 +34,0 @@ MT("rubyBlock", |
@@ -29,3 +29,3 @@ (function(mod) { | ||
"in": operator, "never": kw("property_access"), "trace":kw("trace"), | ||
"class": type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type, | ||
"class": type, "abstract":type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type, | ||
"true": atom, "false": atom, "null": atom | ||
@@ -320,3 +320,3 @@ }; | ||
if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); } | ||
else if(type == "variable" || type == "property" || type == ".") return cont(importdef); | ||
else if(type == "variable" || type == "property" || type == "." || value == "*") return cont(importdef); | ||
} | ||
@@ -327,2 +327,3 @@ | ||
if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); } | ||
else if (type == "type" && /[A-Z]/.test(value.charAt(0))) { return cont(); } | ||
} | ||
@@ -439,3 +440,6 @@ | ||
electricChars: "{}" | ||
electricChars: "{}", | ||
blockCommentStart: "/*", | ||
blockCommentEnd: "*/", | ||
lineComment: "//" | ||
}; | ||
@@ -446,2 +450,70 @@ }); | ||
CodeMirror.defineMode("hxml", function () { | ||
return { | ||
startState: function () { | ||
return { | ||
define: false, | ||
inString: false | ||
}; | ||
}, | ||
token: function (stream, state) { | ||
var ch = stream.peek(); | ||
var sol = stream.sol(); | ||
///* comments */ | ||
if (ch == "#") { | ||
stream.skipToEnd(); | ||
return "comment"; | ||
} | ||
if (sol && ch == "-") { | ||
var style = "variable-2"; | ||
stream.eat(/-/); | ||
if (stream.peek() == "-") { | ||
stream.eat(/-/); | ||
style = "keyword a"; | ||
} | ||
if (stream.peek() == "D") { | ||
stream.eat(/[D]/); | ||
style = "keyword c"; | ||
state.define = true; | ||
} | ||
stream.eatWhile(/[A-Z]/i); | ||
return style; | ||
} | ||
var ch = stream.peek(); | ||
if (state.inString == false && ch == "'") { | ||
state.inString = true; | ||
ch = stream.next(); | ||
} | ||
if (state.inString == true) { | ||
if (stream.skipTo("'")) { | ||
} else { | ||
stream.skipToEnd(); | ||
} | ||
if (stream.peek() == "'") { | ||
stream.next(); | ||
state.inString = false; | ||
} | ||
return "string"; | ||
} | ||
stream.next(); | ||
return null; | ||
} | ||
}; | ||
}); | ||
CodeMirror.defineMIME("text/x-hxml", "hxml"); | ||
}); |
@@ -328,3 +328,7 @@ // TODO actually recognize syntax of TypeScript constructs | ||
if (type == ";") return cont(); | ||
if (type == "if") return cont(pushlex("form"), expression, statement, poplex, maybeelse); | ||
if (type == "if") { | ||
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex) | ||
cx.state.cc.pop()(); | ||
return cont(pushlex("form"), expression, statement, poplex, maybeelse); | ||
} | ||
if (type == "function") return cont(functiondef); | ||
@@ -360,3 +364,3 @@ if (type == "for") return cont(pushlex("form"), forspec, statement, poplex); | ||
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop); | ||
if (type == "function") return cont(functiondef); | ||
if (type == "function") return cont(functiondef, maybeop); | ||
if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression); | ||
@@ -367,2 +371,3 @@ if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop); | ||
if (type == "{") return contCommasep(objprop, "}", null, maybeop); | ||
if (type == "quasi") { return pass(quasi, maybeop); } | ||
return cont(); | ||
@@ -392,3 +397,3 @@ } | ||
} | ||
if (type == "quasi") { cx.cc.push(me); return quasi(value); } | ||
if (type == "quasi") { return pass(quasi, me); } | ||
if (type == ";") return; | ||
@@ -399,4 +404,5 @@ if (type == "(") return contCommasep(expressionNoComma, ")", "call", me); | ||
} | ||
function quasi(value) { | ||
if (value.slice(value.length - 2) != "${") return cont(); | ||
function quasi(type, value) { | ||
if (type != "quasi") return pass(); | ||
if (value.slice(value.length - 2) != "${") return cont(quasi); | ||
return cont(expression, continueQuasi); | ||
@@ -408,3 +414,3 @@ } | ||
cx.state.tokenize = tokenQuasi; | ||
return cont(); | ||
return cont(quasi); | ||
} | ||
@@ -502,3 +508,3 @@ } | ||
function maybeelse(type, value) { | ||
if (type == "keyword b" && value == "else") return cont(pushlex("form"), statement, poplex); | ||
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex); | ||
} | ||
@@ -616,3 +622,3 @@ function forspec(type) { | ||
// Kludge to prevent 'maybelse' from blocking lexical scope pops | ||
for (var i = state.cc.length - 1; i >= 0; --i) { | ||
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) { | ||
var c = state.cc[i]; | ||
@@ -619,0 +625,0 @@ if (c == poplex) lexical = lexical.prev; |
@@ -73,2 +73,5 @@ (function() { | ||
MT("quasi_no_function", | ||
"[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]"); | ||
MT("indent_statement", | ||
@@ -108,2 +111,18 @@ "[keyword var] [variable x] [operator =] [number 10]", | ||
MT("indent_else", | ||
"[keyword for] (;;)", | ||
" [keyword if] ([variable foo])", | ||
" [keyword if] ([variable bar])", | ||
" [number 1];", | ||
" [keyword else]", | ||
" [number 2];", | ||
" [keyword else]", | ||
" [number 3];"); | ||
MT("indent_below_if", | ||
"[keyword for] (;;)", | ||
" [keyword if] ([variable foo])", | ||
" [number 1];", | ||
"[number 2];"); | ||
MT("multilinestring", | ||
@@ -110,0 +129,0 @@ "[keyword var] [variable x] [operator =] [string 'foo\\]", |
@@ -13,43 +13,119 @@ (function(mod) { | ||
var keywords = ["and", "as", "block", "endblock", "by", "cycle", "debug", "else", "elif", | ||
"extends", "filter", "endfilter", "firstof", "for", | ||
"endfor", "if", "endif", "ifchanged", "endifchanged", | ||
"ifequal", "endifequal", "ifnotequal", | ||
"endifnotequal", "in", "include", "load", "not", "now", "or", | ||
"parsed", "regroup", "reversed", "spaceless", | ||
"endspaceless", "ssi", "templatetag", "openblock", | ||
"closeblock", "openvariable", "closevariable", | ||
"openbrace", "closebrace", "opencomment", | ||
"closecomment", "widthratio", "url", "with", "endwith", | ||
"get_current_language", "trans", "noop", "blocktrans", | ||
"endblocktrans", "get_available_languages", | ||
"get_current_language_bidi", "plural"]; | ||
keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b"); | ||
"extends", "filter", "endfilter", "firstof", "for", | ||
"endfor", "if", "endif", "ifchanged", "endifchanged", | ||
"ifequal", "endifequal", "ifnotequal", | ||
"endifnotequal", "in", "include", "load", "not", "now", "or", | ||
"parsed", "regroup", "reversed", "spaceless", | ||
"endspaceless", "ssi", "templatetag", "openblock", | ||
"closeblock", "openvariable", "closevariable", | ||
"openbrace", "closebrace", "opencomment", | ||
"closecomment", "widthratio", "url", "with", "endwith", | ||
"get_current_language", "trans", "endtrans", "noop", "blocktrans", | ||
"endblocktrans", "get_available_languages", | ||
"get_current_language_bidi", "plural"], | ||
operator = /^[+\-*&%=<>!?|~^]/, | ||
sign = /^[:\[\(\{]/, | ||
atom = ["true", "false"], | ||
number = /^(\d[+\-\*\/])?\d+(\.\d+)?/; | ||
keywords = new RegExp("((" + keywords.join(")|(") + "))\\b"); | ||
atom = new RegExp("((" + atom.join(")|(") + "))\\b"); | ||
function tokenBase (stream, state) { | ||
var ch = stream.next(); | ||
if (ch == "{") { | ||
if (ch = stream.eat(/\{|%|#/)) { | ||
var ch = stream.peek(); | ||
//Comment | ||
if (state.incomment) { | ||
if(!stream.skipTo("#}")) { | ||
stream.skipToEnd(); | ||
} else { | ||
stream.eatWhile(/\#|}/); | ||
state.incomment = false; | ||
} | ||
return "comment"; | ||
//Tag | ||
} else if (state.intag) { | ||
//After operator | ||
if(state.operator) { | ||
state.operator = false; | ||
if(stream.match(atom)) { | ||
return "atom"; | ||
} | ||
if(stream.match(number)) { | ||
return "number"; | ||
} | ||
} | ||
//After sign | ||
if(state.sign) { | ||
state.sign = false; | ||
if(stream.match(atom)) { | ||
return "atom"; | ||
} | ||
if(stream.match(number)) { | ||
return "number"; | ||
} | ||
} | ||
if(state.instring) { | ||
if(ch == state.instring) { | ||
state.instring = false; | ||
} | ||
stream.next(); | ||
return "string"; | ||
} else if(ch == "'" || ch == '"') { | ||
state.instring = ch; | ||
stream.next(); | ||
return "string"; | ||
} else if(stream.match(state.intag + "}") || stream.eat("-") && stream.match(state.intag + "}")) { | ||
state.intag = false; | ||
return "tag"; | ||
} else if(stream.match(operator)) { | ||
state.operator = true; | ||
return "operator"; | ||
} else if(stream.match(sign)) { | ||
state.sign = true; | ||
} else { | ||
if(stream.eat(" ") || stream.sol()) { | ||
if(stream.match(keywords)) { | ||
return "keyword"; | ||
} | ||
if(stream.match(atom)) { | ||
return "atom"; | ||
} | ||
if(stream.match(number)) { | ||
return "number"; | ||
} | ||
if(stream.sol()) { | ||
stream.next(); | ||
} | ||
} else { | ||
stream.next(); | ||
} | ||
} | ||
return "variable"; | ||
} else if (stream.eat("{")) { | ||
if (ch = stream.eat("#")) { | ||
state.incomment = true; | ||
if(!stream.skipTo("#}")) { | ||
stream.skipToEnd(); | ||
} else { | ||
stream.eatWhile(/\#|}/); | ||
state.incomment = false; | ||
} | ||
return "comment"; | ||
//Open tag | ||
} else if (ch = stream.eat(/\{|%/)) { | ||
//Cache close tag | ||
state.intag = ch; | ||
if(ch == "{") { | ||
state.intag = "}"; | ||
} | ||
stream.eat("-"); | ||
state.tokenize = inTag(ch); | ||
return "tag"; | ||
} | ||
} | ||
} | ||
function inTag (close) { | ||
if (close == "{") { | ||
close = "}"; | ||
} | ||
return function (stream, state) { | ||
var ch = stream.next(); | ||
if ((ch == close || (ch == "-" && stream.eat(close))) | ||
&& stream.eat("}")) { | ||
state.tokenize = tokenBase; | ||
return "tag"; | ||
} | ||
if (stream.match(keywords)) { | ||
return "keyword"; | ||
} | ||
return close == "#" ? "comment" : "string"; | ||
}; | ||
} | ||
stream.next(); | ||
}; | ||
return { | ||
@@ -56,0 +132,0 @@ startState: function () { |
@@ -27,3 +27,3 @@ /** | ||
if (r.regex && (m = stream.match(r.regex))) { | ||
state.next = r.next; | ||
state.next = r.next || state.next; | ||
return r.token; | ||
@@ -207,3 +207,3 @@ } | ||
token: 'text', | ||
regex: '.', | ||
regex: '', | ||
next: 'start' | ||
@@ -270,7 +270,7 @@ } | ||
var rr = r[i]; | ||
if (rr.regex) { | ||
if (typeof rr.regex === 'string') { | ||
Rules[idx][i].regex = new RegExp('^' + rr.regex); | ||
} | ||
} | ||
} else if (r.regex) { | ||
} else if (typeof rr.regex === 'string') { | ||
Rules[idx].regex = new RegExp('^' + r.regex); | ||
@@ -277,0 +277,0 @@ } |
@@ -712,3 +712,4 @@ (function(mod) { | ||
state.prevLineHasContent = false; | ||
return blankLine(state); | ||
blankLine(state); | ||
return this.token(stream, state); | ||
} else { | ||
@@ -741,3 +742,5 @@ state.prevLineHasContent = state.thisLineHasContent; | ||
} | ||
return state.f(stream, state); | ||
var result = state.f(stream, state); | ||
if (stream.start == stream.pos) return this.token(stream, state); | ||
else return result; | ||
}, | ||
@@ -744,0 +747,0 @@ |
@@ -27,2 +27,3 @@ (function(mod) { | ||
{name: 'DTD', mime: 'application/xml-dtd', mode: 'dtd'}, | ||
{name: 'Dylan', mime: 'text/x-dylan', mode: 'dylan'}, | ||
{name: 'ECL', mime: 'text/x-ecl', mode: 'ecl'}, | ||
@@ -92,2 +93,3 @@ {name: 'Eiffel', mime: 'text/x-eiffel', mode: 'eiffel'}, | ||
{name: 'LaTeX', mime: 'text/x-latex', mode: 'stex'}, | ||
{name: 'SystemVerilog', mime: 'text/x-systemverilog', mode: 'verilog'}, | ||
{name: 'Tcl', mime: 'text/x-tcl', mode: 'tcl'}, | ||
@@ -94,0 +96,0 @@ {name: 'TiddlyWiki ', mime: 'text/x-tiddlywiki', mode: 'tiddlywiki'}, |
@@ -23,13 +23,84 @@ (function(mod) { | ||
} | ||
// Helper for stringWithEscapes | ||
function matchSequence(list) { | ||
if (list.length == 0) return stringWithEscapes; | ||
return function (stream, state) { | ||
var patterns = list[0]; | ||
for (var i = 0; i < patterns.length; i++) if (stream.match(patterns[i][0])) { | ||
state.tokenize = matchSequence(list.slice(1)); | ||
return patterns[i][1]; | ||
} | ||
state.tokenize = stringWithEscapes; | ||
return "string"; | ||
}; | ||
} | ||
function stringWithEscapes(stream, state) { | ||
var escaped = false, next, end = false; | ||
if (stream.current() == '"') return "string"; | ||
// "Complex" syntax | ||
if (stream.match("${", false) || stream.match("{$", false)) { | ||
state.tokenize = null; | ||
return "string"; | ||
} | ||
// Simple syntax | ||
if (stream.match(/\$[a-zA-Z_][a-zA-Z0-9_]*/)) { | ||
// After the variable name there may appear array or object operator. | ||
if (stream.match("[", false)) { | ||
// Match array operator | ||
state.tokenize = matchSequence([ | ||
[["[", null]], | ||
[[/\d[\w\.]*/, "number"], | ||
[/\$[a-zA-Z_][a-zA-Z0-9_]*/, "variable-2"], | ||
[/[\w\$]+/, "variable"]], | ||
[["]", null]] | ||
]); | ||
} | ||
if (stream.match(/\-\>\w/, false)) { | ||
// Match object operator | ||
state.tokenize = matchSequence([ | ||
[["->", null]], | ||
[[/[\w]+/, "variable"]] | ||
]); | ||
} | ||
return "variable-2"; | ||
} | ||
// Normal string | ||
while ( | ||
!stream.eol() && | ||
(!stream.match("{$", false)) && | ||
(!stream.match(/(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false) || escaped) | ||
) { | ||
next = stream.next(); | ||
if (!escaped && next == '"') { end = true; break; } | ||
escaped = !escaped && next == "\\"; | ||
} | ||
if (end) { | ||
state.tokenize = null; | ||
state.phpEncapsStack.pop(); | ||
} | ||
return "string"; | ||
} | ||
var phpKeywords = "abstract and array as break case catch class clone const continue declare default " + | ||
"do else elseif enddeclare endfor endforeach endif endswitch endwhile extends final " + | ||
"for foreach function global goto if implements interface instanceof namespace " + | ||
"new or private protected public static switch throw trait try use var while xor " + | ||
"die echo empty exit eval include include_once isset list require require_once return " + | ||
"print unset __halt_compiler self static parent yield insteadof finally"; | ||
var phpAtoms = "true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__"; | ||
var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once"; | ||
CodeMirror.registerHelper("hintWords", "php", [phpKeywords, phpAtoms, phpBuiltin].join(" ").split(" ")); | ||
var phpConfig = { | ||
name: "clike", | ||
keywords: keywords("abstract and array as break case catch class clone const continue declare default " + | ||
"do else elseif enddeclare endfor endforeach endif endswitch endwhile extends final " + | ||
"for foreach function global goto if implements interface instanceof namespace " + | ||
"new or private protected public static switch throw trait try use var while xor " + | ||
"die echo empty exit eval include include_once isset list require require_once return " + | ||
"print unset __halt_compiler self static parent yield insteadof finally"), | ||
helperType: "php", | ||
keywords: keywords(phpKeywords), | ||
blockKeywords: keywords("catch do else elseif for foreach if switch try while finally"), | ||
atoms: keywords("true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__"), | ||
builtin: keywords("func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once"), | ||
atoms: keywords(phpAtoms), | ||
builtin: keywords(phpBuiltin), | ||
multiLineStrings: true, | ||
@@ -59,2 +130,20 @@ hooks: { | ||
return false; | ||
}, | ||
'"': function(stream, state) { | ||
if (!state.phpEncapsStack) | ||
state.phpEncapsStack = []; | ||
state.phpEncapsStack.push(0); | ||
state.tokenize = stringWithEscapes; | ||
return state.tokenize(stream, state); | ||
}, | ||
"{": function(_stream, state) { | ||
if (state.phpEncapsStack && state.phpEncapsStack.length > 0) | ||
state.phpEncapsStack[state.phpEncapsStack.length - 1]++; | ||
return false; | ||
}, | ||
"}": function(_stream, state) { | ||
if (state.phpEncapsStack && state.phpEncapsStack.length > 0) | ||
if (--state.phpEncapsStack[state.phpEncapsStack.length - 1] == 0) | ||
state.tokenize = stringWithEscapes; | ||
return false; | ||
} | ||
@@ -99,3 +188,4 @@ } | ||
} else { | ||
return phpMode.token(stream, state.curState); | ||
var result = phpMode.token(stream, state.curState); | ||
return (stream.pos <= stream.start) ? phpMode.token(stream, state.curState) : result; | ||
} | ||
@@ -102,0 +192,0 @@ } |
@@ -151,3 +151,5 @@ (function(mod) { | ||
else return ctx.indent + (closing ? 0 : config.indentUnit); | ||
} | ||
}, | ||
lineComment: "#" | ||
}; | ||
@@ -154,0 +156,0 @@ }); |
@@ -12,31 +12,137 @@ (function(mod) { | ||
CodeMirror.defineMode("verilog", function(config, parserConfig) { | ||
var indentUnit = config.indentUnit, | ||
keywords = parserConfig.keywords || {}, | ||
blockKeywords = parserConfig.blockKeywords || {}, | ||
atoms = parserConfig.atoms || {}, | ||
hooks = parserConfig.hooks || {}, | ||
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit, | ||
dontAlignCalls = parserConfig.dontAlignCalls, | ||
noIndentKeywords = parserConfig.noIndentKeywords || [], | ||
multiLineStrings = parserConfig.multiLineStrings; | ||
var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/; | ||
function words(str) { | ||
var obj = {}, words = str.split(" "); | ||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true; | ||
return obj; | ||
} | ||
/** | ||
* Keywords from IEEE 1800-2012 | ||
*/ | ||
var keywords = words( | ||
"accept_on alias always always_comb always_ff always_latch and assert assign assume automatic before begin bind " + | ||
"bins binsof bit break buf bufif0 bufif1 byte case casex casez cell chandle checker class clocking cmos config " + | ||
"const constraint context continue cover covergroup coverpoint cross deassign default defparam design disable " + | ||
"dist do edge else end endcase endchecker endclass endclocking endconfig endfunction endgenerate endgroup " + | ||
"endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask " + | ||
"enum event eventually expect export extends extern final first_match for force foreach forever fork forkjoin " + | ||
"function generate genvar global highz0 highz1 if iff ifnone ignore_bins illegal_bins implements implies import " + | ||
"incdir include initial inout input inside instance int integer interconnect interface intersect join join_any " + | ||
"join_none large let liblist library local localparam logic longint macromodule matches medium modport module " + | ||
"nand negedge nettype new nexttime nmos nor noshowcancelled not notif0 notif1 null or output package packed " + | ||
"parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup " + | ||
"pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos real realtime ref reg " + | ||
"reject_on release repeat restrict return rnmos rpmos rtran rtranif0 rtranif1 s_always s_eventually s_nexttime " + | ||
"s_until s_until_with scalared sequence shortint shortreal showcancelled signed small soft solve specify " + | ||
"specparam static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on sync_reject_on " + | ||
"table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior " + | ||
"trireg type typedef union unique unique0 unsigned until until_with untyped use uwire var vectored virtual void " + | ||
"wait wait_order wand weak weak0 weak1 while wildcard wire with within wor xnor xor"); | ||
/** Operators from IEEE 1800-2012 | ||
unary_operator ::= | ||
+ | - | ! | ~ | & | ~& | | | ~| | ^ | ~^ | ^~ | ||
binary_operator ::= | ||
+ | - | * | / | % | == | != | === | !== | ==? | !=? | && | || | ** | ||
| < | <= | > | >= | & | | | ^ | ^~ | ~^ | >> | << | >>> | <<< | ||
| -> | <-> | ||
inc_or_dec_operator ::= ++ | -- | ||
unary_module_path_operator ::= | ||
! | ~ | & | ~& | | | ~| | ^ | ~^ | ^~ | ||
binary_module_path_operator ::= | ||
== | != | && | || | & | | | ^ | ^~ | ~^ | ||
*/ | ||
var isOperatorChar = /[\+\-\*\/!~&|^%=?:]/; | ||
var isBracketChar = /[\[\]{}()]/; | ||
var unsignedNumber = /\d[0-9_]*/; | ||
var decimalLiteral = /\d*\s*'s?d\s*\d[0-9_]*/i; | ||
var binaryLiteral = /\d*\s*'s?b\s*[xz01][xz01_]*/i; | ||
var octLiteral = /\d*\s*'s?o\s*[xz0-7][xz0-7_]*/i; | ||
var hexLiteral = /\d*\s*'s?h\s*[0-9a-fxz?][0-9a-fxz?_]*/i; | ||
var realLiteral = /(\d[\d_]*(\.\d[\d_]*)?E-?[\d_]+)|(\d[\d_]*\.\d[\d_]*)/i; | ||
var closingBracketOrWord = /^((\w+)|[)}\]])/; | ||
var closingBracket = /[)}\]]/; | ||
var curPunc; | ||
var curKeyword; | ||
// Block openings which are closed by a matching keyword in the form of ("end" + keyword) | ||
// E.g. "task" => "endtask" | ||
var blockKeywords = words( | ||
"case checker class clocking config function generate group interface module package" + | ||
"primitive program property specify sequence table task" | ||
); | ||
// Opening/closing pairs | ||
var openClose = {}; | ||
for (var keyword in blockKeywords) { | ||
openClose[keyword] = "end" + keyword; | ||
} | ||
openClose["begin"] = "end"; | ||
openClose["casex"] = "endcase"; | ||
openClose["casez"] = "endcase"; | ||
openClose["do" ] = "while"; | ||
openClose["fork" ] = "join;join_any;join_none"; | ||
for (var i in noIndentKeywords) { | ||
var keyword = noIndentKeywords[i]; | ||
if (openClose[keyword]) { | ||
openClose[keyword] = undefined; | ||
} | ||
} | ||
var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else for foreach forever if initial repeat while"); | ||
function tokenBase(stream, state) { | ||
var ch = stream.next(); | ||
if (hooks[ch]) { | ||
var result = hooks[ch](stream, state); | ||
if (result !== false) return result; | ||
var ch = stream.peek(); | ||
if (/[,;:\.]/.test(ch)) { | ||
curPunc = stream.next(); | ||
return null; | ||
} | ||
if (isBracketChar.test(ch)) { | ||
curPunc = stream.next(); | ||
return "bracket"; | ||
} | ||
// Macros (tick-defines) | ||
if (ch == '`') { | ||
stream.next(); | ||
if (stream.eatWhile(/[\w\$_]/)) { | ||
return "def"; | ||
} else { | ||
return null; | ||
} | ||
} | ||
// System calls | ||
if (ch == '$') { | ||
stream.next(); | ||
if (stream.eatWhile(/[\w\$_]/)) { | ||
return "meta"; | ||
} else { | ||
return null; | ||
} | ||
} | ||
// Time literals | ||
if (ch == '#') { | ||
stream.next(); | ||
stream.eatWhile(/[\d_.]/); | ||
return "def"; | ||
} | ||
// Strings | ||
if (ch == '"') { | ||
stream.next(); | ||
state.tokenize = tokenString(ch); | ||
return state.tokenize(stream, state); | ||
} | ||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) { | ||
curPunc = ch; | ||
return null; | ||
} | ||
if (/[\d']/.test(ch)) { | ||
stream.eatWhile(/[\w\.']/); | ||
return "number"; | ||
} | ||
// Comments | ||
if (ch == "/") { | ||
stream.next(); | ||
if (stream.eat("*")) { | ||
@@ -50,15 +156,39 @@ state.tokenize = tokenComment; | ||
} | ||
stream.backUp(1); | ||
} | ||
if (isOperatorChar.test(ch)) { | ||
stream.eatWhile(isOperatorChar); | ||
return "operator"; | ||
// Numeric literals | ||
if (stream.match(realLiteral) || | ||
stream.match(decimalLiteral) || | ||
stream.match(binaryLiteral) || | ||
stream.match(octLiteral) || | ||
stream.match(hexLiteral) || | ||
stream.match(unsignedNumber) || | ||
stream.match(realLiteral)) { | ||
return "number"; | ||
} | ||
stream.eatWhile(/[\w\$_]/); | ||
var cur = stream.current(); | ||
if (keywords.propertyIsEnumerable(cur)) { | ||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; | ||
return "keyword"; | ||
// Operators | ||
if (stream.eatWhile(isOperatorChar)) { | ||
return "meta"; | ||
} | ||
if (atoms.propertyIsEnumerable(cur)) return "atom"; | ||
return "variable"; | ||
// Keywords / plain variables | ||
if (stream.eatWhile(/[\w\$_]/)) { | ||
var cur = stream.current(); | ||
if (keywords[cur]) { | ||
if (openClose[cur]) { | ||
curPunc = "newblock"; | ||
} | ||
if (statementKeywords[cur]) { | ||
curPunc = "newstatement"; | ||
} | ||
curKeyword = cur; | ||
return "keyword"; | ||
} | ||
return "variable"; | ||
} | ||
stream.next(); | ||
return null; | ||
} | ||
@@ -99,14 +229,52 @@ | ||
function pushContext(state, col, type) { | ||
return state.context = new Context(state.indented, col, type, null, state.context); | ||
var indent = state.indented; | ||
var c = new Context(indent, col, type, null, state.context); | ||
return state.context = c; | ||
} | ||
function popContext(state) { | ||
var t = state.context.type; | ||
if (t == ")" || t == "]" || t == "}") | ||
if (t == ")" || t == "]" || t == "}") { | ||
state.indented = state.context.indented; | ||
} | ||
return state.context = state.context.prev; | ||
} | ||
function isClosing(text, contextClosing) { | ||
if (text == contextClosing) { | ||
return true; | ||
} else { | ||
// contextClosing may be mulitple keywords separated by ; | ||
var closingKeywords = contextClosing.split(";"); | ||
for (var i in closingKeywords) { | ||
if (text == closingKeywords[i]) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
function buildElectricInputRegEx() { | ||
// Reindentation should occur on any bracket char: {}()[] | ||
// or on a match of any of the block closing keywords, at | ||
// the end of a line | ||
var allClosings = []; | ||
for (var i in openClose) { | ||
if (openClose[i]) { | ||
var closings = openClose[i].split(";"); | ||
for (var j in closings) { | ||
allClosings.push(closings[j]); | ||
} | ||
} | ||
} | ||
var re = new RegExp("[{}()\\[\\]]|(" + allClosings.join("|") + ")$"); | ||
return re; | ||
} | ||
// Interface | ||
return { | ||
return { | ||
// Regex to force current line to reindent | ||
electricInput: buildElectricInputRegEx(), | ||
startState: function(basecolumn) { | ||
@@ -130,18 +298,26 @@ return { | ||
curPunc = null; | ||
curKeyword = null; | ||
var style = (state.tokenize || tokenBase)(stream, state); | ||
if (style == "comment" || style == "meta") return style; | ||
if (style == "comment" || style == "meta" || style == "variable") return style; | ||
if (ctx.align == null) ctx.align = true; | ||
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state); | ||
else if (curPunc == "{") pushContext(state, stream.column(), "}"); | ||
else if (curPunc == "[") pushContext(state, stream.column(), "]"); | ||
else if (curPunc == "(") pushContext(state, stream.column(), ")"); | ||
else if (curPunc == "}") { | ||
while (ctx.type == "statement") ctx = popContext(state); | ||
if (ctx.type == "}") ctx = popContext(state); | ||
while (ctx.type == "statement") ctx = popContext(state); | ||
if (curPunc == ctx.type) { | ||
popContext(state); | ||
} | ||
else if (curPunc == ctx.type) popContext(state); | ||
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement")) | ||
else if ((curPunc == ";" && ctx.type == "statement") || | ||
(ctx.type && isClosing(curKeyword, ctx.type))) { | ||
ctx = popContext(state); | ||
while (ctx && ctx.type == "statement") ctx = popContext(state); | ||
} | ||
else if (curPunc == "{") { pushContext(state, stream.column(), "}"); } | ||
else if (curPunc == "[") { pushContext(state, stream.column(), "]"); } | ||
else if (curPunc == "(") { pushContext(state, stream.column(), ")"); } | ||
else if (ctx && ctx.type == "endcase" && curPunc == ":") { pushContext(state, stream.column(), "statement"); } | ||
else if (curPunc == "newstatement") { | ||
pushContext(state, stream.column(), "statement"); | ||
} else if (curPunc == "newblock") { | ||
var close = openClose[curKeyword]; | ||
pushContext(state, stream.column(), close); | ||
} | ||
state.startOfLine = false; | ||
@@ -152,46 +328,29 @@ return style; | ||
indent: function(state, textAfter) { | ||
if (state.tokenize != tokenBase && state.tokenize != null) return 0; | ||
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type; | ||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit); | ||
else if (ctx.align) return ctx.column + (closing ? 0 : 1); | ||
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass; | ||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); | ||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev; | ||
var closing = false; | ||
var possibleClosing = textAfter.match(closingBracketOrWord); | ||
if (possibleClosing) { | ||
closing = isClosing(possibleClosing[0], ctx.type); | ||
} | ||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit); | ||
else if (closingBracket.test(ctx.type) && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1); | ||
else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit; | ||
else return ctx.indented + (closing ? 0 : indentUnit); | ||
}, | ||
electricChars: "{}" | ||
blockCommentStart: "/*", | ||
blockCommentEnd: "*/", | ||
lineComment: "//" | ||
}; | ||
}); | ||
function words(str) { | ||
var obj = {}, words = str.split(" "); | ||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true; | ||
return obj; | ||
} | ||
CodeMirror.defineMIME("text/x-verilog", { | ||
name: "verilog" | ||
}); | ||
CodeMirror.defineMIME("text/x-systemverilog", { | ||
name: "systemverilog" | ||
}); | ||
var verilogKeywords = "always and assign automatic begin buf bufif0 bufif1 case casex casez cell cmos config " + | ||
"deassign default defparam design disable edge else end endcase endconfig endfunction endgenerate endmodule " + | ||
"endprimitive endspecify endtable endtask event for force forever fork function generate genvar highz0 " + | ||
"highz1 if ifnone incdir include initial inout input instance integer join large liblist library localparam " + | ||
"macromodule medium module nand negedge nmos nor noshowcancelled not notif0 notif1 or output parameter pmos " + | ||
"posedge primitive pull0 pull1 pulldown pullup pulsestyle_onevent pulsestyle_ondetect rcmos real realtime " + | ||
"reg release repeat rnmos rpmos rtran rtranif0 rtranif1 scalared showcancelled signed small specify specparam " + | ||
"strong0 strong1 supply0 supply1 table task time tran tranif0 tranif1 tri tri0 tri1 triand trior trireg " + | ||
"unsigned use vectored wait wand weak0 weak1 while wire wor xnor xor"; | ||
var verilogBlockKeywords = "begin bufif0 bufif1 case casex casez config else end endcase endconfig endfunction " + | ||
"endgenerate endmodule endprimitive endspecify endtable endtask for forever function generate if ifnone " + | ||
"macromodule module primitive repeat specify table task while"; | ||
function metaHook(stream) { | ||
stream.eatWhile(/[\w\$_]/); | ||
return "meta"; | ||
} | ||
CodeMirror.defineMIME("text/x-verilog", { | ||
name: "verilog", | ||
keywords: words(verilogKeywords), | ||
blockKeywords: words(verilogBlockKeywords), | ||
atoms: words("null"), | ||
hooks: {"`": metaHook, "$": metaHook} | ||
}); | ||
}); |
@@ -61,3 +61,3 @@ (function(mod) { | ||
// Return variables for tokenizers | ||
var tagName, type, setStyle; | ||
var type, setStyle; | ||
@@ -89,11 +89,5 @@ function inText(stream, state) { | ||
} else { | ||
var isClose = stream.eat("/"); | ||
tagName = ""; | ||
var c; | ||
while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c; | ||
if (Kludges.caseFold) tagName = tagName.toLowerCase(); | ||
if (!tagName) return "tag error"; | ||
type = isClose ? "closeTag" : "openTag"; | ||
type = stream.eat("/") ? "closeTag" : "openTag"; | ||
state.tokenize = inTag; | ||
return "tag"; | ||
return "tag bracket"; | ||
} | ||
@@ -123,3 +117,3 @@ } else if (ch == "&") { | ||
type = ch == ">" ? "endTag" : "selfcloseTag"; | ||
return "tag"; | ||
return "tag bracket"; | ||
} else if (ch == "=") { | ||
@@ -139,3 +133,3 @@ type = "equals"; | ||
} else { | ||
stream.eatWhile(/[^\s\u00a0=<>\"\']/); | ||
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/); | ||
return "word"; | ||
@@ -220,20 +214,36 @@ } | ||
if (type == "openTag") { | ||
state.tagName = tagName; | ||
state.tagStart = stream.column(); | ||
return tagNameState; | ||
} else if (type == "closeTag") { | ||
return closeTagNameState; | ||
} else { | ||
return baseState; | ||
} | ||
} | ||
function tagNameState(type, stream, state) { | ||
if (type == "word") { | ||
state.tagName = stream.current(); | ||
setStyle = "tag"; | ||
return attrState; | ||
} else if (type == "closeTag") { | ||
var err = false; | ||
if (state.context) { | ||
if (state.context.tagName != tagName) { | ||
if (Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName)) | ||
popContext(state); | ||
err = !state.context || state.context.tagName != tagName; | ||
} | ||
} else { | ||
setStyle = "error"; | ||
return tagNameState; | ||
} | ||
} | ||
function closeTagNameState(type, stream, state) { | ||
if (type == "word") { | ||
var tagName = stream.current(); | ||
if (state.context && state.context.tagName != tagName && | ||
Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName)) | ||
popContext(state); | ||
if (state.context && state.context.tagName == tagName) { | ||
setStyle = "tag"; | ||
return closeState; | ||
} else { | ||
err = true; | ||
setStyle = "tag error"; | ||
return closeStateErr; | ||
} | ||
if (err) setStyle = "error"; | ||
return err ? closeStateErr : closeState; | ||
} else { | ||
return baseState; | ||
setStyle = "error"; | ||
return closeStateErr; | ||
} | ||
@@ -304,3 +314,3 @@ } | ||
if (stream.eatSpace()) return null; | ||
tagName = type = null; | ||
type = null; | ||
var style = state.tokenize(stream, state); | ||
@@ -320,3 +330,6 @@ if ((style || type) && style != "comment") { | ||
if (state.tokenize.isInAttribute) { | ||
return state.stringStartCol + 1; | ||
if (state.tagStart == state.indented) | ||
return state.stringStartCol + 1; | ||
else | ||
return state.indented + indentUnit; | ||
} | ||
@@ -334,4 +347,23 @@ if (context && context.noIndent) return CodeMirror.Pass; | ||
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0; | ||
if (context && /^<\//.test(textAfter)) | ||
context = context.prev; | ||
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter); | ||
if (tagAfter && tagAfter[1]) { // Closing tag spotted | ||
while (context) { | ||
if (context.tagName == tagAfter[2]) { | ||
context = context.prev; | ||
break; | ||
} else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) { | ||
context = context.prev; | ||
} else { | ||
break; | ||
} | ||
} | ||
} else if (tagAfter) { // Opening tag spotted | ||
while (context) { | ||
var grabbers = Kludges.contextGrabbers[context.tagName]; | ||
if (grabbers && grabbers.hasOwnProperty(tagAfter[2])) | ||
context = context.prev; | ||
else | ||
break; | ||
} | ||
} | ||
while (context && !context.startOfLine) | ||
@@ -343,3 +375,3 @@ context = context.prev; | ||
electricChars: "/", | ||
electricInput: /<\/[\s\w:]+>$/, | ||
blockCommentStart: "<!--", | ||
@@ -346,0 +378,0 @@ blockCommentEnd: "-->", |
{ | ||
"name": "codemirror", | ||
"version":"4.0.3", | ||
"version":"4.1.0", | ||
"main": "lib/codemirror.js", | ||
@@ -5,0 +5,0 @@ "description": "In-browser code editing made bearable", |
# CodeMirror | ||
[![Build Status](https://secure.travis-ci.org/marijnh/CodeMirror.png?branch=master)](http://travis-ci.org/marijnh/CodeMirror) | ||
[![NPM version](https://badge.fury.io/js/codemirror.png)](http://badge.fury.io/js/codemirror) | ||
[![Build Status](https://travis-ci.org/marijnh/CodeMirror.svg)](https://travis-ci.org/marijnh/CodeMirror) | ||
[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror) | ||
@@ -5,0 +5,0 @@ CodeMirror is a JavaScript component that provides a code editor in |
@@ -323,2 +323,25 @@ (function() { | ||
testDoc("sharedMarkerCopy", "A='abcde'", function(a) { | ||
var shared = a.markText(Pos(0, 1), Pos(0, 3), {shared: true}); | ||
var b = a.linkedDoc(); | ||
var found = b.findMarksAt(Pos(0, 2)); | ||
eq(found.length, 1); | ||
eq(found[0], shared); | ||
shared.clear(); | ||
eq(b.findMarksAt(Pos(0, 2)), 0); | ||
}); | ||
testDoc("sharedMarkerDetach", "A='abcde' B<A C<B", function(a, b, c) { | ||
var shared = a.markText(Pos(0, 1), Pos(0, 3), {shared: true}); | ||
a.unlinkDoc(b); | ||
var inB = b.findMarksAt(Pos(0, 2)); | ||
eq(inB.length, 1); | ||
is(inB[0] != shared); | ||
var inC = c.findMarksAt(Pos(0, 2)); | ||
eq(inC.length, 1); | ||
is(inC[0] != shared); | ||
inC[0].clear(); | ||
is(shared.find()); | ||
}); | ||
testDoc("sharedBookmark", "A='ab\ncd\nef\ngh' B<A C<~A/1-2", function(a, b, c) { | ||
@@ -325,0 +348,0 @@ var mark = b.setBookmark(Pos(1, 1), {shared: true}); |
@@ -123,2 +123,4 @@ /** | ||
var compare = mode.token(stream, state), substr = stream.current(); | ||
if (stream.start >= stream.pos) | ||
throw new Failure("Failed to advance the stream." + stream.string + " " + stream.pos); | ||
if (compare && compare.indexOf(" ") > -1) compare = compare.split(' ').sort().join(' '); | ||
@@ -125,0 +127,0 @@ stream.start = stream.pos; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2724272
358
46798