From e11c32768459bced344024d9a3fb472e4e7bea54 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 20 Feb 2015 17:48:43 +0100 Subject: [PATCH 01/57] Bump version number post-5.0 --- bower.json | 2 +- doc/manual.html | 2 +- lib/codemirror.js | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index c59f2d9d27..be3cdca9f5 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version":"5.0.0", + "version":"5.0.1", "main": ["lib/codemirror.js", "lib/codemirror.css"], "ignore": [ "**/.*", diff --git a/doc/manual.html b/doc/manual.html index 74a74e29ed..ba537d959b 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -63,7 +63,7 @@

User manual and reference guide - version 5.0.0 + version 5.0.1

CodeMirror is a code-editor component that can be embedded in diff --git a/lib/codemirror.js b/lib/codemirror.js index 53b35329fc..98a45c60ba 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -8639,7 +8639,7 @@ // THE END - CodeMirror.version = "5.0.0"; + CodeMirror.version = "5.0.1"; return CodeMirror; }); diff --git a/package.json b/package.json index b4a9b53fe6..3d99c1adb0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version":"5.0.0", + "version":"5.0.1", "main": "lib/codemirror.js", "description": "In-browser code editing made bearable", "licenses": [{"type": "MIT", From 2e591196dce9d51a70c921dfe79277b99a4d2bf8 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 20 Feb 2015 17:49:16 +0100 Subject: [PATCH 02/57] [release notes] Fix bad patches link --- doc/releases.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/releases.html b/doc/releases.html index 8b2b375253..49d5be43bc 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -36,7 +36,7 @@

  • New option inputStyle to switch between hidden textarea and contenteditable input.
  • The getInputField method is no longer guaranteed to return a textarea.
  • -
  • Full list of patches.
  • +
  • Full list of patches.
  • 20-02-2015: Version 4.13:

    From 318f32da231c264438473e3cebe0543293fe216b Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Sat, 21 Feb 2015 16:19:13 +0800 Subject: [PATCH 03/57] [sql-hint addon] Fix defaultTable for new tables format --- addon/hint/sql-hint.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index 5b0cc7696f..37937ca9a2 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -208,9 +208,17 @@ CodeMirror.registerHelper("hint", "sql", function(editor, options) { tables = (options && options.tables) || {}; var defaultTableName = options && options.defaultTable; - defaultTable = (defaultTableName && getItem(tables, defaultTableName)) || []; + defaultTable = defaultTableName && getItem(tables, defaultTableName); keywords = keywords || getKeywords(editor); + if (defaultTableName && !defaultTable) + defaultTable = findTableByAlias(defaultTableName, editor); + + defaultTable = defaultTable || []; + + if (Array.isArray(tables) && defaultTable.columns) + defaultTable = defaultTable.columns; + var cur = editor.getCursor(); var result = []; var token = editor.getTokenAt(cur), start, end, search; From ead08e070cfe2990ed972b7bb432c6e04cbfea16 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 23 Feb 2015 10:27:17 +0100 Subject: [PATCH 04/57] [sql-hint addon] Remove uses of Array.isArray We're still targeting ES3. --- addon/hint/sql-hint.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index 37937ca9a2..cba27a0b2c 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -52,12 +52,9 @@ function addMatches(result, search, wordlist, formatter) { for (var word in wordlist) { if (!wordlist.hasOwnProperty(word)) continue; - if (Array.isArray(wordlist)) { - word = wordlist[word]; - } - if (match(search, word)) { - result.push(formatter(word)); - } + if (wordlist.slice) word = wordlist[word]; + + if (match(search, word)) result.push(formatter(word)); } } @@ -120,7 +117,7 @@ table = findTableByAlias(table, editor); var columns = getItem(tables, table); - if (columns && Array.isArray(tables) && columns.columns) + if (columns && columns.columns) columns = columns.columns; if (columns) { @@ -216,7 +213,7 @@ defaultTable = defaultTable || []; - if (Array.isArray(tables) && defaultTable.columns) + if (defaultTable.columns) defaultTable = defaultTable.columns; var cur = editor.getCursor(); From b1360a32fa98b193055b42a593d21b26a07f8cdc Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 23 Feb 2015 10:55:46 +0100 Subject: [PATCH 05/57] [asciiarmor mode] Add Closes #3099 --- doc/compress.html | 1 + mode/asciiarmor/asciiarmor.js | 73 +++++++++++++++++++++++++++++++++++++++++++ mode/asciiarmor/index.html | 46 +++++++++++++++++++++++++++ mode/meta.js | 1 + 4 files changed, 121 insertions(+) create mode 100644 mode/asciiarmor/asciiarmor.js create mode 100644 mode/asciiarmor/index.html diff --git a/doc/compress.html b/doc/compress.html index a376c86d2d..b2b4d08754 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -103,6 +103,7 @@ + diff --git a/mode/asciiarmor/asciiarmor.js b/mode/asciiarmor/asciiarmor.js new file mode 100644 index 0000000000..d830903767 --- /dev/null +++ b/mode/asciiarmor/asciiarmor.js @@ -0,0 +1,73 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + function errorIfNotEmpty(stream) { + var nonWS = stream.match(/^\s*\S/); + stream.skipToEnd(); + return nonWS ? "error" : null; + } + + CodeMirror.defineMode("asciiarmor", function() { + return { + token: function(stream, state) { + var m; + if (state.state == "top") { + if (stream.sol() && (m = stream.match(/^-----BEGIN (.*)?-----\s*$/))) { + state.state = "headers"; + state.type = m[1]; + return "tag"; + } + return errorIfNotEmpty(stream); + } else if (state.state == "headers") { + if (stream.sol() && stream.match(/^\w+:/)) { + state.state = "header"; + return "atom"; + } else { + var result = errorIfNotEmpty(stream); + if (result) state.state = "body"; + return result; + } + } else if (state.state == "header") { + stream.skipToEnd(); + state.state = "headers"; + return "string"; + } else if (state.state == "body") { + if (stream.sol() && (m = stream.match(/^-----END (.*)?-----\s*$/))) { + if (m[1] != state.type) return "error"; + state.state = "end"; + return "tag"; + } else { + if (stream.eatWhile(/[A-Za-z0-9+\/=]/)) { + return null; + } else { + stream.next(); + return "error"; + } + } + } else if (state.state == "end") { + return errorIfNotEmpty(stream); + } + }, + blankLine: function(state) { + if (state.state == "headers") state.state = "body"; + }, + startState: function() { + return {state: "top", type: null}; + } + }; + }); + + CodeMirror.defineMIME("application/pgp", "asciiarmor"); + CodeMirror.defineMIME("application/pgp-keys", "asciiarmor"); + CodeMirror.defineMIME("application/pgp-signature", "asciiarmor"); +}); diff --git a/mode/asciiarmor/index.html b/mode/asciiarmor/index.html new file mode 100644 index 0000000000..8ba1b5c76c --- /dev/null +++ b/mode/asciiarmor/index.html @@ -0,0 +1,46 @@ + + +CodeMirror: ASCII Armor (PGP) mode + + + + + + + + + +
    +

    ASCII Armor (PGP) mode

    +
    + + + +

    MIME types +defined: application/pgp, application/pgp-keys, application/pgp-signature

    + +
    diff --git a/mode/meta.js b/mode/meta.js index e110288afc..914d2dc291 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -13,6 +13,7 @@ CodeMirror.modeInfo = [ {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]}, + {name: "PGP", mimes: ["application/pgp", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["pgp"]}, {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i}, {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]}, {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]}, From b1e087975c300f44615826d103916a1ea4ec4347 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 23 Feb 2015 11:02:46 +0100 Subject: [PATCH 06/57] [asciiarmor mode] Add to mode list --- mode/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/mode/index.html b/mode/index.html index 04167a5a54..b39cca479f 100644 --- a/mode/index.html +++ b/mode/index.html @@ -85,6 +85,7 @@
  • Pascal
  • PEG.js
  • Perl
  • +
  • PGP (ASCII armor)
  • PHP
  • Pig Latin
  • Properties files
  • From 35a96182ede54c935cca7231365fe180092e32e2 Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Sun, 22 Feb 2015 16:58:32 +0100 Subject: [PATCH 07/57] Fix scroll position jump on mousedown in Chrome --- lib/codemirror.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 98a45c60ba..0f7c8090e6 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -3517,10 +3517,11 @@ e_preventDefault(e2); if (!modifier) extendSelection(cm.doc, start); - display.input.focus(); - // Work around unexplainable focus problem in IE9 (#2127) - if (ie && ie_version == 9) + // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081) + if (webkit || ie && ie_version == 9) setTimeout(function() {document.body.focus(); display.input.focus();}, 20); + else + display.input.focus(); } }); // Let the drag handler handle this. From 28b25a4ca0a48f3385dbe6371c7d841b0a8c67f4 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 24 Feb 2015 14:24:52 +0100 Subject: [PATCH 08/57] [contenteditable input] Work around mobile firefox randomly resetting selection sometimes --- lib/codemirror.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 0f7c8090e6..e813755bb6 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -1491,6 +1491,7 @@ this.cm = cm; this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null; this.polling = new Delayed(); + this.gracePeriod = false; } ContentEditableInput.prototype = copyObj({ @@ -1625,10 +1626,21 @@ sel.removeAllRanges(); sel.addRange(rng); if (old && sel.anchorNode == null) sel.addRange(old); + else if (gecko) this.startGracePeriod(); } this.rememberSelection(); }, + startGracePeriod: function() { + var input = this; + clearTimeout(this.gracePeriod); + this.gracePeriod = setTimeout(function() { + input.gracePeriod = false; + if (input.selectionChanged()) + input.cm.operation(function() { input.cm.curOp.selectionChanged = true; }); + }, 20); + }, + showMultipleSelections: function(info) { removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors); removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection); @@ -1671,12 +1683,15 @@ this.polling.set(this.cm.options.pollInterval, poll); }, - pollSelection: function() { - if (this.composing) return; + selectionChanged: function() { + var sel = window.getSelection(); + return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || + sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset; + }, - var sel = window.getSelection(), cm = this.cm; - if (sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || - sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset) { + pollSelection: function() { + if (!this.composing && !this.gracePeriod && this.selectionChanged()) { + var sel = window.getSelection(), cm = this.cm; this.rememberSelection(); var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); var head = domToPos(cm, sel.focusNode, sel.focusOffset); From 6d115cdfb57ff4a53075c4c88a86c1de3046d7a2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 24 Feb 2015 15:03:26 +0100 Subject: [PATCH 09/57] [htmlembedded mode] Strip down to a simple addon/mode/multiplex wrapper At least that works. Closes #1788 --- mode/htmlembedded/htmlembedded.js | 94 ++++++++------------------------------- mode/htmlembedded/index.html | 1 + mode/index.html | 1 - 3 files changed, 19 insertions(+), 77 deletions(-) diff --git a/mode/htmlembedded/htmlembedded.js b/mode/htmlembedded/htmlembedded.js index e8f7ba803f..464dc57f83 100644 --- a/mode/htmlembedded/htmlembedded.js +++ b/mode/htmlembedded/htmlembedded.js @@ -3,84 +3,26 @@ (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed")); + mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), + require("../../addon/mode/multiplex")); else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror", "../htmlmixed/htmlmixed"], mod); + define(["../../lib/codemirror", "../htmlmixed/htmlmixed", + "../../addon/mode/multiplex"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { -"use strict"; - -CodeMirror.defineMode("htmlembedded", function(config, parserConfig) { - - //config settings - var scriptStartRegex = parserConfig.scriptStartRegex || /^<%/i, - scriptEndRegex = parserConfig.scriptEndRegex || /^%>/i; - - //inner modes - var scriptingMode, htmlMixedMode; - - //tokenizer when in html mode - function htmlDispatch(stream, state) { - if (stream.match(scriptStartRegex, false)) { - state.token=scriptingDispatch; - return scriptingMode.token(stream, state.scriptState); - } - else - return htmlMixedMode.token(stream, state.htmlState); - } - - //tokenizer when in scripting mode - function scriptingDispatch(stream, state) { - if (stream.match(scriptEndRegex, false)) { - state.token=htmlDispatch; - return htmlMixedMode.token(stream, state.htmlState); - } - else - return scriptingMode.token(stream, state.scriptState); - } - - - return { - startState: function() { - scriptingMode = scriptingMode || CodeMirror.getMode(config, parserConfig.scriptingModeSpec); - htmlMixedMode = htmlMixedMode || CodeMirror.getMode(config, "htmlmixed"); - return { - token : parserConfig.startOpen ? scriptingDispatch : htmlDispatch, - htmlState : CodeMirror.startState(htmlMixedMode), - scriptState : CodeMirror.startState(scriptingMode) - }; - }, - - token: function(stream, state) { - return state.token(stream, state); - }, - - indent: function(state, textAfter) { - if (state.token == htmlDispatch) - return htmlMixedMode.indent(state.htmlState, textAfter); - else if (scriptingMode.indent) - return scriptingMode.indent(state.scriptState, textAfter); - }, - - copyState: function(state) { - return { - token : state.token, - htmlState : CodeMirror.copyState(htmlMixedMode, state.htmlState), - scriptState : CodeMirror.copyState(scriptingMode, state.scriptState) - }; - }, - - innerMode: function(state) { - if (state.token == scriptingDispatch) return {state: state.scriptState, mode: scriptingMode}; - else return {state: state.htmlState, mode: htmlMixedMode}; - } - }; -}, "htmlmixed"); - -CodeMirror.defineMIME("application/x-ejs", { name: "htmlembedded", scriptingModeSpec:"javascript"}); -CodeMirror.defineMIME("application/x-aspx", { name: "htmlembedded", scriptingModeSpec:"text/x-csharp"}); -CodeMirror.defineMIME("application/x-jsp", { name: "htmlembedded", scriptingModeSpec:"text/x-java"}); -CodeMirror.defineMIME("application/x-erb", { name: "htmlembedded", scriptingModeSpec:"ruby"}); - + "use strict"; + + CodeMirror.defineMode("htmlembedded", function(config, parserConfig) { + return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), { + open: parserConfig.open || parserConfig.scriptStartRegex || "<%", + close: parserConfig.close || parserConfig.scriptEndRegex || "%>", + mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec) + }); + }, "htmlmixed"); + + CodeMirror.defineMIME("application/x-ejs", {name: "htmlembedded", scriptingModeSpec:"javascript"}); + CodeMirror.defineMIME("application/x-aspx", {name: "htmlembedded", scriptingModeSpec:"text/x-csharp"}); + CodeMirror.defineMIME("application/x-jsp", {name: "htmlembedded", scriptingModeSpec:"text/x-java"}); + CodeMirror.defineMIME("application/x-erb", {name: "htmlembedded", scriptingModeSpec:"ruby"}); }); diff --git a/mode/htmlembedded/index.html b/mode/htmlembedded/index.html index 93d01c4512..365ef8f366 100644 --- a/mode/htmlembedded/index.html +++ b/mode/htmlembedded/index.html @@ -10,6 +10,7 @@ +
    + +
    + +

    Version 4.x

    +

    20-02-2015: Version 4.13:

      @@ -1033,12 +1040,12 @@ parser. And, as usual, add workarounds for various newly discovered browser incompatibilities.

      -

      31-08-2009: Version 0.63:

      +

      31-08-2009: Version 0.63:

      Overhaul of paste-handling (less fragile), fixes for several serious IE8 issues (cursor jumping, end-of-document bugs) and a number of small problems.

      -

      30-05-2009: Version 0.62:

      +

      30-05-2009: Version 0.62:

      Introduces Python and Lua parsers. Add setParser (on-the-fly mode changing) and From 8dbb84f44d3f4cdecde25e910277ca1816f80a24 Mon Sep 17 00:00:00 2001 From: Vincent Woo Date: Fri, 13 Mar 2015 04:08:41 -0700 Subject: [PATCH 38/57] [sublime keymap] Add sublime-style smart backspace --- keymap/sublime.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/keymap/sublime.js b/keymap/sublime.js index 45936c3628..2b49f1ae35 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -409,6 +409,22 @@ map[cK + ctrl + "Backspace"] = "delLineLeft"; + cmds[map["Backspace"] = "smartBackspace"] = function(cm) { + if (cm.somethingSelected()) { + return CodeMirror.Pass; + } + + var tabSize = cm.getOption('tabSize'); + var cursor = cm.getCursor(); + var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor); + var column = CodeMirror.countColumn(toStartOfLine, null, tabSize); + + if (/^\s+$/.test(toStartOfLine) && column % tabSize == 0) { + return cm.indentSelection('subtract'); + } + return CodeMirror.Pass; + }; + cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) { cm.operation(function() { var ranges = cm.listSelections(); From 33e56fbd728ad0d0f60823f4c8ffad37520ac59e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 14 Mar 2015 11:03:34 +0100 Subject: [PATCH 39/57] [sublime keymap] Adjust backspace binding Issue #3127 --- keymap/sublime.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index 2b49f1ae35..cf18573605 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -410,19 +410,16 @@ map[cK + ctrl + "Backspace"] = "delLineLeft"; cmds[map["Backspace"] = "smartBackspace"] = function(cm) { - if (cm.somethingSelected()) { - return CodeMirror.Pass; - } + if (cm.somethingSelected()) return CodeMirror.Pass; - var tabSize = cm.getOption('tabSize'); var cursor = cm.getCursor(); var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor); - var column = CodeMirror.countColumn(toStartOfLine, null, tabSize); + var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize")); - if (/^\s+$/.test(toStartOfLine) && column % tabSize == 0) { - return cm.indentSelection('subtract'); - } - return CodeMirror.Pass; + if (!/\S/.test(toStartOfLine) && column % cm.getOption("indentUnit") == 0) + return cm.indentSelection("subtract"); + else + return CodeMirror.Pass; }; cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) { From 30a118ac43682b7783a1f9031e4edbb3d048bba5 Mon Sep 17 00:00:00 2001 From: darealshinji Date: Fri, 13 Mar 2015 09:01:51 +0100 Subject: [PATCH 40/57] [troff mode] Add --- doc/compress.html | 1 + mode/index.html | 1 + mode/meta.js | 1 + mode/troff/index.html | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++ mode/troff/troff.js | 82 ++++++++++++++++++++++++++++ 5 files changed, 231 insertions(+) create mode 100644 mode/troff/index.html create mode 100644 mode/troff/troff.js diff --git a/doc/compress.html b/doc/compress.html index 6fe3477e3f..6331835eb4 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -185,6 +185,7 @@ + diff --git a/mode/index.html b/mode/index.html index f9b2a89d42..6ecb2cb558 100644 --- a/mode/index.html +++ b/mode/index.html @@ -118,6 +118,7 @@

    • Tiki wiki
    • TOML
    • Tornado (templating language)
    • +
    • troff (for manpages)
    • Turtle
    • VB.NET
    • VBScript
    • diff --git a/mode/meta.js b/mode/meta.js index 6519cde4c9..2d8d9275d8 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -120,6 +120,7 @@ {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"}, {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]}, {name: "Tornado", mime: "text/x-tornado", mode: "tornado"}, + {name: "troff", mime: "troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]}, {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]}, {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]}, {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]}, diff --git a/mode/troff/index.html b/mode/troff/index.html new file mode 100644 index 0000000000..7c5a54e54f --- /dev/null +++ b/mode/troff/index.html @@ -0,0 +1,146 @@ + + +CodeMirror: troff mode + + + + + + + + + + +
      +

      troff

      + + + + + + +

      MIME types defined: troff.

      +
      diff --git a/mode/troff/troff.js b/mode/troff/troff.js new file mode 100644 index 0000000000..beca778eeb --- /dev/null +++ b/mode/troff/troff.js @@ -0,0 +1,82 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) + define(["../../lib/codemirror"], mod); + else + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode('troff', function() { + + var words = {}; + + function tokenBase(stream) { + if (stream.eatSpace()) return null; + + var sol = stream.sol(); + var ch = stream.next(); + + if (ch === '\\') { + if (stream.match('fB') || stream.match('fR') || stream.match('fI') || + stream.match('u') || stream.match('d') || + stream.match('%') || stream.match('&')) { + return 'string'; + } + if (stream.match('m[')) { + stream.skipTo(']'); + stream.next(); + return 'string'; + } + if (stream.match('s+') || stream.match('s-')) { + stream.eatWhile(/[\d-]/); + return 'string'; + } + if (stream.match('\(') || stream.match('*\(')) { + stream.eatWhile(/[\w-]/); + return 'string'; + } + return 'string'; + } + if (sol && (ch === '.' || ch === '\'')) { + if (stream.eat('\\') && stream.eat('\"')) { + stream.skipToEnd(); + return 'comment'; + } + } + if (sol && ch === '.') { + if (stream.match('B ') || stream.match('I ') || stream.match('R ')) { + return 'attribute'; + } + if (stream.match('TH ') || stream.match('SH ') || stream.match('SS ') || stream.match('HP ')) { + stream.skipToEnd(); + return 'quote'; + } + if ((stream.match(/[A-Z]/) && stream.match(/[A-Z]/)) || (stream.match(/[a-z]/) && stream.match(/[a-z]/))) { + return 'attribute'; + } + } + stream.eatWhile(/[\w-]/); + var cur = stream.current(); + return words.hasOwnProperty(cur) ? words[cur] : null; + } + + function tokenize(stream, state) { + return (state.tokens[0] || tokenBase) (stream, state); + }; + + return { + startState: function() {return {tokens:[]};}, + token: function(stream, state) { + return tokenize(stream, state); + } + }; +}); + +CodeMirror.defineMIME('troff', 'troff'); + +}); From fd9f66c3fb1970a1cd426dbdb76343abb513fbd2 Mon Sep 17 00:00:00 2001 From: darealshinji Date: Fri, 13 Mar 2015 08:53:11 +0100 Subject: [PATCH 41/57] [cmake mode] Add --- mode/cmake/cmake.js | 97 ++++++++++ mode/cmake/index.html | 493 ++++++++++++++++++++++++++++++++++++++++++++++++++ mode/index.html | 1 + mode/meta.js | 1 + 4 files changed, 592 insertions(+) create mode 100644 mode/cmake/cmake.js create mode 100644 mode/cmake/index.html diff --git a/mode/cmake/cmake.js b/mode/cmake/cmake.js new file mode 100644 index 0000000000..9f9eda5417 --- /dev/null +++ b/mode/cmake/cmake.js @@ -0,0 +1,97 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) + define(["../../lib/codemirror"], mod); + else + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode("cmake", function () { + var variable_regex = /({)?[a-zA-Z0-9_]+(})?/; + + function tokenString(stream, state) { + var current, prev, found_var = false; + while (!stream.eol() && (current = stream.next()) != state.pending) { + if (current === '$' && prev != '\\' && state.pending == '"') { + found_var = true; + break; + } + prev = current; + } + if (found_var) { + stream.backUp(1); + } + if (current == state.pending) { + state.continueString = false; + } else { + state.continueString = true; + } + return "string"; + } + + function tokenize(stream, state) { + var ch = stream.next(); + + // Have we found a variable? + if (ch === '$') { + if (stream.match(variable_regex)) { + return 'variable-2'; + } + return 'variable'; + } + // Should we still be looking for the end of a string? + if (state.continueString) { + // If so, go through the loop again + stream.backUp(1); + return tokenString(stream, state); + } + // Do we just have a function on our hands? + // In 'cmake_minimum_required (VERSION 2.8.8)', 'cmake_minimum_required' is matched + if (stream.match(/(\s+)?\w+\(/) || stream.match(/(\s+)?\w+\ \(/)) { + stream.backUp(1); + return 'def'; + } + if (ch == "#") { + stream.skipToEnd(); + return "comment"; + } + // Have we found a string? + if (ch == "'" || ch == '"') { + // Store the type (single or double) + state.pending = ch; + // Perform the looping function to find the end + return tokenString(stream, state); + } + if (ch == '(' || ch == ')') { + return 'bracket'; + } + if (ch.match(/[0-9]/)) { + return 'number'; + } + stream.eatWhile(/[\w-]/); + return null; + } + return { + startState: function () { + var state = {}; + state.inDefinition = false; + state.inInclude = false; + state.continueString = false; + state.pending = false; + return state; + }, + token: function (stream, state) { + if (stream.eatSpace()) return null; + return tokenize(stream, state); + } + }; +}); + +CodeMirror.defineMIME("text/x-cmake", "cmake"); + +}); diff --git a/mode/cmake/index.html b/mode/cmake/index.html new file mode 100644 index 0000000000..5f8b485328 --- /dev/null +++ b/mode/cmake/index.html @@ -0,0 +1,493 @@ + + +CodeMirror: CMake mode + + + + + + + + + + +
      +

      CMake mode

      +
      + + +

      MIME types defined: text/x-cmake.

      + +
      diff --git a/mode/index.html b/mode/index.html index 6ecb2cb558..7b62a33cf2 100644 --- a/mode/index.html +++ b/mode/index.html @@ -34,6 +34,7 @@
    • Asterisk dialplan
    • C, C++, C#
    • Clojure
    • +
    • CMake
    • COBOL
    • CoffeeScript
    • Common Lisp
    • diff --git a/mode/meta.js b/mode/meta.js index 2d8d9275d8..d138809179 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -20,6 +20,7 @@ {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]}, {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]}, {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj"]}, + {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/}, {name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]}, {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]}, {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]}, From 03a49e971fb5b5b36867c05131475b264d8d2c85 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 14 Mar 2015 11:11:47 +0100 Subject: [PATCH 42/57] [cmake mode] Cut size of example code Issue #3125 --- doc/compress.html | 1 + mode/cmake/index.html | 364 -------------------------------------------------- 2 files changed, 1 insertion(+), 364 deletions(-) diff --git a/doc/compress.html b/doc/compress.html index 6331835eb4..b3ef59af3b 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -106,6 +106,7 @@ + diff --git a/mode/cmake/index.html b/mode/cmake/index.html index 5f8b485328..ed114fece5 100644 --- a/mode/cmake/index.html +++ b/mode/cmake/index.html @@ -115,370 +115,6 @@ if (APPLE) add_definitions(-DMACOS) endif() - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CLANG 1) -endif() -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - set(INTEL_CXX 1) -endif() -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(GCC 1) -endif() - -if(INTEL_CXX AND WIN32) - # treat icl roughly like MSVC - set(MSVC 1) -endif() -if(MSVC) - option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF) - if (STATIC_LINK_CRT) - set(CompilerFlags CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE) - foreach(CompilerFlag ${CompilerFlags}) - string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") - endforeach() - endif (STATIC_LINK_CRT) - add_definitions(/W4) # Full warnings - add_definitions(/Ob2) # always inline - add_definitions(/MP) # multithreaded build - - # disable Microsofts suggestions for proprietary secure APIs - add_definitions(/D_CRT_SECURE_NO_WARNINGS) - - check_include_files(stdint.h HAVE_STDINT_H) - if(NOT HAVE_STDINT_H) - include_directories(compat/msvc) - endif() -endif(MSVC) - -check_include_files(inttypes.h HAVE_INT_TYPES_H) -if(HAVE_INT_TYPES_H) - add_definitions(-DHAVE_INT_TYPES_H=1) -endif() - -if(INTEL_CXX AND UNIX) - set(GCC 1) # treat icpc roughly like gcc -elseif(CLANG) - set(GCC 1) # treat clang roughly like gcc -elseif(CMAKE_COMPILER_IS_GNUCXX) - set(GCC 1) -endif() -if(GCC) - add_definitions(-Wall -Wextra -Wshadow) - add_definitions(-D__STDC_LIMIT_MACROS=1) - if(ENABLE_PIC) - add_definitions(-fPIC) - endif(ENABLE_PIC) - if(X86 AND NOT X64) - add_definitions(-march=i686) - endif() - if(ARM) - add_definitions(-march=armv6 -mfloat-abi=hard -mfpu=vfp) - endif() - check_cxx_compiler_flag(-Wno-narrowing CC_HAS_NO_NARROWING) - check_cxx_compiler_flag(-Wno-array-bounds CC_HAS_NO_ARRAY_BOUNDS) - if (CC_HAS_NO_ARRAY_BOUNDS) - add_definitions(-Wno-array-bounds) # these are unhelpful - endif() - check_cxx_compiler_flag(-ffast-math CC_HAS_FAST_MATH) - if (CC_HAS_FAST_MATH) - add_definitions(-ffast-math) - endif() - check_cxx_compiler_flag(-mstackrealign CC_HAS_STACK_REALIGN) - if (CC_HAS_STACK_REALIGN) - add_definitions(-mstackrealign) - endif() - # Disable exceptions. Reduce executable size, increase compability. - check_cxx_compiler_flag(-fno-exceptions CC_HAS_FNO_EXCEPTIONS_FLAG) - if(CC_HAS_FNO_EXCEPTIONS_FLAG) - add_definitions(-fno-exceptions) - endif() - set(FSANITIZE "" CACHE STRING "-fsanitize options for GCC/clang") - if(FSANITIZE) - add_definitions(-fsanitize=${FSANITIZE}) - # clang and gcc need the sanitize options to be passed at link - # time so the appropriate ASAN/TSAN runtime libraries can be - # linked. - list(APPEND LINKER_OPTIONS "-fsanitize=${FSANITIZE}") - endif() - execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CC_VERSION) -endif(GCC) - -find_package(Yasm) -if(YASM_FOUND AND X86) - if (YASM_VERSION_STRING VERSION_LESS "1.2.0") - message(STATUS "Yasm version ${YASM_VERSION_STRING} is too old. 1.2.0 or later required") - option(ENABLE_ASSEMBLY "Enable use of assembly coded primitives" OFF) - else() - message(STATUS "Found Yasm ${YASM_VERSION_STRING} to build assembly primitives") - option(ENABLE_ASSEMBLY "Enable use of assembly coded primitives" ON) - endif() -endif() - -option(CHECKED_BUILD "Enable run-time sanity checks (debugging)" OFF) -if(CHECKED_BUILD) - add_definitions(-DCHECKED_BUILD=1) - if(GCC) - check_cxx_compiler_flag(-fsanitize=undefined-trap CC_HAS_CATCH_UNDEFINED) # clang - check_cxx_compiler_flag(-ftrapv CC_HAS_FTRAPV) # gcc - check_cxx_compiler_flag(-fstack-protector-all CC_HAS_STACK_PROTECT) # gcc - if(CC_HAS_FTRAPV) - add_definitions(-ftrapv) - endif() - if(CC_HAS_CATCH_UNDEFINED) - add_definitions(-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error) - endif() - if(CC_HAS_STACK_PROTECT) - add_definitions(-fstack-protector-all) - if(MINGW) - list(APPEND PLATFORM_LIBS ssp) - endif() - endif() - endif(GCC) -endif() - -# Build options -set(LIB_INSTALL_DIR lib CACHE STRING "Install location of libraries") -set(BIN_INSTALL_DIR bin CACHE STRING "Install location of executables") - -if(X64) - # NOTE: We only officially support 16bit-per-pixel compiles of x265 - # on 64bit architectures. 16bpp plus large resolution plus slow - # preset plus 32bit address space usually means malloc failure. You - # can disable this if(X64) check if you desparately need a 32bit - # build with 10bit/12bit support, but this violates the "shrink wrap - # license" so to speak. If it breaks you get to keep both halves. - # You will likely need to compile without assembly - option(HIGH_BIT_DEPTH "Store pixels as 16bit values" OFF) -endif(X64) -if(HIGH_BIT_DEPTH) - add_definitions(-DHIGH_BIT_DEPTH=1) -else(HIGH_BIT_DEPTH) - add_definitions(-DHIGH_BIT_DEPTH=0) -endif(HIGH_BIT_DEPTH) - -option(WARNINGS_AS_ERRORS "Stop compiles on first warning" OFF) -if(WARNINGS_AS_ERRORS) - if(GCC) - add_definitions(-Werror) - elseif(MSVC) - add_definitions(/WX) - endif() -endif(WARNINGS_AS_ERRORS) - -if (WIN32) - # Visual leak detector - find_package(VLD QUIET) - if(VLD_FOUND) - add_definitions(-DHAVE_VLD) - include_directories(${VLD_INCLUDE_DIRS}) - list(APPEND PLATFORM_LIBS ${VLD_LIBRARIES}) - link_directories(${VLD_LIBRARY_DIRS}) - endif() - option(WINXP_SUPPORT "Make binaries compatible with Windows XP" OFF) - if(WINXP_SUPPORT) - # force use of workarounds for CONDITION_VARIABLE and atomic - # intrinsics introduced after XP - add_definitions(-D_WIN32_WINNT=_WIN32_WINNT_WINXP) - endif() -endif() - -include(version) # determine X265_VERSION and X265_LATEST_TAG -include_directories(. common encoder "${PROJECT_BINARY_DIR}") - -option(ENABLE_PPA "Enable PPA profiling instrumentation" OFF) -if(ENABLE_PPA) - add_definitions(-DENABLE_PPA) - list(APPEND PLATFORM_LIBS PPA) - if(UNIX) - list(APPEND PLATFORM_LIBS dl) - endif(UNIX) - add_subdirectory(profile/PPA) -endif(ENABLE_PPA) - -option(ENABLE_VTUNE "Enable Vtune profiling instrumentation" OFF) -if(ENABLE_VTUNE) - add_definitions(-DENABLE_VTUNE) - include_directories($ENV{VTUNE_AMPLIFIER_XE_2015_DIR}/include) - list(APPEND PLATFORM_LIBS vtune) - link_directories($ENV{VTUNE_AMPLIFIER_XE_2015_DIR}/lib64) - if(WIN32) - list(APPEND PLATFORM_LIBS libittnotify.lib) - else() - list(APPEND PLATFORM_LIBS libittnotify.a dl) - endif() - add_subdirectory(profile/vtune) -endif(ENABLE_VTUNE) - -option(DETAILED_CU_STATS "Enable internal profiling of encoder work" OFF) -if(DETAILED_CU_STATS) - add_definitions(-DDETAILED_CU_STATS) -endif(DETAILED_CU_STATS) - -add_subdirectory(encoder) -add_subdirectory(common) - -if((MSVC_IDE OR XCODE) AND ENABLE_ASSEMBLY) - # this is required because of this cmake bug - # http://www.cmake.org/Bug/print_bug_page.php?bug_id=8170 - if(WIN32) - set(SUFFIX obj) - else() - set(SUFFIX o) - endif() - foreach(ASM ${MSVC_ASMS}) - set(YASM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/common/x86/${ASM}) - list(APPEND YASM_SRCS ${YASM_SRC}) - list(APPEND YASM_OBJS ${ASM}.${SUFFIX}) - add_custom_command( - OUTPUT ${ASM}.${SUFFIX} - COMMAND ${YASM_EXECUTABLE} ARGS ${YASM_FLAGS} ${YASM_SRC} -o ${ASM}.${SUFFIX} - DEPENDS ${YASM_SRC}) - endforeach() -endif() - -source_group(ASM FILES ${YASM_SRCS}) -add_library(x265-static STATIC $ $ ${YASM_OBJS} ${YASM_SRCS}) -if(NOT MSVC) - set_target_properties(x265-static PROPERTIES OUTPUT_NAME x265) -endif() -install(TARGETS x265-static - LIBRARY DESTINATION ${LIB_INSTALL_DIR} - ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) -install(FILES x265.h "${PROJECT_BINARY_DIR}/x265_config.h" DESTINATION include) - -if(CMAKE_RC_COMPILER) - # The resource compiler does not need CFLAGS or macro defines. It - # often breaks them - string(REPLACE "" "" CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILE_OBJECT}") - string(REPLACE "" "" CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILE_OBJECT}") - - # convert X265_LATEST_TAG (ex: 0.7) and X265_TAG_DISTANCE (ex: 103) to - # @X265_VERSION_MAJOR@,@X265_VERSION_MINOR@,@X265_BRANCH_ID@,@X265_TAG_DISTANCE@ - string(REPLACE "." ";" VERSION_LIST "${X265_LATEST_TAG}") - list(GET VERSION_LIST 0 X265_VERSION_MAJOR) - list(GET VERSION_LIST 1 X265_VERSION_MINOR) - set(X265_BRANCH_ID 0) # TODO: 0 - stable, 1 - default or other - set(X265_RC_FILE "${CMAKE_CURRENT_BINARY_DIR}/x265.rc") - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/x265.rc.in" "${X265_RC_FILE}" @ONLY) -endif() - -if(NOT (MSVC_IDE OR XCODE)) - add_custom_target(clean-generated COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/clean-generated.cmake) -endif() - -option(ENABLE_SHARED "Build shared library" ON) -if(ENABLE_SHARED) - add_library(x265-shared SHARED "${PROJECT_BINARY_DIR}/x265.def" ${YASM_OBJS} - ${X265_RC_FILE} $ $) - target_link_libraries(x265-shared ${PLATFORM_LIBS}) - if(MSVC) - set_target_properties(x265-shared PROPERTIES OUTPUT_NAME libx265) - else() - set_target_properties(x265-shared PROPERTIES OUTPUT_NAME x265) - endif() - if(UNIX) - set_target_properties(x265-shared PROPERTIES VERSION ${X265_BUILD}) - if(APPLE) - set_target_properties(x265-shared PROPERTIES MACOSX_RPATH 1) - else() - set_target_properties(x265-shared PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,-znoexecstack") - endif() - endif() - set_target_properties(x265-shared PROPERTIES SOVERSION ${X265_BUILD}) - if(X265_LATEST_TAG) - if(WINDOWS) - set_target_properties(x265-shared PROPERTIES VERSION ${X265_LATEST_TAG}) - endif() - # shared library is not installed if a tag is not found - install(TARGETS x265-shared - LIBRARY DESTINATION ${LIB_INSTALL_DIR} - ARCHIVE DESTINATION ${LIB_INSTALL_DIR} - RUNTIME DESTINATION ${BIN_INSTALL_DIR}) - endif() - if(LINKER_OPTIONS) - set_target_properties(x265-shared PROPERTIES LINK_FLAGS ${LINKER_OPTIONS}) - endif() -endif() - -if(X265_LATEST_TAG) - # convert lists of link libraries into -lstdc++ -lm etc.. - foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES} ${PLATFORM_LIBS}) - if(IS_ABSOLUTE ${LIB} AND EXISTS ${LIB}) - list(APPEND PLIBLIST "${LIB}") - else() - list(APPEND PLIBLIST "-l${LIB}") - endif() - endforeach() - if(PLIBLIST) - # blacklist of libraries that should not be in Libs.private - list(REMOVE_ITEM PLIBLIST "-lc" "-lpthread") - string(REPLACE ";" " " PRIVATE_LIBS "${PLIBLIST}") - else() - set(PRIVATE_LIBS "") - endif(PLIBLIST) - - # Produce a pkg-config file - configure_file("x265.pc.in" "x265.pc" @ONLY) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/x265.pc" - DESTINATION "${LIB_INSTALL_DIR}/pkgconfig") -endif() - -if(NOT WIN32) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" - IMMEDIATE @ONLY) - add_custom_target(uninstall - "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake") -endif() - -# Main CLI application -option(ENABLE_CLI "Build standalone CLI application" ON) -if(ENABLE_CLI) - file(GLOB InputFiles input/*.cpp input/*.h) - file(GLOB OutputFiles output/*.cpp output/*.h) - file(GLOB FilterFiles filters/*.cpp filters/*.h) - source_group(input FILES ${InputFiles}) - source_group(output FILES ${OutputFiles}) - source_group(filters FILES ${FilterFiles}) - - check_include_files(getopt.h HAVE_GETOPT_H) - if(NOT HAVE_GETOPT_H) - if(MSVC) - set_source_files_properties(compat/getopt/getopt.c PROPERTIES COMPILE_FLAGS "/wd4100 /wd4131 -DHAVE_STRING_H=1") - endif(MSVC) - include_directories(compat/getopt) - set(GETOPT compat/getopt/getopt.c compat/getopt/getopt.h) - endif(NOT HAVE_GETOPT_H) - - if(XCODE) - # Xcode seems unable to link the CLI with libs, so link as one targget - add_executable(cli ../COPYING ${InputFiles} ${OutputFiles} ${FilterFiles} ${GETOPT} x265.cpp x265.h x265cli.h - $ $ ${YASM_OBJS} ${YASM_SRCS}) - else() - add_executable(cli ../COPYING ${InputFiles} ${OutputFiles} ${FilterFiles} ${GETOPT} ${X265_RC_FILE} x265.cpp x265.h x265cli.h) - if(WIN32 OR NOT ENABLE_SHARED OR INTEL_CXX) - # The CLI cannot link to the shared library on Windows, it - # requires internal APIs not exported from the DLL - target_link_libraries(cli x265-static ${PLATFORM_LIBS}) - else() - target_link_libraries(cli x265-shared ${PLATFORM_LIBS}) - endif() - endif() - set_target_properties(cli PROPERTIES OUTPUT_NAME x265) - if(LINKER_OPTIONS) - set_target_properties(cli PROPERTIES LINK_FLAGS ${LINKER_OPTIONS}) - endif() - - install(TARGETS cli DESTINATION ${BIN_INSTALL_DIR}) -endif(ENABLE_CLI) - -if(ENABLE_ASSEMBLY AND NOT XCODE) - option(ENABLE_TESTS "Enable Unit Tests" OFF) - if(ENABLE_TESTS) - add_subdirectory(test) - endif() -endif() -

      The LESS mode is a sub-mode of the CSS mode (defined in css.js.

      +

      The LESS mode is a sub-mode of the CSS mode (defined in css.js).

      Parsing/Highlighting Tests: normal, verbose.

      diff --git a/mode/css/scss.html b/mode/css/scss.html index 21f20e0d16..f8e4d37368 100644 --- a/mode/css/scss.html +++ b/mode/css/scss.html @@ -150,7 +150,7 @@ }); -

      The SCSS mode is a sub-mode of the CSS mode (defined in css.js.

      +

      The SCSS mode is a sub-mode of the CSS mode (defined in css.js).

      Parsing/Highlighting Tests: normal, verbose.

      From fc2def32c40914164923b417823f7452b0e5b13d Mon Sep 17 00:00:00 2001 From: Dmitry Kiselyov Date: Mon, 16 Mar 2015 17:49:29 +0200 Subject: [PATCH 48/57] [stylus mode] New version Better auto-indent and highlighting. --- mode/stylus/stylus.js | 987 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 653 insertions(+), 334 deletions(-) diff --git a/mode/stylus/stylus.js b/mode/stylus/stylus.js index 6f7c754425..e9561109f7 100644 --- a/mode/stylus/stylus.js +++ b/mode/stylus/stylus.js @@ -1,444 +1,763 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: http://codemirror.net/LICENSE +// Stylus mode created by Dmitry Kiselyov http://git.io/AaRB + (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror")); + mod(require("lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror"], mod); + define(["lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("stylus", function(config) { - - var operatorsRegexp = /^(\?:?|\+[+=]?|-[\-=]?|\*[\*=]?|\/=?|[=!:\?]?=|<=?|>=?|%=?|&&|\|=?|\~|!|\^|\\)/, - delimitersRegexp = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/, - wordOperatorsRegexp = wordRegexp(wordOperators), - commonKeywordsRegexp = wordRegexp(commonKeywords), - commonAtomsRegexp = wordRegexp(commonAtoms), - commonDefRegexp = wordRegexp(commonDef), - vendorPrefixesRegexp = new RegExp(/^\-(moz|ms|o|webkit)-/), - cssValuesWithBracketsRegexp = new RegExp("^(" + cssValuesWithBrackets_.join("|") + ")\\([\\w\-\\#\\,\\.\\%\\s\\(\\)]*\\)"); - - var tokenBase = function(stream, state) { - - if (stream.eatSpace()) return null; - - var ch = stream.peek(); - - // Single line Comment - if (stream.match('//')) { + var indentUnit = config.indentUnit, + tagKeywords = keySet(tagKeywords_), + tagVariablesRegexp = /^(a|b|i|s|col|em)$/i, + propertyKeywords = keySet(propertyKeywords_), + nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_), + valueKeywords = keySet(valueKeywords_), + colorKeywords = keySet(colorKeywords_), + documentTypes = keySet(documentTypes_), + documentTypesRegexp = wordRegexp(documentTypes_), + mediaFeatures = keySet(mediaFeatures_), + mediaTypes = keySet(mediaTypes_), + fontProperties = keySet(fontProperties_), + operatorsRegexp = /^\s*([.]{2,3}|&&|\|\||\*\*|[?!=:]?=|[-+*\/%<>]=?|\?:|\~)/, + wordOperatorKeywordsRegexp = wordRegexp(wordOperatorKeywords_), + blockKeywords = keySet(blockKeywords_), + vendorPrefixesRegexp = new RegExp(/^\-(moz|ms|o|webkit)-/i), + commonAtoms = keySet(commonAtoms_), + firstWordMatch = "", + states = {}, + ch, + style, + type, + override; + + /** + * Tokenizers + */ + function tokenBase(stream, state) { + firstWordMatch = stream.string.match(/(^[\w-]+\s*=\s*$)|(^\s*[\w-]+\s*=\s*[\w-])|(^\s*(\.|#|@|\$|\&|\[|\d|\+|::?|\{|\>|~|\/)?\s*[\w-]*([a-z0-9-]|\*|\/\*)(\(|,)?)/); + state.context.line.firstWord = firstWordMatch ? firstWordMatch[0].replace(/^\s*/, "") : ""; + state.context.line.indent = stream.indentation(); + ch = stream.peek(); + + // Line comment + if (stream.match("//")) { stream.skipToEnd(); - return "comment"; + return ["comment", "comment"]; } - - // Multiline Comment - if (stream.match('/*')) { - state.tokenizer = multilineComment; - return state.tokenizer(stream, state); + // Block comment + if (stream.match("/*")) { + state.tokenize = tokenCComment; + return tokenCComment(stream, state); } - - // Strings - if (ch === '"' || ch === "'") { + // String + if (ch == "\"" || ch == "'") { stream.next(); - state.tokenizer = buildStringTokenizer(ch); - return "string"; + state.tokenize = tokenString(ch); + return state.tokenize(stream, state); } - // Def - if (ch === "@") { + if (ch == "@") { stream.next(); - if (stream.match(/extend/)) { - dedent(state); // remove indentation after selectors - } else if (stream.match(/media[\w-\s]*[\w-]/)) { - indent(state); - } else if(stream.eatWhile(/[\w-]/)) { - if(stream.current().match(commonDefRegexp)) { - indent(state); - } - } - return "def"; - } - - // Number - if (stream.match(/^-?[0-9\.]/, false)) { - - // Floats - if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i) || stream.match(/^-?\d+\.\d*/)) { - - // Prevent from getting extra . on 1.. - if (stream.peek() == ".") { - stream.backUp(1); - } - // Units - stream.eatWhile(/[a-z%]/i); - return "number"; - } - // Integers - if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/) || stream.match(/^-?0(?![\dx])/i)) { - // Units - stream.eatWhile(/[a-z%]/i); - return "number"; - } + stream.eatWhile(/[\w\\-]/); + return ["def", stream.current()]; } - - // Hex color and id selector - if (ch === "#") { + // ID selector or Hex color + if (ch == "#") { stream.next(); - // Hex color if (stream.match(/^[0-9a-f]{6}|[0-9a-f]{3}/i)) { - return "atom"; + return ["atom", "atom"]; } - // ID selector - if (stream.match(/^[\w-]+/i)) { - indent(state); - return "builtin"; + if (stream.match(/^[a-z][\w-]*/i)) { + return ["builtin", "hash"]; } } - // Vendor prefixes if (stream.match(vendorPrefixesRegexp)) { - return "meta"; + return ["meta", "vendor-prefixes"]; } - - // Gradients and animation as CSS value - if (stream.match(cssValuesWithBracketsRegexp)) { - return "atom"; + // Numbers + if (stream.match(/^-?[0-9]?\.?[0-9]/)) { + stream.eatWhile(/[a-z%]/i); + return ["number", "unit"]; } - - // Mixins / Functions with indentation - if (stream.sol() && stream.match(/^\.?[a-z][\w-]*\(/i)) { - stream.backUp(1); - indent(state); - return "keyword"; + // !important|optional + if (ch == "!") { + stream.next(); + return [stream.match(/^(important|optional)/i) ? "keyword": "operator", "important"]; + } + // Class + if (ch == "." && stream.match(/^\.[a-z][\w-]*/i)) { + return ["qualifier", "qualifier"]; + } + // url url-prefix domain regexp + if (stream.match(documentTypesRegexp)) { + if (stream.peek() == "(") state.tokenize = tokenParenthesized; + return ["property", "word"]; } - // Mixins / Functions - if (stream.match(/^\.?[a-z][\w-]*\(/i)) { + if (stream.match(/^[a-z][\w-]*\(/i)) { stream.backUp(1); - return "keyword"; + return ["keyword", "mixin"]; } - - // +Block mixins - if (stream.match(/^(\+|\-)[a-z][\w-]+\(/i)) { + // Block mixins + if (stream.match(/^(\+|-)[a-z][\w-]*\(/i)) { stream.backUp(1); - indent(state); - return "keyword"; + return ["keyword", "block-mixin"]; } - - // url tokens - if (stream.match(/^url/) && stream.peek() === "(") { - state.tokenizer = urlTokens; - if(!stream.peek()) { - state.cursorHalf = 0; + // Parent Reference BEM naming + if (stream.string.match(/^\s*&/) && stream.match(/^[-_]+[a-z][\w-]*/)) { + return ["qualifier", "qualifier"]; + } + // / Root Reference & Parent Reference + if (stream.match(/^(\/|&)(-|_|:|\.|#|[a-z])/)) { + stream.backUp(1); + return ["variable-3", "reference"]; + } + if (stream.match(/^&{1}\s*$/)) { + return ["variable-3", "reference"]; + } + // Variable + if (ch == "$" && stream.match(/^\$[\w-]+/i)) { + return ["variable-2", "variable-name"]; + } + // Word operator + if (stream.match(wordOperatorKeywordsRegexp)) { + return ["operator", "operator"]; + } + // Word + if (stream.match(/^[-_]*[a-z0-9]+[\w-]*/i)) { + if (stream.match(/^(\.|\[)[\w-\'\"\]]+/i, false)) { + if (!wordIsTag(stream.current())) { + stream.match(/[\w-]+/); + return ["variable-2", "variable-name"]; + } } - return "atom"; + return ["variable-2", "word"]; } - - // Class - if (stream.match(/^\.[a-z][\w-]*/i)) { - indent(state); - return "qualifier"; + // Operators + if (stream.match(operatorsRegexp)) { + return ["operator", stream.current()]; } - - // & Parent Reference with BEM naming - if (stream.match(/^(_|__|-|--)[a-z0-9-]+/)) { - return "qualifier"; + // Delimiters + if (/[:;,{}\[\]\(\)]/.test(ch)) { + stream.next(); + return [null, ch]; } + // Non-detected items + stream.next(); + return [null, null]; + } - // Pseudo elements/classes - if (ch == ':' && stream.match(/^::?[\w-]+/)) { - indent(state); - return "variable-3"; + /** + * Token comment + */ + function tokenCComment(stream, state) { + var maybeEnd = false, ch; + while ((ch = stream.next()) != null) { + if (maybeEnd && ch == "/") { + state.tokenize = null; + break; + } + maybeEnd = (ch == "*"); } + return ["comment", "comment"]; + } - // Conditionals - if (stream.match(wordRegexp(["for", "if", "else", "unless"]))) { - indent(state); - return "keyword"; - } + /** + * Token string + */ + function tokenString(quote) { + return function(stream, state) { + var escaped = false, ch; + while ((ch = stream.next()) != null) { + if (ch == quote && !escaped) { + if (quote == ")") stream.backUp(1); + break; + } + escaped = !escaped && ch == "\\"; + } + if (ch == quote || !escaped && quote != ")") state.tokenize = null; + return ["string", "string"]; + }; + } - // Keywords - if (stream.match(commonKeywordsRegexp)) { - return "keyword"; - } + /** + * Token parenthesized + */ + function tokenParenthesized(stream, state) { + stream.next(); // Must be "(" + if (!stream.match(/\s*[\"\')]/, false)) + state.tokenize = tokenString(")"); + else + state.tokenize = null; + return [null, "("]; + } - // Atoms - if (stream.match(commonAtomsRegexp)) { - return "atom"; - } + /** + * Context management + */ + function Context(type, indent, prev, line) { + this.type = type; + this.indent = indent; + this.prev = prev; + this.line = line || {firstWord: "", indent: 0}; + } - // Variables - if (stream.match(/^\$?[a-z][\w-]+\s?=(\s|[\w-'"\$])/i)) { - stream.backUp(2); - var cssPropertie = stream.current().toLowerCase().match(/[\w-]+/)[0]; - return cssProperties[cssPropertie] === undefined ? "variable-2" : "property"; - } else if (stream.match(/\$[\w-\.]+/i)) { - return "variable-2"; - } else if (stream.match(/\$?[\w-]+\.[\w-]+/i)) { - var cssTypeSelector = stream.current().toLowerCase().match(/[\w]+/)[0]; - if(cssTypeSelectors[cssTypeSelector] === undefined) { - return "variable-2"; - } else stream.backUp(stream.current().length); - } + function pushContext(state, stream, type, indent) { + indent = indent >= 0 ? indent : indentUnit; + state.context = new Context(type, stream.indentation() + indent, state.context); + return type; + } - // !important - if (ch === "!") { - stream.next(); - return stream.match(/^[\w]+/) ? "keyword": "operator"; - } + function popContext(state, currentIndent) { + var contextIndent = state.context.indent - indentUnit; + currentIndent = currentIndent || false; + state.context = state.context.prev; + if (currentIndent) state.context.indent = contextIndent; + return state.context.type; + } - // / Root Reference - if (stream.match(/^\/(:|\.|#|[a-z])/)) { - stream.backUp(1); - return "variable-3"; - } + function pass(type, stream, state) { + return states[state.context.type](type, stream, state); + } - // Operators and delimiters - if (stream.match(operatorsRegexp) || stream.match(wordOperatorsRegexp)) { - return "operator"; - } - if (stream.match(delimitersRegexp)) { - return null; - } + function popAndPass(type, stream, state, n) { + for (var i = n || 1; i > 0; i--) + state.context = state.context.prev; + return pass(type, stream, state); + } - // & Parent Reference - if (ch === "&") { - stream.next(); - return "variable-3"; - } + + /** + * Parser + */ + function wordIsTag(word) { + return word.toLowerCase() in tagKeywords; + } + + function wordIsProperty(word) { + word = word.toLowerCase(); + return word in propertyKeywords || word in fontProperties; + } + + function wordIsBlock(word) { + return word.toLowerCase() in blockKeywords; + } + + function wordIsVendorPrefix(word) { + return word.toLowerCase().match(vendorPrefixesRegexp); + } + + function wordAsValue(word) { + var wordLC = word.toLowerCase(); + var override = "variable-2"; + if (wordIsTag(word)) override = "tag"; + else if (wordIsBlock(word)) override = "block-keyword"; + else if (wordIsProperty(word)) override = "property"; + else if (wordLC in valueKeywords || wordLC in commonAtoms) override = "atom"; + else if (wordLC == "return" || wordLC in colorKeywords) override = "keyword"; // Font family - if (stream.match(/^[A-Z][a-z0-9-]+/)) { - return "string"; - } + else if (word.match(/^[A-Z]/)) override = "string"; + return override; + } - // CSS rule - // NOTE: Some css selectors and property values have the same name - // (embed, menu, pre, progress, sub, table), - // so they will have the same color (.cm-atom). - if (stream.match(/[\w-]*/i)) { + function typeIsBlock(type, stream) { + return ((endOfLine(stream) && (type == "{" || type == "]" || type == "hash" || type == "qualifier")) || type == "block-mixin"); + } - var word = stream.current().toLowerCase(); + function typeIsInterpolation(type, stream) { + return type == "{" && stream.match(/^\s*\$?[\w-]+/i, false); + } - if(cssProperties[word] !== undefined) { - // CSS property - if(!stream.eol()) - return "property"; - else - return "variable-2"; - - } else if(cssValues[word] !== undefined) { - // CSS value - return "atom"; - - } else if(cssTypeSelectors[word] !== undefined) { - // CSS type selectors - indent(state); - return "tag"; - - } else if(word) { - // By default variable-2 - return "variable-2"; - } - } + function typeIsPseudo(type, stream) { + return type == ":" && stream.match(/^[a-z-]+/, false); + } - // Handle non-detected items - stream.next(); - return null; + function startOfLine(stream) { + return stream.sol() || stream.string.match(new RegExp("^\\s*" + escapeRegExp(stream.current()))); + } - }; + function endOfLine(stream) { + return stream.eol() || stream.match(/^\s*$/, false); + } + + function firstWordOfLine(line) { + var re = /^\s*[-_]*[a-z0-9]+[\w-]*/i; + var result = typeof line == "string" ? line.match(re) : line.string.match(re); + return result ? result[0].replace(/^\s*/, "") : ""; + } - var tokenLexer = function(stream, state) { - if (stream.sol()) { - state.indentCount = 0; + /** + * Block + */ + states.block = function(type, stream, state) { + if ((type == "comment" && startOfLine(stream)) || + (type == "," && endOfLine(stream)) || + type == "mixin") { + return pushContext(state, stream, "block", 0); + } + if (typeIsInterpolation(type, stream)) { + return pushContext(state, stream, "interpolation"); + } + if (endOfLine(stream) && type == "]") { + if (!/^\s*(\.|#|:|\[|\*|&)/.test(stream.string) && !wordIsTag(firstWordOfLine(stream))) { + return pushContext(state, stream, "block", 0); + } + } + if (typeIsBlock(type, stream, state)) { + return pushContext(state, stream, "block"); + } + if (type == "}" && endOfLine(stream)) { + return pushContext(state, stream, "block", 0); + } + if (type == "variable-name") { + return pushContext(state, stream, "variableName"); + } + if (type == "=") { + if (!endOfLine(stream) && !wordIsBlock(firstWordOfLine(stream))) { + return pushContext(state, stream, "block", 0); + } + return pushContext(state, stream, "block"); } + if (type == "*") { + if (endOfLine(stream) || stream.match(/\s*(,|\.|#|\[|:|{)/,false)) { + override = "tag"; + return pushContext(state, stream, "block"); + } + } + if (typeIsPseudo(type, stream)) { + return pushContext(state, stream, "pseudo"); + } + if (/@(font-face|media|supports|(-moz-)?document)/.test(type)) { + return pushContext(state, stream, endOfLine(stream) ? "block" : "atBlock"); + } + if (/@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) { + return pushContext(state, stream, "keyframes"); + } + if (/@extends?/.test(type)) { + return pushContext(state, stream, "extend", 0); + } + if (type && type.charAt(0) == "@") { - var style = state.tokenizer(stream, state); - var current = stream.current(); + // Property Lookup + if (stream.indentation() > 0 && wordIsProperty(stream.current().slice(1))) { + override = "variable-2"; + return "block"; + } + if (/(@import|@require|@charset)/.test(type)) { + return pushContext(state, stream, "block", 0); + } + return pushContext(state, stream, "block"); + } + if (type == "reference" && endOfLine(stream)) { + return pushContext(state, stream, "block"); + } + if (type == "(") { + return pushContext(state, stream, "parens"); + } - if (stream.eol() && (current === "}" || current === ",")) { - dedent(state); + if (type == "vendor-prefixes") { + return pushContext(state, stream, "vendorPrefixes"); } + if (type == "word") { + var word = stream.current(); + override = wordAsValue(word); + + if (override == "property") { + if (startOfLine(stream)) { + return pushContext(state, stream, "block", 0); + } else { + override = "atom"; + return "block"; + } + } - if (style !== null) { - var startOfToken = stream.pos - current.length; - var withCurrentIndent = startOfToken + (config.indentUnit * state.indentCount); + if (override == "tag") { - var newScopes = []; + // tag is a css value + if (/embed|menu|pre|progress|sub|table/.test(word)) { + if (wordIsProperty(firstWordOfLine(stream))) { + override = "atom"; + return "block"; + } + } - for (var i = 0; i < state.scopes.length; i++) { - var scope = state.scopes[i]; + // tag is an attribute + if (stream.string.match(new RegExp("\\[\\s*" + word + "|" + word +"\\s*\\]"))) { + override = "atom"; + return "block"; + } - if (scope.offset <= withCurrentIndent) { - newScopes.push(scope); + // tag is a variable + if (tagVariablesRegexp.test(word)) { + if ((startOfLine(stream) && stream.string.match(/=/)) || + (!startOfLine(stream) && + !stream.string.match(/^(\s*\.|#|\&|\[|\/|>|\*)/) && + !wordIsTag(firstWordOfLine(stream)))) { + override = "variable-2"; + if (wordIsBlock(firstWordOfLine(stream))) return "block"; + return pushContext(state, stream, "block", 0); + } } + + if (endOfLine(stream)) return pushContext(state, stream, "block"); } + if (override == "block-keyword") { + override = "keyword"; - state.scopes = newScopes; + // Postfix conditionals + if (stream.current(/(if|unless)/) && !startOfLine(stream)) { + return "block"; + } + return pushContext(state, stream, "block"); + } + if (word == "return") return pushContext(state, stream, "block", 0); } - - return style; + return state.context.type; }; - return { - startState: function() { - return { - tokenizer: tokenBase, - scopes: [{offset: 0, type: 'styl'}] - }; - }, - token: function(stream, state) { - var style = tokenLexer(stream, state); - state.lastToken = { style: style, content: stream.current() }; - return style; - }, + /** + * Parens + */ + states.parens = function(type, stream, state) { + if (type == "(") return pushContext(state, stream, "parens"); + if (type == ")") { + if (state.context.prev.type == "parens") { + return popContext(state); + } + if ((stream.string.match(/^[a-z][\w-]*\(/i) && endOfLine(stream)) || + wordIsBlock(firstWordOfLine(stream)) || + /(\.|#|:|\[|\*|&|>|~|\+|\/)/.test(firstWordOfLine(stream)) || + (!stream.string.match(/^-?[a-z][\w-\.\[\]\'\"]*\s*=/) && + wordIsTag(firstWordOfLine(stream)))) { + return pushContext(state, stream, "block"); + } + if (stream.string.match(/^-?[a-z][\w-\.\[\]\'\"]*\s*=/) || + stream.string.match(/^\s*(\(|\)|[0-9])/) || + stream.string.match(/^\s+[a-z][\w-]*\(/i) || + stream.string.match(/^\s+-?[a-z]/i)) { + return pushContext(state, stream, "block", 0); + } + if (endOfLine(stream)) return pushContext(state, stream, "block"); + else return pushContext(state, stream, "block", 0); + } + if (type && type.charAt(0) == "@" && wordIsProperty(stream.current().slice(1))) { + override = "variable-2"; + } + if (type == "word") { + var word = stream.current(); + override = wordAsValue(word); + if (override == "tag" && tagVariablesRegexp.test(word)) { + override = "variable-2"; + } + if (override == "property" || word == "to") override = "atom"; + } + if (type == "variable-name") { + return pushContext(state, stream, "variableName"); + } + if (typeIsPseudo(type, stream)) { + return pushContext(state, stream, "pseudo"); + } + return state.context.type; + }; - indent: function(state) { - return state.scopes[0].offset; - }, - - lineComment: "//", - fold: "indent" + /** + * Vendor prefixes + */ + states.vendorPrefixes = function(type, stream, state) { + if (type == "word") { + override = "property"; + return pushContext(state, stream, "block", 0); + } + return popContext(state); }; - function urlTokens(stream, state) { - var ch = stream.peek(); - if (ch === ")") { - stream.next(); - state.tokenizer = tokenBase; - return "operator"; - } else if (ch === "(") { - stream.next(); - stream.eatSpace(); + /** + * Pseudo + */ + states.pseudo = function(type, stream, state) { + if (!wordIsProperty(firstWordOfLine(stream.string))) { + stream.match(/^[a-z-]+/); + override = "variable-3"; + if (endOfLine(stream)) return pushContext(state, stream, "block"); + return popContext(state); + } + return popAndPass(type, stream, state); + }; - return "operator"; - } else if (ch === "'" || ch === '"') { - state.tokenizer = buildStringTokenizer(stream.next()); - return "string"; - } else { - state.tokenizer = buildStringTokenizer(")", false); - return "string"; + + /** + * atBlock + */ + states.atBlock = function(type, stream, state) { + if (type == "(") return pushContext(state, stream, "atBlock_parens"); + if (typeIsBlock(type, stream, state)) { + return pushContext(state, stream, "block"); } - } + if (typeIsInterpolation(type, stream)) { + return pushContext(state, stream, "interpolation"); + } + if (type == "word") { + var word = stream.current().toLowerCase(); + if (/^(only|not|and|or)$/.test(word)) + override = "keyword"; + else if (documentTypes.hasOwnProperty(word)) + override = "tag"; + else if (mediaTypes.hasOwnProperty(word)) + override = "attribute"; + else if (mediaFeatures.hasOwnProperty(word)) + override = "property"; + else if (nonStandardPropertyKeywords.hasOwnProperty(word)) + override = "string-2"; + else override = wordAsValue(stream.current()); + if (override == "tag" && endOfLine(stream)) { + return pushContext(state, stream, "block"); + } + } + if (type == "operator" && /^(not|and|or)$/.test(stream.current())) { + override = "keyword"; + } + return state.context.type; + }; - function multilineComment(stream, state) { - if (stream.skipTo("*/")) { - stream.next(); - stream.next(); - state.tokenizer = tokenBase; - } else { - stream.next(); + states.atBlock_parens = function(type, stream, state) { + if (type == "{" || type == "}") return state.context.type; + if (type == ")") { + if (endOfLine(stream)) return pushContext(state, stream, "block"); + else return pushContext(state, stream, "atBlock"); } - return "comment"; - } + if (type == "word") { + var word = stream.current().toLowerCase(); + override = wordAsValue(word); + if (/^(max|min)/.test(word)) override = "property"; + if (override == "tag") { + tagVariablesRegexp.test(word) ? override = "variable-2" : override = "atom"; + } + return state.context.type; + } + return states.atBlock(type, stream, state); + }; - function buildStringTokenizer(quote, greedy) { - if(greedy == null) { - greedy = true; + /** + * Keyframes + */ + states.keyframes = function(type, stream, state) { + if (stream.indentation() == "0" && ((type == "}" && startOfLine(stream)) || type == "]" || type == "hash" + || type == "qualifier" || wordIsTag(stream.current()))) { + return popAndPass(type, stream, state); } + if (type == "{") return pushContext(state, stream, "keyframes"); + if (type == "}") { + if (startOfLine(stream)) return popContext(state, true); + else return pushContext(state, stream, "keyframes"); + } + if (type == "unit" && /^[0-9]+\%$/.test(stream.current())) { + return pushContext(state, stream, "keyframes"); + } + if (type == "word") { + override = wordAsValue(stream.current()); + if (override == "block-keyword") { + override = "keyword"; + return pushContext(state, stream, "keyframes"); + } + } + if (/@(font-face|media|supports|(-moz-)?document)/.test(type)) { + return pushContext(state, stream, endOfLine(stream) ? "block" : "atBlock"); + } + if (type == "mixin") { + return pushContext(state, stream, "block", 0); + } + return state.context.type; + }; - 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 !== "\\")); - if (endingString) { - if (nextChar !== quote && greedy) { - stream.next(); - } - state.tokenizer = tokenBase; - return "string"; - } else if (nextChar === "#" && peekChar === "{") { - state.tokenizer = buildInterpolationTokenizer(stringTokenizer); - stream.next(); - return "operator"; - } else { - return "string"; + /** + * Interpolation + */ + states.interpolation = function(type, stream, state) { + if (type == "{") popContext(state) && pushContext(state, stream, "block"); + if (type == "}") { + if (stream.string.match(/^\s*(\.|#|:|\[|\*|&|>|~|\+|\/)/i) || + (stream.string.match(/^\s*[a-z]/i) && wordIsTag(firstWordOfLine(stream)))) { + return pushContext(state, stream, "block"); } + if (!stream.string.match(/^(\{|\s*\&)/) || + stream.match(/\s*[\w-]/,false)) { + return pushContext(state, stream, "block", 0); + } + return pushContext(state, stream, "block"); + } + if (type == "variable-name") { + return pushContext(state, stream, "variableName", 0); + } + if (type == "word") { + override = wordAsValue(stream.current()); + if (override == "tag") override = "atom"; } + return state.context.type; + }; - return stringTokenizer; - } - function buildInterpolationTokenizer(currentTokenizer) { - return function(stream, state) { - if (stream.peek() === "}") { - stream.next(); - state.tokenizer = currentTokenizer; - return "operator"; - } else { - return tokenBase(stream, state); - } - }; - } + /** + * Extend/s + */ + states.extend = function(type, stream, state) { + if (type == "[" || type == "=") return "extend"; + if (type == "]") return popContext(state); + if (type == "word") { + override = wordAsValue(stream.current()); + return "extend"; + } + return popContext(state); + }; + - 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 }); + /** + * Variable name + */ + states.variableName = function(type, stream, state) { + if (type == "string" || type == "[" || type == "]" || stream.current().match(/^(\.|\$)/)) { + if (stream.current().match(/^\.[\w-]+/i)) override = "variable-2"; + if (endOfLine(stream)) return popContext(state); + return "variableName"; } - } + return popAndPass(type, stream, state); + }; - function dedent(state) { - if (state.scopes.length == 1) { return true; } - state.scopes.shift(); - } + return { + startState: function(base) { + return { + tokenize: null, + state: "block", + context: new Context("block", base || 0, null) + }; + }, + token: function(stream, state) { + if (!state.tokenize && stream.eatSpace()) return null; + style = (state.tokenize || tokenBase)(stream, state); + if (style && typeof style == "object") { + type = style[1]; + style = style[0]; + } + override = style; + state.state = states[state.state](type, stream, state); + return override; + }, + indent: function(state, textAfter, line) { + + var cx = state.context, + ch = textAfter && textAfter.charAt(0), + indent = cx.indent, + lineFirstWord = firstWordOfLine(textAfter), + lineIndent = line.length - line.replace(/^\s*/, "").length, + prevLineFirstWord = state.context.prev ? state.context.prev.line.firstWord : "", + prevLineIndent = state.context.prev ? state.context.prev.line.indent : lineIndent; + + if (cx.prev && + (ch == "}" && (cx.type == "block" || cx.type == "atBlock" || cx.type == "keyframes") || + ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") || + ch == "{" && (cx.type == "at"))) { + indent = cx.indent - indentUnit; + cx = cx.prev; + } else if (!(/(\})/.test(ch))) { + if (/@|\$|\d/.test(ch) || + /^\{/.test(textAfter) || +/^\s*\/(\/|\*)/.test(textAfter) || + /^\s*\/\*/.test(prevLineFirstWord) || + /^\s*[\w-\.\[\]\'\"]+\s*(\?|:|\+)?=/i.test(textAfter) || +/^(\+|-)?[a-z][\w-]*\(/i.test(textAfter) || +/^return/.test(textAfter) || + wordIsBlock(lineFirstWord)) { + indent = lineIndent; + } else if (/(\.|#|:|\[|\*|&|>|~|\+|\/)/.test(ch) || wordIsTag(lineFirstWord)) { + if (/\,\s*$/.test(prevLineFirstWord)) { + indent = prevLineIndent; + } else if (/^\s+/.test(line) && (/(\.|#|:|\[|\*|&|>|~|\+|\/)/.test(prevLineFirstWord) || wordIsTag(prevLineFirstWord))) { + indent = lineIndent <= prevLineIndent ? prevLineIndent : prevLineIndent + indentUnit; + } else { + indent = lineIndent; + } + } else if (!/,\s*$/.test(line) && (wordIsVendorPrefix(lineFirstWord) || wordIsProperty(lineFirstWord))) { + if (wordIsBlock(prevLineFirstWord)) { + indent = lineIndent <= prevLineIndent ? prevLineIndent : prevLineIndent + indentUnit; + } else if (/^\{/.test(prevLineFirstWord)) { + indent = lineIndent <= prevLineIndent ? lineIndent : prevLineIndent + indentUnit; + } else if (wordIsVendorPrefix(prevLineFirstWord) || wordIsProperty(prevLineFirstWord)) { + indent = lineIndent >= prevLineIndent ? prevLineIndent : lineIndent; + } else if (/^(\.|#|:|\[|\*|&|@|\+|\-|>|~|\/)/.test(prevLineFirstWord) || + /=\s*$/.test(prevLineFirstWord) || + wordIsTag(prevLineFirstWord) || + /^\$[\w-\.\[\]\'\"]/.test(prevLineFirstWord)) { + indent = prevLineIndent + indentUnit; + } else { + indent = lineIndent; + } + } + } + return indent; + }, + electricChars: "}", + lineComment: "//", + fold: "indent" + }; }); - // https://developer.mozilla.org/en-US/docs/Web/HTML/Element - var cssTypeSelectors_ = ["a","abbr","address","area","article","aside","audio", "b", "base","bdi","bdo","bgsound","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","nobr","noframes","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]; - // https://github.com/csscomb/csscomb.js/blob/master/config/zen.json - var cssProperties_ = ["position","top","right","bottom","left","z-index","display","visibility","flex-direction","flex-order","flex-pack","float","clear","flex-align","overflow","overflow-x","overflow-y","overflow-scrolling","clip","box-sizing","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","min-width","min-height","max-width","max-height","width","height","outline","outline-width","outline-style","outline-color","outline-offset","border","border-spacing","border-collapse","border-width","border-style","border-color","border-top","border-top-width","border-top-style","border-top-color","border-right","border-right-width","border-right-style","border-right-color","border-bottom","border-bottom-width","border-bottom-style","border-bottom-color","border-left","border-left-width","border-left-style","border-left-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-right-radius","border-bottom-left-radius","border-image","border-image-source","border-image-slice","border-image-width","border-image-outset","border-image-repeat","border-top-image","border-right-image","border-bottom-image","border-left-image","border-corner-image","border-top-left-image","border-top-right-image","border-bottom-right-image","border-bottom-left-image","background","filter:progid:DXImageTransform\\.Microsoft\\.AlphaImageLoader","background-color","background-image","background-attachment","background-position","background-position-x","background-position-y","background-clip","background-origin","background-size","background-repeat","box-decoration-break","box-shadow","color","table-layout","caption-side","empty-cells","list-style","list-style-position","list-style-type","list-style-image","quotes","content","counter-increment","counter-reset","writing-mode","vertical-align","text-align","text-align-last","text-decoration","text-emphasis","text-emphasis-position","text-emphasis-style","text-emphasis-color","text-indent","-ms-text-justify","text-justify","text-outline","text-transform","text-wrap","text-overflow","text-overflow-ellipsis","text-overflow-mode","text-size-adjust","text-shadow","white-space","word-spacing","word-wrap","word-break","tab-size","hyphens","letter-spacing","font","font-weight","font-style","font-variant","font-size-adjust","font-stretch","font-size","font-family","src","line-height","opacity","filter:\\\\\\\\'progid:DXImageTransform.Microsoft.Alpha","filter:progid:DXImageTransform.Microsoft.Alpha\\(Opacity","interpolation-mode","filter","resize","cursor","nav-index","nav-up","nav-right","nav-down","nav-left","transition","transition-delay","transition-timing-function","transition-duration","transition-property","transform","transform-origin","animation","animation-name","animation-duration","animation-play-state","animation-timing-function","animation-delay","animation-iteration-count","animation-direction","pointer-events","unicode-bidi","direction","columns","column-span","column-width","column-count","column-fill","column-gap","column-rule","column-rule-width","column-rule-style","column-rule-color","break-before","break-inside","break-after","page-break-before","page-break-inside","page-break-after","orphans","widows","zoom","max-zoom","min-zoom","user-zoom","orientation","text-rendering","speak","animation-fill-mode","backface-visibility","user-drag","user-select","appearance"]; - // https://github.com/codemirror/CodeMirror/blob/master/mode/css/css.js#L501 - var cssValues_ = ["above","absolute","activeborder","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","cambodian","capitalize","caps-lock-indicator","captiontext","caret","cell","center","checkbox","circle","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","cover","crop","cross","crosshair","currentcolor","cursive","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ew-resize","expanded","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-table","inset","inside","intrinsic","invert","italic","justify","kannada","katakana","katakana-iroha","keep-all","khmer","landscape","lao","large","larger","left","level","lighter","line-through","linear","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","single","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","telugu","text","text-bottom","text-top","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","x-large","x-small","xor","xx-large","xx-small","bicubic","optimizespeed","grayscale"]; - var cssColorValues_ = ["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]; - var cssValuesWithBrackets_ = ["gradient","linear-gradient","radial-gradient","repeating-linear-gradient","repeating-radial-gradient","cubic-bezier","translateX","translateY","translate3d","rotate3d","scale","scale3d","perspective","skewX"]; - - var wordOperators = ["in", "and", "or", "not", "is a", "is", "isnt", "defined", "if unless"], - commonKeywords = ["for", "if", "else", "unless", "return"], - commonAtoms = ["null", "true", "false", "href", "title", "type", "not-allowed", "readonly", "disabled"], - commonDef = ["@font-face", "@keyframes", "@media", "@viewport", "@page", "@host", "@supports", "@block", "@css"], - cssTypeSelectors = keySet(cssTypeSelectors_), - cssProperties = keySet(cssProperties_), - cssValues = keySet(cssValues_.concat(cssColorValues_)), - hintWords = wordOperators.concat(commonKeywords, - commonAtoms, - commonDef, - cssTypeSelectors_, - cssProperties_, - cssValues_, - cssValuesWithBrackets_, - cssColorValues_); + // developer.mozilla.org/en-US/docs/Web/HTML/Element + var tagKeywords_ = ["a","abbr","address","area","article","aside","audio", "b", "base","bdi", "bdo","bgsound","blockquote","body","br","button","canvas","caption","cite", "code","col","colgroup","data","datalist","dd","del","details","dfn","div", "dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1", "h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe", "img","input","ins","kbd","keygen","label","legend","li","link","main","map", "mark","marquee","menu","menuitem","meta","meter","nav","nobr","noframes", "noscript","object","ol","optgroup","option","output","p","param","pre", "progress","q","rp","rt","ruby","s","samp","script","section","select", "small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track", "u","ul","var","video"]; + + // github.com/codemirror/CodeMirror/blob/master/mode/css/css.js + var documentTypes_ = ["domain", "regexp", "url", "url-prefix"]; + var mediaTypes_ = ["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"]; + var mediaFeatures_ = ["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"]; + var propertyKeywords_ = ["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode","font-smoothing","osx-font-smoothing"]; + var nonStandardPropertyKeywords_ = ["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"]; + var fontProperties_ = ["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"]; + var colorKeywords_ = ["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]; + var valueKeywords_ = ["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scale","scale3d","scaleX","scaleY","scaleZ","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","x-large","x-small","xor","xx-large","xx-small","bicubic","optimizespeed","grayscale"]; + + var wordOperatorKeywords_ = ["in","and","or","not","is not","is a","is","isnt","defined","if unless"], + blockKeywords_ = ["for","if","else","unless", "from", "to"], + commonAtoms_ = ["null","true","false","href","title","type","not-allowed","readonly","disabled"], + commonDef_ = ["@font-face", "@keyframes", "@media", "@viewport", "@page", "@host", "@supports", "@block", "@css"]; + + var hintWords = tagKeywords_.concat(documentTypes_,mediaTypes_,mediaFeatures_, + propertyKeywords_,nonStandardPropertyKeywords_, + colorKeywords_,valueKeywords_,fontProperties_, + wordOperatorKeywords_,blockKeywords_, + commonAtoms_,commonDef_); function wordRegexp(words) { + words = words.sort(function(a,b){return b > a;}); return new RegExp("^((" + words.join(")|(") + "))\\b"); - }; + } function keySet(array) { var keys = {}; - for (var i = 0; i < array.length; ++i) { - keys[array[i]] = true; - } + for (var i = 0; i < array.length; ++i) keys[array[i]] = true; return keys; - }; + } + + function escapeRegExp(text) { + return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); + } CodeMirror.registerHelper("hintWords", "stylus", hintWords); CodeMirror.defineMIME("text/x-styl", "stylus"); - }); From 866934b3b1b4c62ae4cf3ee3ecd640ab69acfc3d Mon Sep 17 00:00:00 2001 From: Dmitry Kiselyov Date: Mon, 16 Mar 2015 17:56:20 +0200 Subject: [PATCH 49/57] [stylus mode] Added tabSize and link to the author in demo page --- mode/stylus/index.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mode/stylus/index.html b/mode/stylus/index.html index 354bf30328..862c18f250 100644 --- a/mode/stylus/index.html +++ b/mode/stylus/index.html @@ -28,8 +28,9 @@

      Stylus mode