diff --git a/static/js/lib/codemirror-4.4/mode/verilog/test.js b/static/js/lib/codemirror-4.4/mode/verilog/test.js deleted file mode 100644 index e78860d..0000000 --- a/static/js/lib/codemirror-4.4/mode/verilog/test.js +++ /dev/null @@ -1,117 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE - -(function() { - var mode = CodeMirror.getMode({indentUnit: 4}, "verilog"); - function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } - - MT("Binary literals", - "[number 1'b0]", - "[number 1'b1]", - "[number 1'bx]", - "[number 1'bz]", - "[number 1'bX]", - "[number 1'bZ]", - "[number 1'B0]", - "[number 1'B1]", - "[number 1'Bx]", - "[number 1'Bz]", - "[number 1'BX]", - "[number 1'BZ]", - "[number 1'b0]", - "[number 1'b1]", - "[number 2'b01]", - "[number 2'bxz]", - "[number 2'b11]", - "[number 2'b10]", - "[number 2'b1Z]", - "[number 12'b0101_0101_0101]", - "[number 1'b 0]", - "[number 'b0101]" - ); - - MT("Octal literals", - "[number 3'o7]", - "[number 3'O7]", - "[number 3'so7]", - "[number 3'SO7]" - ); - - MT("Decimal literals", - "[number 0]", - "[number 1]", - "[number 7]", - "[number 123_456]", - "[number 'd33]", - "[number 8'd255]", - "[number 8'D255]", - "[number 8'sd255]", - "[number 8'SD255]", - "[number 32'd123]", - "[number 32 'd123]", - "[number 32 'd 123]" - ); - - MT("Hex literals", - "[number 4'h0]", - "[number 4'ha]", - "[number 4'hF]", - "[number 4'hx]", - "[number 4'hz]", - "[number 4'hX]", - "[number 4'hZ]", - "[number 32'hdc78]", - "[number 32'hDC78]", - "[number 32 'hDC78]", - "[number 32'h DC78]", - "[number 32 'h DC78]", - "[number 32'h44x7]", - "[number 32'hFFF?]" - ); - - MT("Real number literals", - "[number 1.2]", - "[number 0.1]", - "[number 2394.26331]", - "[number 1.2E12]", - "[number 1.2e12]", - "[number 1.30e-2]", - "[number 0.1e-0]", - "[number 23E10]", - "[number 29E-2]", - "[number 236.123_763_e-12]" - ); - - MT("Operators", - "[meta ^]" - ); - - MT("Keywords", - "[keyword logic]", - "[keyword logic] [variable foo]", - "[keyword reg] [variable abc]" - ); - - MT("Variables", - "[variable _leading_underscore]", - "[variable _if]", - "[number 12] [variable foo]", - "[variable foo] [number 14]" - ); - - MT("Tick defines", - "[def `FOO]", - "[def `foo]", - "[def `FOO_bar]" - ); - - MT("System calls", - "[meta $display]", - "[meta $vpi_printf]" - ); - - MT("Line comment", "[comment // Hello world]"); - - - -})(); diff --git a/static/js/lib/codemirror-4.4/addon/comment/comment.js b/static/js/lib/codemirror-4.5/addon/comment/comment.js similarity index 97% rename from static/js/lib/codemirror-4.4/addon/comment/comment.js rename to static/js/lib/codemirror-4.5/addon/comment/comment.js index cb78340..d7f569c 100644 --- a/static/js/lib/codemirror-4.4/addon/comment/comment.js +++ b/static/js/lib/codemirror-4.5/addon/comment/comment.js @@ -157,12 +157,12 @@ // Positions of the last startString before the start of the selection, and the first endString after it. var lastStart = startLine.lastIndexOf(startString, from.ch); var firstEnd = lastStart == -1 ? -1 : startLine.slice(0, from.ch).indexOf(endString, lastStart + startString.length); - if (lastStart != -1 && firstEnd != -1) return false; + if (lastStart != -1 && firstEnd != -1 && firstEnd + endString.length != from.ch) return false; // Positions of the first endString after the end of the selection, and the last startString before it. firstEnd = endLine.indexOf(endString, to.ch); var almostLastStart = endLine.slice(to.ch).lastIndexOf(startString, firstEnd - to.ch); lastStart = (firstEnd == -1 || almostLastStart == -1) ? -1 : to.ch + almostLastStart; - if (firstEnd != -1 && lastStart != -1) return false; + if (firstEnd != -1 && lastStart != -1 && lastStart != to.ch) return false; self.operation(function() { self.replaceRange("", Pos(end, close - (pad && endLine.slice(close - pad.length, close) == pad ? pad.length : 0)), diff --git a/static/js/lib/codemirror-4.4/addon/comment/continuecomment.js b/static/js/lib/codemirror-4.5/addon/comment/continuecomment.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/comment/continuecomment.js rename to static/js/lib/codemirror-4.5/addon/comment/continuecomment.js diff --git a/static/js/lib/codemirror-4.4/addon/dialog/dialog.css b/static/js/lib/codemirror-4.5/addon/dialog/dialog.css similarity index 100% rename from static/js/lib/codemirror-4.4/addon/dialog/dialog.css rename to static/js/lib/codemirror-4.5/addon/dialog/dialog.css diff --git a/static/js/lib/codemirror-4.4/addon/dialog/dialog.js b/static/js/lib/codemirror-4.5/addon/dialog/dialog.js similarity index 85% rename from static/js/lib/codemirror-4.4/addon/dialog/dialog.js rename to static/js/lib/codemirror-4.5/addon/dialog/dialog.js index 622d689..946040c 100644 --- a/static/js/lib/codemirror-4.4/addon/dialog/dialog.js +++ b/static/js/lib/codemirror-4.5/addon/dialog/dialog.js @@ -15,11 +15,11 @@ var wrap = cm.getWrapperElement(); var dialog; dialog = wrap.appendChild(document.createElement("div")); - if (bottom) { + if (bottom) dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom"; - } else { + else dialog.className = "CodeMirror-dialog CodeMirror-dialog-top"; - } + if (typeof template == "string") { dialog.innerHTML = template; } else { // Assuming it's a detached DOM element. @@ -35,8 +35,11 @@ } CodeMirror.defineExtension("openDialog", function(template, callback, options) { + if (!options) options = {}; + closeNotification(this, null); - var dialog = dialogDiv(this, template, options && options.bottom); + + var dialog = dialogDiv(this, template, options.bottom); var closed = false, me = this; function close(newVal) { if (typeof newVal == 'string') { @@ -45,34 +48,43 @@ if (closed) return; closed = true; dialog.parentNode.removeChild(dialog); + me.focus(); + + if (options.onClose) options.onClose(dialog); } } + var inp = dialog.getElementsByTagName("input")[0], button; if (inp) { - if (options && options.value) inp.value = options.value; + if (options.value) inp.value = options.value; + + if (options.onInput) + CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);}); + if (options.onKeyUp) + CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);}); + CodeMirror.on(inp, "keydown", function(e) { if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; } - if (e.keyCode == 13 || e.keyCode == 27) { + if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) { inp.blur(); CodeMirror.e_stop(e); close(); - me.focus(); - if (e.keyCode == 13) callback(inp.value); } + if (e.keyCode == 13) callback(inp.value); }); - if (options && options.onKeyUp) { - CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);}); - } - if (options && options.value) inp.value = options.value; + + if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close); + inp.focus(); - CodeMirror.on(inp, "blur", close); } else if (button = dialog.getElementsByTagName("button")[0]) { CodeMirror.on(button, "click", function() { close(); me.focus(); }); + + if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close); + button.focus(); - CodeMirror.on(button, "blur", close); } return close; }); diff --git a/static/js/lib/codemirror-4.4/addon/display/fullscreen.css b/static/js/lib/codemirror-4.5/addon/display/fullscreen.css similarity index 100% rename from static/js/lib/codemirror-4.4/addon/display/fullscreen.css rename to static/js/lib/codemirror-4.5/addon/display/fullscreen.css diff --git a/static/js/lib/codemirror-4.4/addon/display/fullscreen.js b/static/js/lib/codemirror-4.5/addon/display/fullscreen.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/display/fullscreen.js rename to static/js/lib/codemirror-4.5/addon/display/fullscreen.js diff --git a/static/js/lib/codemirror-4.4/addon/display/placeholder.js b/static/js/lib/codemirror-4.5/addon/display/placeholder.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/display/placeholder.js rename to static/js/lib/codemirror-4.5/addon/display/placeholder.js diff --git a/static/js/lib/codemirror-4.4/addon/display/rulers.js b/static/js/lib/codemirror-4.5/addon/display/rulers.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/display/rulers.js rename to static/js/lib/codemirror-4.5/addon/display/rulers.js diff --git a/static/js/lib/codemirror-4.4/addon/edit/closebrackets.js b/static/js/lib/codemirror-4.5/addon/edit/closebrackets.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/edit/closebrackets.js rename to static/js/lib/codemirror-4.5/addon/edit/closebrackets.js diff --git a/static/js/lib/codemirror-4.4/addon/edit/closetag.js b/static/js/lib/codemirror-4.5/addon/edit/closetag.js similarity index 96% rename from static/js/lib/codemirror-4.4/addon/edit/closetag.js rename to static/js/lib/codemirror-4.5/addon/edit/closetag.js index 414498b..69ea444 100644 --- a/static/js/lib/codemirror-4.4/addon/edit/closetag.js +++ b/static/js/lib/codemirror-4.5/addon/edit/closetag.js @@ -109,6 +109,10 @@ replacements[i] = "/" + state.context.tagName + ">"; } cm.replaceSelections(replacements); + ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) + if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line) + cm.indentLine(ranges[i].head.line); } function indexOf(collection, elt) { diff --git a/static/js/lib/codemirror-4.4/addon/edit/continuelist.js b/static/js/lib/codemirror-4.5/addon/edit/continuelist.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/edit/continuelist.js rename to static/js/lib/codemirror-4.5/addon/edit/continuelist.js diff --git a/static/js/lib/codemirror-4.4/addon/edit/matchbrackets.js b/static/js/lib/codemirror-4.5/addon/edit/matchbrackets.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/edit/matchbrackets.js rename to static/js/lib/codemirror-4.5/addon/edit/matchbrackets.js diff --git a/static/js/lib/codemirror-4.4/addon/edit/matchtags.js b/static/js/lib/codemirror-4.5/addon/edit/matchtags.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/edit/matchtags.js rename to static/js/lib/codemirror-4.5/addon/edit/matchtags.js diff --git a/static/js/lib/codemirror-4.4/addon/edit/trailingspace.js b/static/js/lib/codemirror-4.5/addon/edit/trailingspace.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/edit/trailingspace.js rename to static/js/lib/codemirror-4.5/addon/edit/trailingspace.js diff --git a/static/js/lib/codemirror-4.4/addon/fold/brace-fold.js b/static/js/lib/codemirror-4.5/addon/fold/brace-fold.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/fold/brace-fold.js rename to static/js/lib/codemirror-4.5/addon/fold/brace-fold.js diff --git a/static/js/lib/codemirror-4.4/addon/fold/comment-fold.js b/static/js/lib/codemirror-4.5/addon/fold/comment-fold.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/fold/comment-fold.js rename to static/js/lib/codemirror-4.5/addon/fold/comment-fold.js diff --git a/static/js/lib/codemirror-4.4/addon/fold/foldcode.js b/static/js/lib/codemirror-4.5/addon/fold/foldcode.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/fold/foldcode.js rename to static/js/lib/codemirror-4.5/addon/fold/foldcode.js diff --git a/static/js/lib/codemirror-4.4/addon/fold/foldgutter.css b/static/js/lib/codemirror-4.5/addon/fold/foldgutter.css similarity index 100% rename from static/js/lib/codemirror-4.4/addon/fold/foldgutter.css rename to static/js/lib/codemirror-4.5/addon/fold/foldgutter.css diff --git a/static/js/lib/codemirror-4.4/addon/fold/foldgutter.js b/static/js/lib/codemirror-4.5/addon/fold/foldgutter.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/fold/foldgutter.js rename to static/js/lib/codemirror-4.5/addon/fold/foldgutter.js diff --git a/static/js/lib/codemirror-4.4/addon/fold/indent-fold.js b/static/js/lib/codemirror-4.5/addon/fold/indent-fold.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/fold/indent-fold.js rename to static/js/lib/codemirror-4.5/addon/fold/indent-fold.js diff --git a/static/js/lib/codemirror-4.4/addon/fold/markdown-fold.js b/static/js/lib/codemirror-4.5/addon/fold/markdown-fold.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/fold/markdown-fold.js rename to static/js/lib/codemirror-4.5/addon/fold/markdown-fold.js diff --git a/static/js/lib/codemirror-4.4/addon/fold/xml-fold.js b/static/js/lib/codemirror-4.5/addon/fold/xml-fold.js similarity index 98% rename from static/js/lib/codemirror-4.4/addon/fold/xml-fold.js rename to static/js/lib/codemirror-4.5/addon/fold/xml-fold.js index a45da58..504727f 100644 --- a/static/js/lib/codemirror-4.4/addon/fold/xml-fold.js +++ b/static/js/lib/codemirror-4.5/addon/fold/xml-fold.js @@ -151,8 +151,9 @@ if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return; var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch); var start = end && toTagStart(iter); - if (!end || end == "selfClose" || !start || cmp(iter, pos) > 0) return; + if (!end || !start || cmp(iter, pos) > 0) return; var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]}; + if (end == "selfClose") return {open: here, close: null, at: "open"}; if (start[1]) { // closing tag return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"}; diff --git a/static/js/lib/codemirror-4.4/addon/hint/anyword-hint.js b/static/js/lib/codemirror-4.5/addon/hint/anyword-hint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/hint/anyword-hint.js rename to static/js/lib/codemirror-4.5/addon/hint/anyword-hint.js diff --git a/static/js/lib/codemirror-4.4/addon/hint/css-hint.js b/static/js/lib/codemirror-4.5/addon/hint/css-hint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/hint/css-hint.js rename to static/js/lib/codemirror-4.5/addon/hint/css-hint.js diff --git a/static/js/lib/codemirror-4.4/addon/hint/html-hint.js b/static/js/lib/codemirror-4.5/addon/hint/html-hint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/hint/html-hint.js rename to static/js/lib/codemirror-4.5/addon/hint/html-hint.js diff --git a/static/js/lib/codemirror-4.4/addon/hint/javascript-hint.js b/static/js/lib/codemirror-4.5/addon/hint/javascript-hint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/hint/javascript-hint.js rename to static/js/lib/codemirror-4.5/addon/hint/javascript-hint.js diff --git a/static/js/lib/codemirror-4.4/addon/hint/python-hint.js b/static/js/lib/codemirror-4.5/addon/hint/python-hint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/hint/python-hint.js rename to static/js/lib/codemirror-4.5/addon/hint/python-hint.js diff --git a/static/js/lib/codemirror-4.4/addon/hint/show-hint.css b/static/js/lib/codemirror-4.5/addon/hint/show-hint.css similarity index 100% rename from static/js/lib/codemirror-4.4/addon/hint/show-hint.css rename to static/js/lib/codemirror-4.5/addon/hint/show-hint.css diff --git a/static/js/lib/codemirror-4.4/addon/hint/show-hint.js b/static/js/lib/codemirror-4.5/addon/hint/show-hint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/hint/show-hint.js rename to static/js/lib/codemirror-4.5/addon/hint/show-hint.js diff --git a/static/js/lib/codemirror-4.4/addon/hint/sql-hint.js b/static/js/lib/codemirror-4.5/addon/hint/sql-hint.js similarity index 51% rename from static/js/lib/codemirror-4.4/addon/hint/sql-hint.js rename to static/js/lib/codemirror-4.5/addon/hint/sql-hint.js index fd58b88..20653b5 100644 --- a/static/js/lib/codemirror-4.4/addon/hint/sql-hint.js +++ b/static/js/lib/codemirror-4.5/addon/hint/sql-hint.js @@ -21,7 +21,7 @@ function getKeywords(editor) { var mode = editor.doc.modeOption; - if(mode === "sql") mode = "text/x-sql"; + if (mode === "sql") mode = "text/x-sql"; return CodeMirror.resolveMode(mode).keywords; } @@ -32,12 +32,12 @@ } function addMatches(result, search, wordlist, formatter) { - for(var word in wordlist) { - if(!wordlist.hasOwnProperty(word)) continue; - if(Array.isArray(wordlist)) { + for (var word in wordlist) { + if (!wordlist.hasOwnProperty(word)) continue; + if (Array.isArray(wordlist)) { word = wordlist[word]; } - if(match(search, word)) { + if (match(search, word)) { result.push(formatter(word)); } } @@ -49,33 +49,30 @@ var string = token.string.substr(1); var prevCur = Pos(cur.line, token.start); var table = editor.getTokenAt(prevCur).string; - if( !tables.hasOwnProperty( table ) ){ + if (!tables.hasOwnProperty(table)) table = findTableByAlias(table, editor); - } var columns = tables[table]; - if(!columns) { - return; - } - addMatches(result, string, columns, - function(w) {return "." + w;}); + if (!columns) return; + + addMatches(result, string, columns, function(w) {return "." + w;}); } function eachWord(lineText, f) { - if( !lineText ){return;} + if (!lineText) return; var excepted = /[,;]/g; - var words = lineText.split( " " ); - for( var i = 0; i < words.length; i++ ){ - f( words[i]?words[i].replace( excepted, '' ) : '' ); + var words = lineText.split(" "); + for (var i = 0; i < words.length; i++) { + f(words[i]?words[i].replace(excepted, '') : ''); } } - function convertCurToNumber( cur ){ + function convertCurToNumber(cur) { // max characters of a line is 999,999. - return cur.line + cur.ch / Math.pow( 10, 6 ); + return cur.line + cur.ch / Math.pow(10, 6); } - function convertNumberToCur( num ){ - return Pos(Math.floor( num ), +num.toString().split( '.' ).pop()); + function convertNumberToCur(num) { + return Pos(Math.floor(num), +num.toString().split('.').pop()); } function findTableByAlias(alias, editor) { @@ -86,26 +83,26 @@ var table = ""; var separator = []; var validRange = { - start: Pos( 0, 0 ), - end: Pos( editor.lastLine(), editor.getLineHandle( editor.lastLine() ).length ) + start: Pos(0, 0), + end: Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).length) }; //add separator - var indexOfSeparator = fullQuery.indexOf( CONS.QUERY_DIV ); - while( indexOfSeparator != -1 ){ - separator.push( doc.posFromIndex(indexOfSeparator)); - indexOfSeparator = fullQuery.indexOf( CONS.QUERY_DIV, indexOfSeparator+1); + var indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV); + while(indexOfSeparator != -1) { + separator.push(doc.posFromIndex(indexOfSeparator)); + indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV, indexOfSeparator+1); } - separator.unshift( Pos( 0, 0 ) ); - separator.push( Pos( editor.lastLine(), editor.getLineHandle( editor.lastLine() ).text.length ) ); + separator.unshift(Pos(0, 0)); + separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length)); - //find valieRange + //find valid range var prevItem = 0; - var current = convertCurToNumber( editor.getCursor() ); - for( var i=0; i< separator.length; i++){ - var _v = convertCurToNumber( separator[i] ); - if( current > prevItem && current <= _v ){ - validRange = { start: convertNumberToCur( prevItem ), end: convertNumberToCur( _v ) }; + var current = convertCurToNumber(editor.getCursor()); + for (var i=0; i< separator.length; i++) { + var _v = convertCurToNumber(separator[i]); + if (current > prevItem && current <= _v) { + validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) }; break; } prevItem = _v; @@ -113,52 +110,51 @@ var query = doc.getRange(validRange.start, validRange.end, false); - for(var i=0; i < query.length; i++){ + for (var i = 0; i < query.length; i++) { var lineText = query[i]; - eachWord( lineText, function( word ){ + eachWord(lineText, function(word) { var wordUpperCase = word.toUpperCase(); - if( wordUpperCase === aliasUpperCase && tables.hasOwnProperty( previousWord ) ){ + if (wordUpperCase === aliasUpperCase && tables.hasOwnProperty(previousWord)) { table = previousWord; } - if( wordUpperCase !== CONS.ALIAS_KEYWORD ){ + if (wordUpperCase !== CONS.ALIAS_KEYWORD) { previousWord = word; } }); - if( table ){ break; } + if (table) break; } return table; } - function sqlHint(editor, options) { + CodeMirror.registerHelper("hint", "sql", function(editor, options) { tables = (options && options.tables) || {}; keywords = keywords || getKeywords(editor); var cur = editor.getCursor(); - var token = editor.getTokenAt(cur), end = token.end; var result = []; - var search = token.string.trim(); - + var token = editor.getTokenAt(cur), start, end, search; + if (token.string.match(/^[.\w@]\w*$/)) { + search = token.string; + start = token.start; + end = token.end; + } else { + start = end = cur.ch; + search = ""; + } if (search.charAt(0) == ".") { columnCompletion(result, editor); if (!result.length) { - while (token.start && search.charAt(0) == ".") { + while (start && search.charAt(0) == ".") { token = editor.getTokenAt(Pos(cur.line, token.start - 1)); + start = token.start; search = token.string + search; } - addMatches(result, search, tables, - function(w) {return w;}); + addMatches(result, search, tables, function(w) {return w;}); } } else { - addMatches(result, search, keywords, - function(w) {return w.toUpperCase();}); - addMatches(result, search, tables, - function(w) {return w;}); + addMatches(result, search, tables, function(w) {return w;}); + addMatches(result, search, keywords, function(w) {return w.toUpperCase();}); } - return { - list: result, - from: Pos(cur.line, token.start), - to: Pos(cur.line, end) - }; - } - CodeMirror.registerHelper("hint", "sql", sqlHint); + return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)}; + }); }); diff --git a/static/js/lib/codemirror-4.4/addon/hint/xml-hint.js b/static/js/lib/codemirror-4.5/addon/hint/xml-hint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/hint/xml-hint.js rename to static/js/lib/codemirror-4.5/addon/hint/xml-hint.js diff --git a/static/js/lib/codemirror-4.4/addon/lint/coffeescript-lint.js b/static/js/lib/codemirror-4.5/addon/lint/coffeescript-lint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/lint/coffeescript-lint.js rename to static/js/lib/codemirror-4.5/addon/lint/coffeescript-lint.js diff --git a/static/js/lib/codemirror-4.4/addon/lint/css-lint.js b/static/js/lib/codemirror-4.5/addon/lint/css-lint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/lint/css-lint.js rename to static/js/lib/codemirror-4.5/addon/lint/css-lint.js diff --git a/static/js/lib/codemirror-4.4/addon/lint/javascript-lint.js b/static/js/lib/codemirror-4.5/addon/lint/javascript-lint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/lint/javascript-lint.js rename to static/js/lib/codemirror-4.5/addon/lint/javascript-lint.js diff --git a/static/js/lib/codemirror-4.4/addon/lint/json-lint.js b/static/js/lib/codemirror-4.5/addon/lint/json-lint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/lint/json-lint.js rename to static/js/lib/codemirror-4.5/addon/lint/json-lint.js diff --git a/static/js/lib/codemirror-4.4/addon/lint/lint.css b/static/js/lib/codemirror-4.5/addon/lint/lint.css similarity index 100% rename from static/js/lib/codemirror-4.4/addon/lint/lint.css rename to static/js/lib/codemirror-4.5/addon/lint/lint.css diff --git a/static/js/lib/codemirror-4.4/addon/lint/lint.js b/static/js/lib/codemirror-4.5/addon/lint/lint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/lint/lint.js rename to static/js/lib/codemirror-4.5/addon/lint/lint.js diff --git a/static/js/lib/codemirror-4.4/addon/lint/yaml-lint.js b/static/js/lib/codemirror-4.5/addon/lint/yaml-lint.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/lint/yaml-lint.js rename to static/js/lib/codemirror-4.5/addon/lint/yaml-lint.js diff --git a/static/js/lib/codemirror-4.4/addon/merge/merge.css b/static/js/lib/codemirror-4.5/addon/merge/merge.css similarity index 96% rename from static/js/lib/codemirror-4.4/addon/merge/merge.css rename to static/js/lib/codemirror-4.5/addon/merge/merge.css index 63237fc..5d24b9b 100644 --- a/static/js/lib/codemirror-4.4/addon/merge/merge.css +++ b/static/js/lib/codemirror-4.5/addon/merge/merge.css @@ -62,6 +62,12 @@ color: #44c; } +.CodeMirror-merge-copy-reverse { + position: absolute; + cursor: pointer; + color: #44c; +} + .CodeMirror-merge-copybuttons-left .CodeMirror-merge-copy { left: 2px; } .CodeMirror-merge-copybuttons-right .CodeMirror-merge-copy { right: 2px; } diff --git a/static/js/lib/codemirror-4.4/addon/merge/merge.js b/static/js/lib/codemirror-4.5/addon/merge/merge.js similarity index 90% rename from static/js/lib/codemirror-4.4/addon/merge/merge.js rename to static/js/lib/codemirror-4.5/addon/merge/merge.js index 3583936..d9b2776 100644 --- a/static/js/lib/codemirror-4.4/addon/merge/merge.js +++ b/static/js/lib/codemirror-4.5/addon/merge/merge.js @@ -37,7 +37,7 @@ constructor: DiffView, init: function(pane, orig, options) { this.edit = this.mv.edit; - this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: true}, copyObj(options))); + this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options))); this.diff = getDiff(asString(orig), asString(options.value)); this.diffOutOfDate = false; @@ -71,7 +71,7 @@ function update(mode) { if (mode == "full") { if (dv.svg) clear(dv.svg); - clear(dv.copyButtons); + if (dv.copyButtons) clear(dv.copyButtons); clearMarks(dv.edit, edit.marked, dv.classes); clearMarks(dv.orig, orig.marked, dv.classes); edit.from = edit.to = orig.from = orig.to = 0; @@ -257,7 +257,7 @@ var w = dv.gap.offsetWidth; attrs(dv.svg, "width", w, "height", dv.gap.offsetHeight); } - clear(dv.copyButtons); + if (dv.copyButtons) clear(dv.copyButtons); var flip = dv.type == "left"; var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport(); @@ -279,17 +279,30 @@ "d", "M -1 " + topRpx + curveTop + " L " + (w + 2) + " " + botLpx + curveBot + " z", "class", dv.classes.connect); } - var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc", - "CodeMirror-merge-copy")); - copy.title = "Revert chunk"; - copy.chunk = {topEdit: topEdit, botEdit: botEdit, topOrig: topOrig, botOrig: botOrig}; - copy.style.top = top + "px"; + if (dv.copyButtons) { + var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc", + "CodeMirror-merge-copy")); + var editOriginals = dv.mv.options.allowEditingOriginals; + copy.title = editOriginals ? "Push to left" : "Revert chunk"; + copy.chunk = {topEdit: topEdit, botEdit: botEdit, topOrig: topOrig, botOrig: botOrig}; + copy.style.top = top + "px"; + + if (editOriginals) { + var topReverse = dv.orig.heightAtLine(topEdit, "local") - sTopEdit; + var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc", + "CodeMirror-merge-copy-reverse")); + copyReverse.title = "Push to right"; + copyReverse.chunk = {topEdit: topOrig, botEdit: botOrig, topOrig: topEdit, botOrig: botEdit}; + copyReverse.style.top = topReverse + "px"; + dv.type == "right" ? copyReverse.style.left = "2px" : copyReverse.style.right = "2px"; + } + } }); } - function copyChunk(dv, chunk) { + function copyChunk(dv, to, from, chunk) { if (dv.diffOutOfDate) return; - dv.edit.replaceRange(dv.orig.getRange(Pos(chunk.topOrig, 0), Pos(chunk.botOrig, 0)), + to.replaceRange(from.getRange(Pos(chunk.topOrig, 0), Pos(chunk.botOrig, 0)), Pos(chunk.topEdit, 0), Pos(chunk.botEdit, 0)); } @@ -298,6 +311,7 @@ var MergeView = CodeMirror.MergeView = function(node, options) { if (!(this instanceof MergeView)) return new MergeView(node, options); + this.options = options; var origLeft = options.origLeft, origRight = options.origRight == null ? options.orig : options.origRight; var hasLeft = origLeft != null, hasRight = origRight != null; var panes = 1 + (hasLeft ? 1 : 0) + (hasRight ? 1 : 0); @@ -323,6 +337,7 @@ (hasRight ? rightPane : editPane).className += " CodeMirror-merge-pane-rightmost"; wrap.push(elt("div", null, null, "height: 0; clear: both;")); + var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-merge CodeMirror-merge-" + panes + "pane")); this.edit = CodeMirror(editPane, copyObj(options)); @@ -345,12 +360,20 @@ lock.title = "Toggle locked scrolling"; var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap"); CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); }); - dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type); - CodeMirror.on(dv.copyButtons, "click", function(e) { - var node = e.target || e.srcElement; - if (node.chunk) copyChunk(dv, node.chunk); - }); - var gapElts = [dv.copyButtons, lockWrap]; + var gapElts = [lockWrap]; + if (dv.mv.options.revertButtons !== false) { + dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type); + CodeMirror.on(dv.copyButtons, "click", function(e) { + var node = e.target || e.srcElement; + if (!node.chunk) return; + if (node.className == "CodeMirror-merge-copy-reverse") { + copyChunk(dv, dv.orig, dv.edit, node.chunk); + return; + } + copyChunk(dv, dv.edit, dv.orig, node.chunk); + }); + gapElts.unshift(dv.copyButtons); + } var svg = document.createElementNS && document.createElementNS(svgNS, "svg"); if (svg && !svg.createSVGRect) svg = null; dv.svg = svg; diff --git a/static/js/lib/codemirror-4.4/addon/mode/loadmode.js b/static/js/lib/codemirror-4.5/addon/mode/loadmode.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/mode/loadmode.js rename to static/js/lib/codemirror-4.5/addon/mode/loadmode.js diff --git a/static/js/lib/codemirror-4.4/addon/mode/multiplex.js b/static/js/lib/codemirror-4.5/addon/mode/multiplex.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/mode/multiplex.js rename to static/js/lib/codemirror-4.5/addon/mode/multiplex.js diff --git a/static/js/lib/codemirror-4.4/addon/mode/multiplex_test.js b/static/js/lib/codemirror-4.5/addon/mode/multiplex_test.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/mode/multiplex_test.js rename to static/js/lib/codemirror-4.5/addon/mode/multiplex_test.js diff --git a/static/js/lib/codemirror-4.4/addon/mode/overlay.js b/static/js/lib/codemirror-4.5/addon/mode/overlay.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/mode/overlay.js rename to static/js/lib/codemirror-4.5/addon/mode/overlay.js diff --git a/static/js/lib/codemirror-4.4/addon/runmode/colorize.js b/static/js/lib/codemirror-4.5/addon/runmode/colorize.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/runmode/colorize.js rename to static/js/lib/codemirror-4.5/addon/runmode/colorize.js diff --git a/static/js/lib/codemirror-4.4/addon/runmode/runmode-standalone.js b/static/js/lib/codemirror-4.5/addon/runmode/runmode-standalone.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/runmode/runmode-standalone.js rename to static/js/lib/codemirror-4.5/addon/runmode/runmode-standalone.js diff --git a/static/js/lib/codemirror-4.4/addon/runmode/runmode.js b/static/js/lib/codemirror-4.5/addon/runmode/runmode.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/runmode/runmode.js rename to static/js/lib/codemirror-4.5/addon/runmode/runmode.js diff --git a/static/js/lib/codemirror-4.4/addon/runmode/runmode.node.js b/static/js/lib/codemirror-4.5/addon/runmode/runmode.node.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/runmode/runmode.node.js rename to static/js/lib/codemirror-4.5/addon/runmode/runmode.node.js diff --git a/static/js/lib/codemirror-4.4/addon/scroll/scrollpastend.js b/static/js/lib/codemirror-4.5/addon/scroll/scrollpastend.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/scroll/scrollpastend.js rename to static/js/lib/codemirror-4.5/addon/scroll/scrollpastend.js diff --git a/static/js/lib/codemirror-4.4/addon/search/match-highlighter.js b/static/js/lib/codemirror-4.5/addon/search/match-highlighter.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/search/match-highlighter.js rename to static/js/lib/codemirror-4.5/addon/search/match-highlighter.js diff --git a/static/js/lib/codemirror-4.4/addon/search/search.js b/static/js/lib/codemirror-4.5/addon/search/search.js similarity index 93% rename from static/js/lib/codemirror-4.4/addon/search/search.js rename to static/js/lib/codemirror-4.5/addon/search/search.js index b177dce..c25aeda 100644 --- a/static/js/lib/codemirror-4.4/addon/search/search.js +++ b/static/js/lib/codemirror-4.5/addon/search/search.js @@ -71,7 +71,7 @@ return query; } var queryDialog = - 'Search: (Use /re/ syntax for regexp search)'; + 'Search: (Use /re/ syntax for regexp search)'; function doSearch(cm, rev) { var state = getSearchState(cm); if (state.query) return findNext(cm, rev); @@ -106,8 +106,8 @@ });} var replaceQueryDialog = - 'Replace: (Use /re/ syntax for regexp search)'; - var replacementQueryDialog = 'With: '; + 'Replace: (Use /re/ syntax for regexp search)'; + var replacementQueryDialog = 'With: '; var doReplaceConfirm = "Replace? "; function replace(cm, all) { if (cm.getOption("readOnly")) return; diff --git a/static/js/lib/codemirror-4.4/addon/search/searchcursor.js b/static/js/lib/codemirror-4.5/addon/search/searchcursor.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/search/searchcursor.js rename to static/js/lib/codemirror-4.5/addon/search/searchcursor.js diff --git a/static/js/lib/codemirror-4.4/addon/selection/active-line.js b/static/js/lib/codemirror-4.5/addon/selection/active-line.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/selection/active-line.js rename to static/js/lib/codemirror-4.5/addon/selection/active-line.js diff --git a/static/js/lib/codemirror-4.4/addon/selection/mark-selection.js b/static/js/lib/codemirror-4.5/addon/selection/mark-selection.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/selection/mark-selection.js rename to static/js/lib/codemirror-4.5/addon/selection/mark-selection.js diff --git a/static/js/lib/codemirror-4.4/addon/tern/tern.css b/static/js/lib/codemirror-4.5/addon/tern/tern.css similarity index 100% rename from static/js/lib/codemirror-4.4/addon/tern/tern.css rename to static/js/lib/codemirror-4.5/addon/tern/tern.css diff --git a/static/js/lib/codemirror-4.4/addon/tern/tern.js b/static/js/lib/codemirror-4.5/addon/tern/tern.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/tern/tern.js rename to static/js/lib/codemirror-4.5/addon/tern/tern.js diff --git a/static/js/lib/codemirror-4.4/addon/tern/worker.js b/static/js/lib/codemirror-4.5/addon/tern/worker.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/tern/worker.js rename to static/js/lib/codemirror-4.5/addon/tern/worker.js diff --git a/static/js/lib/codemirror-4.4/addon/wrap/hardwrap.js b/static/js/lib/codemirror-4.5/addon/wrap/hardwrap.js similarity index 100% rename from static/js/lib/codemirror-4.4/addon/wrap/hardwrap.js rename to static/js/lib/codemirror-4.5/addon/wrap/hardwrap.js diff --git a/static/js/lib/codemirror-4.4/codemirror.css b/static/js/lib/codemirror-4.5/codemirror.css similarity index 100% rename from static/js/lib/codemirror-4.4/codemirror.css rename to static/js/lib/codemirror-4.5/codemirror.css diff --git a/static/js/lib/codemirror-4.4/codemirror.js b/static/js/lib/codemirror-4.5/codemirror.js similarity index 98% rename from static/js/lib/codemirror-4.4/codemirror.js rename to static/js/lib/codemirror-4.5/codemirror.js index 9585642..61e8c41 100644 --- a/static/js/lib/codemirror-4.4/codemirror.js +++ b/static/js/lib/codemirror-4.5/codemirror.js @@ -662,6 +662,7 @@ function updateDisplaySimple(cm, viewport) { var update = new DisplayUpdate(cm, viewport); if (updateDisplayIfNeeded(cm, update)) { + updateHeightsInViewport(cm); postUpdateDisplay(cm, update); var barMeasure = measureForScrollbars(cm); updateSelection(cm); @@ -1280,8 +1281,7 @@ return result; } - function updateSelection(cm, drawn) { - if (!drawn) drawn = drawSelection(cm); + function showSelection(cm, drawn) { removeChildrenAndAdd(cm.display.cursorDiv, drawn.cursors); removeChildrenAndAdd(cm.display.selectionDiv, drawn.selection); if (drawn.teTop != null) { @@ -1290,6 +1290,10 @@ } } + function updateSelection(cm) { + showSelection(cm, drawSelection(cm)); + } + // Draws a cursor for the given range function drawSelectionCursor(cm, range, output) { var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine); @@ -1642,18 +1646,24 @@ var rect; if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates. - while (start && isExtendingChar(prepared.line.text.charAt(mStart + start))) --start; - while (mStart + end < mEnd && isExtendingChar(prepared.line.text.charAt(mStart + end))) ++end; - if (ie && ie_version < 9 && start == 0 && end == mEnd - mStart) { - rect = node.parentNode.getBoundingClientRect(); - } else if (ie && cm.options.lineWrapping) { - var rects = range(node, start, end).getClientRects(); - if (rects.length) - rect = rects[bias == "right" ? rects.length - 1 : 0]; - else - rect = nullRect; - } else { - rect = range(node, start, end).getBoundingClientRect() || nullRect; + for (;;) { + while (start && isExtendingChar(prepared.line.text.charAt(mStart + start))) --start; + while (mStart + end < mEnd && isExtendingChar(prepared.line.text.charAt(mStart + end))) ++end; + if (ie && ie_version < 9 && start == 0 && end == mEnd - mStart) { + rect = node.parentNode.getBoundingClientRect(); + } else if (ie && cm.options.lineWrapping) { + var rects = range(node, start, end).getClientRects(); + if (rects.length) + rect = rects[bias == "right" ? rects.length - 1 : 0]; + else + rect = nullRect; + } else { + rect = range(node, start, end).getBoundingClientRect() || nullRect; + } + if (rect.left || rect.right || start == 0) break; + end = start; + start = start - 1; + collapse = "right"; } } else { // If it is a widget, simply get the box for the whole widget. if (start > 0) collapse = bias = "right"; @@ -2029,16 +2039,17 @@ var cm = op.cm, display = cm.display; if (op.updatedDisplay) updateHeightsInViewport(cm); + op.barMeasure = measureForScrollbars(cm); + // If the max line changed since it was last measured, measure it, // and ensure the document's width matches it. - // updateDisplayIfNeeded will use these properties to do the actual resizing + // updateDisplay_W2 will use these properties to do the actual resizing if (display.maxLineChanged && !cm.options.lineWrapping) { - op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left; + op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3; op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo + scrollerCutOff - display.scroller.clientWidth); } - op.barMeasure = measureForScrollbars(cm); if (op.updatedDisplay || op.selectionChanged) op.newSelectionNodes = drawSelection(cm); } @@ -2050,10 +2061,11 @@ cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"; if (op.maxScrollLeft < cm.doc.scrollLeft) setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); + cm.display.maxLineChanged = false; } if (op.newSelectionNodes) - updateSelection(cm, op.newSelectionNodes); + showSelection(cm, op.newSelectionNodes); if (op.updatedDisplay) setDocumentHeight(cm, op.barMeasure); if (op.updatedDisplay || op.startHeight != cm.doc.height) @@ -2068,6 +2080,9 @@ function endOperation_finish(op) { var cm = op.cm, display = cm.display, doc = cm.doc; + if (op.adjustWidthTo != null && Math.abs(op.barMeasure.scrollWidth - cm.display.scroller.scrollWidth) > 1) + updateScrollbars(cm); + if (op.updatedDisplay) postUpdateDisplay(cm, op.update); // Abort mouse wheel delta measurement, when scrolling explicitly @@ -3553,7 +3568,7 @@ var after = i ? computeSelAfterChange(doc, change) : lst(source); makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)); - if (!i && doc.cm) doc.cm.scrollIntoView(change); + if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); var rebased = []; // Propagate to the linked documents @@ -3742,6 +3757,7 @@ if (y1 < 0) y1 = 0; var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; var screen = display.scroller.clientHeight - scrollerCutOff, result = {}; + if (y2 - y1 > screen) y2 = y1 + screen; var docBottom = cm.doc.height + paddingVert(display); var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin; if (y1 < screentop) { @@ -3752,16 +3768,16 @@ } var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft; - var screenw = display.scroller.clientWidth - scrollerCutOff; - x1 += display.gutters.offsetWidth; x2 += display.gutters.offsetWidth; - var gutterw = display.gutters.offsetWidth; - var atLeft = x1 < gutterw + 10; - if (x1 < screenleft + gutterw || atLeft) { - if (atLeft) x1 = 0; - result.scrollLeft = Math.max(0, x1 - 10 - gutterw); - } else if (x2 > screenw + screenleft - 3) { - result.scrollLeft = x2 + 10 - screenw; - } + var screenw = display.scroller.clientWidth - scrollerCutOff - display.gutters.offsetWidth; + var tooWide = x2 - x1 > screenw; + if (tooWide) x2 = y1 + screen; + if (x1 < 10) + result.scrollLeft = 0; + else if (x1 < screenleft) + result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10)); + else if (x2 > screenw + screenleft - 3) + result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw; + return result; } @@ -4070,11 +4086,14 @@ for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; if (!range.empty()) { - var start = Math.max(end, range.from().line); - var to = range.to(); + var from = range.from(), to = range.to(); + var start = Math.max(end, from.line); end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1; for (var j = start; j < end; ++j) indentLine(this, j, how); + var newRanges = this.doc.sel.ranges; + if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0) + replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); } else if (range.head.line > end) { indentLine(this, range.head.line, how, true); end = range.head.line; @@ -4470,7 +4489,7 @@ clearCaches(cm); regChange(cm); }, true); - option("specialChars", /[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g, function(cm, val) { + option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val) { cm.options.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); cm.refresh(); }, true); @@ -4731,15 +4750,7 @@ }, goLineStartSmart: function(cm) { cm.extendSelectionsBy(function(range) { - var start = lineStart(cm, range.head.line); - var line = cm.getLineHandle(start.line); - var order = getOrder(line); - if (!order || order[0].level == 0) { - var firstNonWS = Math.max(0, line.text.search(/\S/)); - var inWS = range.head.line == start.line && range.head.ch <= firstNonWS && range.head.ch; - return Pos(start.line, inWS ? 0 : firstNonWS); - } - return start; + return lineStartSmart(cm, range.head); }, {origin: "+move", bias: 1}); }, goLineEnd: function(cm) { @@ -4758,6 +4769,14 @@ return cm.coordsChar({left: 0, top: top}, "div"); }, sel_move); }, + goLineLeftSmart: function(cm) { + cm.extendSelectionsBy(function(range) { + var top = cm.charCoords(range.head, "div").top + 5; + var pos = cm.coordsChar({left: 0, top: top}, "div"); + if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head); + return pos; + }, sel_move); + }, goLineUp: function(cm) {cm.moveV(-1, "line");}, goLineDown: function(cm) {cm.moveV(1, "line");}, goPageUp: function(cm) {cm.moveV(-1, "page");}, @@ -6495,7 +6514,7 @@ }, changeGeneration: function(forceSplit) { if (forceSplit) - this.history.lastOp = this.history.lastOrigin = null; + this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; return this.history.generation; }, isClean: function (gen) { @@ -6812,7 +6831,7 @@ // Used to track when changes can be merged into a single undo // event this.lastModTime = this.lastSelTime = 0; - this.lastOp = null; + this.lastOp = this.lastSelOp = null; this.lastOrigin = this.lastSelOrigin = null; // Used by the isClean() method this.generation = this.maxGeneration = startGen || 1; @@ -6890,7 +6909,7 @@ hist.done.push(selAfter); hist.generation = ++hist.maxGeneration; hist.lastModTime = hist.lastSelTime = time; - hist.lastOp = opId; + hist.lastOp = hist.lastSelOp = opId; hist.lastOrigin = hist.lastSelOrigin = change.origin; if (!last) signal(doc, "historyAdded"); @@ -6916,7 +6935,7 @@ // the current, or the origins don't allow matching. Origins // starting with * are always merged, those starting with + are // merged when similar and close together in time. - if (opId == hist.lastOp || + if (opId == hist.lastSelOp || (origin && hist.lastSelOrigin == origin && (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) @@ -6926,7 +6945,7 @@ hist.lastSelTime = +new Date; hist.lastSelOrigin = origin; - hist.lastOp = opId; + hist.lastSelOp = opId; if (options && options.clearRedo !== false) clearSelectionEvents(hist.undone); } @@ -7556,6 +7575,17 @@ var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line); return Pos(lineN == null ? lineNo(line) : lineN, ch); } + function lineStartSmart(cm, pos) { + var start = lineStart(cm, pos.line); + var line = getLine(cm.doc, start.line); + var order = getOrder(line); + if (!order || order[0].level == 0) { + var firstNonWS = Math.max(0, line.text.search(/\S/)); + var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch; + return Pos(start.line, inWS ? 0 : firstNonWS); + } + return start; + } function compareBidiLevel(order, a, b) { var linedir = order[0].level; @@ -7795,7 +7825,7 @@ // THE END - CodeMirror.version = "4.4.0"; + CodeMirror.version = "4.5.0"; return CodeMirror; }); diff --git a/static/js/lib/codemirror-4.4/keymap/emacs.js b/static/js/lib/codemirror-4.5/keymap/emacs.js similarity index 100% rename from static/js/lib/codemirror-4.4/keymap/emacs.js rename to static/js/lib/codemirror-4.5/keymap/emacs.js diff --git a/static/js/lib/codemirror-4.4/keymap/sublime.js b/static/js/lib/codemirror-4.5/keymap/sublime.js similarity index 98% rename from static/js/lib/codemirror-4.4/keymap/sublime.js rename to static/js/lib/codemirror-4.5/keymap/sublime.js index 7a3a1e5..f70a1f9 100644 --- a/static/js/lib/codemirror-4.4/keymap/sublime.js +++ b/static/js/lib/codemirror-4.5/keymap/sublime.js @@ -17,7 +17,8 @@ var map = CodeMirror.keyMap.sublime = {fallthrough: "default"}; var cmds = CodeMirror.commands; var Pos = CodeMirror.Pos; - var ctrl = CodeMirror.keyMap["default"] == CodeMirror.keyMap.pcDefault ? "Ctrl-" : "Cmd-"; + var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault; + var ctrl = mac ? "Cmd-" : "Ctrl-"; // This is not exactly Sublime's algorithm. I couldn't make heads or tails of that. function findPosSubword(doc, start, dir) { @@ -186,7 +187,9 @@ }); }; - cmds[map["Shift-" + ctrl + "Up"] = "swapLineUp"] = function(cm) { + var swapLineCombo = mac ? "Cmd-Ctrl-" : "Shift-Ctrl-"; + + cmds[map[swapLineCombo + "Up"] = "swapLineUp"] = function(cm) { var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i], from = range.from().line - 1, to = range.to().line; @@ -212,7 +215,7 @@ }); }; - cmds[map["Shift-" + ctrl + "Down"] = "swapLineDown"] = function(cm) { + cmds[map[swapLineCombo + "Down"] = "swapLineDown"] = function(cm) { var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1; for (var i = ranges.length - 1; i >= 0; i--) { var range = ranges[i], from = range.to().line + 1, to = range.from().line; diff --git a/static/js/lib/codemirror-4.4/keymap/vim.js b/static/js/lib/codemirror-4.5/keymap/vim.js similarity index 92% rename from static/js/lib/codemirror-4.4/keymap/vim.js rename to static/js/lib/codemirror-4.5/keymap/vim.js index a47b005..0bf2c78 100644 --- a/static/js/lib/codemirror-4.4/keymap/vim.js +++ b/static/js/lib/codemirror-4.5/keymap/vim.js @@ -616,7 +616,9 @@ visualLine: false, visualBlock: false, lastSelection: null, - lastPastedText: null + lastPastedText: null, + // Used by two-character ESC keymap routines. Should not be changed from false here. + awaitingEscapeSecondCharacter: false }; } return cm.state.vim; @@ -785,17 +787,19 @@ * pasted, should it insert itself into a new line, or should the text be * inserted at the cursor position.) */ - function Register(text, linewise) { + function Register(text, linewise, blockwise) { this.clear(); this.keyBuffer = [text || '']; this.insertModeChanges = []; this.searchQueries = []; this.linewise = !!linewise; + this.blockwise = !!blockwise; } Register.prototype = { - setText: function(text, linewise) { + setText: function(text, linewise, blockwise) { this.keyBuffer = [text || '']; this.linewise = !!linewise; + this.blockwise = !!blockwise; }, pushText: function(text, linewise) { // if this register has ever been set to linewise, use linewise. @@ -840,7 +844,7 @@ registers['/'] = new Register(); } RegisterController.prototype = { - pushText: function(registerName, operator, text, linewise) { + pushText: function(registerName, operator, text, linewise, blockwise) { if (linewise && text.charAt(0) == '\n') { text = text.slice(1) + '\n'; } @@ -857,7 +861,7 @@ switch (operator) { case 'yank': // The 0 register contains the text from the most recent yank. - this.registers['0'] = new Register(text, linewise); + this.registers['0'] = new Register(text, linewise, blockwise); break; case 'delete': case 'change': @@ -873,7 +877,7 @@ break; } // Make sure the unnamed register is set to what just happened - this.unnamedRegister.setText(text, linewise); + this.unnamedRegister.setText(text, linewise, blockwise); return; } @@ -882,7 +886,7 @@ if (append) { register.pushText(text, linewise); } else { - register.setText(text, linewise); + register.setText(text, linewise, blockwise); } // The unnamed register always has the same value as the last used // register. @@ -1860,6 +1864,12 @@ var curStart = cursorIsBefore(start.anchor, start.head) ? start.anchor : start.head; var curEnd = cursorIsBefore(end.anchor, end.head) ? end.head : end.anchor; var text = cm.getSelection(); + var visualBlock = vim.visualBlock; + if (vim.lastSelection && !vim.visualMode) { + visualBlock = vim.lastSelection.visualBlock ? true : visualBlock; + } + var lastInsertModeChanges = vimGlobalState.macroModeState.lastInsertModeChanges; + lastInsertModeChanges.inVisualBlock = visualBlock; var replacement = new Array(selections.length).join('1').split('1'); // save the selectionEnd mark var selectionEnd = vim.marks['>'] ? vim.marks['>'].find() : cm.getCursor('head'); @@ -1868,7 +1878,7 @@ operatorArgs.linewise); if (operatorArgs.linewise) { // 'C' in visual block extends the block till eol for all lines - if (vim.visualBlock){ + if (visualBlock){ var startLine = curStart.line; while (startLine <= curEnd.line) { var endCh = lineLength(cm, startLine); @@ -1898,7 +1908,7 @@ curEnd = offsetCursor(curEnd, 0, - match[0].length); } } - if (vim.visualBlock) { + if (visualBlock) { cm.replaceSelections(replacement); } else { cm.setCursor(curStart); @@ -1916,17 +1926,19 @@ var curEnd = cursorIsBefore(end.anchor, end.head) ? end.head : end.anchor; // Save the '>' mark before cm.replaceRange clears it. var selectionEnd, selectionStart; + var blockwise = vim.visualBlock; if (vim.visualMode) { selectionEnd = vim.marks['>'].find(); selectionStart = vim.marks['<'].find(); } else if (vim.lastSelection) { selectionEnd = vim.lastSelection.curStartMark.find(); selectionStart = vim.lastSelection.curEndMark.find(); + blockwise = vim.lastSelection.visualBlock; } var text = cm.getSelection(); vimGlobalState.registerController.pushText( operatorArgs.registerName, 'delete', text, - operatorArgs.linewise); + operatorArgs.linewise, blockwise); var replacement = new Array(selections.length).join('1').split('1'); // If the ending line is past the last line, inclusive, instead of // including the trailing \n, include the \n before the starting line @@ -1999,11 +2011,11 @@ cm.setCursor(cursorIsBefore(curStart, curEnd) ? curStart : curEnd); } }, - yank: function(cm, operatorArgs, _vim, _curStart, _curEnd, curOriginal) { + yank: function(cm, operatorArgs, vim, _curStart, _curEnd, curOriginal) { var text = cm.getSelection(); vimGlobalState.registerController.pushText( operatorArgs.registerName, 'yank', - text, operatorArgs.linewise); + text, operatorArgs.linewise, vim.visualBlock); cm.setCursor(curOriginal); } }; @@ -2096,6 +2108,11 @@ vim.insertMode = true; vim.insertModeRepeat = actionArgs && actionArgs.repeat || 1; var insertAt = (actionArgs) ? actionArgs.insertAt : null; + if (vim.visualMode) { + var selections = getSelectedAreaRange(cm, vim); + var selectionStart = selections[0]; + var selectionEnd = selections[1]; + } if (insertAt == 'eol') { var cursor = cm.getCursor(); cursor = Pos(cursor.line, lineLength(cm, cursor.line)); @@ -2103,15 +2120,34 @@ } else if (insertAt == 'charAfter') { cm.setCursor(offsetCursor(cm.getCursor(), 0, 1)); } else if (insertAt == 'firstNonBlank') { - cm.setCursor(motions.moveToFirstNonWhiteSpaceCharacter(cm)); - } else if (insertAt == 'endOfSelectedArea') { - var selectionEnd = cm.getCursor('head'); - var selectionStart = cm.getCursor('anchor'); - if (selectionEnd.line < selectionStart.line) { - selectionEnd = Pos(selectionStart.line, 0); + if (vim.visualMode && !vim.visualBlock) { + if (selectionEnd.line < selectionStart.line) { + cm.setCursor(selectionEnd); + } else { + selectionStart = Pos(selectionStart.line, 0); + cm.setCursor(selectionStart); + } + cm.setCursor(motions.moveToFirstNonWhiteSpaceCharacter(cm)); + } else if (vim.visualBlock) { + selectionEnd = Pos(selectionEnd.line, selectionStart.ch); + cm.setCursor(selectionStart); + selectBlock(cm, selectionEnd); + } else { + cm.setCursor(motions.moveToFirstNonWhiteSpaceCharacter(cm)); + } + } else if (insertAt == 'endOfSelectedArea') { + if (vim.visualBlock) { + selectionStart = Pos(selectionStart.line, selectionEnd.ch); + cm.setCursor(selectionStart); + selectBlock(cm, selectionEnd); + } else if (selectionEnd.line < selectionStart.line) { + selectionEnd = Pos(selectionStart.line, 0); + cm.setCursor(selectionEnd); + } + } else if (insertAt == 'inplace') { + if (vim.visualMode){ + return; } - cm.setCursor(selectionEnd); - exitVisualMode(cm); } cm.setOption('keyMap', 'vim-insert'); cm.setOption('disableInput', false); @@ -2129,6 +2165,9 @@ cm.on('change', onChange); CodeMirror.on(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown); } + if (vim.visualMode) { + exitVisualMode(cm); + } }, toggleVisualMode: function(cm, actionArgs, vim) { var repeat = actionArgs.repeat; @@ -2339,6 +2378,7 @@ var text = Array(actionArgs.repeat + 1).join(text); } var linewise = register.linewise; + var blockwise = register.blockwise; if (linewise) { if(vim.visualMode) { text = vim.visualLine ? text.slice(0, -1) : '\n' + text.slice(0, text.length - 1) + '\n'; @@ -2351,6 +2391,12 @@ cur.ch = 0; } } else { + if (blockwise) { + text = text.split('\n'); + for (var i = 0; i < text.length; i++) { + text[i] = (text[i] == '') ? ' ' : text[i]; + } + } cur.ch += actionArgs.after ? 1 : 0; } var curPosFinal; @@ -2362,32 +2408,75 @@ var selectedArea = getSelectedAreaRange(cm, vim); var selectionStart = selectedArea[0]; var selectionEnd = selectedArea[1]; + var selectedText = cm.getSelection(); + var selections = cm.listSelections(); + var emptyStrings = new Array(selections.length).join('1').split('1'); // save the curEnd marker before it get cleared due to cm.replaceRange. - if (vim.lastSelection) lastSelectionCurEnd = vim.lastSelection.curEndMark.find(); + if (vim.lastSelection) { + lastSelectionCurEnd = vim.lastSelection.curEndMark.find(); + } // push the previously selected text to unnamed register - vimGlobalState.registerController.unnamedRegister.setText(cm.getRange(selectionStart, selectionEnd)); - cm.replaceRange(text, selectionStart, selectionEnd); + vimGlobalState.registerController.unnamedRegister.setText(selectedText); + if (blockwise) { + // first delete the selected text + cm.replaceSelections(emptyStrings); + // Set new selections as per the block length of the yanked text + selectionEnd = Pos(selectionStart.line + text.length-1, selectionStart.ch); + cm.setCursor(selectionStart); + selectBlock(cm, selectionEnd); + cm.replaceSelections(text); + curPosFinal = selectionStart; + } else if (vim.visualBlock) { + cm.replaceSelections(emptyStrings); + cm.setCursor(selectionStart); + cm.replaceRange(text, selectionStart, selectionStart); + curPosFinal = selectionStart; + } else { + cm.replaceRange(text, selectionStart, selectionEnd); + curPosFinal = cm.posFromIndex(cm.indexFromPos(selectionStart) + text.length - 1); + } // restore the the curEnd marker - if(lastSelectionCurEnd) vim.lastSelection.curEndMark = cm.setBookmark(lastSelectionCurEnd); - curPosFinal = cm.posFromIndex(cm.indexFromPos(selectionStart) + text.length - 1); - if(linewise)curPosFinal.ch=0; + if(lastSelectionCurEnd) { + vim.lastSelection.curEndMark = cm.setBookmark(lastSelectionCurEnd); + } + if (linewise) { + curPosFinal.ch=0; + } } else { - cm.replaceRange(text, cur); - // Now fine tune the cursor to where we want it. - if (linewise && actionArgs.after) { - curPosFinal = Pos( + if (blockwise) { + cm.setCursor(cur); + for (var i = 0; i < text.length; i++) { + var line = cur.line+i; + if (line > cm.lastLine()) { + cm.replaceRange('\n', Pos(line, 0)); + } + var lastCh = lineLength(cm, line); + if (lastCh < cur.ch) { + extendLineToColumn(cm, line, cur.ch); + } + } + cm.setCursor(cur); + selectBlock(cm, Pos(cur.line + text.length-1, cur.ch)); + cm.replaceSelections(text); + curPosFinal = cur; + } else { + cm.replaceRange(text, cur); + // Now fine tune the cursor to where we want it. + if (linewise && actionArgs.after) { + curPosFinal = Pos( cur.line + 1, findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line + 1))); - } else if (linewise && !actionArgs.after) { - curPosFinal = Pos( - cur.line, - findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line))); - } else if (!linewise && actionArgs.after) { - idx = cm.indexFromPos(cur); - curPosFinal = cm.posFromIndex(idx + text.length - 1); - } else { - idx = cm.indexFromPos(cur); - curPosFinal = cm.posFromIndex(idx + text.length); + } else if (linewise && !actionArgs.after) { + curPosFinal = Pos( + cur.line, + findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line))); + } else if (!linewise && actionArgs.after) { + idx = cm.indexFromPos(cur); + curPosFinal = cm.posFromIndex(idx + text.length - 1); + } else { + idx = cm.indexFromPos(cur); + curPosFinal = cm.posFromIndex(idx + text.length); + } } } cm.setCursor(curPosFinal); @@ -2597,6 +2686,12 @@ function escapeRegex(s) { return s.replace(/([.?*+$\[\]\/\\(){}|\-])/g, '\\$1'); } + function extendLineToColumn(cm, lineNum, column) { + var endCh = lineLength(cm, lineNum); + var spaces = new Array(column-endCh+1).join(' '); + cm.setCursor(Pos(lineNum, endCh)); + cm.replaceRange(spaces, cm.getCursor()); + } // This functions selects a rectangular block // of text with selectionEnd as any of its corner // Height of block: @@ -2606,55 +2701,86 @@ function selectBlock(cm, selectionEnd) { var selections = [], ranges = cm.listSelections(); var firstRange = ranges[0].anchor, lastRange = ranges[ranges.length-1].anchor; - var start, end, selectionStart; + var start, end, direction, selectionStart; var curEnd = cm.getCursor('head'); + var originalSelectionEnd = copyCursor(selectionEnd); + start = firstRange.line; + end = lastRange.line; + if (selectionEnd.line < curEnd.line) { + direction = 'up'; + } else if (selectionEnd.line > curEnd.line) { + direction = 'down'; + } else { + if (selectionEnd.ch != curEnd.ch) { + direction = selectionEnd.ch > curEnd.ch ? 'right' : 'left'; + } + selectionStart = cm.getCursor('anchor'); + } var primIndex = getIndex(ranges, curEnd); // sets to true when selectionEnd already lies inside the existing selections - var contains = getIndex(ranges, selectionEnd) < 0 ? false : true; selectionEnd = cm.clipPos(selectionEnd); - // difference in distance of selectionEnd from each end of the block. - var near = Math.abs(firstRange.line - selectionEnd.line) - Math.abs(lastRange.line - selectionEnd.line); - if (near > 0) { - end = selectionEnd.line; - start = firstRange.line; - if (lastRange.line == selectionEnd.line && contains) { - start = end; + var contains = getIndex(ranges, selectionEnd) < 0 ? false : true; + var isClipped = !cursorEqual(originalSelectionEnd, selectionEnd); + // This function helps to check selection crossing + // in case of short lines. + var processSelectionCrossing = function() { + if (isClipped) { + if (curEnd.ch >= selectionStart.ch) { + selectionStart.ch++; + } + } else if (curEnd.ch == lineLength(cm, curEnd.line)) { + if (cursorEqual(ranges[primIndex].anchor, ranges[primIndex].head) && ranges.length>1) { + if (direction == 'up') { + if (contains || primIndex>0) { + start = firstRange.line; + end = selectionEnd.line; + selectionStart = ranges[primIndex-1].anchor; + } + } else { + if (contains || primIndex == 0) { + end = lastRange.line; + start = selectionEnd.line; + selectionStart = ranges[primIndex+1].anchor; + } + } + if (selectionEnd.ch >= selectionStart.ch) { + selectionStart.ch--; + } + } } - } else if (near < 0) { - start = selectionEnd.line; - end = lastRange.line; - if (firstRange.line == selectionEnd.line && contains) { - end = start; - } - } else { - // Case where selectionEnd line is halfway between the 2 ends. - // We remove the primary selection in this case - if (primIndex == 0) { - start = selectionEnd.line; - end = lastRange.line; - } else { - start = firstRange.line; + }; + switch(direction) { + case 'up': + start = contains ? firstRange.line : selectionEnd.line; + end = contains ? selectionEnd.line : lastRange.line; + selectionStart = lastRange; + processSelectionCrossing(); + break; + case 'down': + start = contains ? selectionEnd.line : firstRange.line; + end = contains ? lastRange.line : selectionEnd.line; + selectionStart = firstRange; + processSelectionCrossing(); + break; + case 'left': + if ((selectionEnd.ch <= selectionStart.ch) && (curEnd.ch > selectionStart.ch)) { + selectionStart.ch++; + selectionEnd.ch--; + } + break; + case 'right': + if ((selectionStart.ch <= selectionEnd.ch) && (curEnd.ch < selectionStart.ch)) { + selectionStart.ch--; + selectionEnd.ch++; + } + break; + default: + start = selectionStart.line; end = selectionEnd.line; - } } - if (start > end) { - var tmp = start; - start = end; - end = tmp; - } - selectionStart = (near > 0) ? firstRange : lastRange; while (start <= end) { var anchor = {line: start, ch: selectionStart.ch}; var head = {line: start, ch: selectionEnd.ch}; - // Shift the anchor right or left - // as each selection crosses itself. - if ((anchor.ch < curEnd.ch) && ((head.ch == anchor.ch) || (anchor.ch - head.ch == 1))) { - anchor.ch++; - head.ch--; - } else if ((anchor.ch > curEnd.ch) && ((head.ch == anchor.ch) || (anchor.ch - head.ch == -1))) { - anchor.ch--; - head.ch++; - } var range = {anchor: anchor, head: head}; selections.push(range); if (cursorEqual(head, selectionEnd)) { @@ -2666,16 +2792,29 @@ // after selection crossing selectionEnd.ch = selections[0].head.ch; selectionStart.ch = selections[0].anchor.ch; + if (cursorEqual(selectionEnd, selections[0].head)) { + selectionStart.line = selections[selections.length-1].anchor.line; + } else { + selectionStart.line = selections[0].anchor.line; + } cm.setSelections(selections, primIndex); return selectionStart; } - function getIndex(ranges, head) { + // getIndex returns the index of the cursor in the selections. + function getIndex(ranges, cursor, end) { + var pos = -1; for (var i = 0; i < ranges.length; i++) { - if (cursorEqual(ranges[i].head, head)) { - return i; + var atAnchor = cursorEqual(ranges[i].anchor, cursor); + var atHead = cursorEqual(ranges[i].head, cursor); + if (end == 'head') { + pos = atHead ? i : pos; + } else if (end == 'anchor') { + pos = atAnchor ? i : pos; + } else { + pos = (atAnchor || atHead) ? i : pos; } } - return -1; + return pos; } function getSelectedAreaRange(cm, vim) { var lastSelection = vim.lastSelection; @@ -2739,7 +2878,7 @@ var ranges = cm.listSelections(); // This check ensures to set the cursor // position where we left off in previous selection - var swap = getIndex(ranges, selectionStart) > -1; + var swap = getIndex(ranges, selectionStart, 'head') > -1; if (vim.visualBlock) { var height = Math.abs(selectionStart.line - selectionEnd.line)+1; var width = Math.abs(selectionStart.ch - selectionEnd.ch); @@ -2759,14 +2898,16 @@ var vim = cm.state.vim; var selectionStart = cm.getCursor('anchor'); var selectionEnd = cm.getCursor('head'); + // hack to place the cursor at the right place + // in case of visual block + if (vim.visualBlock && (cursorIsBefore(selectionStart, selectionEnd))) { + selectionEnd.ch--; + } updateLastSelection(cm, vim); vim.visualMode = false; vim.visualLine = false; vim.visualBlock = false; if (!cursorEqual(selectionStart, selectionEnd)) { - // Clear the selection and set the cursor only if the selection has not - // already been cleared. Otherwise we risk moving the cursor somewhere - // it's not supposed to be. cm.setCursor(clipCursorToContent(cm, selectionEnd)); } CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); @@ -4498,7 +4639,32 @@ var macroModeState = vimGlobalState.macroModeState; var insertModeChangeRegister = vimGlobalState.registerController.getRegister('.'); var isPlaying = macroModeState.isPlaying; + var lastChange = macroModeState.lastInsertModeChanges; + // In case of visual block, the insertModeChanges are not saved as a + // single word, so we convert them to a single word + // so as to update the ". register as expected in real vim. + var text = []; if (!isPlaying) { + var selLength = lastChange.inVisualBlock ? vim.lastSelection.visualBlock.height : 1; + var changes = lastChange.changes; + var text = []; + var i = 0; + // In case of multiple selections in blockwise visual, + // the inserted text, for example: 'foo', is stored as + // 'f', 'f', InsertModeKey 'o', 'o', 'o', 'o'. (if you have a block with 2 lines). + // We push the contents of the changes array as per the following: + // 1. In case of InsertModeKey, just increment by 1. + // 2. In case of a character, jump by selLength (2 in the example). + while (i < changes.length) { + // This loop will convert 'ffoooo' to 'foo'. + text.push(changes[i]); + if (changes[i] instanceof InsertModeKey) { + i++; + } else { + i+= selLength; + } + } + lastChange.changes = text; cm.off('change', onChange); CodeMirror.off(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown); } @@ -4515,13 +4681,64 @@ cm.setOption('disableInput', true); cm.toggleOverwrite(false); // exit replace mode if we were in it. // update the ". register before exiting insert mode - insertModeChangeRegister.setText(macroModeState.lastInsertModeChanges.changes.join('')); + insertModeChangeRegister.setText(lastChange.changes.join('')); CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); if (macroModeState.isRecording) { logInsertModeChange(macroModeState); } } + defineOption('enableInsertModeEscKeys', false, 'boolean'); + // Use this option to customize the two-character ESC keymap. + // If you want to use characters other than i j or k you'll have to add + // lines to the vim-insert and await-second keymaps later in this file. + defineOption('insertModeEscKeys', 'kj', 'string'); + // The timeout in milliseconds for the two-character ESC keymap should be + // adjusted according to your typing speed to prevent false positives. + defineOption('insertModeEscKeysTimeout', 200, 'number'); + function firstEscCharacterHandler(ch) { + return function(cm){ + var keys = getOption('insertModeEscKeys'); + var firstEscCharacter = keys && keys.length > 1 && keys.charAt(0); + if (!getOption('enableInsertModeEscKeys')|| firstEscCharacter !== ch) { + return CodeMirror.Pass; + } else { + cm.replaceRange(ch, cm.getCursor(), cm.getCursor(), "+input"); + cm.setOption('keyMap', 'await-second'); + cm.state.vim.awaitingEscapeSecondCharacter = true; + setTimeout( + function(){ + if(cm.state.vim.awaitingEscapeSecondCharacter) { + cm.state.vim.awaitingEscapeSecondCharacter = false; + cm.setOption('keyMap', 'vim-insert'); + } + }, + getOption('insertModeEscKeysTimeout')); + } + }; + } + function secondEscCharacterHandler(ch){ + return function(cm) { + var keys = getOption('insertModeEscKeys'); + var secondEscCharacter = keys && keys.length > 1 && keys.charAt(1); + if (!getOption('enableInsertModeEscKeys')|| secondEscCharacter !== ch) { + return CodeMirror.Pass; + // This is not the handler you're looking for. Just insert as usual. + } else { + if (cm.state.vim.insertMode) { + var lastChange = vimGlobalState.macroModeState.lastInsertModeChanges; + if (lastChange && lastChange.changes.length) { + lastChange.changes.pop(); + } + } + cm.state.vim.awaitingEscapeSecondCharacter = false; + cm.replaceRange('', {ch: cm.getCursor().ch - 1, line: cm.getCursor().line}, + cm.getCursor(), "+input"); + exitInsertMode(cm); + } + }; + } + CodeMirror.keyMap['vim-insert'] = { // TODO: override navigation keys so that Esc will cancel automatic // indentation from o, O, i_ @@ -4535,9 +4752,23 @@ CodeMirror.commands.newlineAndIndent; fn(cm); }, + // The next few lines are where you'd add additional handlers if + // you wanted to use keys other than i j and k for two-character + // escape sequences. Don't forget to add them in the await-second + // section as well. + "'i'": firstEscCharacterHandler('i'), + "'j'": firstEscCharacterHandler('j'), + "'k'": firstEscCharacterHandler('k'), fallthrough: ['default'] }; + CodeMirror.keyMap['await-second'] = { + "'i'": secondEscCharacterHandler('i'), + "'j'": secondEscCharacterHandler('j'), + "'k'": secondEscCharacterHandler('k'), + fallthrough: ['vim-insert'] + }; + CodeMirror.keyMap['vim-replace'] = { 'Backspace': 'goCharLeft', fallthrough: ['vim-insert'] @@ -4710,11 +4941,7 @@ // insert mode changes. Will conform to that behavior. repeat = !vim.lastEditActionCommand ? 1 : repeat; var changeObject = macroModeState.lastInsertModeChanges; - // This isn't strictly necessary, but since lastInsertModeChanges is - // supposed to be immutable during replay, this helps catch bugs. - macroModeState.lastInsertModeChanges = {}; repeatInsertModeChanges(cm, changeObject.changes, repeat); - macroModeState.lastInsertModeChanges = changeObject; } } vim.inputState = vim.lastEditInputState; @@ -4752,6 +4979,18 @@ } return true; } + var curStart = cm.getCursor(); + var inVisualBlock = vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock; + if (inVisualBlock) { + // Set up block selection again for repeating the changes. + var vim = cm.state.vim; + var block = vim.lastSelection.visualBlock; + var curEnd = Pos(curStart.line + block.height-1, curStart.ch); + cm.setCursor(curStart); + selectBlock(cm, curEnd); + repeat = cm.listSelections().length; + cm.setCursor(curStart); + } for (var i = 0; i < repeat; i++) { for (var j = 0; j < changes.length; j++) { var change = changes[j]; @@ -4762,6 +5001,10 @@ cm.replaceRange(change, cur, cur); } } + if (inVisualBlock) { + curStart.line++; + cm.setCursor(curStart); + } } } diff --git a/static/js/lib/codemirror-4.4/mode/apl/apl.js b/static/js/lib/codemirror-4.5/mode/apl/apl.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/apl/apl.js rename to static/js/lib/codemirror-4.5/mode/apl/apl.js diff --git a/static/js/lib/codemirror-4.4/mode/apl/index.html b/static/js/lib/codemirror-4.5/mode/apl/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/apl/index.html rename to static/js/lib/codemirror-4.5/mode/apl/index.html diff --git a/static/js/lib/codemirror-4.4/mode/asterisk/asterisk.js b/static/js/lib/codemirror-4.5/mode/asterisk/asterisk.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/asterisk/asterisk.js rename to static/js/lib/codemirror-4.5/mode/asterisk/asterisk.js diff --git a/static/js/lib/codemirror-4.4/mode/asterisk/index.html b/static/js/lib/codemirror-4.5/mode/asterisk/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/asterisk/index.html rename to static/js/lib/codemirror-4.5/mode/asterisk/index.html diff --git a/static/js/lib/codemirror-4.4/mode/clike/clike.js b/static/js/lib/codemirror-4.5/mode/clike/clike.js similarity index 97% rename from static/js/lib/codemirror-4.4/mode/clike/clike.js rename to static/js/lib/codemirror-4.5/mode/clike/clike.js index 2873e36..ee2c77a 100644 --- a/static/js/lib/codemirror-4.4/mode/clike/clike.js +++ b/static/js/lib/codemirror-4.5/mode/clike/clike.js @@ -437,4 +437,15 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { modeProps: {fold: ["brace", "include"]} }); + def("text/x-nesc", { + name: "clike", + keywords: words(cKeywords + "as atomic async call command component components configuration event generic " + + "implementation includes interface module new norace nx_struct nx_union post provides " + + "signal task uses abstract extends"), + blockKeywords: words("case do else for if switch while struct"), + atoms: words("null"), + hooks: {"#": cppHook}, + modeProps: {fold: ["brace", "include"]} + }); + }); diff --git a/static/js/lib/codemirror-4.4/mode/clike/index.html b/static/js/lib/codemirror-4.5/mode/clike/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/clike/index.html rename to static/js/lib/codemirror-4.5/mode/clike/index.html diff --git a/static/js/lib/codemirror-4.4/mode/clike/scala.html b/static/js/lib/codemirror-4.5/mode/clike/scala.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/clike/scala.html rename to static/js/lib/codemirror-4.5/mode/clike/scala.html diff --git a/static/js/lib/codemirror-4.4/mode/clojure/clojure.js b/static/js/lib/codemirror-4.5/mode/clojure/clojure.js similarity index 99% rename from static/js/lib/codemirror-4.4/mode/clojure/clojure.js rename to static/js/lib/codemirror-4.5/mode/clojure/clojure.js index f81bd2c..73bfcd3 100644 --- a/static/js/lib/codemirror-4.4/mode/clojure/clojure.js +++ b/static/js/lib/codemirror-4.5/mode/clojure/clojure.js @@ -114,7 +114,7 @@ CodeMirror.defineMode("clojure", function (options) { var first = stream.next(); // Read special literals: backspace, newline, space, return. // Just read all lowercase letters. - if (first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) { + if (first && first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) { return; } // Read unicode character: \u1000 \uA0a1 diff --git a/static/js/lib/codemirror-4.4/mode/clojure/index.html b/static/js/lib/codemirror-4.5/mode/clojure/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/clojure/index.html rename to static/js/lib/codemirror-4.5/mode/clojure/index.html diff --git a/static/js/lib/codemirror-4.4/mode/cobol/cobol.js b/static/js/lib/codemirror-4.5/mode/cobol/cobol.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/cobol/cobol.js rename to static/js/lib/codemirror-4.5/mode/cobol/cobol.js diff --git a/static/js/lib/codemirror-4.4/mode/cobol/index.html b/static/js/lib/codemirror-4.5/mode/cobol/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/cobol/index.html rename to static/js/lib/codemirror-4.5/mode/cobol/index.html diff --git a/static/js/lib/codemirror-4.4/mode/coffeescript/coffeescript.js b/static/js/lib/codemirror-4.5/mode/coffeescript/coffeescript.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/coffeescript/coffeescript.js rename to static/js/lib/codemirror-4.5/mode/coffeescript/coffeescript.js diff --git a/static/js/lib/codemirror-4.4/mode/coffeescript/index.html b/static/js/lib/codemirror-4.5/mode/coffeescript/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/coffeescript/index.html rename to static/js/lib/codemirror-4.5/mode/coffeescript/index.html diff --git a/static/js/lib/codemirror-4.4/mode/commonlisp/commonlisp.js b/static/js/lib/codemirror-4.5/mode/commonlisp/commonlisp.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/commonlisp/commonlisp.js rename to static/js/lib/codemirror-4.5/mode/commonlisp/commonlisp.js diff --git a/static/js/lib/codemirror-4.4/mode/commonlisp/index.html b/static/js/lib/codemirror-4.5/mode/commonlisp/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/commonlisp/index.html rename to static/js/lib/codemirror-4.5/mode/commonlisp/index.html diff --git a/static/js/lib/codemirror-4.4/mode/css/css.js b/static/js/lib/codemirror-4.5/mode/css/css.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/css/css.js rename to static/js/lib/codemirror-4.5/mode/css/css.js diff --git a/static/js/lib/codemirror-4.4/mode/css/index.html b/static/js/lib/codemirror-4.5/mode/css/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/css/index.html rename to static/js/lib/codemirror-4.5/mode/css/index.html diff --git a/static/js/lib/codemirror-4.4/mode/css/less.html b/static/js/lib/codemirror-4.5/mode/css/less.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/css/less.html rename to static/js/lib/codemirror-4.5/mode/css/less.html diff --git a/static/js/lib/codemirror-4.4/mode/css/less_test.js b/static/js/lib/codemirror-4.5/mode/css/less_test.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/css/less_test.js rename to static/js/lib/codemirror-4.5/mode/css/less_test.js diff --git a/static/js/lib/codemirror-4.4/mode/css/scss.html b/static/js/lib/codemirror-4.5/mode/css/scss.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/css/scss.html rename to static/js/lib/codemirror-4.5/mode/css/scss.html diff --git a/static/js/lib/codemirror-4.4/mode/css/scss_test.js b/static/js/lib/codemirror-4.5/mode/css/scss_test.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/css/scss_test.js rename to static/js/lib/codemirror-4.5/mode/css/scss_test.js diff --git a/static/js/lib/codemirror-4.4/mode/css/test.js b/static/js/lib/codemirror-4.5/mode/css/test.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/css/test.js rename to static/js/lib/codemirror-4.5/mode/css/test.js diff --git a/static/js/lib/codemirror-4.4/mode/cypher/cypher.js b/static/js/lib/codemirror-4.5/mode/cypher/cypher.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/cypher/cypher.js rename to static/js/lib/codemirror-4.5/mode/cypher/cypher.js diff --git a/static/js/lib/codemirror-4.4/mode/cypher/index.html b/static/js/lib/codemirror-4.5/mode/cypher/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/cypher/index.html rename to static/js/lib/codemirror-4.5/mode/cypher/index.html diff --git a/static/js/lib/codemirror-4.4/mode/d/d.js b/static/js/lib/codemirror-4.5/mode/d/d.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/d/d.js rename to static/js/lib/codemirror-4.5/mode/d/d.js diff --git a/static/js/lib/codemirror-4.4/mode/d/index.html b/static/js/lib/codemirror-4.5/mode/d/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/d/index.html rename to static/js/lib/codemirror-4.5/mode/d/index.html diff --git a/static/js/lib/codemirror-4.4/mode/diff/diff.js b/static/js/lib/codemirror-4.5/mode/diff/diff.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/diff/diff.js rename to static/js/lib/codemirror-4.5/mode/diff/diff.js diff --git a/static/js/lib/codemirror-4.4/mode/diff/index.html b/static/js/lib/codemirror-4.5/mode/diff/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/diff/index.html rename to static/js/lib/codemirror-4.5/mode/diff/index.html diff --git a/static/js/lib/codemirror-4.4/mode/django/django.js b/static/js/lib/codemirror-4.5/mode/django/django.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/django/django.js rename to static/js/lib/codemirror-4.5/mode/django/django.js diff --git a/static/js/lib/codemirror-4.4/mode/django/index.html b/static/js/lib/codemirror-4.5/mode/django/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/django/index.html rename to static/js/lib/codemirror-4.5/mode/django/index.html diff --git a/static/js/lib/codemirror-4.4/mode/dtd/dtd.js b/static/js/lib/codemirror-4.5/mode/dtd/dtd.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/dtd/dtd.js rename to static/js/lib/codemirror-4.5/mode/dtd/dtd.js diff --git a/static/js/lib/codemirror-4.4/mode/dtd/index.html b/static/js/lib/codemirror-4.5/mode/dtd/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/dtd/index.html rename to static/js/lib/codemirror-4.5/mode/dtd/index.html diff --git a/static/js/lib/codemirror-4.4/mode/dylan/dylan.js b/static/js/lib/codemirror-4.5/mode/dylan/dylan.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/dylan/dylan.js rename to static/js/lib/codemirror-4.5/mode/dylan/dylan.js diff --git a/static/js/lib/codemirror-4.4/mode/dylan/index.html b/static/js/lib/codemirror-4.5/mode/dylan/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/dylan/index.html rename to static/js/lib/codemirror-4.5/mode/dylan/index.html diff --git a/static/js/lib/codemirror-4.4/mode/ecl/ecl.js b/static/js/lib/codemirror-4.5/mode/ecl/ecl.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/ecl/ecl.js rename to static/js/lib/codemirror-4.5/mode/ecl/ecl.js diff --git a/static/js/lib/codemirror-4.4/mode/ecl/index.html b/static/js/lib/codemirror-4.5/mode/ecl/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/ecl/index.html rename to static/js/lib/codemirror-4.5/mode/ecl/index.html diff --git a/static/js/lib/codemirror-4.4/mode/eiffel/eiffel.js b/static/js/lib/codemirror-4.5/mode/eiffel/eiffel.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/eiffel/eiffel.js rename to static/js/lib/codemirror-4.5/mode/eiffel/eiffel.js diff --git a/static/js/lib/codemirror-4.4/mode/eiffel/index.html b/static/js/lib/codemirror-4.5/mode/eiffel/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/eiffel/index.html rename to static/js/lib/codemirror-4.5/mode/eiffel/index.html diff --git a/static/js/lib/codemirror-4.4/mode/erlang/erlang.js b/static/js/lib/codemirror-4.5/mode/erlang/erlang.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/erlang/erlang.js rename to static/js/lib/codemirror-4.5/mode/erlang/erlang.js diff --git a/static/js/lib/codemirror-4.4/mode/erlang/index.html b/static/js/lib/codemirror-4.5/mode/erlang/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/erlang/index.html rename to static/js/lib/codemirror-4.5/mode/erlang/index.html diff --git a/static/js/lib/codemirror-4.4/mode/fortran/fortran.js b/static/js/lib/codemirror-4.5/mode/fortran/fortran.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/fortran/fortran.js rename to static/js/lib/codemirror-4.5/mode/fortran/fortran.js diff --git a/static/js/lib/codemirror-4.4/mode/fortran/index.html b/static/js/lib/codemirror-4.5/mode/fortran/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/fortran/index.html rename to static/js/lib/codemirror-4.5/mode/fortran/index.html diff --git a/static/js/lib/codemirror-4.4/mode/gas/gas.js b/static/js/lib/codemirror-4.5/mode/gas/gas.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/gas/gas.js rename to static/js/lib/codemirror-4.5/mode/gas/gas.js diff --git a/static/js/lib/codemirror-4.4/mode/gas/index.html b/static/js/lib/codemirror-4.5/mode/gas/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/gas/index.html rename to static/js/lib/codemirror-4.5/mode/gas/index.html diff --git a/static/js/lib/codemirror-4.4/mode/gfm/gfm.js b/static/js/lib/codemirror-4.5/mode/gfm/gfm.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/gfm/gfm.js rename to static/js/lib/codemirror-4.5/mode/gfm/gfm.js diff --git a/static/js/lib/codemirror-4.4/mode/gfm/index.html b/static/js/lib/codemirror-4.5/mode/gfm/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/gfm/index.html rename to static/js/lib/codemirror-4.5/mode/gfm/index.html diff --git a/static/js/lib/codemirror-4.4/mode/gfm/test.js b/static/js/lib/codemirror-4.5/mode/gfm/test.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/gfm/test.js rename to static/js/lib/codemirror-4.5/mode/gfm/test.js diff --git a/static/js/lib/codemirror-4.4/mode/gherkin/gherkin.js b/static/js/lib/codemirror-4.5/mode/gherkin/gherkin.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/gherkin/gherkin.js rename to static/js/lib/codemirror-4.5/mode/gherkin/gherkin.js diff --git a/static/js/lib/codemirror-4.4/mode/gherkin/index.html b/static/js/lib/codemirror-4.5/mode/gherkin/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/gherkin/index.html rename to static/js/lib/codemirror-4.5/mode/gherkin/index.html diff --git a/static/js/lib/codemirror-4.4/mode/go/go.js b/static/js/lib/codemirror-4.5/mode/go/go.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/go/go.js rename to static/js/lib/codemirror-4.5/mode/go/go.js diff --git a/static/js/lib/codemirror-4.4/mode/go/index.html b/static/js/lib/codemirror-4.5/mode/go/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/go/index.html rename to static/js/lib/codemirror-4.5/mode/go/index.html diff --git a/static/js/lib/codemirror-4.4/mode/groovy/groovy.js b/static/js/lib/codemirror-4.5/mode/groovy/groovy.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/groovy/groovy.js rename to static/js/lib/codemirror-4.5/mode/groovy/groovy.js diff --git a/static/js/lib/codemirror-4.4/mode/groovy/index.html b/static/js/lib/codemirror-4.5/mode/groovy/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/groovy/index.html rename to static/js/lib/codemirror-4.5/mode/groovy/index.html diff --git a/static/js/lib/codemirror-4.4/mode/haml/haml.js b/static/js/lib/codemirror-4.5/mode/haml/haml.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/haml/haml.js rename to static/js/lib/codemirror-4.5/mode/haml/haml.js diff --git a/static/js/lib/codemirror-4.4/mode/haml/index.html b/static/js/lib/codemirror-4.5/mode/haml/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/haml/index.html rename to static/js/lib/codemirror-4.5/mode/haml/index.html diff --git a/static/js/lib/codemirror-4.4/mode/haml/test.js b/static/js/lib/codemirror-4.5/mode/haml/test.js similarity index 96% rename from static/js/lib/codemirror-4.4/mode/haml/test.js rename to static/js/lib/codemirror-4.5/mode/haml/test.js index 3a6100a..508458a 100644 --- a/static/js/lib/codemirror-4.4/mode/haml/test.js +++ b/static/js/lib/codemirror-4.5/mode/haml/test.js @@ -53,9 +53,9 @@ " [comment -# this is a comment]", " [comment and this is a comment too]", " Date/Time", - " [operator -] [variable now] [operator =] [tag DateTime][operator .][variable now]", + " [operator -] [variable now] [operator =] [tag DateTime][operator .][property now]", " [tag %strong=] [variable now]", - " [operator -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][variable parse]([string \"December 31, 2006\"])", + " [operator -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][property parse]([string \"December 31, 2006\"])", " [operator =][string \"Happy\"]", " [operator =][string \"Belated\"]", " [operator =][string \"Birthday\"]"); diff --git a/static/js/lib/codemirror-4.4/mode/haskell/haskell.js b/static/js/lib/codemirror-4.5/mode/haskell/haskell.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/haskell/haskell.js rename to static/js/lib/codemirror-4.5/mode/haskell/haskell.js diff --git a/static/js/lib/codemirror-4.4/mode/haskell/index.html b/static/js/lib/codemirror-4.5/mode/haskell/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/haskell/index.html rename to static/js/lib/codemirror-4.5/mode/haskell/index.html diff --git a/static/js/lib/codemirror-4.4/mode/haxe/haxe.js b/static/js/lib/codemirror-4.5/mode/haxe/haxe.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/haxe/haxe.js rename to static/js/lib/codemirror-4.5/mode/haxe/haxe.js diff --git a/static/js/lib/codemirror-4.4/mode/haxe/index.html b/static/js/lib/codemirror-4.5/mode/haxe/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/haxe/index.html rename to static/js/lib/codemirror-4.5/mode/haxe/index.html diff --git a/static/js/lib/codemirror-4.4/mode/htmlembedded/htmlembedded.js b/static/js/lib/codemirror-4.5/mode/htmlembedded/htmlembedded.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/htmlembedded/htmlembedded.js rename to static/js/lib/codemirror-4.5/mode/htmlembedded/htmlembedded.js diff --git a/static/js/lib/codemirror-4.4/mode/htmlembedded/index.html b/static/js/lib/codemirror-4.5/mode/htmlembedded/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/htmlembedded/index.html rename to static/js/lib/codemirror-4.5/mode/htmlembedded/index.html diff --git a/static/js/lib/codemirror-4.4/mode/htmlmixed/htmlmixed.js b/static/js/lib/codemirror-4.5/mode/htmlmixed/htmlmixed.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/htmlmixed/htmlmixed.js rename to static/js/lib/codemirror-4.5/mode/htmlmixed/htmlmixed.js diff --git a/static/js/lib/codemirror-4.4/mode/htmlmixed/index.html b/static/js/lib/codemirror-4.5/mode/htmlmixed/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/htmlmixed/index.html rename to static/js/lib/codemirror-4.5/mode/htmlmixed/index.html diff --git a/static/js/lib/codemirror-4.4/mode/http/http.js b/static/js/lib/codemirror-4.5/mode/http/http.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/http/http.js rename to static/js/lib/codemirror-4.5/mode/http/http.js diff --git a/static/js/lib/codemirror-4.4/mode/http/index.html b/static/js/lib/codemirror-4.5/mode/http/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/http/index.html rename to static/js/lib/codemirror-4.5/mode/http/index.html diff --git a/static/js/lib/codemirror-4.4/mode/index.html b/static/js/lib/codemirror-4.5/mode/index.html similarity index 99% rename from static/js/lib/codemirror-4.4/mode/index.html rename to static/js/lib/codemirror-4.5/mode/index.html index 1aa0b8d..1c106ae 100644 --- a/static/js/lib/codemirror-4.4/mode/index.html +++ b/static/js/lib/codemirror-4.5/mode/index.html @@ -95,6 +95,7 @@ option.

  • SCSS
  • Shell
  • Sieve
  • +
  • Slim
  • Smalltalk
  • Smarty
  • Smarty/HTML mixed
  • diff --git a/static/js/lib/codemirror-4.4/mode/jade/index.html b/static/js/lib/codemirror-4.5/mode/jade/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/jade/index.html rename to static/js/lib/codemirror-4.5/mode/jade/index.html diff --git a/static/js/lib/codemirror-4.4/mode/jade/jade.js b/static/js/lib/codemirror-4.5/mode/jade/jade.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/jade/jade.js rename to static/js/lib/codemirror-4.5/mode/jade/jade.js diff --git a/static/js/lib/codemirror-4.4/mode/javascript/index.html b/static/js/lib/codemirror-4.5/mode/javascript/index.html similarity index 92% rename from static/js/lib/codemirror-4.4/mode/javascript/index.html rename to static/js/lib/codemirror-4.5/mode/javascript/index.html index faf5036..59e3924 100644 --- a/static/js/lib/codemirror-4.4/mode/javascript/index.html +++ b/static/js/lib/codemirror-4.5/mode/javascript/index.html @@ -102,6 +102,11 @@ StringStream.prototype = {
  • statementIndent which (given a number) will determine the amount of indentation to use for statements continued on a new line.
  • +
  • wordCharacters, a regexp that indicates which + characters should be considered part of an identifier. + Defaults to /[\w$]/, which does not handle + non-ASCII identifiers. Can be set to something more elaborate + to improve Unicode support.
  • diff --git a/static/js/lib/codemirror-4.4/mode/javascript/javascript.js b/static/js/lib/codemirror-4.5/mode/javascript/javascript.js similarity index 99% rename from static/js/lib/codemirror-4.4/mode/javascript/javascript.js rename to static/js/lib/codemirror-4.5/mode/javascript/javascript.js index fdb066e..46616bc 100644 --- a/static/js/lib/codemirror-4.4/mode/javascript/javascript.js +++ b/static/js/lib/codemirror-4.5/mode/javascript/javascript.js @@ -19,6 +19,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { var jsonldMode = parserConfig.jsonld; var jsonMode = parserConfig.json || jsonldMode; var isTS = parserConfig.typescript; + var wordRE = parserConfig.wordCharacters || /[\w$]/; // Tokenizer @@ -132,8 +133,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } else if (isOperatorChar.test(ch)) { stream.eatWhile(isOperatorChar); return ret("operator", "operator", stream.current()); - } else { - stream.eatWhile(/[\w\$_]/); + } else if (wordRE.test(ch)) { + stream.eatWhile(wordRE); var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word]; return (known && state.lastType != ".") ? ret(known.type, known.style, word) : ret("variable", "variable", word); @@ -202,7 +203,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (--depth == 0) break; } else if (bracket >= 3 && bracket < 6) { ++depth; - } else if (/[$\w]/.test(ch)) { + } else if (wordRE.test(ch)) { sawSomething = true; } else if (sawSomething && !depth) { ++pos; @@ -669,7 +670,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { }; }); -CodeMirror.registerHelper("wordChars", "javascript", /[\\w$]/); +CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/); CodeMirror.defineMIME("text/javascript", "javascript"); CodeMirror.defineMIME("text/ecmascript", "javascript"); diff --git a/static/js/lib/codemirror-4.4/mode/javascript/json-ld.html b/static/js/lib/codemirror-4.5/mode/javascript/json-ld.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/javascript/json-ld.html rename to static/js/lib/codemirror-4.5/mode/javascript/json-ld.html diff --git a/static/js/lib/codemirror-4.4/mode/javascript/test.js b/static/js/lib/codemirror-4.5/mode/javascript/test.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/javascript/test.js rename to static/js/lib/codemirror-4.5/mode/javascript/test.js diff --git a/static/js/lib/codemirror-4.4/mode/javascript/typescript.html b/static/js/lib/codemirror-4.5/mode/javascript/typescript.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/javascript/typescript.html rename to static/js/lib/codemirror-4.5/mode/javascript/typescript.html diff --git a/static/js/lib/codemirror-4.4/mode/jinja2/index.html b/static/js/lib/codemirror-4.5/mode/jinja2/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/jinja2/index.html rename to static/js/lib/codemirror-4.5/mode/jinja2/index.html diff --git a/static/js/lib/codemirror-4.4/mode/jinja2/jinja2.js b/static/js/lib/codemirror-4.5/mode/jinja2/jinja2.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/jinja2/jinja2.js rename to static/js/lib/codemirror-4.5/mode/jinja2/jinja2.js diff --git a/static/js/lib/codemirror-4.4/mode/julia/index.html b/static/js/lib/codemirror-4.5/mode/julia/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/julia/index.html rename to static/js/lib/codemirror-4.5/mode/julia/index.html diff --git a/static/js/lib/codemirror-4.4/mode/julia/julia.js b/static/js/lib/codemirror-4.5/mode/julia/julia.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/julia/julia.js rename to static/js/lib/codemirror-4.5/mode/julia/julia.js diff --git a/static/js/lib/codemirror-4.4/mode/kotlin/index.html b/static/js/lib/codemirror-4.5/mode/kotlin/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/kotlin/index.html rename to static/js/lib/codemirror-4.5/mode/kotlin/index.html diff --git a/static/js/lib/codemirror-4.4/mode/kotlin/kotlin.js b/static/js/lib/codemirror-4.5/mode/kotlin/kotlin.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/kotlin/kotlin.js rename to static/js/lib/codemirror-4.5/mode/kotlin/kotlin.js diff --git a/static/js/lib/codemirror-4.4/mode/livescript/index.html b/static/js/lib/codemirror-4.5/mode/livescript/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/livescript/index.html rename to static/js/lib/codemirror-4.5/mode/livescript/index.html diff --git a/static/js/lib/codemirror-4.4/mode/livescript/livescript.js b/static/js/lib/codemirror-4.5/mode/livescript/livescript.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/livescript/livescript.js rename to static/js/lib/codemirror-4.5/mode/livescript/livescript.js diff --git a/static/js/lib/codemirror-4.4/mode/lua/index.html b/static/js/lib/codemirror-4.5/mode/lua/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/lua/index.html rename to static/js/lib/codemirror-4.5/mode/lua/index.html diff --git a/static/js/lib/codemirror-4.4/mode/lua/lua.js b/static/js/lib/codemirror-4.5/mode/lua/lua.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/lua/lua.js rename to static/js/lib/codemirror-4.5/mode/lua/lua.js diff --git a/static/js/lib/codemirror-4.4/mode/markdown/index.html b/static/js/lib/codemirror-4.5/mode/markdown/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/markdown/index.html rename to static/js/lib/codemirror-4.5/mode/markdown/index.html diff --git a/static/js/lib/codemirror-4.4/mode/markdown/markdown.js b/static/js/lib/codemirror-4.5/mode/markdown/markdown.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/markdown/markdown.js rename to static/js/lib/codemirror-4.5/mode/markdown/markdown.js diff --git a/static/js/lib/codemirror-4.4/mode/markdown/test.js b/static/js/lib/codemirror-4.5/mode/markdown/test.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/markdown/test.js rename to static/js/lib/codemirror-4.5/mode/markdown/test.js diff --git a/static/js/lib/codemirror-4.4/mode/meta.js b/static/js/lib/codemirror-4.5/mode/meta.js similarity index 99% rename from static/js/lib/codemirror-4.4/mode/meta.js rename to static/js/lib/codemirror-4.5/mode/meta.js index 3627cd7..e3c32b6 100644 --- a/static/js/lib/codemirror-4.4/mode/meta.js +++ b/static/js/lib/codemirror-4.5/mode/meta.js @@ -86,6 +86,7 @@ CodeMirror.modeInfo = [ {name: "SCSS", mime: "text/x-scss", mode: "css"}, {name: "Shell", mime: "text/x-sh", mode: "shell"}, {name: "Sieve", mime: "application/sieve", mode: "sieve"}, + {name: "Slim", mime: "text/x-slim", mode: "slim"}, {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk"}, {name: "Smarty", mime: "text/x-smarty", mode: "smarty"}, {name: "SmartyMixed", mime: "text/x-smarty", mode: "smartymixed"}, diff --git a/static/js/lib/codemirror-4.4/mode/mirc/index.html b/static/js/lib/codemirror-4.5/mode/mirc/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/mirc/index.html rename to static/js/lib/codemirror-4.5/mode/mirc/index.html diff --git a/static/js/lib/codemirror-4.4/mode/mirc/mirc.js b/static/js/lib/codemirror-4.5/mode/mirc/mirc.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/mirc/mirc.js rename to static/js/lib/codemirror-4.5/mode/mirc/mirc.js diff --git a/static/js/lib/codemirror-4.4/mode/mllike/index.html b/static/js/lib/codemirror-4.5/mode/mllike/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/mllike/index.html rename to static/js/lib/codemirror-4.5/mode/mllike/index.html diff --git a/static/js/lib/codemirror-4.4/mode/mllike/mllike.js b/static/js/lib/codemirror-4.5/mode/mllike/mllike.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/mllike/mllike.js rename to static/js/lib/codemirror-4.5/mode/mllike/mllike.js diff --git a/static/js/lib/codemirror-4.4/mode/nginx/index.html b/static/js/lib/codemirror-4.5/mode/nginx/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/nginx/index.html rename to static/js/lib/codemirror-4.5/mode/nginx/index.html diff --git a/static/js/lib/codemirror-4.4/mode/nginx/nginx.js b/static/js/lib/codemirror-4.5/mode/nginx/nginx.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/nginx/nginx.js rename to static/js/lib/codemirror-4.5/mode/nginx/nginx.js diff --git a/static/js/lib/codemirror-4.4/mode/ntriples/index.html b/static/js/lib/codemirror-4.5/mode/ntriples/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/ntriples/index.html rename to static/js/lib/codemirror-4.5/mode/ntriples/index.html diff --git a/static/js/lib/codemirror-4.4/mode/ntriples/ntriples.js b/static/js/lib/codemirror-4.5/mode/ntriples/ntriples.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/ntriples/ntriples.js rename to static/js/lib/codemirror-4.5/mode/ntriples/ntriples.js diff --git a/static/js/lib/codemirror-4.4/mode/octave/index.html b/static/js/lib/codemirror-4.5/mode/octave/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/octave/index.html rename to static/js/lib/codemirror-4.5/mode/octave/index.html diff --git a/static/js/lib/codemirror-4.4/mode/octave/octave.js b/static/js/lib/codemirror-4.5/mode/octave/octave.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/octave/octave.js rename to static/js/lib/codemirror-4.5/mode/octave/octave.js diff --git a/static/js/lib/codemirror-4.4/mode/pascal/index.html b/static/js/lib/codemirror-4.5/mode/pascal/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/pascal/index.html rename to static/js/lib/codemirror-4.5/mode/pascal/index.html diff --git a/static/js/lib/codemirror-4.4/mode/pascal/pascal.js b/static/js/lib/codemirror-4.5/mode/pascal/pascal.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/pascal/pascal.js rename to static/js/lib/codemirror-4.5/mode/pascal/pascal.js diff --git a/static/js/lib/codemirror-4.4/mode/pegjs/index.html b/static/js/lib/codemirror-4.5/mode/pegjs/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/pegjs/index.html rename to static/js/lib/codemirror-4.5/mode/pegjs/index.html diff --git a/static/js/lib/codemirror-4.4/mode/pegjs/pegjs.js b/static/js/lib/codemirror-4.5/mode/pegjs/pegjs.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/pegjs/pegjs.js rename to static/js/lib/codemirror-4.5/mode/pegjs/pegjs.js diff --git a/static/js/lib/codemirror-4.4/mode/perl/index.html b/static/js/lib/codemirror-4.5/mode/perl/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/perl/index.html rename to static/js/lib/codemirror-4.5/mode/perl/index.html diff --git a/static/js/lib/codemirror-4.4/mode/perl/perl.js b/static/js/lib/codemirror-4.5/mode/perl/perl.js similarity index 99% rename from static/js/lib/codemirror-4.4/mode/perl/perl.js rename to static/js/lib/codemirror-4.5/mode/perl/perl.js index ab86e84..c12677d 100644 --- a/static/js/lib/codemirror-4.4/mode/perl/perl.js +++ b/static/js/lib/codemirror-4.5/mode/perl/perl.js @@ -791,7 +791,7 @@ CodeMirror.defineMode("perl",function(){ return (state.tokenize||tokenPerl)(stream,state);}, electricChars:"{}"};}); -CodeMirror.registerHelper("wordChars", "perl", /[\\w$]/); +CodeMirror.registerHelper("wordChars", "perl", /[\w$]/); CodeMirror.defineMIME("text/x-perl", "perl"); diff --git a/static/js/lib/codemirror-4.4/mode/php/index.html b/static/js/lib/codemirror-4.5/mode/php/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/php/index.html rename to static/js/lib/codemirror-4.5/mode/php/index.html diff --git a/static/js/lib/codemirror-4.4/mode/php/php.js b/static/js/lib/codemirror-4.5/mode/php/php.js similarity index 89% rename from static/js/lib/codemirror-4.4/mode/php/php.js rename to static/js/lib/codemirror-4.5/mode/php/php.js index 72c19d8..f8821ed 100644 --- a/static/js/lib/codemirror-4.4/mode/php/php.js +++ b/static/js/lib/codemirror-4.5/mode/php/php.js @@ -95,9 +95,9 @@ "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"; + 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 json_decode json_encode json_last_error json_last_error_msg curl_close curl_copy_handle curl_errno curl_error curl_escape curl_exec curl_file_create curl_getinfo curl_init curl_multi_add_handle curl_multi_close curl_multi_exec curl_multi_getcontent curl_multi_info_read curl_multi_init curl_multi_remove_handle curl_multi_select curl_multi_setopt curl_multi_strerror curl_pause curl_reset curl_setopt_array curl_setopt curl_share_close curl_share_init curl_share_setopt curl_strerror curl_unescape curl_version mysqli_affected_rows mysqli_autocommit mysqli_change_user mysqli_character_set_name mysqli_close mysqli_commit mysqli_connect_errno mysqli_connect_error mysqli_connect mysqli_data_seek mysqli_debug mysqli_dump_debug_info mysqli_errno mysqli_error_list mysqli_error mysqli_fetch_all mysqli_fetch_array mysqli_fetch_assoc mysqli_fetch_field_direct mysqli_fetch_field mysqli_fetch_fields mysqli_fetch_lengths mysqli_fetch_object mysqli_fetch_row mysqli_field_count mysqli_field_seek mysqli_field_tell mysqli_free_result mysqli_get_charset mysqli_get_client_info mysqli_get_client_stats mysqli_get_client_version mysqli_get_connection_stats mysqli_get_host_info mysqli_get_proto_info mysqli_get_server_info mysqli_get_server_version mysqli_info mysqli_init mysqli_insert_id mysqli_kill mysqli_more_results mysqli_multi_query mysqli_next_result mysqli_num_fields mysqli_num_rows mysqli_options mysqli_ping mysqli_prepare mysqli_query mysqli_real_connect mysqli_real_escape_string mysqli_real_query mysqli_reap_async_query mysqli_refresh mysqli_rollback mysqli_select_db mysqli_set_charset mysqli_set_local_infile_default mysqli_set_local_infile_handler mysqli_sqlstate mysqli_ssl_set mysqli_stat mysqli_stmt_init mysqli_store_result mysqli_thread_id mysqli_thread_safe mysqli_use_result mysqli_warning_count"; CodeMirror.registerHelper("hintWords", "php", [phpKeywords, phpAtoms, phpBuiltin].join(" ").split(" ")); - CodeMirror.registerHelper("wordChars", "php", /[\\w$]/); + CodeMirror.registerHelper("wordChars", "php", /[\w$]/); var phpConfig = { name: "clike", diff --git a/static/js/lib/codemirror-4.4/mode/php/test.js b/static/js/lib/codemirror-4.5/mode/php/test.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/php/test.js rename to static/js/lib/codemirror-4.5/mode/php/test.js diff --git a/static/js/lib/codemirror-4.4/mode/pig/index.html b/static/js/lib/codemirror-4.5/mode/pig/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/pig/index.html rename to static/js/lib/codemirror-4.5/mode/pig/index.html diff --git a/static/js/lib/codemirror-4.4/mode/pig/pig.js b/static/js/lib/codemirror-4.5/mode/pig/pig.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/pig/pig.js rename to static/js/lib/codemirror-4.5/mode/pig/pig.js diff --git a/static/js/lib/codemirror-4.4/mode/properties/index.html b/static/js/lib/codemirror-4.5/mode/properties/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/properties/index.html rename to static/js/lib/codemirror-4.5/mode/properties/index.html diff --git a/static/js/lib/codemirror-4.4/mode/properties/properties.js b/static/js/lib/codemirror-4.5/mode/properties/properties.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/properties/properties.js rename to static/js/lib/codemirror-4.5/mode/properties/properties.js diff --git a/static/js/lib/codemirror-4.4/mode/puppet/index.html b/static/js/lib/codemirror-4.5/mode/puppet/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/puppet/index.html rename to static/js/lib/codemirror-4.5/mode/puppet/index.html diff --git a/static/js/lib/codemirror-4.4/mode/puppet/puppet.js b/static/js/lib/codemirror-4.5/mode/puppet/puppet.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/puppet/puppet.js rename to static/js/lib/codemirror-4.5/mode/puppet/puppet.js diff --git a/static/js/lib/codemirror-4.4/mode/python/index.html b/static/js/lib/codemirror-4.5/mode/python/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/python/index.html rename to static/js/lib/codemirror-4.5/mode/python/index.html diff --git a/static/js/lib/codemirror-4.4/mode/python/python.js b/static/js/lib/codemirror-4.5/mode/python/python.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/python/python.js rename to static/js/lib/codemirror-4.5/mode/python/python.js diff --git a/static/js/lib/codemirror-4.4/mode/q/index.html b/static/js/lib/codemirror-4.5/mode/q/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/q/index.html rename to static/js/lib/codemirror-4.5/mode/q/index.html diff --git a/static/js/lib/codemirror-4.4/mode/q/q.js b/static/js/lib/codemirror-4.5/mode/q/q.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/q/q.js rename to static/js/lib/codemirror-4.5/mode/q/q.js diff --git a/static/js/lib/codemirror-4.4/mode/r/index.html b/static/js/lib/codemirror-4.5/mode/r/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/r/index.html rename to static/js/lib/codemirror-4.5/mode/r/index.html diff --git a/static/js/lib/codemirror-4.4/mode/r/r.js b/static/js/lib/codemirror-4.5/mode/r/r.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/r/r.js rename to static/js/lib/codemirror-4.5/mode/r/r.js diff --git a/static/js/lib/codemirror-4.4/mode/rpm/changes/index.html b/static/js/lib/codemirror-4.5/mode/rpm/changes/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/rpm/changes/index.html rename to static/js/lib/codemirror-4.5/mode/rpm/changes/index.html diff --git a/static/js/lib/codemirror-4.4/mode/rpm/index.html b/static/js/lib/codemirror-4.5/mode/rpm/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/rpm/index.html rename to static/js/lib/codemirror-4.5/mode/rpm/index.html diff --git a/static/js/lib/codemirror-4.4/mode/rpm/rpm.js b/static/js/lib/codemirror-4.5/mode/rpm/rpm.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/rpm/rpm.js rename to static/js/lib/codemirror-4.5/mode/rpm/rpm.js diff --git a/static/js/lib/codemirror-4.4/mode/rst/index.html b/static/js/lib/codemirror-4.5/mode/rst/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/rst/index.html rename to static/js/lib/codemirror-4.5/mode/rst/index.html diff --git a/static/js/lib/codemirror-4.4/mode/rst/rst.js b/static/js/lib/codemirror-4.5/mode/rst/rst.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/rst/rst.js rename to static/js/lib/codemirror-4.5/mode/rst/rst.js diff --git a/static/js/lib/codemirror-4.4/mode/ruby/index.html b/static/js/lib/codemirror-4.5/mode/ruby/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/ruby/index.html rename to static/js/lib/codemirror-4.5/mode/ruby/index.html diff --git a/static/js/lib/codemirror-4.4/mode/ruby/ruby.js b/static/js/lib/codemirror-4.5/mode/ruby/ruby.js similarity index 92% rename from static/js/lib/codemirror-4.4/mode/ruby/ruby.js rename to static/js/lib/codemirror-4.5/mode/ruby/ruby.js index e7de7b5..6c9977b 100644 --- a/static/js/lib/codemirror-4.4/mode/ruby/ruby.js +++ b/static/js/lib/codemirror-4.5/mode/ruby/ruby.js @@ -141,7 +141,8 @@ CodeMirror.defineMode("ruby", function(config) { } else if (ch == "-" && stream.eat(">")) { return "arrow"; } else if (/[=+\-\/*:\.^%<>~|]/.test(ch)) { - stream.eatWhile(/[=+\-\/*:\.^%<>~|]/); + var more = stream.eatWhile(/[=+\-\/*:\.^%<>~|]/); + if (ch == "." && !more) curPunc = "."; return "operator"; } else { return null; @@ -232,20 +233,25 @@ CodeMirror.defineMode("ruby", function(config) { token: function(stream, state) { if (stream.sol()) state.indented = stream.indentation(); var style = state.tokenize[state.tokenize.length-1](stream, state), kwtype; + var thisTok = curPunc; if (style == "ident") { var word = stream.current(); - style = keywords.propertyIsEnumerable(stream.current()) ? "keyword" + style = state.lastTok == "." ? "property" + : keywords.propertyIsEnumerable(stream.current()) ? "keyword" : /^[A-Z]/.test(word) ? "tag" : (state.lastTok == "def" || state.lastTok == "class" || state.varList) ? "def" : "variable"; - if (indentWords.propertyIsEnumerable(word)) kwtype = "indent"; - else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent"; - else if ((word == "if" || word == "unless") && stream.column() == stream.indentation()) - kwtype = "indent"; - else if (word == "do" && state.context.indented < state.indented) - kwtype = "indent"; + if (style == "keyword") { + thisTok = word; + if (indentWords.propertyIsEnumerable(word)) kwtype = "indent"; + else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent"; + else if ((word == "if" || word == "unless") && stream.column() == stream.indentation()) + kwtype = "indent"; + else if (word == "do" && state.context.indented < state.indented) + kwtype = "indent"; + } } - if (curPunc || (style && style != "comment")) state.lastTok = word || curPunc || style; + if (curPunc || (style && style != "comment")) state.lastTok = thisTok; if (curPunc == "|") state.varList = !state.varList; if (kwtype == "indent" || /[\(\[\{]/.test(curPunc)) diff --git a/static/js/lib/codemirror-4.4/mode/ruby/test.js b/static/js/lib/codemirror-4.5/mode/ruby/test.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/ruby/test.js rename to static/js/lib/codemirror-4.5/mode/ruby/test.js diff --git a/static/js/lib/codemirror-4.4/mode/rust/index.html b/static/js/lib/codemirror-4.5/mode/rust/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/rust/index.html rename to static/js/lib/codemirror-4.5/mode/rust/index.html diff --git a/static/js/lib/codemirror-4.4/mode/rust/rust.js b/static/js/lib/codemirror-4.5/mode/rust/rust.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/rust/rust.js rename to static/js/lib/codemirror-4.5/mode/rust/rust.js diff --git a/static/js/lib/codemirror-4.4/mode/sass/index.html b/static/js/lib/codemirror-4.5/mode/sass/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/sass/index.html rename to static/js/lib/codemirror-4.5/mode/sass/index.html diff --git a/static/js/lib/codemirror-4.4/mode/sass/sass.js b/static/js/lib/codemirror-4.5/mode/sass/sass.js similarity index 64% rename from static/js/lib/codemirror-4.4/mode/sass/sass.js rename to static/js/lib/codemirror-4.5/mode/sass/sass.js index 2ff5003..68df323 100644 --- a/static/js/lib/codemirror-4.4/mode/sass/sass.js +++ b/static/js/lib/codemirror-4.5/mode/sass/sass.js @@ -12,9 +12,9 @@ "use strict"; CodeMirror.defineMode("sass", function(config) { - var tokenRegexp = function(words){ + function tokenRegexp(words) { return new RegExp("^" + words.join("|")); - }; + } var keywords = ["true", "false", "null", "auto"]; var keywordsRegexp = new RegExp("^" + keywords.join("|")); @@ -24,246 +24,233 @@ CodeMirror.defineMode("sass", function(config) { var pseudoElementsRegexp = /^::?[\w\-]+/; - var urlTokens = function(stream, state){ + function urlTokens(stream, state) { var ch = stream.peek(); - if (ch === ")"){ + if (ch === ")") { stream.next(); state.tokenizer = tokenBase; return "operator"; - }else if (ch === "("){ + } else if (ch === "(") { stream.next(); stream.eatSpace(); return "operator"; - }else if (ch === "'" || ch === '"'){ + } else if (ch === "'" || ch === '"') { state.tokenizer = buildStringTokenizer(stream.next()); return "string"; - }else{ + } else { state.tokenizer = buildStringTokenizer(")", false); return "string"; } - }; - var multilineComment = function(stream, state) { - if (stream.skipTo("*/")){ - stream.next(); - stream.next(); - state.tokenizer = tokenBase; - }else { - stream.next(); - } + } + function comment(indentation, multiLine) { + return function(stream, state) { + if (stream.sol() && stream.indentation() <= indentation) { + state.tokenizer = tokenBase; + return tokenBase(stream, state); + } - return "comment"; - }; + if (multiLine && stream.skipTo("*/")) { + stream.next(); + stream.next(); + state.tokenizer = tokenBase; + } else { + stream.next(); + } - var buildStringTokenizer = function(quote, greedy){ - if(greedy == null){ greedy = true; } + return "comment"; + }; + } - function stringTokenizer(stream, state){ + function buildStringTokenizer(quote, greedy) { + if(greedy == null) { greedy = true; } + + function stringTokenizer(stream, state) { var nextChar = stream.next(); var peekChar = stream.peek(); var previousChar = stream.string.charAt(stream.pos-2); var endingString = ((nextChar !== "\\" && peekChar === quote) || (nextChar === quote && previousChar !== "\\")); - /* - console.log("previousChar: " + previousChar); - console.log("nextChar: " + nextChar); - console.log("peekChar: " + peekChar); - console.log("ending: " + endingString); - */ - - if (endingString){ + if (endingString) { if (nextChar !== quote && greedy) { stream.next(); } state.tokenizer = tokenBase; return "string"; - }else if (nextChar === "#" && peekChar === "{"){ + } else if (nextChar === "#" && peekChar === "{") { state.tokenizer = buildInterpolationTokenizer(stringTokenizer); stream.next(); return "operator"; - }else { + } else { return "string"; } } return stringTokenizer; - }; + } - var buildInterpolationTokenizer = function(currentTokenizer){ - return function(stream, state){ - if (stream.peek() === "}"){ + function buildInterpolationTokenizer(currentTokenizer) { + return function(stream, state) { + if (stream.peek() === "}") { stream.next(); state.tokenizer = currentTokenizer; return "operator"; - }else{ + } else { return tokenBase(stream, state); } }; - }; + } - var indent = function(state){ - if (state.indentCount == 0){ + function indent(state) { + if (state.indentCount == 0) { state.indentCount++; var lastScopeOffset = state.scopes[0].offset; var currentOffset = lastScopeOffset + config.indentUnit; state.scopes.unshift({ offset:currentOffset }); } - }; + } - var dedent = function(state){ - if (state.scopes.length == 1) { return; } + function dedent(state) { + if (state.scopes.length == 1) return; state.scopes.shift(); - }; + } - var tokenBase = function(stream, state) { + function tokenBase(stream, state) { var ch = stream.peek(); - // Single line Comment - if (stream.match('//')) { - stream.skipToEnd(); - return "comment"; + // Comment + if (stream.match("/*")) { + state.tokenizer = comment(stream.indentation(), true); + return state.tokenizer(stream, state); } - - // Multiline Comment - if (stream.match('/*')){ - state.tokenizer = multilineComment; + if (stream.match("//")) { + state.tokenizer = comment(stream.indentation(), false); return state.tokenizer(stream, state); } // Interpolation - if (stream.match('#{')){ - state.tokenizer = buildInterpolationTokenizer(tokenBase); + if (stream.match("#{")) { + state.tokenizer = buildInterpolationTokenizer(tokenBase); return "operator"; } - if (ch === "."){ + if (ch === ".") { stream.next(); // Match class selectors - if (stream.match(/^[\w-]+/)){ + if (stream.match(/^[\w-]+/)) { indent(state); return "atom"; - }else if (stream.peek() === "#"){ + } else if (stream.peek() === "#") { indent(state); return "atom"; - }else{ + } else { return "operator"; } } - if (ch === "#"){ + if (ch === "#") { stream.next(); // Hex numbers - if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){ + if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)) return "number"; - } // ID selectors - if (stream.match(/^[\w-]+/)){ + if (stream.match(/^[\w-]+/)) { indent(state); return "atom"; } - if (stream.peek() === "#"){ + if (stream.peek() === "#") { indent(state); return "atom"; } } // Numbers - if (stream.match(/^-?[0-9\.]+/)){ + if (stream.match(/^-?[0-9\.]+/)) return "number"; - } // Units - if (stream.match(/^(px|em|in)\b/)){ + if (stream.match(/^(px|em|in)\b/)) return "unit"; - } - if (stream.match(keywordsRegexp)){ + if (stream.match(keywordsRegexp)) return "keyword"; - } - if (stream.match(/^url/) && stream.peek() === "("){ + if (stream.match(/^url/) && stream.peek() === "(") { state.tokenizer = urlTokens; return "atom"; } // Variables - if (ch === "$"){ + if (ch === "$") { stream.next(); stream.eatWhile(/[\w-]/); - if (stream.peek() === ":"){ + if (stream.peek() === ":") { stream.next(); return "variable-2"; - }else{ + } else { return "variable-3"; } } - if (ch === "!"){ + if (ch === "!") { stream.next(); - - if (stream.match(/^[\w]+/)){ - return "keyword"; - } - - return "operator"; + return stream.match(/^[\w]+/) ? "keyword": "operator"; } - if (ch === "="){ + if (ch === "=") { stream.next(); // Match shortcut mixin definition - if (stream.match(/^[\w-]+/)){ + if (stream.match(/^[\w-]+/)) { indent(state); return "meta"; - }else { + } else { return "operator"; } } - if (ch === "+"){ + if (ch === "+") { stream.next(); // Match shortcut mixin definition - if (stream.match(/^[\w-]+/)){ + if (stream.match(/^[\w-]+/)) return "variable-3"; - }else { + else return "operator"; - } } // Indent Directives - if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)){ + if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) { indent(state); return "meta"; } // Other Directives - if (ch === "@"){ + if (ch === "@") { stream.next(); stream.eatWhile(/[\w-]/); return "meta"; } // Strings - if (ch === '"' || ch === "'"){ + if (ch === '"' || ch === "'") { stream.next(); state.tokenizer = buildStringTokenizer(ch); return "string"; } // Pseudo element selectors - if (ch == ':' && stream.match(pseudoElementsRegexp)){ + if (ch == ":" && stream.match(pseudoElementsRegexp)) return "keyword"; - } // atoms - if (stream.eatWhile(/[\w-&]/)){ + if (stream.eatWhile(/[\w-&]/)) { // matches a property definition if (stream.peek() === ":" && !stream.match(pseudoElementsRegexp, false)) return "property"; @@ -271,43 +258,37 @@ CodeMirror.defineMode("sass", function(config) { return "atom"; } - if (stream.match(opRegexp)){ + if (stream.match(opRegexp)) return "operator"; - } // If we haven't returned by now, we move 1 character // and return an error stream.next(); return null; - }; + } - var tokenLexer = function(stream, state) { - if (stream.sol()){ - state.indentCount = 0; - } + function tokenLexer(stream, state) { + if (stream.sol()) state.indentCount = 0; var style = state.tokenizer(stream, state); var current = stream.current(); - if (current === "@return"){ + if (current === "@return") dedent(state); - } - if (style === "atom"){ + if (style === "atom") indent(state); - } - if (style !== null){ + if (style !== null) { var startOfToken = stream.pos - current.length; var withCurrentIndent = startOfToken + (config.indentUnit * state.indentCount); var newScopes = []; - for (var i = 0; i < state.scopes.length; i++){ + for (var i = 0; i < state.scopes.length; i++) { var scope = state.scopes[i]; - if (scope.offset <= withCurrentIndent){ + if (scope.offset <= withCurrentIndent) newScopes.push(scope); - } } state.scopes = newScopes; @@ -315,13 +296,13 @@ CodeMirror.defineMode("sass", function(config) { return style; - }; + } return { startState: function() { return { tokenizer: tokenBase, - scopes: [{offset: 0, type: 'sass'}], + scopes: [{offset: 0, type: "sass"}], definedVars: [], definedMixins: [] }; diff --git a/static/js/lib/codemirror-4.4/mode/scheme/index.html b/static/js/lib/codemirror-4.5/mode/scheme/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/scheme/index.html rename to static/js/lib/codemirror-4.5/mode/scheme/index.html diff --git a/static/js/lib/codemirror-4.4/mode/scheme/scheme.js b/static/js/lib/codemirror-4.5/mode/scheme/scheme.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/scheme/scheme.js rename to static/js/lib/codemirror-4.5/mode/scheme/scheme.js diff --git a/static/js/lib/codemirror-4.4/mode/shell/index.html b/static/js/lib/codemirror-4.5/mode/shell/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/shell/index.html rename to static/js/lib/codemirror-4.5/mode/shell/index.html diff --git a/static/js/lib/codemirror-4.4/mode/shell/shell.js b/static/js/lib/codemirror-4.5/mode/shell/shell.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/shell/shell.js rename to static/js/lib/codemirror-4.5/mode/shell/shell.js diff --git a/static/js/lib/codemirror-4.4/mode/shell/test.js b/static/js/lib/codemirror-4.5/mode/shell/test.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/shell/test.js rename to static/js/lib/codemirror-4.5/mode/shell/test.js diff --git a/static/js/lib/codemirror-4.4/mode/sieve/index.html b/static/js/lib/codemirror-4.5/mode/sieve/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/sieve/index.html rename to static/js/lib/codemirror-4.5/mode/sieve/index.html diff --git a/static/js/lib/codemirror-4.4/mode/sieve/sieve.js b/static/js/lib/codemirror-4.5/mode/sieve/sieve.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/sieve/sieve.js rename to static/js/lib/codemirror-4.5/mode/sieve/sieve.js diff --git a/static/js/lib/codemirror-4.5/mode/slim/index.html b/static/js/lib/codemirror-4.5/mode/slim/index.html new file mode 100644 index 0000000..1a3b6ac --- /dev/null +++ b/static/js/lib/codemirror-4.5/mode/slim/index.html @@ -0,0 +1,96 @@ + + +CodeMirror: SLIM mode + + + + + + + + + + + + + + + + + + + + +
    +

    SLIM mode

    +
    + + +

    MIME types defined: application/x-slim.

    + +

    + Parsing/Highlighting Tests: + normal, + verbose. +

    +
    diff --git a/static/js/lib/codemirror-4.5/mode/slim/slim.js b/static/js/lib/codemirror-4.5/mode/slim/slim.js new file mode 100644 index 0000000..164464d --- /dev/null +++ b/static/js/lib/codemirror-4.5/mode/slim/slim.js @@ -0,0 +1,575 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// Slim Highlighting for CodeMirror copyright (c) HicknHack Software Gmbh + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../ruby/ruby")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../ruby/ruby"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + + CodeMirror.defineMode("slim", function(config) { + var htmlMode = CodeMirror.getMode(config, {name: "htmlmixed"}); + var rubyMode = CodeMirror.getMode(config, "ruby"); + var modes = { html: htmlMode, ruby: rubyMode }; + var embedded = { + ruby: "ruby", + javascript: "javascript", + css: "text/css", + sass: "text/x-sass", + scss: "text/x-scss", + less: "text/x-less", + styl: "text/x-styl", // no highlighting so far + coffee: "coffeescript", + asciidoc: "text/x-asciidoc", + markdown: "text/x-markdown", + textile: "text/x-textile", // no highlighting so far + creole: "text/x-creole", // no highlighting so far + wiki: "text/x-wiki", // no highlighting so far + mediawiki: "text/x-mediawiki", // no highlighting so far + rdoc: "text/x-rdoc", // no highlighting so far + builder: "text/x-builder", // no highlighting so far + nokogiri: "text/x-nokogiri", // no highlighting so far + erb: "application/x-erb" + }; + var embeddedRegexp = function(map){ + var arr = []; + for(var key in map) arr.push(key); + return new RegExp("^("+arr.join('|')+"):"); + }(embedded); + + var styleMap = { + "commentLine": "comment", + "slimSwitch": "operator special", + "slimTag": "tag", + "slimId": "attribute def", + "slimClass": "attribute qualifier", + "slimAttribute": "attribute", + "slimSubmode": "keyword special", + "closeAttributeTag": null, + "slimDoctype": null, + "lineContinuation": null + }; + var closing = { + "{": "}", + "[": "]", + "(": ")" + }; + + var nameStartChar = "_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD"; + var nameChar = nameStartChar + "\\-0-9\xB7\u0300-\u036F\u203F-\u2040"; + var nameRegexp = new RegExp("^[:"+nameStartChar+"](?::["+nameChar+"]|["+nameChar+"]*)"); + var attributeNameRegexp = new RegExp("^[:"+nameStartChar+"][:\\."+nameChar+"]*(?=\\s*=)"); + var wrappedAttributeNameRegexp = new RegExp("^[:"+nameStartChar+"][:\\."+nameChar+"]*"); + var classNameRegexp = /^\.-?[_a-zA-Z]+[\w\-]*/; + var classIdRegexp = /^#[_a-zA-Z]+[\w\-]*/; + + function backup(pos, tokenize, style) { + var restore = function(stream, state) { + state.tokenize = tokenize; + if (stream.pos < pos) { + stream.pos = pos; + return style; + } + return state.tokenize(stream, state); + }; + return function(stream, state) { + state.tokenize = restore; + return tokenize(stream, state); + }; + } + + function maybeBackup(stream, state, pat, offset, style) { + var cur = stream.current(); + var idx = cur.search(pat); + if (idx > -1) { + state.tokenize = backup(stream.pos, state.tokenize, style); + stream.backUp(cur.length - idx - offset); + } + return style; + } + + function continueLine(state, column) { + state.stack = { + parent: state.stack, + style: "continuation", + indented: column, + tokenize: state.line + }; + state.line = state.tokenize; + } + function finishContinue(state) { + if (state.line == state.tokenize) { + state.line = state.stack.tokenize; + state.stack = state.stack.parent; + } + } + + function lineContinuable(column, tokenize) { + return function(stream, state) { + finishContinue(state); + if (stream.match(/^\\$/)) { + continueLine(state, column); + return "lineContinuation"; + } + var style = tokenize(stream, state); + if (stream.eol() && stream.current().match(/(?:^|[^\\])(?:\\\\)*\\$/)) { + stream.backUp(1); + } + return style; + }; + } + function commaContinuable(column, tokenize) { + return function(stream, state) { + finishContinue(state); + var style = tokenize(stream, state); + if (stream.eol() && stream.current().match(/,$/)) { + continueLine(state, column); + } + return style; + }; + } + + function rubyInQuote(endQuote, tokenize) { + // TODO: add multi line support + return function(stream, state) { + var ch = stream.peek(); + if (ch == endQuote && state.rubyState.tokenize.length == 1) { + // step out of ruby context as it seems to complete processing all the braces + stream.next(); + state.tokenize = tokenize; + return "closeAttributeTag"; + } else { + return ruby(stream, state); + } + }; + } + function startRubySplat(tokenize) { + var rubyState; + var runSplat = function(stream, state) { + if (state.rubyState.tokenize.length == 1 && !state.rubyState.context.prev) { + stream.backUp(1); + if (stream.eatSpace()) { + state.rubyState = rubyState; + state.tokenize = tokenize; + return tokenize(stream, state); + } + stream.next(); + } + return ruby(stream, state); + }; + return function(stream, state) { + rubyState = state.rubyState; + state.rubyState = rubyMode.startState(); + state.tokenize = runSplat; + return ruby(stream, state); + }; + } + + function ruby(stream, state) { + return rubyMode.token(stream, state.rubyState); + } + + function htmlLine(stream, state) { + if (stream.match(/^\\$/)) { + return "lineContinuation"; + } + return html(stream, state); + } + function html(stream, state) { + if (stream.match(/^#\{/)) { + state.tokenize = rubyInQuote("}", state.tokenize); + return null; + } + return maybeBackup(stream, state, /[^\\]#\{/, 1, htmlMode.token(stream, state.htmlState)); + } + + function startHtmlLine(lastTokenize) { + return function(stream, state) { + var style = htmlLine(stream, state); + if (stream.eol()) state.tokenize = lastTokenize; + return style; + }; + } + + function startHtmlMode(stream, state, offset) { + state.stack = { + parent: state.stack, + style: "html", + indented: stream.column() + offset, // pipe + space + tokenize: state.line + }; + state.line = state.tokenize = html; + return null; + } + + function comment(stream, state) { + stream.skipToEnd(); + return state.stack.style; + } + + function commentMode(stream, state) { + state.stack = { + parent: state.stack, + style: "comment", + indented: state.indented + 1, + tokenize: state.line + }; + state.line = comment; + return comment(stream, state); + } + + function attributeWrapper(stream, state) { + if (stream.eat(state.stack.endQuote)) { + state.line = state.stack.line; + state.tokenize = state.stack.tokenize; + state.stack = state.stack.parent; + return null; + } + if (stream.match(wrappedAttributeNameRegexp)) { + state.tokenize = attributeWrapperAssign; + return "slimAttribute"; + } + stream.next(); + return null; + } + function attributeWrapperAssign(stream, state) { + if (stream.match(/^==?/)) { + state.tokenize = attributeWrapperValue; + return null; + } + return attributeWrapper(stream, state); + } + function attributeWrapperValue(stream, state) { + var ch = stream.peek(); + if (ch == '"' || ch == "\'") { + state.tokenize = readQuoted(ch, "string", true, false, attributeWrapper); + stream.next(); + return state.tokenize(stream, state); + } + if (ch == '[') { + return startRubySplat(attributeWrapper)(stream, state); + } + if (stream.match(/^(true|false|nil)\b/)) { + state.tokenize = attributeWrapper; + return "keyword"; + } + return startRubySplat(attributeWrapper)(stream, state); + } + + function startAttributeWrapperMode(state, endQuote, tokenize) { + state.stack = { + parent: state.stack, + style: "wrapper", + indented: state.indented + 1, + tokenize: tokenize, + line: state.line, + endQuote: endQuote + }; + state.line = state.tokenize = attributeWrapper; + return null; + } + + function sub(stream, state) { + if (stream.match(/^#\{/)) { + state.tokenize = rubyInQuote("}", state.tokenize); + return null; + } + var subStream = new CodeMirror.StringStream(stream.string.slice(state.stack.indented), stream.tabSize); + subStream.pos = stream.pos - state.stack.indented; + subStream.start = stream.start - state.stack.indented; + subStream.lastColumnPos = stream.lastColumnPos - state.stack.indented; + subStream.lastColumnValue = stream.lastColumnValue - state.stack.indented; + var style = state.subMode.token(subStream, state.subState); + stream.pos = subStream.pos + state.stack.indented; + return style; + } + function firstSub(stream, state) { + state.stack.indented = stream.column(); + state.line = state.tokenize = sub; + return state.tokenize(stream, state); + } + + function createMode(mode) { + var query = embedded[mode]; + var spec = CodeMirror.mimeModes[query]; + if (spec) { + return CodeMirror.getMode(config, spec); + } + var factory = CodeMirror.modes[query]; + if (factory) { + return factory(config, {name: query}); + } + return CodeMirror.getMode(config, "null"); + } + + function getMode(mode) { + if (!modes.hasOwnProperty(mode)) { + return modes[mode] = createMode(mode); + } + return modes[mode]; + } + + function startSubMode(mode, state) { + var subMode = getMode(mode); + var subState = subMode.startState && subMode.startState(); + + state.subMode = subMode; + state.subState = subState; + + state.stack = { + parent: state.stack, + style: "sub", + indented: state.indented + 1, + tokenize: state.line + }; + state.line = state.tokenize = firstSub; + return "slimSubmode"; + } + + function doctypeLine(stream, _state) { + stream.skipToEnd(); + return "slimDoctype"; + } + + function startLine(stream, state) { + var ch = stream.peek(); + if (ch == '<') { + return (state.tokenize = startHtmlLine(state.tokenize))(stream, state); + } + if (stream.match(/^[|']/)) { + return startHtmlMode(stream, state, 1); + } + if (stream.match(/^\/(!|\[\w+])?/)) { + return commentMode(stream, state); + } + if (stream.match(/^(-|==?[<>]?)/)) { + state.tokenize = lineContinuable(stream.column(), commaContinuable(stream.column(), ruby)); + return "slimSwitch"; + } + if (stream.match(/^doctype\b/)) { + state.tokenize = doctypeLine; + return "keyword"; + } + + var m = stream.match(embeddedRegexp); + if (m) { + return startSubMode(m[1], state); + } + + return slimTag(stream, state); + } + + function slim(stream, state) { + if (state.startOfLine) { + return startLine(stream, state); + } + return slimTag(stream, state); + } + + function slimTag(stream, state) { + if (stream.eat('*')) { + state.tokenize = startRubySplat(slimTagExtras); + return null; + } + if (stream.match(nameRegexp)) { + state.tokenize = slimTagExtras; + return "slimTag"; + } + return slimClass(stream, state); + } + function slimTagExtras(stream, state) { + if (stream.match(/^(<>?|> state.indented && state.last != "slimSubmode") { + state.line = state.tokenize = state.stack.tokenize; + state.stack = state.stack.parent; + state.subMode = null; + state.subState = null; + } + } + if (stream.eatSpace()) return null; + var style = state.tokenize(stream, state); + state.startOfLine = false; + if (style) state.last = style; + return styleMap.hasOwnProperty(style) ? styleMap[style] : style; + }, + + blankLine: function(state) { + if (state.subMode && state.subMode.blankLine) { + return state.subMode.blankLine(state.subState); + } + }, + + innerMode: function(state) { + if (state.subMode) return {state: state.subState, mode: state.subMode}; + return {state: state, mode: mode}; + } + + //indent: function(state) { + // return state.indented; + //} + }; + return mode; + }, "htmlmixed", "ruby"); + + CodeMirror.defineMIME("text/x-slim", "slim"); + CodeMirror.defineMIME("application/x-slim", "slim"); +}); diff --git a/static/js/lib/codemirror-4.5/mode/slim/test.js b/static/js/lib/codemirror-4.5/mode/slim/test.js new file mode 100644 index 0000000..be4ddac --- /dev/null +++ b/static/js/lib/codemirror-4.5/mode/slim/test.js @@ -0,0 +1,96 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// Slim Highlighting for CodeMirror copyright (c) HicknHack Software Gmbh + +(function() { + var mode = CodeMirror.getMode({tabSize: 4, indentUnit: 2}, "slim"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + // Requires at least one media query + MT("elementName", + "[tag h1] Hey There"); + + MT("oneElementPerLine", + "[tag h1] Hey There .h2"); + + MT("idShortcut", + "[attribute&def #test] Hey There"); + + MT("tagWithIdShortcuts", + "[tag h1][attribute&def #test] Hey There"); + + MT("classShortcut", + "[attribute&qualifier .hello] Hey There"); + + MT("tagWithIdAndClassShortcuts", + "[tag h1][attribute&def #test][attribute&qualifier .hello] Hey There"); + + MT("docType", + "[keyword doctype] xml"); + + MT("comment", + "[comment / Hello WORLD]"); + + MT("notComment", + "[tag h1] This is not a / comment "); + + MT("attributes", + "[tag a]([attribute title]=[string \"test\"]) [attribute href]=[string \"link\"]}"); + + MT("multiLineAttributes", + "[tag a]([attribute title]=[string \"test\"]", + " ) [attribute href]=[string \"link\"]}"); + + MT("htmlCode", + "[tag&bracket <][tag h1][tag&bracket >]Title[tag&bracket ]"); + + MT("rubyBlock", + "[operator&special =][variable-2 @item]"); + + MT("selectorRubyBlock", + "[tag a][attribute&qualifier .test][operator&special =] [variable-2 @item]"); + + MT("nestedRubyBlock", + "[tag a]", + " [operator&special =][variable puts] [string \"test\"]"); + + MT("multilinePlaintext", + "[tag p]", + " | Hello,", + " World"); + + MT("multilineRuby", + "[tag p]", + " [comment /# this is a comment]", + " [comment and this is a comment too]", + " | Date/Time", + " [operator&special -] [variable now] [operator =] [tag DateTime][operator .][property now]", + " [tag strong][operator&special =] [variable now]", + " [operator&special -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][property parse]([string \"December 31, 2006\"])", + " [operator&special =][string \"Happy\"]", + " [operator&special =][string \"Belated\"]", + " [operator&special =][string \"Birthday\"]"); + + MT("multilineComment", + "[comment /]", + " [comment Multiline]", + " [comment Comment]"); + + MT("hamlAfterRubyTag", + "[attribute&qualifier .block]", + " [tag strong][operator&special =] [variable now]", + " [attribute&qualifier .test]", + " [operator&special =][variable now]", + " [attribute&qualifier .right]"); + + MT("stretchedRuby", + "[operator&special =] [variable puts] [string \"Hello\"],", + " [string \"World\"]"); + + MT("interpolationInHashAttribute", + "[tag div]{[attribute id] = [string \"]#{[variable test]}[string _]#{[variable ting]}[string \"]} test"); + + MT("interpolationInHTMLAttribute", + "[tag div]([attribute title]=[string \"]#{[variable test]}[string _]#{[variable ting]()}[string \"]) Test"); +})(); diff --git a/static/js/lib/codemirror-4.4/mode/smalltalk/index.html b/static/js/lib/codemirror-4.5/mode/smalltalk/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/smalltalk/index.html rename to static/js/lib/codemirror-4.5/mode/smalltalk/index.html diff --git a/static/js/lib/codemirror-4.4/mode/smalltalk/smalltalk.js b/static/js/lib/codemirror-4.5/mode/smalltalk/smalltalk.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/smalltalk/smalltalk.js rename to static/js/lib/codemirror-4.5/mode/smalltalk/smalltalk.js diff --git a/static/js/lib/codemirror-4.4/mode/smarty/index.html b/static/js/lib/codemirror-4.5/mode/smarty/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/smarty/index.html rename to static/js/lib/codemirror-4.5/mode/smarty/index.html diff --git a/static/js/lib/codemirror-4.4/mode/smarty/smarty.js b/static/js/lib/codemirror-4.5/mode/smarty/smarty.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/smarty/smarty.js rename to static/js/lib/codemirror-4.5/mode/smarty/smarty.js diff --git a/static/js/lib/codemirror-4.4/mode/smartymixed/index.html b/static/js/lib/codemirror-4.5/mode/smartymixed/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/smartymixed/index.html rename to static/js/lib/codemirror-4.5/mode/smartymixed/index.html diff --git a/static/js/lib/codemirror-4.4/mode/smartymixed/smartymixed.js b/static/js/lib/codemirror-4.5/mode/smartymixed/smartymixed.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/smartymixed/smartymixed.js rename to static/js/lib/codemirror-4.5/mode/smartymixed/smartymixed.js diff --git a/static/js/lib/codemirror-4.4/mode/solr/index.html b/static/js/lib/codemirror-4.5/mode/solr/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/solr/index.html rename to static/js/lib/codemirror-4.5/mode/solr/index.html diff --git a/static/js/lib/codemirror-4.4/mode/solr/solr.js b/static/js/lib/codemirror-4.5/mode/solr/solr.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/solr/solr.js rename to static/js/lib/codemirror-4.5/mode/solr/solr.js diff --git a/static/js/lib/codemirror-4.4/mode/sparql/index.html b/static/js/lib/codemirror-4.5/mode/sparql/index.html similarity index 100% rename from static/js/lib/codemirror-4.4/mode/sparql/index.html rename to static/js/lib/codemirror-4.5/mode/sparql/index.html diff --git a/static/js/lib/codemirror-4.4/mode/sparql/sparql.js b/static/js/lib/codemirror-4.5/mode/sparql/sparql.js similarity index 100% rename from static/js/lib/codemirror-4.4/mode/sparql/sparql.js rename to static/js/lib/codemirror-4.5/mode/sparql/sparql.js diff --git a/static/js/lib/codemirror-4.4/mode/sql/index.html b/static/js/lib/codemirror-4.5/mode/sql/index.html similarity index 86% rename from static/js/lib/codemirror-4.4/mode/sql/index.html rename to static/js/lib/codemirror-4.5/mode/sql/index.html index 79a2e74..7dd5f30 100644 --- a/static/js/lib/codemirror-4.4/mode/sql/index.html +++ b/static/js/lib/codemirror-4.5/mode/sql/index.html @@ -7,6 +7,9 @@ + + +