Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Codemirror v5.8

Borislav Sapundzhievf42104bd2b8d
diff --git a/data/ext/editorText/codemirror/codemirror.css b/data/ext/editorText/codemirror/codemirror.css
index 6cf5bae38..3543523e6 100644
--- a/data/ext/editorText/codemirror/codemirror.css
+++ b/data/ext/editorText/codemirror/codemirror.css
@@ -4,10 +4,7 @@
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
-}
-.CodeMirror-scroll {
- /* Set scrolling behaviour here */
- overflow: auto;
+ color: black;
}
/* PADDING */
@@ -36,30 +33,60 @@
min-width: 20px;
text-align: right;
color: #999;
- -moz-box-sizing: content-box;
- box-sizing: content-box;
+ white-space: nowrap;
}
+.CodeMirror-guttermarker { color: black; }
+.CodeMirror-guttermarker-subtle { color: #999; }
+
/* CURSOR */
-.CodeMirror div.CodeMirror-cursor {
+.CodeMirror-cursor {
border-left: 1px solid black;
- z-index: 3;
+ border-right: none;
+ width: 0;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
-.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
+.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0;
background: #7e7;
+}
+.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
+
+.cm-animate-fat-cursor {
+ width: auto;
+ border: 0;
+ -webkit-animation: blink 1.06s steps(1) infinite;
+ -moz-animation: blink 1.06s steps(1) infinite;
+ animation: blink 1.06s steps(1) infinite;
+ background-color: #7e7;
+}
+@-moz-keyframes blink {
+ 0% {}
+ 50% { background-color: transparent; }
+ 100% {}
+}
+@-webkit-keyframes blink {
+ 0% {}
+ 50% { background-color: transparent; }
+ 100% {}
+}
+@keyframes blink {
+ 0% {}
+ 50% { background-color: transparent; }
+ 100% {}
+}
+
/* Can style cursor different in overwrite (non-insert) mode */
-.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {}
+.CodeMirror-overwrite .CodeMirror-cursor {}
-.cm-tab { display: inline-block; }
+.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-ruler {
border-left: 1px solid #ccc;
@@ -68,6 +95,15 @@
/* DEFAULT THEME */
+.cm-s-default .cm-header {color: blue;}
+.cm-s-default .cm-quote {color: #090;}
+.cm-negative {color: #d44;}
+.cm-positive {color: #292;}
+.cm-header, .cm-strong {font-weight: bold;}
+.cm-em {font-style: italic;}
+.cm-link {text-decoration: underline;}
+.cm-strikethrough {text-decoration: line-through;}
+
.cm-s-default .cm-keyword {color: #708;}
.cm-s-default .cm-atom {color: #219;}
.cm-s-default .cm-number {color: #164;}
@@ -87,22 +123,19 @@
.cm-s-default .cm-bracket {color: #997;}
.cm-s-default .cm-tag {color: #170;}
.cm-s-default .cm-attribute {color: #00c;}
-.cm-s-default .cm-header {color: blue;}
-.cm-s-default .cm-quote {color: #090;}
.cm-s-default .cm-hr {color: #999;}
.cm-s-default .cm-link {color: #00c;}
-.cm-negative {color: #d44;}
-.cm-positive {color: #292;}
-.cm-header, .cm-strong {font-weight: bold;}
-.cm-em {font-style: italic;}
-.cm-link {text-decoration: underline;}
-
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
+.CodeMirror-composing { border-bottom: 2px solid; }
+
+/* Default styles for common addons */
+
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
+.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
@@ -111,14 +144,13 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
the editor. You probably shouldn't touch them. */
.CodeMirror {
- line-height: 1;
position: relative;
overflow: hidden;
background: white;
- color: black;
}
.CodeMirror-scroll {
+ overflow: scroll !important; /* Things will break if this is overridden */
/* 30px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -30px; margin-right: -30px;
@@ -126,14 +158,10 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
- -moz-box-sizing: content-box;
- box-sizing: content-box;
}
.CodeMirror-sizer {
position: relative;
border-right: 30px solid transparent;
- -moz-box-sizing: content-box;
- box-sizing: content-box;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
@@ -163,29 +191,42 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
- padding-bottom: 30px;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
- -moz-box-sizing: content-box;
- box-sizing: content-box;
- padding-bottom: 30px;
- margin-bottom: -32px;
display: inline-block;
+ margin-bottom: -30px;
/* Hack to make IE7 behave */
*zoom:1;
*display:inline;
}
+.CodeMirror-gutter-wrapper {
+ position: absolute;
+ z-index: 4;
+ background: none !important;
+ border: none !important;
+}
+.CodeMirror-gutter-background {
+ position: absolute;
+ top: 0; bottom: 0;
+ z-index: 4;
+}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
}
+.CodeMirror-gutter-wrapper {
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ user-select: none;
+}
.CodeMirror-lines {
cursor: text;
+ min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre {
/* Reset some styles that the rest of the page might have set */
@@ -202,6 +243,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
z-index: 2;
position: relative;
overflow: visible;
+ -webkit-tap-highlight-color: transparent;
}
.CodeMirror-wrap pre {
word-wrap: break-word;
@@ -223,8 +265,18 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-widget {}
-.CodeMirror-wrap .CodeMirror-scroll {
- overflow-x: hidden;
+.CodeMirror-code {
+ outline: none;
+}
+
+/* Force content-box sizing for the elements where we expect it */
+.CodeMirror-scroll,
+.CodeMirror-sizer,
+.CodeMirror-gutter,
+.CodeMirror-gutters,
+.CodeMirror-linenumber {
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
}
.CodeMirror-measure {
@@ -234,20 +286,28 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
overflow: hidden;
visibility: hidden;
}
+
+.CodeMirror-cursor { position: absolute; }
.CodeMirror-measure pre { position: static; }
-.CodeMirror div.CodeMirror-cursor {
- position: absolute;
+div.CodeMirror-cursors {
visibility: hidden;
- border-right: none;
- width: 0;
+ position: relative;
+ z-index: 3;
}
-.CodeMirror-focused div.CodeMirror-cursor {
+div.CodeMirror-dragcursors {
+ visibility: visible;
+}
+
+.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
+.CodeMirror-crosshair { cursor: crosshair; }
+.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
+.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
.cm-searching {
background: #ffa;
@@ -257,9 +317,18 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
.CodeMirror span { *vertical-align: text-bottom; }
+/* Used to force a border model for a node */
+.cm-force-border { padding-right: .1px; }
+
@media print {
/* Hide the cursor when printing */
- .CodeMirror div.CodeMirror-cursor {
+ .CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
}
+
+/* See issue #2901 */
+.cm-tab-wrap-hack:after { content: ''; }
+
+/* Help users use markselection to safely style text background */
+span.CodeMirror-selectedtext { background: none; }
diff --git a/data/ext/editorText/codemirror/codemirror.js b/data/ext/editorText/codemirror/codemirror.js
index 3d450b35a..e08dedea4 100644
--- a/data/ext/editorText/codemirror/codemirror.js
+++ b/data/ext/editorText/codemirror/codemirror.js
@@ -1,184 +1,214 @@
-// CodeMirror is the only global var we claim
-window.CodeMirror = (function() {
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// This is CodeMirror (http://codemirror.net), a code editor
+// implemented in JavaScript on top of the browser's DOM.
+//
+// You can find some technical background for some of the code below
+// at http://marijnhaverbeke.nl/blog/#cm-internals .
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ module.exports = mod();
+ else if (typeof define == "function" && define.amd) // AMD
+ return define([], mod);
+ else // Plain browser env
+ this.CodeMirror = mod();
+})(function() {
"use strict";
// BROWSER SNIFFING
- // Crude, but necessary to handle a number of hard-to-feature-detect
- // bugs and behavior differences.
- var gecko = /gecko\/\d/i.test(navigator.userAgent);
- // IE11 currently doesn't count as 'ie', since it has almost none of
- // the same bugs as earlier versions. Use ie_gt10 to handle
- // incompatibilities in that version.
- var old_ie = /MSIE \d/.test(navigator.userAgent);
- var ie_lt8 = old_ie && (document.documentMode == null || document.documentMode < 8);
- var ie_lt9 = old_ie && (document.documentMode == null || document.documentMode < 9);
- var ie_lt10 = old_ie && (document.documentMode == null || document.documentMode < 10);
- var ie_gt10 = /Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent);
- var ie = old_ie || ie_gt10;
- var webkit = /WebKit\//.test(navigator.userAgent);
- var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
- var chrome = /Chrome\//.test(navigator.userAgent);
- var opera = /Opera\//.test(navigator.userAgent);
+ // Kludges for bugs and behavior differences that can't be feature
+ // detected are enabled based on userAgent etc sniffing.
+ var userAgent = navigator.userAgent;
+ var platform = navigator.platform;
+
+ var gecko = /gecko\/\d/i.test(userAgent);
+ var ie_upto10 = /MSIE \d/.test(userAgent);
+ var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
+ var ie = ie_upto10 || ie_11up;
+ var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
+ var webkit = /WebKit\//.test(userAgent);
+ var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
+ var chrome = /Chrome\//.test(userAgent);
+ var presto = /Opera\//.test(userAgent);
var safari = /Apple Computer/.test(navigator.vendor);
- var khtml = /KHTML\//.test(navigator.userAgent);
- var mac_geLion = /Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent);
- var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
- var phantom = /PhantomJS/.test(navigator.userAgent);
+ var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
+ var phantom = /PhantomJS/.test(userAgent);
- var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
+ var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
// This is woefully incomplete. Suggestions for alternative methods welcome.
- var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
- var mac = ios || /Mac/.test(navigator.platform);
- var windows = /win/i.test(navigator.platform);
+ var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
+ var mac = ios || /Mac/.test(platform);
+ var windows = /win/i.test(platform);
- var opera_version = opera && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
- if (opera_version) opera_version = Number(opera_version[1]);
- if (opera_version && opera_version >= 15) { opera = false; webkit = true; }
+ var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
+ if (presto_version) presto_version = Number(presto_version[1]);
+ if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
- var flipCtrlCmd = mac && (qtwebkit || opera && (opera_version == null || opera_version < 12.11));
- var captureMiddleClick = gecko || (ie && !ie_lt9);
+ var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
+ var captureRightClick = gecko || (ie && ie_version >= 9);
- // Optimize some code when these features are not used
+ // Optimize some code when these features are not used.
var sawReadOnlySpans = false, sawCollapsedSpans = false;
- // CONSTRUCTOR
+ // EDITOR CONSTRUCTOR
+
+ // A CodeMirror instance represents an editor. This is the object
+ // that user code is usually dealing with.
function CodeMirror(place, options) {
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
- this.options = options = options || {};
+ this.options = options = options ? copyObj(options) : {};
// Determine effective options based on given values and defaults.
- for (var opt in defaults) if (!options.hasOwnProperty(opt) && defaults.hasOwnProperty(opt))
- options[opt] = defaults[opt];
+ copyObj(defaults, options, false);
setGuttersForLineNumbers(options);
- var docStart = typeof options.value == "string" ? 0 : options.value.first;
- var display = this.display = makeDisplay(place, docStart);
+ var doc = options.value;
+ if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator);
+ this.doc = doc;
+
+ var input = new CodeMirror.inputStyles[options.inputStyle](this);
+ var display = this.display = new Display(place, doc, input);
display.wrapper.CodeMirror = this;
updateGutters(this);
- if (options.autofocus && !mobile) focusInput(this);
-
- this.state = {keyMaps: [],
- overlays: [],
- modeGen: 0,
- overwrite: false, focused: false,
- suppressEdits: false,
- pasteIncoming: false, cutIncoming: false,
- draggingText: false,
- highlight: new Delayed()};
-
themeChanged(this);
if (options.lineWrapping)
this.display.wrapper.className += " CodeMirror-wrap";
+ if (options.autofocus && !mobile) display.input.focus();
+ initScrollbars(this);
+
+ this.state = {
+ keyMaps: [], // stores maps added by addKeyMap
+ overlays: [], // highlighting overlays, as added by addOverlay
+ modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
+ overwrite: false,
+ delayingBlurEvent: false,
+ focused: false,
+ suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
+ pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
+ selectingText: false,
+ draggingText: false,
+ highlight: new Delayed(), // stores highlight worker timeout
+ keySeq: null, // Unfinished key sequence
+ specialChars: null
+ };
- var doc = options.value;
- if (typeof doc == "string") doc = new Doc(options.value, options.mode);
- operation(this, attachDoc)(this, doc);
+ var cm = this;
// Override magic textarea content restore that IE sometimes does
// on our hidden textarea on reload
- if (old_ie) setTimeout(bind(resetInput, this, true), 20);
+ if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
registerEventHandlers(this);
- // IE throws unspecified error in certain cases, when
- // trying to access activeElement before onload
- var hasFocus; try { hasFocus = (document.activeElement == display.input); } catch(e) { }
- if (hasFocus || (options.autofocus && !mobile)) setTimeout(bind(onFocus, this), 20);
- else onBlur(this);
+ ensureGlobalHandlers();
+
+ startOperation(this);
+ this.curOp.forceUpdate = true;
+ attachDoc(this, doc);
+
+ if ((options.autofocus && !mobile) || cm.hasFocus())
+ setTimeout(bind(onFocus, this), 20);
+ else
+ onBlur(this);
- operation(this, function() {
- for (var opt in optionHandlers)
- if (optionHandlers.propertyIsEnumerable(opt))
- optionHandlers[opt](this, options[opt], Init);
- for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
- })();
+ for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
+ optionHandlers[opt](this, options[opt], Init);
+ maybeUpdateLineNumberWidth(this);
+ if (options.finishInit) options.finishInit(this);
+ for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
+ endOperation(this);
+ // Suppress optimizelegibility in Webkit, since it breaks text
+ // measuring on line wrapping boundaries.
+ if (webkit && options.lineWrapping &&
+ getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
+ display.lineDiv.style.textRendering = "auto";
}
// DISPLAY CONSTRUCTOR
- function makeDisplay(place, docStart) {
- var d = {};
-
- var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
- if (webkit) input.style.width = "1000px";
- else input.setAttribute("wrap", "off");
- // if border: 0; -- iOS fails to open keyboard (issue #1287)
- if (ios) input.style.border = "1px solid black";
- input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off"); input.setAttribute("spellcheck", "false");
-
- // Wraps and hides input textarea
- d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
- // The actual fake scrollbars.
- d.scrollbarH = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
- d.scrollbarV = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
+ // The display handles the DOM integration, both for input reading
+ // and content drawing. It holds references to DOM nodes and
+ // display-related state.
+
+ function Display(place, doc, input) {
+ var d = this;
+ this.input = input;
+
+ // Covers bottom-right square when both scrollbars are present.
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
+ d.scrollbarFiller.setAttribute("cm-not-content", "true");
+ // Covers bottom of gutter when coverGutterNextToScrollbar is on
+ // and h scrollbar is present.
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
- // DIVs containing the selection and the actual code
+ d.gutterFiller.setAttribute("cm-not-content", "true");
+ // Will contain the actual code, positioned to cover the viewport.
d.lineDiv = elt("div", null, "CodeMirror-code");
+ // Elements are added to these to represent selection and cursors.
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
- // Blinky cursor, and element used to ensure cursor fits at the end of a line
- d.cursor = elt("div", "\u00a0", "CodeMirror-cursor");
- // Secondary cursor, shown when on a 'jump' in bi-directional text
- d.otherCursor = elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor");
- // Used to measure text size
+ d.cursorDiv = elt("div", null, "CodeMirror-cursors");
+ // A visibility: hidden element used to find the size of things.
d.measure = elt("div", null, "CodeMirror-measure");
+ // When lines outside of the viewport are measured, they are drawn in this.
+ d.lineMeasure = elt("div", null, "CodeMirror-measure");
// Wraps everything that needs to exist inside the vertically-padded coordinate system
- d.lineSpace = elt("div", [d.measure, d.selectionDiv, d.lineDiv, d.cursor, d.otherCursor],
- null, "position: relative; outline: none");
- // Moved around its parent to cover visible view
+ d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
+ null, "position: relative; outline: none");
+ // Moved around its parent to cover visible view.
d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
- // Set to the height of the text, causes scrolling
+ // Set to the height of the document, allowing scrolling.
d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
- // D is needed because behavior of elts with overflow: auto and padding is inconsistent across browsers
- d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerCutOff + "px; width: 1px;");
- // Will contain the gutters, if any
+ d.sizerWidth = null;
+ // Behavior of elts with overflow: auto and padding is
+ // inconsistent across browsers. This is used to ensure the
+ // scrollable area is big enough.
+ d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
+ // Will contain the gutters, if any.
d.gutters = elt("div", null, "CodeMirror-gutters");
d.lineGutter = null;
- // Provides scrolling
+ // Actual scrollable element.
d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
d.scroller.setAttribute("tabIndex", "-1");
// The element in which the editor lives.
- d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV,
- d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
- // Work around IE7 z-index bug
- if (ie_lt8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
- if (place.appendChild) place.appendChild(d.wrapper); else place(d.wrapper);
-
- // Needed to hide big blue blinking cursor on Mobile Safari
- if (ios) input.style.width = "0px";
- if (!webkit) d.scroller.draggable = true;
- // Needed to handle Tab key in KHTML
- if (khtml) { d.inputDiv.style.height = "1px"; d.inputDiv.style.position = "absolute"; }
- // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
- else if (ie_lt8) d.scrollbarH.style.minWidth = d.scrollbarV.style.minWidth = "18px";
-
- // Current visible range (may be bigger than the view window).
- d.viewOffset = d.lastSizeC = 0;
- d.showingFrom = d.showingTo = docStart;
+ d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
+
+ // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
+ if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
+ if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
+
+ if (place) {
+ if (place.appendChild) place.appendChild(d.wrapper);
+ else place(d.wrapper);
+ }
+
+ // Current rendered range (may be bigger than the view window).
+ d.viewFrom = d.viewTo = doc.first;
+ d.reportedViewFrom = d.reportedViewTo = doc.first;
+ // Information about the rendered lines.
+ d.view = [];
+ d.renderedView = null;
+ // Holds info about a single rendered line when it was rendered
+ // for measurement, while not in view.
+ d.externalMeasured = null;
+ // Empty space (in pixels) above the view
+ d.viewOffset = 0;
+ d.lastWrapHeight = d.lastWrapWidth = 0;
+ d.updateLineNumbers = null;
+
+ d.nativeBarWidth = d.barHeight = d.barWidth = 0;
+ d.scrollbarsClipped = false;
// Used to only resize the line number gutter when necessary (when
// the amount of lines crosses a boundary that makes its width change)
d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
- // See readInput and resetInput
- d.prevInput = "";
- // Set to true when a non-horizontal-scrolling widget is added. As
- // an optimization, widget aligning is skipped when d is false.
+ // Set to true when a non-horizontal-scrolling line widget is
+ // added. As an optimization, line widget aligning is skipped when
+ // this is false.
d.alignWidgets = false;
- // Flag that indicates whether we currently expect input to appear
- // (after some event like 'keypress' or 'input') and are polling
- // intensively.
- d.pollingFast = false;
- // Self-resetting timeout for the poller
- d.poll = new Delayed();
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
- d.measureLineCache = [];
- d.measureLineCachePos = 0;
-
- // Tracks when resetInput has punted to just putting a short
- // string instead of the (large) selection.
- d.inaccurateSelection = false;
// Tracks the maximum line length so that the horizontal scrollbar
// can be kept static when scrolling.
@@ -189,7 +219,16 @@ window.CodeMirror = (function() {
// Used for measuring wheel scrolling granularity
d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
- return d;
+ // True when shift is held down.
+ d.shift = false;
+
+ // Used to track whether anything happened since the context menu
+ // was opened.
+ d.selForContextMenu = null;
+
+ d.activeTouch = null;
+
+ input.init(d);
}
// STATE UPDATES
@@ -214,11 +253,12 @@ window.CodeMirror = (function() {
function wrappingChanged(cm) {
if (cm.options.lineWrapping) {
- cm.display.wrapper.className += " CodeMirror-wrap";
+ addClass(cm.display.wrapper, "CodeMirror-wrap");
cm.display.sizer.style.minWidth = "";
+ cm.display.sizerWidth = null;
} else {
- cm.display.wrapper.className = cm.display.wrapper.className.replace(" CodeMirror-wrap", "");
- computeMaxLength(cm);
+ rmClass(cm.display.wrapper, "CodeMirror-wrap");
+ findMaxLine(cm);
}
estimateLineHeights(cm);
regChange(cm);
@@ -226,6 +266,9 @@ window.CodeMirror = (function() {
setTimeout(function(){updateScrollbars(cm);}, 100);
}
+ // Returns a function that estimates the height of a line, to use as
+ // first approximation until the line becomes visible (and is thus
+ // properly measurable).
function estimateHeight(cm) {
var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
@@ -252,12 +295,6 @@ window.CodeMirror = (function() {
});
}
- function keyMapChanged(cm) {
- var map = keyMap[cm.options.keyMap], style = map.style;
- cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-keymap-\S+/g, "") +
- (style ? " cm-keymap-" + style : "");
- }
-
function themeChanged(cm) {
cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
@@ -270,6 +307,8 @@ window.CodeMirror = (function() {
setTimeout(function(){alignHorizontally(cm);}, 20);
}
+ // Rebuild the gutter elements, ensure the margin to the left of the
+ // code matches their width.
function updateGutters(cm) {
var gutters = cm.display.gutters, specs = cm.options.gutters;
removeChildren(gutters);
@@ -282,33 +321,43 @@ window.CodeMirror = (function() {
}
}
gutters.style.display = i ? "" : "none";
+ updateGutterSpace(cm);
+ }
+
+ function updateGutterSpace(cm) {
+ var width = cm.display.gutters.offsetWidth;
+ cm.display.sizer.style.marginLeft = width + "px";
}
- function lineLength(doc, line) {
+ // Compute the character length of a line, taking into account
+ // collapsed ranges (see markText) that might hide parts, and join
+ // other lines onto it.
+ function lineLength(line) {
if (line.height == 0) return 0;
var len = line.text.length, merged, cur = line;
while (merged = collapsedSpanAtStart(cur)) {
- var found = merged.find();
- cur = getLine(doc, found.from.line);
+ var found = merged.find(0, true);
+ cur = found.from.line;
len += found.from.ch - found.to.ch;
}
cur = line;
while (merged = collapsedSpanAtEnd(cur)) {
- var found = merged.find();
+ var found = merged.find(0, true);
len -= cur.text.length - found.from.ch;
- cur = getLine(doc, found.to.line);
+ cur = found.to.line;
len += cur.text.length - found.to.ch;
}
return len;
}
- function computeMaxLength(cm) {
+ // Find the longest line in the document.
+ function findMaxLine(cm) {
var d = cm.display, doc = cm.doc;
d.maxLine = getLine(doc, doc.first);
- d.maxLineLength = lineLength(doc, d.maxLine);
+ d.maxLineLength = lineLength(d.maxLine);
d.maxLineChanged = true;
doc.iter(function(line) {
- var len = lineLength(doc, line);
+ var len = lineLength(line);
if (len > d.maxLineLength) {
d.maxLineLength = len;
d.maxLine = line;
@@ -330,79 +379,216 @@ window.CodeMirror = (function() {
// SCROLLBARS
- // Re-synchronize the fake scrollbars with the actual size of the
- // content. Optionally force a scrollTop.
- function updateScrollbars(cm) {
- var d = cm.display, docHeight = cm.doc.height;
- var totalHeight = docHeight + paddingVert(d);
- d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
- d.gutters.style.height = Math.max(totalHeight, d.scroller.clientHeight - scrollerCutOff) + "px";
- var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
- var needsH = d.scroller.scrollWidth > d.scroller.clientWidth;
- var needsV = scrollHeight > d.scroller.clientHeight;
- if (needsV) {
- d.scrollbarV.style.display = "block";
- d.scrollbarV.style.bottom = needsH ? scrollbarWidth(d.measure) + "px" : "0";
- // A bug in IE8 can cause this value to be negative, so guard it.
- d.scrollbarV.firstChild.style.height =
- Math.max(0, scrollHeight - d.scroller.clientHeight + d.scrollbarV.clientHeight) + "px";
- } else {
- d.scrollbarV.style.display = "";
- d.scrollbarV.firstChild.style.height = "0";
- }
- if (needsH) {
- d.scrollbarH.style.display = "block";
- d.scrollbarH.style.right = needsV ? scrollbarWidth(d.measure) + "px" : "0";
- d.scrollbarH.firstChild.style.width =
- (d.scroller.scrollWidth - d.scroller.clientWidth + d.scrollbarH.clientWidth) + "px";
- } else {
- d.scrollbarH.style.display = "";
- d.scrollbarH.firstChild.style.width = "0";
+ // Prepare DOM reads needed to update the scrollbars. Done in one
+ // shot to minimize update/measure roundtrips.
+ function measureForScrollbars(cm) {
+ var d = cm.display, gutterW = d.gutters.offsetWidth;
+ var docH = Math.round(cm.doc.height + paddingVert(cm.display));
+ return {
+ clientHeight: d.scroller.clientHeight,
+ viewHeight: d.wrapper.clientHeight,
+ scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
+ viewWidth: d.wrapper.clientWidth,
+ barLeft: cm.options.fixedGutter ? gutterW : 0,
+ docHeight: docH,
+ scrollHeight: docH + scrollGap(cm) + d.barHeight,
+ nativeBarWidth: d.nativeBarWidth,
+ gutterWidth: gutterW
+ };
+ }
+
+ function NativeScrollbars(place, scroll, cm) {
+ this.cm = cm;
+ var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
+ var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
+ place(vert); place(horiz);
+
+ on(vert, "scroll", function() {
+ if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
+ });
+ on(horiz, "scroll", function() {
+ if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
+ });
+
+ this.checkedOverlay = false;
+ // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
+ if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
+ }
+
+ NativeScrollbars.prototype = copyObj({
+ update: function(measure) {
+ var needsH = measure.scrollWidth > measure.clientWidth + 1;
+ var needsV = measure.scrollHeight > measure.clientHeight + 1;
+ var sWidth = measure.nativeBarWidth;
+
+ if (needsV) {
+ this.vert.style.display = "block";
+ this.vert.style.bottom = needsH ? sWidth + "px" : "0";
+ var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
+ // A bug in IE8 can cause this value to be negative, so guard it.
+ this.vert.firstChild.style.height =
+ Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
+ } else {
+ this.vert.style.display = "";
+ this.vert.firstChild.style.height = "0";
+ }
+
+ if (needsH) {
+ this.horiz.style.display = "block";
+ this.horiz.style.right = needsV ? sWidth + "px" : "0";
+ this.horiz.style.left = measure.barLeft + "px";
+ var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
+ this.horiz.firstChild.style.width =
+ (measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
+ } else {
+ this.horiz.style.display = "";
+ this.horiz.firstChild.style.width = "0";
+ }
+
+ if (!this.checkedOverlay && measure.clientHeight > 0) {
+ if (sWidth == 0) this.overlayHack();
+ this.checkedOverlay = true;
+ }
+
+ return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
+ },
+ setScrollLeft: function(pos) {
+ if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
+ },
+ setScrollTop: function(pos) {
+ if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
+ },
+ overlayHack: function() {
+ var w = mac && !mac_geMountainLion ? "12px" : "18px";
+ this.horiz.style.minHeight = this.vert.style.minWidth = w;
+ var self = this;
+ var barMouseDown = function(e) {
+ if (e_target(e) != self.vert && e_target(e) != self.horiz)
+ operation(self.cm, onMouseDown)(e);
+ };
+ on(this.vert, "mousedown", barMouseDown);
+ on(this.horiz, "mousedown", barMouseDown);
+ },
+ clear: function() {
+ var parent = this.horiz.parentNode;
+ parent.removeChild(this.horiz);
+ parent.removeChild(this.vert);
}
- if (needsH && needsV) {
+ }, NativeScrollbars.prototype);
+
+ function NullScrollbars() {}
+
+ NullScrollbars.prototype = copyObj({
+ update: function() { return {bottom: 0, right: 0}; },
+ setScrollLeft: function() {},
+ setScrollTop: function() {},
+ clear: function() {}
+ }, NullScrollbars.prototype);
+
+ CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
+
+ function initScrollbars(cm) {
+ if (cm.display.scrollbars) {
+ cm.display.scrollbars.clear();
+ if (cm.display.scrollbars.addClass)
+ rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
+ }
+
+ cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
+ cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
+ // Prevent clicks in the scrollbars from killing focus
+ on(node, "mousedown", function() {
+ if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
+ });
+ node.setAttribute("cm-not-content", "true");
+ }, function(pos, axis) {
+ if (axis == "horizontal") setScrollLeft(cm, pos);
+ else setScrollTop(cm, pos);
+ }, cm);
+ if (cm.display.scrollbars.addClass)
+ addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
+ }
+
+ function updateScrollbars(cm, measure) {
+ if (!measure) measure = measureForScrollbars(cm);
+ var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
+ updateScrollbarsInner(cm, measure);
+ for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
+ if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
+ updateHeightsInViewport(cm);
+ updateScrollbarsInner(cm, measureForScrollbars(cm));
+ startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
+ }
+ }
+
+ // Re-synchronize the fake scrollbars with the actual size of the
+ // content.
+ function updateScrollbarsInner(cm, measure) {
+ var d = cm.display;
+ var sizes = d.scrollbars.update(measure);
+
+ d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
+ d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
+
+ if (sizes.right && sizes.bottom) {
d.scrollbarFiller.style.display = "block";
- d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px";
+ d.scrollbarFiller.style.height = sizes.bottom + "px";
+ d.scrollbarFiller.style.width = sizes.right + "px";
} else d.scrollbarFiller.style.display = "";
- if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
+ if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
d.gutterFiller.style.display = "block";
- d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px";
- d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
+ d.gutterFiller.style.height = sizes.bottom + "px";
+ d.gutterFiller.style.width = measure.gutterWidth + "px";
} else d.gutterFiller.style.display = "";
-
- if (mac_geLion && scrollbarWidth(d.measure) === 0) {
- d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
- var barMouseDown = function(e) {
- if (e_target(e) != d.scrollbarV && e_target(e) != d.scrollbarH)
- operation(cm, onMouseDown)(e);
- };
- on(d.scrollbarV, "mousedown", barMouseDown);
- on(d.scrollbarH, "mousedown", barMouseDown);
- }
}
- function visibleLines(display, doc, viewPort) {
- var top = display.scroller.scrollTop, height = display.wrapper.clientHeight;
- if (typeof viewPort == "number") top = viewPort;
- else if (viewPort) {top = viewPort.top; height = viewPort.bottom - viewPort.top;}
+ // Compute the lines that are visible in a given viewport (defaults
+ // the the current scroll position). viewport may contain top,
+ // height, and ensure (see op.scrollToPos) properties.
+ function visibleLines(display, doc, viewport) {
+ var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
top = Math.floor(top - paddingTop(display));
- var bottom = Math.ceil(top + height);
- return {from: lineAtHeight(doc, top), to: lineAtHeight(doc, bottom)};
+ var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
+
+ var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
+ // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
+ // forces those lines into the viewport (if possible).
+ if (viewport && viewport.ensure) {
+ var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
+ if (ensureFrom < from) {
+ from = ensureFrom;
+ to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
+ } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
+ from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
+ to = ensureTo;
+ }
+ }
+ return {from: from, to: Math.max(to, from + 1)};
}
// LINE NUMBERS
+ // Re-align line numbers and gutter marks to compensate for
+ // horizontal scrolling.
function alignHorizontally(cm) {
- var display = cm.display;
+ var display = cm.display, view = display.view;
if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
- var gutterW = display.gutters.offsetWidth, l = comp + "px";
- for (var n = display.lineDiv.firstChild; n; n = n.nextSibling) if (n.alignable) {
- for (var i = 0, a = n.alignable; i < a.length; ++i) a[i].style.left = l;
+ var gutterW = display.gutters.offsetWidth, left = comp + "px";
+ for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
+ if (cm.options.fixedGutter && view[i].gutter)
+ view[i].gutter.style.left = left;
+ var align = view[i].alignable;
+ if (align) for (var j = 0; j < align.length; j++)
+ align[j].style.left = left;
}
if (cm.options.fixedGutter)
display.gutters.style.left = (comp + gutterW) + "px";
}
+ // Used to ensure that the line number gutter is still the right
+ // size for the current document size. Returns true when an update
+ // is needed.
function maybeUpdateLineNumberWidth(cm) {
if (!cm.options.lineNumbers) return false;
var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
@@ -411,10 +597,11 @@ window.CodeMirror = (function() {
"CodeMirror-linenumber CodeMirror-gutter-elt"));
var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
display.lineGutter.style.width = "";
- display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding);
+ display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
display.lineNumWidth = display.lineNumInnerWidth + padding;
display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
display.lineGutter.style.width = display.lineNumWidth + "px";
+ updateGutterSpace(cm);
return true;
}
return false;
@@ -423,197 +610,216 @@ window.CodeMirror = (function() {
function lineNumberFor(options, i) {
return String(options.lineNumberFormatter(i + options.firstLineNumber));
}
+
+ // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
+ // but using getBoundingClientRect to get a sub-pixel-accurate
+ // result.
function compensateForHScroll(display) {
- return getRect(display.scroller).left - getRect(display.sizer).left;
+ return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
}
// DISPLAY DRAWING
- function updateDisplay(cm, changes, viewPort, forced) {
- var oldFrom = cm.display.showingFrom, oldTo = cm.display.showingTo, updated;
- var visible = visibleLines(cm.display, cm.doc, viewPort);
- for (var first = true;; first = false) {
- var oldWidth = cm.display.scroller.clientWidth;
- if (!updateDisplayInner(cm, changes, visible, forced)) break;
- updated = true;
- changes = [];
- updateSelection(cm);
- updateScrollbars(cm);
- if (first && cm.options.lineWrapping && oldWidth != cm.display.scroller.clientWidth) {
- forced = true;
- continue;
- }
- forced = false;
+ function DisplayUpdate(cm, viewport, force) {
+ var display = cm.display;
- // Clip forced viewport to actual scrollable area
- if (viewPort)
- viewPort = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight,
- typeof viewPort == "number" ? viewPort : viewPort.top);
- visible = visibleLines(cm.display, cm.doc, viewPort);
- if (visible.from >= cm.display.showingFrom && visible.to <= cm.display.showingTo)
- break;
- }
+ this.viewport = viewport;
+ // Store some values that we'll need later (but don't want to force a relayout for)
+ this.visible = visibleLines(display, cm.doc, viewport);
+ this.editorIsHidden = !display.wrapper.offsetWidth;
+ this.wrapperHeight = display.wrapper.clientHeight;
+ this.wrapperWidth = display.wrapper.clientWidth;
+ this.oldDisplayWidth = displayWidth(cm);
+ this.force = force;
+ this.dims = getDimensions(cm);
+ this.events = [];
+ }
+
+ DisplayUpdate.prototype.signal = function(emitter, type) {
+ if (hasHandler(emitter, type))
+ this.events.push(arguments);
+ };
+ DisplayUpdate.prototype.finish = function() {
+ for (var i = 0; i < this.events.length; i++)
+ signal.apply(null, this.events[i]);
+ };
- if (updated) {
- signalLater(cm, "update", cm);
- if (cm.display.showingFrom != oldFrom || cm.display.showingTo != oldTo)
- signalLater(cm, "viewportChange", cm, cm.display.showingFrom, cm.display.showingTo);
+ function maybeClipScrollbars(cm) {
+ var display = cm.display;
+ if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
+ display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
+ display.heightForcer.style.height = scrollGap(cm) + "px";
+ display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
+ display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
+ display.scrollbarsClipped = true;
}
- return updated;
}
- // Uses a set of changes plus the current scroll position to
- // determine which DOM updates have to be made, and makes the
- // updates.
- function updateDisplayInner(cm, changes, visible, forced) {
+ // Does the actual updating of the line display. Bails out
+ // (returning false) when there is nothing to be done and forced is
+ // false.
+ function updateDisplayIfNeeded(cm, update) {
var display = cm.display, doc = cm.doc;
- if (!display.wrapper.offsetWidth) {
- display.showingFrom = display.showingTo = doc.first;
- display.viewOffset = 0;
- return;
+
+ if (update.editorIsHidden) {
+ resetView(cm);
+ return false;
}
// Bail out if the visible area is already rendered and nothing changed.
- if (!forced && changes.length == 0 &&
- visible.from > display.showingFrom && visible.to < display.showingTo)
- return;
-
- if (maybeUpdateLineNumberWidth(cm))
- changes = [{from: doc.first, to: doc.first + doc.size}];
- var gutterW = display.sizer.style.marginLeft = display.gutters.offsetWidth + "px";
- display.scrollbarH.style.left = cm.options.fixedGutter ? gutterW : "0";
+ if (!update.force &&
+ update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
+ (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
+ display.renderedView == display.view && countDirtyView(cm) == 0)
+ return false;
- // Used to determine which lines need their line numbers updated
- var positionsChangedFrom = Infinity;
- if (cm.options.lineNumbers)
- for (var i = 0; i < changes.length; ++i)
- if (changes[i].diff && changes[i].from < positionsChangedFrom) { positionsChangedFrom = changes[i].from; }
+ if (maybeUpdateLineNumberWidth(cm)) {
+ resetView(cm);
+ update.dims = getDimensions(cm);
+ }
+ // Compute a suitable new viewport (from & to)
var end = doc.first + doc.size;
- var from = Math.max(visible.from - cm.options.viewportMargin, doc.first);
- var to = Math.min(end, visible.to + cm.options.viewportMargin);
- if (display.showingFrom < from && from - display.showingFrom < 20) from = Math.max(doc.first, display.showingFrom);
- if (display.showingTo > to && display.showingTo - to < 20) to = Math.min(end, display.showingTo);
+ var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
+ var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
+ if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
+ if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
if (sawCollapsedSpans) {
- from = lineNo(visualLine(doc, getLine(doc, from)));
- while (to < end && lineIsHidden(doc, getLine(doc, to))) ++to;
- }
-
- // Create a range of theoretically intact lines, and punch holes
- // in that using the change info.
- var intact = [{from: Math.max(display.showingFrom, doc.first),
- to: Math.min(display.showingTo, end)}];
- if (intact[0].from >= intact[0].to) intact = [];
- else intact = computeIntact(intact, changes);
- // When merged lines are present, we might have to reduce the
- // intact ranges because changes in continued fragments of the
- // intact lines do require the lines to be redrawn.
- if (sawCollapsedSpans)
- for (var i = 0; i < intact.length; ++i) {
- var range = intact[i], merged;
- while (merged = collapsedSpanAtEnd(getLine(doc, range.to - 1))) {
- var newTo = merged.find().from.line;
- if (newTo > range.from) range.to = newTo;
- else { intact.splice(i--, 1); break; }
- }
- }
-
- // Clip off the parts that won't be visible
- var intactLines = 0;
- for (var i = 0; i < intact.length; ++i) {
- var range = intact[i];
- if (range.from < from) range.from = from;
- if (range.to > to) range.to = to;
- if (range.from >= range.to) intact.splice(i--, 1);
- else intactLines += range.to - range.from;
- }
- if (!forced && intactLines == to - from && from == display.showingFrom && to == display.showingTo) {
- updateViewOffset(cm);
- return;
+ from = visualLineNo(cm.doc, from);
+ to = visualLineEndNo(cm.doc, to);
}
- intact.sort(function(a, b) {return a.from - b.from;});
- // Avoid crashing on IE's "unspecified error" when in iframes
- try {
- var focused = document.activeElement;
- } catch(e) {}
- if (intactLines < (to - from) * .7) display.lineDiv.style.display = "none";
- patchDisplay(cm, from, to, intact, positionsChangedFrom);
- display.lineDiv.style.display = "";
- if (focused && document.activeElement != focused && focused.offsetHeight) focused.focus();
-
- var different = from != display.showingFrom || to != display.showingTo ||
- display.lastSizeC != display.wrapper.clientHeight;
- // This is just a bogus formula that detects when the editor is
- // resized or the font size changes.
+ var different = from != display.viewFrom || to != display.viewTo ||
+ display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
+ adjustView(cm, from, to);
+
+ display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
+ // Position the mover div to align with the current scroll position
+ cm.display.mover.style.top = display.viewOffset + "px";
+
+ var toUpdate = countDirtyView(cm);
+ if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
+ (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
+ return false;
+
+ // For big changes, we hide the enclosing element during the
+ // update, since that speeds up the operations on most browsers.
+ var focused = activeElt();
+ if (toUpdate > 4) display.lineDiv.style.display = "none";
+ patchDisplay(cm, display.updateLineNumbers, update.dims);
+ if (toUpdate > 4) display.lineDiv.style.display = "";
+ display.renderedView = display.view;
+ // There might have been a widget with a focused element that got
+ // hidden or updated, if so re-focus it.
+ if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
+
+ // Prevent selection and cursors from interfering with the scroll
+ // width and height.
+ removeChildren(display.cursorDiv);
+ removeChildren(display.selectionDiv);
+ display.gutters.style.height = display.sizer.style.minHeight = 0;
+
if (different) {
- display.lastSizeC = display.wrapper.clientHeight;
+ display.lastWrapHeight = update.wrapperHeight;
+ display.lastWrapWidth = update.wrapperWidth;
startWorker(cm, 400);
}
- display.showingFrom = from; display.showingTo = to;
- display.gutters.style.height = "";
- updateHeightsInViewport(cm);
- updateViewOffset(cm);
+ display.updateLineNumbers = null;
return true;
}
+ function postUpdateDisplay(cm, update) {
+ var viewport = update.viewport;
+ for (var first = true;; first = false) {
+ if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
+ // Clip forced viewport to actual scrollable area.
+ if (viewport && viewport.top != null)
+ viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
+ // Updated line heights might result in the drawn area not
+ // actually covering the viewport. Keep looping until it does.
+ update.visible = visibleLines(cm.display, cm.doc, viewport);
+ if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
+ break;
+ }
+ if (!updateDisplayIfNeeded(cm, update)) break;
+ updateHeightsInViewport(cm);
+ var barMeasure = measureForScrollbars(cm);
+ updateSelection(cm);
+ setDocumentHeight(cm, barMeasure);
+ updateScrollbars(cm, barMeasure);
+ }
+
+ update.signal(cm, "update", cm);
+ if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
+ update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
+ cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
+ }
+ }
+
+ function updateDisplaySimple(cm, viewport) {
+ var update = new DisplayUpdate(cm, viewport);
+ if (updateDisplayIfNeeded(cm, update)) {
+ updateHeightsInViewport(cm);
+ postUpdateDisplay(cm, update);
+ var barMeasure = measureForScrollbars(cm);
+ updateSelection(cm);
+ setDocumentHeight(cm, barMeasure);
+ updateScrollbars(cm, barMeasure);
+ update.finish();
+ }
+ }
+
+ function setDocumentHeight(cm, measure) {
+ cm.display.sizer.style.minHeight = measure.docHeight + "px";
+ var total = measure.docHeight + cm.display.barHeight;
+ cm.display.heightForcer.style.top = total + "px";
+ cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px";
+ }
+
+ // Read the actual heights of the rendered lines, and update their
+ // stored heights to match.
function updateHeightsInViewport(cm) {
var display = cm.display;
var prevBottom = display.lineDiv.offsetTop;
- for (var node = display.lineDiv.firstChild, height; node; node = node.nextSibling) if (node.lineObj) {
- if (ie_lt8) {
- var bot = node.offsetTop + node.offsetHeight;
+ for (var i = 0; i < display.view.length; i++) {
+ var cur = display.view[i], height;
+ if (cur.hidden) continue;
+ if (ie && ie_version < 8) {
+ var bot = cur.node.offsetTop + cur.node.offsetHeight;
height = bot - prevBottom;
prevBottom = bot;
} else {
- var box = getRect(node);
+ var box = cur.node.getBoundingClientRect();
height = box.bottom - box.top;
}
- var diff = node.lineObj.height - height;
+ var diff = cur.line.height - height;
if (height < 2) height = textHeight(display);
if (diff > .001 || diff < -.001) {
- updateLineHeight(node.lineObj, height);
- var widgets = node.lineObj.widgets;
- if (widgets) for (var i = 0; i < widgets.length; ++i)
- widgets[i].height = widgets[i].node.offsetHeight;
+ updateLineHeight(cur.line, height);
+ updateWidgetHeight(cur.line);
+ if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
+ updateWidgetHeight(cur.rest[j]);
}
}
}
- function updateViewOffset(cm) {
- var off = cm.display.viewOffset = heightAtLine(cm, getLine(cm.doc, cm.display.showingFrom));
- // Position the mover div to align with the current virtual scroll position
- cm.display.mover.style.top = off + "px";
- }
-
- function computeIntact(intact, changes) {
- for (var i = 0, l = changes.length || 0; i < l; ++i) {
- var change = changes[i], intact2 = [], diff = change.diff || 0;
- for (var j = 0, l2 = intact.length; j < l2; ++j) {
- var range = intact[j];
- if (change.to <= range.from && change.diff) {
- intact2.push({from: range.from + diff, to: range.to + diff});
- } else if (change.to <= range.from || change.from >= range.to) {
- intact2.push(range);
- } else {
- if (change.from > range.from)
- intact2.push({from: range.from, to: change.from});
- if (change.to < range.to)
- intact2.push({from: change.to + diff, to: range.to + diff});
- }
- }
- intact = intact2;
- }
- return intact;
+ // Read and store the height of line widgets associated with the
+ // given line.
+ function updateWidgetHeight(line) {
+ if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
+ line.widgets[i].height = line.widgets[i].node.offsetHeight;
}
+ // Do a bulk-read of the DOM positions and sizes needed to draw the
+ // view, so that we don't interleave reading and writing to the DOM.
function getDimensions(cm) {
var d = cm.display, left = {}, width = {};
+ var gutterLeft = d.gutters.clientLeft;
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
- left[cm.options.gutters[i]] = n.offsetLeft;
- width[cm.options.gutters[i]] = n.offsetWidth;
+ left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
+ width[cm.options.gutters[i]] = n.clientWidth;
}
return {fixedPos: compensateForHScroll(d),
gutterTotalWidth: d.gutters.offsetWidth,
@@ -622,218 +828,1500 @@ window.CodeMirror = (function() {
wrapperWidth: d.wrapper.clientWidth};
}
- function patchDisplay(cm, from, to, intact, updateNumbersFrom) {
- var dims = getDimensions(cm);
+ // Sync the actual display DOM structure with display.view, removing
+ // nodes for lines that are no longer in view, and creating the ones
+ // that are not there yet, and updating the ones that are out of
+ // date.
+ function patchDisplay(cm, updateNumbersFrom, dims) {
var display = cm.display, lineNumbers = cm.options.lineNumbers;
- if (!intact.length && (!webkit || !cm.display.currentWheelTarget))
- removeChildren(display.lineDiv);
var container = display.lineDiv, cur = container.firstChild;
function rm(node) {
var next = node.nextSibling;
- if (webkit && mac && cm.display.currentWheelTarget == node) {
+ // Works around a throw-scroll bug in OS X Webkit
+ if (webkit && mac && cm.display.currentWheelTarget == node)
node.style.display = "none";
- node.lineObj = null;
- } else {
+ else
node.parentNode.removeChild(node);
- }
return next;
}
- var nextIntact = intact.shift(), lineN = from;
- cm.doc.iter(from, to, function(line) {
- if (nextIntact && nextIntact.to == lineN) nextIntact = intact.shift();
- if (lineIsHidden(cm.doc, line)) {
- if (line.height != 0) updateLineHeight(line, 0);
- if (line.widgets && cur && cur.previousSibling) for (var i = 0; i < line.widgets.length; ++i) {
- var w = line.widgets[i];
- if (w.showIfHidden) {
- var prev = cur.previousSibling;
- if (/pre/i.test(prev.nodeName)) {
- var wrap = elt("div", null, null, "position: relative");
- prev.parentNode.replaceChild(wrap, prev);
- wrap.appendChild(prev);
- prev = wrap;
- }
- var wnode = prev.appendChild(elt("div", [w.node], "CodeMirror-linewidget"));
- if (!w.handleMouseEvents) wnode.ignoreEvents = true;
- positionLineWidget(w, wnode, prev, dims);
+ var view = display.view, lineN = display.viewFrom;
+ // Loop over the elements in the view, syncing cur (the DOM nodes
+ // in display.lineDiv) with the view as we go.
+ for (var i = 0; i < view.length; i++) {
+ var lineView = view[i];
+ if (lineView.hidden) {
+ } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
+ var node = buildLineElement(cm, lineView, lineN, dims);
+ container.insertBefore(node, cur);
+ } else { // Already drawn
+ while (cur != lineView.node) cur = rm(cur);
+ var updateNumber = lineNumbers && updateNumbersFrom != null &&
+ updateNumbersFrom <= lineN && lineView.lineNumber;
+ if (lineView.changes) {
+ if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
+ updateLineForChanges(cm, lineView, lineN, dims);
+ }
+ if (updateNumber) {
+ removeChildren(lineView.lineNumber);
+ lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
+ }
+ cur = lineView.node.nextSibling;
+ }
+ lineN += lineView.size;
+ }
+ while (cur) cur = rm(cur);
+ }
+
+ // When an aspect of a line changes, a string is added to
+ // lineView.changes. This updates the relevant part of the line's
+ // DOM structure.
+ function updateLineForChanges(cm, lineView, lineN, dims) {
+ for (var j = 0; j < lineView.changes.length; j++) {
+ var type = lineView.changes[j];
+ if (type == "text") updateLineText(cm, lineView);
+ else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
+ else if (type == "class") updateLineClasses(lineView);
+ else if (type == "widget") updateLineWidgets(cm, lineView, dims);
+ }
+ lineView.changes = null;
+ }
+
+ // Lines with gutter elements, widgets or a background class need to
+ // be wrapped, and have the extra elements added to the wrapper div
+ function ensureLineWrapped(lineView) {
+ if (lineView.node == lineView.text) {
+ lineView.node = elt("div", null, null, "position: relative");
+ if (lineView.text.parentNode)
+ lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
+ lineView.node.appendChild(lineView.text);
+ if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
+ }
+ return lineView.node;
+ }
+
+ function updateLineBackground(lineView) {
+ var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
+ if (cls) cls += " CodeMirror-linebackground";
+ if (lineView.background) {
+ if (cls) lineView.background.className = cls;
+ else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
+ } else if (cls) {
+ var wrap = ensureLineWrapped(lineView);
+ lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
+ }
+ }
+
+ // Wrapper around buildLineContent which will reuse the structure
+ // in display.externalMeasured when possible.
+ function getLineContent(cm, lineView) {
+ var ext = cm.display.externalMeasured;
+ if (ext && ext.line == lineView.line) {
+ cm.display.externalMeasured = null;
+ lineView.measure = ext.measure;
+ return ext.built;
+ }
+ return buildLineContent(cm, lineView);
+ }
+
+ // Redraw the line's text. Interacts with the background and text
+ // classes because the mode may output tokens that influence these
+ // classes.
+ function updateLineText(cm, lineView) {
+ var cls = lineView.text.className;
+ var built = getLineContent(cm, lineView);
+ if (lineView.text == lineView.node) lineView.node = built.pre;
+ lineView.text.parentNode.replaceChild(built.pre, lineView.text);
+ lineView.text = built.pre;
+ if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
+ lineView.bgClass = built.bgClass;
+ lineView.textClass = built.textClass;
+ updateLineClasses(lineView);
+ } else if (cls) {
+ lineView.text.className = cls;
+ }
+ }
+
+ function updateLineClasses(lineView) {
+ updateLineBackground(lineView);
+ if (lineView.line.wrapClass)
+ ensureLineWrapped(lineView).className = lineView.line.wrapClass;
+ else if (lineView.node != lineView.text)
+ lineView.node.className = "";
+ var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
+ lineView.text.className = textClass || "";
+ }
+
+ function updateLineGutter(cm, lineView, lineN, dims) {
+ if (lineView.gutter) {
+ lineView.node.removeChild(lineView.gutter);
+ lineView.gutter = null;
+ }
+ if (lineView.gutterBackground) {
+ lineView.node.removeChild(lineView.gutterBackground);
+ lineView.gutterBackground = null;
+ }
+ if (lineView.line.gutterClass) {
+ var wrap = ensureLineWrapped(lineView);
+ lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
+ "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
+ "px; width: " + dims.gutterTotalWidth + "px");
+ wrap.insertBefore(lineView.gutterBackground, lineView.text);
+ }
+ var markers = lineView.line.gutterMarkers;
+ if (cm.options.lineNumbers || markers) {
+ var wrap = ensureLineWrapped(lineView);
+ var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
+ (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
+ cm.display.input.setUneditable(gutterWrap);
+ wrap.insertBefore(gutterWrap, lineView.text);
+ if (lineView.line.gutterClass)
+ gutterWrap.className += " " + lineView.line.gutterClass;
+ if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
+ lineView.lineNumber = gutterWrap.appendChild(
+ elt("div", lineNumberFor(cm.options, lineN),
+ "CodeMirror-linenumber CodeMirror-gutter-elt",
+ "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
+ + cm.display.lineNumInnerWidth + "px"));
+ if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
+ var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
+ if (found)
+ gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
+ dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
+ }
+ }
+ }
+
+ function updateLineWidgets(cm, lineView, dims) {
+ if (lineView.alignable) lineView.alignable = null;
+ for (var node = lineView.node.firstChild, next; node; node = next) {
+ var next = node.nextSibling;
+ if (node.className == "CodeMirror-linewidget")
+ lineView.node.removeChild(node);
+ }
+ insertLineWidgets(cm, lineView, dims);
+ }
+
+ // Build a line's DOM representation from scratch
+ function buildLineElement(cm, lineView, lineN, dims) {
+ var built = getLineContent(cm, lineView);
+ lineView.text = lineView.node = built.pre;
+ if (built.bgClass) lineView.bgClass = built.bgClass;
+ if (built.textClass) lineView.textClass = built.textClass;
+
+ updateLineClasses(lineView);
+ updateLineGutter(cm, lineView, lineN, dims);
+ insertLineWidgets(cm, lineView, dims);
+ return lineView.node;
+ }
+
+ // A lineView may contain multiple logical lines (when merged by
+ // collapsed spans). The widgets for all of them need to be drawn.
+ function insertLineWidgets(cm, lineView, dims) {
+ insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
+ if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
+ insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
+ }
+
+ function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
+ if (!line.widgets) return;
+ var wrap = ensureLineWrapped(lineView);
+ for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
+ var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
+ if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
+ positionLineWidget(widget, node, lineView, dims);
+ cm.display.input.setUneditable(node);
+ if (allowAbove && widget.above)
+ wrap.insertBefore(node, lineView.gutter || lineView.text);
+ else
+ wrap.appendChild(node);
+ signalLater(widget, "redraw");
+ }
+ }
+
+ function positionLineWidget(widget, node, lineView, dims) {
+ if (widget.noHScroll) {
+ (lineView.alignable || (lineView.alignable = [])).push(node);
+ var width = dims.wrapperWidth;
+ node.style.left = dims.fixedPos + "px";
+ if (!widget.coverGutter) {
+ width -= dims.gutterTotalWidth;
+ node.style.paddingLeft = dims.gutterTotalWidth + "px";
+ }
+ node.style.width = width + "px";
+ }
+ if (widget.coverGutter) {
+ node.style.zIndex = 5;
+ node.style.position = "relative";
+ if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
+ }
+ }
+
+ // POSITION OBJECT
+
+ // A Pos instance represents a position within the text.
+ var Pos = CodeMirror.Pos = function(line, ch) {
+ if (!(this instanceof Pos)) return new Pos(line, ch);
+ this.line = line; this.ch = ch;
+ };
+
+ // Compare two positions, return 0 if they are the same, a negative
+ // number when a is less, and a positive number otherwise.
+ var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
+
+ function copyPos(x) {return Pos(x.line, x.ch);}
+ function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
+ function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
+
+ // INPUT HANDLING
+
+ function ensureFocus(cm) {
+ if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
+ }
+
+ function isReadOnly(cm) {
+ return cm.options.readOnly || cm.doc.cantEdit;
+ }
+
+ // This will be set to an array of strings when copying, so that,
+ // when pasting, we know what kind of selections the copied text
+ // was made out of.
+ var lastCopied = null;
+
+ function applyTextInput(cm, inserted, deleted, sel, origin) {
+ var doc = cm.doc;
+ cm.display.shift = false;
+ if (!sel) sel = doc.sel;
+
+ var paste = cm.state.pasteIncoming || origin == "paste";
+ var textLines = doc.splitLines(inserted), multiPaste = null;
+ // When pasing N lines into N selections, insert one line per selection
+ if (paste && sel.ranges.length > 1) {
+ if (lastCopied && lastCopied.join("\n") == inserted) {
+ if (sel.ranges.length % lastCopied.length == 0) {
+ multiPaste = [];
+ for (var i = 0; i < lastCopied.length; i++)
+ multiPaste.push(doc.splitLines(lastCopied[i]));
+ }
+ } else if (textLines.length == sel.ranges.length) {
+ multiPaste = map(textLines, function(l) { return [l]; });
+ }
+ }
+
+ // Normal behavior is to insert the new text into every selection
+ for (var i = sel.ranges.length - 1; i >= 0; i--) {
+ var range = sel.ranges[i];
+ var from = range.from(), to = range.to();
+ if (range.empty()) {
+ if (deleted && deleted > 0) // Handle deletion
+ from = Pos(from.line, from.ch - deleted);
+ else if (cm.state.overwrite && !paste) // Handle overwrite
+ to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
+ }
+ var updateInput = cm.curOp.updateInput;
+ var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
+ origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
+ makeChange(cm.doc, changeEvent);
+ signalLater(cm, "inputRead", cm, changeEvent);
+ }
+ if (inserted && !paste)
+ triggerElectric(cm, inserted);
+
+ ensureCursorVisible(cm);
+ cm.curOp.updateInput = updateInput;
+ cm.curOp.typing = true;
+ cm.state.pasteIncoming = cm.state.cutIncoming = false;
+ }
+
+ function handlePaste(e, cm) {
+ var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
+ if (pasted) {
+ e.preventDefault();
+ if (!isReadOnly(cm) && !cm.options.disableInput)
+ runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
+ return true;
+ }
+ }
+
+ function triggerElectric(cm, inserted) {
+ // When an 'electric' character is inserted, immediately trigger a reindent
+ if (!cm.options.electricChars || !cm.options.smartIndent) return;
+ var sel = cm.doc.sel;
+
+ for (var i = sel.ranges.length - 1; i >= 0; i--) {
+ var range = sel.ranges[i];
+ if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) continue;
+ var mode = cm.getModeAt(range.head);
+ var indented = false;
+ if (mode.electricChars) {
+ for (var j = 0; j < mode.electricChars.length; j++)
+ if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
+ indented = indentLine(cm, range.head.line, "smart");
+ break;
}
+ } else if (mode.electricInput) {
+ if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
+ indented = indentLine(cm, range.head.line, "smart");
+ }
+ if (indented) signalLater(cm, "electricInput", cm, range.head.line);
+ }
+ }
+
+ function copyableRanges(cm) {
+ var text = [], ranges = [];
+ for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
+ var line = cm.doc.sel.ranges[i].head.line;
+ var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
+ ranges.push(lineRange);
+ text.push(cm.getRange(lineRange.anchor, lineRange.head));
+ }
+ return {text: text, ranges: ranges};
+ }
+
+ function disableBrowserMagic(field) {
+ field.setAttribute("autocorrect", "off");
+ field.setAttribute("autocapitalize", "off");
+ field.setAttribute("spellcheck", "false");
+ }
+
+ // TEXTAREA INPUT STYLE
+
+ function TextareaInput(cm) {
+ this.cm = cm;
+ // See input.poll and input.reset
+ this.prevInput = "";
+
+ // Flag that indicates whether we expect input to appear real soon
+ // now (after some event like 'keypress' or 'input') and are
+ // polling intensively.
+ this.pollingFast = false;
+ // Self-resetting timeout for the poller
+ this.polling = new Delayed();
+ // Tracks when input.reset has punted to just putting a short
+ // string into the textarea instead of the full selection.
+ this.inaccurateSelection = false;
+ // Used to work around IE issue with selection being forgotten when focus moves away from textarea
+ this.hasSelection = false;
+ this.composing = null;
+ };
+
+ function hiddenTextarea() {
+ var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
+ var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
+ // The textarea is kept positioned near the cursor to prevent the
+ // fact that it'll be scrolled into view on input from scrolling
+ // our fake cursor out of view. On webkit, when wrap=off, paste is
+ // very slow. So make the area wide instead.
+ if (webkit) te.style.width = "1000px";
+ else te.setAttribute("wrap", "off");
+ // If border: 0; -- iOS fails to open keyboard (issue #1287)
+ if (ios) te.style.border = "1px solid black";
+ disableBrowserMagic(te);
+ return div;
+ }
+
+ TextareaInput.prototype = copyObj({
+ init: function(display) {
+ var input = this, cm = this.cm;
+
+ // Wraps and hides input textarea
+ var div = this.wrapper = hiddenTextarea();
+ // The semihidden textarea that is focused when the editor is
+ // focused, and receives input.
+ var te = this.textarea = div.firstChild;
+ display.wrapper.insertBefore(div, display.wrapper.firstChild);
+
+ // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
+ if (ios) te.style.width = "0px";
+
+ on(te, "input", function() {
+ if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null;
+ input.poll();
+ });
+
+ on(te, "paste", function(e) {
+ if (handlePaste(e, cm)) return true;
+
+ cm.state.pasteIncoming = true;
+ input.fastPoll();
+ });
+
+ function prepareCopyCut(e) {
+ if (cm.somethingSelected()) {
+ lastCopied = cm.getSelections();
+ if (input.inaccurateSelection) {
+ input.prevInput = "";
+ input.inaccurateSelection = false;
+ te.value = lastCopied.join("\n");
+ selectInput(te);
+ }
+ } else if (!cm.options.lineWiseCopyCut) {
+ return;
+ } else {
+ var ranges = copyableRanges(cm);
+ lastCopied = ranges.text;
+ if (e.type == "cut") {
+ cm.setSelections(ranges.ranges, null, sel_dontScroll);
+ } else {
+ input.prevInput = "";
+ te.value = ranges.text.join("\n");
+ selectInput(te);
+ }
+ }
+ if (e.type == "cut") cm.state.cutIncoming = true;
+ }
+ on(te, "cut", prepareCopyCut);
+ on(te, "copy", prepareCopyCut);
+
+ on(display.scroller, "paste", function(e) {
+ if (eventInWidget(display, e)) return;
+ cm.state.pasteIncoming = true;
+ input.focus();
+ });
+
+ // Prevent normal selection in the editor (we handle our own)
+ on(display.lineSpace, "selectstart", function(e) {
+ if (!eventInWidget(display, e)) e_preventDefault(e);
+ });
+
+ on(te, "compositionstart", function() {
+ var start = cm.getCursor("from");
+ if (input.composing) input.composing.range.clear()
+ input.composing = {
+ start: start,
+ range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
+ };
+ });
+ on(te, "compositionend", function() {
+ if (input.composing) {
+ input.poll();
+ input.composing.range.clear();
+ input.composing = null;
}
- } else if (nextIntact && nextIntact.from <= lineN && nextIntact.to > lineN) {
- // This line is intact. Skip to the actual node. Update its
- // line number if needed.
- while (cur.lineObj != line) cur = rm(cur);
- if (lineNumbers && updateNumbersFrom <= lineN && cur.lineNumber)
- setTextContent(cur.lineNumber, lineNumberFor(cm.options, lineN));
- cur = cur.nextSibling;
+ });
+ },
+
+ prepareSelection: function() {
+ // Redraw the selection and/or cursor
+ var cm = this.cm, display = cm.display, doc = cm.doc;
+ var result = prepareSelection(cm);
+
+ // Move the hidden textarea near the cursor to prevent scrolling artifacts
+ if (cm.options.moveInputWithCursor) {
+ var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
+ var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
+ result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
+ headPos.top + lineOff.top - wrapOff.top));
+ result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
+ headPos.left + lineOff.left - wrapOff.left));
+ }
+
+ return result;
+ },
+
+ showSelection: function(drawn) {
+ var cm = this.cm, display = cm.display;
+ removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
+ removeChildrenAndAdd(display.selectionDiv, drawn.selection);
+ if (drawn.teTop != null) {
+ this.wrapper.style.top = drawn.teTop + "px";
+ this.wrapper.style.left = drawn.teLeft + "px";
+ }
+ },
+
+ // Reset the input to correspond to the selection (or to be empty,
+ // when not typing and nothing is selected)
+ reset: function(typing) {
+ if (this.contextMenuPending) return;
+ var minimal, selected, cm = this.cm, doc = cm.doc;
+ if (cm.somethingSelected()) {
+ this.prevInput = "";
+ var range = doc.sel.primary();
+ minimal = hasCopyEvent &&
+ (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
+ var content = minimal ? "-" : selected || cm.getSelection();
+ this.textarea.value = content;
+ if (cm.state.focused) selectInput(this.textarea);
+ if (ie && ie_version >= 9) this.hasSelection = content;
+ } else if (!typing) {
+ this.prevInput = this.textarea.value = "";
+ if (ie && ie_version >= 9) this.hasSelection = null;
+ }
+ this.inaccurateSelection = minimal;
+ },
+
+ getField: function() { return this.textarea; },
+
+ supportsTouch: function() { return false; },
+
+ focus: function() {
+ if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
+ try { this.textarea.focus(); }
+ catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
+ }
+ },
+
+ blur: function() { this.textarea.blur(); },
+
+ resetPosition: function() {
+ this.wrapper.style.top = this.wrapper.style.left = 0;
+ },
+
+ receivedFocus: function() { this.slowPoll(); },
+
+ // Poll for input changes, using the normal rate of polling. This
+ // runs as long as the editor is focused.
+ slowPoll: function() {
+ var input = this;
+ if (input.pollingFast) return;
+ input.polling.set(this.cm.options.pollInterval, function() {
+ input.poll();
+ if (input.cm.state.focused) input.slowPoll();
+ });
+ },
+
+ // When an event has just come in that is likely to add or change
+ // something in the input textarea, we poll faster, to ensure that
+ // the change appears on the screen quickly.
+ fastPoll: function() {
+ var missed = false, input = this;
+ input.pollingFast = true;
+ function p() {
+ var changed = input.poll();
+ if (!changed && !missed) {missed = true; input.polling.set(60, p);}
+ else {input.pollingFast = false; input.slowPoll();}
+ }
+ input.polling.set(20, p);
+ },
+
+ // Read input from the textarea, and update the document to match.
+ // When something is selected, it is present in the textarea, and
+ // selected (unless it is huge, in which case a placeholder is
+ // used). When nothing is selected, the cursor sits after previously
+ // seen text (can be empty), which is stored in prevInput (we must
+ // not reset the textarea when typing, because that breaks IME).
+ poll: function() {
+ var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
+ // Since this is called a *lot*, try to bail out as cheaply as
+ // possible when it is clear that nothing happened. hasSelection
+ // will be the case when there is a lot of text in the textarea,
+ // in which case reading its value would be expensive.
+ if (this.contextMenuPending || !cm.state.focused ||
+ (hasSelection(input) && !prevInput && !this.composing) ||
+ isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
+ return false;
+
+ var text = input.value;
+ // If nothing changed, bail.
+ if (text == prevInput && !cm.somethingSelected()) return false;
+ // Work around nonsensical selection resetting in IE9/10, and
+ // inexplicable appearance of private area unicode characters on
+ // some key combos in Mac (#2689).
+ if (ie && ie_version >= 9 && this.hasSelection === text ||
+ mac && /[\uf700-\uf7ff]/.test(text)) {
+ cm.display.input.reset();
+ return false;
+ }
+
+ if (cm.doc.sel == cm.display.selForContextMenu) {
+ var first = text.charCodeAt(0);
+ if (first == 0x200b && !prevInput) prevInput = "\u200b";
+ if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo"); }
+ }
+ // Find the part of the input that is actually new
+ var same = 0, l = Math.min(prevInput.length, text.length);
+ while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
+
+ var self = this;
+ runInOp(cm, function() {
+ applyTextInput(cm, text.slice(same), prevInput.length - same,
+ null, self.composing ? "*compose" : null);
+
+ // Don't leave long text in the textarea, since it makes further polling slow
+ if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = "";
+ else self.prevInput = text;
+
+ if (self.composing) {
+ self.composing.range.clear();
+ self.composing.range = cm.markText(self.composing.start, cm.getCursor("to"),
+ {className: "CodeMirror-composing"});
+ }
+ });
+ return true;
+ },
+
+ ensurePolled: function() {
+ if (this.pollingFast && this.poll()) this.pollingFast = false;
+ },
+
+ onKeyPress: function() {
+ if (ie && ie_version >= 9) this.hasSelection = null;
+ this.fastPoll();
+ },
+
+ onContextMenu: function(e) {
+ var input = this, cm = input.cm, display = cm.display, te = input.textarea;
+ var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
+ if (!pos || presto) return; // Opera is difficult.
+
+ // Reset the current text selection only if the click is done outside of the selection
+ // and 'resetSelectionOnContextMenu' option is true.
+ var reset = cm.options.resetSelectionOnContextMenu;
+ if (reset && cm.doc.sel.contains(pos) == -1)
+ operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
+
+ var oldCSS = te.style.cssText;
+ input.wrapper.style.position = "absolute";
+ te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
+ "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
+ (ie ? "rgba(255, 255, 255, .05)" : "transparent") +
+ "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
+ if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
+ display.input.focus();
+ if (webkit) window.scrollTo(null, oldScrollY);
+ display.input.reset();
+ // Adds "Select all" to context menu in FF
+ if (!cm.somethingSelected()) te.value = input.prevInput = " ";
+ input.contextMenuPending = true;
+ display.selForContextMenu = cm.doc.sel;
+ clearTimeout(display.detectingSelectAll);
+
+ // Select-all will be greyed out if there's nothing to select, so
+ // this adds a zero-width space so that we can later check whether
+ // it got selected.
+ function prepareSelectAllHack() {
+ if (te.selectionStart != null) {
+ var selected = cm.somethingSelected();
+ var extval = "\u200b" + (selected ? te.value : "");
+ te.value = "\u21da"; // Used to catch context-menu undo
+ te.value = extval;
+ input.prevInput = selected ? "" : "\u200b";
+ te.selectionStart = 1; te.selectionEnd = extval.length;
+ // Re-set this, in case some other handler touched the
+ // selection in the meantime.
+ display.selForContextMenu = cm.doc.sel;
+ }
+ }
+ function rehide() {
+ input.contextMenuPending = false;
+ input.wrapper.style.position = "relative";
+ te.style.cssText = oldCSS;
+ if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
+
+ // Try to detect the user choosing select-all
+ if (te.selectionStart != null) {
+ if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
+ var i = 0, poll = function() {
+ if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
+ te.selectionEnd > 0 && input.prevInput == "\u200b")
+ operation(cm, commands.selectAll)(cm);
+ else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
+ else display.input.reset();
+ };
+ display.detectingSelectAll = setTimeout(poll, 200);
+ }
+ }
+
+ if (ie && ie_version >= 9) prepareSelectAllHack();
+ if (captureRightClick) {
+ e_stop(e);
+ var mouseup = function() {
+ off(window, "mouseup", mouseup);
+ setTimeout(rehide, 20);
+ };
+ on(window, "mouseup", mouseup);
} else {
- // For lines with widgets, make an attempt to find and reuse
- // the existing element, so that widgets aren't needlessly
- // removed and re-inserted into the dom
- if (line.widgets) for (var j = 0, search = cur, reuse; search && j < 20; ++j, search = search.nextSibling)
- if (search.lineObj == line && /div/i.test(search.nodeName)) { reuse = search; break; }
- // This line needs to be generated.
- var lineNode = buildLineElement(cm, line, lineN, dims, reuse);
- if (lineNode != reuse) {
- container.insertBefore(lineNode, cur);
+ setTimeout(rehide, 50);
+ }
+ },
+
+ readOnlyChanged: function(val) {
+ if (!val) this.reset();
+ },
+
+ setUneditable: nothing,
+
+ needsContentAttribute: false
+ }, TextareaInput.prototype);
+
+ // CONTENTEDITABLE INPUT STYLE
+
+ function ContentEditableInput(cm) {
+ this.cm = cm;
+ this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
+ this.polling = new Delayed();
+ this.gracePeriod = false;
+ }
+
+ ContentEditableInput.prototype = copyObj({
+ init: function(display) {
+ var input = this, cm = input.cm;
+ var div = input.div = display.lineDiv;
+ disableBrowserMagic(div);
+
+ on(div, "paste", function(e) { handlePaste(e, cm); })
+
+ on(div, "compositionstart", function(e) {
+ var data = e.data;
+ input.composing = {sel: cm.doc.sel, data: data, startData: data};
+ if (!data) return;
+ var prim = cm.doc.sel.primary();
+ var line = cm.getLine(prim.head.line);
+ var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length));
+ if (found > -1 && found <= prim.head.ch)
+ input.composing.sel = simpleSelection(Pos(prim.head.line, found),
+ Pos(prim.head.line, found + data.length));
+ });
+ on(div, "compositionupdate", function(e) {
+ input.composing.data = e.data;
+ });
+ on(div, "compositionend", function(e) {
+ var ours = input.composing;
+ if (!ours) return;
+ if (e.data != ours.startData && !/\u200b/.test(e.data))
+ ours.data = e.data;
+ // Need a small delay to prevent other code (input event,
+ // selection polling) from doing damage when fired right after
+ // compositionend.
+ setTimeout(function() {
+ if (!ours.handled)
+ input.applyComposition(ours);
+ if (input.composing == ours)
+ input.composing = null;
+ }, 50);
+ });
+
+ on(div, "touchstart", function() {
+ input.forceCompositionEnd();
+ });
+
+ on(div, "input", function() {
+ if (input.composing) return;
+ if (isReadOnly(cm) || !input.pollContent())
+ runInOp(input.cm, function() {regChange(cm);});
+ });
+
+ function onCopyCut(e) {
+ if (cm.somethingSelected()) {
+ lastCopied = cm.getSelections();
+ if (e.type == "cut") cm.replaceSelection("", null, "cut");
+ } else if (!cm.options.lineWiseCopyCut) {
+ return;
+ } else {
+ var ranges = copyableRanges(cm);
+ lastCopied = ranges.text;
+ if (e.type == "cut") {
+ cm.operation(function() {
+ cm.setSelections(ranges.ranges, 0, sel_dontScroll);
+ cm.replaceSelection("", null, "cut");
+ });
+ }
+ }
+ // iOS exposes the clipboard API, but seems to discard content inserted into it
+ if (e.clipboardData && !ios) {
+ e.preventDefault();
+ e.clipboardData.clearData();
+ e.clipboardData.setData("text/plain", lastCopied.join("\n"));
} else {
- while (cur != reuse) cur = rm(cur);
- cur = cur.nextSibling;
+ // Old-fashioned briefly-focus-a-textarea hack
+ var kludge = hiddenTextarea(), te = kludge.firstChild;
+ cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
+ te.value = lastCopied.join("\n");
+ var hadFocus = document.activeElement;
+ selectInput(te);
+ setTimeout(function() {
+ cm.display.lineSpace.removeChild(kludge);
+ hadFocus.focus();
+ }, 50);
}
+ }
+ on(div, "copy", onCopyCut);
+ on(div, "cut", onCopyCut);
+ },
+
+ prepareSelection: function() {
+ var result = prepareSelection(this.cm, false);
+ result.focus = this.cm.state.focused;
+ return result;
+ },
+
+ showSelection: function(info) {
+ if (!info || !this.cm.display.view.length) return;
+ if (info.focus) this.showPrimarySelection();
+ this.showMultipleSelections(info);
+ },
+
+ showPrimarySelection: function() {
+ var sel = window.getSelection(), prim = this.cm.doc.sel.primary();
+ var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset);
+ var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset);
+ if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
+ cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
+ cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
+ return;
- lineNode.lineObj = line;
+ var start = posToDOM(this.cm, prim.from());
+ var end = posToDOM(this.cm, prim.to());
+ if (!start && !end) return;
+
+ var view = this.cm.display.view;
+ var old = sel.rangeCount && sel.getRangeAt(0);
+ if (!start) {
+ start = {node: view[0].measure.map[2], offset: 0};
+ } else if (!end) { // FIXME dangerously hacky
+ var measure = view[view.length - 1].measure;
+ var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
+ end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]};
}
- ++lineN;
- });
- while (cur) cur = rm(cur);
+
+ try { var rng = range(start.node, start.offset, end.offset, end.node); }
+ catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
+ if (rng) {
+ 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);
+ },
+
+ rememberSelection: function() {
+ var sel = window.getSelection();
+ this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
+ this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
+ },
+
+ selectionInEditor: function() {
+ var sel = window.getSelection();
+ if (!sel.rangeCount) return false;
+ var node = sel.getRangeAt(0).commonAncestorContainer;
+ return contains(this.div, node);
+ },
+
+ focus: function() {
+ if (this.cm.options.readOnly != "nocursor") this.div.focus();
+ },
+ blur: function() { this.div.blur(); },
+ getField: function() { return this.div; },
+
+ supportsTouch: function() { return true; },
+
+ receivedFocus: function() {
+ var input = this;
+ if (this.selectionInEditor())
+ this.pollSelection();
+ else
+ runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; });
+
+ function poll() {
+ if (input.cm.state.focused) {
+ input.pollSelection();
+ input.polling.set(input.cm.options.pollInterval, poll);
+ }
+ }
+ this.polling.set(this.cm.options.pollInterval, poll);
+ },
+
+ selectionChanged: function() {
+ var sel = window.getSelection();
+ return 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);
+ if (anchor && head) runInOp(cm, function() {
+ setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
+ if (anchor.bad || head.bad) cm.curOp.selectionChanged = true;
+ });
+ }
+ },
+
+ pollContent: function() {
+ var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
+ var from = sel.from(), to = sel.to();
+ if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false;
+
+ var fromIndex;
+ if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
+ var fromLine = lineNo(display.view[0].line);
+ var fromNode = display.view[0].node;
+ } else {
+ var fromLine = lineNo(display.view[fromIndex].line);
+ var fromNode = display.view[fromIndex - 1].node.nextSibling;
+ }
+ var toIndex = findViewIndex(cm, to.line);
+ if (toIndex == display.view.length - 1) {
+ var toLine = display.viewTo - 1;
+ var toNode = display.lineDiv.lastChild;
+ } else {
+ var toLine = lineNo(display.view[toIndex + 1].line) - 1;
+ var toNode = display.view[toIndex + 1].node.previousSibling;
+ }
+
+ var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
+ var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
+ while (newText.length > 1 && oldText.length > 1) {
+ if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
+ else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
+ else break;
+ }
+
+ var cutFront = 0, cutEnd = 0;
+ var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
+ while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
+ ++cutFront;
+ var newBot = lst(newText), oldBot = lst(oldText);
+ var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
+ oldBot.length - (oldText.length == 1 ? cutFront : 0));
+ while (cutEnd < maxCutEnd &&
+ newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
+ ++cutEnd;
+
+ newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd);
+ newText[0] = newText[0].slice(cutFront);
+
+ var chFrom = Pos(fromLine, cutFront);
+ var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
+ if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
+ replaceRange(cm.doc, newText, chFrom, chTo, "+input");
+ return true;
+ }
+ },
+
+ ensurePolled: function() {
+ this.forceCompositionEnd();
+ },
+ reset: function() {
+ this.forceCompositionEnd();
+ },
+ forceCompositionEnd: function() {
+ if (!this.composing || this.composing.handled) return;
+ this.applyComposition(this.composing);
+ this.composing.handled = true;
+ this.div.blur();
+ this.div.focus();
+ },
+ applyComposition: function(composing) {
+ if (isReadOnly(this.cm))
+ operation(this.cm, regChange)(this.cm)
+ else if (composing.data && composing.data != composing.startData)
+ operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
+ },
+
+ setUneditable: function(node) {
+ node.contentEditable = "false"
+ },
+
+ onKeyPress: function(e) {
+ e.preventDefault();
+ if (!isReadOnly(this.cm))
+ operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
+ },
+
+ readOnlyChanged: function(val) {
+ this.div.contentEditable = String(val != "nocursor")
+ },
+
+ onContextMenu: nothing,
+ resetPosition: nothing,
+
+ needsContentAttribute: true
+ }, ContentEditableInput.prototype);
+
+ function posToDOM(cm, pos) {
+ var view = findViewForLine(cm, pos.line);
+ if (!view || view.hidden) return null;
+ var line = getLine(cm.doc, pos.line);
+ var info = mapFromLineView(view, line, pos.line);
+
+ var order = getOrder(line), side = "left";
+ if (order) {
+ var partPos = getBidiPartAt(order, pos.ch);
+ side = partPos % 2 ? "right" : "left";
+ }
+ var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
+ result.offset = result.collapse == "right" ? result.end : result.start;
+ return result;
}
- function buildLineElement(cm, line, lineNo, dims, reuse) {
- var built = buildLineContent(cm, line), lineElement = built.pre;
- var markers = line.gutterMarkers, display = cm.display, wrap;
+ function badPos(pos, bad) { if (bad) pos.bad = true; return pos; }
- var bgClass = built.bgClass ? built.bgClass + " " + (line.bgClass || "") : line.bgClass;
- if (!cm.options.lineNumbers && !markers && !bgClass && !line.wrapClass && !line.widgets)
- return lineElement;
+ function domToPos(cm, node, offset) {
+ var lineNode;
+ if (node == cm.display.lineDiv) {
+ lineNode = cm.display.lineDiv.childNodes[offset];
+ if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
+ node = null; offset = 0;
+ } else {
+ for (lineNode = node;; lineNode = lineNode.parentNode) {
+ if (!lineNode || lineNode == cm.display.lineDiv) return null;
+ if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break;
+ }
+ }
+ for (var i = 0; i < cm.display.view.length; i++) {
+ var lineView = cm.display.view[i];
+ if (lineView.node == lineNode)
+ return locateNodeInLineView(lineView, node, offset);
+ }
+ }
- // Lines with gutter elements, widgets or a background class need
- // to be wrapped again, and have the extra elements added to the
- // wrapper div
+ function locateNodeInLineView(lineView, node, offset) {
+ var wrapper = lineView.text.firstChild, bad = false;
+ if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true);
+ if (node == wrapper) {
+ bad = true;
+ node = wrapper.childNodes[offset];
+ offset = 0;
+ if (!node) {
+ var line = lineView.rest ? lst(lineView.rest) : lineView.line;
+ return badPos(Pos(lineNo(line), line.text.length), bad);
+ }
+ }
- if (reuse) {
- reuse.alignable = null;
- var isOk = true, widgetsSeen = 0, insertBefore = null;
- for (var n = reuse.firstChild, next; n; n = next) {
- next = n.nextSibling;
- if (!/\bCodeMirror-linewidget\b/.test(n.className)) {
- reuse.removeChild(n);
- } else {
- for (var i = 0; i < line.widgets.length; ++i) {
- var widget = line.widgets[i];
- if (widget.node == n.firstChild) {
- if (!widget.above && !insertBefore) insertBefore = n;
- positionLineWidget(widget, n, reuse, dims);
- ++widgetsSeen;
- break;
- }
+ var textNode = node.nodeType == 3 ? node : null, topNode = node;
+ if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
+ textNode = node.firstChild;
+ if (offset) offset = textNode.nodeValue.length;
+ }
+ while (topNode.parentNode != wrapper) topNode = topNode.parentNode;
+ var measure = lineView.measure, maps = measure.maps;
+
+ function find(textNode, topNode, offset) {
+ for (var i = -1; i < (maps ? maps.length : 0); i++) {
+ var map = i < 0 ? measure.map : maps[i];
+ for (var j = 0; j < map.length; j += 3) {
+ var curNode = map[j + 2];
+ if (curNode == textNode || curNode == topNode) {
+ var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
+ var ch = map[j] + offset;
+ if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
+ return Pos(line, ch);
}
- if (i == line.widgets.length) { isOk = false; break; }
}
}
- reuse.insertBefore(lineElement, insertBefore);
- if (isOk && widgetsSeen == line.widgets.length) {
- wrap = reuse;
- reuse.className = line.wrapClass || "";
+ }
+ var found = find(textNode, topNode, offset);
+ if (found) return badPos(found, bad);
+
+ // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
+ for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
+ found = find(after, after.firstChild, 0);
+ if (found)
+ return badPos(Pos(found.line, found.ch - dist), bad);
+ else
+ dist += after.textContent.length;
+ }
+ for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) {
+ found = find(before, before.firstChild, -1);
+ if (found)
+ return badPos(Pos(found.line, found.ch + dist), bad);
+ else
+ dist += after.textContent.length;
+ }
+ }
+
+ function domTextBetween(cm, from, to, fromLine, toLine) {
+ var text = "", closing = false, lineSep = cm.doc.lineSeparator();
+ function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
+ function walk(node) {
+ if (node.nodeType == 1) {
+ var cmText = node.getAttribute("cm-text");
+ if (cmText != null) {
+ if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
+ text += cmText;
+ return;
+ }
+ var markerID = node.getAttribute("cm-marker"), range;
+ if (markerID) {
+ var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
+ if (found.length && (range = found[0].find()))
+ text += getBetween(cm.doc, range.from, range.to).join(lineSep);
+ return;
+ }
+ if (node.getAttribute("contenteditable") == "false") return;
+ for (var i = 0; i < node.childNodes.length; i++)
+ walk(node.childNodes[i]);
+ if (/^(pre|div|p)$/i.test(node.nodeName))
+ closing = true;
+ } else if (node.nodeType == 3) {
+ var val = node.nodeValue;
+ if (!val) return;
+ if (closing) {
+ text += lineSep;
+ closing = false;
+ }
+ text += val;
}
}
- if (!wrap) {
- wrap = elt("div", null, line.wrapClass, "position: relative");
- wrap.appendChild(lineElement);
+ for (;;) {
+ walk(from);
+ if (from == to) break;
+ from = from.nextSibling;
}
- // Kludge to make sure the styled element lies behind the selection (by z-index)
- if (bgClass)
- wrap.insertBefore(elt("div", null, bgClass + " CodeMirror-linebackground"), wrap.firstChild);
- if (cm.options.lineNumbers || markers) {
- var gutterWrap = wrap.insertBefore(elt("div", null, "CodeMirror-gutter-wrapper", "position: absolute; left: " +
- (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"),
- lineElement);
- if (cm.options.fixedGutter) (wrap.alignable || (wrap.alignable = [])).push(gutterWrap);
- if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
- wrap.lineNumber = gutterWrap.appendChild(
- elt("div", lineNumberFor(cm.options, lineNo),
- "CodeMirror-linenumber CodeMirror-gutter-elt",
- "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
- + display.lineNumInnerWidth + "px"));
- if (markers)
- for (var k = 0; k < cm.options.gutters.length; ++k) {
- var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
- if (found)
- gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
- dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
+ return text;
+ }
+
+ CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
+
+ // SELECTION / CURSOR
+
+ // Selection objects are immutable. A new one is created every time
+ // the selection changes. A selection is one or more non-overlapping
+ // (and non-touching) ranges, sorted, and an integer that indicates
+ // which one is the primary selection (the one that's scrolled into
+ // view, that getCursor returns, etc).
+ function Selection(ranges, primIndex) {
+ this.ranges = ranges;
+ this.primIndex = primIndex;
+ }
+
+ Selection.prototype = {
+ primary: function() { return this.ranges[this.primIndex]; },
+ equals: function(other) {
+ if (other == this) return true;
+ if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
+ for (var i = 0; i < this.ranges.length; i++) {
+ var here = this.ranges[i], there = other.ranges[i];
+ if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
+ }
+ return true;
+ },
+ deepCopy: function() {
+ for (var out = [], i = 0; i < this.ranges.length; i++)
+ out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
+ return new Selection(out, this.primIndex);
+ },
+ somethingSelected: function() {
+ for (var i = 0; i < this.ranges.length; i++)
+ if (!this.ranges[i].empty()) return true;
+ return false;
+ },
+ contains: function(pos, end) {
+ if (!end) end = pos;
+ for (var i = 0; i < this.ranges.length; i++) {
+ var range = this.ranges[i];
+ if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
+ return i;
+ }
+ return -1;
+ }
+ };
+
+ function Range(anchor, head) {
+ this.anchor = anchor; this.head = head;
+ }
+
+ Range.prototype = {
+ from: function() { return minPos(this.anchor, this.head); },
+ to: function() { return maxPos(this.anchor, this.head); },
+ empty: function() {
+ return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
+ }
+ };
+
+ // Take an unsorted, potentially overlapping set of ranges, and
+ // build a selection out of it. 'Consumes' ranges array (modifying
+ // it).
+ function normalizeSelection(ranges, primIndex) {
+ var prim = ranges[primIndex];
+ ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
+ primIndex = indexOf(ranges, prim);
+ for (var i = 1; i < ranges.length; i++) {
+ var cur = ranges[i], prev = ranges[i - 1];
+ if (cmp(prev.to(), cur.from()) >= 0) {
+ var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
+ var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
+ if (i <= primIndex) --primIndex;
+ ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
+ }
+ }
+ return new Selection(ranges, primIndex);
+ }
+
+ function simpleSelection(anchor, head) {
+ return new Selection([new Range(anchor, head || anchor)], 0);
+ }
+
+ // Most of the external API clips given positions to make sure they
+ // actually exist within the document.
+ function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
+ function clipPos(doc, pos) {
+ if (pos.line < doc.first) return Pos(doc.first, 0);
+ var last = doc.first + doc.size - 1;
+ if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
+ return clipToLen(pos, getLine(doc, pos.line).text.length);
+ }
+ function clipToLen(pos, linelen) {
+ var ch = pos.ch;
+ if (ch == null || ch > linelen) return Pos(pos.line, linelen);
+ else if (ch < 0) return Pos(pos.line, 0);
+ else return pos;
+ }
+ function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
+ function clipPosArray(doc, array) {
+ for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
+ return out;
+ }
+
+ // SELECTION UPDATES
+
+ // The 'scroll' parameter given to many of these indicated whether
+ // the new cursor position should be scrolled into view after
+ // modifying the selection.
+
+ // If shift is held or the extend flag is set, extends a range to
+ // include a given position (and optionally a second position).
+ // Otherwise, simply returns the range between the given positions.
+ // Used for cursor motion and such.
+ function extendRange(doc, range, head, other) {
+ if (doc.cm && doc.cm.display.shift || doc.extend) {
+ var anchor = range.anchor;
+ if (other) {
+ var posBefore = cmp(head, anchor) < 0;
+ if (posBefore != (cmp(other, anchor) < 0)) {
+ anchor = head;
+ head = other;
+ } else if (posBefore != (cmp(head, other) < 0)) {
+ head = other;
}
+ }
+ return new Range(anchor, head);
+ } else {
+ return new Range(other || head, head);
}
- if (ie_lt8) wrap.style.zIndex = 2;
- if (line.widgets && wrap != reuse) for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
- var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
- if (!widget.handleMouseEvents) node.ignoreEvents = true;
- positionLineWidget(widget, node, wrap, dims);
- if (widget.above)
- wrap.insertBefore(node, cm.options.lineNumbers && line.height != 0 ? gutterWrap : lineElement);
- else
- wrap.appendChild(node);
- signalLater(widget, "redraw");
+ }
+
+ // Extend the primary selection range, discard the rest.
+ function extendSelection(doc, head, other, options) {
+ setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
+ }
+
+ // Extend all selections (pos is an array of selections with length
+ // equal the number of selections)
+ function extendSelections(doc, heads, options) {
+ for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
+ out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
+ var newSel = normalizeSelection(out, doc.sel.primIndex);
+ setSelection(doc, newSel, options);
+ }
+
+ // Updates a single range in the selection.
+ function replaceOneSelection(doc, i, range, options) {
+ var ranges = doc.sel.ranges.slice(0);
+ ranges[i] = range;
+ setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
+ }
+
+ // Reset the selection to a single range.
+ function setSimpleSelection(doc, anchor, head, options) {
+ setSelection(doc, simpleSelection(anchor, head), options);
+ }
+
+ // Give beforeSelectionChange handlers a change to influence a
+ // selection update.
+ function filterSelectionChange(doc, sel) {
+ var obj = {
+ ranges: sel.ranges,
+ update: function(ranges) {
+ this.ranges = [];
+ for (var i = 0; i < ranges.length; i++)
+ this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
+ clipPos(doc, ranges[i].head));
+ }
+ };
+ signal(doc, "beforeSelectionChange", doc, obj);
+ if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
+ if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
+ else return sel;
+ }
+
+ function setSelectionReplaceHistory(doc, sel, options) {
+ var done = doc.history.done, last = lst(done);
+ if (last && last.ranges) {
+ done[done.length - 1] = sel;
+ setSelectionNoUndo(doc, sel, options);
+ } else {
+ setSelection(doc, sel, options);
+ }
+ }
+
+ // Set a new selection.
+ function setSelection(doc, sel, options) {
+ setSelectionNoUndo(doc, sel, options);
+ addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
+ }
+
+ function setSelectionNoUndo(doc, sel, options) {
+ if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
+ sel = filterSelectionChange(doc, sel);
+
+ var bias = options && options.bias ||
+ (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
+ setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
+
+ if (!(options && options.scroll === false) && doc.cm)
+ ensureCursorVisible(doc.cm);
+ }
+
+ function setSelectionInner(doc, sel) {
+ if (sel.equals(doc.sel)) return;
+
+ doc.sel = sel;
+
+ if (doc.cm) {
+ doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
+ signalCursorActivity(doc.cm);
}
- return wrap;
+ signalLater(doc, "cursorActivity", doc);
}
- function positionLineWidget(widget, node, wrap, dims) {
- if (widget.noHScroll) {
- (wrap.alignable || (wrap.alignable = [])).push(node);
- var width = dims.wrapperWidth;
- node.style.left = dims.fixedPos + "px";
- if (!widget.coverGutter) {
- width -= dims.gutterTotalWidth;
- node.style.paddingLeft = dims.gutterTotalWidth + "px";
+ // Verify that the selection does not partially select any atomic
+ // marked ranges.
+ function reCheckSelection(doc) {
+ setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
+ }
+
+ // Return a selection that does not partially select any atomic
+ // ranges.
+ function skipAtomicInSelection(doc, sel, bias, mayClear) {
+ var out;
+ for (var i = 0; i < sel.ranges.length; i++) {
+ var range = sel.ranges[i];
+ var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);
+ var newHead = skipAtomic(doc, range.head, bias, mayClear);
+ if (out || newAnchor != range.anchor || newHead != range.head) {
+ if (!out) out = sel.ranges.slice(0, i);
+ out[i] = new Range(newAnchor, newHead);
}
- node.style.width = width + "px";
}
- if (widget.coverGutter) {
- node.style.zIndex = 5;
- node.style.position = "relative";
- if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
+ return out ? normalizeSelection(out, sel.primIndex) : sel;
+ }
+
+ // Ensure a given position is not inside an atomic range.
+ function skipAtomic(doc, pos, bias, mayClear) {
+ var flipped = false, curPos = pos;
+ var dir = bias || 1;
+ doc.cantEdit = false;
+ search: for (;;) {
+ var line = getLine(doc, curPos.line);
+ if (line.markedSpans) {
+ for (var i = 0; i < line.markedSpans.length; ++i) {
+ var sp = line.markedSpans[i], m = sp.marker;
+ if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
+ (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
+ if (mayClear) {
+ signal(m, "beforeCursorEnter");
+ if (m.explicitlyCleared) {
+ if (!line.markedSpans) break;
+ else {--i; continue;}
+ }
+ }
+ if (!m.atomic) continue;
+ var newPos = m.find(dir < 0 ? -1 : 1);
+ if (cmp(newPos, curPos) == 0) {
+ newPos.ch += dir;
+ if (newPos.ch < 0) {
+ if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
+ else newPos = null;
+ } else if (newPos.ch > line.text.length) {
+ if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
+ else newPos = null;
+ }
+ if (!newPos) {
+ if (flipped) {
+ // Driven in a corner -- no valid cursor position found at all
+ // -- try again *with* clearing, if we didn't already
+ if (!mayClear) return skipAtomic(doc, pos, bias, true);
+ // Otherwise, turn off editing until further notice, and return the start of the doc
+ doc.cantEdit = true;
+ return Pos(doc.first, 0);
+ }
+ flipped = true; newPos = pos; dir = -dir;
+ }
+ }
+ curPos = newPos;
+ continue search;
+ }
+ }
+ }
+ return curPos;
}
}
- // SELECTION / CURSOR
+ // SELECTION DRAWING
function updateSelection(cm) {
- var display = cm.display;
- var collapsed = posEq(cm.doc.sel.from, cm.doc.sel.to);
- if (collapsed || cm.options.showCursorWhenSelecting)
- updateSelectionCursor(cm);
- else
- display.cursor.style.display = display.otherCursor.style.display = "none";
- if (!collapsed)
- updateSelectionRange(cm);
- else
- display.selectionDiv.style.display = "none";
+ cm.display.input.showSelection(cm.display.input.prepareSelection());
+ }
+
+ function prepareSelection(cm, primary) {
+ var doc = cm.doc, result = {};
+ var curFragment = result.cursors = document.createDocumentFragment();
+ var selFragment = result.selection = document.createDocumentFragment();
- // Move the hidden textarea near the cursor to prevent scrolling artifacts
- if (cm.options.moveInputWithCursor) {
- var headPos = cursorCoords(cm, cm.doc.sel.head, "div");
- var wrapOff = getRect(display.wrapper), lineOff = getRect(display.lineDiv);
- display.inputDiv.style.top = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
- headPos.top + lineOff.top - wrapOff.top)) + "px";
- display.inputDiv.style.left = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
- headPos.left + lineOff.left - wrapOff.left)) + "px";
+ for (var i = 0; i < doc.sel.ranges.length; i++) {
+ if (primary === false && i == doc.sel.primIndex) continue;
+ var range = doc.sel.ranges[i];
+ var collapsed = range.empty();
+ if (collapsed || cm.options.showCursorWhenSelecting)
+ drawSelectionCursor(cm, range.head, curFragment);
+ if (!collapsed)
+ drawSelectionRange(cm, range, selFragment);
}
+ return result;
}
- // No selection, plain cursor
- function updateSelectionCursor(cm) {
- var display = cm.display, pos = cursorCoords(cm, cm.doc.sel.head, "div");
- display.cursor.style.left = pos.left + "px";
- display.cursor.style.top = pos.top + "px";
- display.cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
- display.cursor.style.display = "";
+ // Draws a cursor for the given range
+ function drawSelectionCursor(cm, head, output) {
+ var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
+
+ var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
+ cursor.style.left = pos.left + "px";
+ cursor.style.top = pos.top + "px";
+ cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
if (pos.other) {
- display.otherCursor.style.display = "";
- display.otherCursor.style.left = pos.other.left + "px";
- display.otherCursor.style.top = pos.other.top + "px";
- display.otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
- } else { display.otherCursor.style.display = "none"; }
+ // Secondary cursor, shown when on a 'jump' in bi-directional text
+ var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
+ otherCursor.style.display = "";
+ otherCursor.style.left = pos.other.left + "px";
+ otherCursor.style.top = pos.other.top + "px";
+ otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
+ }
}
- // Highlight selection
- function updateSelectionRange(cm) {
- var display = cm.display, doc = cm.doc, sel = cm.doc.sel;
+ // Draws the given range as a highlighted selection
+ function drawSelectionRange(cm, range, output) {
+ var display = cm.display, doc = cm.doc;
var fragment = document.createDocumentFragment();
- var padding = paddingH(cm.display), leftSide = padding.left, rightSide = display.lineSpace.offsetWidth - padding.right;
+ var padding = paddingH(cm.display), leftSide = padding.left;
+ var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
function add(left, top, width, bottom) {
if (top < 0) top = 0;
+ top = Math.round(top);
+ bottom = Math.round(bottom);
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
"px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
"px; height: " + (bottom - top) + "px"));
@@ -875,13 +2363,14 @@ window.CodeMirror = (function() {
return {start: start, end: end};
}
- if (sel.from.line == sel.to.line) {
- drawForLine(sel.from.line, sel.from.ch, sel.to.ch);
+ var sFrom = range.from(), sTo = range.to();
+ if (sFrom.line == sTo.line) {
+ drawForLine(sFrom.line, sFrom.ch, sTo.ch);
} else {
- var fromLine = getLine(doc, sel.from.line), toLine = getLine(doc, sel.to.line);
- var singleVLine = visualLine(doc, fromLine) == visualLine(doc, toLine);
- var leftEnd = drawForLine(sel.from.line, sel.from.ch, singleVLine ? fromLine.text.length : null).end;
- var rightStart = drawForLine(sel.to.line, singleVLine ? 0 : null, sel.to.ch).start;
+ var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
+ var singleVLine = visualLine(fromLine) == visualLine(toLine);
+ var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
+ var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
if (singleVLine) {
if (leftEnd.top < rightStart.top - 2) {
add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
@@ -894,8 +2383,7 @@ window.CodeMirror = (function() {
add(leftSide, leftEnd.bottom, null, rightStart.top);
}
- removeChildrenAndAdd(display.selectionDiv, fragment);
- display.selectionDiv.style.display = "";
+ output.appendChild(fragment);
}
// Cursor-blinking
@@ -904,40 +2392,46 @@ window.CodeMirror = (function() {
var display = cm.display;
clearInterval(display.blinker);
var on = true;
- display.cursor.style.visibility = display.otherCursor.style.visibility = "";
+ display.cursorDiv.style.visibility = "";
if (cm.options.cursorBlinkRate > 0)
display.blinker = setInterval(function() {
- display.cursor.style.visibility = display.otherCursor.style.visibility = (on = !on) ? "" : "hidden";
+ display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
}, cm.options.cursorBlinkRate);
+ else if (cm.options.cursorBlinkRate < 0)
+ display.cursorDiv.style.visibility = "hidden";
}
// HIGHLIGHT WORKER
function startWorker(cm, time) {
- if (cm.doc.mode.startState && cm.doc.frontier < cm.display.showingTo)
+ if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
cm.state.highlight.set(time, bind(highlightWorker, cm));
}
function highlightWorker(cm) {
var doc = cm.doc;
if (doc.frontier < doc.first) doc.frontier = doc.first;
- if (doc.frontier >= cm.display.showingTo) return;
+ if (doc.frontier >= cm.display.viewTo) return;
var end = +new Date + cm.options.workTime;
var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
- var changed = [], prevChange;
- doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.showingTo + 500), function(line) {
- if (doc.frontier >= cm.display.showingFrom) { // Visible
- var oldStyles = line.styles;
- line.styles = highlightLine(cm, line, state, true);
- var ischange = !oldStyles || oldStyles.length != line.styles.length;
+ var changedLines = [];
+
+ doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
+ if (doc.frontier >= cm.display.viewFrom) { // Visible
+ var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength;
+ var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true);
+ line.styles = highlighted.styles;
+ var oldCls = line.styleClasses, newCls = highlighted.classes;
+ if (newCls) line.styleClasses = newCls;
+ else if (oldCls) line.styleClasses = null;
+ var ischange = !oldStyles || oldStyles.length != line.styles.length ||
+ oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
- if (ischange) {
- if (prevChange && prevChange.end == doc.frontier) prevChange.end++;
- else changed.push(prevChange = {start: doc.frontier, end: doc.frontier + 1});
- }
- line.stateAfter = copyState(doc.mode, state);
+ if (ischange) changedLines.push(doc.frontier);
+ line.stateAfter = tooLong ? state : copyState(doc.mode, state);
} else {
- processLine(cm, line.text, state);
+ if (line.text.length <= cm.options.maxHighlightLength)
+ processLine(cm, line.text, state);
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
}
++doc.frontier;
@@ -946,11 +2440,10 @@ window.CodeMirror = (function() {
return true;
}
});
- if (changed.length)
- operation(cm, function() {
- for (var i = 0; i < changed.length; ++i)
- regChange(this, changed[i].start, changed[i].end);
- })();
+ if (changedLines.length) runInOp(cm, function() {
+ for (var i = 0; i < changedLines.length; i++)
+ regLineChange(cm, changedLines[i], "text");
+ });
}
// Finds the line to start with when starting a parse. Tries to
@@ -982,7 +2475,7 @@ window.CodeMirror = (function() {
else state = copyState(doc.mode, state);
doc.iter(pos, n, function(line) {
processLine(cm, line.text, state);
- var save = pos == n - 1 || pos % 5 == 0 || pos >= display.showingFrom && pos < display.showingTo;
+ var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
line.stateAfter = save ? copyState(doc.mode, state) : null;
++pos;
});
@@ -998,186 +2491,256 @@ window.CodeMirror = (function() {
if (display.cachedPaddingH) return display.cachedPaddingH;
var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
- return display.cachedPaddingH = {left: parseInt(style.paddingLeft),
- right: parseInt(style.paddingRight)};
- }
-
- function measureChar(cm, line, ch, data, bias) {
- var dir = -1;
- data = data || measureLine(cm, line);
- if (data.crude) {
- var left = data.left + ch * data.width;
- return {left: left, right: left + data.width, top: data.top, bottom: data.bottom};
- }
-
- for (var pos = ch;; pos += dir) {
- var r = data[pos];
- if (r) break;
- if (dir < 0 && pos == 0) dir = 1;
- }
- bias = pos > ch ? "left" : pos < ch ? "right" : bias;
- if (bias == "left" && r.leftSide) r = r.leftSide;
- else if (bias == "right" && r.rightSide) r = r.rightSide;
- return {left: pos < ch ? r.right : r.left,
- right: pos > ch ? r.left : r.right,
- top: r.top,
- bottom: r.bottom};
- }
-
- function findCachedMeasurement(cm, line) {
- var cache = cm.display.measureLineCache;
- for (var i = 0; i < cache.length; ++i) {
- var memo = cache[i];
- if (memo.text == line.text && memo.markedSpans == line.markedSpans &&
- cm.display.scroller.clientWidth == memo.width &&
- memo.classes == line.textClass + "|" + line.wrapClass)
- return memo;
- }
- }
-
- function clearCachedMeasurement(cm, line) {
- var exists = findCachedMeasurement(cm, line);
- if (exists) exists.text = exists.measure = exists.markedSpans = null;
- }
-
- function measureLine(cm, line) {
- // First look in the cache
- var cached = findCachedMeasurement(cm, line);
- if (cached) return cached.measure;
-
- // Failing that, recompute and store result in cache
- var measure = measureLineInner(cm, line);
- var cache = cm.display.measureLineCache;
- var memo = {text: line.text, width: cm.display.scroller.clientWidth,
- markedSpans: line.markedSpans, measure: measure,
- classes: line.textClass + "|" + line.wrapClass};
- if (cache.length == 16) cache[++cm.display.measureLineCachePos % 16] = memo;
- else cache.push(memo);
- return measure;
- }
-
- function measureLineInner(cm, line) {
- if (!cm.options.lineWrapping && line.text.length >= cm.options.crudeMeasuringFrom)
- return crudelyMeasureLine(cm, line);
-
- var display = cm.display, measure = emptyArray(line.text.length);
- var pre = buildLineContent(cm, line, measure, true).pre;
-
- // IE does not cache element positions of inline elements between
- // calls to getBoundingClientRect. This makes the loop below,
- // which gathers the positions of all the characters on the line,
- // do an amount of layout work quadratic to the number of
- // characters. When line wrapping is off, we try to improve things
- // by first subdividing the line into a bunch of inline blocks, so
- // that IE can reuse most of the layout information from caches
- // for those blocks. This does interfere with line wrapping, so it
- // doesn't work when wrapping is on, but in that case the
- // situation is slightly better, since IE does cache line-wrapping
- // information and only recomputes per-line.
- if (old_ie && !ie_lt8 && !cm.options.lineWrapping && pre.childNodes.length > 100) {
- var fragment = document.createDocumentFragment();
- var chunk = 10, n = pre.childNodes.length;
- for (var i = 0, chunks = Math.ceil(n / chunk); i < chunks; ++i) {
- var wrap = elt("div", null, null, "display: inline-block");
- for (var j = 0; j < chunk && n; ++j) {
- wrap.appendChild(pre.firstChild);
- --n;
+ var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
+ if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
+ return data;
+ }
+
+ function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; }
+ function displayWidth(cm) {
+ return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth;
+ }
+ function displayHeight(cm) {
+ return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight;
+ }
+
+ // Ensure the lineView.wrapping.heights array is populated. This is
+ // an array of bottom offsets for the lines that make up a drawn
+ // line. When lineWrapping is on, there might be more than one
+ // height.
+ function ensureLineHeights(cm, lineView, rect) {
+ var wrapping = cm.options.lineWrapping;
+ var curWidth = wrapping && displayWidth(cm);
+ if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
+ var heights = lineView.measure.heights = [];
+ if (wrapping) {
+ lineView.measure.width = curWidth;
+ var rects = lineView.text.firstChild.getClientRects();
+ for (var i = 0; i < rects.length - 1; i++) {
+ var cur = rects[i], next = rects[i + 1];
+ if (Math.abs(cur.bottom - next.bottom) > 2)
+ heights.push((cur.bottom + next.top) / 2 - rect.top);
}
- fragment.appendChild(wrap);
}
- pre.appendChild(fragment);
- }
+ heights.push(rect.bottom - rect.top);
+ }
+ }
+
+ // Find a line map (mapping character offsets to text nodes) and a
+ // measurement cache for the given line number. (A line view might
+ // contain multiple lines when collapsed ranges are present.)
+ function mapFromLineView(lineView, line, lineN) {
+ if (lineView.line == line)
+ return {map: lineView.measure.map, cache: lineView.measure.cache};
+ for (var i = 0; i < lineView.rest.length; i++)
+ if (lineView.rest[i] == line)
+ return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};
+ for (var i = 0; i < lineView.rest.length; i++)
+ if (lineNo(lineView.rest[i]) > lineN)
+ return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true};
+ }
+
+ // Render a line into the hidden node display.externalMeasured. Used
+ // when measurement is needed for a line that's not in the viewport.
+ function updateExternalMeasurement(cm, line) {
+ line = visualLine(line);
+ var lineN = lineNo(line);
+ var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
+ view.lineN = lineN;
+ var built = view.built = buildLineContent(cm, view);
+ view.text = built.pre;
+ removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
+ return view;
+ }
+
+ // Get a {top, bottom, left, right} box (in line-local coordinates)
+ // for a given character.
+ function measureChar(cm, line, ch, bias) {
+ return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
+ }
+
+ // Find a line view that corresponds to the given line number.
+ function findViewForLine(cm, lineN) {
+ if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
+ return cm.display.view[findViewIndex(cm, lineN)];
+ var ext = cm.display.externalMeasured;
+ if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
+ return ext;
+ }
+
+ // Measurement can be split in two steps, the set-up work that
+ // applies to the whole line, and the measurement of the actual
+ // character. Functions like coordsChar, that need to do a lot of
+ // measurements in a row, can thus ensure that the set-up work is
+ // only done once.
+ function prepareMeasureForLine(cm, line) {
+ var lineN = lineNo(line);
+ var view = findViewForLine(cm, lineN);
+ if (view && !view.text) {
+ view = null;
+ } else if (view && view.changes) {
+ updateLineForChanges(cm, view, lineN, getDimensions(cm));
+ cm.curOp.forceUpdate = true;
+ }
+ if (!view)
+ view = updateExternalMeasurement(cm, line);
+
+ var info = mapFromLineView(view, line, lineN);
+ return {
+ line: line, view: view, rect: null,
+ map: info.map, cache: info.cache, before: info.before,
+ hasHeights: false
+ };
+ }
- removeChildrenAndAdd(display.measure, pre);
+ // Given a prepared measurement object, measures the position of an
+ // actual character (or fetches it from the cache).
+ function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
+ if (prepared.before) ch = -1;
+ var key = ch + (bias || ""), found;
+ if (prepared.cache.hasOwnProperty(key)) {
+ found = prepared.cache[key];
+ } else {
+ if (!prepared.rect)
+ prepared.rect = prepared.view.text.getBoundingClientRect();
+ if (!prepared.hasHeights) {
+ ensureLineHeights(cm, prepared.view, prepared.rect);
+ prepared.hasHeights = true;
+ }
+ found = measureCharInner(cm, prepared, ch, bias);
+ if (!found.bogus) prepared.cache[key] = found;
+ }
+ return {left: found.left, right: found.right,
+ top: varHeight ? found.rtop : found.top,
+ bottom: varHeight ? found.rbottom : found.bottom};
+ }
+
+ var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
+
+ function nodeAndOffsetInLineMap(map, ch, bias) {
+ var node, start, end, collapse;
+ // First, search the line map for the text node corresponding to,
+ // or closest to, the target character.
+ for (var i = 0; i < map.length; i += 3) {
+ var mStart = map[i], mEnd = map[i + 1];
+ if (ch < mStart) {
+ start = 0; end = 1;
+ collapse = "left";
+ } else if (ch < mEnd) {
+ start = ch - mStart;
+ end = start + 1;
+ } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
+ end = mEnd - mStart;
+ start = end - 1;
+ if (ch >= mEnd) collapse = "right";
+ }
+ if (start != null) {
+ node = map[i + 2];
+ if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
+ collapse = bias;
+ if (bias == "left" && start == 0)
+ while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
+ node = map[(i -= 3) + 2];
+ collapse = "left";
+ }
+ if (bias == "right" && start == mEnd - mStart)
+ while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
+ node = map[(i += 3) + 2];
+ collapse = "right";
+ }
+ break;
+ }
+ }
+ return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd};
+ }
- var outer = getRect(display.lineDiv);
- var vranges = [], data = emptyArray(line.text.length), maxBot = pre.offsetHeight;
- // Work around an IE7/8 bug where it will sometimes have randomly
- // replaced our pre with a clone at this point.
- if (ie_lt9 && display.measure.first != pre)
- removeChildrenAndAdd(display.measure, pre);
+ function measureCharInner(cm, prepared, ch, bias) {
+ var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
+ var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
- function measureRect(rect) {
- var top = rect.top - outer.top, bot = rect.bottom - outer.top;
- if (bot > maxBot) bot = maxBot;
- if (top < 0) top = 0;
- for (var i = vranges.length - 2; i >= 0; i -= 2) {
- var rtop = vranges[i], rbot = vranges[i+1];
- if (rtop > bot || rbot < top) continue;
- if (rtop <= top && rbot >= bot ||
- top <= rtop && bot >= rbot ||
- Math.min(bot, rbot) - Math.max(top, rtop) >= (bot - top) >> 1) {
- vranges[i] = Math.min(top, rtop);
- vranges[i+1] = Math.max(bot, rbot);
- break;
- }
- }
- if (i < 0) { i = vranges.length; vranges.push(top, bot); }
- return {left: rect.left - outer.left,
- right: rect.right - outer.left,
- top: i, bottom: null};
- }
- function finishRect(rect) {
- rect.bottom = vranges[rect.top+1];
- rect.top = vranges[rect.top];
- }
-
- for (var i = 0, cur; i < measure.length; ++i) if (cur = measure[i]) {
- var node = cur, rect = null;
- // A widget might wrap, needs special care
- if (/\bCodeMirror-widget\b/.test(cur.className) && cur.getClientRects) {
- if (cur.firstChild.nodeType == 1) node = cur.firstChild;
- var rects = node.getClientRects();
- if (rects.length > 1) {
- rect = data[i] = measureRect(rects[0]);
- rect.rightSide = measureRect(rects[rects.length - 1]);
+ var rect;
+ if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
+ for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
+ while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
+ while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
+ if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) {
+ rect = node.parentNode.getBoundingClientRect();
+ } else if (ie && cm.options.lineWrapping) {
+ var rects = range(node, start, end).getClientRects();
+ if (rects.length)
+ rect = rects[bias == "right" ? rects.length - 1 : 0];
+ else
+ rect = nullRect;
+ } else {
+ rect = range(node, start, end).getBoundingClientRect() || nullRect;
}
+ if (rect.left || rect.right || start == 0) break;
+ end = start;
+ start = start - 1;
+ collapse = "right";
}
- if (!rect) rect = data[i] = measureRect(getRect(node));
- if (cur.measureRight) rect.right = getRect(cur.measureRight).left - outer.left;
- if (cur.leftSide) rect.leftSide = measureRect(getRect(cur.leftSide));
+ if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect);
+ } else { // If it is a widget, simply get the box for the whole widget.
+ if (start > 0) collapse = bias = "right";
+ var rects;
+ if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
+ rect = rects[bias == "right" ? rects.length - 1 : 0];
+ else
+ rect = node.getBoundingClientRect();
}
- removeChildren(cm.display.measure);
- for (var i = 0, cur; i < data.length; ++i) if (cur = data[i]) {
- finishRect(cur);
- if (cur.leftSide) finishRect(cur.leftSide);
- if (cur.rightSide) finishRect(cur.rightSide);
+ if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
+ var rSpan = node.parentNode.getClientRects()[0];
+ if (rSpan)
+ rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};
+ else
+ rect = nullRect;
}
- return data;
+
+ var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
+ var mid = (rtop + rbot) / 2;
+ var heights = prepared.view.measure.heights;
+ for (var i = 0; i < heights.length - 1; i++)
+ if (mid < heights[i]) break;
+ var top = i ? heights[i - 1] : 0, bot = heights[i];
+ var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
+ right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
+ top: top, bottom: bot};
+ if (!rect.left && !rect.right) result.bogus = true;
+ if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
+
+ return result;
}
- function crudelyMeasureLine(cm, line) {
- var copy = new Line(line.text.slice(0, 100), null);
- if (line.textClass) copy.textClass = line.textClass;
- var measure = measureLineInner(cm, copy);
- var left = measureChar(cm, copy, 0, measure, "left");
- var right = measureChar(cm, copy, 99, measure, "right");
- return {crude: true, top: left.top, left: left.left, bottom: left.bottom, width: (right.right - left.left) / 100};
+ // Work around problem with bounding client rects on ranges being
+ // returned incorrectly when zoomed on IE10 and below.
+ function maybeUpdateRectForZooming(measure, rect) {
+ if (!window.screen || screen.logicalXDPI == null ||
+ screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
+ return rect;
+ var scaleX = screen.logicalXDPI / screen.deviceXDPI;
+ var scaleY = screen.logicalYDPI / screen.deviceYDPI;
+ return {left: rect.left * scaleX, right: rect.right * scaleX,
+ top: rect.top * scaleY, bottom: rect.bottom * scaleY};
}
- function measureLineWidth(cm, line) {
- var hasBadSpan = false;
- if (line.markedSpans) for (var i = 0; i < line.markedSpans; ++i) {
- var sp = line.markedSpans[i];
- if (sp.collapsed && (sp.to == null || sp.to == line.text.length)) hasBadSpan = true;
+ function clearLineMeasurementCacheFor(lineView) {
+ if (lineView.measure) {
+ lineView.measure.cache = {};
+ lineView.measure.heights = null;
+ if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
+ lineView.measure.caches[i] = {};
}
- var cached = !hasBadSpan && findCachedMeasurement(cm, line);
- if (cached || line.text.length >= cm.options.crudeMeasuringFrom)
- return measureChar(cm, line, line.text.length, cached && cached.measure, "right").right;
+ }
- var pre = buildLineContent(cm, line, null, true).pre;
- var end = pre.appendChild(zeroWidthElement(cm.display.measure));
- removeChildrenAndAdd(cm.display.measure, pre);
- var rect = getRect(end);
- if (rect.right == 0 && rect.bottom == 0) {
- end = pre.appendChild(elt("span", "\u00a0"));
- rect = getRect(end);
- }
- return rect.left - getRect(cm.display.lineDiv).left;
+ function clearLineMeasurementCache(cm) {
+ cm.display.externalMeasure = null;
+ removeChildren(cm.display.lineMeasure);
+ for (var i = 0; i < cm.display.view.length; i++)
+ clearLineMeasurementCacheFor(cm.display.view[i]);
}
function clearCaches(cm) {
- cm.display.measureLineCache.length = cm.display.measureLineCachePos = 0;
+ clearLineMeasurementCache(cm);
cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
cm.display.lineNumChars = null;
@@ -1186,7 +2749,10 @@ window.CodeMirror = (function() {
function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; }
function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; }
- // Context is one of "line", "div" (display.lineDiv), "local"/null (editor), or "page"
+ // Converts a {top, bottom, left, right} box from line-local
+ // coordinates into another coordinate system. Context may be one of
+ // "line", "div" (display.lineDiv), "local"/null (editor), "window",
+ // or "page".
function intoCoordSystem(cm, lineObj, rect, context) {
if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
var size = widgetHeight(lineObj.widgets[i]);
@@ -1194,11 +2760,11 @@ window.CodeMirror = (function() {
}
if (context == "line") return rect;
if (!context) context = "local";
- var yOff = heightAtLine(cm, lineObj);
+ var yOff = heightAtLine(lineObj);
if (context == "local") yOff += paddingTop(cm.display);
else yOff -= cm.display.viewOffset;
if (context == "page" || context == "window") {
- var lOff = getRect(cm.display.lineSpace);
+ var lOff = cm.display.lineSpace.getBoundingClientRect();
yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
rect.left += xOff; rect.right += xOff;
@@ -1207,8 +2773,8 @@ window.CodeMirror = (function() {
return rect;
}
- // Context may be "window", "page", "div", or "local"/null
- // Result is in "div" coords
+ // Coverts a box from "div" coords to another coordinate system.
+ // Context may be "window", "page", "div", or "local"/null.
function fromCoordSystem(cm, coords, context) {
if (context == "div") return coords;
var left = coords.left, top = coords.top;
@@ -1217,25 +2783,28 @@ window.CodeMirror = (function() {
left -= pageScrollX();
top -= pageScrollY();
} else if (context == "local" || !context) {
- var localBox = getRect(cm.display.sizer);
+ var localBox = cm.display.sizer.getBoundingClientRect();
left += localBox.left;
top += localBox.top;
}
- var lineSpaceBox = getRect(cm.display.lineSpace);
+ var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
}
function charCoords(cm, pos, context, lineObj, bias) {
if (!lineObj) lineObj = getLine(cm.doc, pos.line);
- return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, null, bias), context);
+ return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
}
- function cursorCoords(cm, pos, context, lineObj, measurement) {
+ // Returns a box for a given cursor position, which may have an
+ // 'other' property containing the position of the secondary cursor
+ // on a bidi boundary.
+ function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
lineObj = lineObj || getLine(cm.doc, pos.line);
- if (!measurement) measurement = measureLine(cm, lineObj);
+ if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
function get(ch, right) {
- var m = measureChar(cm, lineObj, ch, measurement, right ? "right" : "left");
+ var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
if (right) m.left = m.right; else m.right = m.left;
return intoCoordSystem(cm, lineObj, m, context);
}
@@ -1261,43 +2830,59 @@ window.CodeMirror = (function() {
return val;
}
+ // Used to cheaply estimate the coordinates for a position. Used for
+ // intermediate scroll updates.
+ function estimateCoords(cm, pos) {
+ var left = 0, pos = clipPos(cm.doc, pos);
+ if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
+ var lineObj = getLine(cm.doc, pos.line);
+ var top = heightAtLine(lineObj) + paddingTop(cm.display);
+ return {left: left, right: left, top: top, bottom: top + lineObj.height};
+ }
+
+ // Positions returned by coordsChar contain some extra information.
+ // xRel is the relative x position of the input coordinates compared
+ // to the found position (so xRel > 0 means the coordinates are to
+ // the right of the character position, for example). When outside
+ // is true, that means the coordinates lie outside the line's
+ // vertical range.
function PosWithInfo(line, ch, outside, xRel) {
- var pos = new Pos(line, ch);
+ var pos = Pos(line, ch);
pos.xRel = xRel;
if (outside) pos.outside = true;
return pos;
}
- // Coords must be lineSpace-local
+ // Compute the character position closest to the given coordinates.
+ // Input must be lineSpace-local ("div" coordinate system).
function coordsChar(cm, x, y) {
var doc = cm.doc;
y += cm.display.viewOffset;
if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
- var lineNo = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
- if (lineNo > last)
+ var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
+ if (lineN > last)
return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
if (x < 0) x = 0;
+ var lineObj = getLine(doc, lineN);
for (;;) {
- var lineObj = getLine(doc, lineNo);
- var found = coordsCharInner(cm, lineObj, lineNo, x, y);
+ var found = coordsCharInner(cm, lineObj, lineN, x, y);
var merged = collapsedSpanAtEnd(lineObj);
- var mergedPos = merged && merged.find();
+ var mergedPos = merged && merged.find(0, true);
if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
- lineNo = mergedPos.to.line;
+ lineN = lineNo(lineObj = mergedPos.to.line);
else
return found;
}
}
function coordsCharInner(cm, lineObj, lineNo, x, y) {
- var innerOff = y - heightAtLine(cm, lineObj);
+ var innerOff = y - heightAtLine(lineObj);
var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
- var measurement = measureLine(cm, lineObj);
+ var preparedMeasure = prepareMeasureForLine(cm, lineObj);
function getX(ch) {
- var sp = cursorCoords(cm, Pos(lineNo, ch), "line",
- lineObj, measurement);
+ var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
wrongLine = true;
if (innerOff > sp.bottom) return sp.left - adjust;
else if (innerOff < sp.top) return sp.left + adjust;
@@ -1317,7 +2902,7 @@ window.CodeMirror = (function() {
var xDiff = x - (ch == from ? fromX : toX);
while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
- xDiff < 0 ? -1 : xDiff ? 1 : 0);
+ xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
return pos;
}
var step = Math.ceil(dist / 2), middle = from + step;
@@ -1332,6 +2917,7 @@ window.CodeMirror = (function() {
}
var measureText;
+ // Compute the default text height.
function textHeight(display) {
if (display.cachedTextHeight != null) return display.cachedTextHeight;
if (measureText == null) {
@@ -1351,259 +2937,512 @@ window.CodeMirror = (function() {
return height || 1;
}
+ // Compute the default character width.
function charWidth(display) {
if (display.cachedCharWidth != null) return display.cachedCharWidth;
- var anchor = elt("span", "x");
+ var anchor = elt("span", "xxxxxxxxxx");
var pre = elt("pre", [anchor]);
removeChildrenAndAdd(display.measure, pre);
- var width = anchor.offsetWidth;
+ var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
if (width > 2) display.cachedCharWidth = width;
return width || 10;
}
// OPERATIONS
- // Operations are used to wrap changes in such a way that each
- // change won't have to update the cursor and display (which would
- // be awkward, slow, and error-prone), but instead updates are
- // batched and then all combined and executed at once.
+ // Operations are used to wrap a series of changes to the editor
+ // state in such a way that each change won't have to update the
+ // cursor and display (which would be awkward, slow, and
+ // error-prone). Instead, display updates are batched and then all
+ // combined and executed at once.
+
+ var operationGroup = null;
var nextOpId = 0;
+ // Start a new operation.
function startOperation(cm) {
cm.curOp = {
- // An array of ranges of lines that have to be updated. See
- // updateDisplay.
- changes: [],
- forceUpdate: false,
- updateInput: null,
- userSelChange: null,
- textChanged: null,
- selectionChanged: false,
- cursorActivity: false,
- updateMaxLine: false,
- updateScrollPos: false,
- id: ++nextOpId
+ cm: cm,
+ viewChanged: false, // Flag that indicates that lines might need to be redrawn
+ startHeight: cm.doc.height, // Used to detect need to update scrollbar
+ forceUpdate: false, // Used to force a redraw
+ updateInput: null, // Whether to reset the input textarea
+ typing: false, // Whether this reset should be careful to leave existing text (for compositing)
+ changeObjs: null, // Accumulated changes, for firing change events
+ cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
+ cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
+ selectionChanged: false, // Whether the selection needs to be redrawn
+ updateMaxLine: false, // Set when the widest line needs to be determined anew
+ scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
+ scrollToPos: null, // Used to scroll to a specific position
+ focus: false,
+ id: ++nextOpId // Unique ID
};
- if (!delayedCallbackDepth++) delayedCallbacks = [];
+ if (operationGroup) {
+ operationGroup.ops.push(cm.curOp);
+ } else {
+ cm.curOp.ownsGroup = operationGroup = {
+ ops: [cm.curOp],
+ delayedCallbacks: []
+ };
+ }
+ }
+
+ function fireCallbacksForOps(group) {
+ // Calls delayed callbacks and cursorActivity handlers until no
+ // new ones appear
+ var callbacks = group.delayedCallbacks, i = 0;
+ do {
+ for (; i < callbacks.length; i++)
+ callbacks[i].call(null);
+ for (var j = 0; j < group.ops.length; j++) {
+ var op = group.ops[j];
+ if (op.cursorActivityHandlers)
+ while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
+ op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm);
+ }
+ } while (i < callbacks.length);
}
+ // Finish an operation, updating the display and signalling delayed events
function endOperation(cm) {
- var op = cm.curOp, doc = cm.doc, display = cm.display;
- cm.curOp = null;
-
- if (op.updateMaxLine) computeMaxLength(cm);
- if (display.maxLineChanged && !cm.options.lineWrapping && display.maxLine) {
- var width = measureLineWidth(cm, display.maxLine);
- display.sizer.style.minWidth = Math.max(0, width + 3) + "px";
- display.maxLineChanged = false;
- var maxScrollLeft = Math.max(0, display.sizer.offsetLeft + display.sizer.offsetWidth - display.scroller.clientWidth);
- if (maxScrollLeft < doc.scrollLeft && !op.updateScrollPos)
- setScrollLeft(cm, Math.min(display.scroller.scrollLeft, maxScrollLeft), true);
- }
- var newScrollPos, updated;
- if (op.updateScrollPos) {
- newScrollPos = op.updateScrollPos;
- } else if (op.selectionChanged && display.scroller.clientHeight) { // don't rescroll if not visible
- var coords = cursorCoords(cm, doc.sel.head);
- newScrollPos = calculateScrollPos(cm, coords.left, coords.top, coords.left, coords.bottom);
- }
- if (op.changes.length || op.forceUpdate || newScrollPos && newScrollPos.scrollTop != null) {
- updated = updateDisplay(cm, op.changes, newScrollPos && newScrollPos.scrollTop, op.forceUpdate);
- if (cm.display.scroller.offsetHeight) cm.doc.scrollTop = cm.display.scroller.scrollTop;
- }
- if (!updated && op.selectionChanged) updateSelection(cm);
- if (op.updateScrollPos) {
- var top = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, newScrollPos.scrollTop));
- var left = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, newScrollPos.scrollLeft));
- display.scroller.scrollTop = display.scrollbarV.scrollTop = doc.scrollTop = top;
- display.scroller.scrollLeft = display.scrollbarH.scrollLeft = doc.scrollLeft = left;
- alignHorizontally(cm);
- if (op.scrollToPos)
- scrollPosIntoView(cm, clipPos(cm.doc, op.scrollToPos.from),
- clipPos(cm.doc, op.scrollToPos.to), op.scrollToPos.margin);
- } else if (newScrollPos) {
- scrollCursorIntoView(cm);
+ var op = cm.curOp, group = op.ownsGroup;
+ if (!group) return;
+
+ try { fireCallbacksForOps(group); }
+ finally {
+ operationGroup = null;
+ for (var i = 0; i < group.ops.length; i++)
+ group.ops[i].cm.curOp = null;
+ endOperations(group);
+ }
+ }
+
+ // The DOM updates done when an operation finishes are batched so
+ // that the minimum number of relayouts are required.
+ function endOperations(group) {
+ var ops = group.ops;
+ for (var i = 0; i < ops.length; i++) // Read DOM
+ endOperation_R1(ops[i]);
+ for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
+ endOperation_W1(ops[i]);
+ for (var i = 0; i < ops.length; i++) // Read DOM
+ endOperation_R2(ops[i]);
+ for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
+ endOperation_W2(ops[i]);
+ for (var i = 0; i < ops.length; i++) // Read DOM
+ endOperation_finish(ops[i]);
+ }
+
+ function endOperation_R1(op) {
+ var cm = op.cm, display = cm.display;
+ maybeClipScrollbars(cm);
+ if (op.updateMaxLine) findMaxLine(cm);
+
+ op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
+ op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
+ op.scrollToPos.to.line >= display.viewTo) ||
+ display.maxLineChanged && cm.options.lineWrapping;
+ op.update = op.mustUpdate &&
+ new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
+ }
+
+ function endOperation_W1(op) {
+ op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
+ }
+
+ function endOperation_R2(op) {
+ var cm = op.cm, display = cm.display;
+ if (op.updatedDisplay) updateHeightsInViewport(cm);
+
+ op.barMeasure = measureForScrollbars(cm);
+
+ // If the max line changed since it was last measured, measure it,
+ // and ensure the document's width matches it.
+ // updateDisplay_W2 will use these properties to do the actual resizing
+ if (display.maxLineChanged && !cm.options.lineWrapping) {
+ op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
+ cm.display.sizerWidth = op.adjustWidthTo;
+ op.barMeasure.scrollWidth =
+ Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
+ op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
+ }
+
+ if (op.updatedDisplay || op.selectionChanged)
+ op.preparedSelection = display.input.prepareSelection();
+ }
+
+ function endOperation_W2(op) {
+ var cm = op.cm;
+
+ if (op.adjustWidthTo != null) {
+ cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
+ if (op.maxScrollLeft < cm.doc.scrollLeft)
+ setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true);
+ cm.display.maxLineChanged = false;
}
+
+ if (op.preparedSelection)
+ cm.display.input.showSelection(op.preparedSelection);
+ if (op.updatedDisplay)
+ setDocumentHeight(cm, op.barMeasure);
+ if (op.updatedDisplay || op.startHeight != cm.doc.height)
+ updateScrollbars(cm, op.barMeasure);
+
if (op.selectionChanged) restartBlink(cm);
if (cm.state.focused && op.updateInput)
- resetInput(cm, op.userSelChange);
+ cm.display.input.reset(op.typing);
+ if (op.focus && op.focus == activeElt()) ensureFocus(op.cm);
+ }
+
+ function endOperation_finish(op) {
+ var cm = op.cm, display = cm.display, doc = cm.doc;
+
+ if (op.updatedDisplay) postUpdateDisplay(cm, op.update);
+
+ // Abort mouse wheel delta measurement, when scrolling explicitly
+ if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
+ display.wheelStartX = display.wheelStartY = null;
+ // Propagate the scroll position to the actual DOM scroller
+ if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) {
+ doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop));
+ display.scrollbars.setScrollTop(doc.scrollTop);
+ display.scroller.scrollTop = doc.scrollTop;
+ }
+ if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
+ doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft));
+ display.scrollbars.setScrollLeft(doc.scrollLeft);
+ display.scroller.scrollLeft = doc.scrollLeft;
+ alignHorizontally(cm);
+ }
+ // If we need to scroll a specific position into view, do so.
+ if (op.scrollToPos) {
+ var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
+ clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
+ if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords);
+ }
+
+ // Fire events for markers that are hidden/unidden by editing or
+ // undoing
var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
if (hidden) for (var i = 0; i < hidden.length; ++i)
if (!hidden[i].lines.length) signal(hidden[i], "hide");
if (unhidden) for (var i = 0; i < unhidden.length; ++i)
if (unhidden[i].lines.length) signal(unhidden[i], "unhide");
- var delayed;
- if (!--delayedCallbackDepth) {
- delayed = delayedCallbacks;
- delayedCallbacks = null;
- }
- if (op.textChanged)
- signal(cm, "change", cm, op.textChanged);
- if (op.cursorActivity) signal(cm, "cursorActivity", cm);
- if (delayed) for (var i = 0; i < delayed.length; ++i) delayed[i]();
+ if (display.wrapper.offsetHeight)
+ doc.scrollTop = cm.display.scroller.scrollTop;
+
+ // Fire change events, and delayed event handlers
+ if (op.changeObjs)
+ signal(cm, "changes", cm, op.changeObjs);
+ if (op.update)
+ op.update.finish();
}
+ // Run the given function in an operation
+ function runInOp(cm, f) {
+ if (cm.curOp) return f();
+ startOperation(cm);
+ try { return f(); }
+ finally { endOperation(cm); }
+ }
// Wraps a function in an operation. Returns the wrapped function.
- function operation(cm1, f) {
+ function operation(cm, f) {
return function() {
- var cm = cm1 || this, withOp = !cm.curOp;
- if (withOp) startOperation(cm);
- try { var result = f.apply(cm, arguments); }
- finally { if (withOp) endOperation(cm); }
- return result;
+ if (cm.curOp) return f.apply(cm, arguments);
+ startOperation(cm);
+ try { return f.apply(cm, arguments); }
+ finally { endOperation(cm); }
};
}
- function docOperation(f) {
+ // Used to add methods to editor and doc instances, wrapping them in
+ // operations.
+ function methodOp(f) {
return function() {
- var withOp = this.cm && !this.cm.curOp, result;
- if (withOp) startOperation(this.cm);
- try { result = f.apply(this, arguments); }
- finally { if (withOp) endOperation(this.cm); }
- return result;
+ if (this.curOp) return f.apply(this, arguments);
+ startOperation(this);
+ try { return f.apply(this, arguments); }
+ finally { endOperation(this); }
};
}
- function runInOp(cm, f) {
- var withOp = !cm.curOp, result;
- if (withOp) startOperation(cm);
- try { result = f(); }
- finally { if (withOp) endOperation(cm); }
- return result;
- }
-
- function regChange(cm, from, to, lendiff) {
- if (from == null) from = cm.doc.first;
- if (to == null) to = cm.doc.first + cm.doc.size;
- cm.curOp.changes.push({from: from, to: to, diff: lendiff});
+ function docMethodOp(f) {
+ return function() {
+ var cm = this.cm;
+ if (!cm || cm.curOp) return f.apply(this, arguments);
+ startOperation(cm);
+ try { return f.apply(this, arguments); }
+ finally { endOperation(cm); }
+ };
}
- // INPUT HANDLING
+ // VIEW TRACKING
- function slowPoll(cm) {
- if (cm.display.pollingFast) return;
- cm.display.poll.set(cm.options.pollInterval, function() {
- readInput(cm);
- if (cm.state.focused) slowPoll(cm);
- });
+ // These objects are used to represent the visible (currently drawn)
+ // part of the document. A LineView may correspond to multiple
+ // logical lines, if those are connected by collapsed ranges.
+ function LineView(doc, line, lineN) {
+ // The starting line
+ this.line = line;
+ // Continuing lines, if any
+ this.rest = visualLineContinued(line);
+ // Number of logical lines in this visual line
+ this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
+ this.node = this.text = null;
+ this.hidden = lineIsHidden(doc, line);
}
- function fastPoll(cm) {
- var missed = false;
- cm.display.pollingFast = true;
- function p() {
- var changed = readInput(cm);
- if (!changed && !missed) {missed = true; cm.display.poll.set(60, p);}
- else {cm.display.pollingFast = false; slowPoll(cm);}
- }
- cm.display.poll.set(20, p);
- }
-
- // prevInput is a hack to work with IME. If we reset the textarea
- // on every change, that breaks IME. So we look for changes
- // compared to the previous content instead. (Modern browsers have
- // events that indicate IME taking place, but these are not widely
- // supported or compatible enough yet to rely on.)
- function readInput(cm) {
- var input = cm.display.input, prevInput = cm.display.prevInput, doc = cm.doc, sel = doc.sel;
- if (!cm.state.focused || hasSelection(input) || isReadOnly(cm) || cm.options.disableInput) return false;
- var text = input.value;
- if (text == prevInput && posEq(sel.from, sel.to)) return false;
- if (ie && !ie_lt9 && cm.display.inputHasSelection === text) {
- resetInput(cm, true);
- return false;
- }
-
- var withOp = !cm.curOp;
- if (withOp) startOperation(cm);
- sel.shift = false;
- var same = 0, l = Math.min(prevInput.length, text.length);
- while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
- var from = sel.from, to = sel.to;
- var inserted = text.slice(same);
- if (same < prevInput.length)
- from = Pos(from.line, from.ch - (prevInput.length - same));
- else if (cm.state.overwrite && posEq(from, to) && !cm.state.pasteIncoming)
- to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + inserted.length));
-
- var updateInput = cm.curOp.updateInput;
- var changeEvent = {from: from, to: to, text: splitLines(inserted),
- origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"};
- makeChange(cm.doc, changeEvent, "end");
- cm.curOp.updateInput = updateInput;
- signalLater(cm, "inputRead", cm, changeEvent);
- if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&
- cm.options.smartIndent && sel.head.ch < 100) {
- var electric = cm.getModeAt(sel.head).electricChars;
- if (electric) for (var i = 0; i < electric.length; i++)
- if (inserted.indexOf(electric.charAt(i)) > -1) {
- indentLine(cm, sel.head.line, "smart");
- break;
- }
+ // Create a range of LineView objects for the given lines.
+ function buildViewArray(cm, from, to) {
+ var array = [], nextPos;
+ for (var pos = from; pos < to; pos = nextPos) {
+ var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
+ nextPos = pos + view.size;
+ array.push(view);
}
-
- if (text.length > 1000 || text.indexOf("\n") > -1) input.value = cm.display.prevInput = "";
- else cm.display.prevInput = text;
- if (withOp) endOperation(cm);
- cm.state.pasteIncoming = cm.state.cutIncoming = false;
- return true;
+ return array;
}
- function resetInput(cm, user) {
- var minimal, selected, doc = cm.doc;
- if (!posEq(doc.sel.from, doc.sel.to)) {
- cm.display.prevInput = "";
- minimal = hasCopyEvent &&
- (doc.sel.to.line - doc.sel.from.line > 100 || (selected = cm.getSelection()).length > 1000);
- var content = minimal ? "-" : selected || cm.getSelection();
- cm.display.input.value = content;
- if (cm.state.focused) selectInput(cm.display.input);
- if (ie && !ie_lt9) cm.display.inputHasSelection = content;
- } else if (user) {
- cm.display.prevInput = cm.display.input.value = "";
- if (ie && !ie_lt9) cm.display.inputHasSelection = null;
+ // Updates the display.view data structure for a given change to the
+ // document. From and to are in pre-change coordinates. Lendiff is
+ // the amount of lines added or subtracted by the change. This is
+ // used for changes that span multiple lines, or change the way
+ // lines are divided into visual lines. regLineChange (below)
+ // registers single-line changes.
+ function regChange(cm, from, to, lendiff) {
+ if (from == null) from = cm.doc.first;
+ if (to == null) to = cm.doc.first + cm.doc.size;
+ if (!lendiff) lendiff = 0;
+
+ var display = cm.display;
+ if (lendiff && to < display.viewTo &&
+ (display.updateLineNumbers == null || display.updateLineNumbers > from))
+ display.updateLineNumbers = from;
+
+ cm.curOp.viewChanged = true;
+
+ if (from >= display.viewTo) { // Change after
+ if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
+ resetView(cm);
+ } else if (to <= display.viewFrom) { // Change before
+ if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
+ resetView(cm);
+ } else {
+ display.viewFrom += lendiff;
+ display.viewTo += lendiff;
+ }
+ } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
+ resetView(cm);
+ } else if (from <= display.viewFrom) { // Top overlap
+ var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
+ if (cut) {
+ display.view = display.view.slice(cut.index);
+ display.viewFrom = cut.lineN;
+ display.viewTo += lendiff;
+ } else {
+ resetView(cm);
+ }
+ } else if (to >= display.viewTo) { // Bottom overlap
+ var cut = viewCuttingPoint(cm, from, from, -1);
+ if (cut) {
+ display.view = display.view.slice(0, cut.index);
+ display.viewTo = cut.lineN;
+ } else {
+ resetView(cm);
+ }
+ } else { // Gap in the middle
+ var cutTop = viewCuttingPoint(cm, from, from, -1);
+ var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
+ if (cutTop && cutBot) {
+ display.view = display.view.slice(0, cutTop.index)
+ .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
+ .concat(display.view.slice(cutBot.index));
+ display.viewTo += lendiff;
+ } else {
+ resetView(cm);
+ }
}
- cm.display.inaccurateSelection = minimal;
- }
- function focusInput(cm) {
- if (cm.options.readOnly != "nocursor" && (!mobile || document.activeElement != cm.display.input))
- cm.display.input.focus();
+ var ext = display.externalMeasured;
+ if (ext) {
+ if (to < ext.lineN)
+ ext.lineN += lendiff;
+ else if (from < ext.lineN + ext.size)
+ display.externalMeasured = null;
+ }
+ }
+
+ // Register a change to a single line. Type must be one of "text",
+ // "gutter", "class", "widget"
+ function regLineChange(cm, line, type) {
+ cm.curOp.viewChanged = true;
+ var display = cm.display, ext = cm.display.externalMeasured;
+ if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
+ display.externalMeasured = null;
+
+ if (line < display.viewFrom || line >= display.viewTo) return;
+ var lineView = display.view[findViewIndex(cm, line)];
+ if (lineView.node == null) return;
+ var arr = lineView.changes || (lineView.changes = []);
+ if (indexOf(arr, type) == -1) arr.push(type);
+ }
+
+ // Clear the view.
+ function resetView(cm) {
+ cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
+ cm.display.view = [];
+ cm.display.viewOffset = 0;
+ }
+
+ // Find the view element corresponding to a given line. Return null
+ // when the line isn't visible.
+ function findViewIndex(cm, n) {
+ if (n >= cm.display.viewTo) return null;
+ n -= cm.display.viewFrom;
+ if (n < 0) return null;
+ var view = cm.display.view;
+ for (var i = 0; i < view.length; i++) {
+ n -= view[i].size;
+ if (n < 0) return i;
+ }
+ }
+
+ function viewCuttingPoint(cm, oldN, newN, dir) {
+ var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
+ if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
+ return {index: index, lineN: newN};
+ for (var i = 0, n = cm.display.viewFrom; i < index; i++)
+ n += view[i].size;
+ if (n != oldN) {
+ if (dir > 0) {
+ if (index == view.length - 1) return null;
+ diff = (n + view[index].size) - oldN;
+ index++;
+ } else {
+ diff = n - oldN;
+ }
+ oldN += diff; newN += diff;
+ }
+ while (visualLineNo(cm.doc, newN) != newN) {
+ if (index == (dir < 0 ? 0 : view.length - 1)) return null;
+ newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
+ index += dir;
+ }
+ return {index: index, lineN: newN};
}
- function ensureFocus(cm) {
- if (!cm.state.focused) { focusInput(cm); onFocus(cm); }
+ // Force the view to cover a given range, adding empty view element
+ // or clipping off existing ones as needed.
+ function adjustView(cm, from, to) {
+ var display = cm.display, view = display.view;
+ if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
+ display.view = buildViewArray(cm, from, to);
+ display.viewFrom = from;
+ } else {
+ if (display.viewFrom > from)
+ display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
+ else if (display.viewFrom < from)
+ display.view = display.view.slice(findViewIndex(cm, from));
+ display.viewFrom = from;
+ if (display.viewTo < to)
+ display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
+ else if (display.viewTo > to)
+ display.view = display.view.slice(0, findViewIndex(cm, to));
+ }
+ display.viewTo = to;
}
- function isReadOnly(cm) {
- return cm.options.readOnly || cm.doc.cantEdit;
+ // Count the number of lines in the view whose DOM representation is
+ // out of date (or nonexistent).
+ function countDirtyView(cm) {
+ var view = cm.display.view, dirty = 0;
+ for (var i = 0; i < view.length; i++) {
+ var lineView = view[i];
+ if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;
+ }
+ return dirty;
}
// EVENT HANDLERS
+ // Attach the necessary event handlers when initializing the editor
function registerEventHandlers(cm) {
var d = cm.display;
on(d.scroller, "mousedown", operation(cm, onMouseDown));
- if (old_ie)
+ // Older IE's will not fire a second mousedown for a double click
+ if (ie && ie_version < 11)
on(d.scroller, "dblclick", operation(cm, function(e) {
if (signalDOMEvent(cm, e)) return;
var pos = posFromMouse(cm, e);
if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
e_preventDefault(e);
- var word = findWordAt(getLine(cm.doc, pos.line).text, pos);
- extendSelection(cm.doc, word.from, word.to);
+ var word = cm.findWordAt(pos);
+ extendSelection(cm.doc, word.anchor, word.head);
}));
else
on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
- on(d.lineSpace, "selectstart", function(e) {
- if (!eventInWidget(d, e)) e_preventDefault(e);
- });
- // Gecko browsers fire contextmenu *after* opening the menu, at
+ // Some browsers fire contextmenu *after* opening the menu, at
// which point we can't mess with it anymore. Context menu is
- // handled in onMouseDown for Gecko.
- if (!captureMiddleClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
+ // handled in onMouseDown for these browsers.
+ if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
+
+ // Used to suppress mouse event handling when a touch happens
+ var touchFinished, prevTouch = {end: 0};
+ function finishTouch() {
+ if (d.activeTouch) {
+ touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000);
+ prevTouch = d.activeTouch;
+ prevTouch.end = +new Date;
+ }
+ };
+ function isMouseLikeTouchEvent(e) {
+ if (e.touches.length != 1) return false;
+ var touch = e.touches[0];
+ return touch.radiusX <= 1 && touch.radiusY <= 1;
+ }
+ function farAway(touch, other) {
+ if (other.left == null) return true;
+ var dx = other.left - touch.left, dy = other.top - touch.top;
+ return dx * dx + dy * dy > 20 * 20;
+ }
+ on(d.scroller, "touchstart", function(e) {
+ if (!isMouseLikeTouchEvent(e)) {
+ clearTimeout(touchFinished);
+ var now = +new Date;
+ d.activeTouch = {start: now, moved: false,
+ prev: now - prevTouch.end <= 300 ? prevTouch : null};
+ if (e.touches.length == 1) {
+ d.activeTouch.left = e.touches[0].pageX;
+ d.activeTouch.top = e.touches[0].pageY;
+ }
+ }
+ });
+ on(d.scroller, "touchmove", function() {
+ if (d.activeTouch) d.activeTouch.moved = true;
+ });
+ on(d.scroller, "touchend", function(e) {
+ var touch = d.activeTouch;
+ if (touch && !eventInWidget(d, e) && touch.left != null &&
+ !touch.moved && new Date - touch.start < 300) {
+ var pos = cm.coordsChar(d.activeTouch, "page"), range;
+ if (!touch.prev || farAway(touch, touch.prev)) // Single tap
+ range = new Range(pos, pos);
+ else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
+ range = cm.findWordAt(pos);
+ else // Triple tap
+ range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)));
+ cm.setSelection(range.anchor, range.head);
+ cm.focus();
+ e_preventDefault(e);
+ }
+ finishTouch();
+ });
+ on(d.scroller, "touchcancel", finishTouch);
+ // Sync scrolling between fake scrollbars and real scrollable
+ // area, ensure viewport is updated when scrolling.
on(d.scroller, "scroll", function() {
if (d.scroller.clientHeight) {
setScrollTop(cm, d.scroller.scrollTop);
@@ -1611,119 +3450,100 @@ window.CodeMirror = (function() {
signal(cm, "scroll", cm);
}
});
- on(d.scrollbarV, "scroll", function() {
- if (d.scroller.clientHeight) setScrollTop(cm, d.scrollbarV.scrollTop);
- });
- on(d.scrollbarH, "scroll", function() {
- if (d.scroller.clientHeight) setScrollLeft(cm, d.scrollbarH.scrollLeft);
- });
+ // Listen to wheel events in order to try and update the viewport on time.
on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
- function reFocus() { if (cm.state.focused) setTimeout(bind(focusInput, cm), 0); }
- on(d.scrollbarH, "mousedown", reFocus);
- on(d.scrollbarV, "mousedown", reFocus);
// Prevent wrapper from ever scrolling
on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
- var resizeTimer;
- function onResize() {
- if (resizeTimer == null) resizeTimer = setTimeout(function() {
- resizeTimer = null;
- // Might be a text scaling operation, clear size caches.
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = knownScrollbarWidth = null;
- clearCaches(cm);
- runInOp(cm, bind(regChange, cm));
- }, 100);
- }
- on(window, "resize", onResize);
- // Above handler holds on to the editor and its data structures.
- // Here we poll to unregister it when the editor is no longer in
- // the document, so that it can be garbage-collected.
- function unregister() {
- for (var p = d.wrapper.parentNode; p && p != document.body; p = p.parentNode) {}
- if (p) setTimeout(unregister, 5000);
- else off(window, "resize", onResize);
- }
- setTimeout(unregister, 5000);
-
- on(d.input, "keyup", operation(cm, onKeyUp));
- on(d.input, "input", function() {
- if (ie && !ie_lt9 && cm.display.inputHasSelection) cm.display.inputHasSelection = null;
- fastPoll(cm);
- });
- on(d.input, "keydown", operation(cm, onKeyDown));
- on(d.input, "keypress", operation(cm, onKeyPress));
- on(d.input, "focus", bind(onFocus, cm));
- on(d.input, "blur", bind(onBlur, cm));
-
- function drag_(e) {
- if (signalDOMEvent(cm, e) || cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e))) return;
- e_stop(e);
- }
- if (cm.options.dragDrop) {
- on(d.scroller, "dragstart", function(e){onDragStart(cm, e);});
- on(d.scroller, "dragenter", drag_);
- on(d.scroller, "dragover", drag_);
- on(d.scroller, "drop", operation(cm, onDrop));
- }
- on(d.scroller, "paste", function(e) {
- if (eventInWidget(d, e)) return;
- focusInput(cm);
- fastPoll(cm);
- });
- on(d.input, "paste", function() {
- cm.state.pasteIncoming = true;
- fastPoll(cm);
- });
+ d.dragFunctions = {
+ enter: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
+ over: function(e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
+ start: function(e){onDragStart(cm, e);},
+ drop: operation(cm, onDrop),
+ leave: function() {clearDragCursor(cm);}
+ };
- function prepareCopy(e) {
- if (d.inaccurateSelection) {
- d.prevInput = "";
- d.inaccurateSelection = false;
- d.input.value = cm.getSelection();
- selectInput(d.input);
- }
- if (e.type == "cut") cm.state.cutIncoming = true;
+ var inp = d.input.getField();
+ on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
+ on(inp, "keydown", operation(cm, onKeyDown));
+ on(inp, "keypress", operation(cm, onKeyPress));
+ on(inp, "focus", bind(onFocus, cm));
+ on(inp, "blur", bind(onBlur, cm));
+ }
+
+ function dragDropChanged(cm, value, old) {
+ var wasOn = old && old != CodeMirror.Init;
+ if (!value != !wasOn) {
+ var funcs = cm.display.dragFunctions;
+ var toggle = value ? on : off;
+ toggle(cm.display.scroller, "dragstart", funcs.start);
+ toggle(cm.display.scroller, "dragenter", funcs.enter);
+ toggle(cm.display.scroller, "dragover", funcs.over);
+ toggle(cm.display.scroller, "dragleave", funcs.leave);
+ toggle(cm.display.scroller, "drop", funcs.drop);
}
- on(d.input, "cut", prepareCopy);
- on(d.input, "copy", prepareCopy);
+ }
- // Needed to handle Tab key in KHTML
- if (khtml) on(d.sizer, "mouseup", function() {
- if (document.activeElement == d.input) d.input.blur();
- focusInput(cm);
- });
+ // Called when the window resizes
+ function onResize(cm) {
+ var d = cm.display;
+ if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
+ return;
+ // Might be a text scaling operation, clear size caches.
+ d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
+ d.scrollbarsClipped = false;
+ cm.setSize();
}
+ // MOUSE EVENTS
+
+ // Return true when the given mouse event happened in a widget
function eventInWidget(display, e) {
for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
- if (!n || n.ignoreEvents || n.parentNode == display.sizer && n != display.mover) return true;
+ if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
+ (n.parentNode == display.sizer && n != display.mover))
+ return true;
}
}
- function posFromMouse(cm, e, liberal) {
+ // Given a mouse event, find the corresponding position. If liberal
+ // is false, it checks whether a gutter or scrollbar was clicked,
+ // and returns null if it was. forRect is used by rectangular
+ // selections, and tries to estimate a character position even for
+ // coordinates beyond the right of the text.
+ function posFromMouse(cm, e, liberal, forRect) {
var display = cm.display;
- if (!liberal) {
- var target = e_target(e);
- if (target == display.scrollbarH || target == display.scrollbarV ||
- target == display.scrollbarFiller || target == display.gutterFiller) return null;
- }
- var x, y, space = getRect(display.lineSpace);
+ if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null;
+
+ var x, y, space = display.lineSpace.getBoundingClientRect();
// Fails unpredictably on IE[67] when mouse is dragged around quickly.
- try { x = e.clientX; y = e.clientY; } catch (e) { return null; }
- return coordsChar(cm, x - space.left, y - space.top);
+ try { x = e.clientX - space.left; y = e.clientY - space.top; }
+ catch (e) { return null; }
+ var coords = coordsChar(cm, x, y), line;
+ if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
+ var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
+ coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
+ }
+ return coords;
}
- var lastClick, lastDoubleClick;
+ // A mouse down can be a single click, double click, triple click,
+ // start of selection drag, start of text drag, new cursor
+ // (ctrl-click), rectangle drag (alt-drag), or xwin
+ // middle-click-paste. Or it might be a click on something we should
+ // not interfere with, such as a scrollbar or widget.
function onMouseDown(e) {
- if (signalDOMEvent(this, e)) return;
- var cm = this, display = cm.display, doc = cm.doc, sel = doc.sel;
- sel.shift = e.shiftKey;
+ var cm = this, display = cm.display;
+ if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return;
+ display.shift = e.shiftKey;
if (eventInWidget(display, e)) {
if (!webkit) {
+ // Briefly turn off draggability, to allow widgets to do
+ // normal dragging things.
display.scroller.draggable = false;
setTimeout(function(){display.scroller.draggable = true;}, 100);
}
@@ -1734,90 +3554,182 @@ window.CodeMirror = (function() {
window.focus();
switch (e_button(e)) {
- case 3:
- if (captureMiddleClick) onContextMenu.call(cm, cm, e);
- return;
+ case 1:
+ // #3261: make sure, that we're not starting a second selection
+ if (cm.state.selectingText)
+ cm.state.selectingText(e);
+ else if (start)
+ leftButtonDown(cm, e, start);
+ else if (e_target(e) == display.scroller)
+ e_preventDefault(e);
+ break;
case 2:
if (webkit) cm.state.lastMiddleDown = +new Date;
if (start) extendSelection(cm.doc, start);
- setTimeout(bind(focusInput, cm), 20);
+ setTimeout(function() {display.input.focus();}, 20);
e_preventDefault(e);
- return;
- }
- // For button 1, if it was clicked inside the editor
- // (posFromMouse returning non-null), we have to adjust the
- // selection.
- if (!start) {if (e_target(e) == display.scroller) e_preventDefault(e); return;}
-
- setTimeout(bind(ensureFocus, cm), 0);
-
- var now = +new Date, type = "single";
- if (lastDoubleClick && lastDoubleClick.time > now - 400 && posEq(lastDoubleClick.pos, start)) {
- type = "triple";
- e_preventDefault(e);
- setTimeout(bind(focusInput, cm), 20);
- selectLine(cm, start.line);
- } else if (lastClick && lastClick.time > now - 400 && posEq(lastClick.pos, start)) {
- type = "double";
- lastDoubleClick = {time: now, pos: start};
- e_preventDefault(e);
- var word = findWordAt(getLine(doc, start.line).text, start);
- extendSelection(cm.doc, word.from, word.to);
- } else { lastClick = {time: now, pos: start}; }
-
- var last = start;
- if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && !posEq(sel.from, sel.to) &&
- !posLess(start, sel.from) && !posLess(sel.to, start) && type == "single") {
- var dragEnd = operation(cm, function(e2) {
- if (webkit) display.scroller.draggable = false;
- cm.state.draggingText = false;
- off(document, "mouseup", dragEnd);
- off(display.scroller, "drop", dragEnd);
- if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
- e_preventDefault(e2);
- extendSelection(cm.doc, start);
- focusInput(cm);
- // Work around unexplainable focus problem in IE9 (#2127)
- if (old_ie && !ie_lt9)
- setTimeout(function() {document.body.focus(); focusInput(cm);}, 20);
- }
- });
- // Let the drag handler handle this.
- if (webkit) display.scroller.draggable = true;
- cm.state.draggingText = dragEnd;
- // IE's approach to draggable
- if (display.scroller.dragDrop) display.scroller.dragDrop();
- on(document, "mouseup", dragEnd);
- on(display.scroller, "drop", dragEnd);
- return;
+ break;
+ case 3:
+ if (captureRightClick) onContextMenu(cm, e);
+ else delayBlurEvent(cm);
+ break;
}
- e_preventDefault(e);
- if (type == "single") extendSelection(cm.doc, clipPos(doc, start));
+ }
- var startstart = sel.from, startend = sel.to, lastPos = start;
+ var lastClick, lastDoubleClick;
+ function leftButtonDown(cm, e, start) {
+ if (ie) setTimeout(bind(ensureFocus, cm), 0);
+ else cm.curOp.focus = activeElt();
- function doSelect(cur) {
- if (posEq(lastPos, cur)) return;
- lastPos = cur;
+ var now = +new Date, type;
+ if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
+ type = "triple";
+ } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
+ type = "double";
+ lastDoubleClick = {time: now, pos: start};
+ } else {
+ type = "single";
+ lastClick = {time: now, pos: start};
+ }
- if (type == "single") {
- extendSelection(cm.doc, clipPos(doc, start), cur);
- return;
+ var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
+ if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
+ type == "single" && (contained = sel.contains(start)) > -1 &&
+ (cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
+ (cmp(contained.to(), start) > 0 || start.xRel < 0))
+ leftButtonStartDrag(cm, e, start, modifier);
+ else
+ leftButtonSelect(cm, e, start, type, modifier);
+ }
+
+ // Start a text drag. When it ends, see if any dragging actually
+ // happen, and treat as a click if it didn't.
+ function leftButtonStartDrag(cm, e, start, modifier) {
+ var display = cm.display, startTime = +new Date;
+ var dragEnd = operation(cm, function(e2) {
+ if (webkit) display.scroller.draggable = false;
+ cm.state.draggingText = false;
+ off(document, "mouseup", dragEnd);
+ off(display.scroller, "drop", dragEnd);
+ if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
+ e_preventDefault(e2);
+ if (!modifier && +new Date - 200 < startTime)
+ extendSelection(cm.doc, start);
+ // 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.
+ if (webkit) display.scroller.draggable = true;
+ cm.state.draggingText = dragEnd;
+ // IE's approach to draggable
+ if (display.scroller.dragDrop) display.scroller.dragDrop();
+ on(document, "mouseup", dragEnd);
+ on(display.scroller, "drop", dragEnd);
+ }
- startstart = clipPos(doc, startstart);
- startend = clipPos(doc, startend);
- if (type == "double") {
- var word = findWordAt(getLine(doc, cur.line).text, cur);
- if (posLess(cur, startstart)) extendSelection(cm.doc, word.from, startend);
- else extendSelection(cm.doc, startstart, word.to);
- } else if (type == "triple") {
- if (posLess(cur, startstart)) extendSelection(cm.doc, startend, clipPos(doc, Pos(cur.line, 0)));
- else extendSelection(cm.doc, startstart, clipPos(doc, Pos(cur.line + 1, 0)));
+ // Normal selection, as opposed to text dragging.
+ function leftButtonSelect(cm, e, start, type, addNew) {
+ var display = cm.display, doc = cm.doc;
+ e_preventDefault(e);
+
+ var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
+ if (addNew && !e.shiftKey) {
+ ourIndex = doc.sel.contains(start);
+ if (ourIndex > -1)
+ ourRange = ranges[ourIndex];
+ else
+ ourRange = new Range(start, start);
+ } else {
+ ourRange = doc.sel.primary();
+ ourIndex = doc.sel.primIndex;
+ }
+
+ if (e.altKey) {
+ type = "rect";
+ if (!addNew) ourRange = new Range(start, start);
+ start = posFromMouse(cm, e, true, true);
+ ourIndex = -1;
+ } else if (type == "double") {
+ var word = cm.findWordAt(start);
+ if (cm.display.shift || doc.extend)
+ ourRange = extendRange(doc, ourRange, word.anchor, word.head);
+ else
+ ourRange = word;
+ } else if (type == "triple") {
+ var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));
+ if (cm.display.shift || doc.extend)
+ ourRange = extendRange(doc, ourRange, line.anchor, line.head);
+ else
+ ourRange = line;
+ } else {
+ ourRange = extendRange(doc, ourRange, start);
+ }
+
+ if (!addNew) {
+ ourIndex = 0;
+ setSelection(doc, new Selection([ourRange], 0), sel_mouse);
+ startSel = doc.sel;
+ } else if (ourIndex == -1) {
+ ourIndex = ranges.length;
+ setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
+ {scroll: false, origin: "*mouse"});
+ } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
+ setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
+ {scroll: false, origin: "*mouse"});
+ startSel = doc.sel;
+ } else {
+ replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
+ }
+
+ var lastPos = start;
+ function extendTo(pos) {
+ if (cmp(lastPos, pos) == 0) return;
+ lastPos = pos;
+
+ if (type == "rect") {
+ var ranges = [], tabSize = cm.options.tabSize;
+ var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
+ var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
+ var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
+ for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
+ line <= end; line++) {
+ var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
+ if (left == right)
+ ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
+ else if (text.length > leftPos)
+ ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
+ }
+ if (!ranges.length) ranges.push(new Range(start, start));
+ setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
+ {origin: "*mouse", scroll: false});
+ cm.scrollIntoView(pos);
+ } else {
+ var oldRange = ourRange;
+ var anchor = oldRange.anchor, head = pos;
+ if (type != "single") {
+ if (type == "double")
+ var range = cm.findWordAt(pos);
+ else
+ var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
+ if (cmp(range.anchor, anchor) > 0) {
+ head = range.head;
+ anchor = minPos(oldRange.from(), range.anchor);
+ } else {
+ head = range.anchor;
+ anchor = maxPos(oldRange.to(), range.head);
+ }
+ }
+ var ranges = startSel.ranges.slice(0);
+ ranges[ourIndex] = new Range(clipPos(doc, anchor), head);
+ setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);
}
}
- var editorSize = getRect(display.wrapper);
+ var editorSize = display.wrapper.getBoundingClientRect();
// Used to ensure timeout re-tries don't fire when another extend
// happened in the meantime (clearTimeout isn't reliable -- at
// least on Chrome, the timeouts still happen even when cleared,
@@ -1826,12 +3738,11 @@ window.CodeMirror = (function() {
function extend(e) {
var curCount = ++counter;
- var cur = posFromMouse(cm, e, true);
+ var cur = posFromMouse(cm, e, true, type == "rect");
if (!cur) return;
- if (!posEq(cur, last)) {
- ensureFocus(cm);
- last = cur;
- doSelect(cur);
+ if (cmp(cur, lastPos) != 0) {
+ cm.curOp.focus = activeElt();
+ extendTo(cur);
var visible = visibleLines(display, doc);
if (cur.line >= visible.to || cur.line < visible.from)
setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
@@ -1846,37 +3757,42 @@ window.CodeMirror = (function() {
}
function done(e) {
+ cm.state.selectingText = false;
counter = Infinity;
e_preventDefault(e);
- focusInput(cm);
+ display.input.focus();
off(document, "mousemove", move);
off(document, "mouseup", up);
+ doc.history.lastSelOrigin = null;
}
var move = operation(cm, function(e) {
- if ((ie && !ie_lt10) ? !e.buttons : !e_button(e)) done(e);
+ if (!e_button(e)) done(e);
else extend(e);
});
var up = operation(cm, done);
+ cm.state.selectingText = up;
on(document, "mousemove", move);
on(document, "mouseup", up);
}
+ // Determines whether an event happened in the gutter, and fires the
+ // handlers for the corresponding event.
function gutterEvent(cm, e, type, prevent, signalfn) {
try { var mX = e.clientX, mY = e.clientY; }
catch(e) { return false; }
- if (mX >= Math.floor(getRect(cm.display.gutters).right)) return false;
+ if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
if (prevent) e_preventDefault(e);
var display = cm.display;
- var lineBox = getRect(display.lineDiv);
+ var lineBox = display.lineDiv.getBoundingClientRect();
if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
mY -= lineBox.top - display.viewOffset;
for (var i = 0; i < cm.options.gutters.length; ++i) {
var g = display.gutters.childNodes[i];
- if (g && getRect(g).right >= mX) {
+ if (g && g.getBoundingClientRect().right >= mX) {
var line = lineAtHeight(cm.doc, mY);
var gutter = cm.options.gutters[i];
signalfn(cm, type, cm, line, gutter, e);
@@ -1885,11 +3801,6 @@ window.CodeMirror = (function() {
}
}
- function contextMenuInGutter(cm, e) {
- if (!hasHandler(cm, "gutterContextMenu")) return false;
- return gutterEvent(cm, e, "gutterContextMenu", false, signal);
- }
-
function clickInGutter(cm, e) {
return gutterEvent(cm, e, "gutterClick", true, signalLater);
}
@@ -1900,42 +3811,57 @@ window.CodeMirror = (function() {
function onDrop(e) {
var cm = this;
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e) || (cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e))))
+ clearDragCursor(cm);
+ if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
return;
e_preventDefault(e);
if (ie) lastDrop = +new Date;
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
if (!pos || isReadOnly(cm)) return;
+ // Might be a file drop, in which case we simply extract the text
+ // and insert it.
if (files && files.length && window.FileReader && window.File) {
var n = files.length, text = Array(n), read = 0;
var loadFile = function(file, i) {
+ if (cm.options.allowDropFileTypes &&
+ indexOf(cm.options.allowDropFileTypes, file.type) == -1)
+ return;
+
var reader = new FileReader;
- reader.onload = function() {
- text[i] = reader.result;
+ reader.onload = operation(cm, function() {
+ var content = reader.result;
+ if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = "";
+ text[i] = content;
if (++read == n) {
pos = clipPos(cm.doc, pos);
- makeChange(cm.doc, {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"}, "around");
+ var change = {from: pos, to: pos,
+ text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
+ origin: "paste"};
+ makeChange(cm.doc, change);
+ setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
}
- };
+ });
reader.readAsText(file);
};
for (var i = 0; i < n; ++i) loadFile(files[i], i);
- } else {
+ } else { // Normal drop
// Don't do a replace if the drop happened inside of the selected text.
- if (cm.state.draggingText && !(posLess(pos, cm.doc.sel.from) || posLess(cm.doc.sel.to, pos))) {
+ if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
cm.state.draggingText(e);
// Ensure the editor is re-focused
- setTimeout(bind(focusInput, cm), 20);
+ setTimeout(function() {cm.display.input.focus();}, 20);
return;
}
try {
var text = e.dataTransfer.getData("Text");
if (text) {
- var curFrom = cm.doc.sel.from, curTo = cm.doc.sel.to;
- setSelection(cm.doc, pos, pos);
- if (cm.state.draggingText) replaceRange(cm.doc, "", curFrom, curTo, "paste");
- cm.replaceSelection(text, null, "paste");
- focusInput(cm);
+ if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey))
+ var selected = cm.listSelections();
+ setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
+ if (selected) for (var i = 0; i < selected.length; ++i)
+ replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag");
+ cm.replaceSelection(text, "around", "paste");
+ cm.display.input.focus();
}
}
catch(e){}
@@ -1946,41 +3872,65 @@ window.CodeMirror = (function() {
if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
- var txt = cm.getSelection();
- e.dataTransfer.setData("Text", txt);
+ e.dataTransfer.setData("Text", cm.getSelection());
// Use dummy image instead of default browsers image.
// Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
if (e.dataTransfer.setDragImage && !safari) {
var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
- if (opera) {
+ if (presto) {
img.width = img.height = 1;
cm.display.wrapper.appendChild(img);
// Force a relayout, or Opera won't use our image for some obscure reason
img._top = img.offsetTop;
}
e.dataTransfer.setDragImage(img, 0, 0);
- if (opera) img.parentNode.removeChild(img);
+ if (presto) img.parentNode.removeChild(img);
+ }
+ }
+
+ function onDragOver(cm, e) {
+ var pos = posFromMouse(cm, e);
+ if (!pos) return;
+ var frag = document.createDocumentFragment();
+ drawSelectionCursor(cm, pos, frag);
+ if (!cm.display.dragCursor) {
+ cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
+ cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
+ }
+ removeChildrenAndAdd(cm.display.dragCursor, frag);
+ }
+
+ function clearDragCursor(cm) {
+ if (cm.display.dragCursor) {
+ cm.display.lineSpace.removeChild(cm.display.dragCursor);
+ cm.display.dragCursor = null;
}
}
+ // SCROLL EVENTS
+
+ // Sync the scrollable area and scrollbars, ensure the viewport
+ // covers the visible area.
function setScrollTop(cm, val) {
if (Math.abs(cm.doc.scrollTop - val) < 2) return;
cm.doc.scrollTop = val;
- if (!gecko) updateDisplay(cm, [], val);
+ if (!gecko) updateDisplaySimple(cm, {top: val});
if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
- if (cm.display.scrollbarV.scrollTop != val) cm.display.scrollbarV.scrollTop = val;
- if (gecko) updateDisplay(cm, []);
+ cm.display.scrollbars.setScrollTop(val);
+ if (gecko) updateDisplaySimple(cm);
startWorker(cm, 100);
}
+ // Sync scroller and scrollbar, ensure the gutter elements are
+ // aligned.
function setScrollLeft(cm, val, isScroller) {
if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
cm.doc.scrollLeft = val;
alignHorizontally(cm);
if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
- if (cm.display.scrollbarH.scrollLeft != val) cm.display.scrollbarH.scrollLeft = val;
+ cm.display.scrollbars.setScrollLeft(val);
}
// Since the delta values reported on mouse wheel events are
@@ -2004,26 +3954,40 @@ window.CodeMirror = (function() {
else if (chrome) wheelPixelsPerUnit = -.7;
else if (safari) wheelPixelsPerUnit = -1/3;
- function onScrollWheel(cm, e) {
+ var wheelEventDelta = function(e) {
var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
else if (dy == null) dy = e.wheelDelta;
+ return {x: dx, y: dy};
+ };
+ CodeMirror.wheelEventPixels = function(e) {
+ var delta = wheelEventDelta(e);
+ delta.x *= wheelPixelsPerUnit;
+ delta.y *= wheelPixelsPerUnit;
+ return delta;
+ };
+
+ function onScrollWheel(cm, e) {
+ var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
var display = cm.display, scroll = display.scroller;
// Quit if there's nothing to scroll here
- if (!(dx && scroll.scrollWidth > scroll.clientWidth ||
- dy && scroll.scrollHeight > scroll.clientHeight)) return;
+ var canScrollX = scroll.scrollWidth > scroll.clientWidth;
+ var canScrollY = scroll.scrollHeight > scroll.clientHeight;
+ if (!(dx && canScrollX || dy && canScrollY)) return;
// Webkit browsers on OS X abort momentum scrolls when the target
// of the scroll event is removed from the scrollable element.
// This hack (see related code in patchDisplay) makes sure the
// element is kept around.
if (dy && mac && webkit) {
- for (var cur = e.target; cur != scroll; cur = cur.parentNode) {
- if (cur.lineObj) {
- cm.display.currentWheelTarget = cur;
- break;
+ outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
+ for (var i = 0; i < view.length; i++) {
+ if (view[i].node == cur) {
+ cm.display.currentWheelTarget = cur;
+ break outer;
+ }
}
}
}
@@ -2034,21 +3998,28 @@ window.CodeMirror = (function() {
// estimated pixels/delta value, we just handle horizontal
// scrolling entirely here. It'll be slightly off from native, but
// better than glitching out.
- if (dx && !gecko && !opera && wheelPixelsPerUnit != null) {
- if (dy)
+ if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
+ if (dy && canScrollY)
setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
- e_preventDefault(e);
+ // Only prevent default scrolling if vertical scrolling is
+ // actually possible. Otherwise, it causes vertical scroll
+ // jitter on OSX trackpads when deltaX is small and deltaY
+ // is large (issue #3579)
+ if (!dy || (dy && canScrollY))
+ e_preventDefault(e);
display.wheelStartX = null; // Abort measurement, if in progress
return;
}
+ // 'Project' the visible viewport to cover the area that is being
+ // scrolled into view (if we know enough to estimate it).
if (dy && wheelPixelsPerUnit != null) {
var pixels = dy * wheelPixelsPerUnit;
var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
if (pixels < 0) top = Math.max(0, top + pixels - 50);
else bot = Math.min(cm.doc.height, bot + pixels + 50);
- updateDisplay(cm, [], {top: top, bottom: bot});
+ updateDisplaySimple(cm, {top: top, bottom: bot});
}
if (wheelSamples < 20) {
@@ -2072,6 +4043,9 @@ window.CodeMirror = (function() {
}
}
+ // KEY EVENTS
+
+ // Run a handler that was bound to a key.
function doHandleBinding(cm, bound, dropShift) {
if (typeof bound == "string") {
bound = commands[bound];
@@ -2079,251 +4053,257 @@ window.CodeMirror = (function() {
}
// Ensure previous input has been read, so that the handler sees a
// consistent view of the document
- if (cm.display.pollingFast && readInput(cm)) cm.display.pollingFast = false;
- var doc = cm.doc, prevShift = doc.sel.shift, done = false;
+ cm.display.input.ensurePolled();
+ var prevShift = cm.display.shift, done = false;
try {
if (isReadOnly(cm)) cm.state.suppressEdits = true;
- if (dropShift) doc.sel.shift = false;
+ if (dropShift) cm.display.shift = false;
done = bound(cm) != Pass;
} finally {
- doc.sel.shift = prevShift;
+ cm.display.shift = prevShift;
cm.state.suppressEdits = false;
}
return done;
}
- function allKeyMaps(cm) {
- var maps = cm.state.keyMaps.slice(0);
- if (cm.options.extraKeys) maps.push(cm.options.extraKeys);
- maps.push(cm.options.keyMap);
- return maps;
+ function lookupKeyForEditor(cm, name, handle) {
+ for (var i = 0; i < cm.state.keyMaps.length; i++) {
+ var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
+ if (result) return result;
+ }
+ return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
+ || lookupKey(name, cm.options.keyMap, handle, cm);
}
- var maybeTransition;
- function handleKeyBinding(cm, e) {
- // Handle auto keymap transitions
- var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto;
- clearTimeout(maybeTransition);
- if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
- if (getKeyMap(cm.options.keyMap) == startMap) {
- cm.options.keyMap = (next.call ? next.call(null, cm) : next);
- keyMapChanged(cm);
- }
- }, 50);
+ var stopSeq = new Delayed;
+ function dispatchKey(cm, name, e, handle) {
+ var seq = cm.state.keySeq;
+ if (seq) {
+ if (isModifierKey(name)) return "handled";
+ stopSeq.set(50, function() {
+ if (cm.state.keySeq == seq) {
+ cm.state.keySeq = null;
+ cm.display.input.reset();
+ }
+ });
+ name = seq + " " + name;
+ }
+ var result = lookupKeyForEditor(cm, name, handle);
- var name = keyName(e, true), handled = false;
- if (!name) return false;
- var keymaps = allKeyMaps(cm);
+ if (result == "multi")
+ cm.state.keySeq = name;
+ if (result == "handled")
+ signalLater(cm, "keyHandled", cm, name, e);
- if (e.shiftKey) {
- // First try to resolve full name (including 'Shift-'). Failing
- // that, see if there is a cursor-motion command (starting with
- // 'go') bound to the keyname without 'Shift-'.
- handled = lookupKey("Shift-" + name, keymaps, function(b) {return doHandleBinding(cm, b, true);})
- || lookupKey(name, keymaps, function(b) {
- if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
- return doHandleBinding(cm, b);
- });
- } else {
- handled = lookupKey(name, keymaps, function(b) { return doHandleBinding(cm, b); });
+ if (result == "handled" || result == "multi") {
+ e_preventDefault(e);
+ restartBlink(cm);
}
- if (handled) {
+ if (seq && !result && /\'$/.test(name)) {
e_preventDefault(e);
- restartBlink(cm);
- if (ie_lt9) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
- signalLater(cm, "keyHandled", cm, name, e);
+ return true;
}
- return handled;
+ return !!result;
}
- function handleCharBinding(cm, e, ch) {
- var handled = lookupKey("'" + ch + "'", allKeyMaps(cm),
- function(b) { return doHandleBinding(cm, b, true); });
- if (handled) {
- e_preventDefault(e);
- restartBlink(cm);
- signalLater(cm, "keyHandled", cm, "'" + ch + "'", e);
+ // Handle a key from the keydown event.
+ function handleKeyBinding(cm, e) {
+ var name = keyName(e, true);
+ if (!name) return false;
+
+ if (e.shiftKey && !cm.state.keySeq) {
+ // First try to resolve full name (including 'Shift-'). Failing
+ // that, see if there is a cursor-motion command (starting with
+ // 'go') bound to the keyname without 'Shift-'.
+ return dispatchKey(cm, "Shift-" + name, e, function(b) {return doHandleBinding(cm, b, true);})
+ || dispatchKey(cm, name, e, function(b) {
+ if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
+ return doHandleBinding(cm, b);
+ });
+ } else {
+ return dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); });
}
- return handled;
}
- function onKeyUp(e) {
- var cm = this;
- if (signalDOMEvent(cm, e) || cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
- if (e.keyCode == 16) cm.doc.sel.shift = false;
+ // Handle a key from the keypress event
+ function handleCharBinding(cm, e, ch) {
+ return dispatchKey(cm, "'" + ch + "'", e,
+ function(b) { return doHandleBinding(cm, b, true); });
}
var lastStoppedKey = null;
function onKeyDown(e) {
var cm = this;
- ensureFocus(cm);
- if (signalDOMEvent(cm, e) || cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
- if (old_ie && e.keyCode == 27) e.returnValue = false;
- var code = e.keyCode;
+ cm.curOp.focus = activeElt();
+ if (signalDOMEvent(cm, e)) return;
// IE does strange things with escape.
- cm.doc.sel.shift = code == 16 || e.shiftKey;
- // First give onKeyEvent option a chance to handle this.
+ if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false;
+ var code = e.keyCode;
+ cm.display.shift = code == 16 || e.shiftKey;
var handled = handleKeyBinding(cm, e);
- if (opera) {
+ if (presto) {
lastStoppedKey = handled ? code : null;
// Opera has no cut event... we try to at least catch the key combo
if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
- cm.replaceSelection("");
+ cm.replaceSelection("", null, "cut");
+ }
+
+ // Turn mouse into crosshair when Alt is held on Mac.
+ if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
+ showCrossHair(cm);
+ }
+
+ function showCrossHair(cm) {
+ var lineDiv = cm.display.lineDiv;
+ addClass(lineDiv, "CodeMirror-crosshair");
+
+ function up(e) {
+ if (e.keyCode == 18 || !e.altKey) {
+ rmClass(lineDiv, "CodeMirror-crosshair");
+ off(document, "keyup", up);
+ off(document, "mouseover", up);
+ }
}
+ on(document, "keyup", up);
+ on(document, "mouseover", up);
+ }
+
+ function onKeyUp(e) {
+ if (e.keyCode == 16) this.doc.sel.shift = false;
+ signalDOMEvent(this, e);
}
function onKeyPress(e) {
var cm = this;
- if (signalDOMEvent(cm, e) || cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
+ if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return;
var keyCode = e.keyCode, charCode = e.charCode;
- if (opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
- if (((opera && (!e.which || e.which < 10)) || khtml) && handleKeyBinding(cm, e)) return;
+ if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
+ if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) return;
var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
if (handleCharBinding(cm, e, ch)) return;
- if (ie && !ie_lt9) cm.display.inputHasSelection = null;
- fastPoll(cm);
+ cm.display.input.onKeyPress(e);
+ }
+
+ // FOCUS/BLUR EVENTS
+
+ function delayBlurEvent(cm) {
+ cm.state.delayingBlurEvent = true;
+ setTimeout(function() {
+ if (cm.state.delayingBlurEvent) {
+ cm.state.delayingBlurEvent = false;
+ onBlur(cm);
+ }
+ }, 100);
}
function onFocus(cm) {
+ if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false;
+
if (cm.options.readOnly == "nocursor") return;
if (!cm.state.focused) {
signal(cm, "focus", cm);
cm.state.focused = true;
- if (cm.display.wrapper.className.search(/\bCodeMirror-focused\b/) == -1)
- cm.display.wrapper.className += " CodeMirror-focused";
- if (!cm.curOp) {
- resetInput(cm, true);
- if (webkit) setTimeout(bind(resetInput, cm, true), 0); // Issue #1730
+ addClass(cm.display.wrapper, "CodeMirror-focused");
+ // This test prevents this from firing when a context
+ // menu is closed (since the input reset would kill the
+ // select-all detection hack)
+ if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
+ cm.display.input.reset();
+ if (webkit) setTimeout(function() { cm.display.input.reset(true); }, 20); // Issue #1730
}
+ cm.display.input.receivedFocus();
}
- slowPoll(cm);
restartBlink(cm);
}
function onBlur(cm) {
+ if (cm.state.delayingBlurEvent) return;
+
if (cm.state.focused) {
signal(cm, "blur", cm);
cm.state.focused = false;
- cm.display.wrapper.className = cm.display.wrapper.className.replace(" CodeMirror-focused", "");
+ rmClass(cm.display.wrapper, "CodeMirror-focused");
}
clearInterval(cm.display.blinker);
- setTimeout(function() {if (!cm.state.focused) cm.doc.sel.shift = false;}, 150);
+ setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150);
}
- var detectingSelectAll;
+ // CONTEXT MENU HANDLING
+
+ // To make the context menu work, we need to briefly unhide the
+ // textarea (making it as unobtrusive as possible) to let the
+ // right-click take effect on it.
function onContextMenu(cm, e) {
+ if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
if (signalDOMEvent(cm, e, "contextmenu")) return;
- var display = cm.display, sel = cm.doc.sel;
- if (eventInWidget(display, e) || contextMenuInGutter(cm, e)) return;
-
- var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
- if (!pos || opera) return; // Opera is difficult.
-
- // Reset the current text selection only if the click is done outside of the selection
- // and 'resetSelectionOnContextMenu' option is true.
- var reset = cm.options.resetSelectionOnContextMenu;
- if (reset && (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to)))
- operation(cm, setSelection)(cm.doc, pos, pos);
-
- var oldCSS = display.input.style.cssText;
- display.inputDiv.style.position = "absolute";
- display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
- "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
- (ie ? "rgba(255, 255, 255, .05)" : "transparent") +
- "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
- focusInput(cm);
- resetInput(cm, true);
- // Adds "Select all" to context menu in FF
- if (posEq(sel.from, sel.to)) display.input.value = display.prevInput = " ";
-
- function prepareSelectAllHack() {
- if (display.input.selectionStart != null) {
- var extval = display.input.value = "\u200b" + (posEq(sel.from, sel.to) ? "" : display.input.value);
- display.prevInput = "\u200b";
- display.input.selectionStart = 1; display.input.selectionEnd = extval.length;
- }
- }
- function rehide() {
- display.inputDiv.style.position = "relative";
- display.input.style.cssText = oldCSS;
- if (ie_lt9) display.scrollbarV.scrollTop = display.scroller.scrollTop = scrollPos;
- slowPoll(cm);
-
- // Try to detect the user choosing select-all
- if (display.input.selectionStart != null) {
- if (!ie || ie_lt9) prepareSelectAllHack();
- clearTimeout(detectingSelectAll);
- var i = 0, poll = function(){
- if (display.prevInput == "\u200b" && display.input.selectionStart == 0)
- operation(cm, commands.selectAll)(cm);
- else if (i++ < 10) detectingSelectAll = setTimeout(poll, 500);
- else resetInput(cm);
- };
- detectingSelectAll = setTimeout(poll, 200);
- }
- }
+ cm.display.input.onContextMenu(e);
+ }
- if (ie && !ie_lt9) prepareSelectAllHack();
- if (captureMiddleClick) {
- e_stop(e);
- var mouseup = function() {
- off(window, "mouseup", mouseup);
- setTimeout(rehide, 20);
- };
- on(window, "mouseup", mouseup);
- } else {
- setTimeout(rehide, 50);
- }
+ function contextMenuInGutter(cm, e) {
+ if (!hasHandler(cm, "gutterContextMenu")) return false;
+ return gutterEvent(cm, e, "gutterContextMenu", false, signal);
}
// UPDATING
+ // Compute the position of the end of a change (its 'to' property
+ // refers to the pre-change end).
var changeEnd = CodeMirror.changeEnd = function(change) {
if (!change.text) return change.to;
return Pos(change.from.line + change.text.length - 1,
lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
};
- // Make sure a position will be valid after the given change.
- function clipPostChange(doc, change, pos) {
- if (!posLess(change.from, pos)) return clipPos(doc, pos);
- var diff = (change.text.length - 1) - (change.to.line - change.from.line);
- if (pos.line > change.to.line + diff) {
- var preLine = pos.line - diff, lastLine = doc.first + doc.size - 1;
- if (preLine > lastLine) return Pos(lastLine, getLine(doc, lastLine).text.length);
- return clipToLen(pos, getLine(doc, preLine).text.length);
- }
- if (pos.line == change.to.line + diff)
- return clipToLen(pos, lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0) +
- getLine(doc, change.to.line).text.length - change.to.ch);
- var inside = pos.line - change.from.line;
- return clipToLen(pos, change.text[inside].length + (inside ? 0 : change.from.ch));
- }
-
- // Hint can be null|"end"|"start"|"around"|{anchor,head}
- function computeSelAfterChange(doc, change, hint) {
- if (hint && typeof hint == "object") // Assumed to be {anchor, head} object
- return {anchor: clipPostChange(doc, change, hint.anchor),
- head: clipPostChange(doc, change, hint.head)};
-
- if (hint == "start") return {anchor: change.from, head: change.from};
-
- var end = changeEnd(change);
- if (hint == "around") return {anchor: change.from, head: end};
- if (hint == "end") return {anchor: end, head: end};
-
- // hint is null, leave the selection alone as much as possible
- var adjustPos = function(pos) {
- if (posLess(pos, change.from)) return pos;
- if (!posLess(change.to, pos)) return end;
-
- var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
- if (pos.line == change.to.line) ch += end.ch - change.to.ch;
- return Pos(line, ch);
- };
- return {anchor: adjustPos(doc.sel.anchor), head: adjustPos(doc.sel.head)};
+ // Adjust a position to refer to the post-change position of the
+ // same text, or the end of the change if the change covers it.
+ function adjustForChange(pos, change) {
+ if (cmp(pos, change.from) < 0) return pos;
+ if (cmp(pos, change.to) <= 0) return changeEnd(change);
+
+ var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
+ if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
+ return Pos(line, ch);
}
+ function computeSelAfterChange(doc, change) {
+ var out = [];
+ for (var i = 0; i < doc.sel.ranges.length; i++) {
+ var range = doc.sel.ranges[i];
+ out.push(new Range(adjustForChange(range.anchor, change),
+ adjustForChange(range.head, change)));
+ }
+ return normalizeSelection(out, doc.sel.primIndex);
+ }
+
+ function offsetPos(pos, old, nw) {
+ if (pos.line == old.line)
+ return Pos(nw.line, pos.ch - old.ch + nw.ch);
+ else
+ return Pos(nw.line + (pos.line - old.line), pos.ch);
+ }
+
+ // Used by replaceSelections to allow moving the selection to the
+ // start or around the replaced test. Hint may be "start" or "around".
+ function computeReplacedSel(doc, changes, hint) {
+ var out = [];
+ var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
+ for (var i = 0; i < changes.length; i++) {
+ var change = changes[i];
+ var from = offsetPos(change.from, oldPrev, newPrev);
+ var to = offsetPos(changeEnd(change), oldPrev, newPrev);
+ oldPrev = change.to;
+ newPrev = to;
+ if (hint == "around") {
+ var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
+ out[i] = new Range(inv ? to : from, inv ? from : to);
+ } else {
+ out[i] = new Range(from, from);
+ }
+ }
+ return new Selection(out, doc.sel.primIndex);
+ }
+
+ // Allow "beforeChange" event handlers to influence a change
function filterChange(doc, change, update) {
var obj = {
canceled: false,
@@ -2346,11 +4326,11 @@ window.CodeMirror = (function() {
return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
}
- // Replace the range from from to to by the strings in replacement.
- // change is a {from, to, text [, origin]} object
- function makeChange(doc, change, selUpdate, ignoreReadOnly) {
+ // Apply a change to a document, and add it to the document's
+ // history, and propagating it to all linked documents.
+ function makeChange(doc, change, ignoreReadOnly) {
if (doc.cm) {
- if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, selUpdate, ignoreReadOnly);
+ if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
if (doc.cm.state.suppressEdits) return;
}
@@ -2363,19 +4343,17 @@ window.CodeMirror = (function() {
// of read-only spans in its range.
var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
if (split) {
- for (var i = split.length - 1; i >= 1; --i)
- makeChangeNoReadonly(doc, {from: split[i].from, to: split[i].to, text: [""]});
- if (split.length)
- makeChangeNoReadonly(doc, {from: split[0].from, to: split[0].to, text: change.text}, selUpdate);
+ for (var i = split.length - 1; i >= 0; --i)
+ makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
} else {
- makeChangeNoReadonly(doc, change, selUpdate);
+ makeChangeInner(doc, change);
}
}
- function makeChangeNoReadonly(doc, change, selUpdate) {
- if (change.text.length == 1 && change.text[0] == "" && posEq(change.from, change.to)) return;
- var selAfter = computeSelAfterChange(doc, change, selUpdate);
- addToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
+ function makeChangeInner(doc, change) {
+ if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;
+ var selAfter = computeSelAfterChange(doc, change);
+ addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
var rebased = [];
@@ -2389,17 +4367,41 @@ window.CodeMirror = (function() {
});
}
- function makeChangeFromHistory(doc, type) {
+ // Revert a change stored in a document's history.
+ function makeChangeFromHistory(doc, type, allowSelectionOnly) {
if (doc.cm && doc.cm.state.suppressEdits) return;
- var hist = doc.history;
- var event = (type == "undo" ? hist.done : hist.undone).pop();
- if (!event) return;
+ var hist = doc.history, event, selAfter = doc.sel;
+ var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
+
+ // Verify that there is a useable event (so that ctrl-z won't
+ // needlessly clear selection events)
+ for (var i = 0; i < source.length; i++) {
+ event = source[i];
+ if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
+ break;
+ }
+ if (i == source.length) return;
+ hist.lastOrigin = hist.lastSelOrigin = null;
+
+ for (;;) {
+ event = source.pop();
+ if (event.ranges) {
+ pushSelectionToHistory(event, dest);
+ if (allowSelectionOnly && !event.equals(doc.sel)) {
+ setSelection(doc, event, {clearRedo: false});
+ return;
+ }
+ selAfter = event;
+ }
+ else break;
+ }
- var anti = {changes: [], anchorBefore: event.anchorAfter, headBefore: event.headAfter,
- anchorAfter: event.anchorBefore, headAfter: event.headBefore,
- generation: hist.generation};
- (type == "undo" ? hist.undone : hist.done).push(anti);
+ // Build up a reverse change object to add to the opposite history
+ // stack (redo when undoing, and vice versa).
+ var antiChanges = [];
+ pushSelectionToHistory(selAfter, dest);
+ dest.push({changes: antiChanges, generation: hist.generation});
hist.generation = event.generation || ++hist.maxGeneration;
var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
@@ -2408,17 +4410,18 @@ window.CodeMirror = (function() {
var change = event.changes[i];
change.origin = type;
if (filter && !filterChange(doc, change, false)) {
- (type == "undo" ? hist.done : hist.undone).length = 0;
+ source.length = 0;
return;
}
- anti.changes.push(historyChangeFromChange(doc, change));
+ antiChanges.push(historyChangeFromChange(doc, change));
- var after = i ? computeSelAfterChange(doc, change, null)
- : {anchor: event.anchorBefore, head: event.headBefore};
+ var after = i ? computeSelAfterChange(doc, change) : lst(source);
makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
+ if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)});
var rebased = [];
+ // Propagate to the linked documents
linkedDocs(doc, function(doc, sharedHist) {
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
rebaseHist(doc.history, change);
@@ -2429,14 +4432,24 @@ window.CodeMirror = (function() {
}
}
+ // Sub-views need their line numbers shifted when text is added
+ // above or below them in the parent document.
function shiftDoc(doc, distance) {
- function shiftPos(pos) {return Pos(pos.line + distance, pos.ch);}
+ if (distance == 0) return;
doc.first += distance;
- if (doc.cm) regChange(doc.cm, doc.first, doc.first, distance);
- doc.sel.head = shiftPos(doc.sel.head); doc.sel.anchor = shiftPos(doc.sel.anchor);
- doc.sel.from = shiftPos(doc.sel.from); doc.sel.to = shiftPos(doc.sel.to);
+ doc.sel = new Selection(map(doc.sel.ranges, function(range) {
+ return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
+ Pos(range.head.line + distance, range.head.ch));
+ }), doc.sel.primIndex);
+ if (doc.cm) {
+ regChange(doc.cm, doc.first, doc.first - distance, distance);
+ for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
+ regLineChange(doc.cm, l, "gutter");
+ }
}
+ // More lower-level change function, handling only a single document
+ // (not linked ones).
function makeChangeSingleDoc(doc, change, selAfter, spans) {
if (doc.cm && !doc.cm.curOp)
return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
@@ -2462,228 +4475,94 @@ window.CodeMirror = (function() {
change.removed = getBetween(doc, change.from, change.to);
- if (!selAfter) selAfter = computeSelAfterChange(doc, change, null);
- if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans, selAfter);
- else updateDoc(doc, change, spans, selAfter);
+ if (!selAfter) selAfter = computeSelAfterChange(doc, change);
+ if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
+ else updateDoc(doc, change, spans);
+ setSelectionNoUndo(doc, selAfter, sel_dontScroll);
}
- function makeChangeSingleDocInEditor(cm, change, spans, selAfter) {
+ // Handle the interaction of a change to a document with the editor
+ // that this document is part of.
+ function makeChangeSingleDocInEditor(cm, change, spans) {
var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
var recomputeMaxLength = false, checkWidthStart = from.line;
if (!cm.options.lineWrapping) {
- checkWidthStart = lineNo(visualLine(doc, getLine(doc, from.line)));
+ checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
doc.iter(checkWidthStart, to.line + 1, function(line) {
if (line == display.maxLine) {
recomputeMaxLength = true;
return true;
}
- });
- }
-
- if (!posLess(doc.sel.head, change.from) && !posLess(change.to, doc.sel.head))
- cm.curOp.cursorActivity = true;
-
- updateDoc(doc, change, spans, selAfter, estimateHeight(cm));
-
- if (!cm.options.lineWrapping) {
- doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
- var len = lineLength(doc, line);
- if (len > display.maxLineLength) {
- display.maxLine = line;
- display.maxLineLength = len;
- display.maxLineChanged = true;
- recomputeMaxLength = false;
- }
- });
- if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
- }
-
- // Adjust frontier, schedule worker
- doc.frontier = Math.min(doc.frontier, from.line);
- startWorker(cm, 400);
-
- var lendiff = change.text.length - (to.line - from.line) - 1;
- // Remember that these lines changed, for updating the display
- regChange(cm, from.line, to.line + 1, lendiff);
-
- if (hasHandler(cm, "change")) {
- var changeObj = {from: from, to: to,
- text: change.text,
- removed: change.removed,
- origin: change.origin};
- if (cm.curOp.textChanged) {
- for (var cur = cm.curOp.textChanged; cur.next; cur = cur.next) {}
- cur.next = changeObj;
- } else cm.curOp.textChanged = changeObj;
- }
- }
-
- function replaceRange(doc, code, from, to, origin) {
- if (!to) to = from;
- if (posLess(to, from)) { var tmp = to; to = from; from = tmp; }
- if (typeof code == "string") code = splitLines(code);
- makeChange(doc, {from: from, to: to, text: code, origin: origin}, null);
- }
-
- // POSITION OBJECT
-
- function Pos(line, ch) {
- if (!(this instanceof Pos)) return new Pos(line, ch);
- this.line = line; this.ch = ch;
- }
- CodeMirror.Pos = Pos;
-
- function posEq(a, b) {return a.line == b.line && a.ch == b.ch;}
- function posLess(a, b) {return a.line < b.line || (a.line == b.line && a.ch < b.ch);}
- function cmp(a, b) {return a.line - b.line || a.ch - b.ch;}
- function copyPos(x) {return Pos(x.line, x.ch);}
-
- // SELECTION
-
- function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
- function clipPos(doc, pos) {
- if (pos.line < doc.first) return Pos(doc.first, 0);
- var last = doc.first + doc.size - 1;
- if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
- return clipToLen(pos, getLine(doc, pos.line).text.length);
- }
- function clipToLen(pos, linelen) {
- var ch = pos.ch;
- if (ch == null || ch > linelen) return Pos(pos.line, linelen);
- else if (ch < 0) return Pos(pos.line, 0);
- else return pos;
- }
- function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
-
- // If shift is held, this will move the selection anchor. Otherwise,
- // it'll set the whole selection.
- function extendSelection(doc, pos, other, bias) {
- if (doc.sel.shift || doc.sel.extend) {
- var anchor = doc.sel.anchor;
- if (other) {
- var posBefore = posLess(pos, anchor);
- if (posBefore != posLess(other, anchor)) {
- anchor = pos;
- pos = other;
- } else if (posBefore != posLess(pos, other)) {
- pos = other;
- }
- }
- setSelection(doc, anchor, pos, bias);
- } else {
- setSelection(doc, pos, other || pos, bias);
- }
- if (doc.cm) doc.cm.curOp.userSelChange = true;
- }
-
- function filterSelectionChange(doc, anchor, head) {
- var obj = {anchor: anchor, head: head};
- signal(doc, "beforeSelectionChange", doc, obj);
- if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
- obj.anchor = clipPos(doc, obj.anchor); obj.head = clipPos(doc, obj.head);
- return obj;
- }
-
- // Update the selection. Last two args are only used by
- // updateDoc, since they have to be expressed in the line
- // numbers before the update.
- function setSelection(doc, anchor, head, bias, checkAtomic) {
- if (!checkAtomic && hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) {
- var filtered = filterSelectionChange(doc, anchor, head);
- head = filtered.head;
- anchor = filtered.anchor;
- }
-
- var sel = doc.sel;
- sel.goalColumn = null;
- if (bias == null) bias = posLess(head, sel.head) ? -1 : 1;
- // Skip over atomic spans.
- if (checkAtomic || !posEq(anchor, sel.anchor))
- anchor = skipAtomic(doc, anchor, bias, checkAtomic != "push");
- if (checkAtomic || !posEq(head, sel.head))
- head = skipAtomic(doc, head, bias, checkAtomic != "push");
-
- if (posEq(sel.anchor, anchor) && posEq(sel.head, head)) return;
-
- sel.anchor = anchor; sel.head = head;
- var inv = posLess(head, anchor);
- sel.from = inv ? head : anchor;
- sel.to = inv ? anchor : head;
-
- if (doc.cm)
- doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged =
- doc.cm.curOp.cursorActivity = true;
-
- signalLater(doc, "cursorActivity", doc);
- }
-
- function reCheckSelection(cm) {
- setSelection(cm.doc, cm.doc.sel.from, cm.doc.sel.to, null, "push");
- }
-
- function skipAtomic(doc, pos, bias, mayClear) {
- var flipped = false, curPos = pos;
- var dir = bias || 1;
- doc.cantEdit = false;
- search: for (;;) {
- var line = getLine(doc, curPos.line);
- if (line.markedSpans) {
- for (var i = 0; i < line.markedSpans.length; ++i) {
- var sp = line.markedSpans[i], m = sp.marker;
- if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
- (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
- if (mayClear) {
- signal(m, "beforeCursorEnter");
- if (m.explicitlyCleared) {
- if (!line.markedSpans) break;
- else {--i; continue;}
- }
- }
- if (!m.atomic) continue;
- var newPos = m.find()[dir < 0 ? "from" : "to"];
- if (posEq(newPos, curPos)) {
- newPos.ch += dir;
- if (newPos.ch < 0) {
- if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
- else newPos = null;
- } else if (newPos.ch > line.text.length) {
- if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
- else newPos = null;
- }
- if (!newPos) {
- if (flipped) {
- // Driven in a corner -- no valid cursor position found at all
- // -- try again *with* clearing, if we didn't already
- if (!mayClear) return skipAtomic(doc, pos, bias, true);
- // Otherwise, turn off editing until further notice, and return the start of the doc
- doc.cantEdit = true;
- return Pos(doc.first, 0);
- }
- flipped = true; newPos = pos; dir = -dir;
- }
- }
- curPos = newPos;
- continue search;
- }
+ });
+ }
+
+ if (doc.sel.contains(change.from, change.to) > -1)
+ signalCursorActivity(cm);
+
+ updateDoc(doc, change, spans, estimateHeight(cm));
+
+ if (!cm.options.lineWrapping) {
+ doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
+ var len = lineLength(line);
+ if (len > display.maxLineLength) {
+ display.maxLine = line;
+ display.maxLineLength = len;
+ display.maxLineChanged = true;
+ recomputeMaxLength = false;
}
- }
- return curPos;
+ });
+ if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
}
+
+ // Adjust frontier, schedule worker
+ doc.frontier = Math.min(doc.frontier, from.line);
+ startWorker(cm, 400);
+
+ var lendiff = change.text.length - (to.line - from.line) - 1;
+ // Remember that these lines changed, for updating the display
+ if (change.full)
+ regChange(cm);
+ else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
+ regLineChange(cm, from.line, "text");
+ else
+ regChange(cm, from.line, to.line + 1, lendiff);
+
+ var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
+ if (changeHandler || changesHandler) {
+ var obj = {
+ from: from, to: to,
+ text: change.text,
+ removed: change.removed,
+ origin: change.origin
+ };
+ if (changeHandler) signalLater(cm, "change", cm, obj);
+ if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
+ }
+ cm.display.selForContextMenu = null;
+ }
+
+ function replaceRange(doc, code, from, to, origin) {
+ if (!to) to = from;
+ if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
+ if (typeof code == "string") code = doc.splitLines(code);
+ makeChange(doc, {from: from, to: to, text: code, origin: origin});
}
- // SCROLLING
+ // SCROLLING THINGS INTO VIEW
- function scrollCursorIntoView(cm) {
- var coords = scrollPosIntoView(cm, cm.doc.sel.head, null, cm.options.cursorScrollMargin);
- if (!cm.state.focused) return;
- var display = cm.display, box = getRect(display.sizer), doScroll = null;
+ // If an editor sits on the top or bottom of the window, partially
+ // scrolled out of view, this ensures that the cursor is visible.
+ function maybeScrollWindow(cm, coords) {
+ if (signalDOMEvent(cm, "scrollCursorIntoView")) return;
+
+ var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
if (coords.top + box.top < 0) doScroll = true;
else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
if (doScroll != null && !phantom) {
var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
- (coords.top - display.viewOffset) + "px; height: " +
- (coords.bottom - coords.top + scrollerCutOff) + "px; left: " +
+ (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
+ (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " +
coords.left + "px; width: 2px;");
cm.display.lineSpace.appendChild(scrollNode);
scrollNode.scrollIntoView(doScroll);
@@ -2691,9 +4570,12 @@ window.CodeMirror = (function() {
}
}
+ // Scroll a given position into view (immediately), verifying that
+ // it actually became visible (as line heights are accurately
+ // measured, the position of something may 'drift' during drawing).
function scrollPosIntoView(cm, pos, end, margin) {
if (margin == null) margin = 0;
- for (;;) {
+ for (var limit = 0; limit < 5; limit++) {
var changed = false, coords = cursorCoords(cm, pos);
var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
@@ -2709,20 +4591,28 @@ window.CodeMirror = (function() {
setScrollLeft(cm, scrollPos.scrollLeft);
if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
}
- if (!changed) return coords;
+ if (!changed) break;
}
+ return coords;
}
+ // Scroll a given set of coordinates into view (immediately).
function scrollIntoView(cm, x1, y1, x2, y2) {
var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
}
+ // Calculate a new scroll position needed to scroll the given
+ // rectangle into view. Returns an object with scrollTop and
+ // scrollLeft properties. When these are undefined, the
+ // vertical/horizontal position does not need to be adjusted.
function calculateScrollPos(cm, x1, y1, x2, y2) {
var display = cm.display, snapMargin = textHeight(cm.display);
if (y1 < 0) y1 = 0;
- var screen = display.scroller.clientHeight - scrollerCutOff, screentop = display.scroller.scrollTop, result = {};
+ var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
+ var screen = displayHeight(cm), result = {};
+ if (y2 - y1 > screen) y2 = y1 + screen;
var docBottom = cm.doc.height + paddingVert(display);
var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;
if (y1 < screentop) {
@@ -2732,38 +4622,72 @@ window.CodeMirror = (function() {
if (newTop != screentop) result.scrollTop = newTop;
}
- var screenw = display.scroller.clientWidth - scrollerCutOff, screenleft = display.scroller.scrollLeft;
- x1 += display.gutters.offsetWidth; x2 += display.gutters.offsetWidth;
- var gutterw = display.gutters.offsetWidth;
- var atLeft = x1 < gutterw + 10;
- if (x1 < screenleft + gutterw || atLeft) {
- if (atLeft) x1 = 0;
- result.scrollLeft = Math.max(0, x1 - 10 - gutterw);
- } else if (x2 > screenw + screenleft - 3) {
- result.scrollLeft = x2 + 10 - screenw;
- }
+ var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
+ var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
+ var tooWide = x2 - x1 > screenw;
+ if (tooWide) x2 = x1 + screenw;
+ if (x1 < 10)
+ result.scrollLeft = 0;
+ else if (x1 < screenleft)
+ result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10));
+ else if (x2 > screenw + screenleft - 3)
+ result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw;
return result;
}
- function updateScrollPos(cm, left, top) {
- cm.curOp.updateScrollPos = {scrollLeft: left == null ? cm.doc.scrollLeft : left,
- scrollTop: top == null ? cm.doc.scrollTop : top};
+ // Store a relative adjustment to the scroll position in the current
+ // operation (to be applied when the operation finishes).
+ function addToScrollPos(cm, left, top) {
+ if (left != null || top != null) resolveScrollToPos(cm);
+ if (left != null)
+ cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left;
+ if (top != null)
+ cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
+ }
+
+ // Make sure that at the end of the operation the current cursor is
+ // shown.
+ function ensureCursorVisible(cm) {
+ resolveScrollToPos(cm);
+ var cur = cm.getCursor(), from = cur, to = cur;
+ if (!cm.options.lineWrapping) {
+ from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
+ to = Pos(cur.line, cur.ch + 1);
+ }
+ cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true};
}
- function addToScrollPos(cm, left, top) {
- var pos = cm.curOp.updateScrollPos || (cm.curOp.updateScrollPos = {scrollLeft: cm.doc.scrollLeft, scrollTop: cm.doc.scrollTop});
- var scroll = cm.display.scroller;
- pos.scrollTop = Math.max(0, Math.min(scroll.scrollHeight - scroll.clientHeight, pos.scrollTop + top));
- pos.scrollLeft = Math.max(0, Math.min(scroll.scrollWidth - scroll.clientWidth, pos.scrollLeft + left));
+ // When an operation has its scrollToPos property set, and another
+ // scroll action is applied before the end of the operation, this
+ // 'simulates' scrolling that position into view in a cheap way, so
+ // that the effect of intermediate scroll commands is not ignored.
+ function resolveScrollToPos(cm) {
+ var range = cm.curOp.scrollToPos;
+ if (range) {
+ cm.curOp.scrollToPos = null;
+ var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);
+ var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
+ Math.min(from.top, to.top) - range.margin,
+ Math.max(from.right, to.right),
+ Math.max(from.bottom, to.bottom) + range.margin);
+ cm.scrollTo(sPos.scrollLeft, sPos.scrollTop);
+ }
}
// API UTILITIES
+ // Indent the given line. The how parameter can be "smart",
+ // "add"/null, "subtract", or "prev". When aggressive is false
+ // (typically set to true for forced single-line indents), empty
+ // lines are not indented, and places where the mode returns Pass
+ // are left alone.
function indentLine(cm, n, how, aggressive) {
var doc = cm.doc, state;
if (how == null) how = "add";
if (how == "smart") {
- if (!cm.doc.mode.indent) how = "prev";
+ // Fall back to "prev" when the mode doesn't have an indentation
+ // method.
+ if (!doc.mode.indent) how = "prev";
else state = getStateBefore(cm, n);
}
@@ -2775,8 +4699,8 @@ window.CodeMirror = (function() {
indentation = 0;
how = "not";
} else if (how == "smart") {
- indentation = cm.doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
- if (indentation == Pass) {
+ indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
+ if (indentation == Pass || indentation > 150) {
if (!aggressive) return;
how = "prev";
}
@@ -2798,22 +4722,70 @@ window.CodeMirror = (function() {
for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
if (pos < indentation) indentString += spaceStr(indentation - pos);
- if (indentString != curSpaceString)
- replaceRange(cm.doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
- else if (doc.sel.head.line == n && doc.sel.head.ch < curSpaceString.length)
- setSelection(doc, Pos(n, curSpaceString.length), Pos(n, curSpaceString.length), 1);
- line.stateAfter = null;
+ if (indentString != curSpaceString) {
+ replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
+ line.stateAfter = null;
+ return true;
+ } else {
+ // Ensure that, if the cursor was in the whitespace at the start
+ // of the line, it is moved to the end of that space.
+ for (var i = 0; i < doc.sel.ranges.length; i++) {
+ var range = doc.sel.ranges[i];
+ if (range.head.line == n && range.head.ch < curSpaceString.length) {
+ var pos = Pos(n, curSpaceString.length);
+ replaceOneSelection(doc, i, new Range(pos, pos));
+ break;
+ }
+ }
+ }
}
- function changeLine(cm, handle, op) {
- var no = handle, line = handle, doc = cm.doc;
+ // Utility for applying a change to a line by handle or number,
+ // returning the number and optionally registering the line as
+ // changed.
+ function changeLine(doc, handle, changeType, op) {
+ var no = handle, line = handle;
if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
else no = lineNo(handle);
if (no == null) return null;
- if (op(line, no)) regChange(cm, no, no + 1);
+ if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType);
return line;
}
+ // Helper for deleting text near the selection(s), used to implement
+ // backspace, delete, and similar functionality.
+ function deleteNearSelection(cm, compute) {
+ var ranges = cm.doc.sel.ranges, kill = [];
+ // Build up a set of ranges to kill first, merging overlapping
+ // ranges.
+ for (var i = 0; i < ranges.length; i++) {
+ var toKill = compute(ranges[i]);
+ while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
+ var replaced = kill.pop();
+ if (cmp(replaced.from, toKill.from) < 0) {
+ toKill.from = replaced.from;
+ break;
+ }
+ }
+ kill.push(toKill);
+ }
+ // Next, remove those actual ranges.
+ runInOp(cm, function() {
+ for (var i = kill.length - 1; i >= 0; i--)
+ replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
+ ensureCursorVisible(cm);
+ });
+ }
+
+ // Used for horizontal relative motion. Dir is -1 or 1 (left or
+ // right), unit can be "char", "column" (like char, but doesn't
+ // cross line boundaries), "word" (across next word), or "group" (to
+ // the start of next group of word or non-word-non-whitespace
+ // chars). The visually param controls whether, in right-to-left
+ // text, direction 1 means to move towards the next index in the
+ // string, or towards the character to the right of the current
+ // position. The resulting position will have a hitSide=true
+ // property if it reached the end of the document.
function findPosH(doc, pos, dir, unit, visually) {
var line = pos.line, ch = pos.ch, origDir = dir;
var lineObj = getLine(doc, line);
@@ -2839,10 +4811,11 @@ window.CodeMirror = (function() {
else if (unit == "column") moveOnce(true);
else if (unit == "word" || unit == "group") {
var sawType = null, group = unit == "group";
+ var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
for (var first = true;; first = false) {
if (dir < 0 && !moveOnce(!first)) break;
var cur = lineObj.text.charAt(ch) || "\n";
- var type = isWordChar(cur) ? "w"
+ var type = isWordChar(cur, helper) ? "w"
: group && cur == "\n" ? "n"
: !group || /\s/.test(cur) ? null
: "p";
@@ -2861,6 +4834,9 @@ window.CodeMirror = (function() {
return result;
}
+ // For relative vertical movement. Dir may be -1 or 1. Unit can be
+ // "page" or "line". The resulting position will have a hitSide=true
+ // property if it reached the end of the document.
function findPosV(cm, pos, dir, unit) {
var doc = cm.doc, x = pos.left, y;
if (unit == "page") {
@@ -2878,32 +4854,19 @@ window.CodeMirror = (function() {
return target;
}
- function findWordAt(line, pos) {
- var start = pos.ch, end = pos.ch;
- if (line) {
- if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
- var startChar = line.charAt(start);
- var check = isWordChar(startChar) ? isWordChar
- : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
- : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
- while (start > 0 && check(line.charAt(start - 1))) --start;
- while (end < line.length && check(line.charAt(end))) ++end;
- }
- return {from: Pos(pos.line, start), to: Pos(pos.line, end)};
- }
-
- function selectLine(cm, line) {
- extendSelection(cm.doc, Pos(line, 0), clipPos(cm.doc, Pos(line + 1, 0)));
- }
+ // EDITOR METHODS
- // PROTOTYPE
+ // The publicly visible API. Note that methodOp(f) means
+ // 'wrap f in an operation, performed on its `this` parameter'.
- // The publicly visible API. Note that operation(null, f) means
- // 'wrap f in an operation, performed on its `this` parameter'
+ // This is not the complete set of editor methods. Most of the
+ // methods defined on the Doc type are also injected into
+ // CodeMirror.prototype, for backwards compatibility and
+ // convenience.
CodeMirror.prototype = {
constructor: CodeMirror,
- focus: function(){window.focus(); focusInput(this); fastPoll(this);},
+ focus: function(){window.focus(); this.display.input.focus();},
setOption: function(option, value) {
var options = this.options, old = options[option];
@@ -2917,25 +4880,25 @@ window.CodeMirror = (function() {
getDoc: function() {return this.doc;},
addKeyMap: function(map, bottom) {
- this.state.keyMaps[bottom ? "push" : "unshift"](map);
+ this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map));
},
removeKeyMap: function(map) {
var maps = this.state.keyMaps;
for (var i = 0; i < maps.length; ++i)
- if (maps[i] == map || (typeof maps[i] != "string" && maps[i].name == map)) {
+ if (maps[i] == map || maps[i].name == map) {
maps.splice(i, 1);
return true;
}
},
- addOverlay: operation(null, function(spec, options) {
+ addOverlay: methodOp(function(spec, options) {
var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
if (mode.startState) throw new Error("Overlays may not be stateful.");
this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
this.state.modeGen++;
regChange(this);
}),
- removeOverlay: operation(null, function(spec) {
+ removeOverlay: methodOp(function(spec) {
var overlays = this.state.overlays;
for (var i = 0; i < overlays.length; ++i) {
var cur = overlays[i].modeSpec;
@@ -2948,51 +4911,58 @@ window.CodeMirror = (function() {
}
}),
- indentLine: operation(null, function(n, dir, aggressive) {
+ indentLine: methodOp(function(n, dir, aggressive) {
if (typeof dir != "string" && typeof dir != "number") {
if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
else dir = dir ? "add" : "subtract";
}
if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);
}),
- indentSelection: operation(null, function(how) {
- var sel = this.doc.sel;
- if (posEq(sel.from, sel.to)) return indentLine(this, sel.from.line, how, true);
- var e = sel.to.line - (sel.to.ch ? 0 : 1);
- for (var i = sel.from.line; i <= e; ++i) indentLine(this, i, how);
+ indentSelection: methodOp(function(how) {
+ var ranges = this.doc.sel.ranges, end = -1;
+ for (var i = 0; i < ranges.length; i++) {
+ var range = ranges[i];
+ if (!range.empty()) {
+ var from = range.from(), to = range.to();
+ var start = Math.max(end, from.line);
+ end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
+ for (var j = start; j < end; ++j)
+ indentLine(this, j, how);
+ var newRanges = this.doc.sel.ranges;
+ if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
+ replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll);
+ } else if (range.head.line > end) {
+ indentLine(this, range.head.line, how, true);
+ end = range.head.line;
+ if (i == this.doc.sel.primIndex) ensureCursorVisible(this);
+ }
+ }
}),
// Fetch the parser token for a given character. Useful for hacks
// that want to inspect the mode state (say, for completion).
getTokenAt: function(pos, precise) {
- var doc = this.doc;
- pos = clipPos(doc, pos);
- var state = getStateBefore(this, pos.line, precise), mode = this.doc.mode;
- var line = getLine(doc, pos.line);
- var stream = new StringStream(line.text, this.options.tabSize);
- while (stream.pos < pos.ch && !stream.eol()) {
- stream.start = stream.pos;
- var style = mode.token(stream, state);
- }
- return {start: stream.start,
- end: stream.pos,
- string: stream.current(),
- className: style || null, // Deprecated, use 'type' instead
- type: style || null,
- state: state};
+ return takeToken(this, pos, precise);
+ },
+
+ getLineTokens: function(line, precise) {
+ return takeToken(this, Pos(line), precise, true);
},
getTokenTypeAt: function(pos) {
pos = clipPos(this.doc, pos);
var styles = getLineStyles(this, getLine(this.doc, pos.line));
var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
- if (ch == 0) return styles[2];
- for (;;) {
+ var type;
+ if (ch == 0) type = styles[2];
+ else for (;;) {
var mid = (before + after) >> 1;
if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;
else if (styles[mid * 2 + 1] < ch) before = mid + 1;
- else return styles[mid * 2 + 2];
+ else { type = styles[mid * 2 + 2]; break; }
}
+ var cut = type ? type.indexOf("cm-overlay ") : -1;
+ return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);
},
getModeAt: function(pos) {
@@ -3007,7 +4977,7 @@ window.CodeMirror = (function() {
getHelpers: function(pos, type) {
var found = [];
- if (!helpers.hasOwnProperty(type)) return helpers;
+ if (!helpers.hasOwnProperty(type)) return found;
var help = helpers[type], mode = this.getModeAt(pos);
if (typeof mode[type] == "string") {
if (help[mode[type]]) found.push(help[mode[type]]);
@@ -3036,10 +5006,10 @@ window.CodeMirror = (function() {
},
cursorCoords: function(start, mode) {
- var pos, sel = this.doc.sel;
- if (start == null) pos = sel.head;
+ var pos, range = this.doc.sel.primary();
+ if (start == null) pos = range.head;
else if (typeof start == "object") pos = clipPos(this.doc, start);
- else pos = start ? sel.from : sel.to;
+ else pos = start ? range.from() : range.to();
return cursorCoords(this, pos, mode || "page");
},
@@ -3057,19 +5027,24 @@ window.CodeMirror = (function() {
return lineAtHeight(this.doc, height + this.display.viewOffset);
},
heightAtLine: function(line, mode) {
- var end = false, last = this.doc.first + this.doc.size - 1;
- if (line < this.doc.first) line = this.doc.first;
- else if (line > last) { line = last; end = true; }
- var lineObj = getLine(this.doc, line);
- return intoCoordSystem(this, getLine(this.doc, line), {top: 0, left: 0}, mode || "page").top +
- (end ? this.doc.height - heightAtLine(this, lineObj) : 0);
+ var end = false, lineObj;
+ if (typeof line == "number") {
+ var last = this.doc.first + this.doc.size - 1;
+ if (line < this.doc.first) line = this.doc.first;
+ else if (line > last) { line = last; end = true; }
+ lineObj = getLine(this.doc, line);
+ } else {
+ lineObj = line;
+ }
+ return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top +
+ (end ? this.doc.height - heightAtLine(lineObj) : 0);
},
defaultTextHeight: function() { return textHeight(this.display); },
defaultCharWidth: function() { return charWidth(this.display); },
- setGutterMarker: operation(null, function(line, gutterID, value) {
- return changeLine(this, line, function(line) {
+ setGutterMarker: methodOp(function(line, gutterID, value) {
+ return changeLine(this.doc, line, "gutter", function(line) {
var markers = line.gutterMarkers || (line.gutterMarkers = {});
markers[gutterID] = value;
if (!value && isEmpty(markers)) line.gutterMarkers = null;
@@ -3077,50 +5052,18 @@ window.CodeMirror = (function() {
});
}),
- clearGutter: operation(null, function(gutterID) {
+ clearGutter: methodOp(function(gutterID) {
var cm = this, doc = cm.doc, i = doc.first;
doc.iter(function(line) {
if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
line.gutterMarkers[gutterID] = null;
- regChange(cm, i, i + 1);
+ regLineChange(cm, i, "gutter");
if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
}
++i;
});
}),
- addLineClass: operation(null, function(handle, where, cls) {
- return changeLine(this, handle, function(line) {
- var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass";
- if (!line[prop]) line[prop] = cls;
- else if (new RegExp("(?:^|\\s)" + cls + "(?:$|\\s)").test(line[prop])) return false;
- else line[prop] += " " + cls;
- return true;
- });
- }),
-
- removeLineClass: operation(null, function(handle, where, cls) {
- return changeLine(this, handle, function(line) {
- var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass";
- var cur = line[prop];
- if (!cur) return false;
- else if (cls == null) line[prop] = null;
- else {
- var found = cur.match(new RegExp("(?:^|\\s+)" + cls + "(?:$|\\s+)"));
- if (!found) return false;
- var end = found.index + found[0].length;
- line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
- }
- return true;
- });
- }),
-
- addLineWidget: operation(null, function(handle, node, options) {
- return addLineWidget(this, handle, node, options);
- }),
-
- removeLineWidget: function(widget) { widget.clear(); },
-
lineInfo: function(line) {
if (typeof line == "number") {
if (!isLine(this.doc, line)) return null;
@@ -3136,13 +5079,15 @@ window.CodeMirror = (function() {
widgets: line.widgets};
},
- getViewport: function() { return {from: this.display.showingFrom, to: this.display.showingTo};},
+ getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};},
addWidget: function(pos, node, scroll, vert, horiz) {
var display = this.display;
pos = cursorCoords(this, clipPos(this.doc, pos));
var top = pos.bottom, left = pos.left;
node.style.position = "absolute";
+ node.setAttribute("cm-ignore-events", "true");
+ this.display.input.setUneditable(node);
display.sizer.appendChild(node);
if (vert == "over") {
top = pos.top;
@@ -3171,15 +5116,17 @@ window.CodeMirror = (function() {
scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);
},
- triggerOnKeyDown: operation(null, onKeyDown),
- triggerOnKeyPress: operation(null, onKeyPress),
- triggerOnKeyUp: operation(null, onKeyUp),
+ triggerOnKeyDown: methodOp(onKeyDown),
+ triggerOnKeyPress: methodOp(onKeyPress),
+ triggerOnKeyUp: onKeyUp,
execCommand: function(cmd) {
if (commands.hasOwnProperty(cmd))
- return commands[cmd](this);
+ return commands[cmd].call(null, this);
},
+ triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
+
findPosH: function(from, amount, unit, visually) {
var dir = 1;
if (amount < 0) { dir = -1; amount = -amount; }
@@ -3190,20 +5137,25 @@ window.CodeMirror = (function() {
return cur;
},
- moveH: operation(null, function(dir, unit) {
- var sel = this.doc.sel, pos;
- if (sel.shift || sel.extend || posEq(sel.from, sel.to))
- pos = findPosH(this.doc, sel.head, dir, unit, this.options.rtlMoveVisually);
- else
- pos = dir < 0 ? sel.from : sel.to;
- extendSelection(this.doc, pos, pos, dir);
+ moveH: methodOp(function(dir, unit) {
+ var cm = this;
+ cm.extendSelectionsBy(function(range) {
+ if (cm.display.shift || cm.doc.extend || range.empty())
+ return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually);
+ else
+ return dir < 0 ? range.from() : range.to();
+ }, sel_move);
}),
- deleteH: operation(null, function(dir, unit) {
- var sel = this.doc.sel;
- if (!posEq(sel.from, sel.to)) replaceRange(this.doc, "", sel.from, sel.to, "+delete");
- else replaceRange(this.doc, "", sel.from, findPosH(this.doc, sel.head, dir, unit, false), "+delete");
- this.curOp.userSelChange = true;
+ deleteH: methodOp(function(dir, unit) {
+ var sel = this.doc.sel, doc = this.doc;
+ if (sel.somethingSelected())
+ doc.replaceSelection("", null, "+delete");
+ else
+ deleteNearSelection(this, function(range) {
+ var other = findPosH(doc, range.head, dir, unit, false);
+ return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other};
+ });
}),
findPosV: function(from, amount, unit, goalColumn) {
@@ -3219,98 +5171,135 @@ window.CodeMirror = (function() {
return cur;
},
- moveV: operation(null, function(dir, unit) {
- var sel = this.doc.sel, target, goal;
- if (sel.shift || sel.extend || posEq(sel.from, sel.to)) {
- var pos = cursorCoords(this, sel.head, "div");
- if (sel.goalColumn != null) pos.left = sel.goalColumn;
- target = findPosV(this, pos, dir, unit);
- if (unit == "page") addToScrollPos(this, 0, charCoords(this, target, "div").top - pos.top);
- goal = pos.left;
- } else {
- target = dir < 0 ? sel.from : sel.to;
- }
- extendSelection(this.doc, target, target, dir);
- if (goal != null) sel.goalColumn = goal;
+ moveV: methodOp(function(dir, unit) {
+ var cm = this, doc = this.doc, goals = [];
+ var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected();
+ doc.extendSelectionsBy(function(range) {
+ if (collapse)
+ return dir < 0 ? range.from() : range.to();
+ var headPos = cursorCoords(cm, range.head, "div");
+ if (range.goalColumn != null) headPos.left = range.goalColumn;
+ goals.push(headPos.left);
+ var pos = findPosV(cm, headPos, dir, unit);
+ if (unit == "page" && range == doc.sel.primary())
+ addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top);
+ return pos;
+ }, sel_move);
+ if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++)
+ doc.sel.ranges[i].goalColumn = goals[i];
}),
+ // Find the word at the given position (as returned by coordsChar).
+ findWordAt: function(pos) {
+ var doc = this.doc, line = getLine(doc, pos.line).text;
+ var start = pos.ch, end = pos.ch;
+ if (line) {
+ var helper = this.getHelper(pos, "wordChars");
+ if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
+ var startChar = line.charAt(start);
+ var check = isWordChar(startChar, helper)
+ ? function(ch) { return isWordChar(ch, helper); }
+ : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
+ : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
+ while (start > 0 && check(line.charAt(start - 1))) --start;
+ while (end < line.length && check(line.charAt(end))) ++end;
+ }
+ return new Range(Pos(pos.line, start), Pos(pos.line, end));
+ },
+
toggleOverwrite: function(value) {
if (value != null && value == this.state.overwrite) return;
if (this.state.overwrite = !this.state.overwrite)
- this.display.cursor.className += " CodeMirror-overwrite";
+ addClass(this.display.cursorDiv, "CodeMirror-overwrite");
else
- this.display.cursor.className = this.display.cursor.className.replace(" CodeMirror-overwrite", "");
+ rmClass(this.display.cursorDiv, "CodeMirror-overwrite");
signal(this, "overwriteToggle", this, this.state.overwrite);
},
- hasFocus: function() { return document.activeElement == this.display.input; },
+ hasFocus: function() { return this.display.input.getField() == activeElt(); },
- scrollTo: operation(null, function(x, y) {
- updateScrollPos(this, x, y);
+ scrollTo: methodOp(function(x, y) {
+ if (x != null || y != null) resolveScrollToPos(this);
+ if (x != null) this.curOp.scrollLeft = x;
+ if (y != null) this.curOp.scrollTop = y;
}),
getScrollInfo: function() {
- var scroller = this.display.scroller, co = scrollerCutOff;
+ var scroller = this.display.scroller;
return {left: scroller.scrollLeft, top: scroller.scrollTop,
- height: scroller.scrollHeight - co, width: scroller.scrollWidth - co,
- clientHeight: scroller.clientHeight - co, clientWidth: scroller.clientWidth - co};
+ height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
+ width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
+ clientHeight: displayHeight(this), clientWidth: displayWidth(this)};
},
- scrollIntoView: operation(null, function(range, margin) {
- if (range == null) range = {from: this.doc.sel.head, to: null};
- else if (typeof range == "number") range = {from: Pos(range, 0), to: null};
- else if (range.from == null) range = {from: range, to: null};
+ scrollIntoView: methodOp(function(range, margin) {
+ if (range == null) {
+ range = {from: this.doc.sel.primary().head, to: null};
+ if (margin == null) margin = this.options.cursorScrollMargin;
+ } else if (typeof range == "number") {
+ range = {from: Pos(range, 0), to: null};
+ } else if (range.from == null) {
+ range = {from: range, to: null};
+ }
if (!range.to) range.to = range.from;
- if (!margin) margin = 0;
+ range.margin = margin || 0;
- var coords = range;
if (range.from.line != null) {
- this.curOp.scrollToPos = {from: range.from, to: range.to, margin: margin};
- coords = {from: cursorCoords(this, range.from),
- to: cursorCoords(this, range.to)};
- }
- var sPos = calculateScrollPos(this, Math.min(coords.from.left, coords.to.left),
- Math.min(coords.from.top, coords.to.top) - margin,
- Math.max(coords.from.right, coords.to.right),
- Math.max(coords.from.bottom, coords.to.bottom) + margin);
- updateScrollPos(this, sPos.scrollLeft, sPos.scrollTop);
+ resolveScrollToPos(this);
+ this.curOp.scrollToPos = range;
+ } else {
+ var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),
+ Math.min(range.from.top, range.to.top) - range.margin,
+ Math.max(range.from.right, range.to.right),
+ Math.max(range.from.bottom, range.to.bottom) + range.margin);
+ this.scrollTo(sPos.scrollLeft, sPos.scrollTop);
+ }
}),
- setSize: operation(null, function(width, height) {
+ setSize: methodOp(function(width, height) {
+ var cm = this;
function interpret(val) {
return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
}
- if (width != null) this.display.wrapper.style.width = interpret(width);
- if (height != null) this.display.wrapper.style.height = interpret(height);
- if (this.options.lineWrapping)
- this.display.measureLineCache.length = this.display.measureLineCachePos = 0;
- this.curOp.forceUpdate = true;
- signal(this, "refresh", this);
+ if (width != null) cm.display.wrapper.style.width = interpret(width);
+ if (height != null) cm.display.wrapper.style.height = interpret(height);
+ if (cm.options.lineWrapping) clearLineMeasurementCache(this);
+ var lineNo = cm.display.viewFrom;
+ cm.doc.iter(lineNo, cm.display.viewTo, function(line) {
+ if (line.widgets) for (var i = 0; i < line.widgets.length; i++)
+ if (line.widgets[i].noHScroll) { regLineChange(cm, lineNo, "widget"); break; }
+ ++lineNo;
+ });
+ cm.curOp.forceUpdate = true;
+ signal(cm, "refresh", this);
}),
operation: function(f){return runInOp(this, f);},
- refresh: operation(null, function() {
+ refresh: methodOp(function() {
var oldHeight = this.display.cachedTextHeight;
- clearCaches(this);
- updateScrollPos(this, this.doc.scrollLeft, this.doc.scrollTop);
regChange(this);
+ this.curOp.forceUpdate = true;
+ clearCaches(this);
+ this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop);
+ updateGutterSpace(this);
if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
estimateLineHeights(this);
signal(this, "refresh", this);
}),
- swapDoc: operation(null, function(doc) {
+ swapDoc: methodOp(function(doc) {
var old = this.doc;
old.cm = null;
attachDoc(this, doc);
clearCaches(this);
- resetInput(this, true);
- updateScrollPos(this, doc.scrollLeft, doc.scrollTop);
+ this.display.input.reset();
+ this.scrollTo(doc.scrollLeft, doc.scrollTop);
+ this.curOp.forceScroll = true;
signalLater(this, "swapDoc", this, old);
return old;
}),
- getInputField: function(){return this.display.input;},
+ getInputField: function(){return this.display.input.getField();},
getWrapperElement: function(){return this.display.wrapper;},
getScrollerElement: function(){return this.display.scroller;},
getGutterElement: function(){return this.display.gutters;}
@@ -3319,10 +5308,10 @@ window.CodeMirror = (function() {
// OPTION DEFAULTS
- var optionHandlers = CodeMirror.optionHandlers = {};
-
// The default configuration options.
var defaults = CodeMirror.defaults = {};
+ // Functions to run when options are changed.
+ var optionHandlers = CodeMirror.optionHandlers = {};
function option(name, deflt, handle, notOnInit) {
CodeMirror.defaults[name] = deflt;
@@ -3330,6 +5319,7 @@ window.CodeMirror = (function() {
notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
}
+ // Passed to option handlers when there is no old value.
var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}};
// These two are, on init, called from the constructor because they
@@ -3350,12 +5340,31 @@ window.CodeMirror = (function() {
clearCaches(cm);
regChange(cm);
}, true);
- option("specialChars", /[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g, function(cm, val) {
- cm.options.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
- cm.refresh();
- }, true);
+ option("lineSeparator", null, function(cm, val) {
+ cm.doc.lineSep = val;
+ if (!val) return;
+ var newBreaks = [], lineNo = cm.doc.first;
+ cm.doc.iter(function(line) {
+ for (var pos = 0;;) {
+ var found = line.text.indexOf(val, pos);
+ if (found == -1) break;
+ pos = found + val.length;
+ newBreaks.push(Pos(lineNo, found));
+ }
+ lineNo++;
+ });
+ for (var i = newBreaks.length - 1; i >= 0; i--)
+ replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length))
+ });
+ option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) {
+ cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
+ if (old != CodeMirror.Init) cm.refresh();
+ });
option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);
option("electricChars", true);
+ option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
+ throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME
+ }, true);
option("rtlMoveVisually", !windows);
option("wholeLineUpdateBefore", true);
@@ -3363,12 +5372,14 @@ window.CodeMirror = (function() {
themeChanged(cm);
guttersChanged(cm);
}, true);
- option("keyMap", "default", keyMapChanged);
+ option("keyMap", "default", function(cm, val, old) {
+ var next = getKeyMap(val);
+ var prev = old != CodeMirror.Init && getKeyMap(old);
+ if (prev && prev.detach) prev.detach(cm, next);
+ if (next.attach) next.attach(cm, prev || null);
+ });
option("extraKeys", null);
- option("onKeyEvent", null);
- option("onDragEvent", null);
-
option("lineWrapping", false, wrappingChanged, true);
option("gutters", [], function(cm) {
setGuttersForLineNumbers(cm.options);
@@ -3378,7 +5389,13 @@ window.CodeMirror = (function() {
cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
cm.refresh();
}, true);
- option("coverGutterNextToScrollbar", false, updateScrollbars, true);
+ option("coverGutterNextToScrollbar", false, function(cm) {updateScrollbars(cm);}, true);
+ option("scrollbarStyle", "native", function(cm) {
+ initScrollbars(cm);
+ updateScrollbars(cm);
+ cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
+ cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
+ }, true);
option("lineNumbers", false, function(cm) {
setGuttersForLineNumbers(cm.options);
guttersChanged(cm);
@@ -3388,6 +5405,7 @@ window.CodeMirror = (function() {
option("showCursorWhenSelecting", false, updateSelection, true);
option("resetSelectionOnContextMenu", true);
+ option("lineWiseCopyCut", true);
option("readOnly", false, function(cm, val) {
if (val == "nocursor") {
@@ -3396,31 +5414,32 @@ window.CodeMirror = (function() {
cm.display.disabled = true;
} else {
cm.display.disabled = false;
- if (!val) resetInput(cm, true);
}
+ cm.display.input.readOnlyChanged(val)
});
- option("disableInput", false, function(cm, val) {if (!val) resetInput(cm, true);}, true);
- option("dragDrop", true);
+ option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
+ option("dragDrop", true, dragDropChanged);
+ option("allowDropFileTypes", null);
option("cursorBlinkRate", 530);
option("cursorScrollMargin", 0);
- option("cursorHeight", 1);
+ option("cursorHeight", 1, updateSelection, true);
+ option("singleCursorHeightPerLine", true, updateSelection, true);
option("workTime", 100);
option("workDelay", 100);
option("flattenSpans", true, resetModeState, true);
option("addModeClass", false, resetModeState, true);
option("pollInterval", 100);
- option("undoDepth", 40, function(cm, val){cm.doc.history.undoDepth = val;});
- option("historyEventDelay", 500);
+ option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;});
+ option("historyEventDelay", 1250);
option("viewportMargin", 10, function(cm){cm.refresh();}, true);
option("maxHighlightLength", 10000, resetModeState, true);
- option("crudeMeasuringFrom", 10000);
option("moveInputWithCursor", true, function(cm, val) {
- if (!val) cm.display.inputDiv.style.top = cm.display.inputDiv.style.left = 0;
+ if (!val) cm.display.input.resetPosition();
});
option("tabindex", null, function(cm, val) {
- cm.display.input.tabIndex = val || "";
+ cm.display.input.getField().tabIndex = val || "";
});
option("autofocus", null);
@@ -3429,12 +5448,13 @@ window.CodeMirror = (function() {
// Known modes, by name and by MIME
var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
+ // Extra arguments are stored as the mode's dependencies, which is
+ // used by (legacy) mechanisms like loadmode.js to automatically
+ // load a mode. (Preferred mechanism is the require/define calls.)
CodeMirror.defineMode = function(name, mode) {
if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
- if (arguments.length > 2) {
- mode.dependencies = [];
- for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]);
- }
+ if (arguments.length > 2)
+ mode.dependencies = Array.prototype.slice.call(arguments, 2);
modes[name] = mode;
};
@@ -3442,6 +5462,8 @@ window.CodeMirror = (function() {
mimeModes[mime] = spec;
};
+ // Given a MIME type, a {name, ...options} config object, or a name
+ // string, return a mode config object.
CodeMirror.resolveMode = function(spec) {
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
spec = mimeModes[spec];
@@ -3457,6 +5479,8 @@ window.CodeMirror = (function() {
else return spec || {name: "null"};
};
+ // Given a mode spec (anything that resolveMode accepts), find and
+ // initialize an actual mode object.
CodeMirror.getMode = function(options, spec) {
var spec = CodeMirror.resolveMode(spec);
var mfactory = modes[spec.name];
@@ -3478,11 +5502,14 @@ window.CodeMirror = (function() {
return modeObj;
};
+ // Minimal default mode.
CodeMirror.defineMode("null", function() {
return {token: function(stream) {stream.skipToEnd();}};
});
CodeMirror.defineMIME("text/plain", "null");
+ // This can be used to attach properties to mode objects from
+ // outside the actual mode definition.
var modeExtensions = CodeMirror.modeExtensions = {};
CodeMirror.extendMode = function(mode, properties) {
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
@@ -3512,15 +5539,12 @@ window.CodeMirror = (function() {
helpers[type]._global.push({pred: predicate, val: value});
};
- // UTILITIES
-
- CodeMirror.isWordChar = isWordChar;
-
// MODE STATE HANDLING
- // Utility functions for working with state. Exported because modes
- // sometimes need to do this.
- function copyState(mode, state) {
+ // Utility functions for working with state. Exported because nested
+ // modes need to do this for their inner modes.
+
+ var copyState = CodeMirror.copyState = function(mode, state) {
if (state === true) return state;
if (mode.copyState) return mode.copyState(state);
var nstate = {};
@@ -3530,14 +5554,14 @@ window.CodeMirror = (function() {
nstate[n] = val;
}
return nstate;
- }
- CodeMirror.copyState = copyState;
+ };
- function startState(mode, a1, a2) {
+ var startState = CodeMirror.startState = function(mode, a1, a2) {
return mode.startState ? mode.startState(a1, a2) : true;
- }
- CodeMirror.startState = startState;
+ };
+ // Given a mode and a state (for that mode), find the inner mode and
+ // state at the position that the state refers to.
CodeMirror.innerMode = function(mode, state) {
while (mode.innerMode) {
var info = mode.innerMode(state);
@@ -3550,49 +5574,89 @@ window.CodeMirror = (function() {
// STANDARD COMMANDS
+ // Commands are parameter-less actions that can be performed on an
+ // editor, mostly used for keybindings.
var commands = CodeMirror.commands = {
- selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()));},
+ selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);},
+ singleSelection: function(cm) {
+ cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
+ },
killLine: function(cm) {
- var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
- if (!sel && cm.getLine(from.line).length == from.ch)
- cm.replaceRange("", from, Pos(from.line + 1, 0), "+delete");
- else cm.replaceRange("", from, sel ? to : Pos(from.line), "+delete");
+ deleteNearSelection(cm, function(range) {
+ if (range.empty()) {
+ var len = getLine(cm.doc, range.head.line).text.length;
+ if (range.head.ch == len && range.head.line < cm.lastLine())
+ return {from: range.head, to: Pos(range.head.line + 1, 0)};
+ else
+ return {from: range.head, to: Pos(range.head.line, len)};
+ } else {
+ return {from: range.from(), to: range.to()};
+ }
+ });
},
deleteLine: function(cm) {
- var l = cm.getCursor().line;
- cm.replaceRange("", Pos(l, 0), Pos(l + 1, 0), "+delete");
+ deleteNearSelection(cm, function(range) {
+ return {from: Pos(range.from().line, 0),
+ to: clipPos(cm.doc, Pos(range.to().line + 1, 0))};
+ });
},
delLineLeft: function(cm) {
- var cur = cm.getCursor();
- cm.replaceRange("", Pos(cur.line, 0), cur, "+delete");
+ deleteNearSelection(cm, function(range) {
+ return {from: Pos(range.from().line, 0), to: range.from()};
+ });
+ },
+ delWrappedLineLeft: function(cm) {
+ deleteNearSelection(cm, function(range) {
+ var top = cm.charCoords(range.head, "div").top + 5;
+ var leftPos = cm.coordsChar({left: 0, top: top}, "div");
+ return {from: leftPos, to: range.from()};
+ });
+ },
+ delWrappedLineRight: function(cm) {
+ deleteNearSelection(cm, function(range) {
+ var top = cm.charCoords(range.head, "div").top + 5;
+ var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
+ return {from: range.from(), to: rightPos };
+ });
},
undo: function(cm) {cm.undo();},
redo: function(cm) {cm.redo();},
+ undoSelection: function(cm) {cm.undoSelection();},
+ redoSelection: function(cm) {cm.redoSelection();},
goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
goLineStart: function(cm) {
- cm.extendSelection(lineStart(cm, cm.getCursor().line));
+ cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); },
+ {origin: "+move", bias: 1});
},
goLineStartSmart: function(cm) {
- var cur = cm.getCursor(), start = lineStart(cm, cur.line);
- var line = cm.getLineHandle(start.line);
- var order = getOrder(line);
- if (!order || order[0].level == 0) {
- var firstNonWS = Math.max(0, line.text.search(/\S/));
- var inWS = cur.line == start.line && cur.ch <= firstNonWS && cur.ch;
- cm.extendSelection(Pos(start.line, inWS ? 0 : firstNonWS));
- } else cm.extendSelection(start);
+ cm.extendSelectionsBy(function(range) {
+ return lineStartSmart(cm, range.head);
+ }, {origin: "+move", bias: 1});
},
goLineEnd: function(cm) {
- cm.extendSelection(lineEnd(cm, cm.getCursor().line));
+ cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); },
+ {origin: "+move", bias: -1});
},
goLineRight: function(cm) {
- var top = cm.charCoords(cm.getCursor(), "div").top + 5;
- cm.extendSelection(cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"));
+ cm.extendSelectionsBy(function(range) {
+ var top = cm.charCoords(range.head, "div").top + 5;
+ return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
+ }, sel_move);
},
goLineLeft: function(cm) {
- var top = cm.charCoords(cm.getCursor(), "div").top + 5;
- cm.extendSelection(cm.coordsChar({left: 0, top: top}, "div"));
+ cm.extendSelectionsBy(function(range) {
+ var top = cm.charCoords(range.head, "div").top + 5;
+ return cm.coordsChar({left: 0, top: top}, "div");
+ }, sel_move);
+ },
+ goLineLeftSmart: function(cm) {
+ cm.extendSelectionsBy(function(range) {
+ var top = cm.charCoords(range.head, "div").top + 5;
+ var pos = cm.coordsChar({left: 0, top: top}, "div");
+ if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head);
+ return pos;
+ }, sel_move);
},
goLineUp: function(cm) {cm.moveV(-1, "line");},
goLineDown: function(cm) {cm.moveV(1, "line");},
@@ -3615,135 +5679,208 @@ window.CodeMirror = (function() {
indentAuto: function(cm) {cm.indentSelection("smart");},
indentMore: function(cm) {cm.indentSelection("add");},
indentLess: function(cm) {cm.indentSelection("subtract");},
- insertTab: function(cm) {
- cm.replaceSelection("\t", "end", "+input");
- },
+ insertTab: function(cm) {cm.replaceSelection("\t");},
insertSoftTab: function(cm) {
- var pos = cm.getCursor("from"), tabSize = cm.options.tabSize;
- var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
- cm.replaceSelection(new Array(tabSize - col % tabSize + 1).join(" "), "end", "+input");
+ var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
+ for (var i = 0; i < ranges.length; i++) {
+ var pos = ranges[i].from();
+ var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
+ spaces.push(new Array(tabSize - col % tabSize + 1).join(" "));
+ }
+ cm.replaceSelections(spaces);
},
defaultTab: function(cm) {
if (cm.somethingSelected()) cm.indentSelection("add");
- else cm.replaceSelection("\t", "end", "+input");
+ else cm.execCommand("insertTab");
},
transposeChars: function(cm) {
- var cur = cm.getCursor(), line = cm.getLine(cur.line);
- if (cur.ch > 0 && cur.ch < line.length - 1)
- cm.replaceRange(line.charAt(cur.ch) + line.charAt(cur.ch - 1),
- Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1));
+ runInOp(cm, function() {
+ var ranges = cm.listSelections(), newSel = [];
+ for (var i = 0; i < ranges.length; i++) {
+ var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
+ if (line) {
+ if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1);
+ if (cur.ch > 0) {
+ cur = new Pos(cur.line, cur.ch + 1);
+ cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
+ Pos(cur.line, cur.ch - 2), cur, "+transpose");
+ } else if (cur.line > cm.doc.first) {
+ var prev = getLine(cm.doc, cur.line - 1).text;
+ if (prev)
+ cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
+ prev.charAt(prev.length - 1),
+ Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
+ }
+ }
+ newSel.push(new Range(cur, cur));
+ }
+ cm.setSelections(newSel);
+ });
},
newlineAndIndent: function(cm) {
- operation(cm, function() {
- cm.replaceSelection("\n", "end", "+input");
- cm.indentLine(cm.getCursor().line, null, true);
- })();
+ runInOp(cm, function() {
+ var len = cm.listSelections().length;
+ for (var i = 0; i < len; i++) {
+ var range = cm.listSelections()[i];
+ cm.replaceRange(cm.doc.lineSeparator(), range.anchor, range.head, "+input");
+ cm.indentLine(range.from().line + 1, null, true);
+ }
+ ensureCursorVisible(cm);
+ });
},
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
};
+
// STANDARD KEYMAPS
var keyMap = CodeMirror.keyMap = {};
+
keyMap.basic = {
"Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
"End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
"Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
"Tab": "defaultTab", "Shift-Tab": "indentAuto",
- "Enter": "newlineAndIndent", "Insert": "toggleOverwrite"
+ "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
+ "Esc": "singleSelection"
};
// Note that the save and find-related commands aren't defined by
- // default. Unknown commands are simply ignored.
+ // default. User code or addons can define them. Unknown commands
+ // are simply ignored.
keyMap.pcDefault = {
"Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
- "Ctrl-Home": "goDocStart", "Ctrl-Up": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Down": "goDocEnd",
+ "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
"Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
"Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
"Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
"Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
+ "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
fallthrough: "basic"
};
+ // Very basic readline/emacs-style bindings, which are standard on Mac.
+ keyMap.emacsy = {
+ "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
+ "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
+ "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
+ "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
+ };
keyMap.macDefault = {
"Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
- "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
- "Alt-Right": "goGroupRight", "Cmd-Left": "goLineStart", "Cmd-Right": "goLineEnd", "Alt-Backspace": "delGroupBefore",
+ "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
+ "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
"Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
"Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
- "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delLineLeft",
+ "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
+ "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
fallthrough: ["basic", "emacsy"]
};
keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
- keyMap.emacsy = {
- "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
- "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
- "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
- "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
- };
// KEYMAP DISPATCH
- function getKeyMap(val) {
- if (typeof val == "string") return keyMap[val];
- else return val;
- }
-
- function lookupKey(name, maps, handle) {
- function lookup(map) {
- map = getKeyMap(map);
- var found = map[name];
- if (found === false) return "stop";
- if (found != null && handle(found)) return true;
- if (map.nofallthrough) return "stop";
-
- var fallthrough = map.fallthrough;
- if (fallthrough == null) return false;
- if (Object.prototype.toString.call(fallthrough) != "[object Array]")
- return lookup(fallthrough);
- for (var i = 0, e = fallthrough.length; i < e; ++i) {
- var done = lookup(fallthrough[i]);
- if (done) return done;
+ function normalizeKeyName(name) {
+ var parts = name.split(/-(?!$)/), name = parts[parts.length - 1];
+ var alt, ctrl, shift, cmd;
+ for (var i = 0; i < parts.length - 1; i++) {
+ var mod = parts[i];
+ if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
+ else if (/^a(lt)?$/i.test(mod)) alt = true;
+ else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
+ else if (/^s(hift)$/i.test(mod)) shift = true;
+ else throw new Error("Unrecognized modifier name: " + mod);
+ }
+ if (alt) name = "Alt-" + name;
+ if (ctrl) name = "Ctrl-" + name;
+ if (cmd) name = "Cmd-" + name;
+ if (shift) name = "Shift-" + name;
+ return name;
+ }
+
+ // This is a kludge to keep keymaps mostly working as raw objects
+ // (backwards compatibility) while at the same time support features
+ // like normalization and multi-stroke key bindings. It compiles a
+ // new normalized keymap, and then updates the old object to reflect
+ // this.
+ CodeMirror.normalizeKeyMap = function(keymap) {
+ var copy = {};
+ for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) {
+ var value = keymap[keyname];
+ if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue;
+ if (value == "...") { delete keymap[keyname]; continue; }
+
+ var keys = map(keyname.split(" "), normalizeKeyName);
+ for (var i = 0; i < keys.length; i++) {
+ var val, name;
+ if (i == keys.length - 1) {
+ name = keys.join(" ");
+ val = value;
+ } else {
+ name = keys.slice(0, i + 1).join(" ");
+ val = "...";
+ }
+ var prev = copy[name];
+ if (!prev) copy[name] = val;
+ else if (prev != val) throw new Error("Inconsistent bindings for " + name);
}
- return false;
+ delete keymap[keyname];
}
+ for (var prop in copy) keymap[prop] = copy[prop];
+ return keymap;
+ };
- for (var i = 0; i < maps.length; ++i) {
- var done = lookup(maps[i]);
- if (done) return done != "stop";
+ var lookupKey = CodeMirror.lookupKey = function(key, map, handle, context) {
+ map = getKeyMap(map);
+ var found = map.call ? map.call(key, context) : map[key];
+ if (found === false) return "nothing";
+ if (found === "...") return "multi";
+ if (found != null && handle(found)) return "handled";
+
+ if (map.fallthrough) {
+ if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
+ return lookupKey(key, map.fallthrough, handle, context);
+ for (var i = 0; i < map.fallthrough.length; i++) {
+ var result = lookupKey(key, map.fallthrough[i], handle, context);
+ if (result) return result;
+ }
}
- }
- function isModifierKey(event) {
- var name = keyNames[event.keyCode];
+ };
+
+ // Modifier key presses don't count as 'real' key presses for the
+ // purpose of keymap fallthrough.
+ var isModifierKey = CodeMirror.isModifierKey = function(value) {
+ var name = typeof value == "string" ? value : keyNames[value.keyCode];
return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
- }
- function keyName(event, noShift) {
- if (opera && event.keyCode == 34 && event["char"]) return false;
- var name = keyNames[event.keyCode];
+ };
+
+ // Look up the name of a key as indicated by an event object.
+ var keyName = CodeMirror.keyName = function(event, noShift) {
+ if (presto && event.keyCode == 34 && event["char"]) return false;
+ var base = keyNames[event.keyCode], name = base;
if (name == null || event.altGraphKey) return false;
- if (event.altKey) name = "Alt-" + name;
- if (flipCtrlCmd ? event.metaKey : event.ctrlKey) name = "Ctrl-" + name;
- if (flipCtrlCmd ? event.ctrlKey : event.metaKey) name = "Cmd-" + name;
- if (!noShift && event.shiftKey) name = "Shift-" + name;
+ if (event.altKey && base != "Alt") name = "Alt-" + name;
+ if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name;
+ if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name;
+ if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name;
return name;
+ };
+
+ function getKeyMap(val) {
+ return typeof val == "string" ? keyMap[val] : val;
}
- CodeMirror.lookupKey = lookupKey;
- CodeMirror.isModifierKey = isModifierKey;
- CodeMirror.keyName = keyName;
// FROMTEXTAREA
CodeMirror.fromTextArea = function(textarea, options) {
- if (!options) options = {};
+ options = options ? copyObj(options) : {};
options.value = textarea.value;
- if (!options.tabindex && textarea.tabindex)
- options.tabindex = textarea.tabindex;
+ if (!options.tabindex && textarea.tabIndex)
+ options.tabindex = textarea.tabIndex;
if (!options.placeholder && textarea.placeholder)
options.placeholder = textarea.placeholder;
// Set autofocus to true if this textarea is focused, or if it has
// autofocus and no other element is focused.
if (options.autofocus == null) {
- var hasFocus = document.body;
- // doc.activeElement occasionally throws on IE
- try { hasFocus = document.activeElement; } catch(e) {}
+ var hasFocus = activeElt();
options.autofocus = hasFocus == textarea ||
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
}
@@ -3765,22 +5902,26 @@ window.CodeMirror = (function() {
}
}
+ options.finishInit = function(cm) {
+ cm.save = save;
+ cm.getTextArea = function() { return textarea; };
+ cm.toTextArea = function() {
+ cm.toTextArea = isNaN; // Prevent this from being ran twice
+ save();
+ textarea.parentNode.removeChild(cm.getWrapperElement());
+ textarea.style.display = "";
+ if (textarea.form) {
+ off(textarea.form, "submit", save);
+ if (typeof textarea.form.submit == "function")
+ textarea.form.submit = realSubmit;
+ }
+ };
+ };
+
textarea.style.display = "none";
var cm = CodeMirror(function(node) {
textarea.parentNode.insertBefore(node, textarea.nextSibling);
}, options);
- cm.save = save;
- cm.getTextArea = function() { return textarea; };
- cm.toTextArea = function() {
- save();
- textarea.parentNode.removeChild(cm.getWrapperElement());
- textarea.style.display = "";
- if (textarea.form) {
- off(textarea.form, "submit", save);
- if (typeof textarea.form.submit == "function")
- textarea.form.submit = realSubmit;
- }
- };
return cm;
};
@@ -3789,14 +5930,13 @@ window.CodeMirror = (function() {
// Fed to the mode parsers, provides helper functions to make
// parsers more succinct.
- // The character stream used by a mode's parser.
- function StringStream(string, tabSize) {
+ var StringStream = CodeMirror.StringStream = function(string, tabSize) {
this.pos = this.start = 0;
this.string = string;
this.tabSize = tabSize || 8;
this.lastColumnPos = this.lastColumnValue = 0;
this.lineStart = 0;
- }
+ };
StringStream.prototype = {
eol: function() {return this.pos >= this.string.length;},
@@ -3861,18 +6001,30 @@ window.CodeMirror = (function() {
finally { this.lineStart -= n; }
}
};
- CodeMirror.StringStream = StringStream;
// TEXTMARKERS
- function TextMarker(doc, type) {
+ // Created with markText and setBookmark methods. A TextMarker is a
+ // handle that can be used to clear or find a marked position in the
+ // document. Line objects hold arrays (markedSpans) containing
+ // {from, to, marker} object pointing to such marker objects, and
+ // indicating that such a marker is present on that line. Multiple
+ // lines may point to the same marker when it spans across lines.
+ // The spans will have null for their from/to properties when the
+ // marker continues beyond the start/end of the line. Markers have
+ // links back to the lines they currently touch.
+
+ var nextMarkerId = 0;
+
+ var TextMarker = CodeMirror.TextMarker = function(doc, type) {
this.lines = [];
this.type = type;
this.doc = doc;
- }
- CodeMirror.TextMarker = TextMarker;
+ this.id = ++nextMarkerId;
+ };
eventMixin(TextMarker);
+ // Clear the marker.
TextMarker.prototype.clear = function() {
if (this.explicitlyCleared) return;
var cm = this.doc.cm, withOp = cm && !cm.curOp;
@@ -3885,15 +6037,17 @@ window.CodeMirror = (function() {
for (var i = 0; i < this.lines.length; ++i) {
var line = this.lines[i];
var span = getMarkedSpanFor(line.markedSpans, this);
- if (span.to != null) max = lineNo(line);
+ if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text");
+ else if (cm) {
+ if (span.to != null) max = lineNo(line);
+ if (span.from != null) min = lineNo(line);
+ }
line.markedSpans = removeMarkedSpan(line.markedSpans, span);
- if (span.from != null)
- min = lineNo(line);
- else if (this.collapsed && !lineIsHidden(this.doc, line) && cm)
+ if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm)
updateLineHeight(line, textHeight(cm.display));
}
if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) {
- var visual = visualLine(cm.doc, this.lines[i]), len = lineLength(cm.doc, visual);
+ var visual = visualLine(this.lines[i]), len = lineLength(visual);
if (len > cm.display.maxLineLength) {
cm.display.maxLine = visual;
cm.display.maxLineLength = len;
@@ -3901,48 +6055,62 @@ window.CodeMirror = (function() {
}
}
- if (min != null && cm) regChange(cm, min, max + 1);
+ if (min != null && cm && this.collapsed) regChange(cm, min, max + 1);
this.lines.length = 0;
this.explicitlyCleared = true;
if (this.atomic && this.doc.cantEdit) {
this.doc.cantEdit = false;
- if (cm) reCheckSelection(cm);
+ if (cm) reCheckSelection(cm.doc);
}
if (cm) signalLater(cm, "markerCleared", cm, this);
if (withOp) endOperation(cm);
if (this.parent) this.parent.clear();
};
- TextMarker.prototype.find = function(bothSides) {
+ // Find the position of the marker in the document. Returns a {from,
+ // to} object by default. Side can be passed to get a specific side
+ // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
+ // Pos objects returned contain a line object, rather than a line
+ // number (used to prevent looking up the same line twice).
+ TextMarker.prototype.find = function(side, lineObj) {
+ if (side == null && this.type == "bookmark") side = 1;
var from, to;
for (var i = 0; i < this.lines.length; ++i) {
var line = this.lines[i];
var span = getMarkedSpanFor(line.markedSpans, this);
- if (span.from != null || span.to != null) {
- var found = lineNo(line);
- if (span.from != null) from = Pos(found, span.from);
- if (span.to != null) to = Pos(found, span.to);
+ if (span.from != null) {
+ from = Pos(lineObj ? line : lineNo(line), span.from);
+ if (side == -1) return from;
+ }
+ if (span.to != null) {
+ to = Pos(lineObj ? line : lineNo(line), span.to);
+ if (side == 1) return to;
}
}
- if (this.type == "bookmark" && !bothSides) return from;
return from && {from: from, to: to};
};
+ // Signals that the marker's widget changed, and surrounding layout
+ // should be recomputed.
TextMarker.prototype.changed = function() {
- var pos = this.find(), cm = this.doc.cm;
+ var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
if (!pos || !cm) return;
- if (this.type != "bookmark") pos = pos.from;
- var line = getLine(this.doc, pos.line);
- clearCachedMeasurement(cm, line);
- if (pos.line >= cm.display.showingFrom && pos.line < cm.display.showingTo) {
- for (var node = cm.display.lineDiv.firstChild; node; node = node.nextSibling) if (node.lineObj == line) {
- if (node.offsetHeight != line.height) updateLineHeight(line, node.offsetHeight);
- break;
+ runInOp(cm, function() {
+ var line = pos.line, lineN = lineNo(pos.line);
+ var view = findViewForLine(cm, lineN);
+ if (view) {
+ clearLineMeasurementCacheFor(view);
+ cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
}
- runInOp(cm, function() {
- cm.curOp.selectionChanged = cm.curOp.forceUpdate = cm.curOp.updateMaxLine = true;
- });
- }
+ cm.curOp.updateMaxLine = true;
+ if (!lineIsHidden(widget.doc, line) && widget.height != null) {
+ var oldHeight = widget.height;
+ widget.height = null;
+ var dHeight = widgetHeight(widget) - oldHeight;
+ if (dHeight)
+ updateLineHeight(line, line.height + dHeight);
+ }
+ });
};
TextMarker.prototype.attachLine = function(line) {
@@ -3961,20 +6129,31 @@ window.CodeMirror = (function() {
}
};
+ // Collapsed markers have unique ids, in order to be able to order
+ // them, which is needed for uniquely determining an outer marker
+ // when they overlap (they may nest, but not partially overlap).
var nextMarkerId = 0;
+ // Create a marker, wire it up to the right lines, and
function markText(doc, from, to, options, type) {
+ // Shared markers (across linked documents) are handled separately
+ // (markTextShared will call out to this again, once per
+ // document).
if (options && options.shared) return markTextShared(doc, from, to, options, type);
+ // Ensure we are in an operation.
if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
- var marker = new TextMarker(doc, type);
+ var marker = new TextMarker(doc, type), diff = cmp(from, to);
if (options) copyObj(options, marker, false);
- if (posLess(to, from) || posEq(from, to) && marker.clearWhenEmpty !== false)
+ // Don't connect empty markers unless clearWhenEmpty is false
+ if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
return marker;
if (marker.replacedWith) {
+ // Showing up as a widget implies collapsed (widget replaces text)
marker.collapsed = true;
- marker.replacedWith = elt("span", [marker.replacedWith], "CodeMirror-widget");
- if (!options.handleMouseEvents) marker.replacedWith.ignoreEvents = true;
+ marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget");
+ if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true");
+ if (options.insertLeft) marker.widgetNode.insertLeft = true;
}
if (marker.collapsed) {
if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
@@ -3984,20 +6163,19 @@ window.CodeMirror = (function() {
}
if (marker.addToHistory)
- addToHistory(doc, {from: from, to: to, origin: "markText"},
- {head: doc.sel.head, anchor: doc.sel.anchor}, NaN);
+ addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN);
var curLine = from.line, cm = doc.cm, updateMaxLine;
doc.iter(curLine, to.line + 1, function(line) {
- if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(doc, line) == cm.display.maxLine)
+ if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
updateMaxLine = true;
- var span = {from: null, to: null, marker: marker};
- if (curLine == from.line) span.from = from.ch;
- if (curLine == to.line) span.to = to.ch;
if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
- addMarkedSpan(line, span);
+ addMarkedSpan(line, new MarkedSpan(marker,
+ curLine == from.line ? from.ch : null,
+ curLine == to.line ? to.ch : null));
++curLine;
});
+ // lineIsHidden depends on the presence of the spans, so needs a second pass
if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {
if (lineIsHidden(doc, line)) updateLineHeight(line, 0);
});
@@ -4014,10 +6192,13 @@ window.CodeMirror = (function() {
marker.atomic = true;
}
if (cm) {
+ // Sync editor state
if (updateMaxLine) cm.curOp.updateMaxLine = true;
- if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.collapsed)
+ if (marker.collapsed)
regChange(cm, from.line, to.line + 1);
- if (marker.atomic) reCheckSelection(cm);
+ else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
+ for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text");
+ if (marker.atomic) reCheckSelection(cm.doc);
signalLater(cm, "markerAdded", cm, marker);
}
return marker;
@@ -4025,13 +6206,15 @@ window.CodeMirror = (function() {
// SHARED TEXTMARKERS
- function SharedTextMarker(markers, primary) {
+ // A shared marker spans multiple linked documents. It is
+ // implemented as a meta-marker-object controlling multiple normal
+ // markers.
+ var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) {
this.markers = markers;
this.primary = primary;
for (var i = 0; i < markers.length; ++i)
markers[i].parent = this;
- }
- CodeMirror.SharedTextMarker = SharedTextMarker;
+ };
eventMixin(SharedTextMarker);
SharedTextMarker.prototype.clear = function() {
@@ -4041,17 +6224,17 @@ window.CodeMirror = (function() {
this.markers[i].clear();
signalLater(this, "clear");
};
- SharedTextMarker.prototype.find = function() {
- return this.primary.find();
+ SharedTextMarker.prototype.find = function(side, lineObj) {
+ return this.primary.find(side, lineObj);
};
function markTextShared(doc, from, to, options, type) {
options = copyObj(options);
options.shared = false;
var markers = [markText(doc, from, to, options, type)], primary = markers[0];
- var widget = options.replacedWith;
+ var widget = options.widgetNode;
linkedDocs(doc, function(doc) {
- if (widget) options.replacedWith = widget.cloneNode(true);
+ if (widget) options.widgetNode = widget.cloneNode(true);
markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
for (var i = 0; i < doc.linked.length; ++i)
if (doc.linked[i].isParent) return;
@@ -4093,56 +6276,72 @@ window.CodeMirror = (function() {
// TEXTMARKER SPANS
+ function MarkedSpan(marker, from, to) {
+ this.marker = marker;
+ this.from = from; this.to = to;
+ }
+
+ // Search an array of spans for a span matching the given marker.
function getMarkedSpanFor(spans, marker) {
if (spans) for (var i = 0; i < spans.length; ++i) {
var span = spans[i];
if (span.marker == marker) return span;
}
}
+ // Remove a span from an array, returning undefined if no spans are
+ // left (we don't store arrays for lines without spans).
function removeMarkedSpan(spans, span) {
for (var r, i = 0; i < spans.length; ++i)
if (spans[i] != span) (r || (r = [])).push(spans[i]);
return r;
}
+ // Add a span to a line.
function addMarkedSpan(line, span) {
line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
span.marker.attachLine(line);
}
+ // Used for the algorithm that adjusts markers for a change in the
+ // document. These functions cut an array of spans at a given
+ // character position, returning an array of remaining chunks (or
+ // undefined if nothing remains).
function markedSpansBefore(old, startCh, isInsert) {
if (old) for (var i = 0, nw; i < old.length; ++i) {
var span = old[i], marker = span.marker;
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
- (nw || (nw = [])).push({from: span.from,
- to: endsAfter ? null : span.to,
- marker: marker});
+ (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
}
}
return nw;
}
-
function markedSpansAfter(old, endCh, isInsert) {
if (old) for (var i = 0, nw; i < old.length; ++i) {
var span = old[i], marker = span.marker;
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
- (nw || (nw = [])).push({from: startsBefore ? null : span.from - endCh,
- to: span.to == null ? null : span.to - endCh,
- marker: marker});
+ (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
+ span.to == null ? null : span.to - endCh));
}
}
return nw;
}
+ // Given a change object, compute the new set of marker spans that
+ // cover the line in which the change took place. Removes spans
+ // entirely within the change, reconnects spans belonging to the
+ // same marker that appear on both sides of the change, and cuts off
+ // spans partially within the change. Returns an array of span
+ // arrays with one element for each line in (after) the change.
function stretchSpansOverChange(doc, change) {
+ if (change.full) return null;
var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
if (!oldFirst && !oldLast) return null;
- var startCh = change.from.ch, endCh = change.to.ch, isInsert = posEq(change.from, change.to);
+ var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
// Get the spans that 'stick out' on both sides
var first = markedSpansBefore(oldFirst, startCh, isInsert);
var last = markedSpansAfter(oldLast, endCh, isInsert);
@@ -4188,7 +6387,7 @@ window.CodeMirror = (function() {
if (gap > 0 && first)
for (var i = 0; i < first.length; ++i)
if (first[i].to == null)
- (gapMarkers || (gapMarkers = [])).push({from: null, to: null, marker: first[i].marker});
+ (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null));
for (var i = 0; i < gap; ++i)
newMarkers.push(gapMarkers);
newMarkers.push(last);
@@ -4196,6 +6395,8 @@ window.CodeMirror = (function() {
return newMarkers;
}
+ // Remove spans that are empty and don't have a clearWhenEmpty
+ // option of false.
function clearEmptySpans(spans) {
for (var i = 0; i < spans.length; ++i) {
var span = spans[i];
@@ -4206,6 +6407,10 @@ window.CodeMirror = (function() {
return spans;
}
+ // Used for un/re-doing changes from the history. Combines the
+ // result of computing the existing spans with the set of spans that
+ // existed in the history (so that deleting around a span and then
+ // undoing brings back the span).
function mergeOldSpans(doc, change) {
var old = getOldSpans(doc, change);
var stretched = stretchSpansOverChange(doc, change);
@@ -4228,6 +6433,7 @@ window.CodeMirror = (function() {
return old;
}
+ // Used to 'clip' out readOnly ranges when making a change.
function removeReadOnlyRanges(doc, from, to) {
var markers = null;
doc.iter(from.line, to.line + 1, function(line) {
@@ -4240,14 +6446,14 @@ window.CodeMirror = (function() {
if (!markers) return null;
var parts = [{from: from, to: to}];
for (var i = 0; i < markers.length; ++i) {
- var mk = markers[i], m = mk.find();
+ var mk = markers[i], m = mk.find(0);
for (var j = 0; j < parts.length; ++j) {
var p = parts[j];
- if (posLess(p.to, m.from) || posLess(m.to, p.from)) continue;
- var newParts = [j, 1];
- if (posLess(p.from, m.from) || !mk.inclusiveLeft && posEq(p.from, m.from))
+ if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
+ var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
+ if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
newParts.push({from: p.from, to: m.from});
- if (posLess(m.to, p.to) || !mk.inclusiveRight && posEq(p.to, m.to))
+ if (dto > 0 || !mk.inclusiveRight && !dto)
newParts.push({from: m.to, to: p.to});
parts.splice.apply(parts, newParts);
j += newParts.length - 1;
@@ -4256,9 +6462,29 @@ window.CodeMirror = (function() {
return parts;
}
+ // Connect or disconnect spans from a line.
+ function detachMarkedSpans(line) {
+ var spans = line.markedSpans;
+ if (!spans) return;
+ for (var i = 0; i < spans.length; ++i)
+ spans[i].marker.detachLine(line);
+ line.markedSpans = null;
+ }
+ function attachMarkedSpans(line, spans) {
+ if (!spans) return;
+ for (var i = 0; i < spans.length; ++i)
+ spans[i].marker.attachLine(line);
+ line.markedSpans = spans;
+ }
+
+ // Helpers used when computing which overlapping collapsed span
+ // counts as the larger one.
function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
+ // Returns a number indicating which of two overlapping collapsed
+ // spans is larger (and thus includes the other). Falls back to
+ // comparing ids when the spans cover exactly the same range.
function compareCollapsedMarkers(a, b) {
var lenDiff = a.lines.length - b.lines.length;
if (lenDiff != 0) return lenDiff;
@@ -4270,6 +6496,8 @@ window.CodeMirror = (function() {
return b.id - a.id;
}
+ // Find out whether a line ends or starts in a collapsed span. If
+ // so, return the marker for that span.
function collapsedSpanAtSide(line, start) {
var sps = sawCollapsedSpans && line.markedSpans, found;
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
@@ -4283,130 +6511,164 @@ window.CodeMirror = (function() {
function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); }
function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); }
+ // Test whether there exists a collapsed span that partially
+ // overlaps (covers the start or end, but not both) of a new span.
+ // Such overlap is not allowed.
function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
var line = getLine(doc, lineNo);
var sps = sawCollapsedSpans && line.markedSpans;
if (sps) for (var i = 0; i < sps.length; ++i) {
var sp = sps[i];
if (!sp.marker.collapsed) continue;
- var found = sp.marker.find(true);
+ var found = sp.marker.find(0);
var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
- if (fromCmp <= 0 && (cmp(found.to, from) || extraRight(sp.marker) - extraLeft(marker)) > 0 ||
- fromCmp >= 0 && (cmp(found.from, to) || extraLeft(sp.marker) - extraRight(marker)) < 0)
+ if (fromCmp <= 0 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) ||
+ fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight)))
return true;
}
}
- function visualLine(doc, line) {
+ // A visual line is a line as drawn on the screen. Folding, for
+ // example, can cause multiple logical lines to appear on the same
+ // visual line. This finds the start of the visual line that the
+ // given line is part of (usually that is the line itself).
+ function visualLine(line) {
var merged;
while (merged = collapsedSpanAtStart(line))
- line = getLine(doc, merged.find().from.line);
+ line = merged.find(-1, true).line;
return line;
}
+ // Returns an array of logical lines that continue the visual line
+ // started by the argument, or undefined if there are no such lines.
+ function visualLineContinued(line) {
+ var merged, lines;
+ while (merged = collapsedSpanAtEnd(line)) {
+ line = merged.find(1, true).line;
+ (lines || (lines = [])).push(line);
+ }
+ return lines;
+ }
+
+ // Get the line number of the start of the visual line that the
+ // given line number is part of.
+ function visualLineNo(doc, lineN) {
+ var line = getLine(doc, lineN), vis = visualLine(line);
+ if (line == vis) return lineN;
+ return lineNo(vis);
+ }
+ // Get the line number of the start of the next visual line after
+ // the given line.
+ function visualLineEndNo(doc, lineN) {
+ if (lineN > doc.lastLine()) return lineN;
+ var line = getLine(doc, lineN), merged;
+ if (!lineIsHidden(doc, line)) return lineN;
+ while (merged = collapsedSpanAtEnd(line))
+ line = merged.find(1, true).line;
+ return lineNo(line) + 1;
+ }
+
+ // Compute whether a line is hidden. Lines count as hidden when they
+ // are part of a visual line that starts with another line, or when
+ // they are entirely covered by collapsed, non-widget span.
function lineIsHidden(doc, line) {
var sps = sawCollapsedSpans && line.markedSpans;
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
sp = sps[i];
if (!sp.marker.collapsed) continue;
if (sp.from == null) return true;
- if (sp.marker.replacedWith) continue;
+ if (sp.marker.widgetNode) continue;
if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
return true;
}
}
function lineIsHiddenInner(doc, line, span) {
if (span.to == null) {
- var end = span.marker.find().to, endLine = getLine(doc, end.line);
- return lineIsHiddenInner(doc, endLine, getMarkedSpanFor(endLine.markedSpans, span.marker));
- }
- if (span.marker.inclusiveRight && span.to == line.text.length)
- return true;
- for (var sp, i = 0; i < line.markedSpans.length; ++i) {
- sp = line.markedSpans[i];
- if (sp.marker.collapsed && !sp.marker.replacedWith && sp.from == span.to &&
- (sp.to == null || sp.to != span.from) &&
- (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
- lineIsHiddenInner(doc, line, sp)) return true;
+ var end = span.marker.find(1, true);
+ return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
+ }
+ if (span.marker.inclusiveRight && span.to == line.text.length)
+ return true;
+ for (var sp, i = 0; i < line.markedSpans.length; ++i) {
+ sp = line.markedSpans[i];
+ if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
+ (sp.to == null || sp.to != span.from) &&
+ (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
+ lineIsHiddenInner(doc, line, sp)) return true;
}
- }
-
- function detachMarkedSpans(line) {
- var spans = line.markedSpans;
- if (!spans) return;
- for (var i = 0; i < spans.length; ++i)
- spans[i].marker.detachLine(line);
- line.markedSpans = null;
- }
-
- function attachMarkedSpans(line, spans) {
- if (!spans) return;
- for (var i = 0; i < spans.length; ++i)
- spans[i].marker.attachLine(line);
- line.markedSpans = spans;
}
// LINE WIDGETS
- var LineWidget = CodeMirror.LineWidget = function(cm, node, options) {
+ // Line widgets are block elements displayed above or below a line.
+
+ var LineWidget = CodeMirror.LineWidget = function(doc, node, options) {
if (options) for (var opt in options) if (options.hasOwnProperty(opt))
this[opt] = options[opt];
- this.cm = cm;
+ this.doc = doc;
this.node = node;
};
eventMixin(LineWidget);
- function widgetOperation(f) {
- return function() {
- var withOp = !this.cm.curOp;
- if (withOp) startOperation(this.cm);
- try {var result = f.apply(this, arguments);}
- finally {if (withOp) endOperation(this.cm);}
- return result;
- };
+
+ function adjustScrollWhenAboveVisible(cm, line, diff) {
+ if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
+ addToScrollPos(cm, null, diff);
}
- LineWidget.prototype.clear = widgetOperation(function() {
- var ws = this.line.widgets, no = lineNo(this.line);
+
+ LineWidget.prototype.clear = function() {
+ var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
if (no == null || !ws) return;
for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);
- if (!ws.length) this.line.widgets = null;
- var aboveVisible = heightAtLine(this.cm, this.line) < this.cm.doc.scrollTop;
- updateLineHeight(this.line, Math.max(0, this.line.height - widgetHeight(this)));
- this.cm.curOp.forceUpdate = true;
- if (aboveVisible) addToScrollPos(this.cm, 0, -this.height);
- regChange(this.cm, no, no + 1);
- });
- LineWidget.prototype.changed = widgetOperation(function() {
- var oldH = this.height;
+ if (!ws.length) line.widgets = null;
+ var height = widgetHeight(this);
+ updateLineHeight(line, Math.max(0, line.height - height));
+ if (cm) runInOp(cm, function() {
+ adjustScrollWhenAboveVisible(cm, line, -height);
+ regLineChange(cm, no, "widget");
+ });
+ };
+ LineWidget.prototype.changed = function() {
+ var oldH = this.height, cm = this.doc.cm, line = this.line;
this.height = null;
var diff = widgetHeight(this) - oldH;
if (!diff) return;
- updateLineHeight(this.line, this.line.height + diff);
- this.cm.curOp.forceUpdate = true;
- var no = lineNo(this.line);
- regChange(this.cm, no, no + 1);
- });
+ updateLineHeight(line, line.height + diff);
+ if (cm) runInOp(cm, function() {
+ cm.curOp.forceUpdate = true;
+ adjustScrollWhenAboveVisible(cm, line, diff);
+ });
+ };
function widgetHeight(widget) {
if (widget.height != null) return widget.height;
- if (!widget.node.parentNode || widget.node.parentNode.nodeType != 1)
- removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, "position: relative"));
+ var cm = widget.doc.cm;
+ if (!cm) return 0;
+ if (!contains(document.body, widget.node)) {
+ var parentStyle = "position: relative;";
+ if (widget.coverGutter)
+ parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;";
+ if (widget.noHScroll)
+ parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
+ removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
+ }
return widget.height = widget.node.offsetHeight;
}
- function addLineWidget(cm, handle, node, options) {
- var widget = new LineWidget(cm, node, options);
- if (widget.noHScroll) cm.display.alignWidgets = true;
- changeLine(cm, handle, function(line) {
+ function addLineWidget(doc, handle, node, options) {
+ var widget = new LineWidget(doc, node, options);
+ var cm = doc.cm;
+ if (cm && widget.noHScroll) cm.display.alignWidgets = true;
+ changeLine(doc, handle, "widget", function(line) {
var widgets = line.widgets || (line.widgets = []);
if (widget.insertAt == null) widgets.push(widget);
else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
widget.line = line;
- if (!lineIsHidden(cm.doc, line) || widget.showIfHidden) {
- var aboveVisible = heightAtLine(cm, line) < cm.doc.scrollTop;
+ if (cm && !lineIsHidden(doc, line)) {
+ var aboveVisible = heightAtLine(line) < doc.scrollTop;
updateLineHeight(line, line.height + widgetHeight(widget));
- if (aboveVisible) addToScrollPos(cm, 0, widget.height);
+ if (aboveVisible) addToScrollPos(cm, null, widget.height);
cm.curOp.forceUpdate = true;
}
return true;
@@ -4426,6 +6688,9 @@ window.CodeMirror = (function() {
eventMixin(Line);
Line.prototype.lineNo = function() { return lineNo(this); };
+ // Change the content (text, markers) of a line. Automatically
+ // invalidates cached information and tries to re-estimate the
+ // line's height.
function updateLine(line, text, markedSpans, estimateHeight) {
line.text = text;
if (line.stateAfter) line.stateAfter = null;
@@ -4437,20 +6702,72 @@ window.CodeMirror = (function() {
if (estHeight != line.height) updateLineHeight(line, estHeight);
}
+ // Detach a line from the document tree and its markers.
function cleanUpLine(line) {
line.parent = null;
detachMarkedSpans(line);
}
- // Run the given mode's parser over a line, update the styles
- // array, which contains alternating fragments of text and CSS
- // classes.
- function runMode(cm, text, mode, state, f, forceToEnd) {
+ function extractLineClasses(type, output) {
+ if (type) for (;;) {
+ var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
+ if (!lineClass) break;
+ type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
+ var prop = lineClass[1] ? "bgClass" : "textClass";
+ if (output[prop] == null)
+ output[prop] = lineClass[2];
+ else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
+ output[prop] += " " + lineClass[2];
+ }
+ return type;
+ }
+
+ function callBlankLine(mode, state) {
+ if (mode.blankLine) return mode.blankLine(state);
+ if (!mode.innerMode) return;
+ var inner = CodeMirror.innerMode(mode, state);
+ if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
+ }
+
+ function readToken(mode, stream, state, inner) {
+ for (var i = 0; i < 10; i++) {
+ if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode;
+ var style = mode.token(stream, state);
+ if (stream.pos > stream.start) return style;
+ }
+ throw new Error("Mode " + mode.name + " failed to advance stream.");
+ }
+
+ // Utility for getTokenAt and getLineTokens
+ function takeToken(cm, pos, precise, asArray) {
+ function getObj(copy) {
+ return {start: stream.start, end: stream.pos,
+ string: stream.current(),
+ type: style || null,
+ state: copy ? copyState(doc.mode, state) : state};
+ }
+
+ var doc = cm.doc, mode = doc.mode, style;
+ pos = clipPos(doc, pos);
+ var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise);
+ var stream = new StringStream(line.text, cm.options.tabSize), tokens;
+ if (asArray) tokens = [];
+ while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
+ stream.start = stream.pos;
+ style = readToken(mode, stream, state);
+ if (asArray) tokens.push(getObj(true));
+ }
+ return asArray ? tokens : getObj();
+ }
+
+ // Run the given mode's parser over a line, calling f for each token.
+ function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
var flattenSpans = mode.flattenSpans;
if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
var curStart = 0, curStyle = null;
var stream = new StringStream(text, cm.options.tabSize), style;
- if (text == "" && mode.blankLine) mode.blankLine(state);
+ var inner = cm.options.addModeClass && [null];
+ if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
while (!stream.eol()) {
if (stream.pos > cm.options.maxHighlightLength) {
flattenSpans = false;
@@ -4458,15 +6775,18 @@ window.CodeMirror = (function() {
stream.pos = text.length;
style = null;
} else {
- style = mode.token(stream, state);
+ style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses);
}
- if (cm.options.addModeClass) {
- var mName = CodeMirror.innerMode(mode, state).mode.name;
+ if (inner) {
+ var mName = inner[0].name;
if (mName) style = "m-" + (style ? mName + " " + style : mName);
}
if (!flattenSpans || curStyle != style) {
- if (curStart < stream.start) f(stream.start, curStyle);
- curStart = stream.start; curStyle = style;
+ while (curStart < stream.start) {
+ curStart = Math.min(stream.start, curStart + 50000);
+ f(curStart, curStyle);
+ }
+ curStyle = style;
}
stream.start = stream.pos;
}
@@ -4478,14 +6798,18 @@ window.CodeMirror = (function() {
}
}
+ // Compute a style array (an array starting with a mode generation
+ // -- for invalidation -- followed by pairs of end positions and
+ // style strings), which is used to highlight the tokens on the
+ // line.
function highlightLine(cm, line, state, forceToEnd) {
// A styles array always starts with a number identifying the
// mode/overlays that it is based on (for easy invalidation).
- var st = [cm.state.modeGen];
+ var st = [cm.state.modeGen], lineClasses = {};
// Compute the base array of styles
runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
st.push(end, style);
- }, forceToEnd);
+ }, lineClasses, forceToEnd);
// Run overlays, adjust style array.
for (var o = 0; o < cm.state.overlays.length; ++o) {
@@ -4502,121 +6826,136 @@ window.CodeMirror = (function() {
}
if (!style) return;
if (overlay.opaque) {
- st.splice(start, i - start, end, style);
+ st.splice(start, i - start, end, "cm-overlay " + style);
i = start + 2;
} else {
for (; start < i; start += 2) {
var cur = st[start+1];
- st[start+1] = cur ? cur + " " + style : style;
+ st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
}
}
- });
+ }, lineClasses);
}
- return st;
+ return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
}
- function getLineStyles(cm, line) {
- if (!line.styles || line.styles[0] != cm.state.modeGen)
- line.styles = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
+ function getLineStyles(cm, line, updateFrontier) {
+ if (!line.styles || line.styles[0] != cm.state.modeGen) {
+ var state = getStateBefore(cm, lineNo(line));
+ var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state);
+ line.stateAfter = state;
+ line.styles = result.styles;
+ if (result.classes) line.styleClasses = result.classes;
+ else if (line.styleClasses) line.styleClasses = null;
+ if (updateFrontier === cm.doc.frontier) cm.doc.frontier++;
+ }
return line.styles;
}
// Lightweight form of highlight -- proceed over this line and
- // update state, but don't save a style array.
+ // update state, but don't save a style array. Used for lines that
+ // aren't currently visible.
function processLine(cm, text, state, startAt) {
var mode = cm.doc.mode;
var stream = new StringStream(text, cm.options.tabSize);
stream.start = stream.pos = startAt || 0;
- if (text == "" && mode.blankLine) mode.blankLine(state);
- while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
- mode.token(stream, state);
+ if (text == "") callBlankLine(mode, state);
+ while (!stream.eol()) {
+ readToken(mode, stream, state);
stream.start = stream.pos;
}
}
+ // Convert a style as returned by a mode (either null, or a string
+ // containing one or more styles) to a CSS style. This is cached,
+ // and also looks for line-wide styles.
var styleToClassCache = {}, styleToClassCacheWithMode = {};
- function interpretTokenStyle(style, builder) {
- if (!style) return null;
- for (;;) {
- var lineClass = style.match(/(?:^|\s+)line-(background-)?(\S+)/);
- if (!lineClass) break;
- style = style.slice(0, lineClass.index) + style.slice(lineClass.index + lineClass[0].length);
- var prop = lineClass[1] ? "bgClass" : "textClass";
- if (builder[prop] == null)
- builder[prop] = lineClass[2];
- else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(builder[prop]))
- builder[prop] += " " + lineClass[2];
- }
- if (/^\s*$/.test(style)) return null;
- var cache = builder.cm.options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
+ function interpretTokenStyle(style, options) {
+ if (!style || /^\s*$/.test(style)) return null;
+ var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
return cache[style] ||
(cache[style] = style.replace(/\S+/g, "cm-$&"));
}
- function buildLineContent(cm, realLine, measure, copyWidgets) {
- var merged, line = realLine, empty = true;
- while (merged = collapsedSpanAtStart(line))
- line = getLine(cm.doc, merged.find().from.line);
+ // Render the DOM representation of the text of a line. Also builds
+ // up a 'line map', which points at the DOM nodes that represent
+ // specific stretches of text, and is used by the measuring code.
+ // The returned object contains the DOM node, this map, and
+ // information about line-wide styles that were set by the mode.
+ function buildLineContent(cm, lineView) {
+ // The padding-right forces the element to have a 'border', which
+ // is needed on Webkit to be able to get line-level bounding
+ // rectangles for it (in measureChar).
+ var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
+ var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
+ col: 0, pos: 0, cm: cm,
+ splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
+ lineView.measure = {};
+
+ // Iterate over the logical lines that make up this visual line.
+ for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
+ var line = i ? lineView.rest[i - 1] : lineView.line, order;
+ builder.pos = 0;
+ builder.addToken = buildToken;
+ // Optionally wire in some hacks into the token-rendering
+ // algorithm, to deal with browser quirks.
+ if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
+ builder.addToken = buildTokenBadBidi(builder.addToken, order);
+ builder.map = [];
+ var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
+ insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
+ if (line.styleClasses) {
+ if (line.styleClasses.bgClass)
+ builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
+ if (line.styleClasses.textClass)
+ builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
+ }
- var builder = {pre: elt("pre"), col: 0, pos: 0,
- measure: null, measuredSomething: false, cm: cm,
- copyWidgets: copyWidgets};
+ // Ensure at least a single node is present, for measuring.
+ if (builder.map.length == 0)
+ builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
+
+ // Store the map and a cache object for the current logical line
+ if (i == 0) {
+ lineView.measure.map = builder.map;
+ lineView.measure.cache = {};
+ } else {
+ (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
+ (lineView.measure.caches || (lineView.measure.caches = [])).push({});
+ }
+ }
+
+ // See issue #2901
+ if (webkit && /\bcm-tab\b/.test(builder.content.lastChild.className))
+ builder.content.className = "cm-tab-wrap-hack";
+
+ signal(cm, "renderLine", cm, lineView.line, builder.pre);
+ if (builder.pre.className)
+ builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
- do {
- if (line.text) empty = false;
- builder.measure = line == realLine && measure;
- builder.pos = 0;
- builder.addToken = builder.measure ? buildTokenMeasure : buildToken;
- if ((ie || webkit) && cm.getOption("lineWrapping"))
- builder.addToken = buildTokenSplitSpaces(builder.addToken);
- var next = insertLineContent(line, builder, getLineStyles(cm, line));
- if (measure && line == realLine && !builder.measuredSomething) {
- measure[0] = builder.pre.appendChild(zeroWidthElement(cm.display.measure));
- builder.measuredSomething = true;
- }
- if (next) line = getLine(cm.doc, next.to.line);
- } while (next);
-
- if (measure && !builder.measuredSomething && !measure[0])
- measure[0] = builder.pre.appendChild(empty ? elt("span", "\u00a0") : zeroWidthElement(cm.display.measure));
- if (!builder.pre.firstChild && !lineIsHidden(cm.doc, realLine))
- builder.pre.appendChild(document.createTextNode("\u00a0"));
-
- var order;
- // Work around problem with the reported dimensions of single-char
- // direction spans on IE (issue #1129). See also the comment in
- // cursorCoords.
- if (measure && ie && (order = getOrder(line))) {
- var l = order.length - 1;
- if (order[l].from == order[l].to) --l;
- var last = order[l], prev = order[l - 1];
- if (last.from + 1 == last.to && prev && last.level < prev.level) {
- var span = measure[builder.pos - 1];
- if (span) span.parentNode.insertBefore(span.measureRight = zeroWidthElement(cm.display.measure),
- span.nextSibling);
- }
- }
-
- var textClass = builder.textClass ? builder.textClass + " " + (realLine.textClass || "") : realLine.textClass;
- if (textClass) builder.pre.className = textClass;
-
- signal(cm, "renderLine", cm, realLine, builder.pre);
return builder;
}
function defaultSpecialCharPlaceholder(ch) {
var token = elt("span", "\u2022", "cm-invalidchar");
token.title = "\\u" + ch.charCodeAt(0).toString(16);
+ token.setAttribute("aria-label", token.title);
return token;
}
- function buildToken(builder, text, style, startStyle, endStyle, title) {
+ // Build up the DOM representation for a single token, and add it to
+ // the line map. Takes care to render special characters separately.
+ function buildToken(builder, text, style, startStyle, endStyle, title, css) {
if (!text) return;
- var special = builder.cm.options.specialChars;
+ var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text;
+ var special = builder.cm.state.specialChars, mustWrap = false;
if (!special.test(text)) {
builder.col += text.length;
- var content = document.createTextNode(text);
+ var content = document.createTextNode(displayText);
+ builder.map.push(builder.pos, builder.pos + text.length, content);
+ if (ie && ie_version < 9) mustWrap = true;
+ builder.pos += text.length;
} else {
var content = document.createDocumentFragment(), pos = 0;
while (true) {
@@ -4624,89 +6963,86 @@ window.CodeMirror = (function() {
var m = special.exec(text);
var skipped = m ? m.index - pos : text.length - pos;
if (skipped) {
- content.appendChild(document.createTextNode(text.slice(pos, pos + skipped)));
+ var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
+ if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
+ else content.appendChild(txt);
+ builder.map.push(builder.pos, builder.pos + skipped, txt);
builder.col += skipped;
+ builder.pos += skipped;
}
if (!m) break;
pos += skipped + 1;
if (m[0] == "\t") {
var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
- content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
+ var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
+ txt.setAttribute("role", "presentation");
+ txt.setAttribute("cm-text", "\t");
builder.col += tabWidth;
+ } else if (m[0] == "\r" || m[0] == "\n") {
+ var txt = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
+ txt.setAttribute("cm-text", m[0]);
+ builder.col += 1;
} else {
- var token = builder.cm.options.specialCharPlaceholder(m[0]);
- content.appendChild(token);
+ var txt = builder.cm.options.specialCharPlaceholder(m[0]);
+ txt.setAttribute("cm-text", m[0]);
+ if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
+ else content.appendChild(txt);
builder.col += 1;
}
+ builder.map.push(builder.pos, builder.pos + 1, txt);
+ builder.pos++;
}
}
- if (style || startStyle || endStyle || builder.measure) {
+ if (style || startStyle || endStyle || mustWrap || css) {
var fullStyle = style || "";
if (startStyle) fullStyle += startStyle;
if (endStyle) fullStyle += endStyle;
- var token = elt("span", [content], fullStyle);
+ var token = elt("span", [content], fullStyle, css);
if (title) token.title = title;
- return builder.pre.appendChild(token);
- }
- builder.pre.appendChild(content);
- }
-
- function buildTokenMeasure(builder, text, style, startStyle, endStyle) {
- var wrapping = builder.cm.options.lineWrapping;
- for (var i = 0; i < text.length; ++i) {
- var start = i == 0, to = i + 1;
- while (to < text.length && isExtendingChar(text.charAt(to))) ++to;
- var ch = text.slice(i, to);
- i = to - 1;
- if (i && wrapping && spanAffectsWrapping(text, i))
- builder.pre.appendChild(elt("wbr"));
- var old = builder.measure[builder.pos];
- var span = builder.measure[builder.pos] =
- buildToken(builder, ch, style,
- start && startStyle, i == text.length - 1 && endStyle);
- if (old) span.leftSide = old.leftSide || old;
- // In IE single-space nodes wrap differently than spaces
- // embedded in larger text nodes, except when set to
- // white-space: normal (issue #1268).
- if (old_ie && wrapping && ch == " " && i && !/\s/.test(text.charAt(i - 1)) &&
- i < text.length - 1 && !/\s/.test(text.charAt(i + 1)))
- span.style.whiteSpace = "normal";
- builder.pos += ch.length;
- }
- if (text.length) builder.measuredSomething = true;
- }
-
- function buildTokenSplitSpaces(inner) {
- function split(old) {
- var out = " ";
- for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
- out += " ";
- return out;
- }
- return function(builder, text, style, startStyle, endStyle, title) {
- return inner(builder, text.replace(/ {3,}/g, split), style, startStyle, endStyle, title);
+ return builder.content.appendChild(token);
+ }
+ builder.content.appendChild(content);
+ }
+
+ function splitSpaces(old) {
+ var out = " ";
+ for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
+ out += " ";
+ return out;
+ }
+
+ // Work around nonsense dimensions being reported for stretches of
+ // right-to-left text.
+ function buildTokenBadBidi(inner, order) {
+ return function(builder, text, style, startStyle, endStyle, title, css) {
+ style = style ? style + " cm-force-border" : "cm-force-border";
+ var start = builder.pos, end = start + text.length;
+ for (;;) {
+ // Find the part that overlaps with the start of this text
+ for (var i = 0; i < order.length; i++) {
+ var part = order[i];
+ if (part.to > start && part.from <= start) break;
+ }
+ if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css);
+ inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css);
+ startStyle = null;
+ text = text.slice(part.to - start);
+ start = part.to;
+ }
};
}
function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
- var widget = !ignoreWidget && marker.replacedWith;
+ var widget = !ignoreWidget && marker.widgetNode;
+ if (widget) builder.map.push(builder.pos, builder.pos + size, widget);
+ if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
+ if (!widget)
+ widget = builder.content.appendChild(document.createElement("span"));
+ widget.setAttribute("cm-marker", marker.id);
+ }
if (widget) {
- if (builder.copyWidgets) widget = widget.cloneNode(true);
- builder.pre.appendChild(widget);
- if (builder.measure) {
- if (size) {
- builder.measure[builder.pos] = widget;
- } else {
- var elt = zeroWidthElement(builder.cm.display.measure);
- if (marker.type == "bookmark" && !marker.insertLeft)
- builder.measure[builder.pos] = builder.pre.appendChild(elt);
- else if (builder.measure[builder.pos])
- return;
- else
- builder.measure[builder.pos] = builder.pre.insertBefore(elt, widget);
- }
- builder.measuredSomething = true;
- }
+ builder.cm.display.input.setUneditable(widget);
+ builder.content.appendChild(widget);
}
builder.pos += size;
}
@@ -4717,22 +7053,28 @@ window.CodeMirror = (function() {
var spans = line.markedSpans, allText = line.text, at = 0;
if (!spans) {
for (var i = 1; i < styles.length; i+=2)
- builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder));
+ builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));
return;
}
- var len = allText.length, pos = 0, i = 1, text = "", style;
+ var len = allText.length, pos = 0, i = 1, text = "", style, css;
var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
for (;;) {
if (nextChange == pos) { // Update current marker set
- spanStyle = spanEndStyle = spanStartStyle = title = "";
+ spanStyle = spanEndStyle = spanStartStyle = title = css = "";
collapsed = null; nextChange = Infinity;
var foundBookmarks = [];
for (var j = 0; j < spans.length; ++j) {
var sp = spans[j], m = sp.marker;
- if (sp.from <= pos && (sp.to == null || sp.to > pos)) {
- if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; }
+ if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
+ foundBookmarks.push(m);
+ } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
+ if (sp.to != null && sp.to != pos && nextChange > sp.to) {
+ nextChange = sp.to;
+ spanEndStyle = "";
+ }
if (m.className) spanStyle += " " + m.className;
+ if (m.css) css = m.css;
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
if (m.title && !title) title = m.title;
@@ -4741,12 +7083,12 @@ window.CodeMirror = (function() {
} else if (sp.from > pos && nextChange > sp.from) {
nextChange = sp.from;
}
- if (m.type == "bookmark" && sp.from == pos && m.replacedWith) foundBookmarks.push(m);
}
if (collapsed && (collapsed.from || 0) == pos) {
- buildCollapsedSpan(builder, (collapsed.to == null ? len : collapsed.to) - pos,
+ buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
collapsed.marker, collapsed.from == null);
- if (collapsed.to == null) return collapsed.marker.find();
+ if (collapsed.to == null) return;
+ if (collapsed.to == pos) collapsed = false;
}
if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)
buildCollapsedSpan(builder, 0, foundBookmarks[j]);
@@ -4760,38 +7102,53 @@ window.CodeMirror = (function() {
if (!collapsed) {
var tokenText = end > upto ? text.slice(0, upto - pos) : text;
builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
- spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title);
+ spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css);
}
if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
pos = end;
spanStartStyle = "";
}
text = allText.slice(at, at = styles[i++]);
- style = interpretTokenStyle(styles[i++], builder);
+ style = interpretTokenStyle(styles[i++], builder.cm.options);
}
}
}
// DOCUMENT DATA STRUCTURE
- function updateDoc(doc, change, markedSpans, selAfter, estimateHeight) {
+ // By default, updates that start and end at the beginning of a line
+ // are treated specially, in order to make the association of line
+ // widgets and marker elements with the text behave more intuitive.
+ function isWholeLineUpdate(doc, change) {
+ return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
+ (!doc.cm || doc.cm.options.wholeLineUpdateBefore);
+ }
+
+ // Perform a change on the document data structure.
+ function updateDoc(doc, change, markedSpans, estimateHeight) {
function spansFor(n) {return markedSpans ? markedSpans[n] : null;}
function update(line, text, spans) {
updateLine(line, text, spans, estimateHeight);
signalLater(line, "change", line, change);
}
+ function linesFor(start, end) {
+ for (var i = start, result = []; i < end; ++i)
+ result.push(new Line(text[i], spansFor(i), estimateHeight));
+ return result;
+ }
var from = change.from, to = change.to, text = change.text;
var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
- // First adjust the line structure
- if (from.ch == 0 && to.ch == 0 && lastText == "" &&
- (!doc.cm || doc.cm.options.wholeLineUpdateBefore)) {
+ // Adjust the line structure
+ if (change.full) {
+ doc.insert(0, linesFor(0, text.length));
+ doc.remove(text.length, doc.size - text.length);
+ } else if (isWholeLineUpdate(doc, change)) {
// This is a whole-line replace. Treated specially to make
// sure line objects move the way they are supposed to.
- for (var i = 0, e = text.length - 1, added = []; i < e; ++i)
- added.push(new Line(text[i], spansFor(i), estimateHeight));
+ var added = linesFor(0, text.length - 1);
update(lastLine, lastLine.text, lastSpans);
if (nlines) doc.remove(from.line, nlines);
if (added.length) doc.insert(from.line, added);
@@ -4799,8 +7156,7 @@ window.CodeMirror = (function() {
if (text.length == 1) {
update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
} else {
- for (var added = [], i = 1, e = text.length - 1; i < e; ++i)
- added.push(new Line(text[i], spansFor(i), estimateHeight));
+ var added = linesFor(1, text.length - 1);
added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
doc.insert(from.line + 1, added);
@@ -4811,20 +7167,31 @@ window.CodeMirror = (function() {
} else {
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
- for (var i = 1, e = text.length - 1, added = []; i < e; ++i)
- added.push(new Line(text[i], spansFor(i), estimateHeight));
+ var added = linesFor(1, text.length - 1);
if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
doc.insert(from.line + 1, added);
}
signalLater(doc, "change", doc, change);
- setSelection(doc, selAfter.anchor, selAfter.head, null, true);
}
+ // The document is represented as a BTree consisting of leaves, with
+ // chunk of lines in them, and branches, with up to ten leaves or
+ // other branch nodes below them. The top node is always a branch
+ // node, and is the document object itself (meaning it has
+ // additional methods and properties).
+ //
+ // All nodes have parent links. The tree is used both to go from
+ // line numbers to line objects, and to go from objects to numbers.
+ // It also indexes by height, and is used to convert between height
+ // and line object, and to find the total height of the document.
+ //
+ // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
+
function LeafChunk(lines) {
this.lines = lines;
this.parent = null;
- for (var i = 0, e = lines.length, height = 0; i < e; ++i) {
+ for (var i = 0, height = 0; i < lines.length; ++i) {
lines[i].parent = this;
height += lines[i].height;
}
@@ -4833,6 +7200,7 @@ window.CodeMirror = (function() {
LeafChunk.prototype = {
chunkSize: function() { return this.lines.length; },
+ // Remove the n lines at offset 'at'.
removeInner: function(at, n) {
for (var i = at, e = at + n; i < e; ++i) {
var line = this.lines[i];
@@ -4842,14 +7210,18 @@ window.CodeMirror = (function() {
}
this.lines.splice(at, n);
},
+ // Helper used to collapse a small branch into a single leaf.
collapse: function(lines) {
- lines.splice.apply(lines, [lines.length, 0].concat(this.lines));
+ lines.push.apply(lines, this.lines);
},
+ // Insert the given array of lines at offset 'at', count them as
+ // having the given height.
insertInner: function(at, lines, height) {
this.height += height;
this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
- for (var i = 0, e = lines.length; i < e; ++i) lines[i].parent = this;
+ for (var i = 0; i < lines.length; ++i) lines[i].parent = this;
},
+ // Used to iterate over a part of the tree.
iterN: function(at, n, op) {
for (var e = at + n; at < e; ++at)
if (op(this.lines[at])) return true;
@@ -4859,7 +7231,7 @@ window.CodeMirror = (function() {
function BranchChunk(children) {
this.children = children;
var size = 0, height = 0;
- for (var i = 0, e = children.length; i < e; ++i) {
+ for (var i = 0; i < children.length; ++i) {
var ch = children[i];
size += ch.chunkSize(); height += ch.height;
ch.parent = this;
@@ -4884,7 +7256,10 @@ window.CodeMirror = (function() {
at = 0;
} else at -= sz;
}
- if (this.size - n < 25) {
+ // If the result is smaller than 25 lines, ensure that it is a
+ // single leaf node.
+ if (this.size - n < 25 &&
+ (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
var lines = [];
this.collapse(lines);
this.children = [new LeafChunk(lines)];
@@ -4892,12 +7267,12 @@ window.CodeMirror = (function() {
}
},
collapse: function(lines) {
- for (var i = 0, e = this.children.length; i < e; ++i) this.children[i].collapse(lines);
+ for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines);
},
insertInner: function(at, lines, height) {
this.size += lines.length;
this.height += height;
- for (var i = 0, e = this.children.length; i < e; ++i) {
+ for (var i = 0; i < this.children.length; ++i) {
var child = this.children[i], sz = child.chunkSize();
if (at <= sz) {
child.insertInner(at, lines, height);
@@ -4916,6 +7291,7 @@ window.CodeMirror = (function() {
at -= sz;
}
},
+ // When a node has grown, check whether it should be split.
maybeSpill: function() {
if (this.children.length <= 10) return;
var me = this;
@@ -4938,7 +7314,7 @@ window.CodeMirror = (function() {
me.parent.maybeSpill();
},
iterN: function(at, n, op) {
- for (var i = 0, e = this.children.length; i < e; ++i) {
+ for (var i = 0; i < this.children.length; ++i) {
var child = this.children[i], sz = child.chunkSize();
if (at < sz) {
var used = Math.min(n, sz - at);
@@ -4951,51 +7327,61 @@ window.CodeMirror = (function() {
};
var nextDocId = 0;
- var Doc = CodeMirror.Doc = function(text, mode, firstLine) {
- if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);
+ var Doc = CodeMirror.Doc = function(text, mode, firstLine, lineSep) {
+ if (!(this instanceof Doc)) return new Doc(text, mode, firstLine, lineSep);
if (firstLine == null) firstLine = 0;
BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
this.first = firstLine;
this.scrollTop = this.scrollLeft = 0;
this.cantEdit = false;
- this.history = makeHistory();
this.cleanGeneration = 1;
this.frontier = firstLine;
var start = Pos(firstLine, 0);
- this.sel = {from: start, to: start, head: start, anchor: start, shift: false, extend: false, goalColumn: null};
+ this.sel = simpleSelection(start);
+ this.history = new History(null);
this.id = ++nextDocId;
this.modeOption = mode;
+ this.lineSep = lineSep;
- if (typeof text == "string") text = splitLines(text);
- updateDoc(this, {from: start, to: start, text: text}, null, {head: start, anchor: start});
+ if (typeof text == "string") text = this.splitLines(text);
+ updateDoc(this, {from: start, to: start, text: text});
+ setSelection(this, simpleSelection(start), sel_dontScroll);
};
Doc.prototype = createObj(BranchChunk.prototype, {
constructor: Doc,
+ // Iterate over the document. Supports two forms -- with only one
+ // argument, it calls that for each line in the document. With
+ // three, it iterates over the range given by the first two (with
+ // the second being non-inclusive).
iter: function(from, to, op) {
if (op) this.iterN(from - this.first, to - from, op);
else this.iterN(this.first, this.first + this.size, from);
},
+ // Non-public interface for adding and removing lines.
insert: function(at, lines) {
var height = 0;
- for (var i = 0, e = lines.length; i < e; ++i) height += lines[i].height;
+ for (var i = 0; i < lines.length; ++i) height += lines[i].height;
this.insertInner(at - this.first, lines, height);
},
remove: function(at, n) { this.removeInner(at - this.first, n); },
+ // From here, the methods are part of the public interface. Most
+ // are also available from CodeMirror (editor) instances.
+
getValue: function(lineSep) {
var lines = getLines(this, this.first, this.first + this.size);
if (lineSep === false) return lines;
- return lines.join(lineSep || "\n");
+ return lines.join(lineSep || this.lineSeparator());
},
- setValue: function(code) {
+ setValue: docMethodOp(function(code) {
var top = Pos(this.first, 0), last = this.first + this.size - 1;
makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
- text: splitLines(code), origin: "setValue"},
- {head: top, anchor: top}, true);
- },
+ text: this.splitLines(code), origin: "setValue", full: true}, true);
+ setSelection(this, simpleSelection(top));
+ }),
replaceRange: function(code, from, to, origin) {
from = clipPos(this, from);
to = to ? clipPos(this, to) : from;
@@ -5004,25 +7390,17 @@ window.CodeMirror = (function() {
getRange: function(from, to, lineSep) {
var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
if (lineSep === false) return lines;
- return lines.join(lineSep || "\n");
+ return lines.join(lineSep || this.lineSeparator());
},
getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
- setLine: function(line, text) {
- if (isLine(this, line))
- replaceRange(this, text, Pos(line, 0), clipPos(this, Pos(line)));
- },
- removeLine: function(line) {
- if (line) replaceRange(this, "", clipPos(this, Pos(line - 1)), clipPos(this, Pos(line)));
- else replaceRange(this, "", Pos(0, 0), clipPos(this, Pos(1, 0)));
- },
getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);},
getLineNumber: function(line) {return lineNo(line);},
getLineHandleVisualStart: function(line) {
if (typeof line == "number") line = getLine(this, line);
- return visualLine(this, line);
+ return visualLine(line);
},
lineCount: function() {return this.size;},
@@ -5032,49 +7410,103 @@ window.CodeMirror = (function() {
clipPos: function(pos) {return clipPos(this, pos);},
getCursor: function(start) {
- var sel = this.sel, pos;
- if (start == null || start == "head") pos = sel.head;
- else if (start == "anchor") pos = sel.anchor;
- else if (start == "end" || start === false) pos = sel.to;
- else pos = sel.from;
- return copyPos(pos);
+ var range = this.sel.primary(), pos;
+ if (start == null || start == "head") pos = range.head;
+ else if (start == "anchor") pos = range.anchor;
+ else if (start == "end" || start == "to" || start === false) pos = range.to();
+ else pos = range.from();
+ return pos;
},
- somethingSelected: function() {return !posEq(this.sel.head, this.sel.anchor);},
+ listSelections: function() { return this.sel.ranges; },
+ somethingSelected: function() {return this.sel.somethingSelected();},
- setCursor: docOperation(function(line, ch, extend) {
- var pos = clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line);
- if (extend) extendSelection(this, pos);
- else setSelection(this, pos, pos);
+ setCursor: docMethodOp(function(line, ch, options) {
+ setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
+ }),
+ setSelection: docMethodOp(function(anchor, head, options) {
+ setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
}),
- setSelection: docOperation(function(anchor, head, bias) {
- setSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), bias);
+ extendSelection: docMethodOp(function(head, other, options) {
+ extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
}),
- extendSelection: docOperation(function(from, to, bias) {
- extendSelection(this, clipPos(this, from), to && clipPos(this, to), bias);
+ extendSelections: docMethodOp(function(heads, options) {
+ extendSelections(this, clipPosArray(this, heads, options));
+ }),
+ extendSelectionsBy: docMethodOp(function(f, options) {
+ extendSelections(this, map(this.sel.ranges, f), options);
+ }),
+ setSelections: docMethodOp(function(ranges, primary, options) {
+ if (!ranges.length) return;
+ for (var i = 0, out = []; i < ranges.length; i++)
+ out[i] = new Range(clipPos(this, ranges[i].anchor),
+ clipPos(this, ranges[i].head));
+ if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
+ setSelection(this, normalizeSelection(out, primary), options);
+ }),
+ addSelection: docMethodOp(function(anchor, head, options) {
+ var ranges = this.sel.ranges.slice(0);
+ ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
+ setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
}),
- getSelection: function(lineSep) {return this.getRange(this.sel.from, this.sel.to, lineSep);},
+ getSelection: function(lineSep) {
+ var ranges = this.sel.ranges, lines;
+ for (var i = 0; i < ranges.length; i++) {
+ var sel = getBetween(this, ranges[i].from(), ranges[i].to());
+ lines = lines ? lines.concat(sel) : sel;
+ }
+ if (lineSep === false) return lines;
+ else return lines.join(lineSep || this.lineSeparator());
+ },
+ getSelections: function(lineSep) {
+ var parts = [], ranges = this.sel.ranges;
+ for (var i = 0; i < ranges.length; i++) {
+ var sel = getBetween(this, ranges[i].from(), ranges[i].to());
+ if (lineSep !== false) sel = sel.join(lineSep || this.lineSeparator());
+ parts[i] = sel;
+ }
+ return parts;
+ },
replaceSelection: function(code, collapse, origin) {
- makeChange(this, {from: this.sel.from, to: this.sel.to, text: splitLines(code), origin: origin}, collapse || "around");
+ var dup = [];
+ for (var i = 0; i < this.sel.ranges.length; i++)
+ dup[i] = code;
+ this.replaceSelections(dup, collapse, origin || "+input");
},
- undo: docOperation(function() {makeChangeFromHistory(this, "undo");}),
- redo: docOperation(function() {makeChangeFromHistory(this, "redo");}),
+ replaceSelections: docMethodOp(function(code, collapse, origin) {
+ var changes = [], sel = this.sel;
+ for (var i = 0; i < sel.ranges.length; i++) {
+ var range = sel.ranges[i];
+ changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin};
+ }
+ var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
+ for (var i = changes.length - 1; i >= 0; i--)
+ makeChange(this, changes[i]);
+ if (newSel) setSelectionReplaceHistory(this, newSel);
+ else if (this.cm) ensureCursorVisible(this.cm);
+ }),
+ undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
+ redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
+ undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
+ redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
- setExtending: function(val) {this.sel.extend = val;},
- getExtending: function() {return this.sel.extend;},
+ setExtending: function(val) {this.extend = val;},
+ getExtending: function() {return this.extend;},
historySize: function() {
- var hist = this.history;
- return {undo: hist.done.length, redo: hist.undone.length};
+ var hist = this.history, done = 0, undone = 0;
+ for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done;
+ for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone;
+ return {undo: done, redo: undone};
},
- clearHistory: function() {this.history = makeHistory(this.history.maxGeneration);},
+ clearHistory: function() {this.history = new History(this.history.maxGeneration);},
markClean: function() {
this.cleanGeneration = this.changeGeneration(true);
},
changeGeneration: function(forceSplit) {
if (forceSplit)
- this.history.lastOp = this.history.lastOrigin = null;
+ this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null;
return this.history.generation;
},
isClean: function (gen) {
@@ -5086,18 +7518,53 @@ window.CodeMirror = (function() {
undone: copyHistoryArray(this.history.undone)};
},
setHistory: function(histData) {
- var hist = this.history = makeHistory(this.history.maxGeneration);
- hist.done = histData.done.slice(0);
- hist.undone = histData.undone.slice(0);
+ var hist = this.history = new History(this.history.maxGeneration);
+ hist.done = copyHistoryArray(histData.done.slice(0), null, true);
+ hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
},
+ addLineClass: docMethodOp(function(handle, where, cls) {
+ return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
+ var prop = where == "text" ? "textClass"
+ : where == "background" ? "bgClass"
+ : where == "gutter" ? "gutterClass" : "wrapClass";
+ if (!line[prop]) line[prop] = cls;
+ else if (classTest(cls).test(line[prop])) return false;
+ else line[prop] += " " + cls;
+ return true;
+ });
+ }),
+ removeLineClass: docMethodOp(function(handle, where, cls) {
+ return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
+ var prop = where == "text" ? "textClass"
+ : where == "background" ? "bgClass"
+ : where == "gutter" ? "gutterClass" : "wrapClass";
+ var cur = line[prop];
+ if (!cur) return false;
+ else if (cls == null) line[prop] = null;
+ else {
+ var found = cur.match(classTest(cls));
+ if (!found) return false;
+ var end = found.index + found[0].length;
+ line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
+ }
+ return true;
+ });
+ }),
+
+ addLineWidget: docMethodOp(function(handle, node, options) {
+ return addLineWidget(this, handle, node, options);
+ }),
+ removeLineWidget: function(widget) { widget.clear(); },
+
markText: function(from, to, options) {
- return markText(this, clipPos(this, from), clipPos(this, to), options, "range");
+ return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range");
},
setBookmark: function(pos, options) {
var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
insertLeft: options && options.insertLeft,
- clearWhenEmpty: false};
+ clearWhenEmpty: false, shared: options && options.shared,
+ handleMouseEvents: options && options.handleMouseEvents};
pos = clipPos(this, pos);
return markText(this, pos, pos, realOpts, "bookmark");
},
@@ -5160,10 +7627,11 @@ window.CodeMirror = (function() {
},
copy: function(copyHistory) {
- var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first);
+ var doc = new Doc(getLines(this, this.first, this.first + this.size),
+ this.modeOption, this.first, this.lineSep);
doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
- doc.sel = {from: this.sel.from, to: this.sel.to, head: this.sel.head, anchor: this.sel.anchor,
- shift: this.sel.shift, extend: false, goalColumn: this.sel.goalColumn};
+ doc.sel = this.sel;
+ doc.extend = false;
if (copyHistory) {
doc.history.undoDepth = this.history.undoDepth;
doc.setHistory(this.getHistory());
@@ -5176,7 +7644,7 @@ window.CodeMirror = (function() {
var from = this.first, to = this.first + this.size;
if (options.from != null && options.from > from) from = options.from;
if (options.to != null && options.to < to) to = options.to;
- var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);
+ var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep);
if (options.sharedHist) copy.history = this.history;
(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
@@ -5197,7 +7665,7 @@ window.CodeMirror = (function() {
if (other.history == this.history) {
var splitIds = [other.id];
linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);
- other.history = makeHistory();
+ other.history = new History(null);
other.history.done = copyHistoryArray(this.history.done, splitIds);
other.history.undone = copyHistoryArray(this.history.undone, splitIds);
}
@@ -5205,13 +7673,20 @@ window.CodeMirror = (function() {
iterLinkedDocs: function(f) {linkedDocs(this, f);},
getMode: function() {return this.mode;},
- getEditor: function() {return this.cm;}
+ getEditor: function() {return this.cm;},
+
+ splitLines: function(str) {
+ if (this.lineSep) return str.split(this.lineSep);
+ return splitLinesAuto(str);
+ },
+ lineSeparator: function() { return this.lineSep || "\n"; }
});
+ // Public alias.
Doc.prototype.eachLine = Doc.prototype.iter;
- // The Doc methods that should be available on CodeMirror instances
- var dontDelegate = "iter insert remove copy getEditor".split(" ");
+ // Set up methods on CodeMirror's prototype to redirect to the editor's document.
+ var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
CodeMirror.prototype[prop] = (function(method) {
return function() {return method.apply(this.doc, arguments);};
@@ -5219,6 +7694,7 @@ window.CodeMirror = (function() {
eventMixin(Doc);
+ // Call f for all linked documents.
function linkedDocs(doc, f, sharedHistOnly) {
function propagate(doc, skip, sharedHist) {
if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
@@ -5233,22 +7709,25 @@ window.CodeMirror = (function() {
propagate(doc, null, true);
}
+ // Attach a document to an editor.
function attachDoc(cm, doc) {
if (doc.cm) throw new Error("This document is already in use.");
cm.doc = doc;
doc.cm = cm;
estimateLineHeights(cm);
loadMode(cm);
- if (!cm.options.lineWrapping) computeMaxLength(cm);
+ if (!cm.options.lineWrapping) findMaxLine(cm);
cm.options.mode = doc.modeOption;
regChange(cm);
}
// LINE UTILITIES
- function getLine(chunk, n) {
- n -= chunk.first;
- while (!chunk.lines) {
+ // Find the line object corresponding to the given line number.
+ function getLine(doc, n) {
+ n -= doc.first;
+ if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document.");
+ for (var chunk = doc; !chunk.lines;) {
for (var i = 0;; ++i) {
var child = chunk.children[i], sz = child.chunkSize();
if (n < sz) { chunk = child; break; }
@@ -5258,6 +7737,8 @@ window.CodeMirror = (function() {
return chunk.lines[n];
}
+ // Get the part of a document between two positions, as an array of
+ // strings.
function getBetween(doc, start, end) {
var out = [], n = start.line;
doc.iter(start.line, end.line + 1, function(line) {
@@ -5269,17 +7750,22 @@ window.CodeMirror = (function() {
});
return out;
}
+ // Get the lines between from and to, as array of strings.
function getLines(doc, from, to) {
var out = [];
doc.iter(from, to, function(line) { out.push(line.text); });
return out;
}
+ // Update the height of a line, propagating the height change
+ // upwards to parent nodes.
function updateLineHeight(line, height) {
var diff = height - line.height;
- for (var n = line; n; n = n.parent) n.height += diff;
+ if (diff) for (var n = line; n; n = n.parent) n.height += diff;
}
+ // Given a line object, find its line number by walking up through
+ // its parent links.
function lineNo(line) {
if (line.parent == null) return null;
var cur = line.parent, no = indexOf(cur.lines, line);
@@ -5292,10 +7778,12 @@ window.CodeMirror = (function() {
return no + cur.first;
}
+ // Find the line at the given vertical position, using the height
+ // information in the document tree.
function lineAtHeight(chunk, h) {
var n = chunk.first;
outer: do {
- for (var i = 0, e = chunk.children.length; i < e; ++i) {
+ for (var i = 0; i < chunk.children.length; ++i) {
var child = chunk.children[i], ch = child.height;
if (h < ch) { chunk = child; continue outer; }
h -= ch;
@@ -5303,7 +7791,7 @@ window.CodeMirror = (function() {
}
return n;
} while (!chunk.lines);
- for (var i = 0, e = chunk.lines.length; i < e; ++i) {
+ for (var i = 0; i < chunk.lines.length; ++i) {
var line = chunk.lines[i], lh = line.height;
if (h < lh) break;
h -= lh;
@@ -5311,8 +7799,10 @@ window.CodeMirror = (function() {
return n + i;
}
- function heightAtLine(cm, lineObj) {
- lineObj = visualLine(cm.doc, lineObj);
+
+ // Find the height above the given line.
+ function heightAtLine(lineObj) {
+ lineObj = visualLine(lineObj);
var h = 0, chunk = lineObj.parent;
for (var i = 0; i < chunk.lines.length; ++i) {
@@ -5330,6 +7820,9 @@ window.CodeMirror = (function() {
return h;
}
+ // Get the bidi ordering for the given line (and cache it). Returns
+ // false for lines that are fully left-to-right, and an array of
+ // BidiSpan objects otherwise.
function getOrder(line) {
var order = line.order;
if (order == null) order = line.order = bidiOrdering(line.text);
@@ -5338,50 +7831,70 @@ window.CodeMirror = (function() {
// HISTORY
- function makeHistory(startGen) {
- return {
- // Arrays of history events. Doing something adds an event to
- // done and clears undo. Undoing moves events from done to
- // undone, redoing moves them in the other direction.
- done: [], undone: [], undoDepth: Infinity,
- // Used to track when changes can be merged into a single undo
- // event
- lastTime: 0, lastOp: null, lastOrigin: null,
- // Used by the isClean() method
- generation: startGen || 1, maxGeneration: startGen || 1
- };
- }
-
- function attachLocalSpans(doc, change, from, to) {
- var existing = change["spans_" + doc.id], n = 0;
- doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {
- if (line.markedSpans)
- (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
- ++n;
- });
- }
-
+ function History(startGen) {
+ // Arrays of change events and selections. Doing something adds an
+ // event to done and clears undo. Undoing moves events from done
+ // to undone, redoing moves them in the other direction.
+ this.done = []; this.undone = [];
+ this.undoDepth = Infinity;
+ // Used to track when changes can be merged into a single undo
+ // event
+ this.lastModTime = this.lastSelTime = 0;
+ this.lastOp = this.lastSelOp = null;
+ this.lastOrigin = this.lastSelOrigin = null;
+ // Used by the isClean() method
+ this.generation = this.maxGeneration = startGen || 1;
+ }
+
+ // Create a history change event from an updateDoc-style change
+ // object.
function historyChangeFromChange(doc, change) {
- var from = { line: change.from.line, ch: change.from.ch };
- var histChange = {from: from, to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
+ var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);
return histChange;
}
- function addToHistory(doc, change, selAfter, opId) {
+ // Pop all selection events off the end of a history array. Stop at
+ // a change event.
+ function clearSelectionEvents(array) {
+ while (array.length) {
+ var last = lst(array);
+ if (last.ranges) array.pop();
+ else break;
+ }
+ }
+
+ // Find the top change event in the history. Pop off selection
+ // events that are in the way.
+ function lastChangeEvent(hist, force) {
+ if (force) {
+ clearSelectionEvents(hist.done);
+ return lst(hist.done);
+ } else if (hist.done.length && !lst(hist.done).ranges) {
+ return lst(hist.done);
+ } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
+ hist.done.pop();
+ return lst(hist.done);
+ }
+ }
+
+ // Register a change in the history. Merges changes that are within
+ // a single operation, ore are close together with an origin that
+ // allows merging (starting with "+") into a single event.
+ function addChangeToHistory(doc, change, selAfter, opId) {
var hist = doc.history;
hist.undone.length = 0;
- var time = +new Date, cur = lst(hist.done);
+ var time = +new Date, cur;
- if (cur &&
- (hist.lastOp == opId ||
+ if ((hist.lastOp == opId ||
hist.lastOrigin == change.origin && change.origin &&
- ((change.origin.charAt(0) == "+" && doc.cm && hist.lastTime > time - doc.cm.options.historyEventDelay) ||
- change.origin.charAt(0) == "*"))) {
+ ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
+ change.origin.charAt(0) == "*")) &&
+ (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
// Merge this change into the last event
var last = lst(cur.changes);
- if (posEq(change.from, change.to) && posEq(change.from, last.to)) {
+ if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
// Optimized case for simple insertion -- don't want to add
// new changesets for every character typed
last.to = changeEnd(change);
@@ -5389,25 +7902,81 @@ window.CodeMirror = (function() {
// Add new sub-event
cur.changes.push(historyChangeFromChange(doc, change));
}
- cur.anchorAfter = selAfter.anchor; cur.headAfter = selAfter.head;
} else {
// Can not be merged, start a new event.
+ var before = lst(hist.done);
+ if (!before || !before.ranges)
+ pushSelectionToHistory(doc.sel, hist.done);
cur = {changes: [historyChangeFromChange(doc, change)],
- generation: hist.generation,
- anchorBefore: doc.sel.anchor, headBefore: doc.sel.head,
- anchorAfter: selAfter.anchor, headAfter: selAfter.head};
+ generation: hist.generation};
hist.done.push(cur);
- while (hist.done.length > hist.undoDepth)
+ while (hist.done.length > hist.undoDepth) {
hist.done.shift();
+ if (!hist.done[0].ranges) hist.done.shift();
+ }
}
+ hist.done.push(selAfter);
hist.generation = ++hist.maxGeneration;
- hist.lastTime = time;
- hist.lastOp = opId;
- hist.lastOrigin = change.origin;
+ hist.lastModTime = hist.lastSelTime = time;
+ hist.lastOp = hist.lastSelOp = opId;
+ hist.lastOrigin = hist.lastSelOrigin = change.origin;
if (!last) signal(doc, "historyAdded");
}
+ function selectionEventCanBeMerged(doc, origin, prev, sel) {
+ var ch = origin.charAt(0);
+ return ch == "*" ||
+ ch == "+" &&
+ prev.ranges.length == sel.ranges.length &&
+ prev.somethingSelected() == sel.somethingSelected() &&
+ new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500);
+ }
+
+ // Called whenever the selection changes, sets the new selection as
+ // the pending selection in the history, and pushes the old pending
+ // selection into the 'done' array when it was significantly
+ // different (in number of selected ranges, emptiness, or time).
+ function addSelectionToHistory(doc, sel, opId, options) {
+ var hist = doc.history, origin = options && options.origin;
+
+ // A new event is started when the previous origin does not match
+ // the current, or the origins don't allow matching. Origins
+ // starting with * are always merged, those starting with + are
+ // merged when similar and close together in time.
+ if (opId == hist.lastSelOp ||
+ (origin && hist.lastSelOrigin == origin &&
+ (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
+ selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
+ hist.done[hist.done.length - 1] = sel;
+ else
+ pushSelectionToHistory(sel, hist.done);
+
+ hist.lastSelTime = +new Date;
+ hist.lastSelOrigin = origin;
+ hist.lastSelOp = opId;
+ if (options && options.clearRedo !== false)
+ clearSelectionEvents(hist.undone);
+ }
+
+ function pushSelectionToHistory(sel, dest) {
+ var top = lst(dest);
+ if (!(top && top.ranges && top.equals(sel)))
+ dest.push(sel);
+ }
+
+ // Used to store marked span information in the history.
+ function attachLocalSpans(doc, change, from, to) {
+ var existing = change["spans_" + doc.id], n = 0;
+ doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {
+ if (line.markedSpans)
+ (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
+ ++n;
+ });
+ }
+
+ // When un/re-doing restores text containing marked spans, those
+ // that have been explicitly cleared should not be restored.
function removeClearedSpans(spans) {
if (!spans) return null;
for (var i = 0, out; i < spans.length; ++i) {
@@ -5417,6 +7986,7 @@ window.CodeMirror = (function() {
return !out ? spans : out.length ? out : null;
}
+ // Retrieve and filter the old marked spans stored in a change event.
function getOldSpans(doc, change) {
var found = change["spans_" + doc.id];
if (!found) return null;
@@ -5427,11 +7997,15 @@ window.CodeMirror = (function() {
// Used both to provide a JSON-safe object in .getHistory, and, when
// detaching a document, to split the history in two
- function copyHistoryArray(events, newGroup) {
+ function copyHistoryArray(events, newGroup, instantiateSel) {
for (var i = 0, copy = []; i < events.length; ++i) {
- var event = events[i], changes = event.changes, newChanges = [];
- copy.push({changes: newChanges, anchorBefore: event.anchorBefore, headBefore: event.headBefore,
- anchorAfter: event.anchorAfter, headAfter: event.headAfter});
+ var event = events[i];
+ if (event.ranges) {
+ copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
+ continue;
+ }
+ var changes = event.changes, newChanges = [];
+ copy.push({changes: newChanges});
for (var j = 0; j < changes.length; ++j) {
var change = changes[j], m;
newChanges.push({from: change.from, to: change.to, text: change.text});
@@ -5448,7 +8022,7 @@ window.CodeMirror = (function() {
// Rebasing/resetting history to deal with externally-sourced changes
- function rebaseHistSel(pos, from, to, diff) {
+ function rebaseHistSelSingle(pos, from, to, diff) {
if (to < pos.line) {
pos.line += diff;
} else if (from < pos.line) {
@@ -5467,28 +8041,27 @@ window.CodeMirror = (function() {
function rebaseHistArray(array, from, to, diff) {
for (var i = 0; i < array.length; ++i) {
var sub = array[i], ok = true;
+ if (sub.ranges) {
+ if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
+ for (var j = 0; j < sub.ranges.length; j++) {
+ rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
+ rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
+ }
+ continue;
+ }
for (var j = 0; j < sub.changes.length; ++j) {
var cur = sub.changes[j];
- if (!sub.copied) { cur.from = copyPos(cur.from); cur.to = copyPos(cur.to); }
if (to < cur.from.line) {
- cur.from.line += diff;
- cur.to.line += diff;
+ cur.from = Pos(cur.from.line + diff, cur.from.ch);
+ cur.to = Pos(cur.to.line + diff, cur.to.ch);
} else if (from <= cur.to.line) {
ok = false;
break;
}
}
- if (!sub.copied) {
- sub.anchorBefore = copyPos(sub.anchorBefore); sub.headBefore = copyPos(sub.headBefore);
- sub.anchorAfter = copyPos(sub.anchorAfter); sub.readAfter = copyPos(sub.headAfter);
- sub.copied = true;
- }
if (!ok) {
array.splice(0, i + 1);
i = 0;
- } else {
- rebaseHistSel(sub.anchorBefore); rebaseHistSel(sub.headBefore);
- rebaseHistSel(sub.anchorAfter); rebaseHistSel(sub.headAfter);
}
}
}
@@ -5499,30 +8072,23 @@ window.CodeMirror = (function() {
rebaseHistArray(hist.undone, from, to, diff);
}
- // EVENT OPERATORS
+ // EVENT UTILITIES
- function stopMethod() {e_stop(this);}
- // Ensure an event has a stop method.
- function addStop(event) {
- if (!event.stop) event.stop = stopMethod;
- return event;
- }
+ // Due to the fact that we still support jurassic IE versions, some
+ // compatibility wrappers are needed.
- function e_preventDefault(e) {
+ var e_preventDefault = CodeMirror.e_preventDefault = function(e) {
if (e.preventDefault) e.preventDefault();
else e.returnValue = false;
- }
- function e_stopPropagation(e) {
+ };
+ var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) {
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
- }
+ };
function e_defaultPrevented(e) {
return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
}
- function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}
- CodeMirror.e_stop = e_stop;
- CodeMirror.e_preventDefault = e_preventDefault;
- CodeMirror.e_stopPropagation = e_stopPropagation;
+ var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);};
function e_target(e) {return e.target || e.srcElement;}
function e_button(e) {
@@ -5538,7 +8104,10 @@ window.CodeMirror = (function() {
// EVENT HANDLING
- function on(emitter, type, f) {
+ // Lightweight event framework. on/off also work on DOM nodes,
+ // registering native DOM handlers.
+
+ var on = CodeMirror.on = function(emitter, type, f) {
if (emitter.addEventListener)
emitter.addEventListener(type, f, false);
else if (emitter.attachEvent)
@@ -5548,62 +8117,90 @@ window.CodeMirror = (function() {
var arr = map[type] || (map[type] = []);
arr.push(f);
}
+ };
+
+ var noHandlers = []
+ function getHandlers(emitter, type, copy) {
+ var arr = emitter._handlers && emitter._handlers[type]
+ if (copy) return arr && arr.length > 0 ? arr.slice() : noHandlers
+ else return arr || noHandlers
}
- function off(emitter, type, f) {
+ var off = CodeMirror.off = function(emitter, type, f) {
if (emitter.removeEventListener)
emitter.removeEventListener(type, f, false);
else if (emitter.detachEvent)
emitter.detachEvent("on" + type, f);
else {
- var arr = emitter._handlers && emitter._handlers[type];
- if (!arr) return;
- for (var i = 0; i < arr.length; ++i)
- if (arr[i] == f) { arr.splice(i, 1); break; }
+ var handlers = getHandlers(emitter, type, false)
+ for (var i = 0; i < handlers.length; ++i)
+ if (handlers[i] == f) { handlers.splice(i, 1); break; }
}
- }
+ };
- function signal(emitter, type /*, values...*/) {
- var arr = emitter._handlers && emitter._handlers[type];
- if (!arr) return;
+ var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
+ var handlers = getHandlers(emitter, type, true)
+ if (!handlers.length) return;
var args = Array.prototype.slice.call(arguments, 2);
- for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
- }
+ for (var i = 0; i < handlers.length; ++i) handlers[i].apply(null, args);
+ };
- var delayedCallbacks, delayedCallbackDepth = 0;
+ var orphanDelayedCallbacks = null;
+
+ // Often, we want to signal events at a point where we are in the
+ // middle of some work, but don't want the handler to start calling
+ // other methods on the editor, which might be in an inconsistent
+ // state or simply not expect any other events to happen.
+ // signalLater looks whether there are any handlers, and schedules
+ // them to be executed when the last operation ends, or, if no
+ // operation is active, when a timeout fires.
function signalLater(emitter, type /*, values...*/) {
- var arr = emitter._handlers && emitter._handlers[type];
- if (!arr) return;
- var args = Array.prototype.slice.call(arguments, 2);
- if (!delayedCallbacks) {
- ++delayedCallbackDepth;
- delayedCallbacks = [];
- setTimeout(fireDelayed, 0);
+ var arr = getHandlers(emitter, type, false)
+ if (!arr.length) return;
+ var args = Array.prototype.slice.call(arguments, 2), list;
+ if (operationGroup) {
+ list = operationGroup.delayedCallbacks;
+ } else if (orphanDelayedCallbacks) {
+ list = orphanDelayedCallbacks;
+ } else {
+ list = orphanDelayedCallbacks = [];
+ setTimeout(fireOrphanDelayed, 0);
}
function bnd(f) {return function(){f.apply(null, args);};};
for (var i = 0; i < arr.length; ++i)
- delayedCallbacks.push(bnd(arr[i]));
+ list.push(bnd(arr[i]));
+ }
+
+ function fireOrphanDelayed() {
+ var delayed = orphanDelayedCallbacks;
+ orphanDelayedCallbacks = null;
+ for (var i = 0; i < delayed.length; ++i) delayed[i]();
}
+ // The DOM events that CodeMirror handles can be overridden by
+ // registering a (non-DOM) handler on the editor for the event name,
+ // and preventDefault-ing the event in that handler.
function signalDOMEvent(cm, e, override) {
+ if (typeof e == "string")
+ e = {type: e, preventDefault: function() { this.defaultPrevented = true; }};
signal(cm, override || e.type, cm, e);
return e_defaultPrevented(e) || e.codemirrorIgnore;
}
- function fireDelayed() {
- --delayedCallbackDepth;
- var delayed = delayedCallbacks;
- delayedCallbacks = null;
- for (var i = 0; i < delayed.length; ++i) delayed[i]();
+ function signalCursorActivity(cm) {
+ var arr = cm._handlers && cm._handlers.cursorActivity;
+ if (!arr) return;
+ var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
+ for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1)
+ set.push(arr[i]);
}
function hasHandler(emitter, type) {
- var arr = emitter._handlers && emitter._handlers[type];
- return arr && arr.length > 0;
+ return getHandlers(emitter, type).length > 0
}
- CodeMirror.on = on; CodeMirror.off = off; CodeMirror.signal = signal;
-
+ // Add on and off methods to a constructor's prototype, to make
+ // registering events on such objects more convenient.
function eventMixin(ctor) {
ctor.prototype.on = function(type, f) {on(this, type, f);};
ctor.prototype.off = function(type, f) {off(this, type, f);};
@@ -5612,29 +8209,53 @@ window.CodeMirror = (function() {
// MISC UTILITIES
// Number of pixels added to scroller and sizer to hide scrollbar
- var scrollerCutOff = 30;
+ var scrollerGap = 30;
// Returned or thrown by various protocols to signal 'I'm not
// handling this'.
var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
+ // Reused option objects for setSelection & friends
+ var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
+
function Delayed() {this.id = null;}
- Delayed.prototype = {set: function(ms, f) {clearTimeout(this.id); this.id = setTimeout(f, ms);}};
+ Delayed.prototype.set = function(ms, f) {
+ clearTimeout(this.id);
+ this.id = setTimeout(f, ms);
+ };
// Counts the column offset in a string, taking tabs into account.
// Used mostly to find indentation.
- function countColumn(string, end, tabSize, startIndex, startValue) {
+ var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) {
if (end == null) {
end = string.search(/[^\s\u00a0]/);
if (end == -1) end = string.length;
}
- for (var i = startIndex || 0, n = startValue || 0; i < end; ++i) {
- if (string.charAt(i) == "\t") n += tabSize - (n % tabSize);
- else ++n;
+ for (var i = startIndex || 0, n = startValue || 0;;) {
+ var nextTab = string.indexOf("\t", i);
+ if (nextTab < 0 || nextTab >= end)
+ return n + (end - i);
+ n += nextTab - i;
+ n += tabSize - (n % tabSize);
+ i = nextTab + 1;
+ }
+ };
+
+ // The inverse of countColumn -- find the offset that corresponds to
+ // a particular column.
+ var findColumn = CodeMirror.findColumn = function(string, goal, tabSize) {
+ for (var pos = 0, col = 0;;) {
+ var nextTab = string.indexOf("\t", pos);
+ if (nextTab == -1) nextTab = string.length;
+ var skipped = nextTab - pos;
+ if (nextTab == string.length || col + skipped >= goal)
+ return pos + Math.min(skipped, goal - col);
+ col += nextTab - pos;
+ col += tabSize - (col % tabSize);
+ pos = nextTab + 1;
+ if (col >= goal) return pos;
}
- return n;
}
- CodeMirror.countColumn = countColumn;
var spaceStrs = [""];
function spaceStr(n) {
@@ -5645,31 +8266,36 @@ window.CodeMirror = (function() {
function lst(arr) { return arr[arr.length-1]; }
- function selectInput(node) {
- if (ios) { // Mobile Safari apparently has a bug where select() is broken.
- node.selectionStart = 0;
- node.selectionEnd = node.value.length;
- } else {
- // Suppress mysterious IE10 errors
- try { node.select(); }
- catch(_e) {}
- }
- }
+ var selectInput = function(node) { node.select(); };
+ if (ios) // Mobile Safari apparently has a bug where select() is broken.
+ selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; };
+ else if (ie) // Suppress mysterious IE10 errors
+ selectInput = function(node) { try { node.select(); } catch(_e) {} };
- function indexOf(collection, elt) {
- if (collection.indexOf) return collection.indexOf(elt);
- for (var i = 0, e = collection.length; i < e; ++i)
- if (collection[i] == elt) return i;
+ function indexOf(array, elt) {
+ for (var i = 0; i < array.length; ++i)
+ if (array[i] == elt) return i;
return -1;
}
+ function map(array, f) {
+ var out = [];
+ for (var i = 0; i < array.length; i++) out[i] = f(array[i], i);
+ return out;
+ }
+
+ function nothing() {}
function createObj(base, props) {
- function Obj() {}
- Obj.prototype = base;
- var inst = new Obj();
+ var inst;
+ if (Object.create) {
+ inst = Object.create(base);
+ } else {
+ nothing.prototype = base;
+ inst = new nothing();
+ }
if (props) copyObj(props, inst);
return inst;
- }
+ };
function copyObj(obj, target, overwrite) {
if (!target) target = {};
@@ -5679,20 +8305,20 @@ window.CodeMirror = (function() {
return target;
}
- function emptyArray(size) {
- for (var a = [], i = 0; i < size; ++i) a.push(undefined);
- return a;
- }
-
function bind(f) {
var args = Array.prototype.slice.call(arguments, 1);
return function(){return f.apply(null, args);};
}
- var nonASCIISingleCaseWordChar = /[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
- function isWordChar(ch) {
+ var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
+ var isWordCharBasic = CodeMirror.isWordChar = function(ch) {
return /\w/.test(ch) || ch > "\x80" &&
(ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
+ };
+ function isWordChar(ch, helper) {
+ if (!helper) return isWordCharBasic(ch);
+ if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true;
+ return helper.test(ch);
}
function isEmpty(obj) {
@@ -5700,6 +8326,11 @@ window.CodeMirror = (function() {
return true;
}
+ // Extending unicode characters. A series of a non-extending char +
+ // any number of extending chars is treated as a single unit as far
+ // as editing and measuring is concerned. This is not fully correct,
+ // since some scripts/fonts/browsers also treat other configurations
+ // of code points as a group.
var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); }
@@ -5709,11 +8340,28 @@ window.CodeMirror = (function() {
var e = document.createElement(tag);
if (className) e.className = className;
if (style) e.style.cssText = style;
- if (typeof content == "string") setTextContent(e, content);
+ if (typeof content == "string") e.appendChild(document.createTextNode(content));
else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
return e;
}
+ var range;
+ if (document.createRange) range = function(node, start, end, endNode) {
+ var r = document.createRange();
+ r.setEnd(endNode || node, end);
+ r.setStart(node, start);
+ return r;
+ };
+ else range = function(node, start, end) {
+ var r = document.body.createTextRange();
+ try { r.moveToElementText(node.parentNode); }
+ catch(e) { return r; }
+ r.collapse(true);
+ r.moveEnd("character", end);
+ r.moveStart("character", start);
+ return r;
+ };
+
function removeChildren(e) {
for (var count = e.childNodes.length; count > 0; --count)
e.removeChild(e.firstChild);
@@ -5724,17 +8372,85 @@ window.CodeMirror = (function() {
return removeChildren(parent).appendChild(e);
}
- function setTextContent(e, str) {
- if (ie_lt9) {
- e.innerHTML = "";
- e.appendChild(document.createTextNode(str));
- } else e.textContent = str;
+ var contains = CodeMirror.contains = function(parent, child) {
+ if (child.nodeType == 3) // Android browser always returns false when child is a textnode
+ child = child.parentNode;
+ if (parent.contains)
+ return parent.contains(child);
+ do {
+ if (child.nodeType == 11) child = child.host;
+ if (child == parent) return true;
+ } while (child = child.parentNode);
+ };
+
+ function activeElt() {
+ var activeElement = document.activeElement;
+ while (activeElement && activeElement.root && activeElement.root.activeElement)
+ activeElement = activeElement.root.activeElement;
+ return activeElement;
+ }
+ // Older versions of IE throws unspecified error when touching
+ // document.activeElement in some cases (during loading, in iframe)
+ if (ie && ie_version < 11) activeElt = function() {
+ try { return document.activeElement; }
+ catch(e) { return document.body; }
+ };
+
+ function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); }
+ var rmClass = CodeMirror.rmClass = function(node, cls) {
+ var current = node.className;
+ var match = classTest(cls).exec(current);
+ if (match) {
+ var after = current.slice(match.index + match[0].length);
+ node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
+ }
+ };
+ var addClass = CodeMirror.addClass = function(node, cls) {
+ var current = node.className;
+ if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls;
+ };
+ function joinClasses(a, b) {
+ var as = a.split(" ");
+ for (var i = 0; i < as.length; i++)
+ if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i];
+ return b;
+ }
+
+ // WINDOW-WIDE EVENTS
+
+ // These must be handled carefully, because naively registering a
+ // handler for each editor will cause the editors to never be
+ // garbage collected.
+
+ function forEachCodeMirror(f) {
+ if (!document.body.getElementsByClassName) return;
+ var byClass = document.body.getElementsByClassName("CodeMirror");
+ for (var i = 0; i < byClass.length; i++) {
+ var cm = byClass[i].CodeMirror;
+ if (cm) f(cm);
+ }
}
- function getRect(node) {
- return node.getBoundingClientRect();
+ var globalsRegistered = false;
+ function ensureGlobalHandlers() {
+ if (globalsRegistered) return;
+ registerGlobalHandlers();
+ globalsRegistered = true;
+ }
+ function registerGlobalHandlers() {
+ // When the window resizes, we need to refresh active editors.
+ var resizeTimer;
+ on(window, "resize", function() {
+ if (resizeTimer == null) resizeTimer = setTimeout(function() {
+ resizeTimer = null;
+ forEachCodeMirror(onResize);
+ }, 100);
+ });
+ // When the window loses focus, we want to show the editor as blurred
+ on(window, "blur", function() {
+ forEachCodeMirror(onBlur);
+ });
}
- CodeMirror.replaceGetRect = function(f) { getRect = f; };
// FEATURE DETECTION
@@ -5742,66 +8458,39 @@ window.CodeMirror = (function() {
var dragAndDrop = function() {
// There is *some* kind of drag-and-drop support in IE6-8, but I
// couldn't get it to work yet.
- if (ie_lt9) return false;
+ if (ie && ie_version < 9) return false;
var div = elt('div');
return "draggable" in div || "dragDrop" in div;
}();
- // For a reason I have yet to figure out, some browsers disallow
- // word wrapping between certain characters *only* if a new inline
- // element is started between them. This makes it hard to reliably
- // measure the position of things, since that requires inserting an
- // extra span. This terribly fragile set of tests matches the
- // character combinations that suffer from this phenomenon on the
- // various browsers.
- function spanAffectsWrapping() { return false; }
- if (gecko) // Only for "$'"
- spanAffectsWrapping = function(str, i) {
- return str.charCodeAt(i - 1) == 36 && str.charCodeAt(i) == 39;
- };
- else if (safari && !/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent))
- spanAffectsWrapping = function(str, i) {
- return /\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(str.slice(i - 1, i + 1));
- };
- else if (webkit && /Chrome\/(?:29|[3-9]\d|\d\d\d)\./.test(navigator.userAgent))
- spanAffectsWrapping = function(str, i) {
- var code = str.charCodeAt(i - 1);
- return code >= 8208 && code <= 8212;
- };
- else if (webkit)
- spanAffectsWrapping = function(str, i) {
- if (i > 1 && str.charCodeAt(i - 1) == 45) {
- if (/\w/.test(str.charAt(i - 2)) && /[^\-?\.]/.test(str.charAt(i))) return true;
- if (i > 2 && /[\d\.,]/.test(str.charAt(i - 2)) && /[\d\.,]/.test(str.charAt(i))) return false;
- }
- return /[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|\u2026[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i - 1, i + 1));
- };
-
- var knownScrollbarWidth;
- function scrollbarWidth(measure) {
- if (knownScrollbarWidth != null) return knownScrollbarWidth;
- var test = elt("div", null, null, "width: 50px; height: 50px; overflow-x: scroll");
- removeChildrenAndAdd(measure, test);
- if (test.offsetWidth)
- knownScrollbarWidth = test.offsetHeight - test.clientHeight;
- return knownScrollbarWidth || 0;
- }
-
var zwspSupported;
function zeroWidthElement(measure) {
if (zwspSupported == null) {
var test = elt("span", "\u200b");
removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
if (measure.firstChild.offsetHeight != 0)
- zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !ie_lt8;
+ zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
}
- if (zwspSupported) return elt("span", "\u200b");
- else return elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
+ var node = zwspSupported ? elt("span", "\u200b") :
+ elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
+ node.setAttribute("cm-text", "");
+ return node;
+ }
+
+ // Feature-detect IE's crummy client rect reporting for bidi text
+ var badBidiRects;
+ function hasBadBidiRects(measure) {
+ if (badBidiRects != null) return badBidiRects;
+ var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
+ var r0 = range(txt, 0, 1).getBoundingClientRect();
+ if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
+ var r1 = range(txt, 1, 2).getBoundingClientRect();
+ return badBidiRects = (r1.right - r0.right < 3);
}
// See if "".split is the broken IE version, if so, provide an
// alternative way to split lines.
- var splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
+ var splitLinesAuto = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
var pos = 0, result = [], l = string.length;
while (pos <= l) {
var nl = string.indexOf("\n", pos);
@@ -5818,7 +8507,6 @@ window.CodeMirror = (function() {
}
return result;
} : function(string){return string.split(/\r\n?|\n/);};
- CodeMirror.splitLines = splitLines;
var hasSelection = window.getSelection ? function(te) {
try { return te.selectionStart != te.selectionEnd; }
@@ -5834,19 +8522,30 @@ window.CodeMirror = (function() {
var e = elt("div");
if ("oncopy" in e) return true;
e.setAttribute("oncopy", "return;");
- return typeof e.oncopy == 'function';
+ return typeof e.oncopy == "function";
})();
- // KEY NAMING
-
- var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
- 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
- 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
- 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete",
- 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
- 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
- 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"};
- CodeMirror.keyNames = keyNames;
+ var badZoomedRects = null;
+ function hasBadZoomedRects(measure) {
+ if (badZoomedRects != null) return badZoomedRects;
+ var node = removeChildrenAndAdd(measure, elt("span", "x"));
+ var normal = node.getBoundingClientRect();
+ var fromRange = range(node, 0, 1).getBoundingClientRect();
+ return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
+ }
+
+ // KEY NAMES
+
+ var keyNames = CodeMirror.keyNames = {
+ 3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
+ 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
+ 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
+ 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
+ 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete",
+ 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
+ 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
+ 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
+ };
(function() {
// Number keys
for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
@@ -5883,19 +8582,32 @@ window.CodeMirror = (function() {
function lineStart(cm, lineN) {
var line = getLine(cm.doc, lineN);
- var visual = visualLine(cm.doc, line);
+ var visual = visualLine(line);
if (visual != line) lineN = lineNo(visual);
var order = getOrder(visual);
var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);
return Pos(lineN, ch);
}
function lineEnd(cm, lineN) {
- var merged, line;
- while (merged = collapsedSpanAtEnd(line = getLine(cm.doc, lineN)))
- lineN = merged.find().to.line;
+ var merged, line = getLine(cm.doc, lineN);
+ while (merged = collapsedSpanAtEnd(line)) {
+ line = merged.find(1, true).line;
+ lineN = null;
+ }
var order = getOrder(line);
var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);
- return Pos(lineN, ch);
+ return Pos(lineN == null ? lineNo(line) : lineN, ch);
+ }
+ function lineStartSmart(cm, pos) {
+ var start = lineStart(cm, pos.line);
+ var line = getLine(cm.doc, start.line);
+ var order = getOrder(line);
+ if (!order || order[0].level == 0) {
+ var firstNonWS = Math.max(0, line.text.search(/\S/));
+ var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
+ return Pos(start.line, inWS ? 0 : firstNonWS);
+ }
+ return start;
}
function compareBidiLevel(order, a, b) {
@@ -5932,12 +8644,11 @@ window.CodeMirror = (function() {
return pos;
}
- // This is somewhat involved. It is needed in order to move
- // 'visually' through bi-directional text -- i.e., pressing left
- // should make the cursor go left, even when in RTL text. The
- // tricky part is the 'jumps', where RTL and LTR text touch each
- // other. This often requires the cursor offset to move more than
- // one unit, in order to visually move one unit.
+ // This is needed in order to move 'visually' through bi-directional
+ // text -- i.e., pressing left should make the cursor go left, even
+ // when in RTL text. The tricky part is the 'jumps', where RTL and
+ // LTR text touch each other. This often requires the cursor offset
+ // to move more than one unit, in order to visually move one unit.
function moveVisually(line, start, dir, byUnit) {
var bidi = getOrder(line);
if (!bidi) return moveLogically(line, start, dir, byUnit);
@@ -5992,14 +8703,16 @@ window.CodeMirror = (function() {
// objects) in the order in which they occur visually.
var bidiOrdering = (function() {
// Character types for codepoints 0 to 0xff
- var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL";
+ var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
// Character types for codepoints 0x600 to 0x6ff
- var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr";
+ var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";
function charType(code) {
- if (code <= 0xff) return lowTypes.charAt(code);
+ if (code <= 0xf7) return lowTypes.charAt(code);
else if (0x590 <= code && code <= 0x5f4) return "R";
- else if (0x600 <= code && code <= 0x6ff) return arabicTypes.charAt(code - 0x600);
- else if (0x700 <= code && code <= 0x8ac) return "r";
+ else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600);
+ else if (0x6ee <= code && code <= 0x8ac) return "r";
+ else if (0x2000 <= code && code <= 0x200b) return "w";
+ else if (code == 0x200c) return "b";
else return "L";
}
@@ -6008,6 +8721,11 @@ window.CodeMirror = (function() {
// Browsers seem to always treat the boundaries of block elements as being L.
var outerType = "L";
+ function BidiSpan(level, from, to) {
+ this.level = level;
+ this.from = from; this.to = to;
+ }
+
return function(str) {
if (!bidiRE.test(str)) return false;
var len = str.length, types = [];
@@ -6097,32 +8815,34 @@ window.CodeMirror = (function() {
if (countsAsLeft.test(types[i])) {
var start = i;
for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}
- order.push({from: start, to: i, level: 0});
+ order.push(new BidiSpan(0, start, i));
} else {
var pos = i, at = order.length;
for (++i; i < len && types[i] != "L"; ++i) {}
for (var j = pos; j < i;) {
if (countsAsNum.test(types[j])) {
- if (pos < j) order.splice(at, 0, {from: pos, to: j, level: 1});
+ if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j));
var nstart = j;
for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
- order.splice(at, 0, {from: nstart, to: j, level: 2});
+ order.splice(at, 0, new BidiSpan(2, nstart, j));
pos = j;
} else ++j;
}
- if (pos < i) order.splice(at, 0, {from: pos, to: i, level: 1});
+ if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i));
}
}
if (order[0].level == 1 && (m = str.match(/^\s+/))) {
order[0].from = m[0].length;
- order.unshift({from: 0, to: m[0].length, level: 0});
+ order.unshift(new BidiSpan(0, 0, m[0].length));
}
if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
lst(order).to -= m[0].length;
- order.push({from: len - m[0].length, to: len, level: 0});
+ order.push(new BidiSpan(0, len - m[0].length, len));
}
+ if (order[0].level == 2)
+ order.unshift(new BidiSpan(1, order[0].to, order[0].to));
if (order[0].level != lst(order).level)
- order.push({from: len, to: len, level: order[0].level});
+ order.push(new BidiSpan(order[0].level, len, len));
return order;
};
@@ -6130,7 +8850,7 @@ window.CodeMirror = (function() {
// THE END
- CodeMirror.version = "3.24.0";
+ CodeMirror.version = "5.8.0";
return CodeMirror;
-})();
+});
diff --git a/data/ext/editorText/codemirror/mode/apl/apl.js b/data/ext/editorText/codemirror/mode/apl/apl.js
index 5c23af85d..caafe4e91 100644
--- a/data/ext/editorText/codemirror/mode/apl/apl.js
+++ b/data/ext/editorText/codemirror/mode/apl/apl.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("apl", function() {
var builtInOps = {
".": "innerProduct",
@@ -89,7 +102,7 @@ CodeMirror.defineMode("apl", function() {
};
},
token: function(stream, state) {
- var ch, funcName, word;
+ var ch, funcName;
if (stream.eatSpace()) {
return null;
}
@@ -150,7 +163,6 @@ CodeMirror.defineMode("apl", function() {
return "function jot-dot";
}
stream.eatWhile(/[\w\$_]/);
- word = stream.current();
state.prev = true;
return "keyword";
}
@@ -158,3 +170,5 @@ CodeMirror.defineMode("apl", function() {
});
CodeMirror.defineMIME("text/apl", "apl");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/apl/index.html b/data/ext/editorText/codemirror/mode/apl/index.html
index f8282ac42..53dda6b58 100644
--- a/data/ext/editorText/codemirror/mode/apl/index.html
+++ b/data/ext/editorText/codemirror/mode/apl/index.html
@@ -12,12 +12,12 @@
.CodeMirror { border: 2px inset #dee; }
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/asciiarmor/asciiarmor.js b/data/ext/editorText/codemirror/mode/asciiarmor/asciiarmor.js
new file mode 100644
index 000000000..d83090376
--- /dev/null
+++ b/data/ext/editorText/codemirror/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/data/ext/editorText/codemirror/mode/asciiarmor/index.html b/data/ext/editorText/codemirror/mode/asciiarmor/index.html
new file mode 100644
index 000000000..8ba1b5c76
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/asciiarmor/index.html
@@ -0,0 +1,46 @@
+<!doctype html>
+
+<title>CodeMirror: ASCII Armor (PGP) mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="asciiarmor.js"></script>
+<style>.CodeMirror {background: #f8f8f8;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">ASCII Armor</a>
+ </ul>
+</div>
+
+<article>
+<h2>ASCII Armor (PGP) mode</h2>
+<form><textarea id="code" name="code">
+-----BEGIN PGP MESSAGE-----
+Version: OpenPrivacy 0.99
+
+yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS
+vBSFjNSiVHsuAA==
+=njUN
+-----END PGP MESSAGE-----
+</textarea></form>
+
+<script>
+var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true
+});
+</script>
+
+<p><strong>MIME types
+defined:</strong> <code>application/pgp</code>, <code>application/pgp-keys</code>, <code>application/pgp-signature</code></p>
+
+</article>
diff --git a/data/ext/editorText/codemirror/mode/asn.1/asn.1.js b/data/ext/editorText/codemirror/mode/asn.1/asn.1.js
new file mode 100644
index 000000000..9600247ea
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/asn.1/asn.1.js
@@ -0,0 +1,204 @@
+// 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";
+
+ CodeMirror.defineMode("asn.1", function(config, parserConfig) {
+ var indentUnit = config.indentUnit,
+ keywords = parserConfig.keywords || {},
+ cmipVerbs = parserConfig.cmipVerbs || {},
+ compareTypes = parserConfig.compareTypes || {},
+ status = parserConfig.status || {},
+ tags = parserConfig.tags || {},
+ storage = parserConfig.storage || {},
+ modifier = parserConfig.modifier || {},
+ accessTypes = parserConfig.accessTypes|| {},
+ multiLineStrings = parserConfig.multiLineStrings,
+ indentStatements = parserConfig.indentStatements !== false;
+ var isOperatorChar = /[\|\^]/;
+ var curPunc;
+
+ function tokenBase(stream, state) {
+ var ch = stream.next();
+ if (ch == '"' || ch == "'") {
+ state.tokenize = tokenString(ch);
+ return state.tokenize(stream, state);
+ }
+ if (/[\[\]\(\){}:=,;]/.test(ch)) {
+ curPunc = ch;
+ return "punctuation";
+ }
+ if (ch == "-"){
+ if (stream.eat("-")) {
+ stream.skipToEnd();
+ return "comment";
+ }
+ }
+ if (/\d/.test(ch)) {
+ stream.eatWhile(/[\w\.]/);
+ return "number";
+ }
+ if (isOperatorChar.test(ch)) {
+ stream.eatWhile(isOperatorChar);
+ return "operator";
+ }
+
+ stream.eatWhile(/[\w\-]/);
+ var cur = stream.current();
+ if (keywords.propertyIsEnumerable(cur)) return "keyword";
+ if (cmipVerbs.propertyIsEnumerable(cur)) return "variable cmipVerbs";
+ if (compareTypes.propertyIsEnumerable(cur)) return "atom compareTypes";
+ if (status.propertyIsEnumerable(cur)) return "comment status";
+ if (tags.propertyIsEnumerable(cur)) return "variable-3 tags";
+ if (storage.propertyIsEnumerable(cur)) return "builtin storage";
+ if (modifier.propertyIsEnumerable(cur)) return "string-2 modifier";
+ if (accessTypes.propertyIsEnumerable(cur)) return "atom accessTypes";
+
+ return "variable";
+ }
+
+ function tokenString(quote) {
+ return function(stream, state) {
+ var escaped = false, next, end = false;
+ while ((next = stream.next()) != null) {
+ if (next == quote && !escaped){
+ var afterNext = stream.peek();
+ //look if the character if the quote is like the B in '10100010'B
+ if (afterNext){
+ afterNext = afterNext.toLowerCase();
+ if(afterNext == "b" || afterNext == "h" || afterNext == "o")
+ stream.next();
+ }
+ end = true; break;
+ }
+ escaped = !escaped && next == "\\";
+ }
+ if (end || !(escaped || multiLineStrings))
+ state.tokenize = null;
+ return "string";
+ };
+ }
+
+ function Context(indented, column, type, align, prev) {
+ this.indented = indented;
+ this.column = column;
+ this.type = type;
+ this.align = align;
+ this.prev = prev;
+ }
+ function pushContext(state, col, type) {
+ var indent = state.indented;
+ if (state.context && state.context.type == "statement")
+ indent = state.context.indented;
+ return state.context = new Context(indent, col, type, null, state.context);
+ }
+ function popContext(state) {
+ var t = state.context.type;
+ if (t == ")" || t == "]" || t == "}")
+ state.indented = state.context.indented;
+ return state.context = state.context.prev;
+ }
+
+ //Interface
+ return {
+ startState: function(basecolumn) {
+ return {
+ tokenize: null,
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
+ indented: 0,
+ startOfLine: true
+ };
+ },
+
+ token: function(stream, state) {
+ var ctx = state.context;
+ if (stream.sol()) {
+ if (ctx.align == null) ctx.align = false;
+ state.indented = stream.indentation();
+ state.startOfLine = true;
+ }
+ if (stream.eatSpace()) return null;
+ curPunc = null;
+ var style = (state.tokenize || tokenBase)(stream, state);
+ if (style == "comment") return style;
+ if (ctx.align == null) ctx.align = true;
+
+ if ((curPunc == ";" || curPunc == ":" || curPunc == ",")
+ && ctx.type == "statement"){
+ popContext(state);
+ }
+ else if (curPunc == "{") pushContext(state, stream.column(), "}");
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
+ else if (curPunc == "}") {
+ while (ctx.type == "statement") ctx = popContext(state);
+ if (ctx.type == "}") ctx = popContext(state);
+ while (ctx.type == "statement") ctx = popContext(state);
+ }
+ else if (curPunc == ctx.type) popContext(state);
+ else if (indentStatements && (((ctx.type == "}" || ctx.type == "top")
+ && curPunc != ';') || (ctx.type == "statement"
+ && curPunc == "newstatement")))
+ pushContext(state, stream.column(), "statement");
+
+ state.startOfLine = false;
+ return style;
+ },
+
+ electricChars: "{}",
+ lineComment: "--",
+ fold: "brace"
+ };
+ });
+
+ function words(str) {
+ var obj = {}, words = str.split(" ");
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
+ return obj;
+ }
+
+ CodeMirror.defineMIME("text/x-ttcn-asn", {
+ name: "asn.1",
+ keywords: words("DEFINITIONS OBJECTS IF DERIVED INFORMATION ACTION" +
+ " REPLY ANY NAMED CHARACTERIZED BEHAVIOUR REGISTERED" +
+ " WITH AS IDENTIFIED CONSTRAINED BY PRESENT BEGIN" +
+ " IMPORTS FROM UNITS SYNTAX MIN-ACCESS MAX-ACCESS" +
+ " MINACCESS MAXACCESS REVISION STATUS DESCRIPTION" +
+ " SEQUENCE SET COMPONENTS OF CHOICE DistinguishedName" +
+ " ENUMERATED SIZE MODULE END INDEX AUGMENTS EXTENSIBILITY" +
+ " IMPLIED EXPORTS"),
+ cmipVerbs: words("ACTIONS ADD GET NOTIFICATIONS REPLACE REMOVE"),
+ compareTypes: words("OPTIONAL DEFAULT MANAGED MODULE-TYPE MODULE_IDENTITY" +
+ " MODULE-COMPLIANCE OBJECT-TYPE OBJECT-IDENTITY" +
+ " OBJECT-COMPLIANCE MODE CONFIRMED CONDITIONAL" +
+ " SUBORDINATE SUPERIOR CLASS TRUE FALSE NULL" +
+ " TEXTUAL-CONVENTION"),
+ status: words("current deprecated mandatory obsolete"),
+ tags: words("APPLICATION AUTOMATIC EXPLICIT IMPLICIT PRIVATE TAGS" +
+ " UNIVERSAL"),
+ storage: words("BOOLEAN INTEGER OBJECT IDENTIFIER BIT OCTET STRING" +
+ " UTCTime InterfaceIndex IANAifType CMIP-Attribute" +
+ " REAL PACKAGE PACKAGES IpAddress PhysAddress" +
+ " NetworkAddress BITS BMPString TimeStamp TimeTicks" +
+ " TruthValue RowStatus DisplayString GeneralString" +
+ " GraphicString IA5String NumericString" +
+ " PrintableString SnmpAdminAtring TeletexString" +
+ " UTF8String VideotexString VisibleString StringStore" +
+ " ISO646String T61String UniversalString Unsigned32" +
+ " Integer32 Gauge Gauge32 Counter Counter32 Counter64"),
+ modifier: words("ATTRIBUTE ATTRIBUTES MANDATORY-GROUP MANDATORY-GROUPS" +
+ " GROUP GROUPS ELEMENTS EQUALITY ORDERING SUBSTRINGS" +
+ " DEFINED"),
+ accessTypes: words("not-accessible accessible-for-notify read-only" +
+ " read-create read-write"),
+ multiLineStrings: true
+ });
+});
diff --git a/data/ext/editorText/codemirror/mode/asn.1/index.html b/data/ext/editorText/codemirror/mode/asn.1/index.html
new file mode 100644
index 000000000..8346f8e50
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/asn.1/index.html
@@ -0,0 +1,78 @@
+<!doctype html>
+
+<title>CodeMirror: ASN.1 mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="asn.1.js"></script>
+<style type="text/css">
+ .CodeMirror {
+ border-top: 1px solid black;
+ border-bottom: 1px solid black;
+ }
+</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1>
+ <img id=logo src="../../doc/logo.png">
+ </a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One">ASN.1</a>
+ </ul>
+</div>
+<article>
+ <h2>ASN.1 example</h2>
+ <div>
+ <textarea id="ttcn-asn-code">
+ --
+ -- Sample ASN.1 Code
+ --
+ MyModule DEFINITIONS ::=
+ BEGIN
+
+ MyTypes ::= SEQUENCE {
+ myObjectId OBJECT IDENTIFIER,
+ mySeqOf SEQUENCE OF MyInt,
+ myBitString BIT STRING {
+ muxToken(0),
+ modemToken(1)
+ }
+ }
+
+ MyInt ::= INTEGER (0..65535)
+
+ END
+ </textarea>
+ </div>
+
+ <script>
+ var ttcnEditor = CodeMirror.fromTextArea(document.getElementById("ttcn-asn-code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-ttcn-asn"
+ });
+ ttcnEditor.setSize(400, 400);
+ var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
+ CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
+ </script>
+ <br/>
+ <p><strong>Language:</strong> Abstract Syntax Notation One
+ (<a href="http://www.itu.int/en/ITU-T/asn1/Pages/introduction.aspx">ASN.1</a>)
+ </p>
+ <p><strong>MIME types defined:</strong> <code>text/x-ttcn-asn</code></p>
+
+ <br/>
+ <p>The development of this mode has been sponsored by <a href="http://www.ericsson.com/">Ericsson
+ </a>.</p>
+ <p>Coded by Asmelash Tsegay Gebretsadkan </p>
+ </article>
+</article>
+
diff --git a/data/ext/editorText/codemirror/mode/asterisk/asterisk.js b/data/ext/editorText/codemirror/mode/asterisk/asterisk.js
index 60b689d1d..b7ebfc5ad 100644
--- a/data/ext/editorText/codemirror/mode/asterisk/asterisk.js
+++ b/data/ext/editorText/codemirror/mode/asterisk/asterisk.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/*
* =====================================================================================
*
@@ -14,6 +17,16 @@
* =====================================================================================
*/
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("asterisk", function() {
var atoms = ["exten", "same", "include","ignorepat","switch"],
dpcmd = ["#include","#exec"],
@@ -52,8 +65,7 @@ CodeMirror.defineMode("asterisk", function() {
function basicToken(stream,state){
var cur = '';
- var ch = '';
- ch = stream.next();
+ var ch = stream.next();
// comment
if(ch == ";") {
stream.skipToEnd();
@@ -123,7 +135,6 @@ CodeMirror.defineMode("asterisk", function() {
token: function(stream, state) {
var cur = '';
- var ch = '';
if(stream.eatSpace()) return null;
// extension started
if(state.extenStart){
@@ -157,7 +168,7 @@ CodeMirror.defineMode("asterisk", function() {
} else if(state.extenPriority) {
state.extenPriority = false;
state.extenApplication = true;
- ch = stream.next(); // get comma
+ stream.next(); // get comma
if(state.extenSame) return null;
stream.eatWhile(/[^,]/);
return "number";
@@ -181,3 +192,5 @@ CodeMirror.defineMode("asterisk", function() {
});
CodeMirror.defineMIME("text/x-asterisk", "asterisk");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/asterisk/index.html b/data/ext/editorText/codemirror/mode/asterisk/index.html
index 6abdecb50..257bd3987 100644
--- a/data/ext/editorText/codemirror/mode/asterisk/index.html
+++ b/data/ext/editorText/codemirror/mode/asterisk/index.html
@@ -12,12 +12,12 @@
.cm-s-default span.cm-arrow { color: red; }
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/brainfuck/brainfuck.js b/data/ext/editorText/codemirror/mode/brainfuck/brainfuck.js
new file mode 100644
index 000000000..3becf2a5a
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/brainfuck/brainfuck.js
@@ -0,0 +1,85 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Brainfuck mode created by Michael Kaminsky https://github.com/mkaminsky11
+
+(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"
+ var reserve = "><+-.,[]".split("");
+ /*
+ comments can be either:
+ placed behind lines
+
+ +++ this is a comment
+
+ where reserved characters cannot be used
+ or in a loop
+ [
+ this is ok to use [ ] and stuff
+ ]
+ or preceded by #
+ */
+ CodeMirror.defineMode("brainfuck", function() {
+ return {
+ startState: function() {
+ return {
+ commentLine: false,
+ left: 0,
+ right: 0,
+ commentLoop: false
+ }
+ },
+ token: function(stream, state) {
+ if (stream.eatSpace()) return null
+ if(stream.sol()){
+ state.commentLine = false;
+ }
+ var ch = stream.next().toString();
+ if(reserve.indexOf(ch) !== -1){
+ if(state.commentLine === true){
+ if(stream.eol()){
+ state.commentLine = false;
+ }
+ return "comment";
+ }
+ if(ch === "]" || ch === "["){
+ if(ch === "["){
+ state.left++;
+ }
+ else{
+ state.right++;
+ }
+ return "bracket";
+ }
+ else if(ch === "+" || ch === "-"){
+ return "keyword";
+ }
+ else if(ch === "<" || ch === ">"){
+ return "atom";
+ }
+ else if(ch === "." || ch === ","){
+ return "def";
+ }
+ }
+ else{
+ state.commentLine = true;
+ if(stream.eol()){
+ state.commentLine = false;
+ }
+ return "comment";
+ }
+ if(stream.eol()){
+ state.commentLine = false;
+ }
+ }
+ };
+ });
+CodeMirror.defineMIME("text/x-brainfuck","brainfuck")
+});
diff --git a/data/ext/editorText/codemirror/mode/brainfuck/index.html b/data/ext/editorText/codemirror/mode/brainfuck/index.html
new file mode 100644
index 000000000..6048fc241
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/brainfuck/index.html
@@ -0,0 +1,85 @@
+<!doctype html>
+
+<title>CodeMirror: Brainfuck mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/edit/matchbrackets.js"></script>
+<script src="./brainfuck.js"></script>
+<style>
+ .CodeMirror { border: 2px inset #dee; }
+ </style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#"></a>
+ </ul>
+</div>
+
+<article>
+<h2>Brainfuck mode</h2>
+<form><textarea id="code" name="code">
+[ This program prints "Hello World!" and a newline to the screen, its
+ length is 106 active command characters [it is not the shortest.]
+
+ This loop is a "comment loop", it's a simple way of adding a comment
+ to a BF program such that you don't have to worry about any command
+ characters. Any ".", ",", "+", "-", "&lt;" and "&gt;" characters are simply
+ ignored, the "[" and "]" characters just have to be balanced.
+]
++++++ +++ Set Cell #0 to 8
+[
+ &gt;++++ Add 4 to Cell #1; this will always set Cell #1 to 4
+ [ as the cell will be cleared by the loop
+ &gt;++ Add 2 to Cell #2
+ &gt;+++ Add 3 to Cell #3
+ &gt;+++ Add 3 to Cell #4
+ &gt;+ Add 1 to Cell #5
+ &lt;&lt;&lt;&lt;- Decrement the loop counter in Cell #1
+ ] Loop till Cell #1 is zero; number of iterations is 4
+ &gt;+ Add 1 to Cell #2
+ &gt;+ Add 1 to Cell #3
+ &gt;- Subtract 1 from Cell #4
+ &gt;&gt;+ Add 1 to Cell #6
+ [&lt;] Move back to the first zero cell you find; this will
+ be Cell #1 which was cleared by the previous loop
+ &lt;- Decrement the loop Counter in Cell #0
+] Loop till Cell #0 is zero; number of iterations is 8
+
+The result of this is:
+Cell No : 0 1 2 3 4 5 6
+Contents: 0 0 72 104 88 32 8
+Pointer : ^
+
+&gt;&gt;. Cell #2 has value 72 which is 'H'
+&gt;---. Subtract 3 from Cell #3 to get 101 which is 'e'
++++++++..+++. Likewise for 'llo' from Cell #3
+&gt;&gt;. Cell #5 is 32 for the space
+&lt;-. Subtract 1 from Cell #4 for 87 to give a 'W'
+&lt;. Cell #3 was set to 'o' from the end of 'Hello'
++++.------.--------. Cell #3 for 'rl' and 'd'
+&gt;&gt;+. Add 1 to Cell #5 gives us an exclamation point
+&gt;++. And finally a newline from Cell #6
+</textarea></form>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-brainfuck"
+ });
+ </script>
+
+ <p>A mode for Brainfuck</p>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-brainfuck</code></p>
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/clike/clike.js b/data/ext/editorText/codemirror/mode/clike/clike.js
index 2ba1a9080..603e48ce4 100644
--- a/data/ext/editorText/codemirror/mode/clike/clike.js
+++ b/data/ext/editorText/codemirror/mode/clike/clike.js
@@ -1,16 +1,37 @@
+// 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";
+
CodeMirror.defineMode("clike", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
dontAlignCalls = parserConfig.dontAlignCalls,
keywords = parserConfig.keywords || {},
+ types = parserConfig.types || {},
builtin = parserConfig.builtin || {},
blockKeywords = parserConfig.blockKeywords || {},
+ defKeywords = parserConfig.defKeywords || {},
atoms = parserConfig.atoms || {},
hooks = parserConfig.hooks || {},
- multiLineStrings = parserConfig.multiLineStrings;
- var isOperatorChar = /[+\-*&%=<>!?|\/]/;
+ multiLineStrings = parserConfig.multiLineStrings,
+ indentStatements = parserConfig.indentStatements !== false,
+ indentSwitch = parserConfig.indentSwitch !== false,
+ namespaceSeparator = parserConfig.namespaceSeparator,
+ isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/,
+ isNumberChar = parserConfig.isNumberChar || /\d/,
+ isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
+ endStatement = parserConfig.endStatement || /^[;:,]$/;
- var curPunc;
+ var curPunc, isDefKeyword;
function tokenBase(stream, state) {
var ch = stream.next();
@@ -22,11 +43,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
}
- if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
+ if (isPunctuationChar.test(ch)) {
curPunc = ch;
return null;
}
- if (/\d/.test(ch)) {
+ if (isNumberChar.test(ch)) {
stream.eatWhile(/[\w\.]/);
return "number";
}
@@ -44,17 +65,22 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
stream.eatWhile(isOperatorChar);
return "operator";
}
- stream.eatWhile(/[\w\$_]/);
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/);
+ if (namespaceSeparator) while (stream.match(namespaceSeparator))
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/);
+
var cur = stream.current();
- if (keywords.propertyIsEnumerable(cur)) {
- if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
+ if (contains(keywords, cur)) {
+ if (contains(blockKeywords, cur)) curPunc = "newstatement";
+ if (contains(defKeywords, cur)) isDefKeyword = true;
return "keyword";
}
- if (builtin.propertyIsEnumerable(cur)) {
- if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
+ if (contains(types, cur)) return "variable-3";
+ if (contains(builtin, cur)) {
+ if (contains(blockKeywords, cur)) curPunc = "newstatement";
return "builtin";
}
- if (atoms.propertyIsEnumerable(cur)) return "atom";
+ if (contains(atoms, cur)) return "atom";
return "variable";
}
@@ -90,9 +116,12 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
this.align = align;
this.prev = prev;
}
+ function isStatement(type) {
+ return type == "statement" || type == "switchstatement" || type == "namespace";
+ }
function pushContext(state, col, type) {
var indent = state.indented;
- if (state.context && state.context.type == "statement")
+ if (state.context && isStatement(state.context.type) && !isStatement(type))
indent = state.context.indented;
return state.context = new Context(indent, col, type, null, state.context);
}
@@ -103,6 +132,19 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
return state.context = state.context.prev;
}
+ function typeBefore(stream, state) {
+ if (state.prevToken == "variable" || state.prevToken == "variable-3") return true;
+ if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, stream.start))) return true;
+ }
+
+ function isTopScope(context) {
+ for (;;) {
+ if (!context || context.type == "top") return true;
+ if (context.type == "}" && context.prev.type != "namespace") return false;
+ context = context.prev;
+ }
+ }
+
// Interface
return {
@@ -111,7 +153,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
tokenize: null,
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
indented: 0,
- startOfLine: true
+ startOfLine: true,
+ prevToken: null
};
},
@@ -123,39 +166,72 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
state.startOfLine = true;
}
if (stream.eatSpace()) return null;
- curPunc = null;
+ curPunc = isDefKeyword = null;
var style = (state.tokenize || tokenBase)(stream, state);
if (style == "comment" || style == "meta") return style;
if (ctx.align == null) ctx.align = true;
- if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
+ if (endStatement.test(curPunc)) while (isStatement(state.context.type)) popContext(state);
else if (curPunc == "{") pushContext(state, stream.column(), "}");
else if (curPunc == "[") pushContext(state, stream.column(), "]");
else if (curPunc == "(") pushContext(state, stream.column(), ")");
else if (curPunc == "}") {
- while (ctx.type == "statement") ctx = popContext(state);
+ while (isStatement(ctx.type)) ctx = popContext(state);
if (ctx.type == "}") ctx = popContext(state);
- while (ctx.type == "statement") ctx = popContext(state);
+ while (isStatement(ctx.type)) ctx = popContext(state);
}
else if (curPunc == ctx.type) popContext(state);
- else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
- pushContext(state, stream.column(), "statement");
+ else if (indentStatements &&
+ (((ctx.type == "}" || ctx.type == "top") && curPunc != ";") ||
+ (isStatement(ctx.type) && curPunc == "newstatement"))) {
+ var type = "statement";
+ if (curPunc == "newstatement" && indentSwitch && stream.current() == "switch")
+ type = "switchstatement";
+ else if (style == "keyword" && stream.current() == "namespace")
+ type = "namespace";
+ pushContext(state, stream.column(), type);
+ }
+
+ if (style == "variable" &&
+ ((state.prevToken == "def" ||
+ (parserConfig.typeFirstDefinitions && typeBefore(stream, state) &&
+ isTopScope(state.context) && stream.match(/^\s*\(/, false)))))
+ style = "def";
+
+ if (hooks.token) {
+ var result = hooks.token(stream, state, style);
+ if (result !== undefined) style = result;
+ }
+
+ if (style == "def" && parserConfig.styleDefs === false) style = "variable";
+
state.startOfLine = false;
+ state.prevToken = isDefKeyword ? "def" : style || curPunc;
return style;
},
indent: function(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
- if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
+ if (isStatement(ctx.type) && firstChar == "}") ctx = ctx.prev;
+ if (hooks.indent) {
+ var hook = hooks.indent(state, ctx, textAfter);
+ if (typeof hook == "number") return hook
+ }
var closing = firstChar == ctx.type;
- if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
- else if (ctx.align && (!dontAlignCalls || ctx.type != ")")) return ctx.column + (closing ? 0 : 1);
- else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
- else return ctx.indented + (closing ? 0 : indentUnit);
+ var switchBlock = ctx.prev && ctx.prev.type == "switchstatement";
+ if (isStatement(ctx.type))
+ return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
+ if (ctx.align && (!dontAlignCalls || ctx.type != ")"))
+ return ctx.column + (closing ? 0 : 1);
+ if (ctx.type == ")" && !closing)
+ return ctx.indented + statementIndentUnit;
+
+ return ctx.indented + (closing ? 0 : indentUnit) +
+ (!closing && switchBlock && !/^(?:case|default)\b/.test(textAfter) ? indentUnit : 0);
},
- electricChars: "{}",
+ electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/,
blockCommentStart: "/*",
blockCommentEnd: "*/",
lineComment: "//",
@@ -163,15 +239,22 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
};
});
-(function() {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
- var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
- "double static else struct entry switch extern typedef float union for unsigned " +
- "goto while enum void const signed volatile";
+ function contains(words, word) {
+ if (typeof words === "function") {
+ return words(word);
+ } else {
+ return words.propertyIsEnumerable(word);
+ }
+ }
+ var cKeywords = "auto if break case register continue return default do sizeof " +
+ "static else struct switch extern typedef float union for " +
+ "goto while enum const volatile";
+ var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t";
function cppHook(stream, state) {
if (!state.startOfLine) return false;
@@ -191,11 +274,21 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
return "meta";
}
+ function pointerHook(_stream, state) {
+ if (state.prevToken == "variable-3") return "variable-3";
+ return false;
+ }
+
+ function cpp14Literal(stream) {
+ stream.eatWhile(/[\w\.']/);
+ return "number";
+ }
+
function cpp11StringHook(stream, state) {
stream.backUp(1);
// Raw strings.
if (stream.match(/(R|u8R|uR|UR|LR)/)) {
- var match = stream.match(/"(.{0,16})\(/);
+ var match = stream.match(/"([^\s\\()]{0,16})\(/);
if (!match) {
return false;
}
@@ -215,6 +308,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
return false;
}
+ function cppLooksLikeConstructor(word) {
+ var lastTwo = /(\w+)::(\w+)$/.exec(word);
+ return lastTwo && lastTwo[1] == lastTwo[2];
+ }
+
// C#-style strings where "" escapes a quote.
function tokenAtString(stream, state) {
var next;
@@ -230,13 +328,13 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
// C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where
// <delim> can be a string up to 16 characters long.
function tokenRawString(stream, state) {
- var closingSequence = new RegExp(".*?\\)" + state.cpp11RawStringDelim + '"');
- var match = stream.match(closingSequence);
- if (match) {
+ // Escape characters that have special regex meanings.
+ var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&');
+ var match = stream.match(new RegExp(".*?\\)" + delim + '"'));
+ if (match)
state.tokenize = null;
- } else {
+ else
stream.skipToEnd();
- }
return "string";
}
@@ -248,6 +346,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
words.push(prop);
}
add(mode.keywords);
+ add(mode.types);
add(mode.builtin);
add(mode.atoms);
if (words.length) {
@@ -262,39 +361,72 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
name: "clike",
keywords: words(cKeywords),
+ types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " +
+ "int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " +
+ "uint32_t uint64_t"),
blockKeywords: words("case do else for if switch while struct"),
- atoms: words("null"),
- hooks: {"#": cppHook},
+ defKeywords: words("struct"),
+ typeFirstDefinitions: true,
+ atoms: words("null true false"),
+ hooks: {"#": cppHook, "*": pointerHook},
modeProps: {fold: ["brace", "include"]}
});
def(["text/x-c++src", "text/x-c++hdr"], {
name: "clike",
- keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
+ keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " +
"static_cast typeid catch operator template typename class friend private " +
"this using const_cast inline public throw virtual delete mutable protected " +
- "wchar_t alignas alignof constexpr decltype nullptr noexcept thread_local final " +
+ "alignas alignof constexpr decltype nullptr noexcept thread_local final " +
"static_assert override"),
+ types: words(cTypes + " bool wchar_t"),
blockKeywords: words("catch class do else finally for if struct switch try while"),
+ defKeywords: words("class namespace struct enum union"),
+ typeFirstDefinitions: true,
atoms: words("true false null"),
hooks: {
"#": cppHook,
+ "*": pointerHook,
"u": cpp11StringHook,
"U": cpp11StringHook,
"L": cpp11StringHook,
- "R": cpp11StringHook
+ "R": cpp11StringHook,
+ "0": cpp14Literal,
+ "1": cpp14Literal,
+ "2": cpp14Literal,
+ "3": cpp14Literal,
+ "4": cpp14Literal,
+ "5": cpp14Literal,
+ "6": cpp14Literal,
+ "7": cpp14Literal,
+ "8": cpp14Literal,
+ "9": cpp14Literal,
+ token: function(stream, state, style) {
+ if (style == "variable" && stream.peek() == "(" &&
+ (state.prevToken == ";" || state.prevToken == null ||
+ state.prevToken == "}") &&
+ cppLooksLikeConstructor(stream.current()))
+ return "def";
+ }
},
+ namespaceSeparator: "::",
modeProps: {fold: ["brace", "include"]}
});
+
def("text/x-java", {
name: "clike",
- keywords: words("abstract assert boolean break byte case catch char class const continue default " +
- "do double else enum extends final finally float for goto if implements import " +
- "instanceof int interface long native new package private protected public " +
- "return short static strictfp super switch synchronized this throw throws transient " +
- "try void volatile while"),
+ keywords: words("abstract assert break case catch class const continue default " +
+ "do else enum extends final finally float for goto if implements import " +
+ "instanceof interface native new package private protected public " +
+ "return static strictfp super switch synchronized this throw throws transient " +
+ "try volatile while"),
+ types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " +
+ "Integer Long Number Object Short String StringBuffer StringBuilder Void"),
blockKeywords: words("catch class do else finally for if switch try while"),
+ defKeywords: words("class interface package enum"),
+ typeFirstDefinitions: true,
atoms: words("true false null"),
+ endStatement: /^[;:]$/,
hooks: {
"@": function(stream) {
stream.eatWhile(/[\w\$_]/);
@@ -303,20 +435,23 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
},
modeProps: {fold: ["brace", "import"]}
});
+
def("text/x-csharp", {
name: "clike",
- keywords: words("abstract as base break case catch checked class const continue" +
+ keywords: words("abstract as async await base break case catch checked class const continue" +
" default delegate do else enum event explicit extern finally fixed for" +
" foreach goto if implicit in interface internal is lock namespace new" +
" operator out override params private protected public readonly ref return sealed" +
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
" global group into join let orderby partial remove select set value var yield"),
+ types: words("Action Boolean Byte Char DateTime DateTimeOffset Decimal Double Func" +
+ " Guid Int16 Int32 Int64 Object SByte Single String Task TimeSpan UInt16 UInt32" +
+ " UInt64 bool byte char decimal double short int long object" +
+ " sbyte float string ushort uint ulong"),
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
- builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
- " Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
- " UInt64 bool byte char decimal double short int long object" +
- " sbyte float string ushort uint ulong"),
+ defKeywords: words("class interface namespace struct var"),
+ typeFirstDefinitions: true,
atoms: words("true false null"),
hooks: {
"@": function(stream, state) {
@@ -329,58 +464,115 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
}
}
});
+
+ function tokenTripleString(stream, state) {
+ var escaped = false;
+ while (!stream.eol()) {
+ if (!escaped && stream.match('"""')) {
+ state.tokenize = null;
+ break;
+ }
+ escaped = stream.next() == "\\" && !escaped;
+ }
+ return "string";
+ }
+
def("text/x-scala", {
name: "clike",
keywords: words(
/* scala */
- "abstract case catch class def do else extends false final finally for forSome if " +
+ "abstract case catch class def do else extends final finally for forSome if " +
"implicit import lazy match new null object override package private protected return " +
- "sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
+ "sealed super this throw trait try type val var while with yield _ : = => <- <: " +
"<% >: # @ " +
/* package scala */
"assert assume require print println printf readLine readBoolean readByte readShort " +
"readChar readInt readLong readFloat readDouble " +
+ ":: #:: "
+ ),
+ types: words(
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
- "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
+ "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " +
/* package java.lang */
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
-
-
),
+ multiLineStrings: true,
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
+ defKeywords: words("class def object package trait type val var"),
atoms: words("true false null"),
+ indentStatements: false,
+ indentSwitch: false,
hooks: {
"@": function(stream) {
stream.eatWhile(/[\w\$_]/);
return "meta";
+ },
+ '"': function(stream, state) {
+ if (!stream.match('""')) return false;
+ state.tokenize = tokenTripleString;
+ return state.tokenize(stream, state);
+ },
+ "'": function(stream) {
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/);
+ return "atom";
}
- }
+ },
+ modeProps: {closeBrackets: {triples: '"'}}
+ });
+
+ def("text/x-kotlin", {
+ name: "clike",
+ keywords: words(
+ /*keywords*/
+ "package as typealias class interface this super val " +
+ "var fun for is in This throw return " +
+ "break continue object if else while do try when !in !is as?" +
+
+ /*soft keywords*/
+ "file import where by get set abstract enum open inner override private public internal " +
+ "protected catch finally out final vararg reified dynamic companion constructor init " +
+ "sealed field property receiver param sparam lateinit data inline noinline tailrec " +
+ "external annotation crossinline"
+ ),
+ types: words(
+ /* package java.lang */
+ "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
+ "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
+ "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
+ "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
+ ),
+ multiLineStrings: true,
+ blockKeywords: words("catch class do else finally for if where try while enum"),
+ defKeywords: words("class val var object package interface fun"),
+ atoms: words("true false null this"),
+ modeProps: {closeBrackets: {triples: '"'}}
});
+
def(["x-shader/x-vertex", "x-shader/x-fragment"], {
name: "clike",
- keywords: words("float int bool void " +
- "vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
- "mat2 mat3 mat4 " +
- "sampler1D sampler2D sampler3D samplerCube " +
- "sampler1DShadow sampler2DShadow" +
+ keywords: words("sampler1D sampler2D sampler3D samplerCube " +
+ "sampler1DShadow sampler2DShadow " +
"const attribute uniform varying " +
"break continue discard return " +
"for while do if else struct " +
"in out inout"),
+ types: words("float int bool void " +
+ "vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
+ "mat2 mat3 mat4"),
blockKeywords: words("for while do if else struct"),
builtin: words("radians degrees sin cos tan asin acos atan " +
"pow exp log exp2 sqrt inversesqrt " +
- "abs sign floor ceil fract mod min max clamp mix step smootstep " +
+ "abs sign floor ceil fract mod min max clamp mix step smoothstep " +
"length distance dot cross normalize ftransform faceforward " +
"reflect refract matrixCompMult " +
"lessThan lessThanEqual greaterThan greaterThanEqual " +
@@ -397,12 +589,12 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
- "gl_FogCoord " +
+ "gl_FogCoord gl_PointCoord " +
"gl_Position gl_PointSize gl_ClipVertex " +
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
"gl_TexCoord gl_FogFragCoord " +
"gl_FragCoord gl_FrontFacing " +
- "gl_FragColor gl_FragData gl_FragDepth " +
+ "gl_FragData gl_FragDepth " +
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
@@ -420,7 +612,133 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
"gl_MaxDrawBuffers"),
+ indentSwitch: false,
+ hooks: {"#": cppHook},
+ modeProps: {fold: ["brace", "include"]}
+ });
+
+ def("text/x-nesc", {
+ name: "clike",
+ keywords: words(cKeywords + "as atomic async call command component components configuration event generic " +
+ "implementation includes interface module new norace nx_struct nx_union post provides " +
+ "signal task uses abstract extends"),
+ types: words(cTypes),
+ blockKeywords: words("case do else for if switch while struct"),
+ atoms: words("null true false"),
+ hooks: {"#": cppHook},
+ modeProps: {fold: ["brace", "include"]}
+ });
+
+ def("text/x-objectivec", {
+ name: "clike",
+ keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginery BOOL Class bycopy byref id IMP in " +
+ "inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"),
+ types: words(cTypes),
+ atoms: words("YES NO NULL NILL ON OFF true false"),
+ hooks: {
+ "@": function(stream) {
+ stream.eatWhile(/[\w\$]/);
+ return "keyword";
+ },
+ "#": cppHook,
+ indent: function(_state, ctx, textAfter) {
+ if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented
+ }
+ },
+ modeProps: {fold: "brace"}
+ });
+
+ def("text/x-squirrel", {
+ name: "clike",
+ keywords: words("base break clone continue const default delete enum extends function in class" +
+ " foreach local resume return this throw typeof yield constructor instanceof static"),
+ types: words(cTypes),
+ blockKeywords: words("case catch class else for foreach if switch try while"),
+ defKeywords: words("function local class"),
+ typeFirstDefinitions: true,
+ atoms: words("true false null"),
hooks: {"#": cppHook},
modeProps: {fold: ["brace", "include"]}
});
-}());
+
+ // Ceylon Strings need to deal with interpolation
+ var stringTokenizer = null;
+ function tokenCeylonString(type) {
+ return function(stream, state) {
+ var escaped = false, next, end = false;
+ while (!stream.eol()) {
+ if (!escaped && stream.match('"') &&
+ (type == "single" || stream.match('""'))) {
+ end = true;
+ break;
+ }
+ if (!escaped && stream.match('``')) {
+ stringTokenizer = tokenCeylonString(type);
+ end = true;
+ break;
+ }
+ next = stream.next();
+ escaped = type == "single" && !escaped && next == "\\";
+ }
+ if (end)
+ state.tokenize = null;
+ return "string";
+ }
+ }
+
+ def("text/x-ceylon", {
+ name: "clike",
+ keywords: words("abstracts alias assembly assert assign break case catch class continue dynamic else" +
+ " exists extends finally for function given if import in interface is let module new" +
+ " nonempty object of out outer package return satisfies super switch then this throw" +
+ " try value void while"),
+ types: function(word) {
+ // In Ceylon all identifiers that start with an uppercase are types
+ var first = word.charAt(0);
+ return (first === first.toUpperCase() && first !== first.toLowerCase());
+ },
+ blockKeywords: words("case catch class dynamic else finally for function if interface module new object switch try while"),
+ defKeywords: words("class dynamic function interface module object package value"),
+ builtin: words("abstract actual aliased annotation by default deprecated doc final formal late license" +
+ " native optional sealed see serializable shared suppressWarnings tagged throws variable"),
+ isPunctuationChar: /[\[\]{}\(\),;\:\.`]/,
+ isOperatorChar: /[+\-*&%=<>!?|^~:\/]/,
+ isNumberChar: /[\d#$]/,
+ multiLineStrings: true,
+ typeFirstDefinitions: true,
+ atoms: words("true false null larger smaller equal empty finished"),
+ indentSwitch: false,
+ styleDefs: false,
+ hooks: {
+ "@": function(stream) {
+ stream.eatWhile(/[\w\$_]/);
+ return "meta";
+ },
+ '"': function(stream, state) {
+ state.tokenize = tokenCeylonString(stream.match('""') ? "triple" : "single");
+ return state.tokenize(stream, state);
+ },
+ '`': function(stream, state) {
+ if (!stringTokenizer || !stream.match('`')) return false;
+ state.tokenize = stringTokenizer;
+ stringTokenizer = null;
+ return state.tokenize(stream, state);
+ },
+ "'": function(stream) {
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/);
+ return "atom";
+ },
+ token: function(_stream, state, style) {
+ if ((style == "variable" || style == "variable-3") &&
+ state.prevToken == ".") {
+ return "variable-2";
+ }
+ }
+ },
+ modeProps: {
+ fold: ["brace", "import"],
+ closeBrackets: {triples: '"'}
+ }
+ });
+
+});
diff --git a/data/ext/editorText/codemirror/mode/clike/index.html b/data/ext/editorText/codemirror/mode/clike/index.html
index d892fddbd..45c670ae5 100644
--- a/data/ext/editorText/codemirror/mode/clike/index.html
+++ b/data/ext/editorText/codemirror/mode/clike/index.html
@@ -7,15 +7,17 @@
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
+<link rel="stylesheet" href="../../addon/hint/show-hint.css">
+<script src="../../addon/hint/show-hint.js"></script>
<script src="clike.js"></script>
<style>.CodeMirror {border: 2px inset #dee;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -137,6 +139,26 @@ void Class::Method2(MyType<T, V>* value) {
}
</textarea></div>
+<h2>Objective-C example</h2>
+
+<div><textarea id="objectivec-code">
+/*
+This is a longer comment
+That spans two lines
+*/
+
+#import <Test/Test.h>
+@implementation YourAppDelegate
+
+// This is a one-line comment
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
+ char myString[] = "This is a C character array";
+ int test = 5;
+ return YES;
+}
+</textarea></div>
+
<h2>Java example</h2>
<div><textarea id="java-code">
@@ -169,6 +191,118 @@ public class Class<T, V> implements MyInterface {
}
</textarea></div>
+<h2>Scala example</h2>
+
+<div><textarea id="scala-code">
+object FilterTest extends App {
+ def filter(xs: List[Int], threshold: Int) = {
+ def process(ys: List[Int]): List[Int] =
+ if (ys.isEmpty) ys
+ else if (ys.head < threshold) ys.head :: process(ys.tail)
+ else process(ys.tail)
+ process(xs)
+ }
+ println(filter(List(1, 9, 2, 8, 3, 7, 4), 5))
+}
+</textarea></div>
+
+<h2>Kotlin mode</h2>
+
+<div><textarea id="kotlin-code">
+package org.wasabi.http
+
+import java.util.concurrent.Executors
+import java.net.InetSocketAddress
+import org.wasabi.app.AppConfiguration
+import io.netty.bootstrap.ServerBootstrap
+import io.netty.channel.nio.NioEventLoopGroup
+import io.netty.channel.socket.nio.NioServerSocketChannel
+import org.wasabi.app.AppServer
+
+public class HttpServer(private val appServer: AppServer) {
+
+ val bootstrap: ServerBootstrap
+ val primaryGroup: NioEventLoopGroup
+ val workerGroup: NioEventLoopGroup
+
+ init {
+ // Define worker groups
+ primaryGroup = NioEventLoopGroup()
+ workerGroup = NioEventLoopGroup()
+
+ // Initialize bootstrap of server
+ bootstrap = ServerBootstrap()
+
+ bootstrap.group(primaryGroup, workerGroup)
+ bootstrap.channel(javaClass<NioServerSocketChannel>())
+ bootstrap.childHandler(NettyPipelineInitializer(appServer))
+ }
+
+ public fun start(wait: Boolean = true) {
+ val channel = bootstrap.bind(appServer.configuration.port)?.sync()?.channel()
+
+ if (wait) {
+ channel?.closeFuture()?.sync()
+ }
+ }
+
+ public fun stop() {
+ // Shutdown all event loops
+ primaryGroup.shutdownGracefully()
+ workerGroup.shutdownGracefully()
+
+ // Wait till all threads are terminated
+ primaryGroup.terminationFuture().sync()
+ workerGroup.terminationFuture().sync()
+ }
+}
+</textarea></div>
+
+<h2>Ceylon mode</h2>
+
+<div><textarea id="ceylon-code">
+"Produces the [[stream|Iterable]] that results from repeated
+ application of the given [[function|next]] to the given
+ [[first]] element of the stream, until the function first
+ returns [[finished]]. If the given function never returns
+ `finished`, the resulting stream is infinite.
+
+ For example:
+
+ loop(0)(2.plus).takeWhile(10.largerThan)
+
+ produces the stream `{ 0, 2, 4, 6, 8 }`."
+tagged("Streams")
+shared {Element+} loop&lt;Element&gt;(
+ "The first element of the resulting stream."
+ Element first)(
+ "The function that produces the next element of the
+ stream, given the current element. The function may
+ return [[finished]] to indicate the end of the
+ stream."
+ Element|Finished next(Element element))
+ =&gt; let (start = first)
+ object satisfies {Element+} {
+ first =&gt; start;
+ empty =&gt; false;
+ function nextElement(Element element)
+ =&gt; next(element);
+ iterator()
+ =&gt; object satisfies Iterator&lt;Element&gt; {
+ variable Element|Finished current = start;
+ shared actual Element|Finished next() {
+ if (!is Finished result = current) {
+ current = nextElement(result);
+ return result;
+ }
+ else {
+ return finished;
+ }
+ }
+ };
+ };
+</textarea></div>
+
<script>
var cEditor = CodeMirror.fromTextArea(document.getElementById("c-code"), {
lineNumbers: true,
@@ -185,6 +319,28 @@ public class Class<T, V> implements MyInterface {
matchBrackets: true,
mode: "text/x-java"
});
+ var objectivecEditor = CodeMirror.fromTextArea(document.getElementById("objectivec-code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-objectivec"
+ });
+ var scalaEditor = CodeMirror.fromTextArea(document.getElementById("scala-code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-scala"
+ });
+ var kotlinEditor = CodeMirror.fromTextArea(document.getElementById("kotlin-code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-kotlin"
+ });
+ var ceylonEditor = CodeMirror.fromTextArea(document.getElementById("ceylon-code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-ceylon"
+ });
+ var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
+ CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
</script>
<p>Simple mode that tries to handle C-like languages as well as it
@@ -194,7 +350,11 @@ public class Class<T, V> implements MyInterface {
directives are recognized.</p>
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
- (C code), <code>text/x-c++src</code> (C++
- code), <code>text/x-java</code> (Java
- code), <code>text/x-csharp</code> (C#).</p>
+ (C), <code>text/x-c++src</code> (C++), <code>text/x-java</code>
+ (Java), <code>text/x-csharp</code> (C#),
+ <code>text/x-objectivec</code> (Objective-C),
+ <code>text/x-scala</code> (Scala), <code>text/x-vertex</code>
+ <code>x-shader/x-fragment</code> (shader programs),
+ <code>text/x-squirrel</code> (Squirrel) and
+ <code>text/x-ceylon</code> (Ceylon)</p>
</article>
diff --git a/data/ext/editorText/codemirror/mode/clike/scala.html b/data/ext/editorText/codemirror/mode/clike/scala.html
index e9acc049b..aa04cf0f0 100644
--- a/data/ext/editorText/codemirror/mode/clike/scala.html
+++ b/data/ext/editorText/codemirror/mode/clike/scala.html
@@ -10,12 +10,12 @@
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="clike.js"></script>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/clike/test.js b/data/ext/editorText/codemirror/mode/clike/test.js
new file mode 100644
index 000000000..c84d22e18
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/clike/test.js
@@ -0,0 +1,42 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function() {
+ var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
+
+ MT("indent",
+ "[variable-3 void] [def foo]([variable-3 void*] [variable a], [variable-3 int] [variable b]) {",
+ " [variable-3 int] [variable c] [operator =] [variable b] [operator +]",
+ " [number 1];",
+ " [keyword return] [operator *][variable a];",
+ "}");
+
+ MT("indent_switch",
+ "[keyword switch] ([variable x]) {",
+ " [keyword case] [number 10]:",
+ " [keyword return] [number 20];",
+ " [keyword default]:",
+ " [variable printf]([string \"foo %c\"], [variable x]);",
+ "}");
+
+ MT("def",
+ "[variable-3 void] [def foo]() {}",
+ "[keyword struct] [def bar]{}",
+ "[variable-3 int] [variable-3 *][def baz]() {}");
+
+ MT("double_block",
+ "[keyword for] (;;)",
+ " [keyword for] (;;)",
+ " [variable x][operator ++];",
+ "[keyword return];");
+
+ var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
+ function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
+
+ MTCPP("cpp14_literal",
+ "[number 10'000];",
+ "[number 0b10'000];",
+ "[number 0x10'000];",
+ "[string '100000'];");
+})();
diff --git a/data/ext/editorText/codemirror/mode/clojure/clojure.js b/data/ext/editorText/codemirror/mode/clojure/clojure.js
index a45a95de5..d531022a2 100644
--- a/data/ext/editorText/codemirror/mode/clojure/clojure.js
+++ b/data/ext/editorText/codemirror/mode/clojure/clojure.js
@@ -1,10 +1,24 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/**
* Author: Hans Engel
* Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun)
*/
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("clojure", function (options) {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2",
- ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword";
+ ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword", VAR = "variable";
var INDENT_WORD_SKIP = options.indentUnit || 2;
var NORMAL_INDENT_UNIT = options.indentUnit || 2;
@@ -45,7 +59,7 @@ CodeMirror.defineMode("clojure", function (options) {
sign: /[+-]/,
exponent: /e/i,
keyword_char: /[^\s\(\[\;\)\]]/,
- symbol: /[\w*+!\-\._?:<>\/]/
+ symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/
};
function stateStack(indent, type, prev) { // represents a state stack object
@@ -100,7 +114,7 @@ CodeMirror.defineMode("clojure", function (options) {
var first = stream.next();
// Read special literals: backspace, newline, space, return.
// Just read all lowercase letters.
- if (first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) {
+ if (first && first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) {
return;
}
// Read unicode character: \u1000 \uA0a1
@@ -206,7 +220,9 @@ CodeMirror.defineMode("clojure", function (options) {
returnType = BUILTIN;
} else if (atoms && atoms.propertyIsEnumerable(stream.current())) {
returnType = ATOM;
- } else returnType = null;
+ } else {
+ returnType = VAR;
+ }
}
}
@@ -218,8 +234,11 @@ CodeMirror.defineMode("clojure", function (options) {
return state.indentStack.indent;
},
+ closeBrackets: {pairs: "()[]{}\"\""},
lineComment: ";;"
};
});
CodeMirror.defineMIME("text/x-clojure", "clojure");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/clojure/index.html b/data/ext/editorText/codemirror/mode/clojure/index.html
index 5a50c566f..3ecf4c486 100644
--- a/data/ext/editorText/codemirror/mode/clojure/index.html
+++ b/data/ext/editorText/codemirror/mode/clojure/index.html
@@ -9,12 +9,12 @@
<script src="clojure.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/cmake/cmake.js b/data/ext/editorText/codemirror/mode/cmake/cmake.js
new file mode 100644
index 000000000..9f9eda541
--- /dev/null
+++ b/data/ext/editorText/codemirror/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/data/ext/editorText/codemirror/mode/cmake/index.html b/data/ext/editorText/codemirror/mode/cmake/index.html
new file mode 100644
index 000000000..ed114fece
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/cmake/index.html
@@ -0,0 +1,129 @@
+<!doctype html>
+
+<title>CodeMirror: CMake mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/edit/matchbrackets.js"></script>
+<script src="cmake.js"></script>
+<style>
+ .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
+ .cm-s-default span.cm-arrow { color: red; }
+ </style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">CMake</a>
+ </ul>
+</div>
+
+<article>
+<h2>CMake mode</h2>
+<form><textarea id="code" name="code">
+# vim: syntax=cmake
+if(NOT CMAKE_BUILD_TYPE)
+ # default to Release build for GCC builds
+ set(CMAKE_BUILD_TYPE Release CACHE STRING
+ "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
+ FORCE)
+endif()
+message(STATUS "cmake version ${CMAKE_VERSION}")
+if(POLICY CMP0025)
+ cmake_policy(SET CMP0025 OLD) # report Apple's Clang as just Clang
+endif()
+if(POLICY CMP0042)
+ cmake_policy(SET CMP0042 NEW) # MACOSX_RPATH
+endif()
+
+project (x265)
+cmake_minimum_required (VERSION 2.8.8) # OBJECT libraries require 2.8.8
+include(CheckIncludeFiles)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(CheckCXXCompilerFlag)
+
+# X265_BUILD must be incremented each time the public API is changed
+set(X265_BUILD 48)
+configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
+ "${PROJECT_BINARY_DIR}/x265.def")
+configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
+ "${PROJECT_BINARY_DIR}/x265_config.h")
+
+SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
+
+# System architecture detection
+string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSPROC)
+set(X86_ALIASES x86 i386 i686 x86_64 amd64)
+list(FIND X86_ALIASES "${SYSPROC}" X86MATCH)
+if("${SYSPROC}" STREQUAL "" OR X86MATCH GREATER "-1")
+ message(STATUS "Detected x86 target processor")
+ set(X86 1)
+ add_definitions(-DX265_ARCH_X86=1)
+ if("${CMAKE_SIZEOF_VOID_P}" MATCHES 8)
+ set(X64 1)
+ add_definitions(-DX86_64=1)
+ endif()
+elseif(${SYSPROC} STREQUAL "armv6l")
+ message(STATUS "Detected ARM target processor")
+ set(ARM 1)
+ add_definitions(-DX265_ARCH_ARM=1 -DHAVE_ARMV6=1)
+else()
+ message(STATUS "CMAKE_SYSTEM_PROCESSOR value `${CMAKE_SYSTEM_PROCESSOR}` is unknown")
+ message(STATUS "Please add this value near ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}")
+endif()
+
+if(UNIX)
+ list(APPEND PLATFORM_LIBS pthread)
+ find_library(LIBRT rt)
+ if(LIBRT)
+ list(APPEND PLATFORM_LIBS rt)
+ endif()
+ find_package(Numa)
+ if(NUMA_FOUND)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${NUMA_LIBRARY})
+ check_symbol_exists(numa_node_of_cpu numa.h NUMA_V2)
+ if(NUMA_V2)
+ add_definitions(-DHAVE_LIBNUMA)
+ message(STATUS "libnuma found, building with support for NUMA nodes")
+ list(APPEND PLATFORM_LIBS ${NUMA_LIBRARY})
+ link_directories(${NUMA_LIBRARY_DIR})
+ include_directories(${NUMA_INCLUDE_DIR})
+ endif()
+ endif()
+ mark_as_advanced(LIBRT NUMA_FOUND)
+endif(UNIX)
+
+if(X64 AND NOT WIN32)
+ option(ENABLE_PIC "Enable Position Independent Code" ON)
+else()
+ option(ENABLE_PIC "Enable Position Independent Code" OFF)
+endif(X64 AND NOT WIN32)
+
+# Compiler detection
+if(CMAKE_GENERATOR STREQUAL "Xcode")
+ set(XCODE 1)
+endif()
+if (APPLE)
+ add_definitions(-DMACOS)
+endif()
+</textarea></form>
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ mode: "text/x-cmake",
+ matchBrackets: true,
+ indentUnit: 4
+ });
+ </script>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-cmake</code>.</p>
+
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/cobol/cobol.js b/data/ext/editorText/codemirror/mode/cobol/cobol.js
index d92491dde..897022b18 100644
--- a/data/ext/editorText/codemirror/mode/cobol/cobol.js
+++ b/data/ext/editorText/codemirror/mode/cobol/cobol.js
@@ -1,7 +1,20 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/**
* Author: Gautam Mehta
* Branched from CodeMirror's Scheme mode
*/
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("cobol", function () {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
ATOM = "atom", NUMBER = "number", KEYWORD = "keyword", MODTAG = "header",
@@ -238,3 +251,5 @@ CodeMirror.defineMode("cobol", function () {
});
CodeMirror.defineMIME("text/x-cobol", "cobol");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/cobol/index.html b/data/ext/editorText/codemirror/mode/cobol/index.html
index a6c5c339c..4352419a0 100644
--- a/data/ext/editorText/codemirror/mode/cobol/index.html
+++ b/data/ext/editorText/codemirror/mode/cobol/index.html
@@ -39,12 +39,12 @@
.CodeMirror-activeline-background {background: #555555 !important;}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/coffeescript/coffeescript.js b/data/ext/editorText/codemirror/mode/coffeescript/coffeescript.js
index 0e9e6352f..adf2184fd 100644
--- a/data/ext/editorText/codemirror/mode/coffeescript/coffeescript.js
+++ b/data/ext/editorText/codemirror/mode/coffeescript/coffeescript.js
@@ -1,18 +1,31 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/**
* Link to the project's GitHub page:
* https://github.com/pickhardt/coffeescript-codemirror-mode
*/
-CodeMirror.defineMode("coffeescript", function(conf) {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.defineMode("coffeescript", function(conf, parserConf) {
var ERRORCLASS = "error";
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b");
}
- var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?)/;
+ var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?|(or|and|\|\||&&|\?)=)/;
var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/;
var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/;
- var properties = /^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*/;
+ var atProp = /^@[_A-Za-z$][_A-Za-z$0-9]*/;
var wordOperators = wordRegexp(["and", "or", "not",
"is", "isnt", "in",
@@ -21,7 +34,7 @@ CodeMirror.defineMode("coffeescript", function(conf) {
"switch", "try", "catch", "finally", "class"];
var commonKeywords = ["break", "by", "continue", "debugger", "delete",
"do", "in", "of", "new", "return", "then",
- "this", "throw", "when", "until"];
+ "this", "@", "throw", "when", "until", "extends"];
var keywords = wordRegexp(indentKeywords.concat(commonKeywords));
@@ -132,6 +145,8 @@ CodeMirror.defineMode("coffeescript", function(conf) {
}
}
+
+
// Handle operators and delimiters
if (stream.match(operators) || stream.match(wordOperators)) {
return "operator";
@@ -144,6 +159,10 @@ CodeMirror.defineMode("coffeescript", function(conf) {
return "atom";
}
+ if (stream.match(atProp) || state.prop && stream.match(identifiers)) {
+ return "property";
+ }
+
if (stream.match(keywords)) {
return "keyword";
}
@@ -152,10 +171,6 @@ CodeMirror.defineMode("coffeescript", function(conf) {
return "variable";
}
- if (stream.match(properties)) {
- return "property";
- }
-
// Handle non-detected items
stream.next();
return ERRORCLASS;
@@ -178,7 +193,7 @@ CodeMirror.defineMode("coffeescript", function(conf) {
}
}
if (singleline) {
- if (conf.mode.singleLineStringErrors) {
+ if (parserConf.singleLineStringErrors) {
outclass = ERRORCLASS;
} else {
state.tokenize = tokenBase;
@@ -204,7 +219,7 @@ CodeMirror.defineMode("coffeescript", function(conf) {
type = type || "coffee";
var offset = 0, align = false, alignOffset = null;
for (var scope = state.scope; scope; scope = scope.prev) {
- if (scope.type === "coffee") {
+ if (scope.type === "coffee" || scope.type == "}") {
offset = scope.offset + conf.indentUnit;
break;
}
@@ -252,24 +267,11 @@ CodeMirror.defineMode("coffeescript", function(conf) {
var style = state.tokenize(stream, state);
var current = stream.current();
- // Handle "." connected identifiers
- if (current === ".") {
- style = state.tokenize(stream, state);
- current = stream.current();
- if (/^\.[\w$]+$/.test(current)) {
- return "variable";
- } else {
- return ERRORCLASS;
- }
- }
-
// Handle scope changes.
if (current === "return") {
- state.dedent += 1;
+ state.dedent = true;
}
- if (((current === "->" || current === "=>") &&
- !state.lambda &&
- !stream.peek())
+ if (((current === "->" || current === "=>") && stream.eol())
|| style === "indent") {
indent(stream, state);
}
@@ -297,9 +299,10 @@ CodeMirror.defineMode("coffeescript", function(conf) {
if (state.scope.type == current)
state.scope = state.scope.prev;
}
- if (state.dedent > 0 && stream.eol() && state.scope.type == "coffee") {
- if (state.scope.prev) state.scope = state.scope.prev;
- state.dedent -= 1;
+ if (state.dedent && stream.eol()) {
+ if (state.scope.type == "coffee" && state.scope.prev)
+ state.scope = state.scope.prev;
+ state.dedent = false;
}
return style;
@@ -310,8 +313,7 @@ CodeMirror.defineMode("coffeescript", function(conf) {
return {
tokenize: tokenBase,
scope: {offset:basecolumn || 0, type:"coffee", prev: null, align: false},
- lastToken: null,
- lambda: false,
+ prop: false,
dedent: 0
};
},
@@ -321,12 +323,9 @@ CodeMirror.defineMode("coffeescript", function(conf) {
if (fillAlign && stream.sol()) fillAlign.align = false;
var style = tokenLexer(stream, state);
- if (fillAlign && style && style != "comment") fillAlign.align = true;
-
- state.lastToken = {style:style, content: stream.current()};
-
- if (stream.eol() && stream.lambda) {
- state.lambda = false;
+ if (style && style != "comment") {
+ if (fillAlign) fillAlign.align = true;
+ state.prop = style == "punctuation" && stream.current() == "."
}
return style;
@@ -351,3 +350,6 @@ CodeMirror.defineMode("coffeescript", function(conf) {
});
CodeMirror.defineMIME("text/x-coffeescript", "coffeescript");
+CodeMirror.defineMIME("text/coffeescript", "coffeescript");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/coffeescript/index.html b/data/ext/editorText/codemirror/mode/coffeescript/index.html
index 6e6fde52e..93a5f4f30 100644
--- a/data/ext/editorText/codemirror/mode/coffeescript/index.html
+++ b/data/ext/editorText/codemirror/mode/coffeescript/index.html
@@ -9,12 +9,12 @@
<script src="coffeescript.js"></script>
<style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -735,6 +735,6 @@ wrapper::value = -> this._wrapped
<p><strong>MIME types defined:</strong> <code>text/x-coffeescript</code>.</p>
- <p>The CoffeeScript mode was written by Jeff Pickhardt (<a href="LICENSE">license</a>).</p>
+ <p>The CoffeeScript mode was written by Jeff Pickhardt.</p>
</article>
diff --git a/data/ext/editorText/codemirror/mode/commonlisp/commonlisp.js b/data/ext/editorText/codemirror/mode/commonlisp/commonlisp.js
index 8fa08c8ac..fb1f99c63 100644
--- a/data/ext/editorText/codemirror/mode/commonlisp/commonlisp.js
+++ b/data/ext/editorText/codemirror/mode/commonlisp/commonlisp.js
@@ -1,4 +1,18 @@
+// 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";
+
CodeMirror.defineMode("commonlisp", function (config) {
+ var specialForm = /^(block|let*|return-from|catch|load-time-value|setq|eval-when|locally|symbol-macrolet|flet|macrolet|tagbody|function|multiple-value-call|the|go|multiple-value-prog1|throw|if|progn|unwind-protect|labels|progv|let|quote)$/;
var assumeBody = /^with|^def|^do|^prog|case$|^cond$|bind$|when$|unless$/;
var numLiteral = /^(?:[+\-]?(?:\d+|\d*\.\d+)(?:[efd][+\-]?\d+)?|[+\-]?\d+(?:\/[+\-]?\d+)?|#b[+\-]?[01]+|#o[+\-]?[0-7]+|#x[+\-]?[\da-f]+)/;
var symbol = /[^\s'`,@()\[\]";]/;
@@ -39,8 +53,8 @@ CodeMirror.defineMode("commonlisp", function (config) {
var name = readSym(stream);
if (name == ".") return null;
type = "symbol";
- if (name == "nil" || name == "t") return "atom";
- if (name.charAt(0) == ":") return "keyword";
+ if (name == "nil" || name == "t" || name.charAt(0) == ":") return "atom";
+ if (state.lastType == "open" && (specialForm.test(name) || assumeBody.test(name))) return "keyword";
if (name.charAt(0) == "&") return "variable-2";
return "variable";
}
@@ -67,7 +81,7 @@ CodeMirror.defineMode("commonlisp", function (config) {
return {
startState: function () {
- return {ctx: {prev: null, start: 0, indentTo: 0}, tokenize: base};
+ return {ctx: {prev: null, start: 0, indentTo: 0}, lastType: null, tokenize: base};
},
token: function (stream, state) {
@@ -85,6 +99,7 @@ CodeMirror.defineMode("commonlisp", function (config) {
} else if (state.ctx.indentTo == "next") {
state.ctx.indentTo = stream.column();
}
+ state.lastType = type;
}
if (type == "open") state.ctx = {prev: state.ctx, start: stream.column(), indentTo: null};
else if (type == "close") state.ctx = state.ctx.prev || state.ctx;
@@ -96,6 +111,7 @@ CodeMirror.defineMode("commonlisp", function (config) {
return typeof i == "number" ? i : state.ctx.start + 1;
},
+ closeBrackets: {pairs: "()[]{}\"\""},
lineComment: ";;",
blockCommentStart: "#|",
blockCommentEnd: "|#"
@@ -103,3 +119,5 @@ CodeMirror.defineMode("commonlisp", function (config) {
});
CodeMirror.defineMIME("text/x-common-lisp", "commonlisp");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/commonlisp/index.html b/data/ext/editorText/codemirror/mode/commonlisp/index.html
index d48be8d23..f2bf4522d 100644
--- a/data/ext/editorText/codemirror/mode/commonlisp/index.html
+++ b/data/ext/editorText/codemirror/mode/commonlisp/index.html
@@ -9,12 +9,12 @@
<script src="commonlisp.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/css/css.js b/data/ext/editorText/codemirror/mode/css/css.js
index 28b0f3356..d07426473 100644
--- a/data/ext/editorText/codemirror/mode/css/css.js
+++ b/data/ext/editorText/codemirror/mode/css/css.js
@@ -1,18 +1,35 @@
-CodeMirror.defineMode("css", function(config, parserConfig) {
- "use strict";
+// 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";
+CodeMirror.defineMode("css", function(config, parserConfig) {
+ var provided = parserConfig;
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
+ parserConfig.inline = provided.inline;
var indentUnit = config.indentUnit,
tokenHooks = parserConfig.tokenHooks,
+ documentTypes = parserConfig.documentTypes || {},
mediaTypes = parserConfig.mediaTypes || {},
mediaFeatures = parserConfig.mediaFeatures || {},
+ mediaValueKeywords = parserConfig.mediaValueKeywords || {},
propertyKeywords = parserConfig.propertyKeywords || {},
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
+ fontProperties = parserConfig.fontProperties || {},
+ counterDescriptors = parserConfig.counterDescriptors || {},
colorKeywords = parserConfig.colorKeywords || {},
valueKeywords = parserConfig.valueKeywords || {},
- fontProperties = parserConfig.fontProperties || {},
- allowNested = parserConfig.allowNested;
+ allowNested = parserConfig.allowNested,
+ supportsAtComponent = parserConfig.supportsAtComponent === true;
var type, override;
function ret(style, tp) { type = tp; return style; }
@@ -46,7 +63,12 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
if (/[\d.]/.test(stream.peek())) {
stream.eatWhile(/[\w.%]/);
return ret("number", "unit");
- } else if (stream.match(/^[^-]+-/)) {
+ } else if (stream.match(/^-[\w\\\-]+/)) {
+ stream.eatWhile(/[\w\\\-]/);
+ if (stream.match(/^\s*:/, false))
+ return ret("variable-2", "variable-definition");
+ return ret("variable-2", "variable");
+ } else if (stream.match(/^\w+-/)) {
return ret("meta", "meta");
}
} else if (/[,+>*\/]/.test(ch)) {
@@ -55,7 +77,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
return ret("qualifier", "qualifier");
} else if (/[:;{}\[\]\(\)]/.test(ch)) {
return ret(null, ch);
- } else if (ch == "u" && stream.match("rl(")) {
+ } else if ((ch == "u" && stream.match(/rl(-prefix)?\(/)) ||
+ (ch == "d" && stream.match("omain(")) ||
+ (ch == "r" && stream.match("egexp("))) {
stream.backUp(1);
state.tokenize = tokenParenthesized;
return ret("property", "word");
@@ -99,13 +123,14 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
this.prev = prev;
}
- function pushContext(state, stream, type) {
- state.context = new Context(type, stream.indentation() + indentUnit, state.context);
+ function pushContext(state, stream, type, indent) {
+ state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
return type;
}
function popContext(state) {
- state.context = state.context.prev;
+ if (state.context.prev)
+ state.context = state.context.prev;
return state.context.type;
}
@@ -137,10 +162,15 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
return pushContext(state, stream, "block");
} else if (type == "}" && state.context.prev) {
return popContext(state);
- } else if (type == "@media") {
- return pushContext(state, stream, "media");
- } else if (type == "@font-face") {
- return "font_face_before";
+ } else if (supportsAtComponent && /@component/.test(type)) {
+ return pushContext(state, stream, "atComponentBlock");
+ } else if (/^@(-moz-)?document$/.test(type)) {
+ return pushContext(state, stream, "documentTypes");
+ } else if (/^@(media|supports|(-moz-)?document|import)$/.test(type)) {
+ return pushContext(state, stream, "atBlock");
+ } else if (/^@(font-face|counter-style)/.test(type)) {
+ state.stateArg = type;
+ return "restricted_atBlock_before";
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
return "keyframes";
} else if (type && type.charAt(0) == "@") {
@@ -156,7 +186,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
} else if (type == ":") {
return "pseudo";
} else if (allowNested && type == "(") {
- return pushContext(state, stream, "params");
+ return pushContext(state, stream, "parens");
}
return state.context.type;
};
@@ -171,7 +201,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
override = "string-2";
return "maybeprop";
} else if (allowNested) {
- override = stream.match(/^\s*:/, false) ? "property" : "tag";
+ override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
return "block";
} else {
override += " error";
@@ -217,6 +247,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
states.parens = function(type, stream, state) {
if (type == "{" || type == "}") return popAndPass(type, stream, state);
if (type == ")") return popContext(state);
+ if (type == "(") return pushContext(state, stream, "parens");
+ if (type == "interpolation") return pushContext(state, stream, "interpolation");
+ if (type == "word") wordAsValue(stream);
return "parens";
};
@@ -228,47 +261,86 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
return pass(type, stream, state);
};
- states.media = function(type, stream, state) {
- if (type == "(") return pushContext(state, stream, "media_parens");
- if (type == "}") return popAndPass(type, stream, state);
+ states.documentTypes = function(type, stream, state) {
+ if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
+ override = "tag";
+ return state.context.type;
+ } else {
+ return states.atBlock(type, stream, state);
+ }
+ };
+
+ states.atBlock = function(type, stream, state) {
+ if (type == "(") return pushContext(state, stream, "atBlock_parens");
+ if (type == "}" || type == ";") return popAndPass(type, stream, state);
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
+ if (type == "interpolation") return pushContext(state, stream, "interpolation");
+
if (type == "word") {
var word = stream.current().toLowerCase();
- if (word == "only" || word == "not" || word == "and")
+ if (word == "only" || word == "not" || word == "and" || word == "or")
override = "keyword";
else if (mediaTypes.hasOwnProperty(word))
override = "attribute";
else if (mediaFeatures.hasOwnProperty(word))
override = "property";
+ else if (mediaValueKeywords.hasOwnProperty(word))
+ override = "keyword";
+ else if (propertyKeywords.hasOwnProperty(word))
+ override = "property";
+ else if (nonStandardPropertyKeywords.hasOwnProperty(word))
+ override = "string-2";
+ else if (valueKeywords.hasOwnProperty(word))
+ override = "atom";
+ else if (colorKeywords.hasOwnProperty(word))
+ override = "keyword";
else
override = "error";
}
return state.context.type;
};
- states.media_parens = function(type, stream, state) {
+ states.atComponentBlock = function(type, stream, state) {
+ if (type == "}")
+ return popAndPass(type, stream, state);
+ if (type == "{")
+ return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
+ if (type == "word")
+ override = "error";
+ return state.context.type;
+ };
+
+ states.atBlock_parens = function(type, stream, state) {
if (type == ")") return popContext(state);
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
- return states.media(type, stream, state);
+ return states.atBlock(type, stream, state);
};
- states.font_face_before = function(type, stream, state) {
+ states.restricted_atBlock_before = function(type, stream, state) {
if (type == "{")
- return pushContext(state, stream, "font_face");
+ return pushContext(state, stream, "restricted_atBlock");
+ if (type == "word" && state.stateArg == "@counter-style") {
+ override = "variable";
+ return "restricted_atBlock_before";
+ }
return pass(type, stream, state);
};
- states.font_face = function(type, stream, state) {
- if (type == "}") return popContext(state);
+ states.restricted_atBlock = function(type, stream, state) {
+ if (type == "}") {
+ state.stateArg = null;
+ return popContext(state);
+ }
if (type == "word") {
- if (!fontProperties.hasOwnProperty(stream.current().toLowerCase()))
+ if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) ||
+ (state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
override = "error";
else
override = "property";
return "maybeprop";
}
- return "font_face";
+ return "restricted_atBlock";
};
states.keyframes = function(type, stream, state) {
@@ -288,22 +360,17 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
states.interpolation = function(type, stream, state) {
if (type == "}") return popContext(state);
if (type == "{" || type == ";") return popAndPass(type, stream, state);
- if (type != "variable") override = "error";
+ if (type == "word") override = "variable";
+ else if (type != "variable" && type != "(" && type != ")") override = "error";
return "interpolation";
};
- states.params = function(type, stream, state) {
- if (type == ")") return popContext(state);
- if (type == "{" || type == "}") return popAndPass(type, stream, state);
- if (type == "word") wordAsValue(stream);
- return "params";
- };
-
return {
startState: function(base) {
return {tokenize: null,
- state: "top",
- context: new Context("top", base || 0, null)};
+ state: parserConfig.inline ? "block" : "top",
+ stateArg: null,
+ context: new Context(parserConfig.inline ? "block" : "top", base || 0, null)};
},
token: function(stream, state) {
@@ -321,13 +388,19 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
indent: function(state, textAfter) {
var cx = state.context, ch = textAfter && textAfter.charAt(0);
var indent = cx.indent;
- if (cx.type == "prop" && ch == "}") cx = cx.prev;
- if (cx.prev &&
- (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") ||
- ch == ")" && (cx.type == "parens" || cx.type == "params" || cx.type == "media_parens") ||
- ch == "{" && (cx.type == "at" || cx.type == "media"))) {
- indent = cx.indent - indentUnit;
- cx = cx.prev;
+ if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
+ if (cx.prev) {
+ if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
+ cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
+ // Resume indentation from parent context.
+ cx = cx.prev;
+ indent = cx.indent;
+ } else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
+ ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
+ // Dedent relative to current context.
+ indent = Math.max(0, cx.indent - indentUnit);
+ cx = cx.prev;
+ }
}
return indent;
},
@@ -339,7 +412,6 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
};
});
-(function() {
function keySet(array) {
var keys = {};
for (var i = 0; i < array.length; ++i) {
@@ -348,6 +420,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
return keys;
}
+ var documentTypes_ = [
+ "domain", "regexp", "url", "url-prefix"
+ ], documentTypes = keySet(documentTypes_);
+
var mediaTypes_ = [
"all", "aural", "braille", "handheld", "print", "projection", "screen",
"tty", "tv", "embossed"
@@ -361,9 +437,16 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"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"
+ "min-resolution", "max-resolution", "scan", "grid", "orientation",
+ "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
+ "pointer", "any-pointer", "hover", "any-hover"
], mediaFeatures = keySet(mediaFeatures_);
+ var mediaValueKeywords_ = [
+ "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
+ "interlace", "progressive"
+ ], mediaValueKeywords = keySet(mediaValueKeywords_);
+
var propertyKeywords_ = [
"align-content", "align-items", "align-self", "alignment-adjust",
"alignment-baseline", "anchor-point", "animation", "animation-delay",
@@ -415,7 +498,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"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", "opacity", "order", "orphans", "outline",
+ "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",
@@ -426,8 +510,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"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-inside", "shape-outside", "size",
- "speak", "speak-as", "speak-header",
+ "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",
@@ -455,13 +539,23 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"glyph-orientation-vertical", "text-anchor", "writing-mode"
], propertyKeywords = keySet(propertyKeywords_);
- var nonStandardPropertyKeywords = [
+ var nonStandardPropertyKeywords_ = [
"scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
"scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
"scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
"searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
"searchfield-results-decoration", "zoom"
- ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords);
+ ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
+
+ var fontProperties_ = [
+ "font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
+ "font-stretch", "font-weight", "font-style"
+ ], fontProperties = keySet(fontProperties_);
+
+ var counterDescriptors_ = [
+ "additive-symbols", "fallback", "negative", "pad", "prefix", "range",
+ "speak-as", "suffix", "symbols", "system"
+ ], counterDescriptors = keySet(counterDescriptors_);
var colorKeywords_ = [
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
@@ -485,54 +579,57 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"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",
+ "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"
], colorKeywords = keySet(colorKeywords_);
var valueKeywords_ = [
- "above", "absolute", "activeborder", "activecaption", "afar",
- "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
+ "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", "auto", "avoid", "avoid-column", "avoid-page",
+ "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", "button", "button-bevel",
- "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
+ "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-earthly-branch",
+ "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", "cover", "crop",
- "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
+ "col-resize", "collapse", "column", "column-reverse", "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", "document", "dot-dash", "dot-dot-dash", "dotted",
- "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
+ "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", "ew-resize", "expanded", "extra-condensed",
- "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes",
+ "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", "flex-end", "flex-start", "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",
+ "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", "lines", "list-item", "listbox", "listitem",
+ "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",
+ "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",
@@ -544,46 +641,50 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"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",
+ "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", "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",
+ "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", "row-resize", "row-reverse", "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",
- "single", "skip-white-space", "slide", "slider-horizontal",
+ "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", "square",
- "square-button", "start", "static", "status-bar", "stretch", "stroke",
- "sub", "subpixel-antialiased", "super", "sw-resize", "table",
+ "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "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",
- "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
+ "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
- "window", "windowframe", "windowtext", "x-large", "x-small", "xor",
+ "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
"xx-large", "xx-small"
], valueKeywords = keySet(valueKeywords_);
- var fontProperties_ = [
- "font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
- "font-stretch", "font-weight", "font-style"
- ], fontProperties = keySet(fontProperties_);
-
- var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_)
- .concat(nonStandardPropertyKeywords).concat(colorKeywords_).concat(valueKeywords_);
+ var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
+ .concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
+ .concat(valueKeywords_);
CodeMirror.registerHelper("hintWords", "css", allWords);
function tokenCComment(stream, state) {
@@ -598,30 +699,18 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
return ["comment", "comment"];
}
- function tokenSGMLComment(stream, state) {
- if (stream.skipTo("-->")) {
- stream.match("-->");
- state.tokenize = null;
- } else {
- stream.skipToEnd();
- }
- return ["comment", "comment"];
- }
-
CodeMirror.defineMIME("text/css", {
+ documentTypes: documentTypes,
mediaTypes: mediaTypes,
mediaFeatures: mediaFeatures,
+ mediaValueKeywords: mediaValueKeywords,
propertyKeywords: propertyKeywords,
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
+ fontProperties: fontProperties,
+ counterDescriptors: counterDescriptors,
colorKeywords: colorKeywords,
valueKeywords: valueKeywords,
- fontProperties: fontProperties,
tokenHooks: {
- "<": function(stream, state) {
- if (!stream.match("!--")) return false;
- state.tokenize = tokenSGMLComment;
- return tokenSGMLComment(stream, state);
- },
"/": function(stream, state) {
if (!stream.eat("*")) return false;
state.tokenize = tokenCComment;
@@ -634,6 +723,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
CodeMirror.defineMIME("text/x-scss", {
mediaTypes: mediaTypes,
mediaFeatures: mediaFeatures,
+ mediaValueKeywords: mediaValueKeywords,
propertyKeywords: propertyKeywords,
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
colorKeywords: colorKeywords,
@@ -653,7 +743,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
}
},
":": function(stream) {
- if (stream.match(/\s*{/))
+ if (stream.match(/\s*\{/))
return [null, "{"];
return false;
},
@@ -675,6 +765,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
CodeMirror.defineMIME("text/x-less", {
mediaTypes: mediaTypes,
mediaFeatures: mediaFeatures,
+ mediaValueKeywords: mediaValueKeywords,
propertyKeywords: propertyKeywords,
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
colorKeywords: colorKeywords,
@@ -694,6 +785,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
}
},
"@": function(stream) {
+ if (stream.eat("{")) return [null, "interpolation"];
if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false;
stream.eatWhile(/[\w\\\-]/);
if (stream.match(/^\s*:/, false))
@@ -707,4 +799,27 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
name: "css",
helperType: "less"
});
-})();
+
+ CodeMirror.defineMIME("text/x-gss", {
+ documentTypes: documentTypes,
+ mediaTypes: mediaTypes,
+ mediaFeatures: mediaFeatures,
+ propertyKeywords: propertyKeywords,
+ nonStandardPropertyKeywords: nonStandardPropertyKeywords,
+ fontProperties: fontProperties,
+ counterDescriptors: counterDescriptors,
+ colorKeywords: colorKeywords,
+ valueKeywords: valueKeywords,
+ supportsAtComponent: true,
+ tokenHooks: {
+ "/": function(stream, state) {
+ if (!stream.eat("*")) return false;
+ state.tokenize = tokenCComment;
+ return tokenCComment(stream, state);
+ }
+ },
+ name: "css",
+ helperType: "gss"
+ });
+
+});
diff --git a/data/ext/editorText/codemirror/mode/css/gss.html b/data/ext/editorText/codemirror/mode/css/gss.html
new file mode 100644
index 000000000..232fe8c12
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/css/gss.html
@@ -0,0 +1,103 @@
+<!doctype html>
+
+<title>CodeMirror: Closure Stylesheets (GSS) mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<link rel="stylesheet" href="../../addon/hint/show-hint.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="css.js"></script>
+<script src="../../addon/hint/show-hint.js"></script>
+<script src="../../addon/hint/css-hint.js"></script>
+<style>.CodeMirror {background: #f8f8f8;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Closure Stylesheets (GSS)</a>
+ </ul>
+</div>
+
+<article>
+<h2>Closure Stylesheets (GSS) mode</h2>
+<form><textarea id="code" name="code">
+/* Some example Closure Stylesheets */
+
+@provide 'some.styles';
+
+@require 'other.styles';
+
+@component {
+
+@def FONT_FAMILY "Times New Roman", Georgia, Serif;
+@def FONT_SIZE_NORMAL 15px;
+@def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY;
+
+@def BG_COLOR rgb(235, 239, 249);
+
+@def DIALOG_BORDER_COLOR rgb(107, 144, 218);
+@def DIALOG_BG_COLOR BG_COLOR;
+
+@def LEFT_HAND_NAV_WIDTH 180px;
+@def LEFT_HAND_NAV_PADDING 3px;
+
+@defmixin size(WIDTH, HEIGHT) {
+ width: WIDTH;
+ height: HEIGHT;
+}
+
+body {
+ background-color: BG_COLOR;
+ margin: 0;
+ padding: 3em 6em;
+ font: FONT_NORMAL;
+ color: #000;
+}
+
+#navigation a {
+ font-weight: bold;
+ text-decoration: none !important;
+}
+
+.dialog {
+ background-color: DIALOG_BG_COLOR;
+ border: 1px solid DIALOG_BORDER_COLOR;
+}
+
+.content {
+ position: absolute;
+ margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */
+ LEFT_HAND_NAV_WIDTH,
+ LEFT_HAND_NAV_PADDING); /* padding right */
+
+}
+
+.logo {
+ @mixin size(150px, 55px);
+ background-image: url('http://www.google.com/images/logo_sm.gif');
+}
+
+}
+</textarea></form>
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ extraKeys: {"Ctrl-Space": "autocomplete"},
+ lineNumbers: true,
+ matchBrackets: "text/x-less",
+ mode: "text/x-gss"
+ });
+ </script>
+
+ <p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p>
+ <p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p>
+
+ <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p>
+
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/css/gss_test.js b/data/ext/editorText/codemirror/mode/css/gss_test.js
new file mode 100644
index 000000000..d56e59280
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/css/gss_test.js
@@ -0,0 +1,17 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function() {
+ "use strict";
+
+ var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-gss");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "gss"); }
+
+ MT("atComponent",
+ "[def @component] {",
+ "[tag foo] {",
+ " [property color]: [keyword black];",
+ "}",
+ "}");
+
+})();
diff --git a/data/ext/editorText/codemirror/mode/css/index.html b/data/ext/editorText/codemirror/mode/css/index.html
index 80ef518e9..2d2b9b073 100644
--- a/data/ext/editorText/codemirror/mode/css/index.html
+++ b/data/ext/editorText/codemirror/mode/css/index.html
@@ -5,16 +5,19 @@
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
+<link rel="stylesheet" href="../../addon/hint/show-hint.css">
<script src="../../lib/codemirror.js"></script>
<script src="css.js"></script>
+<script src="../../addon/hint/show-hint.js"></script>
+<script src="../../addon/hint/css-hint.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -60,7 +63,9 @@ code {
}
</textarea></form>
<script>
- var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ extraKeys: {"Ctrl-Space": "autocomplete"},
+ });
</script>
<p><strong>MIME types defined:</strong> <code>text/css</code>, <code>text/x-scss</code> (<a href="scss.html">demo</a>), <code>text/x-less</code> (<a href="less.html">demo</a>).</p>
diff --git a/data/ext/editorText/codemirror/mode/css/less.html b/data/ext/editorText/codemirror/mode/css/less.html
index 1030ca43f..adf7427d3 100644
--- a/data/ext/editorText/codemirror/mode/css/less.html
+++ b/data/ext/editorText/codemirror/mode/css/less.html
@@ -10,12 +10,12 @@
<script src="css.js"></script>
<style>.CodeMirror {border: 1px solid #ddd; line-height: 1.2;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -146,7 +146,7 @@ fieldset span button, fieldset span input[type="file"] {
});
</script>
- <p>The LESS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>.</p>
+ <p>The LESS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#less_*">normal</a>, <a href="../../test/index.html#verbose,less_*">verbose</a>.</p>
</article>
diff --git a/data/ext/editorText/codemirror/mode/css/less_test.js b/data/ext/editorText/codemirror/mode/css/less_test.js
index ea64f91d1..7b77f5848 100644
--- a/data/ext/editorText/codemirror/mode/css/less_test.js
+++ b/data/ext/editorText/codemirror/mode/css/less_test.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
"use strict";
@@ -45,4 +48,7 @@
" }",
" }",
"}");
+
+
+ MT("interpolation", ".@{[variable foo]} { [property font-weight]: [atom bold]; }");
})();
diff --git a/data/ext/editorText/codemirror/mode/css/scss.html b/data/ext/editorText/codemirror/mode/css/scss.html
index 0677d08fe..f8e4d3736 100644
--- a/data/ext/editorText/codemirror/mode/css/scss.html
+++ b/data/ext/editorText/codemirror/mode/css/scss.html
@@ -9,12 +9,12 @@
<script src="css.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -150,7 +150,7 @@ code {
});
</script>
- <p>The SCSS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>.</p>
+ <p>The SCSS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#scss_*">normal</a>, <a href="../../test/index.html#verbose,scss_*">verbose</a>.</p>
diff --git a/data/ext/editorText/codemirror/mode/css/scss_test.js b/data/ext/editorText/codemirror/mode/css/scss_test.js
index c51cb42bb..26c226a1e 100644
--- a/data/ext/editorText/codemirror/mode/css/scss_test.js
+++ b/data/ext/editorText/codemirror/mode/css/scss_test.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-scss");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); }
@@ -70,7 +73,7 @@
"[tag foo]#{[variable-2 $hello]} { [property color]:[atom #000]; }");
MT('interpolation_error',
- "[tag foo]#{[error foo]} { [property color]:[atom #000]; }");
+ "[tag foo]#{[variable foo]} { [property color]:[atom #000]; }");
MT("divide_operator",
"[tag foo] { [property width]:[number 4] [operator /] [number 2] }");
diff --git a/data/ext/editorText/codemirror/mode/css/test.js b/data/ext/editorText/codemirror/mode/css/test.js
index f9f667295..60f9c837f 100644
--- a/data/ext/editorText/codemirror/mode/css/test.js
+++ b/data/ext/editorText/codemirror/mode/css/test.js
@@ -1,9 +1,12 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "css");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
// Error, because "foobarhello" is neither a known type or property, but
- // property was expected (after "and"), and it should be in parenthese.
+ // property was expected (after "and"), and it should be in parentheses.
MT("atMediaUnknownType",
"[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
@@ -15,6 +18,12 @@
MT("atMediaMaxWidthNested",
"[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
+ MT("atMediaFeatureValueKeyword",
+ "[def @media] ([property orientation]: [keyword landscape]) { }");
+
+ MT("atMediaUnknownFeatureValueKeyword",
+ "[def @media] ([property orientation]: [error upsidedown]) { }");
+
MT("tagSelector",
"[tag foo] { }");
@@ -73,13 +82,6 @@
MT("tagTwoPropertiesURL",
"[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
- MT("commentSGML",
- "[comment <!--comment-->]");
-
- MT("commentSGML2",
- "[comment <!--comment]",
- "[comment -->] [tag div] {}");
-
MT("indent_tagSelector",
"[tag strong], [tag em] {",
" [property background]: [atom rgba](",
@@ -118,5 +120,75 @@
"}");
MT("empty_url",
- "[def @import] [tag url]() [tag screen];");
+ "[def @import] [atom url]() [attribute screen];");
+
+ MT("parens",
+ "[qualifier .foo] {",
+ " [property background-image]: [variable fade]([atom #000], [number 20%]);",
+ " [property border-image]: [atom linear-gradient](",
+ " [atom to] [atom bottom],",
+ " [variable fade]([atom #000], [number 20%]) [number 0%],",
+ " [variable fade]([atom #000], [number 20%]) [number 100%]",
+ " );",
+ "}");
+
+ MT("css_variable",
+ ":[variable-3 root] {",
+ " [variable-2 --main-color]: [atom #06c];",
+ "}",
+ "[tag h1][builtin #foo] {",
+ " [property color]: [atom var]([variable-2 --main-color]);",
+ "}");
+
+ MT("supports",
+ "[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {",
+ " [property text-align-last]: [atom justify];",
+ "}");
+
+ MT("document",
+ "[def @document] [tag url]([string http://blah]),",
+ " [tag url-prefix]([string https://]),",
+ " [tag domain]([string blah.com]),",
+ " [tag regexp]([string \".*blah.+\"]) {",
+ " [builtin #id] {",
+ " [property background-color]: [keyword white];",
+ " }",
+ " [tag foo] {",
+ " [property font-family]: [variable Verdana], [atom sans-serif];",
+ " }",
+ "}");
+
+ MT("document_url",
+ "[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");
+
+ MT("document_urlPrefix",
+ "[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }");
+
+ MT("document_domain",
+ "[def @document] [tag domain]([string blah.com]) { [tag foo] { } }");
+
+ MT("document_regexp",
+ "[def @document] [tag regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
+
+ MT("counter-style",
+ "[def @counter-style] [variable binary] {",
+ " [property system]: [atom numeric];",
+ " [property symbols]: [number 0] [number 1];",
+ " [property suffix]: [string \".\"];",
+ " [property range]: [atom infinite];",
+ " [property speak-as]: [atom numeric];",
+ "}");
+
+ MT("counter-style-additive-symbols",
+ "[def @counter-style] [variable simple-roman] {",
+ " [property system]: [atom additive];",
+ " [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];",
+ " [property range]: [number 1] [number 49];",
+ "}");
+
+ MT("counter-style-use",
+ "[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");
+
+ MT("counter-style-symbols",
+ "[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
})();
diff --git a/data/ext/editorText/codemirror/mode/cypher/cypher.js b/data/ext/editorText/codemirror/mode/cypher/cypher.js
new file mode 100644
index 000000000..107e4f6d2
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/cypher/cypher.js
@@ -0,0 +1,146 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// By the Neo4j Team and contributors.
+// https://github.com/neo4j-contrib/CodeMirror
+
+(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";
+ var wordRegexp = function(words) {
+ return new RegExp("^(?:" + words.join("|") + ")$", "i");
+ };
+
+ CodeMirror.defineMode("cypher", function(config) {
+ var tokenBase = function(stream/*, state*/) {
+ var ch = stream.next();
+ if (ch === "\"" || ch === "'") {
+ stream.match(/.+?["']/);
+ return "string";
+ }
+ if (/[{}\(\),\.;\[\]]/.test(ch)) {
+ curPunc = ch;
+ return "node";
+ } else if (ch === "/" && stream.eat("/")) {
+ stream.skipToEnd();
+ return "comment";
+ } else if (operatorChars.test(ch)) {
+ stream.eatWhile(operatorChars);
+ return null;
+ } else {
+ stream.eatWhile(/[_\w\d]/);
+ if (stream.eat(":")) {
+ stream.eatWhile(/[\w\d_\-]/);
+ return "atom";
+ }
+ var word = stream.current();
+ if (funcs.test(word)) return "builtin";
+ if (preds.test(word)) return "def";
+ if (keywords.test(word)) return "keyword";
+ return "variable";
+ }
+ };
+ var pushContext = function(state, type, col) {
+ return state.context = {
+ prev: state.context,
+ indent: state.indent,
+ col: col,
+ type: type
+ };
+ };
+ var popContext = function(state) {
+ state.indent = state.context.indent;
+ return state.context = state.context.prev;
+ };
+ var indentUnit = config.indentUnit;
+ var curPunc;
+ var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]);
+ var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]);
+ var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]);
+ var operatorChars = /[*+\-<>=&|~%^]/;
+
+ return {
+ startState: function(/*base*/) {
+ return {
+ tokenize: tokenBase,
+ context: null,
+ indent: 0,
+ col: 0
+ };
+ },
+ token: function(stream, state) {
+ if (stream.sol()) {
+ if (state.context && (state.context.align == null)) {
+ state.context.align = false;
+ }
+ state.indent = stream.indentation();
+ }
+ if (stream.eatSpace()) {
+ return null;
+ }
+ var style = state.tokenize(stream, state);
+ if (style !== "comment" && state.context && (state.context.align == null) && state.context.type !== "pattern") {
+ state.context.align = true;
+ }
+ if (curPunc === "(") {
+ pushContext(state, ")", stream.column());
+ } else if (curPunc === "[") {
+ pushContext(state, "]", stream.column());
+ } else if (curPunc === "{") {
+ pushContext(state, "}", stream.column());
+ } else if (/[\]\}\)]/.test(curPunc)) {
+ while (state.context && state.context.type === "pattern") {
+ popContext(state);
+ }
+ if (state.context && curPunc === state.context.type) {
+ popContext(state);
+ }
+ } else if (curPunc === "." && state.context && state.context.type === "pattern") {
+ popContext(state);
+ } else if (/atom|string|variable/.test(style) && state.context) {
+ if (/[\}\]]/.test(state.context.type)) {
+ pushContext(state, "pattern", stream.column());
+ } else if (state.context.type === "pattern" && !state.context.align) {
+ state.context.align = true;
+ state.context.col = stream.column();
+ }
+ }
+ return style;
+ },
+ indent: function(state, textAfter) {
+ var firstChar = textAfter && textAfter.charAt(0);
+ var context = state.context;
+ if (/[\]\}]/.test(firstChar)) {
+ while (context && context.type === "pattern") {
+ context = context.prev;
+ }
+ }
+ var closing = context && firstChar === context.type;
+ if (!context) return 0;
+ if (context.type === "keywords") return CodeMirror.commands.newlineAndIndent;
+ if (context.align) return context.col + (closing ? 0 : 1);
+ return context.indent + (closing ? 0 : indentUnit);
+ }
+ };
+ });
+
+ CodeMirror.modeExtensions["cypher"] = {
+ autoFormatLineBreaks: function(text) {
+ var i, lines, reProcessedPortion;
+ var lines = text.split("\n");
+ var reProcessedPortion = /\s+\b(return|where|order by|match|with|skip|limit|create|delete|set)\b\s/g;
+ for (var i = 0; i < lines.length; i++)
+ lines[i] = lines[i].replace(reProcessedPortion, " \n$1 ").trim();
+ return lines.join("\n");
+ }
+ };
+
+ CodeMirror.defineMIME("application/x-cypher-query", "cypher");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/cypher/index.html b/data/ext/editorText/codemirror/mode/cypher/index.html
new file mode 100644
index 000000000..b8bd75c8b
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/cypher/index.html
@@ -0,0 +1,63 @@
+<!doctype html>
+
+<title>CodeMirror: Cypher Mode for CodeMirror</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css" />
+<link rel="stylesheet" href="../../theme/neo.css" />
+<script src="../../lib/codemirror.js"></script>
+<script src="cypher.js"></script>
+<style>
+.CodeMirror {
+ border-top: 1px solid black;
+ border-bottom: 1px solid black;
+}
+ </style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Cypher Mode for CodeMirror</a>
+ </ul>
+</div>
+
+<article>
+<h2>Cypher Mode for CodeMirror</h2>
+<form>
+ <textarea id="code" name="code">// Cypher Mode for CodeMirror, using the neo theme
+MATCH (joe { name: 'Joe' })-[:knows*2..2]-(friend_of_friend)
+WHERE NOT (joe)-[:knows]-(friend_of_friend)
+RETURN friend_of_friend.name, COUNT(*)
+ORDER BY COUNT(*) DESC , friend_of_friend.name
+</textarea>
+ </form>
+ <p><strong>MIME types defined:</strong>
+ <code><a href="?mime=application/x-cypher-query">application/x-cypher-query</a></code>
+ </p>
+<script>
+window.onload = function() {
+ var mime = 'application/x-cypher-query';
+ // get mime type
+ if (window.location.href.indexOf('mime=') > -1) {
+ mime = window.location.href.substr(window.location.href.indexOf('mime=') + 5);
+ }
+ window.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
+ mode: mime,
+ indentWithTabs: true,
+ smartIndent: true,
+ lineNumbers: true,
+ matchBrackets : true,
+ autofocus: true,
+ theme: 'neo'
+ });
+};
+</script>
+
+</article>
diff --git a/data/ext/editorText/codemirror/mode/d/d.js b/data/ext/editorText/codemirror/mode/d/d.js
index ab345f1a0..c927a7e35 100644
--- a/data/ext/editorText/codemirror/mode/d/d.js
+++ b/data/ext/editorText/codemirror/mode/d/d.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("d", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
@@ -47,7 +60,7 @@ CodeMirror.defineMode("d", function(config, parserConfig) {
stream.eatWhile(isOperatorChar);
return "operator";
}
- stream.eatWhile(/[\w\$_]/);
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
@@ -173,7 +186,6 @@ CodeMirror.defineMode("d", function(config, parserConfig) {
};
});
-(function() {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
@@ -202,4 +214,5 @@ CodeMirror.defineMode("d", function(config, parserConfig) {
}
}
});
-}());
+
+});
diff --git a/data/ext/editorText/codemirror/mode/d/index.html b/data/ext/editorText/codemirror/mode/d/index.html
index 8b25fcc5c..08cabd8a2 100644
--- a/data/ext/editorText/codemirror/mode/d/index.html
+++ b/data/ext/editorText/codemirror/mode/d/index.html
@@ -10,12 +10,12 @@
<script src="d.js"></script>
<style>.CodeMirror {border: 2px inset #dee;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/dart/dart.js b/data/ext/editorText/codemirror/mode/dart/dart.js
new file mode 100644
index 000000000..7d6e5abd9
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/dart/dart.js
@@ -0,0 +1,130 @@
+// 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"), require("../clike/clike"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../clike/clike"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ var keywords = ("this super static final const abstract class extends external factory " +
+ "implements get native operator set typedef with enum throw rethrow " +
+ "assert break case continue default in return new deferred async await " +
+ "try catch finally do else for if switch while import library export " +
+ "part of show hide is").split(" ");
+ var blockKeywords = "try catch finally do else for if switch while".split(" ");
+ var atoms = "true false null".split(" ");
+ var builtins = "void bool num int double dynamic var String".split(" ");
+
+ function set(words) {
+ var obj = {};
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
+ return obj;
+ }
+
+ function pushInterpolationStack(state) {
+ (state.interpolationStack || (state.interpolationStack = [])).push(state.tokenize);
+ }
+
+ function popInterpolationStack(state) {
+ return (state.interpolationStack || (state.interpolationStack = [])).pop();
+ }
+
+ function sizeInterpolationStack(state) {
+ return state.interpolationStack ? state.interpolationStack.length : 0;
+ }
+
+ CodeMirror.defineMIME("application/dart", {
+ name: "clike",
+ keywords: set(keywords),
+ blockKeywords: set(blockKeywords),
+ builtin: set(builtins),
+ atoms: set(atoms),
+ hooks: {
+ "@": function(stream) {
+ stream.eatWhile(/[\w\$_]/);
+ return "meta";
+ },
+
+ // custom string handling to deal with triple-quoted strings and string interpolation
+ "'": function(stream, state) {
+ return tokenString("'", stream, state, false);
+ },
+ "\"": function(stream, state) {
+ return tokenString("\"", stream, state, false);
+ },
+ "r": function(stream, state) {
+ var peek = stream.peek();
+ if (peek == "'" || peek == "\"") {
+ return tokenString(stream.next(), stream, state, true);
+ }
+ return false;
+ },
+
+ "}": function(_stream, state) {
+ // "}" is end of interpolation, if interpolation stack is non-empty
+ if (sizeInterpolationStack(state) > 0) {
+ state.tokenize = popInterpolationStack(state);
+ return null;
+ }
+ return false;
+ }
+ }
+ });
+
+ function tokenString(quote, stream, state, raw) {
+ var tripleQuoted = false;
+ if (stream.eat(quote)) {
+ if (stream.eat(quote)) tripleQuoted = true;
+ else return "string"; //empty string
+ }
+ function tokenStringHelper(stream, state) {
+ var escaped = false;
+ while (!stream.eol()) {
+ if (!raw && !escaped && stream.peek() == "$") {
+ pushInterpolationStack(state);
+ state.tokenize = tokenInterpolation;
+ return "string";
+ }
+ var next = stream.next();
+ if (next == quote && !escaped && (!tripleQuoted || stream.match(quote + quote))) {
+ state.tokenize = null;
+ break;
+ }
+ escaped = !escaped && next == "\\";
+ }
+ return "string";
+ }
+ state.tokenize = tokenStringHelper;
+ return tokenStringHelper(stream, state);
+ }
+
+ function tokenInterpolation(stream, state) {
+ stream.eat("$");
+ if (stream.eat("{")) {
+ // let clike handle the content of ${...},
+ // we take over again when "}" appears (see hooks).
+ state.tokenize = null;
+ } else {
+ state.tokenize = tokenInterpolationIdentifier;
+ }
+ return null;
+ }
+
+ function tokenInterpolationIdentifier(stream, state) {
+ stream.eatWhile(/[\w_]/);
+ state.tokenize = popInterpolationStack(state);
+ return "variable";
+ }
+
+ CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins));
+
+ // This is needed to make loading through meta.js work.
+ CodeMirror.defineMode("dart", function(conf) {
+ return CodeMirror.getMode(conf, "application/dart");
+ }, "clike");
+});
diff --git a/data/ext/editorText/codemirror/mode/dart/index.html b/data/ext/editorText/codemirror/mode/dart/index.html
new file mode 100644
index 000000000..e79da5a8b
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/dart/index.html
@@ -0,0 +1,71 @@
+<!doctype html>
+
+<title>CodeMirror: Dart mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../clike/clike.js"></script>
+<script src="dart.js"></script>
+<style>.CodeMirror {border: 1px solid #dee;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Dart</a>
+ </ul>
+</div>
+
+<article>
+<h2>Dart mode</h2>
+<form>
+<textarea id="code" name="code">
+import 'dart:math' show Random;
+
+void main() {
+ print(new Die(n: 12).roll());
+}
+
+// Define a class.
+class Die {
+ // Define a class variable.
+ static Random shaker = new Random();
+
+ // Define instance variables.
+ int sides, value;
+
+ // Define a method using shorthand syntax.
+ String toString() => '$value';
+
+ // Define a constructor.
+ Die({int n: 6}) {
+ if (4 <= n && n <= 20) {
+ sides = n;
+ } else {
+ // Support for errors and exceptions.
+ throw new ArgumentError(/* */);
+ }
+ }
+
+ // Define an instance method.
+ int roll() {
+ return value = shaker.nextInt(sides) + 1;
+ }
+}
+</textarea>
+</form>
+
+<script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "application/dart"
+ });
+</script>
+
+</article>
diff --git a/data/ext/editorText/codemirror/mode/diff/diff.js b/data/ext/editorText/codemirror/mode/diff/diff.js
index 9a0d90ea5..fe0305e7b 100644
--- a/data/ext/editorText/codemirror/mode/diff/diff.js
+++ b/data/ext/editorText/codemirror/mode/diff/diff.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("diff", function() {
var TOKEN_NAMES = {
@@ -30,3 +43,5 @@ CodeMirror.defineMode("diff", function() {
});
CodeMirror.defineMIME("text/x-diff", "diff");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/diff/index.html b/data/ext/editorText/codemirror/mode/diff/index.html
index 6ceae8b33..0af611fa4 100644
--- a/data/ext/editorText/codemirror/mode/diff/index.html
+++ b/data/ext/editorText/codemirror/mode/diff/index.html
@@ -15,12 +15,12 @@
span.cm-error.cm-tag { background-color: #2b2; }
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/django/django.js b/data/ext/editorText/codemirror/mode/django/django.js
index 58492b2b6..2f08b0631 100644
--- a/data/ext/editorText/codemirror/mode/django/django.js
+++ b/data/ext/editorText/codemirror/mode/django/django.js
@@ -1,47 +1,342 @@
-(function(CodeMirror) {
+// 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"), require("../htmlmixed/htmlmixed"),
+ require("../../addon/mode/overlay"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
+ "../../addon/mode/overlay"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode("django:inner", function() {
- var keywords = ["block", "endblock", "for", "endfor", "in", "true", "false",
- "loop", "none", "self", "super", "if", "endif", "as", "not", "and",
+ var keywords = ["block", "endblock", "for", "endfor", "true", "false",
+ "loop", "none", "self", "super", "if", "endif", "as",
"else", "import", "with", "endwith", "without", "context", "ifequal", "endifequal",
- "ifnotequal", "endifnotequal", "extends", "include", "load", "length", "comment",
- "endcomment", "empty"];
- keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b");
+ "ifnotequal", "endifnotequal", "extends", "include", "load", "comment",
+ "endcomment", "empty", "url", "static", "trans", "blocktrans", "now", "regroup",
+ "lorem", "ifchanged", "endifchanged", "firstof", "debug", "cycle", "csrf_token",
+ "autoescape", "endautoescape", "spaceless", "ssi", "templatetag",
+ "verbatim", "endverbatim", "widthratio"],
+ filters = ["add", "addslashes", "capfirst", "center", "cut", "date",
+ "default", "default_if_none", "dictsort",
+ "dictsortreversed", "divisibleby", "escape", "escapejs",
+ "filesizeformat", "first", "floatformat", "force_escape",
+ "get_digit", "iriencode", "join", "last", "length",
+ "length_is", "linebreaks", "linebreaksbr", "linenumbers",
+ "ljust", "lower", "make_list", "phone2numeric", "pluralize",
+ "pprint", "random", "removetags", "rjust", "safe",
+ "safeseq", "slice", "slugify", "stringformat", "striptags",
+ "time", "timesince", "timeuntil", "title", "truncatechars",
+ "truncatechars_html", "truncatewords", "truncatewords_html",
+ "unordered_list", "upper", "urlencode", "urlize",
+ "urlizetrunc", "wordcount", "wordwrap", "yesno"],
+ operators = ["==", "!=", "<", ">", "<=", ">=", "in", "not", "or", "and"];
+
+ keywords = new RegExp("^\\b(" + keywords.join("|") + ")\\b");
+ filters = new RegExp("^\\b(" + filters.join("|") + ")\\b");
+ operators = new RegExp("^\\b(" + operators.join("|") + ")\\b");
+ // We have to return "null" instead of null, in order to avoid string
+ // styling as the default, when using Django templates inside HTML
+ // element attributes
function tokenBase (stream, state) {
- stream.eatWhile(/[^\{]/);
- var ch = stream.next();
- if (ch == "{") {
- if (ch = stream.eat(/\{|%|#/)) {
- state.tokenize = inTag(ch);
- return "tag";
+ // Attempt to identify a variable, template or comment tag respectively
+ if (stream.match("{{")) {
+ state.tokenize = inVariable;
+ return "tag";
+ } else if (stream.match("{%")) {
+ state.tokenize = inTag;
+ return "tag";
+ } else if (stream.match("{#")) {
+ state.tokenize = inComment;
+ return "comment";
+ }
+
+ // Ignore completely any stream series that do not match the
+ // Django template opening tags.
+ while (stream.next() != null && !stream.match("{{", false) && !stream.match("{%", false)) {}
+ return null;
+ }
+
+ // A string can be included in either single or double quotes (this is
+ // the delimeter). Mark everything as a string until the start delimeter
+ // occurs again.
+ function inString (delimeter, previousTokenizer) {
+ return function (stream, state) {
+ if (!state.escapeNext && stream.eat(delimeter)) {
+ state.tokenize = previousTokenizer;
+ } else {
+ if (state.escapeNext) {
+ state.escapeNext = false;
+ }
+
+ var ch = stream.next();
+
+ // Take into account the backslash for escaping characters, such as
+ // the string delimeter.
+ if (ch == "\\") {
+ state.escapeNext = true;
+ }
+ }
+
+ return "string";
+ };
+ }
+
+ // Apply Django template variable syntax highlighting
+ function inVariable (stream, state) {
+ // Attempt to match a dot that precedes a property
+ if (state.waitDot) {
+ state.waitDot = false;
+
+ if (stream.peek() != ".") {
+ return "null";
+ }
+
+ // Dot folowed by a non-word character should be considered an error.
+ if (stream.match(/\.\W+/)) {
+ return "error";
+ } else if (stream.eat(".")) {
+ state.waitProperty = true;
+ return "null";
+ } else {
+ throw Error ("Unexpected error while waiting for property.");
}
}
+
+ // Attempt to match a pipe that precedes a filter
+ if (state.waitPipe) {
+ state.waitPipe = false;
+
+ if (stream.peek() != "|") {
+ return "null";
+ }
+
+ // Pipe folowed by a non-word character should be considered an error.
+ if (stream.match(/\.\W+/)) {
+ return "error";
+ } else if (stream.eat("|")) {
+ state.waitFilter = true;
+ return "null";
+ } else {
+ throw Error ("Unexpected error while waiting for filter.");
+ }
+ }
+
+ // Highlight properties
+ if (state.waitProperty) {
+ state.waitProperty = false;
+ if (stream.match(/\b(\w+)\b/)) {
+ state.waitDot = true; // A property can be followed by another property
+ state.waitPipe = true; // A property can be followed by a filter
+ return "property";
+ }
+ }
+
+ // Highlight filters
+ if (state.waitFilter) {
+ state.waitFilter = false;
+ if (stream.match(filters)) {
+ return "variable-2";
+ }
+ }
+
+ // Ignore all white spaces
+ if (stream.eatSpace()) {
+ state.waitProperty = false;
+ return "null";
+ }
+
+ // Identify numbers
+ if (stream.match(/\b\d+(\.\d+)?\b/)) {
+ return "number";
+ }
+
+ // Identify strings
+ if (stream.match("'")) {
+ state.tokenize = inString("'", state.tokenize);
+ return "string";
+ } else if (stream.match('"')) {
+ state.tokenize = inString('"', state.tokenize);
+ return "string";
+ }
+
+ // Attempt to find the variable
+ if (stream.match(/\b(\w+)\b/) && !state.foundVariable) {
+ state.waitDot = true;
+ state.waitPipe = true; // A property can be followed by a filter
+ return "variable";
+ }
+
+ // If found closing tag reset
+ if (stream.match("}}")) {
+ state.waitProperty = null;
+ state.waitFilter = null;
+ state.waitDot = null;
+ state.waitPipe = null;
+ state.tokenize = tokenBase;
+ return "tag";
+ }
+
+ // If nothing was found, advance to the next character
+ stream.next();
+ return "null";
}
- function inTag (close) {
- if (close == "{") {
- close = "}";
+
+ function inTag (stream, state) {
+ // Attempt to match a dot that precedes a property
+ if (state.waitDot) {
+ state.waitDot = false;
+
+ if (stream.peek() != ".") {
+ return "null";
+ }
+
+ // Dot folowed by a non-word character should be considered an error.
+ if (stream.match(/\.\W+/)) {
+ return "error";
+ } else if (stream.eat(".")) {
+ state.waitProperty = true;
+ return "null";
+ } else {
+ throw Error ("Unexpected error while waiting for property.");
+ }
}
- return function (stream, state) {
- var ch = stream.next();
- if ((ch == close) && stream.eat("}")) {
- state.tokenize = tokenBase;
- return "tag";
+
+ // Attempt to match a pipe that precedes a filter
+ if (state.waitPipe) {
+ state.waitPipe = false;
+
+ if (stream.peek() != "|") {
+ return "null";
}
- if (stream.match(keywords)) {
- return "keyword";
+
+ // Pipe folowed by a non-word character should be considered an error.
+ if (stream.match(/\.\W+/)) {
+ return "error";
+ } else if (stream.eat("|")) {
+ state.waitFilter = true;
+ return "null";
+ } else {
+ throw Error ("Unexpected error while waiting for filter.");
}
- return close == "#" ? "comment" : "string";
- };
+ }
+
+ // Highlight properties
+ if (state.waitProperty) {
+ state.waitProperty = false;
+ if (stream.match(/\b(\w+)\b/)) {
+ state.waitDot = true; // A property can be followed by another property
+ state.waitPipe = true; // A property can be followed by a filter
+ return "property";
+ }
+ }
+
+ // Highlight filters
+ if (state.waitFilter) {
+ state.waitFilter = false;
+ if (stream.match(filters)) {
+ return "variable-2";
+ }
+ }
+
+ // Ignore all white spaces
+ if (stream.eatSpace()) {
+ state.waitProperty = false;
+ return "null";
+ }
+
+ // Identify numbers
+ if (stream.match(/\b\d+(\.\d+)?\b/)) {
+ return "number";
+ }
+
+ // Identify strings
+ if (stream.match("'")) {
+ state.tokenize = inString("'", state.tokenize);
+ return "string";
+ } else if (stream.match('"')) {
+ state.tokenize = inString('"', state.tokenize);
+ return "string";
+ }
+
+ // Attempt to match an operator
+ if (stream.match(operators)) {
+ return "operator";
+ }
+
+ // Attempt to match a keyword
+ var keywordMatch = stream.match(keywords);
+ if (keywordMatch) {
+ if (keywordMatch[0] == "comment") {
+ state.blockCommentTag = true;
+ }
+ return "keyword";
+ }
+
+ // Attempt to match a variable
+ if (stream.match(/\b(\w+)\b/)) {
+ state.waitDot = true;
+ state.waitPipe = true; // A property can be followed by a filter
+ return "variable";
+ }
+
+ // If found closing tag reset
+ if (stream.match("%}")) {
+ state.waitProperty = null;
+ state.waitFilter = null;
+ state.waitDot = null;
+ state.waitPipe = null;
+ // If the tag that closes is a block comment tag, we want to mark the
+ // following code as comment, until the tag closes.
+ if (state.blockCommentTag) {
+ state.blockCommentTag = false; // Release the "lock"
+ state.tokenize = inBlockComment;
+ } else {
+ state.tokenize = tokenBase;
+ }
+ return "tag";
+ }
+
+ // If nothing was found, advance to the next character
+ stream.next();
+ return "null";
+ }
+
+ // Mark everything as comment inside the tag and the tag itself.
+ function inComment (stream, state) {
+ if (stream.match("#}")) {
+ state.tokenize = tokenBase;
+ }
+ return "comment";
+ }
+
+ // Mark everything as a comment until the `blockcomment` tag closes.
+ function inBlockComment (stream, state) {
+ if (stream.match(/\{%\s*endcomment\s*%\}/, false)) {
+ state.tokenize = inTag;
+ stream.match("{%");
+ return "tag";
+ } else {
+ stream.next();
+ return "comment";
+ }
}
+
return {
startState: function () {
return {tokenize: tokenBase};
},
token: function (stream, state) {
return state.tokenize(stream, state);
- }
+ },
+ blockCommentStart: "{% comment %}",
+ blockCommentEnd: "{% endcomment %}"
};
});
@@ -52,4 +347,4 @@
});
CodeMirror.defineMIME("text/x-django", "django");
-})(CodeMirror);
+});
diff --git a/data/ext/editorText/codemirror/mode/django/index.html b/data/ext/editorText/codemirror/mode/django/index.html
index 07963bc61..41ea07c91 100644
--- a/data/ext/editorText/codemirror/mode/django/index.html
+++ b/data/ext/editorText/codemirror/mode/django/index.html
@@ -5,6 +5,7 @@
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
+<link rel="stylesheet" href="../../theme/mdn-like.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/mode/overlay.js"></script>
<script src="../xml/xml.js"></script>
@@ -12,12 +13,12 @@
<script src="django.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -30,21 +31,29 @@
<form><textarea id="code" name="code">
<!doctype html>
<html>
- <head>
- <title>My Django web application</title>
- </head>
- <body>
- <h1>
- {{ page.title }}
- </h1>
- <ul class="my-list">
- {% for item in items %}
- <li>{% item.name %}</li>
- {% empty %}
- <li>You have no items in your list.</li>
- {% endfor %}
- </ul>
- </body>
+ <head>
+ <title>My Django web application</title>
+ </head>
+ <body>
+ <h1>
+ {{ page.title|capfirst }}
+ </h1>
+ <ul class="my-list">
+ {# traverse a list of items and produce links to their views. #}
+ {% for item in items %}
+ <li>
+ <a href="{% url 'item_view' item.name|slugify %}">
+ {{ item.name }}
+ </a>
+ </li>
+ {% empty %}
+ <li>You have no items in your list.</li>
+ {% endfor %}
+ </ul>
+ {% comment "this is a forgotten footer" %}
+ <footer></footer>
+ {% endcomment %}
+ </body>
</html>
</textarea></form>
@@ -52,8 +61,9 @@
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
mode: "django",
- indentUnit: 4,
- indentWithTabs: true
+ indentUnit: 2,
+ indentWithTabs: true,
+ theme: "mdn-like"
});
</script>
diff --git a/data/ext/editorText/codemirror/mode/dockerfile/dockerfile.js b/data/ext/editorText/codemirror/mode/dockerfile/dockerfile.js
new file mode 100644
index 000000000..4419009af
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/dockerfile/dockerfile.js
@@ -0,0 +1,79 @@
+// 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"), require("../../addon/mode/simple"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ // Collect all Dockerfile directives
+ var instructions = ["from", "maintainer", "run", "cmd", "expose", "env",
+ "add", "copy", "entrypoint", "volume", "user",
+ "workdir", "onbuild"],
+ instructionRegex = "(" + instructions.join('|') + ")",
+ instructionOnlyLine = new RegExp(instructionRegex + "\\s*$", "i"),
+ instructionWithArguments = new RegExp(instructionRegex + "(\\s+)", "i");
+
+ CodeMirror.defineSimpleMode("dockerfile", {
+ start: [
+ // Block comment: This is a line starting with a comment
+ {
+ regex: /#.*$/,
+ token: "comment"
+ },
+ // Highlight an instruction without any arguments (for convenience)
+ {
+ regex: instructionOnlyLine,
+ token: "variable-2"
+ },
+ // Highlight an instruction followed by arguments
+ {
+ regex: instructionWithArguments,
+ token: ["variable-2", null],
+ next: "arguments"
+ },
+ {
+ regex: /./,
+ token: null
+ }
+ ],
+ arguments: [
+ {
+ // Line comment without instruction arguments is an error
+ regex: /#.*$/,
+ token: "error",
+ next: "start"
+ },
+ {
+ regex: /[^#]+\\$/,
+ token: null
+ },
+ {
+ // Match everything except for the inline comment
+ regex: /[^#]+/,
+ token: null,
+ next: "start"
+ },
+ {
+ regex: /$/,
+ token: null,
+ next: "start"
+ },
+ // Fail safe return to start
+ {
+ token: null,
+ next: "start"
+ }
+ ],
+ meta: {
+ lineComment: "#"
+ }
+ });
+
+ CodeMirror.defineMIME("text/x-dockerfile", "dockerfile");
+});
diff --git a/data/ext/editorText/codemirror/mode/dockerfile/index.html b/data/ext/editorText/codemirror/mode/dockerfile/index.html
new file mode 100644
index 000000000..a31759bce
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/dockerfile/index.html
@@ -0,0 +1,73 @@
+<!doctype html>
+
+<title>CodeMirror: Dockerfile mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/mode/simple.js"></script>
+<script src="dockerfile.js"></script>
+<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Dockerfile</a>
+ </ul>
+</div>
+
+<article>
+<h2>Dockerfile mode</h2>
+<form><textarea id="code" name="code"># Install Ghost blogging platform and run development environment
+#
+# VERSION 1.0.0
+
+FROM ubuntu:12.10
+MAINTAINER Amer Grgic "[email protected]"
+WORKDIR /data/ghost
+
+# Install dependencies for nginx installation
+RUN apt-get update
+RUN apt-get install -y python g++ make software-properties-common --force-yes
+RUN add-apt-repository ppa:chris-lea/node.js
+RUN apt-get update
+# Install unzip
+RUN apt-get install -y unzip
+# Install curl
+RUN apt-get install -y curl
+# Install nodejs & npm
+RUN apt-get install -y rlwrap
+RUN apt-get install -y nodejs
+# Download Ghost v0.4.1
+RUN curl -L https://ghost.org/zip/ghost-latest.zip -o /tmp/ghost.zip
+# Unzip Ghost zip to /data/ghost
+RUN unzip -uo /tmp/ghost.zip -d /data/ghost
+# Add custom config js to /data/ghost
+ADD ./config.example.js /data/ghost/config.js
+# Install Ghost with NPM
+RUN cd /data/ghost/ && npm install --production
+# Expose port 2368
+EXPOSE 2368
+# Run Ghost
+CMD ["npm","start"]
+</textarea></form>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "dockerfile"
+ });
+ </script>
+
+ <p>Dockerfile syntax highlighting for CodeMirror. Depends on
+ the <a href="../../demo/simplemode.html">simplemode</a> addon.</p>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-dockerfile</code></p>
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/dtd/dtd.js b/data/ext/editorText/codemirror/mode/dtd/dtd.js
index 7033bf0f8..f37029a77 100644
--- a/data/ext/editorText/codemirror/mode/dtd/dtd.js
+++ b/data/ext/editorText/codemirror/mode/dtd/dtd.js
@@ -1,10 +1,23 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/*
DTD mode
Ported to CodeMirror by Peter Kroon <[email protected]>
- Report bugs/issues here: https://github.com/marijnh/CodeMirror/issues
+ Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
GitHub: @peterkroon
*/
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("dtd", function(config) {
var indentUnit = config.indentUnit, type;
function ret(style, tp) {type = tp; return style;}
@@ -125,3 +138,5 @@ CodeMirror.defineMode("dtd", function(config) {
});
CodeMirror.defineMIME("application/xml-dtd", "dtd");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/dtd/index.html b/data/ext/editorText/codemirror/mode/dtd/index.html
index 076d827f7..e6798a748 100644
--- a/data/ext/editorText/codemirror/mode/dtd/index.html
+++ b/data/ext/editorText/codemirror/mode/dtd/index.html
@@ -9,12 +9,12 @@
<script src="dtd.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/dylan/dylan.js b/data/ext/editorText/codemirror/mode/dylan/dylan.js
index d81ef0cbc..85f0166c1 100644
--- a/data/ext/editorText/codemirror/mode/dylan/dylan.js
+++ b/data/ext/editorText/codemirror/mode/dylan/dylan.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("dylan", function(_config) {
// Words
var words = {
@@ -141,20 +154,12 @@ CodeMirror.defineMode("dylan", function(_config) {
return f(stream, state);
}
- var type, content;
-
- function ret(_type, style, _content) {
- type = _type;
- content = _content;
- return style;
- }
-
function tokenBase(stream, state) {
// String
var ch = stream.peek();
if (ch == "'" || ch == '"') {
stream.next();
- return chain(stream, state, tokenString(ch, "string", "string"));
+ return chain(stream, state, tokenString(ch, "string"));
}
// Comment
else if (ch == "/") {
@@ -163,16 +168,16 @@ CodeMirror.defineMode("dylan", function(_config) {
return chain(stream, state, tokenComment);
} else if (stream.eat("/")) {
stream.skipToEnd();
- return ret("comment", "comment");
+ return "comment";
} else {
stream.skipTo(" ");
- return ret("operator", "operator");
+ return "operator";
}
}
// Decimal
else if (/\d/.test(ch)) {
stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
- return ret("number", "number");
+ return "number";
}
// Hash
else if (ch == "#") {
@@ -181,33 +186,33 @@ CodeMirror.defineMode("dylan", function(_config) {
ch = stream.peek();
if (ch == '"') {
stream.next();
- return chain(stream, state, tokenString('"', "symbol", "string-2"));
+ return chain(stream, state, tokenString('"', "string-2"));
}
// Binary number
else if (ch == "b") {
stream.next();
stream.eatWhile(/[01]/);
- return ret("number", "number");
+ return "number";
}
// Hex number
else if (ch == "x") {
stream.next();
stream.eatWhile(/[\da-f]/i);
- return ret("number", "number");
+ return "number";
}
// Octal number
else if (ch == "o") {
stream.next();
stream.eatWhile(/[0-7]/);
- return ret("number", "number");
+ return "number";
}
// Hash symbol
else {
stream.eatWhile(/[-a-zA-Z]/);
- return ret("hash", "keyword");
+ return "keyword";
}
} else if (stream.match("end")) {
- return ret("end", "keyword");
+ return "keyword";
}
for (var name in patterns) {
if (patterns.hasOwnProperty(name)) {
@@ -215,21 +220,21 @@ CodeMirror.defineMode("dylan", function(_config) {
if ((pattern instanceof Array && pattern.some(function(p) {
return stream.match(p);
})) || stream.match(pattern))
- return ret(name, patternStyles[name], stream.current());
+ return patternStyles[name];
}
}
if (stream.match("define")) {
- return ret("definition", "def");
+ return "def";
} else {
stream.eatWhile(/[\w\-]/);
// Keyword
if (wordLookup[stream.current()]) {
- return ret(wordLookup[stream.current()], styleLookup[stream.current()], stream.current());
+ return styleLookup[stream.current()];
} else if (stream.current().match(symbol)) {
- return ret("variable", "variable");
+ return "variable";
} else {
stream.next();
- return ret("other", "variable-2");
+ return "variable-2";
}
}
}
@@ -244,10 +249,10 @@ CodeMirror.defineMode("dylan", function(_config) {
}
maybeEnd = (ch == "*");
}
- return ret("comment", "comment");
+ return "comment";
}
- function tokenString(quote, type, style) {
+ function tokenString(quote, style) {
return function(stream, state) {
var next, end = false;
while ((next = stream.next()) != null) {
@@ -258,7 +263,7 @@ CodeMirror.defineMode("dylan", function(_config) {
}
if (end)
state.tokenize = tokenBase;
- return ret(type, style);
+ return style;
};
}
@@ -282,3 +287,5 @@ CodeMirror.defineMode("dylan", function(_config) {
});
CodeMirror.defineMIME("text/x-dylan", "dylan");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/dylan/index.html b/data/ext/editorText/codemirror/mode/dylan/index.html
index 049f93cc6..ddf5ad067 100644
--- a/data/ext/editorText/codemirror/mode/dylan/index.html
+++ b/data/ext/editorText/codemirror/mode/dylan/index.html
@@ -12,12 +12,12 @@
<script src="dylan.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/ebnf/ebnf.js b/data/ext/editorText/codemirror/mode/ebnf/ebnf.js
new file mode 100644
index 000000000..6b51aba07
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/ebnf/ebnf.js
@@ -0,0 +1,195 @@
+// 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";
+
+ CodeMirror.defineMode("ebnf", function (config) {
+ var commentType = {slash: 0, parenthesis: 1};
+ var stateType = {comment: 0, _string: 1, characterClass: 2};
+ var bracesMode = null;
+
+ if (config.bracesMode)
+ bracesMode = CodeMirror.getMode(config, config.bracesMode);
+
+ return {
+ startState: function () {
+ return {
+ stringType: null,
+ commentType: null,
+ braced: 0,
+ lhs: true,
+ localState: null,
+ stack: [],
+ inDefinition: false
+ };
+ },
+ token: function (stream, state) {
+ if (!stream) return;
+
+ //check for state changes
+ if (state.stack.length === 0) {
+ //strings
+ if ((stream.peek() == '"') || (stream.peek() == "'")) {
+ state.stringType = stream.peek();
+ stream.next(); // Skip quote
+ state.stack.unshift(stateType._string);
+ } else if (stream.match(/^\/\*/)) { //comments starting with /*
+ state.stack.unshift(stateType.comment);
+ state.commentType = commentType.slash;
+ } else if (stream.match(/^\(\*/)) { //comments starting with (*
+ state.stack.unshift(stateType.comment);
+ state.commentType = commentType.parenthesis;
+ }
+ }
+
+ //return state
+ //stack has
+ switch (state.stack[0]) {
+ case stateType._string:
+ while (state.stack[0] === stateType._string && !stream.eol()) {
+ if (stream.peek() === state.stringType) {
+ stream.next(); // Skip quote
+ state.stack.shift(); // Clear flag
+ } else if (stream.peek() === "\\") {
+ stream.next();
+ stream.next();
+ } else {
+ stream.match(/^.[^\\\"\']*/);
+ }
+ }
+ return state.lhs ? "property string" : "string"; // Token style
+
+ case stateType.comment:
+ while (state.stack[0] === stateType.comment && !stream.eol()) {
+ if (state.commentType === commentType.slash && stream.match(/\*\//)) {
+ state.stack.shift(); // Clear flag
+ state.commentType = null;
+ } else if (state.commentType === commentType.parenthesis && stream.match(/\*\)/)) {
+ state.stack.shift(); // Clear flag
+ state.commentType = null;
+ } else {
+ stream.match(/^.[^\*]*/);
+ }
+ }
+ return "comment";
+
+ case stateType.characterClass:
+ while (state.stack[0] === stateType.characterClass && !stream.eol()) {
+ if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./))) {
+ state.stack.shift();
+ }
+ }
+ return "operator";
+ }
+
+ var peek = stream.peek();
+
+ if (bracesMode !== null && (state.braced || peek === "{")) {
+ if (state.localState === null)
+ state.localState = bracesMode.startState();
+
+ var token = bracesMode.token(stream, state.localState),
+ text = stream.current();
+
+ if (!token) {
+ for (var i = 0; i < text.length; i++) {
+ if (text[i] === "{") {
+ if (state.braced === 0) {
+ token = "matchingbracket";
+ }
+ state.braced++;
+ } else if (text[i] === "}") {
+ state.braced--;
+ if (state.braced === 0) {
+ token = "matchingbracket";
+ }
+ }
+ }
+ }
+ return token;
+ }
+
+ //no stack
+ switch (peek) {
+ case "[":
+ stream.next();
+ state.stack.unshift(stateType.characterClass);
+ return "bracket";
+ case ":":
+ case "|":
+ case ";":
+ stream.next();
+ return "operator";
+ case "%":
+ if (stream.match("%%")) {
+ return "header";
+ } else if (stream.match(/[%][A-Za-z]+/)) {
+ return "keyword";
+ } else if (stream.match(/[%][}]/)) {
+ return "matchingbracket";
+ }
+ break;
+ case "/":
+ if (stream.match(/[\/][A-Za-z]+/)) {
+ return "keyword";
+ }
+ case "\\":
+ if (stream.match(/[\][a-z]+/)) {
+ return "string-2";
+ }
+ case ".":
+ if (stream.match(".")) {
+ return "atom";
+ }
+ case "*":
+ case "-":
+ case "+":
+ case "^":
+ if (stream.match(peek)) {
+ return "atom";
+ }
+ case "$":
+ if (stream.match("$$")) {
+ return "builtin";
+ } else if (stream.match(/[$][0-9]+/)) {
+ return "variable-3";
+ }
+ case "<":
+ if (stream.match(/<<[a-zA-Z_]+>>/)) {
+ return "builtin";
+ }
+ }
+
+ if (stream.match(/^\/\//)) {
+ stream.skipToEnd();
+ return "comment";
+ } else if (stream.match(/return/)) {
+ return "operator";
+ } else if (stream.match(/^[a-zA-Z_][a-zA-Z0-9_]*/)) {
+ if (stream.match(/(?=[\(.])/)) {
+ return "variable";
+ } else if (stream.match(/(?=[\s\n]*[:=])/)) {
+ return "def";
+ }
+ return "variable-2";
+ } else if (["[", "]", "(", ")"].indexOf(stream.peek()) != -1) {
+ stream.next();
+ return "bracket";
+ } else if (!stream.eatSpace()) {
+ stream.next();
+ }
+ return null;
+ }
+ };
+ });
+
+ CodeMirror.defineMIME("text/x-ebnf", "ebnf");
+});
diff --git a/data/ext/editorText/codemirror/mode/ebnf/index.html b/data/ext/editorText/codemirror/mode/ebnf/index.html
new file mode 100644
index 000000000..13845629b
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/ebnf/index.html
@@ -0,0 +1,102 @@
+<!doctype html>
+<html>
+ <head>
+ <title>CodeMirror: EBNF Mode</title>
+ <meta charset="utf-8"/>
+ <link rel=stylesheet href="../../doc/docs.css">
+
+ <link rel="stylesheet" href="../../lib/codemirror.css">
+ <script src="../../lib/codemirror.js"></script>
+ <script src="../javascript/javascript.js"></script>
+ <script src="ebnf.js"></script>
+ <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+ </head>
+ <body>
+ <div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">EBNF Mode</a>
+ </ul>
+ </div>
+
+ <article>
+ <h2>EBNF Mode (bracesMode setting = "javascript")</h2>
+ <form><textarea id="code" name="code">
+/* description: Parses end executes mathematical expressions. */
+
+/* lexical grammar */
+%lex
+
+%%
+\s+ /* skip whitespace */
+[0-9]+("."[0-9]+)?\b return 'NUMBER';
+"*" return '*';
+"/" return '/';
+"-" return '-';
+"+" return '+';
+"^" return '^';
+"(" return '(';
+")" return ')';
+"PI" return 'PI';
+"E" return 'E';
+&lt;&lt;EOF&gt;&gt; return 'EOF';
+
+/lex
+
+/* operator associations and precedence */
+
+%left '+' '-'
+%left '*' '/'
+%left '^'
+%left UMINUS
+
+%start expressions
+
+%% /* language grammar */
+
+expressions
+: e EOF
+{print($1); return $1;}
+;
+
+e
+: e '+' e
+{$$ = $1+$3;}
+| e '-' e
+{$$ = $1-$3;}
+| e '*' e
+{$$ = $1*$3;}
+| e '/' e
+{$$ = $1/$3;}
+| e '^' e
+{$$ = Math.pow($1, $3);}
+| '-' e %prec UMINUS
+{$$ = -$2;}
+| '(' e ')'
+{$$ = $2;}
+| NUMBER
+{$$ = Number(yytext);}
+| E
+{$$ = Math.E;}
+| PI
+{$$ = Math.PI;}
+;</textarea></form>
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ mode: {name: "ebnf"},
+ lineNumbers: true,
+ bracesMode: 'javascript'
+ });
+ </script>
+ <h3>The EBNF Mode</h3>
+ <p> Created by <a href="https://github.com/robertleeplummerjr">Robert Plummer</a></p>
+ </article>
+ </body>
+</html>
diff --git a/data/ext/editorText/codemirror/mode/ecl/ecl.js b/data/ext/editorText/codemirror/mode/ecl/ecl.js
index 7601b189a..8df7ebe4a 100644
--- a/data/ext/editorText/codemirror/mode/ecl/ecl.js
+++ b/data/ext/editorText/codemirror/mode/ecl/ecl.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("ecl", function(config) {
function words(str) {
@@ -21,7 +34,6 @@ CodeMirror.defineMode("ecl", function(config) {
var blockKeywords = words("catch class do else finally for if switch try while");
var atoms = words("true false null");
var hooks = {"#": metaHook};
- var multiLineStrings;
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
var curPunc;
@@ -99,7 +111,7 @@ CodeMirror.defineMode("ecl", function(config) {
if (next == quote && !escaped) {end = true; break;}
escaped = !escaped && next == "\\";
}
- if (end || !(escaped || multiLineStrings))
+ if (end || !escaped)
state.tokenize = tokenBase;
return "string";
};
@@ -190,3 +202,5 @@ CodeMirror.defineMode("ecl", function(config) {
});
CodeMirror.defineMIME("text/x-ecl", "ecl");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/ecl/index.html b/data/ext/editorText/codemirror/mode/ecl/index.html
index f4b612d61..2306860dc 100644
--- a/data/ext/editorText/codemirror/mode/ecl/index.html
+++ b/data/ext/editorText/codemirror/mode/ecl/index.html
@@ -9,12 +9,12 @@
<script src="ecl.js"></script>
<style>.CodeMirror {border: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/eiffel/eiffel.js b/data/ext/editorText/codemirror/mode/eiffel/eiffel.js
index 15f34a932..b8b70e36e 100644
--- a/data/ext/editorText/codemirror/mode/eiffel/eiffel.js
+++ b/data/ext/editorText/codemirror/mode/eiffel/eiffel.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("eiffel", function() {
function wordObj(words) {
var o = {};
@@ -71,7 +84,6 @@ CodeMirror.defineMode("eiffel", function() {
'or'
]);
var operators = wordObj([":=", "and then","and", "or","<<",">>"]);
- var curPunc;
function chain(newtok, stream, state) {
state.tokenize.push(newtok);
@@ -79,7 +91,6 @@ CodeMirror.defineMode("eiffel", function() {
}
function tokenBase(stream, state) {
- curPunc = null;
if (stream.eatSpace()) return null;
var ch = stream.next();
if (ch == '"'||ch == "'") {
@@ -145,3 +156,5 @@ CodeMirror.defineMode("eiffel", function() {
});
CodeMirror.defineMIME("text/x-eiffel", "eiffel");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/eiffel/index.html b/data/ext/editorText/codemirror/mode/eiffel/index.html
index 95c5f885b..108a71bec 100644
--- a/data/ext/editorText/codemirror/mode/eiffel/index.html
+++ b/data/ext/editorText/codemirror/mode/eiffel/index.html
@@ -13,12 +13,12 @@
.cm-s-default span.cm-arrow { color: red; }
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/elm/elm.js b/data/ext/editorText/codemirror/mode/elm/elm.js
new file mode 100644
index 000000000..b31e66375
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/elm/elm.js
@@ -0,0 +1,205 @@
+// 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";
+
+ CodeMirror.defineMode("elm", function() {
+
+ function switchState(source, setState, f) {
+ setState(f);
+ return f(source, setState);
+ }
+
+ // These should all be Unicode extended, as per the Haskell 2010 report
+ var smallRE = /[a-z_]/;
+ var largeRE = /[A-Z]/;
+ var digitRE = /[0-9]/;
+ var hexitRE = /[0-9A-Fa-f]/;
+ var octitRE = /[0-7]/;
+ var idRE = /[a-z_A-Z0-9\']/;
+ var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]/;
+ var specialRE = /[(),;[\]`{}]/;
+ var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
+
+ function normal() {
+ return function (source, setState) {
+ if (source.eatWhile(whiteCharRE)) {
+ return null;
+ }
+
+ var ch = source.next();
+ if (specialRE.test(ch)) {
+ if (ch == '{' && source.eat('-')) {
+ var t = "comment";
+ if (source.eat('#')) t = "meta";
+ return switchState(source, setState, ncomment(t, 1));
+ }
+ return null;
+ }
+
+ if (ch == '\'') {
+ if (source.eat('\\'))
+ source.next(); // should handle other escapes here
+ else
+ source.next();
+
+ if (source.eat('\''))
+ return "string";
+ return "error";
+ }
+
+ if (ch == '"') {
+ return switchState(source, setState, stringLiteral);
+ }
+
+ if (largeRE.test(ch)) {
+ source.eatWhile(idRE);
+ if (source.eat('.'))
+ return "qualifier";
+ return "variable-2";
+ }
+
+ if (smallRE.test(ch)) {
+ var isDef = source.pos === 1;
+ source.eatWhile(idRE);
+ return isDef ? "variable-3" : "variable";
+ }
+
+ if (digitRE.test(ch)) {
+ if (ch == '0') {
+ if (source.eat(/[xX]/)) {
+ source.eatWhile(hexitRE); // should require at least 1
+ return "integer";
+ }
+ if (source.eat(/[oO]/)) {
+ source.eatWhile(octitRE); // should require at least 1
+ return "number";
+ }
+ }
+ source.eatWhile(digitRE);
+ var t = "number";
+ if (source.eat('.')) {
+ t = "number";
+ source.eatWhile(digitRE); // should require at least 1
+ }
+ if (source.eat(/[eE]/)) {
+ t = "number";
+ source.eat(/[-+]/);
+ source.eatWhile(digitRE); // should require at least 1
+ }
+ return t;
+ }
+
+ if (symbolRE.test(ch)) {
+ if (ch == '-' && source.eat(/-/)) {
+ source.eatWhile(/-/);
+ if (!source.eat(symbolRE)) {
+ source.skipToEnd();
+ return "comment";
+ }
+ }
+ source.eatWhile(symbolRE);
+ return "builtin";
+ }
+
+ return "error";
+ }
+ }
+
+ function ncomment(type, nest) {
+ if (nest == 0) {
+ return normal();
+ }
+ return function(source, setState) {
+ var currNest = nest;
+ while (!source.eol()) {
+ var ch = source.next();
+ if (ch == '{' && source.eat('-')) {
+ ++currNest;
+ } else if (ch == '-' && source.eat('}')) {
+ --currNest;
+ if (currNest == 0) {
+ setState(normal());
+ return type;
+ }
+ }
+ }
+ setState(ncomment(type, currNest));
+ return type;
+ }
+ }
+
+ function stringLiteral(source, setState) {
+ while (!source.eol()) {
+ var ch = source.next();
+ if (ch == '"') {
+ setState(normal());
+ return "string";
+ }
+ if (ch == '\\') {
+ if (source.eol() || source.eat(whiteCharRE)) {
+ setState(stringGap);
+ return "string";
+ }
+ if (!source.eat('&')) source.next(); // should handle other escapes here
+ }
+ }
+ setState(normal());
+ return "error";
+ }
+
+ function stringGap(source, setState) {
+ if (source.eat('\\')) {
+ return switchState(source, setState, stringLiteral);
+ }
+ source.next();
+ setState(normal());
+ return "error";
+ }
+
+
+ var wellKnownWords = (function() {
+ var wkw = {};
+
+ var keywords = [
+ "case", "of", "as",
+ "if", "then", "else",
+ "let", "in",
+ "infix", "infixl", "infixr",
+ "type", "alias",
+ "input", "output", "foreign", "loopback",
+ "module", "where", "import", "exposing",
+ "_", "..", "|", ":", "=", "\\", "\"", "->", "<-"
+ ];
+
+ for (var i = keywords.length; i--;)
+ wkw[keywords[i]] = "keyword";
+
+ return wkw;
+ })();
+
+
+
+ return {
+ startState: function () { return { f: normal() }; },
+ copyState: function (s) { return { f: s.f }; },
+
+ token: function(stream, state) {
+ var t = state.f(stream, function(s) { state.f = s; });
+ var w = stream.current();
+ return (wellKnownWords.hasOwnProperty(w)) ? wellKnownWords[w] : t;
+ }
+ };
+
+ });
+
+ CodeMirror.defineMIME("text/x-elm", "elm");
+});
diff --git a/data/ext/editorText/codemirror/mode/elm/index.html b/data/ext/editorText/codemirror/mode/elm/index.html
new file mode 100644
index 000000000..d5cb16abf
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/elm/index.html
@@ -0,0 +1,61 @@
+<!doctype html>
+
+<title>CodeMirror: Elm mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="elm.js"></script>
+<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Elm</a>
+ </ul>
+</div>
+
+<article>
+<h2>Elm mode</h2>
+
+<div><textarea id="code" name="code">
+import Color exposing (..)
+import Graphics.Collage exposing (..)
+import Graphics.Element exposing (..)
+import Time exposing (..)
+
+main =
+ Signal.map clock (every second)
+
+clock t =
+ collage 400 400
+ [ filled lightGrey (ngon 12 110)
+ , outlined (solid grey) (ngon 12 110)
+ , hand orange 100 t
+ , hand charcoal 100 (t/60)
+ , hand charcoal 60 (t/720)
+ ]
+
+hand clr len time =
+ let angle = degrees (90 - 6 * inSeconds time)
+ in
+ segment (0,0) (fromPolar (len,angle))
+ |> traced (solid clr)
+</textarea></div>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "text/x-elm"
+ });
+ </script>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-elm</code>.</p>
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/erlang/erlang.js b/data/ext/editorText/codemirror/mode/erlang/erlang.js
index 8908f9f41..5aed76a52 100644
--- a/data/ext/editorText/codemirror/mode/erlang/erlang.js
+++ b/data/ext/editorText/codemirror/mode/erlang/erlang.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/*jshint unused:true, eqnull:true, curly:true, bitwise:true */
/*jshint undef:true, latedef:true, trailing:true */
/*global CodeMirror:true */
@@ -12,6 +15,16 @@
// old guard/bif/conversion clashes (e.g. "float/1")
// type/spec/opaque
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMIME("text/x-erlang", "erlang");
CodeMirror.defineMode("erlang", function(cmCfg) {
@@ -207,8 +220,6 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
}else{
return rval(state,stream,"function");
}
- }else if (is_member(w,operatorAtomWords)) {
- return rval(state,stream,"operator");
}else if (lookahead(stream) == ":") {
if (w == "erlang") {
return rval(state,stream,"builtin");
@@ -217,8 +228,6 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
}
}else if (is_member(w,["true","false"])) {
return rval(state,stream,"boolean");
- }else if (is_member(w,["true","false"])) {
- return rval(state,stream,"boolean");
}else{
return rval(state,stream,"atom");
}
@@ -605,3 +614,5 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
lineComment: "%"
};
});
+
+});
diff --git a/data/ext/editorText/codemirror/mode/erlang/index.html b/data/ext/editorText/codemirror/mode/erlang/index.html
index 9cacb759f..6d06a890a 100644
--- a/data/ext/editorText/codemirror/mode/erlang/index.html
+++ b/data/ext/editorText/codemirror/mode/erlang/index.html
@@ -11,12 +11,12 @@
<script src="erlang.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/factor/factor.js b/data/ext/editorText/codemirror/mode/factor/factor.js
new file mode 100644
index 000000000..86d7adf62
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/factor/factor.js
@@ -0,0 +1,83 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Factor syntax highlight - simple mode
+//
+// by Dimage Sapelkin (https://github.com/kerabromsmu)
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineSimpleMode("factor", {
+ // The start state contains the rules that are intially used
+ start: [
+ // comments
+ {regex: /#?!.*/, token: "comment"},
+ // strings """, multiline --> state
+ {regex: /"""/, token: "string", next: "string3"},
+ {regex: /"/, token: "string", next: "string"},
+ // numbers: dec, hex, unicode, bin, fractional, complex
+ {regex: /(?:[+-]?)(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\d+.?\d*)/, token: "number"},
+ //{regex: /[+-]?/} //fractional
+ // definition: defining word, defined word, etc
+ {regex: /(\:)(\s+)(\S+)(\s+)(\()/, token: ["keyword", null, "def", null, "keyword"], next: "stack"},
+ // vocabulary using --> state
+ {regex: /USING\:/, token: "keyword", next: "vocabulary"},
+ // vocabulary definition/use
+ {regex: /(USE\:|IN\:)(\s+)(\S+)/, token: ["keyword", null, "variable-2"]},
+ // <constructors>
+ {regex: /<\S+>/, token: "builtin"},
+ // "keywords", incl. ; t f . [ ] { } defining words
+ {regex: /;|t|f|if|\.|\[|\]|\{|\}|MAIN:/, token: "keyword"},
+ // any id (?)
+ {regex: /\S+/, token: "variable"},
+
+ {
+ regex: /./,
+ token: null
+ }
+ ],
+ vocabulary: [
+ {regex: /;/, token: "keyword", next: "start"},
+ {regex: /\S+/, token: "variable-2"},
+ {
+ regex: /./,
+ token: null
+ }
+ ],
+ string: [
+ {regex: /(?:[^\\]|\\.)*?"/, token: "string", next: "start"},
+ {regex: /.*/, token: "string"}
+ ],
+ string3: [
+ {regex: /(?:[^\\]|\\.)*?"""/, token: "string", next: "start"},
+ {regex: /.*/, token: "string"}
+ ],
+ stack: [
+ {regex: /\)/, token: "meta", next: "start"},
+ {regex: /--/, token: "meta"},
+ {regex: /\S+/, token: "variable-3"},
+ {
+ regex: /./,
+ token: null
+ }
+ ],
+ // The meta property contains global information about the mode. It
+ // can contain properties like lineComment, which are supported by
+ // all modes, and also directives like dontIndentStates, which are
+ // specific to simple modes.
+ meta: {
+ dontIndentStates: ["start", "vocabulary", "string", "string3", "stack"],
+ lineComment: [ "!", "#!" ]
+ }
+ });
+
+ CodeMirror.defineMIME("text/x-factor", "factor");
+});
diff --git a/data/ext/editorText/codemirror/mode/factor/index.html b/data/ext/editorText/codemirror/mode/factor/index.html
new file mode 100644
index 000000000..9f1548914
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/factor/index.html
@@ -0,0 +1,77 @@
+<!doctype html>
+
+<title>CodeMirror: Factor mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/mode/simple.js"></script>
+<script src="factor.js"></script>
+<style>
+.CodeMirror {
+ font-family: 'Droid Sans Mono', monospace;
+ font-size: 14px;
+}
+</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Factor</a>
+ </ul>
+</div>
+
+<article>
+
+<h2>Factor mode</h2>
+
+<form><textarea id="code" name="code">
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+
+! A simple time server
+
+USING: accessors calendar calendar.format io io.encodings.ascii
+io.servers kernel threads ;
+IN: time-server
+
+: handle-time-client ( -- )
+ now timestamp>rfc822 print ;
+
+: <time-server> ( -- threaded-server )
+ ascii <threaded-server>
+ "time-server" >>name
+ 1234 >>insecure
+ [ handle-time-client ] >>handler ;
+
+: start-time-server ( -- )
+ <time-server> start-server drop ;
+
+MAIN: start-time-server
+</textarea>
+ </form>
+
+<script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ lineWrapping: true,
+ indentUnit: 2,
+ tabSize: 2,
+ autofocus: true,
+ mode: "text/x-factor"
+ });
+</script>
+<p/>
+<p>Simple mode that handles Factor Syntax (<a href="http://en.wikipedia.org/wiki/Factor_(programming_language)">Factor on WikiPedia</a>).</p>
+
+<p><strong>MIME types defined:</strong> <code>text/x-factor</code>.</p>
+
+</article>
diff --git a/data/ext/editorText/codemirror/mode/forth/forth.js b/data/ext/editorText/codemirror/mode/forth/forth.js
new file mode 100644
index 000000000..1f519d886
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/forth/forth.js
@@ -0,0 +1,180 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Author: Aliaksei Chapyzhenka
+
+(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 toWordList(words) {
+ var ret = [];
+ words.split(' ').forEach(function(e){
+ ret.push({name: e});
+ });
+ return ret;
+ }
+
+ var coreWordList = toWordList(
+'INVERT AND OR XOR\
+ 2* 2/ LSHIFT RSHIFT\
+ 0= = 0< < > U< MIN MAX\
+ 2DROP 2DUP 2OVER 2SWAP ?DUP DEPTH DROP DUP OVER ROT SWAP\
+ >R R> R@\
+ + - 1+ 1- ABS NEGATE\
+ S>D * M* UM*\
+ FM/MOD SM/REM UM/MOD */ */MOD / /MOD MOD\
+ HERE , @ ! CELL+ CELLS C, C@ C! CHARS 2@ 2!\
+ ALIGN ALIGNED +! ALLOT\
+ CHAR [CHAR] [ ] BL\
+ FIND EXECUTE IMMEDIATE COUNT LITERAL STATE\
+ ; DOES> >BODY\
+ EVALUATE\
+ SOURCE >IN\
+ <# # #S #> HOLD SIGN BASE >NUMBER HEX DECIMAL\
+ FILL MOVE\
+ . CR EMIT SPACE SPACES TYPE U. .R U.R\
+ ACCEPT\
+ TRUE FALSE\
+ <> U> 0<> 0>\
+ NIP TUCK ROLL PICK\
+ 2>R 2R@ 2R>\
+ WITHIN UNUSED MARKER\
+ I J\
+ TO\
+ COMPILE, [COMPILE]\
+ SAVE-INPUT RESTORE-INPUT\
+ PAD ERASE\
+ 2LITERAL DNEGATE\
+ D- D+ D0< D0= D2* D2/ D< D= DMAX DMIN D>S DABS\
+ M+ M*/ D. D.R 2ROT DU<\
+ CATCH THROW\
+ FREE RESIZE ALLOCATE\
+ CS-PICK CS-ROLL\
+ GET-CURRENT SET-CURRENT FORTH-WORDLIST GET-ORDER SET-ORDER\
+ PREVIOUS SEARCH-WORDLIST WORDLIST FIND ALSO ONLY FORTH DEFINITIONS ORDER\
+ -TRAILING /STRING SEARCH COMPARE CMOVE CMOVE> BLANK SLITERAL');
+
+ var immediateWordList = toWordList('IF ELSE THEN BEGIN WHILE REPEAT UNTIL RECURSE [IF] [ELSE] [THEN] ?DO DO LOOP +LOOP UNLOOP LEAVE EXIT AGAIN CASE OF ENDOF ENDCASE');
+
+ CodeMirror.defineMode('forth', function() {
+ function searchWordList (wordList, word) {
+ var i;
+ for (i = wordList.length - 1; i >= 0; i--) {
+ if (wordList[i].name === word.toUpperCase()) {
+ return wordList[i];
+ }
+ }
+ return undefined;
+ }
+ return {
+ startState: function() {
+ return {
+ state: '',
+ base: 10,
+ coreWordList: coreWordList,
+ immediateWordList: immediateWordList,
+ wordList: []
+ };
+ },
+ token: function (stream, stt) {
+ var mat;
+ if (stream.eatSpace()) {
+ return null;
+ }
+ if (stt.state === '') { // interpretation
+ if (stream.match(/^(\]|:NONAME)(\s|$)/i)) {
+ stt.state = ' compilation';
+ return 'builtin compilation';
+ }
+ mat = stream.match(/^(\:)\s+(\S+)(\s|$)+/);
+ if (mat) {
+ stt.wordList.push({name: mat[2].toUpperCase()});
+ stt.state = ' compilation';
+ return 'def' + stt.state;
+ }
+ mat = stream.match(/^(VARIABLE|2VARIABLE|CONSTANT|2CONSTANT|CREATE|POSTPONE|VALUE|WORD)\s+(\S+)(\s|$)+/i);
+ if (mat) {
+ stt.wordList.push({name: mat[2].toUpperCase()});
+ return 'def' + stt.state;
+ }
+ mat = stream.match(/^(\'|\[\'\])\s+(\S+)(\s|$)+/);
+ if (mat) {
+ return 'builtin' + stt.state;
+ }
+ } else { // compilation
+ // ; [
+ if (stream.match(/^(\;|\[)(\s)/)) {
+ stt.state = '';
+ stream.backUp(1);
+ return 'builtin compilation';
+ }
+ if (stream.match(/^(\;|\[)($)/)) {
+ stt.state = '';
+ return 'builtin compilation';
+ }
+ if (stream.match(/^(POSTPONE)\s+\S+(\s|$)+/)) {
+ return 'builtin';
+ }
+ }
+
+ // dynamic wordlist
+ mat = stream.match(/^(\S+)(\s+|$)/);
+ if (mat) {
+ if (searchWordList(stt.wordList, mat[1]) !== undefined) {
+ return 'variable' + stt.state;
+ }
+
+ // comments
+ if (mat[1] === '\\') {
+ stream.skipToEnd();
+ return 'comment' + stt.state;
+ }
+
+ // core words
+ if (searchWordList(stt.coreWordList, mat[1]) !== undefined) {
+ return 'builtin' + stt.state;
+ }
+ if (searchWordList(stt.immediateWordList, mat[1]) !== undefined) {
+ return 'keyword' + stt.state;
+ }
+
+ if (mat[1] === '(') {
+ stream.eatWhile(function (s) { return s !== ')'; });
+ stream.eat(')');
+ return 'comment' + stt.state;
+ }
+
+ // // strings
+ if (mat[1] === '.(') {
+ stream.eatWhile(function (s) { return s !== ')'; });
+ stream.eat(')');
+ return 'string' + stt.state;
+ }
+ if (mat[1] === 'S"' || mat[1] === '."' || mat[1] === 'C"') {
+ stream.eatWhile(function (s) { return s !== '"'; });
+ stream.eat('"');
+ return 'string' + stt.state;
+ }
+
+ // numbers
+ if (mat[1] - 0xfffffffff) {
+ return 'number' + stt.state;
+ }
+ // if (mat[1].match(/^[-+]?[0-9]+\.[0-9]*/)) {
+ // return 'number' + stt.state;
+ // }
+
+ return 'atom' + stt.state;
+ }
+ }
+ };
+ });
+ CodeMirror.defineMIME("text/x-forth", "forth");
+});
diff --git a/data/ext/editorText/codemirror/mode/forth/index.html b/data/ext/editorText/codemirror/mode/forth/index.html
new file mode 100644
index 000000000..ae8cd3458
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/forth/index.html
@@ -0,0 +1,75 @@
+<!doctype html>
+
+<title>CodeMirror: Forth mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<link rel=stylesheet href="../../theme/colorforth.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="forth.js"></script>
+<style>
+.CodeMirror {
+ font-family: 'Droid Sans Mono', monospace;
+ font-size: 14px;
+}
+</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Forth</a>
+ </ul>
+</div>
+
+<article>
+
+<h2>Forth mode</h2>
+
+<form><textarea id="code" name="code">
+\ Insertion sort
+
+: cell- 1 cells - ;
+
+: insert ( start end -- start )
+ dup @ >r ( r: v )
+ begin
+ 2dup <
+ while
+ r@ over cell- @ <
+ while
+ cell-
+ dup @ over cell+ !
+ repeat then
+ r> swap ! ;
+
+: sort ( array len -- )
+ 1 ?do
+ dup i cells + insert
+ loop drop ;</textarea>
+ </form>
+
+<script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ lineWrapping: true,
+ indentUnit: 2,
+ tabSize: 2,
+ autofocus: true,
+ theme: "colorforth",
+ mode: "text/x-forth"
+ });
+</script>
+
+<p>Simple mode that handle Forth-Syntax (<a href="http://en.wikipedia.org/wiki/Forth_%28programming_language%29">Forth on WikiPedia</a>).</p>
+
+<p><strong>MIME types defined:</strong> <code>text/x-forth</code>.</p>
+
+</article>
diff --git a/data/ext/editorText/codemirror/mode/fortran/fortran.js b/data/ext/editorText/codemirror/mode/fortran/fortran.js
index 83fd8fde8..4d88f006a 100644
--- a/data/ext/editorText/codemirror/mode/fortran/fortran.js
+++ b/data/ext/editorText/codemirror/mode/fortran/fortran.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("fortran", function() {
function words(array) {
var keys = {};
@@ -171,3 +184,5 @@ CodeMirror.defineMode("fortran", function() {
});
CodeMirror.defineMIME("text/x-fortran", "fortran");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/fortran/index.html b/data/ext/editorText/codemirror/mode/fortran/index.html
index efa55ec89..102e8f826 100644
--- a/data/ext/editorText/codemirror/mode/fortran/index.html
+++ b/data/ext/editorText/codemirror/mode/fortran/index.html
@@ -9,12 +9,12 @@
<script src="fortran.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/gas/gas.js b/data/ext/editorText/codemirror/mode/gas/gas.js
index 0606b18e3..0c74bedc5 100644
--- a/data/ext/editorText/codemirror/mode/gas/gas.js
+++ b/data/ext/editorText/codemirror/mode/gas/gas.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("gas", function(_config, parserConfig) {
'use strict';
@@ -328,3 +341,5 @@ CodeMirror.defineMode("gas", function(_config, parserConfig) {
blockCommentEnd: "*/"
};
});
+
+});
diff --git a/data/ext/editorText/codemirror/mode/gas/index.html b/data/ext/editorText/codemirror/mode/gas/index.html
index cd8a2ff5a..df75ca2db 100644
--- a/data/ext/editorText/codemirror/mode/gas/index.html
+++ b/data/ext/editorText/codemirror/mode/gas/index.html
@@ -9,12 +9,12 @@
<script src="gas.js"></script>
<style>.CodeMirror {border: 2px inset #dee;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/gfm/gfm.js b/data/ext/editorText/codemirror/mode/gfm/gfm.js
index 10d5e05c0..6e74ad4fd 100644
--- a/data/ext/editorText/codemirror/mode/gfm/gfm.js
+++ b/data/ext/editorText/codemirror/mode/gfm/gfm.js
@@ -1,3 +1,18 @@
+// 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"), require("../markdown/markdown"), require("../../addon/mode/overlay"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../markdown/markdown", "../../addon/mode/overlay"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
+
CodeMirror.defineMode("gfm", function(config, modeConfig) {
var codeDepth = 0;
function blankLine(state) {
@@ -20,9 +35,11 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
};
},
token: function(stream, state) {
+ state.combineTokens = null;
+
// Hack to prevent formatting override inside code blocks (block and inline)
if (state.codeBlock) {
- if (stream.match(/^```/)) {
+ if (stream.match(/^```+/)) {
state.codeBlock = false;
return null;
}
@@ -32,7 +49,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
if (stream.sol()) {
state.code = false;
}
- if (stream.sol() && stream.match(/^```/)) {
+ if (stream.sol() && stream.match(/^```+/)) {
stream.skipToEnd();
state.codeBlock = true;
return null;
@@ -63,23 +80,30 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
}
if (stream.sol() || state.ateSpace) {
state.ateSpace = false;
- if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
- // User/Project@SHA
- // User@SHA
- // SHA
- return "link";
- } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
- // User/Project#Num
- // User#Num
- // #Num
- return "link";
+ if (modeConfig.gitHubSpice !== false) {
+ if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
+ // User/Project@SHA
+ // User@SHA
+ // SHA
+ state.combineTokens = true;
+ return "link";
+ } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
+ // User/Project#Num
+ // User#Num
+ // #Num
+ state.combineTokens = true;
+ return "link";
+ }
}
}
- if (stream.match(/^((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i) &&
- stream.string.slice(stream.start - 2, stream.start) != "](") {
+ if (stream.match(urlRE) &&
+ stream.string.slice(stream.start - 2, stream.start) != "](" &&
+ (stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
// URLs
// Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
// And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
+ // And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
+ state.combineTokens = true;
return "link";
}
stream.next();
@@ -91,12 +115,16 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
var markdownConfig = {
underscoresBreakWords: false,
taskLists: true,
- fencedCodeBlocks: true
+ fencedCodeBlocks: '```',
+ strikethrough: true
};
for (var attr in modeConfig) {
markdownConfig[attr] = modeConfig[attr];
}
markdownConfig.name = "markdown";
- CodeMirror.defineMIME("gfmBase", markdownConfig);
- return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay);
+ return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay);
+
}, "markdown");
+
+ CodeMirror.defineMIME("text/x-gfm", "gfm");
+});
diff --git a/data/ext/editorText/codemirror/mode/gfm/index.html b/data/ext/editorText/codemirror/mode/gfm/index.html
index b71cd5c75..7e38c52d6 100644
--- a/data/ext/editorText/codemirror/mode/gfm/index.html
+++ b/data/ext/editorText/codemirror/mode/gfm/index.html
@@ -14,14 +14,15 @@
<script src="../css/css.js"></script>
<script src="../htmlmixed/htmlmixed.js"></script>
<script src="../clike/clike.js"></script>
+<script src="../meta.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -41,6 +42,16 @@ Everything from markdown plus GFM features:
Underscores_are_allowed_between_words.
+## Strikethrough text
+
+GFM adds syntax to strikethrough text, which is missing from standard Markdown.
+
+~~Mistaken text.~~
+~~**works with other fomatting**~~
+
+~~spans across
+lines~~
+
## Fenced code blocks (and syntax highlighting)
```javascript
diff --git a/data/ext/editorText/codemirror/mode/gfm/test.js b/data/ext/editorText/codemirror/mode/gfm/test.js
index e5c3486eb..0dcd3619a 100644
--- a/data/ext/editorText/codemirror/mode/gfm/test.js
+++ b/data/ext/editorText/codemirror/mode/gfm/test.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
@@ -19,6 +22,12 @@
"[variable-2&formatting&formatting-list&formatting-list-ul - ][meta&formatting&formatting-task [ ]]][variable-2 foo]",
"[variable-2&formatting&formatting-list&formatting-list-ul - ][property&formatting&formatting-task [x]]][variable-2 foo]");
+ FT("formatting_strikethrough",
+ "[strikethrough&formatting&formatting-strikethrough ~~][strikethrough foo][strikethrough&formatting&formatting-strikethrough ~~]");
+
+ FT("formatting_strikethrough",
+ "foo [strikethrough&formatting&formatting-strikethrough ~~][strikethrough bar][strikethrough&formatting&formatting-strikethrough ~~]");
+
MT("emInWordAsterisk",
"foo[em *bar*]hello");
@@ -42,6 +51,11 @@
"[comment ```]",
"bar");
+ MT("fencedCodeBlocksNoTildes",
+ "~~~",
+ "foo",
+ "~~~");
+
MT("taskListAsterisk",
"[variable-2 * []] foo]", // Invalid; must have space or x between []
"[variable-2 * [ ]]bar]", // Invalid; must have space after ]
@@ -73,6 +87,9 @@
MT("SHA",
"foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");
+ MT("SHAEmphasis",
+ "[em *foo ][em&link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
+
MT("shortSHA",
"foo [link be6a8cc] bar");
@@ -88,30 +105,60 @@
MT("userSHA",
"foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");
+ MT("userSHAEmphasis",
+ "[em *foo ][em&link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
+
MT("userProjectSHA",
"foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");
+ MT("userProjectSHAEmphasis",
+ "[em *foo ][em&link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
+
MT("num",
"foo [link #1] bar");
+ MT("numEmphasis",
+ "[em *foo ][em&link #1][em *]");
+
MT("badNum",
"foo #1bar hello");
MT("userNum",
"foo [link bar#1] hello");
+ MT("userNumEmphasis",
+ "[em *foo ][em&link bar#1][em *]");
+
MT("userProjectNum",
"foo [link bar/hello#1] world");
+ MT("userProjectNumEmphasis",
+ "[em *foo ][em&link bar/hello#1][em *]");
+
MT("vanillaLink",
"foo [link http://www.example.com/] bar");
+ MT("vanillaLinkNoScheme",
+ "foo [link www.example.com] bar");
+
+ MT("vanillaLinkHttps",
+ "foo [link https://www.example.com/] bar");
+
+ MT("vanillaLinkDataSchema",
+ "foo [link data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==] bar");
+
MT("vanillaLinkPunctuation",
"foo [link http://www.example.com/]. bar");
MT("vanillaLinkExtension",
"foo [link http://www.example.com/index.html] bar");
+ MT("vanillaLinkEmphasis",
+ "foo [em *][em&link http://www.example.com/index.html][em *] bar");
+
+ MT("notALink",
+ "foo asfd:asdf bar");
+
MT("notALink",
"[comment ```css]",
"[tag foo] {[property color]:[keyword black];}",
@@ -122,8 +169,62 @@
MT("notALink",
"[comment `foo]",
- "[link http://www.example.com/]",
- "[comment `foo]",
+ "[comment&link http://www.example.com/]",
+ "[comment `] foo",
"",
"[link http://www.example.com/]");
+
+ MT("headerCodeBlockGithub",
+ "[header&header-1 # heading]",
+ "",
+ "[comment ```]",
+ "[comment code]",
+ "[comment ```]",
+ "",
+ "Commit: [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2]",
+ "Issue: [link #1]",
+ "Link: [link http://www.example.com/]");
+
+ MT("strikethrough",
+ "[strikethrough ~~foo~~]");
+
+ MT("strikethroughWithStartingSpace",
+ "~~ foo~~");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo~~~]");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo ~~]");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo ~~ bar]");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo ~~ bar~~]hello");
+
+ MT("strikethroughOneLetter",
+ "[strikethrough ~~a~~]");
+
+ MT("strikethroughWrapped",
+ "[strikethrough ~~foo]",
+ "[strikethrough foo~~]");
+
+ MT("strikethroughParagraph",
+ "[strikethrough ~~foo]",
+ "",
+ "foo[strikethrough ~~bar]");
+
+ MT("strikethroughEm",
+ "[strikethrough ~~foo][em&strikethrough *bar*][strikethrough ~~]");
+
+ MT("strikethroughEm",
+ "[em *][em&strikethrough ~~foo~~][em *]");
+
+ MT("strikethroughStrong",
+ "[strikethrough ~~][strong&strikethrough **foo**][strikethrough ~~]");
+
+ MT("strikethroughStrong",
+ "[strong **][strong&strikethrough ~~foo~~][strong **]");
+
})();
diff --git a/data/ext/editorText/codemirror/mode/gherkin/gherkin.js b/data/ext/editorText/codemirror/mode/gherkin/gherkin.js
index 685b373df..fc2ebee16 100644
--- a/data/ext/editorText/codemirror/mode/gherkin/gherkin.js
+++ b/data/ext/editorText/codemirror/mode/gherkin/gherkin.js
@@ -1,6 +1,9 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/*
Gherkin mode - http://www.cukes.info/
-Report bugs/issues here: https://github.com/marijnh/CodeMirror/issues
+Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
*/
// Following Objs from Brackets implementation: https://github.com/tregusti/brackets-gherkin/blob/master/main.js
@@ -13,6 +16,16 @@ Report bugs/issues here: https://github.com/marijnh/CodeMirror/issues
// keywords: /(Feature| {2}(Scenario|In order to|As|I)| {4}(Given|When|Then|And))/
//};
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("gherkin", function () {
return {
startState: function () {
@@ -161,3 +174,5 @@ CodeMirror.defineMode("gherkin", function () {
});
CodeMirror.defineMIME("text/x-feature", "gherkin");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/gherkin/index.html b/data/ext/editorText/codemirror/mode/gherkin/index.html
index b76877acd..af8184c98 100644
--- a/data/ext/editorText/codemirror/mode/gherkin/index.html
+++ b/data/ext/editorText/codemirror/mode/gherkin/index.html
@@ -9,12 +9,12 @@
<script src="gherkin.js"></script>
<style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/go/go.js b/data/ext/editorText/codemirror/mode/go/go.js
index 3944d574f..21fe9a2d6 100644
--- a/data/ext/editorText/codemirror/mode/go/go.js
+++ b/data/ext/editorText/codemirror/mode/go/go.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("go", function(config) {
var indentUnit = config.indentUnit;
@@ -58,7 +71,7 @@ CodeMirror.defineMode("go", function(config) {
stream.eatWhile(isOperatorChar);
return "operator";
}
- stream.eatWhile(/[\w\$_]/);
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
if (cur == "case" || cur == "default") curPunc = "case";
@@ -73,7 +86,7 @@ CodeMirror.defineMode("go", function(config) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {end = true; break;}
- escaped = !escaped && next == "\\";
+ escaped = !escaped && quote != "`" && next == "\\";
}
if (end || !(escaped || quote == "`"))
state.tokenize = tokenBase;
@@ -104,6 +117,7 @@ CodeMirror.defineMode("go", function(config) {
return state.context = new Context(state.indented, col, type, null, state.context);
}
function popContext(state) {
+ if (!state.context.prev) return;
var t = state.context.type;
if (t == ")" || t == "]" || t == "}")
state.indented = state.context.indented;
@@ -167,3 +181,5 @@ CodeMirror.defineMode("go", function(config) {
});
CodeMirror.defineMIME("text/x-go", "go");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/go/index.html b/data/ext/editorText/codemirror/mode/go/index.html
index 3673fa0b0..72e3b364c 100644
--- a/data/ext/editorText/codemirror/mode/go/index.html
+++ b/data/ext/editorText/codemirror/mode/go/index.html
@@ -11,12 +11,12 @@
<script src="go.js"></script>
<style>.CodeMirror {border:1px solid #999; background:#ffc}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/groovy/groovy.js b/data/ext/editorText/codemirror/mode/groovy/groovy.js
index 6800e0aaf..721933b01 100644
--- a/data/ext/editorText/codemirror/mode/groovy/groovy.js
+++ b/data/ext/editorText/codemirror/mode/groovy/groovy.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("groovy", function(config) {
function words(str) {
var obj = {}, words = str.split(" ");
@@ -11,6 +24,7 @@ CodeMirror.defineMode("groovy", function(config) {
"short static strictfp super switch synchronized threadsafe throw throws transient " +
"try void volatile while");
var blockKeywords = words("catch class do else finally for if switch try while enum interface def");
+ var standaloneKeywords = words("return break continue");
var atoms = words("null true false this");
var curPunc;
@@ -37,7 +51,7 @@ CodeMirror.defineMode("groovy", function(config) {
stream.skipToEnd();
return "comment";
}
- if (expectExpression(state.lastToken)) {
+ if (expectExpression(state.lastToken, false)) {
return startString(ch, stream, state);
}
}
@@ -57,6 +71,7 @@ CodeMirror.defineMode("groovy", function(config) {
if (atoms.propertyIsEnumerable(cur)) { return "atom"; }
if (keywords.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
+ else if (standaloneKeywords.propertyIsEnumerable(cur)) curPunc = "standalone";
return "keyword";
}
return "variable";
@@ -119,9 +134,10 @@ CodeMirror.defineMode("groovy", function(config) {
return "comment";
}
- function expectExpression(last) {
+ function expectExpression(last, newline) {
return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) ||
- last == "newstatement" || last == "keyword" || last == "proplabel";
+ last == "newstatement" || last == "keyword" || last == "proplabel" ||
+ (last == "standalone" && !newline);
}
function Context(indented, column, type, align, prev) {
@@ -161,7 +177,7 @@ CodeMirror.defineMode("groovy", function(config) {
state.indented = stream.indentation();
state.startOfLine = true;
// Automatic semicolon insertion
- if (ctx.type == "statement" && !expectExpression(state.lastToken)) {
+ if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) {
popContext(state); ctx = state.context;
}
}
@@ -196,7 +212,7 @@ CodeMirror.defineMode("groovy", function(config) {
indent: function(state, textAfter) {
if (!state.tokenize[state.tokenize.length-1].isBase) return 0;
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context;
- if (ctx.type == "statement" && !expectExpression(state.lastToken)) ctx = ctx.prev;
+ if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) ctx = ctx.prev;
var closing = firstChar == ctx.type;
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit);
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
@@ -204,8 +220,11 @@ CodeMirror.defineMode("groovy", function(config) {
},
electricChars: "{}",
+ closeBrackets: {triples: "'\""},
fold: "brace"
};
});
CodeMirror.defineMIME("text/x-groovy", "groovy");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/groovy/index.html b/data/ext/editorText/codemirror/mode/groovy/index.html
index f5efdf758..bb0df078c 100644
--- a/data/ext/editorText/codemirror/mode/groovy/index.html
+++ b/data/ext/editorText/codemirror/mode/groovy/index.html
@@ -10,12 +10,12 @@
<script src="groovy.js"></script>
<style>.CodeMirror {border-top: 1px solid #500; border-bottom: 1px solid #500;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/haml/haml.js b/data/ext/editorText/codemirror/mode/haml/haml.js
index 5ea4ed12c..8fe63b020 100644
--- a/data/ext/editorText/codemirror/mode/haml/haml.js
+++ b/data/ext/editorText/codemirror/mode/haml/haml.js
@@ -1,5 +1,15 @@
-(function() {
- "use strict";
+// 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"), require("../htmlmixed/htmlmixed"), require("../ruby/ruby"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../ruby/ruby"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
// full haml mode. This handled embeded ruby and html fragments too
CodeMirror.defineMode("haml", function(config) {
@@ -65,7 +75,7 @@
// donot handle --> as valid ruby, make it HTML close comment instead
if (state.startOfLine && !stream.match("-->", false) && (ch == "=" || ch == "-" )) {
state.tokenize = ruby;
- return null;
+ return state.tokenize(stream, state);
}
if (state.previousToken.style == "hamlTag" ||
@@ -73,10 +83,10 @@
state.previousToken.style == "hamlAttribute") {
if (ch == "(") {
state.tokenize = rubyInQuote(")");
- return null;
+ return state.tokenize(stream, state);
} else if (ch == "{") {
state.tokenize = rubyInQuote("}");
- return null;
+ return state.tokenize(stream, state);
}
}
@@ -146,4 +156,4 @@
}, "htmlmixed", "ruby");
CodeMirror.defineMIME("text/x-haml", "haml");
-})();
+});
diff --git a/data/ext/editorText/codemirror/mode/haml/index.html b/data/ext/editorText/codemirror/mode/haml/index.html
index a73787554..2894a938e 100644
--- a/data/ext/editorText/codemirror/mode/haml/index.html
+++ b/data/ext/editorText/codemirror/mode/haml/index.html
@@ -13,12 +13,12 @@
<script src="haml.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/haml/test.js b/data/ext/editorText/codemirror/mode/haml/test.js
index 75d0e7710..508458a43 100644
--- a/data/ext/editorText/codemirror/mode/haml/test.js
+++ b/data/ext/editorText/codemirror/mode/haml/test.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({tabSize: 4, indentUnit: 2}, "haml");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
@@ -50,9 +53,9 @@
" [comment -# this is a comment]",
" [comment and this is a comment too]",
" Date/Time",
- " [operator -] [variable now] [operator =] [tag DateTime][operator .][variable now]",
+ " [operator -] [variable now] [operator =] [tag DateTime][operator .][property now]",
" [tag %strong=] [variable now]",
- " [operator -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][variable parse]([string \"December 31, 2006\"])",
+ " [operator -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][property parse]([string \"December 31, 2006\"])",
" [operator =][string \"Happy\"]",
" [operator =][string \"Belated\"]",
" [operator =][string \"Birthday\"]");
diff --git a/data/ext/editorText/codemirror/mode/handlebars/handlebars.js b/data/ext/editorText/codemirror/mode/handlebars/handlebars.js
new file mode 100644
index 000000000..40dfea42a
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/handlebars/handlebars.js
@@ -0,0 +1,53 @@
+// 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"), require("../../addon/mode/simple"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineSimpleMode("handlebars", {
+ start: [
+ { regex: /\{\{!--/, push: "dash_comment", token: "comment" },
+ { regex: /\{\{!/, push: "comment", token: "comment" },
+ { regex: /\{\{/, push: "handlebars", token: "tag" }
+ ],
+ handlebars: [
+ { regex: /\}\}/, pop: true, token: "tag" },
+
+ // Double and single quotes
+ { regex: /"(?:[^\\]|\\.)*?"/, token: "string" },
+ { regex: /'(?:[^\\]|\\.)*?'/, token: "string" },
+
+ // Handlebars keywords
+ { regex: />|[#\/]([A-Za-z_]\w*)/, token: "keyword" },
+ { regex: /(?:else|this)\b/, token: "keyword" },
+
+ // Numeral
+ { regex: /\d+/i, token: "number" },
+
+ // Atoms like = and .
+ { regex: /=|~|@|true|false/, token: "atom" },
+
+ // Paths
+ { regex: /(?:\.\.\/)*(?:[A-Za-z_][\w\.]*)+/, token: "variable-2" }
+ ],
+ dash_comment: [
+ { regex: /--\}\}/, pop: true, token: "comment" },
+
+ // Commented code
+ { regex: /./, token: "comment"}
+ ],
+ comment: [
+ { regex: /\}\}/, pop: true, token: "comment" },
+ { regex: /./, token: "comment" }
+ ]
+ });
+
+ CodeMirror.defineMIME("text/x-handlebars-template", "handlebars");
+});
diff --git a/data/ext/editorText/codemirror/mode/handlebars/index.html b/data/ext/editorText/codemirror/mode/handlebars/index.html
new file mode 100644
index 000000000..beaef87a1
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/handlebars/index.html
@@ -0,0 +1,83 @@
+<!doctype html>
+
+<title>CodeMirror: Handlebars mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/mode/simple.js"></script>
+<script src="../../addon/mode/multiplex.js"></script>
+<script src="../xml/xml.js"></script>
+<script src="handlebars.js"></script>
+<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">HTML mixed</a>
+ </ul>
+</div>
+
+<article>
+<h2>Handlebars</h2>
+<form><textarea id="code" name="code">
+{{> breadcrumbs}}
+
+{{!--
+ You can use the t function to get
+ content translated to the current locale, es:
+ {{t 'article_list'}}
+--}}
+
+<h1>{{t 'article_list'}}</h1>
+
+{{! one line comment }}
+
+{{#each articles}}
+ {{~title}}
+ <p>{{excerpt body size=120 ellipsis=true}}</p>
+
+ {{#with author}}
+ written by {{first_name}} {{last_name}}
+ from category: {{../category.title}}
+ {{#if @../last}}foobar!{{/if}}
+ {{/with~}}
+
+ {{#if promoted.latest}}Read this one! {{else}} This is ok! {{/if}}
+
+ {{#if @last}}<hr>{{/if}}
+{{/each}}
+
+{{#form new_comment}}
+ <input type="text" name="body">
+{{/form}}
+
+</textarea></form>
+ <script>
+ CodeMirror.defineMode("htmlhandlebars", function(config) {
+ return CodeMirror.multiplexingMode(
+ CodeMirror.getMode(config, "text/html"),
+ {open: "{{", close: "}}",
+ mode: CodeMirror.getMode(config, "handlebars"),
+ parseDelimiters: true});
+ });
+
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "htmlhandlebars"
+ });
+ </script>
+ </script>
+
+ <p>Handlebars syntax highlighting for CodeMirror.</p>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-handlebars-template</code></p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/haskell/haskell.js b/data/ext/editorText/codemirror/mode/haskell/haskell.js
index facfd00a6..fe0bab67e 100644
--- a/data/ext/editorText/codemirror/mode/haskell/haskell.js
+++ b/data/ext/editorText/codemirror/mode/haskell/haskell.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("haskell", function(_config, modeConfig) {
function switchState(source, setState, f) {
@@ -11,7 +24,7 @@ CodeMirror.defineMode("haskell", function(_config, modeConfig) {
var digitRE = /\d/;
var hexitRE = /[0-9A-Fa-f]/;
var octitRE = /[0-7]/;
- var idRE = /[a-z_A-Z0-9']/;
+ var idRE = /[a-z_A-Z0-9'\xa1-\uffff]/;
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/;
var specialRE = /[(),;[\]`{}]/;
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
@@ -250,3 +263,5 @@ CodeMirror.defineMode("haskell", function(_config, modeConfig) {
});
CodeMirror.defineMIME("text/x-haskell", "haskell");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/haskell/index.html b/data/ext/editorText/codemirror/mode/haskell/index.html
index 056b01d46..42240b0f2 100644
--- a/data/ext/editorText/codemirror/mode/haskell/index.html
+++ b/data/ext/editorText/codemirror/mode/haskell/index.html
@@ -11,12 +11,12 @@
<script src="haskell.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/haxe/haxe.js b/data/ext/editorText/codemirror/mode/haxe/haxe.js
index e525a1871..a9573dd71 100644
--- a/data/ext/editorText/codemirror/mode/haxe/haxe.js
+++ b/data/ext/editorText/codemirror/mode/haxe/haxe.js
@@ -1,25 +1,36 @@
+// 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";
+
CodeMirror.defineMode("haxe", function(config, parserConfig) {
var indentUnit = config.indentUnit;
// Tokenizer
- var keywords = function(){
- function kw(type) {return {type: type, style: "keyword"};}
- var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
- var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"};
+ function kw(type) {return {type: type, style: "keyword"};}
+ var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
+ var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"};
var type = kw("typedef");
- return {
- "if": A, "while": A, "else": B, "do": B, "try": B,
- "return": C, "break": C, "continue": C, "new": C, "throw": C,
- "var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"),
+ var keywords = {
+ "if": A, "while": A, "else": B, "do": B, "try": B,
+ "return": C, "break": C, "continue": C, "new": C, "throw": C,
+ "var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"),
"public": attribute, "private": attribute, "cast": kw("cast"), "import": kw("import"), "macro": kw("macro"),
- "function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"),
- "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
- "in": operator, "never": kw("property_access"), "trace":kw("trace"),
+ "function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"),
+ "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
+ "in": operator, "never": kw("property_access"), "trace":kw("trace"),
"class": type, "abstract":type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type,
- "true": atom, "false": atom, "null": atom
- };
- }();
+ "true": atom, "false": atom, "null": atom
+ };
var isOperatorChar = /[+\-*&%=<>!?|]/;
@@ -28,14 +39,13 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
return f(stream, state);
}
- function nextUntilUnescaped(stream, end) {
+ function toUnescaped(stream, end) {
var escaped = false, next;
while ((next = stream.next()) != null) {
if (next == end && !escaped)
- return false;
+ return true;
escaped = !escaped && next == "\\";
}
- return escaped;
}
// Used as scratch variables to communicate multiple values without
@@ -48,70 +58,58 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
function haxeTokenBase(stream, state) {
var ch = stream.next();
- if (ch == '"' || ch == "'")
+ if (ch == '"' || ch == "'") {
return chain(stream, state, haxeTokenString(ch));
- else if (/[\[\]{}\(\),;\:\.]/.test(ch))
+ } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
return ret(ch);
- else if (ch == "0" && stream.eat(/x/i)) {
+ } else if (ch == "0" && stream.eat(/x/i)) {
stream.eatWhile(/[\da-f]/i);
return ret("number", "number");
- }
- else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
- stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
+ } else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
+ stream.match(/^\d*(?:\.\d*(?!\.))?(?:[eE][+\-]?\d+)?/);
return ret("number", "number");
- }
- else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) {
- nextUntilUnescaped(stream, "/");
+ } else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) {
+ toUnescaped(stream, "/");
stream.eatWhile(/[gimsu]/);
return ret("regexp", "string-2");
- }
- else if (ch == "/") {
+ } else if (ch == "/") {
if (stream.eat("*")) {
return chain(stream, state, haxeTokenComment);
- }
- else if (stream.eat("/")) {
+ } else if (stream.eat("/")) {
stream.skipToEnd();
return ret("comment", "comment");
- }
- else {
+ } else {
stream.eatWhile(isOperatorChar);
return ret("operator", null, stream.current());
}
- }
- else if (ch == "#") {
+ } else if (ch == "#") {
stream.skipToEnd();
return ret("conditional", "meta");
- }
- else if (ch == "@") {
+ } else if (ch == "@") {
stream.eat(/:/);
stream.eatWhile(/[\w_]/);
return ret ("metadata", "meta");
- }
- else if (isOperatorChar.test(ch)) {
+ } else if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return ret("operator", null, stream.current());
- }
- else {
- var word;
- if(/[A-Z]/.test(ch))
- {
- stream.eatWhile(/[\w_<>]/);
- word = stream.current();
- return ret("type", "variable-3", word);
- }
- else
- {
+ } else {
+ var word;
+ if(/[A-Z]/.test(ch)) {
+ stream.eatWhile(/[\w_<>]/);
+ word = stream.current();
+ return ret("type", "variable-3", word);
+ } else {
stream.eatWhile(/[\w_]/);
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
ret("variable", "variable", word);
- }
+ }
}
}
function haxeTokenString(quote) {
return function(stream, state) {
- if (!nextUntilUnescaped(stream, quote))
+ if (toUnescaped(stream, quote))
state.tokenize = haxeTokenBase;
return ret("string", "string");
};
@@ -163,27 +161,25 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
cc.pop()();
if (cx.marked) return cx.marked;
if (type == "variable" && inScope(state, content)) return "variable-2";
- if (type == "variable" && imported(state, content)) return "variable-3";
+ if (type == "variable" && imported(state, content)) return "variable-3";
return style;
}
}
}
- function imported(state, typename)
- {
- if (/[a-z]/.test(typename.charAt(0)))
- return false;
- var len = state.importedtypes.length;
- for (var i = 0; i<len; i++)
- if(state.importedtypes[i]==typename) return true;
+ function imported(state, typename) {
+ if (/[a-z]/.test(typename.charAt(0)))
+ return false;
+ var len = state.importedtypes.length;
+ for (var i = 0; i<len; i++)
+ if(state.importedtypes[i]==typename) return true;
}
-
function registerimport(importname) {
- var state = cx.state;
- for (var t = state.importedtypes; t; t = t.next)
- if(t.name == importname) return;
- state.importedtypes = { name: importname, next: state.importedtypes };
+ var state = cx.state;
+ for (var t = state.importedtypes; t; t = t.next)
+ if(t.name == importname) return;
+ state.importedtypes = { name: importname, next: state.importedtypes };
}
// Combinator utils
@@ -195,13 +191,20 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
pass.apply(null, arguments);
return true;
}
+ function inList(name, list) {
+ for (var v = list; v; v = v.next)
+ if (v.name == name) return true;
+ return false;
+ }
function register(varname) {
var state = cx.state;
if (state.context) {
cx.marked = "def";
- for (var v = state.localVars; v; v = v.next)
- if (v.name == varname) return;
+ if (inList(varname, state.localVars)) return;
state.localVars = {name: varname, next: state.localVars};
+ } else if (state.globalVars) {
+ if (inList(varname, state.globalVars)) return;
+ state.globalVars = {name: varname, next: state.globalVars};
}
}
@@ -216,6 +219,7 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
cx.state.localVars = cx.state.context.vars;
cx.state.context = cx.state.context.prev;
}
+ popcontext.lex = true;
function pushlex(type, info) {
var result = function() {
var state = cx.state;
@@ -235,11 +239,12 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
poplex.lex = true;
function expect(wanted) {
- return function(type) {
+ function f(type) {
if (type == wanted) return cont();
else if (wanted == ";") return pass();
- else return cont(arguments.callee);
- };
+ else return cont(f);
+ }
+ return f;
}
function statement(type) {
@@ -252,25 +257,26 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
if (type == "attribute") return cont(maybeattribute);
if (type == "function") return cont(functiondef);
if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
- poplex, statement, poplex);
+ poplex, statement, poplex);
if (type == "variable") return cont(pushlex("stat"), maybelabel);
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
- block, poplex, poplex);
+ block, poplex, poplex);
if (type == "case") return cont(expression, expect(":"));
if (type == "default") return cont(expect(":"));
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
- statement, poplex, popcontext);
+ statement, poplex, popcontext);
if (type == "import") return cont(importdef, expect(";"));
if (type == "typedef") return cont(typedef);
return pass(pushlex("stat"), expression, expect(";"), poplex);
}
function expression(type) {
if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
+ if (type == "type" ) return cont(maybeoperator);
if (type == "function") return cont(functiondef);
if (type == "keyword c") return cont(maybeexpression);
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
if (type == "operator") return cont(expression);
- if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
+ if (type == "[") return cont(pushlex("]"), commasep(maybeexpression, "]"), poplex, maybeoperator);
if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
return cont();
}
@@ -304,14 +310,14 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
}
function importdef (type, value) {
- if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
- else if(type == "variable" || type == "property" || type == "." || value == "*") return cont(importdef);
+ if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
+ else if(type == "variable" || type == "property" || type == "." || value == "*") return cont(importdef);
}
function typedef (type, value)
{
- if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
- else if (type == "type" && /[A-Z]/.test(value.charAt(0))) { return cont(); }
+ if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
+ else if (type == "type" && /[A-Z]/.test(value.charAt(0))) { return cont(); }
}
function maybelabel(type) {
@@ -349,16 +355,19 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
if (type == ",") return cont(vardef1);
}
function forspec1(type, value) {
- if (type == "variable") {
- register(value);
- }
- return cont(pushlex(")"), pushcontext, forin, expression, poplex, statement, popcontext);
+ if (type == "variable") {
+ register(value);
+ return cont(forin, expression)
+ } else {
+ return pass()
+ }
}
function forin(_type, value) {
if (value == "in") return cont();
}
function functiondef(type, value) {
- if (type == "variable") {register(value); return cont(functiondef);}
+ //function names starting with upper-case letters are recognised as types, so cludging them together here.
+ if (type == "variable" || type == "type") {register(value); return cont(functiondef);}
if (value == "new") return cont(functiondef);
if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, typeuse, statement, popcontext);
}
@@ -378,21 +387,23 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
}
// Interface
-
return {
startState: function(basecolumn) {
- var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"];
- return {
+ var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"];
+ var state = {
tokenize: haxeTokenBase,
reAllowed: true,
kwAllowed: true,
cc: [],
lexical: new HaxeLexical((basecolumn || 0) - indentUnit, 0, "block", false),
localVars: parserConfig.localVars,
- importedtypes: defaulttypes,
+ importedtypes: defaulttypes,
context: parserConfig.localVars && {vars: parserConfig.localVars},
indented: 0
};
+ if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
+ state.globalVars = parserConfig.globalVars;
+ return state;
},
token: function(stream, state) {
@@ -431,3 +442,74 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
});
CodeMirror.defineMIME("text/x-haxe", "haxe");
+
+CodeMirror.defineMode("hxml", function () {
+
+ return {
+ startState: function () {
+ return {
+ define: false,
+ inString: false
+ };
+ },
+ token: function (stream, state) {
+ var ch = stream.peek();
+ var sol = stream.sol();
+
+ ///* comments */
+ if (ch == "#") {
+ stream.skipToEnd();
+ return "comment";
+ }
+ if (sol && ch == "-") {
+ var style = "variable-2";
+
+ stream.eat(/-/);
+
+ if (stream.peek() == "-") {
+ stream.eat(/-/);
+ style = "keyword a";
+ }
+
+ if (stream.peek() == "D") {
+ stream.eat(/[D]/);
+ style = "keyword c";
+ state.define = true;
+ }
+
+ stream.eatWhile(/[A-Z]/i);
+ return style;
+ }
+
+ var ch = stream.peek();
+
+ if (state.inString == false && ch == "'") {
+ state.inString = true;
+ ch = stream.next();
+ }
+
+ if (state.inString == true) {
+ if (stream.skipTo("'")) {
+
+ } else {
+ stream.skipToEnd();
+ }
+
+ if (stream.peek() == "'") {
+ stream.next();
+ state.inString = false;
+ }
+
+ return "string";
+ }
+
+ stream.next();
+ return null;
+ },
+ lineComment: "#"
+ };
+});
+
+CodeMirror.defineMIME("text/x-hxml", "hxml");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/haxe/index.html b/data/ext/editorText/codemirror/mode/haxe/index.html
index ec3b8e0e7..d415b5e10 100644
--- a/data/ext/editorText/codemirror/mode/haxe/index.html
+++ b/data/ext/editorText/codemirror/mode/haxe/index.html
@@ -9,12 +9,12 @@
<script src="haxe.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -26,7 +26,7 @@
<h2>Haxe mode</h2>
-<div><textarea id="code" name="code">
+<div><p><textarea id="code-haxe" name="code">
import one.two.Three;
@attr("test")
@@ -89,15 +89,36 @@ enum Color
grey( v : Int );
rgb (r:Int,g:Int,b:Int);
}
-</textarea></div>
+</textarea></p>
+
+<p>Hxml mode:</p>
+
+<p><textarea id="code-hxml">
+-cp test
+-js path/to/file.js
+#-remap nme:flash
+--next
+-D source-map-content
+-cmd 'test'
+-lib lime
+</textarea></p>
+</div>
<script>
- var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ var editor = CodeMirror.fromTextArea(document.getElementById("code-haxe"), {
+ mode: "haxe",
+ lineNumbers: true,
+ indentUnit: 4,
+ indentWithTabs: true
+ });
+
+ editor = CodeMirror.fromTextArea(document.getElementById("code-hxml"), {
+ mode: "hxml",
lineNumbers: true,
indentUnit: 4,
indentWithTabs: true
});
</script>
- <p><strong>MIME types defined:</strong> <code>text/x-haxe</code>.</p>
+ <p><strong>MIME types defined:</strong> <code>text/x-haxe, text/x-hxml</code>.</p>
</article>
diff --git a/data/ext/editorText/codemirror/mode/htmlembedded/htmlembedded.js b/data/ext/editorText/codemirror/mode/htmlembedded/htmlembedded.js
index c316cd340..464dc57f8 100644
--- a/data/ext/editorText/codemirror/mode/htmlembedded/htmlembedded.js
+++ b/data/ext/editorText/codemirror/mode/htmlembedded/htmlembedded.js
@@ -1,71 +1,28 @@
-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"});
+// 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"), require("../htmlmixed/htmlmixed"),
+ require("../../addon/mode/multiplex"));
+ else if (typeof define == "function" && define.amd) // AMD
+ 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) {
+ 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/data/ext/editorText/codemirror/mode/htmlembedded/index.html b/data/ext/editorText/codemirror/mode/htmlembedded/index.html
index fee119683..365ef8f36 100644
--- a/data/ext/editorText/codemirror/mode/htmlembedded/index.html
+++ b/data/ext/editorText/codemirror/mode/htmlembedded/index.html
@@ -10,15 +10,16 @@
<script src="../javascript/javascript.js"></script>
<script src="../css/css.js"></script>
<script src="../htmlmixed/htmlmixed.js"></script>
+<script src="../../addon/mode/multiplex.js"></script>
<script src="htmlembedded.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/htmlmixed/htmlmixed.js b/data/ext/editorText/codemirror/mode/htmlmixed/htmlmixed.js
index 8cc9c4e72..21e74f163 100644
--- a/data/ext/editorText/codemirror/mode/htmlmixed/htmlmixed.js
+++ b/data/ext/editorText/codemirror/mode/htmlmixed/htmlmixed.js
@@ -1,105 +1,150 @@
-CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
- var htmlMode = CodeMirror.getMode(config, {name: "xml",
- htmlMode: true,
- multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
- multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag});
- var cssMode = CodeMirror.getMode(config, "css");
-
- var scriptTypes = [], scriptTypesConf = parserConfig && parserConfig.scriptTypes;
- scriptTypes.push({matches: /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,
- mode: CodeMirror.getMode(config, "javascript")});
- if (scriptTypesConf) for (var i = 0; i < scriptTypesConf.length; ++i) {
- var conf = scriptTypesConf[i];
- scriptTypes.push({matches: conf.matches, mode: conf.mode && CodeMirror.getMode(config, conf.mode)});
- }
- scriptTypes.push({matches: /./,
- mode: CodeMirror.getMode(config, "text/plain")});
-
- function html(stream, state) {
- var tagName = state.htmlState.tagName;
- var style = htmlMode.token(stream, state.htmlState);
- if (tagName == "script" && /\btag\b/.test(style) && stream.current() == ">") {
- // Script block: mode to change to depends on type attribute
- var scriptType = stream.string.slice(Math.max(0, stream.pos - 100), stream.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i);
- scriptType = scriptType ? scriptType[1] : "";
- if (scriptType && /[\"\']/.test(scriptType.charAt(0))) scriptType = scriptType.slice(1, scriptType.length - 1);
- for (var i = 0; i < scriptTypes.length; ++i) {
- var tp = scriptTypes[i];
- if (typeof tp.matches == "string" ? scriptType == tp.matches : tp.matches.test(scriptType)) {
- if (tp.mode) {
- state.token = script;
- state.localMode = tp.mode;
- state.localState = tp.mode.startState && tp.mode.startState(htmlMode.indent(state.htmlState, ""));
- }
- break;
- }
- }
- } else if (tagName == "style" && /\btag\b/.test(style) && stream.current() == ">") {
- state.token = css;
- state.localMode = cssMode;
- state.localState = cssMode.startState(htmlMode.indent(state.htmlState, ""));
- }
- return style;
- }
+// 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"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ var defaultTags = {
+ script: [
+ ["lang", /(javascript|babel)/i, "javascript"],
+ ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i, "javascript"],
+ ["type", /./, "text/plain"],
+ [null, null, "javascript"]
+ ],
+ style: [
+ ["lang", /^css$/i, "css"],
+ ["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"],
+ ["type", /./, "text/plain"],
+ [null, null, "css"]
+ ]
+ };
+
function maybeBackup(stream, pat, style) {
- var cur = stream.current();
- var close = cur.search(pat), m;
- if (close > -1) stream.backUp(cur.length - close);
- else if (m = cur.match(/<\/?$/)) {
+ var cur = stream.current(), close = cur.search(pat);
+ if (close > -1) {
+ stream.backUp(cur.length - close);
+ } else if (cur.match(/<\/?$/)) {
stream.backUp(cur.length);
if (!stream.match(pat, false)) stream.match(cur);
}
return style;
}
- function script(stream, state) {
- if (stream.match(/^<\/\s*script\s*>/i, false)) {
- state.token = html;
- state.localState = state.localMode = null;
- return html(stream, state);
- }
- return maybeBackup(stream, /<\/\s*script\s*>/,
- state.localMode.token(stream, state.localState));
+
+ var attrRegexpCache = {};
+ function getAttrRegexp(attr) {
+ var regexp = attrRegexpCache[attr];
+ if (regexp) return regexp;
+ return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
+ }
+
+ function getAttrValue(stream, attr) {
+ var pos = stream.pos, match;
+ while (pos >= 0 && stream.string.charAt(pos) !== "<") pos--;
+ if (pos < 0) return pos;
+ if (match = stream.string.slice(pos, stream.pos).match(getAttrRegexp(attr)))
+ return match[2];
+ return "";
+ }
+
+ function getTagRegexp(tagName, anchored) {
+ return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i");
}
- function css(stream, state) {
- if (stream.match(/^<\/\s*style\s*>/i, false)) {
- state.token = html;
- state.localState = state.localMode = null;
- return html(stream, state);
+
+ function addTags(from, to) {
+ for (var tag in from) {
+ var dest = to[tag] || (to[tag] = []);
+ var source = from[tag];
+ for (var i = source.length - 1; i >= 0; i--)
+ dest.unshift(source[i])
}
- return maybeBackup(stream, /<\/\s*style\s*>/,
- cssMode.token(stream, state.localState));
}
- return {
- startState: function() {
- var state = htmlMode.startState();
- return {token: html, localMode: null, localState: null, htmlState: state};
- },
-
- copyState: function(state) {
- if (state.localState)
- var local = CodeMirror.copyState(state.localMode, state.localState);
- return {token: state.token, localMode: state.localMode, localState: local,
- htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
- },
-
- token: function(stream, state) {
- return state.token(stream, state);
- },
-
- indent: function(state, textAfter) {
- if (!state.localMode || /^\s*<\//.test(textAfter))
- return htmlMode.indent(state.htmlState, textAfter);
- else if (state.localMode.indent)
- return state.localMode.indent(state.localState, textAfter);
- else
- return CodeMirror.Pass;
- },
-
- innerMode: function(state) {
- return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
+ function findMatchingMode(tagInfo, stream) {
+ for (var i = 0; i < tagInfo.length; i++) {
+ var spec = tagInfo[i];
+ if (!spec[0] || spec[1].test(getAttrValue(stream, spec[0]))) return spec[2];
}
- };
-}, "xml", "javascript", "css");
+ }
+
+ CodeMirror.defineMode("htmlmixed", function (config, parserConfig) {
+ var htmlMode = CodeMirror.getMode(config, {
+ name: "xml",
+ htmlMode: true,
+ multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
+ multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
+ });
+
+ var tags = {};
+ var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
+ addTags(defaultTags, tags);
+ if (configTags) addTags(configTags, tags);
+ if (configScript) for (var i = configScript.length - 1; i >= 0; i--)
+ tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
+
+ function html(stream, state) {
+ var tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase();
+ var tagInfo = tagName && tags.hasOwnProperty(tagName) && tags[tagName];
+
+ var style = htmlMode.token(stream, state.htmlState), modeSpec;
+
+ if (tagInfo && /\btag\b/.test(style) && stream.current() === ">" &&
+ (modeSpec = findMatchingMode(tagInfo, stream))) {
+ var mode = CodeMirror.getMode(config, modeSpec);
+ var endTagA = getTagRegexp(tagName, true), endTag = getTagRegexp(tagName, false);
+ state.token = function (stream, state) {
+ if (stream.match(endTagA, false)) {
+ state.token = html;
+ state.localState = state.localMode = null;
+ return null;
+ }
+ return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
+ };
+ state.localMode = mode;
+ state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, ""));
+ }
+ return style;
+ };
+
+ return {
+ startState: function () {
+ var state = htmlMode.startState();
+ return {token: html, localMode: null, localState: null, htmlState: state};
+ },
+
+ copyState: function (state) {
+ var local;
+ if (state.localState) {
+ local = CodeMirror.copyState(state.localMode, state.localState);
+ }
+ return {token: state.token, localMode: state.localMode, localState: local,
+ htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
+ },
+
+ token: function (stream, state) {
+ return state.token(stream, state);
+ },
+
+ indent: function (state, textAfter) {
+ if (!state.localMode || /^\s*<\//.test(textAfter))
+ return htmlMode.indent(state.htmlState, textAfter);
+ else if (state.localMode.indent)
+ return state.localMode.indent(state.localState, textAfter);
+ else
+ return CodeMirror.Pass;
+ },
+
+ innerMode: function (state) {
+ return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
+ }
+ };
+ }, "xml", "javascript", "css");
-CodeMirror.defineMIME("text/html", "htmlmixed");
+ CodeMirror.defineMIME("text/html", "htmlmixed");
+});
diff --git a/data/ext/editorText/codemirror/mode/htmlmixed/index.html b/data/ext/editorText/codemirror/mode/htmlmixed/index.html
index bd06bb504..f94df9e21 100644
--- a/data/ext/editorText/codemirror/mode/htmlmixed/index.html
+++ b/data/ext/editorText/codemirror/mode/htmlmixed/index.html
@@ -6,6 +6,7 @@
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/selection/selection-pointer.js"></script>
<script src="../xml/xml.js"></script>
<script src="../javascript/javascript.js"></script>
<script src="../css/css.js"></script>
@@ -13,12 +14,12 @@
<script src="htmlmixed.js"></script>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -62,7 +63,10 @@
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
- var editor = CodeMirror.fromTextArea(document.getElementById("code"), {mode: mixedMode});
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ mode: mixedMode,
+ selectionPointer: true
+ });
</script>
<p>The HTML mixed mode depends on the XML, JavaScript, and CSS modes.</p>
diff --git a/data/ext/editorText/codemirror/mode/http/http.js b/data/ext/editorText/codemirror/mode/http/http.js
index 5a5163602..9a3c5f9fd 100644
--- a/data/ext/editorText/codemirror/mode/http/http.js
+++ b/data/ext/editorText/codemirror/mode/http/http.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("http", function() {
function failFirstLine(stream, state) {
stream.skipToEnd();
@@ -96,3 +109,5 @@ CodeMirror.defineMode("http", function() {
});
CodeMirror.defineMIME("message/http", "http");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/http/index.html b/data/ext/editorText/codemirror/mode/http/index.html
index 705085e22..0b8d5315d 100644
--- a/data/ext/editorText/codemirror/mode/http/index.html
+++ b/data/ext/editorText/codemirror/mode/http/index.html
@@ -9,12 +9,12 @@
<script src="http.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/idl/idl.js b/data/ext/editorText/codemirror/mode/idl/idl.js
new file mode 100644
index 000000000..07308d71d
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/idl/idl.js
@@ -0,0 +1,290 @@
+// 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 wordRegexp(words) {
+ return new RegExp('^((' + words.join(')|(') + '))\\b', 'i');
+ };
+
+ var builtinArray = [
+ 'a_correlate', 'abs', 'acos', 'adapt_hist_equal', 'alog',
+ 'alog2', 'alog10', 'amoeba', 'annotate', 'app_user_dir',
+ 'app_user_dir_query', 'arg_present', 'array_equal', 'array_indices',
+ 'arrow', 'ascii_template', 'asin', 'assoc', 'atan',
+ 'axis', 'axis', 'bandpass_filter', 'bandreject_filter', 'barplot',
+ 'bar_plot', 'beseli', 'beselj', 'beselk', 'besely',
+ 'beta', 'biginteger', 'bilinear', 'bin_date', 'binary_template',
+ 'bindgen', 'binomial', 'bit_ffs', 'bit_population', 'blas_axpy',
+ 'blk_con', 'boolarr', 'boolean', 'boxplot', 'box_cursor',
+ 'breakpoint', 'broyden', 'bubbleplot', 'butterworth', 'bytarr',
+ 'byte', 'byteorder', 'bytscl', 'c_correlate', 'calendar',
+ 'caldat', 'call_external', 'call_function', 'call_method',
+ 'call_procedure', 'canny', 'catch', 'cd', 'cdf', 'ceil',
+ 'chebyshev', 'check_math', 'chisqr_cvf', 'chisqr_pdf', 'choldc',
+ 'cholsol', 'cindgen', 'cir_3pnt', 'clipboard', 'close',
+ 'clust_wts', 'cluster', 'cluster_tree', 'cmyk_convert', 'code_coverage',
+ 'color_convert', 'color_exchange', 'color_quan', 'color_range_map',
+ 'colorbar', 'colorize_sample', 'colormap_applicable',
+ 'colormap_gradient', 'colormap_rotation', 'colortable',
+ 'comfit', 'command_line_args', 'common', 'compile_opt', 'complex',
+ 'complexarr', 'complexround', 'compute_mesh_normals', 'cond', 'congrid',
+ 'conj', 'constrained_min', 'contour', 'contour', 'convert_coord',
+ 'convol', 'convol_fft', 'coord2to3', 'copy_lun', 'correlate',
+ 'cos', 'cosh', 'cpu', 'cramer', 'createboxplotdata',
+ 'create_cursor', 'create_struct', 'create_view', 'crossp', 'crvlength',
+ 'ct_luminance', 'cti_test', 'cursor', 'curvefit', 'cv_coord',
+ 'cvttobm', 'cw_animate', 'cw_animate_getp', 'cw_animate_load',
+ 'cw_animate_run', 'cw_arcball', 'cw_bgroup', 'cw_clr_index',
+ 'cw_colorsel', 'cw_defroi', 'cw_field', 'cw_filesel', 'cw_form',
+ 'cw_fslider', 'cw_light_editor', 'cw_light_editor_get',
+ 'cw_light_editor_set', 'cw_orient', 'cw_palette_editor',
+ 'cw_palette_editor_get', 'cw_palette_editor_set', 'cw_pdmenu',
+ 'cw_rgbslider', 'cw_tmpl', 'cw_zoom', 'db_exists',
+ 'dblarr', 'dcindgen', 'dcomplex', 'dcomplexarr', 'define_key',
+ 'define_msgblk', 'define_msgblk_from_file', 'defroi', 'defsysv',
+ 'delvar', 'dendro_plot', 'dendrogram', 'deriv', 'derivsig',
+ 'determ', 'device', 'dfpmin', 'diag_matrix', 'dialog_dbconnect',
+ 'dialog_message', 'dialog_pickfile', 'dialog_printersetup',
+ 'dialog_printjob', 'dialog_read_image',
+ 'dialog_write_image', 'dictionary', 'digital_filter', 'dilate', 'dindgen',
+ 'dissolve', 'dist', 'distance_measure', 'dlm_load', 'dlm_register',
+ 'doc_library', 'double', 'draw_roi', 'edge_dog', 'efont',
+ 'eigenql', 'eigenvec', 'ellipse', 'elmhes', 'emboss',
+ 'empty', 'enable_sysrtn', 'eof', 'eos', 'erase',
+ 'erf', 'erfc', 'erfcx', 'erode', 'errorplot',
+ 'errplot', 'estimator_filter', 'execute', 'exit', 'exp',
+ 'expand', 'expand_path', 'expint', 'extrac', 'extract_slice',
+ 'f_cvf', 'f_pdf', 'factorial', 'fft', 'file_basename',
+ 'file_chmod', 'file_copy', 'file_delete', 'file_dirname',
+ 'file_expand_path', 'file_gunzip', 'file_gzip', 'file_info',
+ 'file_lines', 'file_link', 'file_mkdir', 'file_move',
+ 'file_poll_input', 'file_readlink', 'file_same',
+ 'file_search', 'file_tar', 'file_test', 'file_untar', 'file_unzip',
+ 'file_which', 'file_zip', 'filepath', 'findgen', 'finite',
+ 'fix', 'flick', 'float', 'floor', 'flow3',
+ 'fltarr', 'flush', 'format_axis_values', 'forward_function', 'free_lun',
+ 'fstat', 'fulstr', 'funct', 'function', 'fv_test',
+ 'fx_root', 'fz_roots', 'gamma', 'gamma_ct', 'gauss_cvf',
+ 'gauss_pdf', 'gauss_smooth', 'gauss2dfit', 'gaussfit',
+ 'gaussian_function', 'gaussint', 'get_drive_list', 'get_dxf_objects',
+ 'get_kbrd', 'get_login_info',
+ 'get_lun', 'get_screen_size', 'getenv', 'getwindows', 'greg2jul',
+ 'grib', 'grid_input', 'grid_tps', 'grid3', 'griddata',
+ 'gs_iter', 'h_eq_ct', 'h_eq_int', 'hanning', 'hash',
+ 'hdf', 'hdf5', 'heap_free', 'heap_gc', 'heap_nosave',
+ 'heap_refcount', 'heap_save', 'help', 'hilbert', 'hist_2d',
+ 'hist_equal', 'histogram', 'hls', 'hough', 'hqr',
+ 'hsv', 'i18n_multibytetoutf8',
+ 'i18n_multibytetowidechar', 'i18n_utf8tomultibyte',
+ 'i18n_widechartomultibyte',
+ 'ibeta', 'icontour', 'iconvertcoord', 'idelete', 'identity',
+ 'idl_base64', 'idl_container', 'idl_validname',
+ 'idlexbr_assistant', 'idlitsys_createtool',
+ 'idlunit', 'iellipse', 'igamma', 'igetcurrent', 'igetdata',
+ 'igetid', 'igetproperty', 'iimage', 'image', 'image_cont',
+ 'image_statistics', 'image_threshold', 'imaginary', 'imap', 'indgen',
+ 'int_2d', 'int_3d', 'int_tabulated', 'intarr', 'interpol',
+ 'interpolate', 'interval_volume', 'invert', 'ioctl', 'iopen',
+ 'ir_filter', 'iplot', 'ipolygon', 'ipolyline', 'iputdata',
+ 'iregister', 'ireset', 'iresolve', 'irotate', 'isa',
+ 'isave', 'iscale', 'isetcurrent', 'isetproperty', 'ishft',
+ 'isocontour', 'isosurface', 'isurface', 'itext', 'itranslate',
+ 'ivector', 'ivolume', 'izoom', 'journal', 'json_parse',
+ 'json_serialize', 'jul2greg', 'julday', 'keyword_set', 'krig2d',
+ 'kurtosis', 'kw_test', 'l64indgen', 'la_choldc', 'la_cholmprove',
+ 'la_cholsol', 'la_determ', 'la_eigenproblem', 'la_eigenql', 'la_eigenvec',
+ 'la_elmhes', 'la_gm_linear_model', 'la_hqr', 'la_invert',
+ 'la_least_square_equality', 'la_least_squares', 'la_linear_equation',
+ 'la_ludc', 'la_lumprove', 'la_lusol',
+ 'la_svd', 'la_tridc', 'la_trimprove', 'la_triql', 'la_trired',
+ 'la_trisol', 'label_date', 'label_region', 'ladfit', 'laguerre',
+ 'lambda', 'lambdap', 'lambertw', 'laplacian', 'least_squares_filter',
+ 'leefilt', 'legend', 'legendre', 'linbcg', 'lindgen',
+ 'linfit', 'linkimage', 'list', 'll_arc_distance', 'lmfit',
+ 'lmgr', 'lngamma', 'lnp_test', 'loadct', 'locale_get',
+ 'logical_and', 'logical_or', 'logical_true', 'lon64arr', 'lonarr',
+ 'long', 'long64', 'lsode', 'lu_complex', 'ludc',
+ 'lumprove', 'lusol', 'm_correlate', 'machar', 'make_array',
+ 'make_dll', 'make_rt', 'map', 'mapcontinents', 'mapgrid',
+ 'map_2points', 'map_continents', 'map_grid', 'map_image', 'map_patch',
+ 'map_proj_forward', 'map_proj_image', 'map_proj_info',
+ 'map_proj_init', 'map_proj_inverse',
+ 'map_set', 'matrix_multiply', 'matrix_power', 'max', 'md_test',
+ 'mean', 'meanabsdev', 'mean_filter', 'median', 'memory',
+ 'mesh_clip', 'mesh_decimate', 'mesh_issolid',
+ 'mesh_merge', 'mesh_numtriangles',
+ 'mesh_obj', 'mesh_smooth', 'mesh_surfacearea',
+ 'mesh_validate', 'mesh_volume',
+ 'message', 'min', 'min_curve_surf', 'mk_html_help', 'modifyct',
+ 'moment', 'morph_close', 'morph_distance',
+ 'morph_gradient', 'morph_hitormiss',
+ 'morph_open', 'morph_thin', 'morph_tophat', 'multi', 'n_elements',
+ 'n_params', 'n_tags', 'ncdf', 'newton', 'noise_hurl',
+ 'noise_pick', 'noise_scatter', 'noise_slur', 'norm', 'obj_class',
+ 'obj_destroy', 'obj_hasmethod', 'obj_isa', 'obj_new', 'obj_valid',
+ 'objarr', 'on_error', 'on_ioerror', 'online_help', 'openr',
+ 'openu', 'openw', 'oplot', 'oploterr', 'orderedhash',
+ 'p_correlate', 'parse_url', 'particle_trace', 'path_cache', 'path_sep',
+ 'pcomp', 'plot', 'plot3d', 'plot', 'plot_3dbox',
+ 'plot_field', 'ploterr', 'plots', 'polar_contour', 'polar_surface',
+ 'polyfill', 'polyshade', 'pnt_line', 'point_lun', 'polarplot',
+ 'poly', 'poly_2d', 'poly_area', 'poly_fit', 'polyfillv',
+ 'polygon', 'polyline', 'polywarp', 'popd', 'powell',
+ 'pref_commit', 'pref_get', 'pref_set', 'prewitt', 'primes',
+ 'print', 'printf', 'printd', 'pro', 'product',
+ 'profile', 'profiler', 'profiles', 'project_vol', 'ps_show_fonts',
+ 'psafm', 'pseudo', 'ptr_free', 'ptr_new', 'ptr_valid',
+ 'ptrarr', 'pushd', 'qgrid3', 'qhull', 'qromb',
+ 'qromo', 'qsimp', 'query_*', 'query_ascii', 'query_bmp',
+ 'query_csv', 'query_dicom', 'query_gif', 'query_image', 'query_jpeg',
+ 'query_jpeg2000', 'query_mrsid', 'query_pict', 'query_png', 'query_ppm',
+ 'query_srf', 'query_tiff', 'query_video', 'query_wav', 'r_correlate',
+ 'r_test', 'radon', 'randomn', 'randomu', 'ranks',
+ 'rdpix', 'read', 'readf', 'read_ascii', 'read_binary',
+ 'read_bmp', 'read_csv', 'read_dicom', 'read_gif', 'read_image',
+ 'read_interfile', 'read_jpeg', 'read_jpeg2000', 'read_mrsid', 'read_pict',
+ 'read_png', 'read_ppm', 'read_spr', 'read_srf', 'read_sylk',
+ 'read_tiff', 'read_video', 'read_wav', 'read_wave', 'read_x11_bitmap',
+ 'read_xwd', 'reads', 'readu', 'real_part', 'rebin',
+ 'recall_commands', 'recon3', 'reduce_colors', 'reform', 'region_grow',
+ 'register_cursor', 'regress', 'replicate',
+ 'replicate_inplace', 'resolve_all',
+ 'resolve_routine', 'restore', 'retall', 'return', 'reverse',
+ 'rk4', 'roberts', 'rot', 'rotate', 'round',
+ 'routine_filepath', 'routine_info', 'rs_test', 's_test', 'save',
+ 'savgol', 'scale3', 'scale3d', 'scatterplot', 'scatterplot3d',
+ 'scope_level', 'scope_traceback', 'scope_varfetch',
+ 'scope_varname', 'search2d',
+ 'search3d', 'sem_create', 'sem_delete', 'sem_lock', 'sem_release',
+ 'set_plot', 'set_shading', 'setenv', 'sfit', 'shade_surf',
+ 'shade_surf_irr', 'shade_volume', 'shift', 'shift_diff', 'shmdebug',
+ 'shmmap', 'shmunmap', 'shmvar', 'show3', 'showfont',
+ 'signum', 'simplex', 'sin', 'sindgen', 'sinh',
+ 'size', 'skewness', 'skip_lun', 'slicer3', 'slide_image',
+ 'smooth', 'sobel', 'socket', 'sort', 'spawn',
+ 'sph_4pnt', 'sph_scat', 'spher_harm', 'spl_init', 'spl_interp',
+ 'spline', 'spline_p', 'sprsab', 'sprsax', 'sprsin',
+ 'sprstp', 'sqrt', 'standardize', 'stddev', 'stop',
+ 'strarr', 'strcmp', 'strcompress', 'streamline', 'streamline',
+ 'stregex', 'stretch', 'string', 'strjoin', 'strlen',
+ 'strlowcase', 'strmatch', 'strmessage', 'strmid', 'strpos',
+ 'strput', 'strsplit', 'strtrim', 'struct_assign', 'struct_hide',
+ 'strupcase', 'surface', 'surface', 'surfr', 'svdc',
+ 'svdfit', 'svsol', 'swap_endian', 'swap_endian_inplace', 'symbol',
+ 'systime', 't_cvf', 't_pdf', 't3d', 'tag_names',
+ 'tan', 'tanh', 'tek_color', 'temporary', 'terminal_size',
+ 'tetra_clip', 'tetra_surface', 'tetra_volume', 'text', 'thin',
+ 'thread', 'threed', 'tic', 'time_test2', 'timegen',
+ 'timer', 'timestamp', 'timestamptovalues', 'tm_test', 'toc',
+ 'total', 'trace', 'transpose', 'tri_surf', 'triangulate',
+ 'trigrid', 'triql', 'trired', 'trisol', 'truncate_lun',
+ 'ts_coef', 'ts_diff', 'ts_fcast', 'ts_smooth', 'tv',
+ 'tvcrs', 'tvlct', 'tvrd', 'tvscl', 'typename',
+ 'uindgen', 'uint', 'uintarr', 'ul64indgen', 'ulindgen',
+ 'ulon64arr', 'ulonarr', 'ulong', 'ulong64', 'uniq',
+ 'unsharp_mask', 'usersym', 'value_locate', 'variance', 'vector',
+ 'vector_field', 'vel', 'velovect', 'vert_t3d', 'voigt',
+ 'volume', 'voronoi', 'voxel_proj', 'wait', 'warp_tri',
+ 'watershed', 'wdelete', 'wf_draw', 'where', 'widget_base',
+ 'widget_button', 'widget_combobox', 'widget_control',
+ 'widget_displaycontextmenu', 'widget_draw',
+ 'widget_droplist', 'widget_event', 'widget_info',
+ 'widget_label', 'widget_list',
+ 'widget_propertysheet', 'widget_slider', 'widget_tab',
+ 'widget_table', 'widget_text',
+ 'widget_tree', 'widget_tree_move', 'widget_window',
+ 'wiener_filter', 'window',
+ 'window', 'write_bmp', 'write_csv', 'write_gif', 'write_image',
+ 'write_jpeg', 'write_jpeg2000', 'write_nrif', 'write_pict', 'write_png',
+ 'write_ppm', 'write_spr', 'write_srf', 'write_sylk', 'write_tiff',
+ 'write_video', 'write_wav', 'write_wave', 'writeu', 'wset',
+ 'wshow', 'wtn', 'wv_applet', 'wv_cwt', 'wv_cw_wavelet',
+ 'wv_denoise', 'wv_dwt', 'wv_fn_coiflet',
+ 'wv_fn_daubechies', 'wv_fn_gaussian',
+ 'wv_fn_haar', 'wv_fn_morlet', 'wv_fn_paul',
+ 'wv_fn_symlet', 'wv_import_data',
+ 'wv_import_wavelet', 'wv_plot3d_wps', 'wv_plot_multires',
+ 'wv_pwt', 'wv_tool_denoise',
+ 'xbm_edit', 'xdisplayfile', 'xdxf', 'xfont', 'xinteranimate',
+ 'xloadct', 'xmanager', 'xmng_tmpl', 'xmtool', 'xobjview',
+ 'xobjview_rotate', 'xobjview_write_image',
+ 'xpalette', 'xpcolor', 'xplot3d',
+ 'xregistered', 'xroi', 'xsq_test', 'xsurface', 'xvaredit',
+ 'xvolume', 'xvolume_rotate', 'xvolume_write_image',
+ 'xyouts', 'zlib_compress', 'zlib_uncompress', 'zoom', 'zoom_24'
+ ];
+ var builtins = wordRegexp(builtinArray);
+
+ var keywordArray = [
+ 'begin', 'end', 'endcase', 'endfor',
+ 'endwhile', 'endif', 'endrep', 'endforeach',
+ 'break', 'case', 'continue', 'for',
+ 'foreach', 'goto', 'if', 'then', 'else',
+ 'repeat', 'until', 'switch', 'while',
+ 'do', 'pro', 'function'
+ ];
+ var keywords = wordRegexp(keywordArray);
+
+ CodeMirror.registerHelper("hintWords", "idl", builtinArray.concat(keywordArray));
+
+ var identifiers = new RegExp('^[_a-z\xa1-\uffff][_a-z0-9\xa1-\uffff]*', 'i');
+
+ var singleOperators = /[+\-*&=<>\/@#~$]/;
+ var boolOperators = new RegExp('(and|or|eq|lt|le|gt|ge|ne|not)', 'i');
+
+ function tokenBase(stream) {
+ // whitespaces
+ if (stream.eatSpace()) return null;
+
+ // Handle one line Comments
+ if (stream.match(';')) {
+ stream.skipToEnd();
+ return 'comment';
+ }
+
+ // Handle Number Literals
+ if (stream.match(/^[0-9\.+-]/, false)) {
+ if (stream.match(/^[+-]?0x[0-9a-fA-F]+/))
+ return 'number';
+ if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?/))
+ return 'number';
+ if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?/))
+ return 'number';
+ }
+
+ // Handle Strings
+ if (stream.match(/^"([^"]|(""))*"/)) { return 'string'; }
+ if (stream.match(/^'([^']|(''))*'/)) { return 'string'; }
+
+ // Handle words
+ if (stream.match(keywords)) { return 'keyword'; }
+ if (stream.match(builtins)) { return 'builtin'; }
+ if (stream.match(identifiers)) { return 'variable'; }
+
+ if (stream.match(singleOperators) || stream.match(boolOperators)) {
+ return 'operator'; }
+
+ // Handle non-detected items
+ stream.next();
+ return null;
+ };
+
+ CodeMirror.defineMode('idl', function() {
+ return {
+ token: function(stream) {
+ return tokenBase(stream);
+ }
+ };
+ });
+
+ CodeMirror.defineMIME('text/x-idl', 'idl');
+});
diff --git a/data/ext/editorText/codemirror/mode/idl/index.html b/data/ext/editorText/codemirror/mode/idl/index.html
new file mode 100644
index 000000000..4c169e2d6
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/idl/index.html
@@ -0,0 +1,64 @@
+<!doctype html>
+
+<title>CodeMirror: IDL mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="idl.js"></script>
+<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">IDL</a>
+ </ul>
+</div>
+
+<article>
+<h2>IDL mode</h2>
+
+ <div><textarea id="code" name="code">
+;; Example IDL code
+FUNCTION mean_and_stddev,array
+ ;; This program reads in an array of numbers
+ ;; and returns a structure containing the
+ ;; average and standard deviation
+
+ ave = 0.0
+ count = 0.0
+
+ for i=0,N_ELEMENTS(array)-1 do begin
+ ave = ave + array[i]
+ count = count + 1
+ endfor
+
+ ave = ave/count
+
+ std = stddev(array)
+
+ return, {average:ave,std:std}
+
+END
+
+ </textarea></div>
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ mode: {name: "idl",
+ version: 1,
+ singleLineStringErrors: false},
+ lineNumbers: true,
+ indentUnit: 4,
+ matchBrackets: true
+ });
+ </script>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-idl</code>.</p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/index.html b/data/ext/editorText/codemirror/mode/index.html
index de39f9dd5..044dee7fd 100644
--- a/data/ext/editorText/codemirror/mode/index.html
+++ b/data/ext/editorText/codemirror/mode/index.html
@@ -5,12 +5,12 @@
<link rel=stylesheet href="../doc/docs.css">
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Language modes</a>
@@ -19,34 +19,46 @@
<article>
-<h2>Language modes</h2>
+ <h2>Language modes</h2>
-<p>This is a list of every mode in the distribution. Each mode lives
+ <p>This is a list of every mode in the distribution. Each mode lives
in a subdirectory of the <code>mode/</code> directory, and typically
defines a single JavaScript file that implements the mode. Loading
such file will make the language available to CodeMirror, through
-the <a href="manual.html#option_mode"><code>mode</code></a>
+the <a href="../doc/manual.html#option_mode"><code>mode</code></a>
option.</p>
-<div style="-webkit-columns: 100px 2; -moz-columns: 100px 2; columns: 100px 2;">
- <ul>
+ <div style="-webkit-columns: 100px 2; -moz-columns: 100px 2; columns: 100px 2;">
+ <ul style="margin-top: 0">
<li><a href="apl/index.html">APL</a></li>
+ <li><a href="asn.1/index.html">ASN.1</a></li>
<li><a href="asterisk/index.html">Asterisk dialplan</a></li>
+ <li><a href="brainfuck/index.html">Brainfuck</a></li>
<li><a href="clike/index.html">C, C++, C#</a></li>
+ <li><a href="clike/index.html">Ceylon</a></li>
<li><a href="clojure/index.html">Clojure</a></li>
+ <li><a href="css/gss.html">Closure Stylesheets (GSS)</a></li>
+ <li><a href="cmake/index.html">CMake</a></li>
<li><a href="cobol/index.html">COBOL</a></li>
<li><a href="coffeescript/index.html">CoffeeScript</a></li>
<li><a href="commonlisp/index.html">Common Lisp</a></li>
<li><a href="css/index.html">CSS</a></li>
+ <li><a href="cypher/index.html">Cypher</a></li>
<li><a href="python/index.html">Cython</a></li>
<li><a href="d/index.html">D</a></li>
+ <li><a href="dart/index.html">Dart</a></li>
<li><a href="django/index.html">Django</a> (templating language)</li>
+ <li><a href="dockerfile/index.html">Dockerfile</a></li>
<li><a href="diff/index.html">diff</a></li>
<li><a href="dtd/index.html">DTD</a></li>
<li><a href="dylan/index.html">Dylan</a></li>
+ <li><a href="ebnf/index.html">EBNF</a></li>
<li><a href="ecl/index.html">ECL</a></li>
<li><a href="eiffel/index.html">Eiffel</a></li>
+ <li><a href="elm/index.html">Elm</a></li>
<li><a href="erlang/index.html">Erlang</a></li>
+ <li><a href="factor/index.html">Factor</a></li>
+ <li><a href="forth/index.html">Forth</a></li>
<li><a href="fortran/index.html">Fortran</a></li>
<li><a href="mllike/index.html">F#</a></li>
<li><a href="gas/index.html">Gas</a> (AT&amp;T-style assembly)</li>
@@ -54,28 +66,38 @@ option.</p>
<li><a href="go/index.html">Go</a></li>
<li><a href="groovy/index.html">Groovy</a></li>
<li><a href="haml/index.html">HAML</a></li>
+ <li><a href="handlebars/index.html">Handlebars</a></li>
<li><a href="haskell/index.html">Haskell</a></li>
<li><a href="haxe/index.html">Haxe</a></li>
- <li><a href="htmlembedded/index.html">HTML embedded scripts</a></li>
+ <li><a href="htmlembedded/index.html">HTML embedded</a> (JSP, ASP.NET)</li>
<li><a href="htmlmixed/index.html">HTML mixed-mode</a></li>
<li><a href="http/index.html">HTTP</a></li>
+ <li><a href="idl/index.html">IDL</a></li>
<li><a href="clike/index.html">Java</a></li>
<li><a href="jade/index.html">Jade</a></li>
<li><a href="javascript/index.html">JavaScript</a></li>
<li><a href="jinja2/index.html">Jinja2</a></li>
<li><a href="julia/index.html">Julia</a></li>
+ <li><a href="kotlin/index.html">Kotlin</a></li>
<li><a href="css/less.html">LESS</a></li>
<li><a href="livescript/index.html">LiveScript</a></li>
<li><a href="lua/index.html">Lua</a></li>
<li><a href="markdown/index.html">Markdown</a> (<a href="gfm/index.html">GitHub-flavour</a>)</li>
+ <li><a href="mathematica/index.html">Mathematica</a></li>
<li><a href="mirc/index.html">mIRC</a></li>
+ <li><a href="modelica/index.html">Modelica</a></li>
+ <li><a href="mumps/index.html">MUMPS</a></li>
<li><a href="nginx/index.html">Nginx</a></li>
+ <li><a href="nsis/index.html">NSIS</a></li>
<li><a href="ntriples/index.html">NTriples</a></li>
+ <li><a href="clike/index.html">Objective C</a></li>
<li><a href="mllike/index.html">OCaml</a></li>
<li><a href="octave/index.html">Octave</a> (MATLAB)</li>
+ <li><a href="oz/index.html">Oz</a></li>
<li><a href="pascal/index.html">Pascal</a></li>
<li><a href="pegjs/index.html">PEG.js</a></li>
<li><a href="perl/index.html">Perl</a></li>
+ <li><a href="asciiarmor/index.html">PGP (ASCII armor)</a></li>
<li><a href="php/index.html">PHP</a></li>
<li><a href="pig/index.html">Pig Latin</a></li>
<li><a href="properties/index.html">Properties files</a></li>
@@ -83,32 +105,45 @@ option.</p>
<li><a href="python/index.html">Python</a></li>
<li><a href="q/index.html">Q</a></li>
<li><a href="r/index.html">R</a></li>
- <li>RPM <a href="rpm/spec/index.html">spec</a> and <a href="rpm/changes/index.html">changelog</a></li>
+ <li><a href="rpm/index.html">RPM</a></li>
<li><a href="rst/index.html">reStructuredText</a></li>
<li><a href="ruby/index.html">Ruby</a></li>
<li><a href="rust/index.html">Rust</a></li>
<li><a href="sass/index.html">Sass</a></li>
+ <li><a href="spreadsheet/index.html">Spreadsheet</a></li>
<li><a href="clike/scala.html">Scala</a></li>
<li><a href="scheme/index.html">Scheme</a></li>
<li><a href="css/scss.html">SCSS</a></li>
<li><a href="shell/index.html">Shell</a></li>
<li><a href="sieve/index.html">Sieve</a></li>
+ <li><a href="slim/index.html">Slim</a></li>
<li><a href="smalltalk/index.html">Smalltalk</a></li>
<li><a href="smarty/index.html">Smarty</a></li>
- <li><a href="smartymixed/index.html">Smarty/HTML mixed</a></li>
<li><a href="solr/index.html">Solr</a></li>
+ <li><a href="soy/index.html">Soy</a></li>
+ <li><a href="stylus/index.html">Stylus</a></li>
<li><a href="sql/index.html">SQL</a> (several dialects)</li>
<li><a href="sparql/index.html">SPARQL</a></li>
+ <li><a href="clike/index.html">Squirrel</a></li>
+ <li><a href="swift/index.html">Swift</a></li>
<li><a href="stex/index.html">sTeX, LaTeX</a></li>
<li><a href="tcl/index.html">Tcl</a></li>
+ <li><a href="textile/index.html">Textile</a></li>
<li><a href="tiddlywiki/index.html">Tiddlywiki</a></li>
<li><a href="tiki/index.html">Tiki wiki</a></li>
<li><a href="toml/index.html">TOML</a></li>
+ <li><a href="tornado/index.html">Tornado</a> (templating language)</li>
+ <li><a href="troff/index.html">troff</a> (for manpages)</li>
+ <li><a href="ttcn/index.html">TTCN</a></li>
+ <li><a href="ttcn-cfg/index.html">TTCN Configuration</a></li>
<li><a href="turtle/index.html">Turtle</a></li>
+ <li><a href="twig/index.html">Twig</a></li>
<li><a href="vb/index.html">VB.NET</a></li>
<li><a href="vbscript/index.html">VBScript</a></li>
<li><a href="velocity/index.html">Velocity</a></li>
<li><a href="verilog/index.html">Verilog/SystemVerilog</a></li>
+ <li><a href="vhdl/index.html">VHDL</a></li>
+ <li><a href="vue/index.html">Vue.js app</a></li>
<li><a href="xml/index.html">XML/HTML</a></li>
<li><a href="xquery/index.html">XQuery</a></li>
<li><a href="yaml/index.html">YAML</a></li>
diff --git a/data/ext/editorText/codemirror/mode/jade/index.html b/data/ext/editorText/codemirror/mode/jade/index.html
index e22b15e65..e534981b2 100644
--- a/data/ext/editorText/codemirror/mode/jade/index.html
+++ b/data/ext/editorText/codemirror/mode/jade/index.html
@@ -6,15 +6,19 @@
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
+<script src="../javascript/javascript.js"></script>
+<script src="../css/css.js"></script>
+<script src="../xml/xml.js"></script>
+<script src="../htmlmixed/htmlmixed.js"></script>
<script src="jade.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -25,7 +29,7 @@
<article>
<h2>Jade Templating Mode</h2>
<form><textarea id="code" name="code">
-doctype 5
+doctype html
html
head
title= "Jade Templating CodeMirror Mode Example"
@@ -61,6 +65,6 @@ doctype 5
});
</script>
<h3>The Jade Templating Mode</h3>
- <p> Created by Drew Bratcher. Managed as part of an Adobe Brackets extension at <a href="https://github.com/dbratcher/brackets-jade">https://github.com/dbratcher/brackets-jade</a>.</p>
+ <p> Created by Forbes Lindesay. Managed as part of a Brackets extension at <a href="https://github.com/ForbesLindesay/jade-brackets">https://github.com/ForbesLindesay/jade-brackets</a>.</p>
<p><strong>MIME type defined:</strong> <code>text/x-jade</code>.</p>
</article>
diff --git a/data/ext/editorText/codemirror/mode/jade/jade.js b/data/ext/editorText/codemirror/mode/jade/jade.js
index 61abb27ab..96fadb19e 100644
--- a/data/ext/editorText/codemirror/mode/jade/jade.js
+++ b/data/ext/editorText/codemirror/mode/jade/jade.js
@@ -1,90 +1,590 @@
-CodeMirror.defineMode("jade", function () {
- var symbol_regex1 = /^(?:~|!|%|\^|\*|\+|=|\\|:|;|,|\/|\?|&|<|>|\|)/;
- var open_paren_regex = /^(\(|\[)/;
- var close_paren_regex = /^(\)|\])/;
- var keyword_regex1 = /^(if|else|return|var|function|include|doctype|each)/;
- var keyword_regex2 = /^(#|{|}|\.)/;
- var keyword_regex3 = /^(in)/;
- var html_regex1 = /^(html|head|title|meta|link|script|body|br|div|input|span|a|img)/;
- var html_regex2 = /^(h1|h2|h3|h4|h5|p|strong|em)/;
- return {
- startState: function () {
- return {
- inString: false,
- stringType: "",
- beforeTag: true,
- justMatchedKeyword: false,
- afterParen: false
- };
- },
- token: function (stream, state) {
- //check for state changes
- if (!state.inString && ((stream.peek() == '"') || (stream.peek() == "'"))) {
- state.stringType = stream.peek();
- stream.next(); // Skip quote
- state.inString = true; // Update state
- }
-
- //return state
- if (state.inString) {
- if (stream.skipTo(state.stringType)) { // Quote found on this line
- stream.next(); // Skip quote
- state.inString = false; // Clear flag
- } else {
- stream.skipToEnd(); // Rest of line is string
+// 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"), require("../javascript/javascript"), require("../css/css"), require("../htmlmixed/htmlmixed"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../javascript/javascript", "../css/css", "../htmlmixed/htmlmixed"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.defineMode('jade', function (config) {
+ // token types
+ var KEYWORD = 'keyword';
+ var DOCTYPE = 'meta';
+ var ID = 'builtin';
+ var CLASS = 'qualifier';
+
+ var ATTRS_NEST = {
+ '{': '}',
+ '(': ')',
+ '[': ']'
+ };
+
+ var jsMode = CodeMirror.getMode(config, 'javascript');
+
+ function State() {
+ this.javaScriptLine = false;
+ this.javaScriptLineExcludesColon = false;
+
+ this.javaScriptArguments = false;
+ this.javaScriptArgumentsDepth = 0;
+
+ this.isInterpolating = false;
+ this.interpolationNesting = 0;
+
+ this.jsState = jsMode.startState();
+
+ this.restOfLine = '';
+
+ this.isIncludeFiltered = false;
+ this.isEach = false;
+
+ this.lastTag = '';
+ this.scriptType = '';
+
+ // Attributes Mode
+ this.isAttrs = false;
+ this.attrsNest = [];
+ this.inAttributeName = true;
+ this.attributeIsType = false;
+ this.attrValue = '';
+
+ // Indented Mode
+ this.indentOf = Infinity;
+ this.indentToken = '';
+
+ this.innerMode = null;
+ this.innerState = null;
+
+ this.innerModeForLine = false;
+ }
+ /**
+ * Safely copy a state
+ *
+ * @return {State}
+ */
+ State.prototype.copy = function () {
+ var res = new State();
+ res.javaScriptLine = this.javaScriptLine;
+ res.javaScriptLineExcludesColon = this.javaScriptLineExcludesColon;
+ res.javaScriptArguments = this.javaScriptArguments;
+ res.javaScriptArgumentsDepth = this.javaScriptArgumentsDepth;
+ res.isInterpolating = this.isInterpolating;
+ res.interpolationNesting = this.intpolationNesting;
+
+ res.jsState = CodeMirror.copyState(jsMode, this.jsState);
+
+ res.innerMode = this.innerMode;
+ if (this.innerMode && this.innerState) {
+ res.innerState = CodeMirror.copyState(this.innerMode, this.innerState);
+ }
+
+ res.restOfLine = this.restOfLine;
+
+ res.isIncludeFiltered = this.isIncludeFiltered;
+ res.isEach = this.isEach;
+ res.lastTag = this.lastTag;
+ res.scriptType = this.scriptType;
+ res.isAttrs = this.isAttrs;
+ res.attrsNest = this.attrsNest.slice();
+ res.inAttributeName = this.inAttributeName;
+ res.attributeIsType = this.attributeIsType;
+ res.attrValue = this.attrValue;
+ res.indentOf = this.indentOf;
+ res.indentToken = this.indentToken;
+
+ res.innerModeForLine = this.innerModeForLine;
+
+ return res;
+ };
+
+ function javaScript(stream, state) {
+ if (stream.sol()) {
+ // if javaScriptLine was set at end of line, ignore it
+ state.javaScriptLine = false;
+ state.javaScriptLineExcludesColon = false;
+ }
+ if (state.javaScriptLine) {
+ if (state.javaScriptLineExcludesColon && stream.peek() === ':') {
+ state.javaScriptLine = false;
+ state.javaScriptLineExcludesColon = false;
+ return;
+ }
+ var tok = jsMode.token(stream, state.jsState);
+ if (stream.eol()) state.javaScriptLine = false;
+ return tok || true;
+ }
+ }
+ function javaScriptArguments(stream, state) {
+ if (state.javaScriptArguments) {
+ if (state.javaScriptArgumentsDepth === 0 && stream.peek() !== '(') {
+ state.javaScriptArguments = false;
+ return;
+ }
+ if (stream.peek() === '(') {
+ state.javaScriptArgumentsDepth++;
+ } else if (stream.peek() === ')') {
+ state.javaScriptArgumentsDepth--;
+ }
+ if (state.javaScriptArgumentsDepth === 0) {
+ state.javaScriptArguments = false;
+ return;
+ }
+
+ var tok = jsMode.token(stream, state.jsState);
+ return tok || true;
+ }
+ }
+
+ function yieldStatement(stream) {
+ if (stream.match(/^yield\b/)) {
+ return 'keyword';
+ }
+ }
+
+ function doctype(stream) {
+ if (stream.match(/^(?:doctype) *([^\n]+)?/)) {
+ return DOCTYPE;
+ }
+ }
+
+ function interpolation(stream, state) {
+ if (stream.match('#{')) {
+ state.isInterpolating = true;
+ state.interpolationNesting = 0;
+ return 'punctuation';
+ }
+ }
+
+ function interpolationContinued(stream, state) {
+ if (state.isInterpolating) {
+ if (stream.peek() === '}') {
+ state.interpolationNesting--;
+ if (state.interpolationNesting < 0) {
+ stream.next();
+ state.isInterpolating = false;
+ return 'puncutation';
}
- state.justMatchedKeyword = false;
- return "string"; // Token style
- } else if (stream.sol() && stream.eatSpace()) {
- if (stream.match(keyword_regex1)) {
- state.justMatchedKeyword = true;
- stream.eatSpace();
- return "keyword";
+ } else if (stream.peek() === '{') {
+ state.interpolationNesting++;
+ }
+ return jsMode.token(stream, state.jsState) || true;
+ }
+ }
+
+ function caseStatement(stream, state) {
+ if (stream.match(/^case\b/)) {
+ state.javaScriptLine = true;
+ return KEYWORD;
+ }
+ }
+
+ function when(stream, state) {
+ if (stream.match(/^when\b/)) {
+ state.javaScriptLine = true;
+ state.javaScriptLineExcludesColon = true;
+ return KEYWORD;
+ }
+ }
+
+ function defaultStatement(stream) {
+ if (stream.match(/^default\b/)) {
+ return KEYWORD;
+ }
+ }
+
+ function extendsStatement(stream, state) {
+ if (stream.match(/^extends?\b/)) {
+ state.restOfLine = 'string';
+ return KEYWORD;
+ }
+ }
+
+ function append(stream, state) {
+ if (stream.match(/^append\b/)) {
+ state.restOfLine = 'variable';
+ return KEYWORD;
+ }
+ }
+ function prepend(stream, state) {
+ if (stream.match(/^prepend\b/)) {
+ state.restOfLine = 'variable';
+ return KEYWORD;
+ }
+ }
+ function block(stream, state) {
+ if (stream.match(/^block\b *(?:(prepend|append)\b)?/)) {
+ state.restOfLine = 'variable';
+ return KEYWORD;
+ }
+ }
+
+ function include(stream, state) {
+ if (stream.match(/^include\b/)) {
+ state.restOfLine = 'string';
+ return KEYWORD;
+ }
+ }
+
+ function includeFiltered(stream, state) {
+ if (stream.match(/^include:([a-zA-Z0-9\-]+)/, false) && stream.match('include')) {
+ state.isIncludeFiltered = true;
+ return KEYWORD;
+ }
+ }
+
+ function includeFilteredContinued(stream, state) {
+ if (state.isIncludeFiltered) {
+ var tok = filter(stream, state);
+ state.isIncludeFiltered = false;
+ state.restOfLine = 'string';
+ return tok;
+ }
+ }
+
+ function mixin(stream, state) {
+ if (stream.match(/^mixin\b/)) {
+ state.javaScriptLine = true;
+ return KEYWORD;
+ }
+ }
+
+ function call(stream, state) {
+ if (stream.match(/^\+([-\w]+)/)) {
+ if (!stream.match(/^\( *[-\w]+ *=/, false)) {
+ state.javaScriptArguments = true;
+ state.javaScriptArgumentsDepth = 0;
+ }
+ return 'variable';
+ }
+ if (stream.match(/^\+#{/, false)) {
+ stream.next();
+ state.mixinCallAfter = true;
+ return interpolation(stream, state);
+ }
+ }
+ function callArguments(stream, state) {
+ if (state.mixinCallAfter) {
+ state.mixinCallAfter = false;
+ if (!stream.match(/^\( *[-\w]+ *=/, false)) {
+ state.javaScriptArguments = true;
+ state.javaScriptArgumentsDepth = 0;
+ }
+ return true;
+ }
+ }
+
+ function conditional(stream, state) {
+ if (stream.match(/^(if|unless|else if|else)\b/)) {
+ state.javaScriptLine = true;
+ return KEYWORD;
+ }
+ }
+
+ function each(stream, state) {
+ if (stream.match(/^(- *)?(each|for)\b/)) {
+ state.isEach = true;
+ return KEYWORD;
+ }
+ }
+ function eachContinued(stream, state) {
+ if (state.isEach) {
+ if (stream.match(/^ in\b/)) {
+ state.javaScriptLine = true;
+ state.isEach = false;
+ return KEYWORD;
+ } else if (stream.sol() || stream.eol()) {
+ state.isEach = false;
+ } else if (stream.next()) {
+ while (!stream.match(/^ in\b/, false) && stream.next());
+ return 'variable';
+ }
+ }
+ }
+
+ function whileStatement(stream, state) {
+ if (stream.match(/^while\b/)) {
+ state.javaScriptLine = true;
+ return KEYWORD;
+ }
+ }
+
+ function tag(stream, state) {
+ var captures;
+ if (captures = stream.match(/^(\w(?:[-:\w]*\w)?)\/?/)) {
+ state.lastTag = captures[1].toLowerCase();
+ if (state.lastTag === 'script') {
+ state.scriptType = 'application/javascript';
+ }
+ return 'tag';
+ }
+ }
+
+ function filter(stream, state) {
+ if (stream.match(/^:([\w\-]+)/)) {
+ var innerMode;
+ if (config && config.innerModes) {
+ innerMode = config.innerModes(stream.current().substring(1));
+ }
+ if (!innerMode) {
+ innerMode = stream.current().substring(1);
+ }
+ if (typeof innerMode === 'string') {
+ innerMode = CodeMirror.getMode(config, innerMode);
+ }
+ setInnerMode(stream, state, innerMode);
+ return 'atom';
+ }
+ }
+
+ function code(stream, state) {
+ if (stream.match(/^(!?=|-)/)) {
+ state.javaScriptLine = true;
+ return 'punctuation';
+ }
+ }
+
+ function id(stream) {
+ if (stream.match(/^#([\w-]+)/)) {
+ return ID;
+ }
+ }
+
+ function className(stream) {
+ if (stream.match(/^\.([\w-]+)/)) {
+ return CLASS;
+ }
+ }
+
+ function attrs(stream, state) {
+ if (stream.peek() == '(') {
+ stream.next();
+ state.isAttrs = true;
+ state.attrsNest = [];
+ state.inAttributeName = true;
+ state.attrValue = '';
+ state.attributeIsType = false;
+ return 'punctuation';
+ }
+ }
+
+ function attrsContinued(stream, state) {
+ if (state.isAttrs) {
+ if (ATTRS_NEST[stream.peek()]) {
+ state.attrsNest.push(ATTRS_NEST[stream.peek()]);
+ }
+ if (state.attrsNest[state.attrsNest.length - 1] === stream.peek()) {
+ state.attrsNest.pop();
+ } else if (stream.eat(')')) {
+ state.isAttrs = false;
+ return 'punctuation';
+ }
+ if (state.inAttributeName && stream.match(/^[^=,\)!]+/)) {
+ if (stream.peek() === '=' || stream.peek() === '!') {
+ state.inAttributeName = false;
+ state.jsState = jsMode.startState();
+ if (state.lastTag === 'script' && stream.current().trim().toLowerCase() === 'type') {
+ state.attributeIsType = true;
+ } else {
+ state.attributeIsType = false;
+ }
}
- if (stream.match(html_regex1) || stream.match(html_regex2)) {
- state.justMatchedKeyword = true;
- return "variable";
+ return 'attribute';
+ }
+
+ var tok = jsMode.token(stream, state.jsState);
+ if (state.attributeIsType && tok === 'string') {
+ state.scriptType = stream.current().toString();
+ }
+ if (state.attrsNest.length === 0 && (tok === 'string' || tok === 'variable' || tok === 'keyword')) {
+ try {
+ Function('', 'var x ' + state.attrValue.replace(/,\s*$/, '').replace(/^!/, ''));
+ state.inAttributeName = true;
+ state.attrValue = '';
+ stream.backUp(stream.current().length);
+ return attrsContinued(stream, state);
+ } catch (ex) {
+ //not the end of an attribute
}
- } else if (stream.sol() && stream.match(keyword_regex1)) {
- state.justMatchedKeyword = true;
- stream.eatSpace();
- return "keyword";
- } else if (stream.sol() && (stream.match(html_regex1) || stream.match(html_regex2))) {
- state.justMatchedKeyword = true;
- return "variable";
- } else if (stream.eatSpace()) {
- state.justMatchedKeyword = false;
- if (stream.match(keyword_regex3) && stream.eatSpace()) {
- state.justMatchedKeyword = true;
- return "keyword";
+ }
+ state.attrValue += stream.current();
+ return tok || true;
+ }
+ }
+
+ function attributesBlock(stream, state) {
+ if (stream.match(/^&attributes\b/)) {
+ state.javaScriptArguments = true;
+ state.javaScriptArgumentsDepth = 0;
+ return 'keyword';
+ }
+ }
+
+ function indent(stream) {
+ if (stream.sol() && stream.eatSpace()) {
+ return 'indent';
+ }
+ }
+
+ function comment(stream, state) {
+ if (stream.match(/^ *\/\/(-)?([^\n]*)/)) {
+ state.indentOf = stream.indentation();
+ state.indentToken = 'comment';
+ return 'comment';
+ }
+ }
+
+ function colon(stream) {
+ if (stream.match(/^: */)) {
+ return 'colon';
+ }
+ }
+
+ function text(stream, state) {
+ if (stream.match(/^(?:\| ?| )([^\n]+)/)) {
+ return 'string';
+ }
+ if (stream.match(/^(<[^\n]*)/, false)) {
+ // html string
+ setInnerMode(stream, state, 'htmlmixed');
+ state.innerModeForLine = true;
+ return innerMode(stream, state, true);
+ }
+ }
+
+ function dot(stream, state) {
+ if (stream.eat('.')) {
+ var innerMode = null;
+ if (state.lastTag === 'script' && state.scriptType.toLowerCase().indexOf('javascript') != -1) {
+ innerMode = state.scriptType.toLowerCase().replace(/"|'/g, '');
+ } else if (state.lastTag === 'style') {
+ innerMode = 'css';
+ }
+ setInnerMode(stream, state, innerMode);
+ return 'dot';
+ }
+ }
+
+ function fail(stream) {
+ stream.next();
+ return null;
+ }
+
+
+ function setInnerMode(stream, state, mode) {
+ mode = CodeMirror.mimeModes[mode] || mode;
+ mode = config.innerModes ? config.innerModes(mode) || mode : mode;
+ mode = CodeMirror.mimeModes[mode] || mode;
+ mode = CodeMirror.getMode(config, mode);
+ state.indentOf = stream.indentation();
+
+ if (mode && mode.name !== 'null') {
+ state.innerMode = mode;
+ } else {
+ state.indentToken = 'string';
+ }
+ }
+ function innerMode(stream, state, force) {
+ if (stream.indentation() > state.indentOf || (state.innerModeForLine && !stream.sol()) || force) {
+ if (state.innerMode) {
+ if (!state.innerState) {
+ state.innerState = state.innerMode.startState ? state.innerMode.startState(stream.indentation()) : {};
}
- } else if (stream.match(symbol_regex1)) {
- state.justMatchedKeyword = false;
- return "atom";
- } else if (stream.match(open_paren_regex)) {
- state.afterParen = true;
- state.justMatchedKeyword = true;
- return "def";
- } else if (stream.match(close_paren_regex)) {
- state.afterParen = false;
- state.justMatchedKeyword = true;
- return "def";
- } else if (stream.match(keyword_regex2)) {
- state.justMatchedKeyword = true;
- return "keyword";
- } else if (stream.eatSpace()) {
- state.justMatchedKeyword = false;
+ return stream.hideFirstChars(state.indentOf + 2, function () {
+ return state.innerMode.token(stream, state.innerState) || true;
+ });
} else {
- stream.next();
- if (state.justMatchedKeyword) {
- return "property";
- } else if (state.afterParen) {
- return "property";
- }
+ stream.skipToEnd();
+ return state.indentToken;
}
- return null;
+ } else if (stream.sol()) {
+ state.indentOf = Infinity;
+ state.indentToken = null;
+ state.innerMode = null;
+ state.innerState = null;
+ }
+ }
+ function restOfLine(stream, state) {
+ if (stream.sol()) {
+ // if restOfLine was set at end of line, ignore it
+ state.restOfLine = '';
}
+ if (state.restOfLine) {
+ stream.skipToEnd();
+ var tok = state.restOfLine;
+ state.restOfLine = '';
+ return tok;
+ }
+ }
+
+
+ function startState() {
+ return new State();
+ }
+ function copyState(state) {
+ return state.copy();
+ }
+ /**
+ * Get the next token in the stream
+ *
+ * @param {Stream} stream
+ * @param {State} state
+ */
+ function nextToken(stream, state) {
+ var tok = innerMode(stream, state)
+ || restOfLine(stream, state)
+ || interpolationContinued(stream, state)
+ || includeFilteredContinued(stream, state)
+ || eachContinued(stream, state)
+ || attrsContinued(stream, state)
+ || javaScript(stream, state)
+ || javaScriptArguments(stream, state)
+ || callArguments(stream, state)
+
+ || yieldStatement(stream, state)
+ || doctype(stream, state)
+ || interpolation(stream, state)
+ || caseStatement(stream, state)
+ || when(stream, state)
+ || defaultStatement(stream, state)
+ || extendsStatement(stream, state)
+ || append(stream, state)
+ || prepend(stream, state)
+ || block(stream, state)
+ || include(stream, state)
+ || includeFiltered(stream, state)
+ || mixin(stream, state)
+ || call(stream, state)
+ || conditional(stream, state)
+ || each(stream, state)
+ || whileStatement(stream, state)
+ || tag(stream, state)
+ || filter(stream, state)
+ || code(stream, state)
+ || id(stream, state)
+ || className(stream, state)
+ || attrs(stream, state)
+ || attributesBlock(stream, state)
+ || indent(stream, state)
+ || text(stream, state)
+ || comment(stream, state)
+ || colon(stream, state)
+ || dot(stream, state)
+ || fail(stream, state);
+
+ return tok === true ? null : tok;
+ }
+ return {
+ startState: startState,
+ copyState: copyState,
+ token: nextToken
};
});
CodeMirror.defineMIME('text/x-jade', 'jade');
+
+});
diff --git a/data/ext/editorText/codemirror/mode/javascript/index.html b/data/ext/editorText/codemirror/mode/javascript/index.html
index faf50363e..592a133d8 100644
--- a/data/ext/editorText/codemirror/mode/javascript/index.html
+++ b/data/ext/editorText/codemirror/mode/javascript/index.html
@@ -12,12 +12,12 @@
<script src="javascript.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -102,6 +102,11 @@ StringStream.prototype = {
<li><code>statementIndent</code> which (given a number) will
determine the amount of indentation to use for statements
continued on a new line.</li>
+ <li><code>wordCharacters</code>, a regexp that indicates which
+ characters should be considered part of an identifier.
+ Defaults to <code>/[\w$]/</code>, which does not handle
+ non-ASCII identifiers. Can be set to something more elaborate
+ to improve Unicode support.</li>
</ul>
</p>
diff --git a/data/ext/editorText/codemirror/mode/javascript/javascript.js b/data/ext/editorText/codemirror/mode/javascript/javascript.js
index bf861b559..b961b8901 100644
--- a/data/ext/editorText/codemirror/mode/javascript/javascript.js
+++ b/data/ext/editorText/codemirror/mode/javascript/javascript.js
@@ -1,11 +1,25 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
// TODO actually recognize syntax of TypeScript constructs
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("javascript", function(config, parserConfig) {
var indentUnit = config.indentUnit;
var statementIndent = parserConfig.statementIndent;
var jsonldMode = parserConfig.jsonld;
var jsonMode = parserConfig.json || jsonldMode;
var isTS = parserConfig.typescript;
+ var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
// Tokenizer
@@ -16,14 +30,14 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var jsKeywords = {
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
- "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C,
+ "return": C, "break": C, "continue": C, "new": kw("new"), "delete": C, "throw": C, "debugger": C,
"var": kw("var"), "const": kw("var"), "let": kw("var"),
- "function": kw("function"), "catch": kw("catch"),
+ "async": kw("async"), "function": kw("function"), "catch": kw("catch"),
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
"in": operator, "typeof": operator, "instanceof": operator,
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
- "this": kw("this"), "module": kw("module"), "class": kw("class"), "super": kw("atom"),
- "yield": C, "export": kw("export"), "import": kw("import"), "extends": C
+ "this": kw("this"), "class": kw("class"), "super": kw("atom"),
+ "await": C, "yield": C, "export": kw("export"), "import": kw("import"), "extends": C
};
// Extend the 'normal' keywords with the TypeScript language extensions
@@ -42,7 +56,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
"static": kw("static"),
// types
- "string": type, "number": type, "bool": type, "any": type
+ "string": type, "number": type, "boolean": type, "any": type
};
for (var attr in tsKeywords) {
@@ -91,6 +105,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
} else if (ch == "0" && stream.eat(/x/i)) {
stream.eatWhile(/[\da-f]/i);
return ret("number", "number");
+ } else if (ch == "0" && stream.eat(/o/i)) {
+ stream.eatWhile(/[0-7]/i);
+ return ret("number", "number");
+ } else if (ch == "0" && stream.eat(/b/i)) {
+ stream.eatWhile(/[01]/i);
+ return ret("number", "number");
} else if (/\d/.test(ch)) {
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
return ret("number", "number");
@@ -102,9 +122,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
stream.skipToEnd();
return ret("comment", "comment");
} else if (state.lastType == "operator" || state.lastType == "keyword c" ||
- state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) {
+ state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) {
readRegexp(stream);
- stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
+ stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
return ret("regexp", "string-2");
} else {
stream.eatWhile(isOperatorChar);
@@ -119,8 +139,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
} else if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return ret("operator", "operator", stream.current());
- } else {
- stream.eatWhile(/[\w\$_]/);
+ } else if (wordRE.test(ch)) {
+ stream.eatWhile(wordRE);
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
ret("variable", "variable", word);
@@ -189,8 +209,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (--depth == 0) break;
} else if (bracket >= 3 && bracket < 6) {
++depth;
- } else if (/[$\w]/.test(ch)) {
+ } else if (wordRE.test(ch)) {
sawSomething = true;
+ } else if (/["'\/]/.test(ch)) {
+ return;
} else if (sawSomething && !depth) {
++pos;
break;
@@ -225,7 +247,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var cc = state.cc;
// Communicate our context to the combinators.
// (Less wasteful than consing up a hundred closures on every call.)
- cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
+ cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
if (!state.lexical.hasOwnProperty("align"))
state.lexical.align = true;
@@ -259,8 +281,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
return false;
}
var state = cx.state;
+ cx.marked = "def";
if (state.context) {
- cx.marked = "def";
if (inList(state.localVars)) return;
state.localVars = {name: varname, next: state.localVars};
} else {
@@ -285,6 +307,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var result = function() {
var state = cx.state, indent = state.indented;
if (state.lexical.type == "stat") indent = state.lexical.indented;
+ else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
+ indent = outer.indented;
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
};
result.lex = true;
@@ -301,11 +325,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
poplex.lex = true;
function expect(wanted) {
- return function(type) {
+ function exp(type) {
if (type == wanted) return cont();
else if (wanted == ";") return pass();
- else return cont(arguments.callee);
+ else return cont(exp);
};
+ return exp;
}
function statement(type, value) {
@@ -328,10 +353,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "default") return cont(expect(":"));
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
statement, poplex, popcontext);
- if (type == "module") return cont(pushlex("form"), pushcontext, afterModule, popcontext, poplex);
- if (type == "class") return cont(pushlex("form"), className, objlit, poplex);
- if (type == "export") return cont(pushlex("form"), afterExport, poplex);
- if (type == "import") return cont(pushlex("form"), afterImport, poplex);
+ if (type == "class") return cont(pushlex("form"), className, poplex);
+ if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
+ if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
return pass(pushlex("stat"), expression, expect(";"), poplex);
}
function expression(type) {
@@ -349,13 +373,15 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
+ if (type == "async") return cont(expression);
if (type == "function") return cont(functiondef, maybeop);
if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
- if (type == "quasi") { return pass(quasi, maybeop); }
+ if (type == "quasi") return pass(quasi, maybeop);
+ if (type == "new") return cont(maybeTarget(noComma));
return cont();
}
function maybeexpression(type) {
@@ -374,7 +400,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
function maybeoperatorNoComma(type, value, noComma) {
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
var expr = noComma == false ? expression : expressionNoComma;
- if (value == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
+ if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
if (type == "operator") {
if (/\+\+|--/.test(value)) return cont(me);
if (value == "?") return cont(expression, expect(":"), expr);
@@ -400,13 +426,23 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
}
function arrowBody(type) {
findFatArrow(cx.stream, cx.state);
- if (type == "{") return pass(statement);
- return pass(expression);
+ return pass(type == "{" ? statement : expression);
}
function arrowBodyNoComma(type) {
findFatArrow(cx.stream, cx.state);
- if (type == "{") return pass(statement);
- return pass(expressionNoComma);
+ return pass(type == "{" ? statement : expressionNoComma);
+ }
+ function maybeTarget(noComma) {
+ return function(type) {
+ if (type == ".") return cont(noComma ? targetNoComma : target);
+ else return pass(noComma ? expressionNoComma : expression);
+ };
+ }
+ function target(_, value) {
+ if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
+ }
+ function targetNoComma(_, value) {
+ if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
}
function maybelabel(type) {
if (type == ":") return cont(poplex, statement);
@@ -416,15 +452,20 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "variable") {cx.marked = "property"; return cont();}
}
function objprop(type, value) {
- if (type == "variable") {
+ if (type == "async") {
+ return cont(objprop);
+ } else if (type == "variable" || cx.style == "keyword") {
cx.marked = "property";
if (value == "get" || value == "set") return cont(getterSetter);
+ return cont(afterprop);
} else if (type == "number" || type == "string") {
- cx.marked = jsonldMode ? "property" : (type + " property");
+ cx.marked = jsonldMode ? "property" : (cx.style + " property");
+ return cont(afterprop);
+ } else if (type == "jsonld-keyword") {
+ return cont(afterprop);
} else if (type == "[") {
return cont(expression, expect("]"), afterprop);
}
- if (atomicTypes.hasOwnProperty(type)) return cont(afterprop);
}
function getterSetter(type) {
if (type != "variable") return pass(afterprop);
@@ -462,14 +503,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
function maybetype(type) {
if (isTS && type == ":") return cont(typedef);
}
+ function maybedefault(_, value) {
+ if (value == "=") return cont(expressionNoComma);
+ }
function typedef(type) {
- if (type == "variable"){cx.marked = "variable-3"; return cont();}
+ if (type == "variable") {cx.marked = "variable-3"; return cont();}
}
function vardef() {
return pass(pattern, maybetype, maybeAssign, vardefCont);
}
function pattern(type, value) {
if (type == "variable") { register(value); return cont(); }
+ if (type == "spread") return cont(pattern);
if (type == "[") return contCommasep(pattern, "]");
if (type == "{") return contCommasep(proppattern, "}");
}
@@ -479,6 +524,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
return cont(maybeAssign);
}
if (type == "variable") cx.marked = "property";
+ if (type == "spread") return cont(pattern);
return cont(expect(":"), pattern, maybeAssign);
}
function maybeAssign(_type, value) {
@@ -518,20 +564,36 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
}
function funarg(type) {
if (type == "spread") return cont(funarg);
- return pass(pattern, maybetype);
+ return pass(pattern, maybetype, maybedefault);
}
function className(type, value) {
if (type == "variable") {register(value); return cont(classNameAfter);}
}
- function classNameAfter(_type, value) {
- if (value == "extends") return cont(expression);
+ function classNameAfter(type, value) {
+ if (value == "extends") return cont(expression, classNameAfter);
+ if (type == "{") return cont(pushlex("}"), classBody, poplex);
}
- function objlit(type) {
- if (type == "{") return contCommasep(objprop, "}");
+ function classBody(type, value) {
+ if (type == "variable" || cx.style == "keyword") {
+ if (value == "static") {
+ cx.marked = "keyword";
+ return cont(classBody);
+ }
+ cx.marked = "property";
+ if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
+ return cont(functiondef, classBody);
+ }
+ if (value == "*") {
+ cx.marked = "keyword";
+ return cont(classBody);
+ }
+ if (type == ";") return cont(classBody);
+ if (type == "}") return cont();
}
- function afterModule(type, value) {
- if (type == "string") return cont(statement);
- if (type == "variable") { register(value); return cont(maybeFrom); }
+ function classGetterSetter(type) {
+ if (type != "variable") return pass();
+ cx.marked = "property";
+ return cont();
}
function afterExport(_type, value) {
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
@@ -545,7 +607,11 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
function importSpec(type, value) {
if (type == "{") return contCommasep(importSpec, "}");
if (type == "variable") register(value);
- return cont();
+ if (value == "*") cx.marked = "keyword";
+ return cont(maybeAs);
+ }
+ function maybeAs(_type, value) {
+ if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
}
function maybeFrom(_type, value) {
if (value == "from") { cx.marked = "keyword"; return cont(expression); }
@@ -556,7 +622,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
}
function maybeArrayComprehension(type) {
if (type == "for") return pass(comprehension, expect("]"));
- if (type == ",") return cont(commasep(expressionNoComma, "]"));
+ if (type == ",") return cont(commasep(maybeexpressionNoComma, "]"));
return pass(commasep(expressionNoComma, "]"));
}
function comprehension(type) {
@@ -564,6 +630,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "if") return cont(expression, comprehension);
}
+ function isContinuedStatement(state, textAfter) {
+ return state.lastType == "operator" || state.lastType == "," ||
+ isOperatorChar.test(textAfter.charAt(0)) ||
+ /[,.]/.test(textAfter.charAt(0));
+ }
+
// Interface
return {
@@ -615,18 +687,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
else if (type == "form" && firstChar == "{") return lexical.indented;
else if (type == "form") return lexical.indented + indentUnit;
else if (type == "stat")
- return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? statementIndent || indentUnit : 0);
+ return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
else return lexical.indented + (closing ? 0 : indentUnit);
},
- electricChars: ":{}",
+ electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
blockCommentStart: jsonMode ? null : "/*",
blockCommentEnd: jsonMode ? null : "*/",
lineComment: jsonMode ? null : "//",
fold: "brace",
+ closeBrackets: "()[]{}''\"\"``",
helperType: jsonMode ? "json" : "javascript",
jsonldMode: jsonldMode,
@@ -634,12 +707,17 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
};
});
+CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
+
CodeMirror.defineMIME("text/javascript", "javascript");
CodeMirror.defineMIME("text/ecmascript", "javascript");
CodeMirror.defineMIME("application/javascript", "javascript");
+CodeMirror.defineMIME("application/x-javascript", "javascript");
CodeMirror.defineMIME("application/ecmascript", "javascript");
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
+
+});
diff --git a/data/ext/editorText/codemirror/mode/javascript/json-ld.html b/data/ext/editorText/codemirror/mode/javascript/json-ld.html
index 256bb0f62..3a37f0bce 100644
--- a/data/ext/editorText/codemirror/mode/javascript/json-ld.html
+++ b/data/ext/editorText/codemirror/mode/javascript/json-ld.html
@@ -12,12 +12,12 @@
<script src="javascript.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id="nav">
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"/></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"/></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/javascript/test.js b/data/ext/editorText/codemirror/mode/javascript/test.js
index 782f0457f..252e064dc 100644
--- a/data/ext/editorText/codemirror/mode/javascript/test.js
+++ b/data/ext/editorText/codemirror/mode/javascript/test.js
@@ -1,9 +1,12 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "javascript");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
MT("locals",
- "[keyword function] [variable foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }");
+ "[keyword function] [def foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }");
MT("comma-and-binop",
"[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }");
@@ -14,55 +17,62 @@
" [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];",
"})();");
+ MT("class_body",
+ "[keyword class] [def Foo] {",
+ " [property constructor]() {}",
+ " [property sayName]() {",
+ " [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];",
+ " }",
+ "}");
+
MT("class",
- "[keyword class] [variable Point] [keyword extends] [variable SuperThing] {",
- " [[ [string-2 /expr/] ]]: [number 24],",
+ "[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
+ " [property get] [property prop]() { [keyword return] [number 24]; }",
" [property constructor]([def x], [def y]) {",
" [keyword super]([string 'something']);",
" [keyword this].[property x] [operator =] [variable-2 x];",
" }",
"}");
- MT("module",
- "[keyword module] [string 'foo'] {",
- " [keyword export] [keyword let] [def x] [operator =] [number 42];",
- " [keyword export] [keyword *] [keyword from] [string 'somewhere'];",
- "}");
-
MT("import",
- "[keyword function] [variable foo]() {",
+ "[keyword function] [def foo]() {",
" [keyword import] [def $] [keyword from] [string 'jquery'];",
- " [keyword module] [def crypto] [keyword from] [string 'crypto'];",
" [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];",
"}");
MT("const",
- "[keyword function] [variable f]() {",
+ "[keyword function] [def f]() {",
" [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];",
"}");
MT("for/of",
- "[keyword for]([keyword let] [variable of] [keyword of] [variable something]) {}");
+ "[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}");
MT("generator",
- "[keyword function*] [variable repeat]([def n]) {",
+ "[keyword function*] [def repeat]([def n]) {",
" [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])",
" [keyword yield] [variable-2 i];",
"}");
+ MT("quotedStringAddition",
+ "[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];");
+
+ MT("quotedFatArrow",
+ "[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];");
+
MT("fatArrow",
"[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);",
"[variable a];", // No longer in scope
- "[keyword let] [variable f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
+ "[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
"[variable c];");
MT("spread",
- "[keyword function] [variable f]([def a], [meta ...][def b]) {",
+ "[keyword function] [def f]([def a], [meta ...][def b]) {",
" [variable something]([variable-2 a], [meta ...][variable-2 b]);",
"}");
MT("comprehension",
- "[keyword function] [variable f]() {",
+ "[keyword function] [def f]() {",
" [[([variable x] [operator +] [number 1]) [keyword for] ([keyword var] [def x] [keyword in] [variable y]) [keyword if] [variable pred]([variable-2 x]) ]];",
" ([variable u] [keyword for] ([keyword var] [def u] [keyword of] [variable generateValues]()) [keyword if] ([variable-2 u].[property color] [operator ===] [string 'blue']));",
"}");
@@ -74,7 +84,7 @@
"[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
MT("indent_statement",
- "[keyword var] [variable x] [operator =] [number 10]",
+ "[keyword var] [def x] [operator =] [number 10]",
"[variable x] [operator +=] [variable y] [operator +]",
" [atom Infinity]",
"[keyword debugger];");
@@ -95,14 +105,14 @@
"}");
MT("indent_for",
- "[keyword for] ([keyword var] [variable i] [operator =] [number 0];",
+ "[keyword for] ([keyword var] [def i] [operator =] [number 0];",
" [variable i] [operator <] [number 100];",
" [variable i][operator ++])",
" [variable doSomething]([variable i]);",
"[keyword debugger];");
MT("indent_c_style",
- "[keyword function] [variable foo]()",
+ "[keyword function] [def foo]()",
"{",
" [keyword debugger];",
"}");
@@ -117,6 +127,12 @@
" [keyword else]",
" [number 3];");
+ MT("indent_funarg",
+ "[variable foo]([number 10000],",
+ " [keyword function]([def a]) {",
+ " [keyword debugger];",
+ "};");
+
MT("indent_below_if",
"[keyword for] (;;)",
" [keyword if] ([variable foo])",
@@ -124,12 +140,32 @@
"[number 2];");
MT("multilinestring",
- "[keyword var] [variable x] [operator =] [string 'foo\\]",
+ "[keyword var] [def x] [operator =] [string 'foo\\]",
"[string bar'];");
MT("scary_regexp",
"[string-2 /foo[[/]]bar/];");
+ MT("indent_strange_array",
+ "[keyword var] [def x] [operator =] [[",
+ " [number 1],,",
+ " [number 2],",
+ "]];",
+ "[number 10];");
+
+ MT("param_default",
+ "[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
+ " [keyword return] [variable-2 x];",
+ "}");
+
+ MT("new_target",
+ "[keyword function] [def F]([def target]) {",
+ " [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {",
+ " [keyword return] [keyword new]",
+ " .[keyword target];",
+ " }",
+ "}");
+
var jsonld_mode = CodeMirror.getMode(
{indentUnit: 2},
{name: "javascript", jsonld: true}
diff --git a/data/ext/editorText/codemirror/mode/javascript/typescript.html b/data/ext/editorText/codemirror/mode/javascript/typescript.html
index 9cc5f4932..2cfc5381f 100644
--- a/data/ext/editorText/codemirror/mode/javascript/typescript.html
+++ b/data/ext/editorText/codemirror/mode/javascript/typescript.html
@@ -9,12 +9,12 @@
<script src="javascript.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/jinja2/index.html b/data/ext/editorText/codemirror/mode/jinja2/index.html
index c99daf6c4..5a70e9153 100644
--- a/data/ext/editorText/codemirror/mode/jinja2/index.html
+++ b/data/ext/editorText/codemirror/mode/jinja2/index.html
@@ -9,12 +9,12 @@
<script src="jinja2.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/jinja2/jinja2.js b/data/ext/editorText/codemirror/mode/jinja2/jinja2.js
index 32f990273..ed195581c 100644
--- a/data/ext/editorText/codemirror/mode/jinja2/jinja2.js
+++ b/data/ext/editorText/codemirror/mode/jinja2/jinja2.js
@@ -1,4 +1,17 @@
-CodeMirror.defineMode("jinja2", function() {
+// 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";
+
+ CodeMirror.defineMode("jinja2", function() {
var keywords = ["and", "as", "block", "endblock", "by", "cycle", "debug", "else", "elif",
"extends", "filter", "endfilter", "firstof", "for",
"endfor", "if", "endif", "ifchanged", "endifchanged",
@@ -118,11 +131,12 @@ CodeMirror.defineMode("jinja2", function() {
};
return {
- startState: function () {
- return {tokenize: tokenBase};
- },
- token: function (stream, state) {
- return state.tokenize(stream, state);
- }
+ startState: function () {
+ return {tokenize: tokenBase};
+ },
+ token: function (stream, state) {
+ return state.tokenize(stream, state);
+ }
};
+ });
});
diff --git a/data/ext/editorText/codemirror/mode/julia/index.html b/data/ext/editorText/codemirror/mode/julia/index.html
index 945e1a91f..e1492c210 100644
--- a/data/ext/editorText/codemirror/mode/julia/index.html
+++ b/data/ext/editorText/codemirror/mode/julia/index.html
@@ -9,12 +9,12 @@
<script src="julia.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -51,6 +51,14 @@ a
as123
function_name!
+#unicode identifiers
+# a = x\ddot
+a⃗ = ẍ
+# a = v\dot
+a⃗ = v̇
+#F\vec = m \cdotp a\vec
+F⃗ = m·a⃗
+
#literal identifier multiples
3x
4[1, 2, 3]
@@ -60,6 +68,7 @@ x=[1, 2, 3]
x[end-1]
x={"julia"=>"language of technical computing"}
+
#exception handling
try
f()
diff --git a/data/ext/editorText/codemirror/mode/julia/julia.js b/data/ext/editorText/codemirror/mode/julia/julia.js
index cc17eb015..d0a74cef5 100644
--- a/data/ext/editorText/codemirror/mode/julia/julia.js
+++ b/data/ext/editorText/codemirror/mode/julia/julia.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("julia", function(_conf, parserConf) {
var ERRORCLASS = 'error';
@@ -7,7 +20,7 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b/;
var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
- var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*!*/;
+ var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*!*/;
var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"];
var blockClosers = ["end", "else", "elseif", "catch", "finally"];
var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype', 'ccall'];
@@ -21,7 +34,6 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
var closers = wordRegexp(blockClosers);
var macro = /^@[_A-Za-z][_A-Za-z0-9]*/;
var symbol = /^:[_A-Za-z][_A-Za-z0-9]*/;
- var indentInfo = null;
function in_array(state) {
var ch = cur_scope(state);
@@ -234,7 +246,6 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
}
function tokenLexer(stream, state) {
- indentInfo = null;
var style = state.tokenize(stream, state);
var current = stream.current();
@@ -284,3 +295,5 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
CodeMirror.defineMIME("text/x-julia", "julia");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/less/index.html b/data/ext/editorText/codemirror/mode/less/index.html
deleted file mode 100644
index 7239143c8..000000000
--- a/data/ext/editorText/codemirror/mode/less/index.html
+++ /dev/null
@@ -1,753 +0,0 @@
-<!doctype html>
-
-<title>CodeMirror: LESS mode</title>
-<meta charset="utf-8"/>
-<link rel=stylesheet href="../../doc/docs.css">
-
-<link rel="stylesheet" href="../../lib/codemirror.css">
-<link rel="stylesheet" href="../../theme/lesser-dark.css">
-<script src="../../lib/codemirror.js"></script>
-<script src="../../addon/edit/matchbrackets.js"></script>
-<script src="less.js"></script>
-<style>.CodeMirror {background: #f8f8f8; border: 1px solid #ddd; font-size:12px; height: 400px}</style>
-<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
-
- <ul>
- <li><a href="../../index.html">Home</a>
- <li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
- </ul>
- <ul>
- <li><a href="../index.html">Language modes</a>
- <li><a class=active href="#">LESS</a>
- </ul>
-</div>
-
-<article>
-<h2>LESS mode</h2>
-<form><textarea id="code" name="code">@media screen and (device-aspect-ratio: 16/9) { … }
-@media screen and (device-aspect-ratio: 32/18) { … }
-@media screen and (device-aspect-ratio: 1280/720) { … }
-@media screen and (device-aspect-ratio: 2560/1440) { … }
-
-html:lang(fr-be)
-html:lang(de)
-:lang(fr-be) > q
-:lang(de) > q
-
-tr:nth-child(2n+1) /* represents every odd row of an HTML table */
-tr:nth-child(odd) /* same */
-tr:nth-child(2n+0) /* represents every even row of an HTML table */
-tr:nth-child(even) /* same */
-
-/* Alternate paragraph colours in CSS */
-p:nth-child(4n+1) { color: navy; }
-p:nth-child(4n+2) { color: green; }
-p:nth-child(4n+3) { color: maroon; }
-p:nth-child(4n+4) { color: purple; }
-
-:nth-child(10n-1) /* represents the 9th, 19th, 29th, etc, element */
-:nth-child(10n+9) /* Same */
-:nth-child(10n+-1) /* Syntactically invalid, and would be ignored */
-
-:nth-child( 3n + 1 )
-:nth-child( +3n - 2 )
-:nth-child( -n+ 6)
-:nth-child( +6 )
-
-html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */
-
-img:nth-of-type(2n+1) { float: right; }
-img:nth-of-type(2n) { float: left; }
-
-body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
-body > h2:not(:first-of-type):not(:last-of-type)
-
-html|*:not(:link):not(:visited)
-*|*:not(:hover)
-p::first-line { text-transform: uppercase }
-
-p { color: red; font-size: 12pt }
-p::first-letter { color: green; font-size: 200% }
-p::first-line { color: blue }
-
-p { line-height: 1.1 }
-p::first-letter { font-size: 3em; font-weight: normal }
-span { font-weight: bold }
-
-* /* a=0 b=0 c=0 -> specificity = 0 */
-LI /* a=0 b=0 c=1 -> specificity = 1 */
-UL LI /* a=0 b=0 c=2 -> specificity = 2 */
-UL OL+LI /* a=0 b=0 c=3 -> specificity = 3 */
-H1 + *[REL=up] /* a=0 b=1 c=1 -> specificity = 11 */
-UL OL LI.red /* a=0 b=1 c=3 -> specificity = 13 */
-LI.red.level /* a=0 b=2 c=1 -> specificity = 21 */
-#x34y /* a=1 b=0 c=0 -> specificity = 100 */
-#s12:not(FOO) /* a=1 b=0 c=1 -> specificity = 101 */
-
-@namespace foo url(http://www.example.com);
-foo|h1 { color: blue } /* first rule */
-foo|* { color: yellow } /* second rule */
-|h1 { color: red } /* ...*/
-*|h1 { color: green }
-h1 { color: green }
-
-span[hello="Ocean"][goodbye="Land"]
-
-a[rel~="copyright"] { ... }
-a[href="http://www.w3.org/"] { ... }
-
-DIALOGUE[character=romeo]
-DIALOGUE[character=juliet]
-
-[att^=val]
-[att$=val]
-[att*=val]
-
-@namespace foo "http://www.example.com";
-[foo|att=val] { color: blue }
-[*|att] { color: yellow }
-[|att] { color: green }
-[att] { color: green }
-
-
-*:target { color : red }
-*:target::before { content : url(target.png) }
-
-E[foo]{
- padding:65px;
-}
-E[foo] ~ F{
- padding:65px;
-}
-E#myid{
- padding:65px;
-}
-input[type="search"]::-webkit-search-decoration,
-input[type="search"]::-webkit-search-cancel-button {
- -webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5
-}
-button::-moz-focus-inner,
-input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
- padding: 0;
- border: 0;
-}
-.btn {
- // reset here as of 2.0.3 due to Recess property order
- border-color: #ccc;
- border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
-}
-fieldset span button, fieldset span input[type="file"] {
- font-size:12px;
- font-family:Arial, Helvetica, sans-serif;
-}
-.el tr:nth-child(even):last-child td:first-child{
- -moz-border-radius-bottomleft:3px;
- -webkit-border-bottom-left-radius:3px;
- border-bottom-left-radius:3px;
-}
-
-/* Some LESS code */
-
-button {
- width: 32px;
- height: 32px;
- border: 0;
- margin: 4px;
- cursor: pointer;
-}
-button.icon-plus { background: url(http://dahlström.net/tmp/sharp-icons/svg-icon-target.svg#plus) no-repeat; }
-button.icon-chart { background: url(http://dahlström.net/tmp/sharp-icons/svg-icon-target.svg#chart) no-repeat; }
-
-button:hover { background-color: #999; }
-button:active { background-color: #666; }
-
-@test_a: #eeeQQQ;//this is not a valid hex value and thus parsed as an element id
-@test_b: #eeeFFF //this is a valid hex value but the declaration doesn't end with a semicolon and thus parsed as an element id
-
-#eee aaa .box
-{
- #test bbb {
- width: 500px;
- height: 250px;
- background-image: url(dir/output/sheep.png), url( betweengrassandsky.png );
- background-position: center bottom, left top;
- background-repeat: no-repeat;
- }
-}
-
-@base: #f938ab;
-
-.box-shadow(@style, @c) when (iscolor(@c)) {
- box-shadow: @style @c;
- -webkit-box-shadow: @style @c;
- -moz-box-shadow: @style @c;
-}
-.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
- .box-shadow(@style, rgba(0, 0, 0, @alpha));
-}
-
-@color: #4D926F;
-
-#header {
- color: @color;
- color: #000000;
-}
-h2 {
- color: @color;
-}
-
-.rounded-corners (@radius: 5px) {
- border-radius: @radius;
- -webkit-border-radius: @radius;
- -moz-border-radius: @radius;
-}
-
-#header {
- .rounded-corners;
-}
-#footer {
- .rounded-corners(10px);
-}
-
-.box-shadow (@x: 0, @y: 0, @blur: 1px, @alpha) {
- @val: @x @y @blur rgba(0, 0, 0, @alpha);
-
- box-shadow: @val;
- -webkit-box-shadow: @val;
- -moz-box-shadow: @val;
-}
-.box { @base: #f938ab;
- color: saturate(@base, 5%);
- border-color: lighten(@base, 30%);
- div { .box-shadow(0, 0, 5px, 0.4) }
-}
-
-@import url("something.css");
-
-@light-blue: hsl(190, 50%, 65%);
-@light-yellow: desaturate(#fefec8, 10%);
-@dark-yellow: desaturate(darken(@light-yellow, 10%), 40%);
-@darkest: hsl(20, 0%, 15%);
-@dark: hsl(190, 20%, 30%);
-@medium: hsl(10, 60%, 30%);
-@light: hsl(90, 40%, 20%);
-@lightest: hsl(90, 20%, 90%);
-@highlight: hsl(80, 50%, 90%);
-@blue: hsl(210, 60%, 20%);
-@alpha-blue: hsla(210, 60%, 40%, 0.5);
-
-.box-shadow (@x, @y, @blur, @alpha) {
- @value: @x @y @blur rgba(0, 0, 0, @alpha);
- box-shadow: @value;
- -moz-box-shadow: @value;
- -webkit-box-shadow: @value;
-}
-.border-radius (@radius) {
- border-radius: @radius;
- -moz-border-radius: @radius;
- -webkit-border-radius: @radius;
-}
-
-.border-radius (@radius, bottom) {
- border-top-right-radius: 0;
- border-top-left-radius: 0;
- -moz-border-top-right-radius: 0;
- -moz-border-top-left-radius: 0;
- -webkit-border-top-left-radius: 0;
- -webkit-border-top-right-radius: 0;
-}
-.border-radius (@radius, right) {
- border-bottom-left-radius: 0;
- border-top-left-radius: 0;
- -moz-border-bottom-left-radius: 0;
- -moz-border-top-left-radius: 0;
- -webkit-border-bottom-left-radius: 0;
- -webkit-border-top-left-radius: 0;
-}
-.box-shadow-inset (@x, @y, @blur, @color) {
- box-shadow: @x @y @blur @color inset;
- -moz-box-shadow: @x @y @blur @color inset;
- -webkit-box-shadow: @x @y @blur @color inset;
-}
-.code () {
- font-family: 'Bitstream Vera Sans Mono',
- 'DejaVu Sans Mono',
- 'Monaco',
- Courier,
- monospace !important;
-}
-.wrap () {
- text-wrap: wrap;
- white-space: pre-wrap; /* css-3 */
- white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
- white-space: -pre-wrap; /* Opera 4-6 */
- white-space: -o-pre-wrap; /* Opera 7 */
- word-wrap: break-word; /* Internet Explorer 5.5+ */
-}
-
-html { margin: 0 }
-body {
- background-color: @darkest;
- margin: 0 auto;
- font-family: Arial, sans-serif;
- font-size: 100%;
- overflow-x: hidden;
-}
-nav, header, footer, section, article {
- display: block;
-}
-a {
- color: #b83000;
-}
-h1 a {
- color: black;
- text-decoration: none;
-}
-a:hover {
- text-decoration: underline;
-}
-h1, h2, h3, h4 {
- margin: 0;
- font-weight: normal;
-}
-ul, li {
- list-style-type: none;
-}
-code { .code; }
-code {
- .string, .regexp { color: @dark }
- .keyword { font-weight: bold }
- .comment { color: rgba(0, 0, 0, 0.5) }
- .number { color: @blue }
- .class, .special { color: rgba(0, 50, 100, 0.8) }
-}
-pre {
- padding: 0 30px;
- .wrap;
-}
-blockquote {
- font-style: italic;
-}
-body > footer {
- text-align: left;
- margin-left: 10px;
- font-style: italic;
- font-size: 18px;
- color: #888;
-}
-
-#logo {
- margin-top: 30px;
- margin-bottom: 30px;
- display: block;
- width: 199px;
- height: 81px;
- background: url(/images/logo.png) no-repeat;
-}
-nav {
- margin-left: 15px;
-}
-nav a, #dropdown li {
- display: inline-block;
- color: white;
- line-height: 42px;
- margin: 0;
- padding: 0px 15px;
- text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.5);
- text-decoration: none;
- border: 2px solid transparent;
- border-width: 0 2px;
- &:hover {
- .dark-red;
- text-decoration: none;
- }
-}
-.dark-red {
- @red: @medium;
- border: 2px solid darken(@red, 25%);
- border-left-color: darken(@red, 15%);
- border-right-color: darken(@red, 15%);
- border-bottom: 0;
- border-top: 0;
- background-color: darken(@red, 10%);
-}
-
-.content {
- margin: 0 auto;
- width: 980px;
-}
-
-#menu {
- position: absolute;
- width: 100%;
- z-index: 3;
- clear: both;
- display: block;
- background-color: @blue;
- height: 42px;
- border-top: 2px solid lighten(@alpha-blue, 20%);
- border-bottom: 2px solid darken(@alpha-blue, 25%);
- .box-shadow(0, 1px, 8px, 0.6);
- -moz-box-shadow: 0 0 0 #000; // Because firefox sucks.
-
- &.docked {
- background-color: hsla(210, 60%, 40%, 0.4);
- }
- &:hover {
- background-color: @blue;
- }
-
- #dropdown {
- margin: 0 0 0 117px;
- padding: 0;
- padding-top: 5px;
- display: none;
- width: 190px;
- border-top: 2px solid @medium;
- color: @highlight;
- border: 2px solid darken(@medium, 25%);
- border-left-color: darken(@medium, 15%);
- border-right-color: darken(@medium, 15%);
- border-top-width: 0;
- background-color: darken(@medium, 10%);
- ul {
- padding: 0px;
- }
- li {
- font-size: 14px;
- display: block;
- text-align: left;
- padding: 0;
- border: 0;
- a {
- display: block;
- padding: 0px 15px;
- text-decoration: none;
- color: white;
- &:hover {
- background-color: darken(@medium, 15%);
- text-decoration: none;
- }
- }
- }
- .border-radius(5px, bottom);
- .box-shadow(0, 6px, 8px, 0.5);
- }
-}
-
-#main {
- margin: 0 auto;
- width: 100%;
- background-color: @light-blue;
- border-top: 8px solid darken(@light-blue, 5%);
-
- #intro {
- background-color: lighten(@light-blue, 25%);
- float: left;
- margin-top: -8px;
- margin-right: 5px;
-
- height: 380px;
- position: relative;
- z-index: 2;
- font-family: 'Droid Serif', 'Georgia';
- width: 395px;
- padding: 45px 20px 23px 30px;
- border: 2px dashed darken(@light-blue, 10%);
- .box-shadow(1px, 0px, 6px, 0.5);
- border-bottom: 0;
- border-top: 0;
- #download { color: transparent; border: 0; float: left; display: inline-block; margin: 15px 0 15px -5px; }
- #download img { display: inline-block}
- #download-info {
- code {
- font-size: 13px;
- }
- color: @blue + #333; display: inline; float: left; margin: 36px 0 0 15px }
- }
- h2 {
- span {
- color: @medium;
- }
- color: @blue;
- margin: 20px 0;
- font-size: 24px;
- line-height: 1.2em;
- }
- h3 {
- color: @blue;
- line-height: 1.4em;
- margin: 30px 0 15px 0;
- font-size: 1em;
- text-shadow: 0px 0px 0px @lightest;
- span { color: @medium }
- }
- #example {
- p {
- font-size: 18px;
- color: @blue;
- font-weight: bold;
- text-shadow: 0px 1px 1px @lightest;
- }
- pre {
- margin: 0;
- text-shadow: 0 -1px 1px @darkest;
- margin-top: 20px;
- background-color: desaturate(@darkest, 8%);
- border: 0;
- width: 450px;
- color: lighten(@lightest, 2%);
- background-repeat: repeat;
- padding: 15px;
- border: 1px dashed @lightest;
- line-height: 15px;
- .box-shadow(0, 0px, 15px, 0.5);
- .code;
- .border-radius(2px);
- code .attribute { color: hsl(40, 50%, 70%) }
- code .variable { color: hsl(120, 10%, 50%) }
- code .element { color: hsl(170, 20%, 50%) }
-
- code .string, .regexp { color: hsl(75, 50%, 65%) }
- code .class { color: hsl(40, 40%, 60%); font-weight: normal }
- code .id { color: hsl(50, 40%, 60%); font-weight: normal }
- code .comment { color: rgba(255, 255, 255, 0.2) }
- code .number, .color { color: hsl(10, 40%, 50%) }
- code .class, code .mixin, .special { color: hsl(190, 20%, 50%) }
- #time { color: #aaa }
- }
- float: right;
- font-size: 12px;
- margin: 0;
- margin-top: 15px;
- padding: 0;
- width: 500px;
- }
-}
-
-
-.page {
- .content {
- width: 870px;
- padding: 45px;
- }
- margin: 0 auto;
- font-family: 'Georgia', serif;
- font-size: 18px;
- line-height: 26px;
- padding: 0 60px;
- code {
- font-size: 16px;
- }
- pre {
- border-width: 1px;
- border-style: dashed;
- padding: 15px;
- margin: 15px 0;
- }
- h1 {
- text-align: left;
- font-size: 40px;
- margin-top: 15px;
- margin-bottom: 35px;
- }
- p + h1 { margin-top: 60px }
- h2, h3 {
- margin: 30px 0 15px 0;
- }
- p + h2, pre + h2, code + h2 {
- border-top: 6px solid rgba(255, 255, 255, 0.1);
- padding-top: 30px;
- }
- h3 {
- margin: 15px 0;
- }
-}
-
-
-#docs {
- @bg: lighten(@light-blue, 5%);
- border-top: 2px solid lighten(@bg, 5%);
- color: @blue;
- background-color: @light-blue;
- .box-shadow(0, -2px, 5px, 0.2);
-
- h1 {
- font-family: 'Droid Serif', 'Georgia', serif;
- padding-top: 30px;
- padding-left: 45px;
- font-size: 44px;
- text-align: left;
- margin: 30px 0 !important;
- text-shadow: 0px 1px 1px @lightest;
- font-weight: bold;
- }
- .content {
- clear: both;
- border-color: transparent;
- background-color: lighten(@light-blue, 25%);
- .box-shadow(0, 5px, 5px, 0.4);
- }
- pre {
- @background: lighten(@bg, 30%);
- color: lighten(@blue, 10%);
- background-color: @background;
- border-color: lighten(@light-blue, 25%);
- border-width: 2px;
- code .attribute { color: hsl(40, 50%, 30%) }
- code .variable { color: hsl(120, 10%, 30%) }
- code .element { color: hsl(170, 20%, 30%) }
-
- code .string, .regexp { color: hsl(75, 50%, 35%) }
- code .class { color: hsl(40, 40%, 30%); font-weight: normal }
- code .id { color: hsl(50, 40%, 30%); font-weight: normal }
- code .comment { color: rgba(0, 0, 0, 0.4) }
- code .number, .color { color: hsl(10, 40%, 30%) }
- code .class, code .mixin, .special { color: hsl(190, 20%, 30%) }
- }
- pre code { font-size: 15px }
- p + h2, pre + h2, code + h2 { border-top-color: rgba(0, 0, 0, 0.1) }
-}
-
-td {
- padding-right: 30px;
-}
-#synopsis {
- .box-shadow(0, 5px, 5px, 0.2);
-}
-#synopsis, #about {
- h2 {
- font-size: 30px;
- padding: 10px 0;
- }
- h1 + h2 {
- margin-top: 15px;
- }
- h3 { font-size: 22px }
-
- .code-example {
- border-spacing: 0;
- border-width: 1px;
- border-style: dashed;
- padding: 0;
- pre { border: 0; margin: 0 }
- td {
- border: 0;
- margin: 0;
- background-color: desaturate(darken(@darkest, 5%), 20%);
- vertical-align: top;
- padding: 0;
- }
- tr { padding: 0 }
- }
- .css-output {
- td {
- border-left: 0;
- }
- }
- .less-example {
- //border-right: 1px dotted rgba(255, 255, 255, 0.5) !important;
- }
- .css-output, .less-example {
- width: 390px;
- }
- pre {
- padding: 20px;
- line-height: 20px;
- font-size: 14px;
- }
-}
-#about, #synopsis, #guide {
- a {
- text-decoration: none;
- color: @light-yellow;
- border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
- &:hover {
- text-decoration: none;
- border-bottom: 1px dashed @light-yellow;
- }
- }
- @bg: desaturate(darken(@darkest, 5%), 20%);
- text-shadow: 0 -1px 1px lighten(@bg, 5%);
- color: @highlight;
- background-color: @bg;
- .content {
- background-color: desaturate(@darkest, 20%);
- clear: both;
- .box-shadow(0, 5px, 5px, 0.4);
- }
- h1, h2, h3 {
- color: @dark-yellow;
- }
- pre {
- code .attribute { color: hsl(40, 50%, 70%) }
- code .variable { color: hsl(120, 10%, 50%) }
- code .element { color: hsl(170, 20%, 50%) }
-
- code .string, .regexp { color: hsl(75, 50%, 65%) }
- code .class { color: hsl(40, 40%, 60%); font-weight: normal }
- code .id { color: hsl(50, 40%, 60%); font-weight: normal }
- code .comment { color: rgba(255, 255, 255, 0.2) }
- code .number, .color { color: hsl(10, 40%, 50%) }
- code .class, code .mixin, .special { color: hsl(190, 20%, 50%) }
- background-color: @bg;
- border-color: darken(@light-yellow, 5%);
- }
- code {
- color: darken(@dark-yellow, 5%);
- .string, .regexp { color: desaturate(@light-blue, 15%) }
- .keyword { color: hsl(40, 40%, 60%); font-weight: normal }
- .comment { color: rgba(255, 255, 255, 0.2) }
- .number { color: lighten(@blue, 10%) }
- .class, .special { color: hsl(190, 20%, 50%) }
- }
-}
-#guide {
- background-color: @darkest;
- .content {
- background-color: transparent;
- }
-
-}
-
-#about {
- background-color: @darkest !important;
- .content {
- background-color: desaturate(lighten(@darkest, 3%), 5%);
- }
-}
-#synopsis {
- background-color: desaturate(lighten(@darkest, 3%), 5%) !important;
- .content {
- background-color: desaturate(lighten(@darkest, 3%), 5%);
- }
- pre {}
-}
-#synopsis, #guide {
- .content {
- .box-shadow(0, 0px, 0px, 0.0);
- }
-}
-#about footer {
- margin-top: 30px;
- padding-top: 30px;
- border-top: 6px solid rgba(0, 0, 0, 0.1);
- text-align: center;
- font-size: 16px;
- color: rgba(255, 255, 255, 0.35);
- #copy { font-size: 12px }
- text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.02);
-}
-</textarea></form>
- <script>
- var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
- theme: "lesser-dark",
- lineNumbers : true,
- matchBrackets : true
- });
- </script>
-
- <p><strong>MIME types defined:</strong> <code>text/x-less</code>, <code>text/css</code> (if not previously defined).</p>
- </article>
diff --git a/data/ext/editorText/codemirror/mode/less/less.js b/data/ext/editorText/codemirror/mode/less/less.js
deleted file mode 100644
index da681ea67..000000000
--- a/data/ext/editorText/codemirror/mode/less/less.js
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- LESS mode - http://www.lesscss.org/
- Ported to CodeMirror by Peter Kroon <[email protected]>
- Report bugs/issues here: https://github.com/marijnh/CodeMirror/issues
- GitHub: @peterkroon
-*/
-
-CodeMirror.defineMode("less", function(config) {
- var indentUnit = config.indentUnit, type;
- function ret(style, tp) {type = tp; return style;}
-
- var selectors = /(^\:root$|^\:nth\-child$|^\:nth\-last\-child$|^\:nth\-of\-type$|^\:nth\-last\-of\-type$|^\:first\-child$|^\:last\-child$|^\:first\-of\-type$|^\:last\-of\-type$|^\:only\-child$|^\:only\-of\-type$|^\:empty$|^\:link|^\:visited$|^\:active$|^\:hover$|^\:focus$|^\:target$|^\:lang$|^\:enabled^\:disabled$|^\:checked$|^\:first\-line$|^\:first\-letter$|^\:before$|^\:after$|^\:not$|^\:required$|^\:invalid$)/;
-
- function tokenBase(stream, state) {
- var ch = stream.next();
-
- if (ch == "@") {stream.eatWhile(/[\w\-]/); return ret("meta", stream.current());}
- else if (ch == "/" && stream.eat("*")) {
- state.tokenize = tokenCComment;
- return tokenCComment(stream, state);
- } else if (ch == "<" && stream.eat("!")) {
- state.tokenize = tokenSGMLComment;
- return tokenSGMLComment(stream, state);
- } else if (ch == "=") ret(null, "compare");
- else if (ch == "|" && stream.eat("=")) return ret(null, "compare");
- else if (ch == "\"" || ch == "'") {
- state.tokenize = tokenString(ch);
- return state.tokenize(stream, state);
- } else if (ch == "/") { // e.g.: .png will not be parsed as a class
- if(stream.eat("/")){
- state.tokenize = tokenSComment;
- return tokenSComment(stream, state);
- } else {
- if(type == "string" || type == "(") return ret("string", "string");
- if(state.stack[state.stack.length-1] !== undefined) return ret(null, ch);
- stream.eatWhile(/[\a-zA-Z0-9\-_.\s]/);
- if( /\/|\)|#/.test(stream.peek() || (stream.eatSpace() && stream.peek() === ")")) || stream.eol() )return ret("string", "string"); // let url(/images/logo.png) without quotes return as string
- }
- } else if (ch == "!") {
- stream.match(/^\s*\w*/);
- return ret("keyword", "important");
- } else if (/\d/.test(ch)) {
- stream.eatWhile(/[\w.%]/);
- return ret("number", "unit");
- } else if (/[,+<>*\/]/.test(ch)) {
- if(stream.peek() == "=" || type == "a")return ret("string", "string");
- if(ch === ",")return ret(null, ch);
- return ret(null, "select-op");
- } else if (/[;{}:\[\]()~\|]/.test(ch)) {
- if(ch == ":"){
- stream.eatWhile(/[a-z\\\-]/);
- if( selectors.test(stream.current()) ){
- return ret("tag", "tag");
- } else if(stream.peek() == ":"){//::-webkit-search-decoration
- stream.next();
- stream.eatWhile(/[a-z\\\-]/);
- if(stream.current().match(/\:\:\-(o|ms|moz|webkit)\-/))return ret("string", "string");
- if( selectors.test(stream.current().substring(1)) )return ret("tag", "tag");
- return ret(null, ch);
- } else {
- return ret(null, ch);
- }
- } else if(ch == "~"){
- if(type == "r")return ret("string", "string");
- } else {
- return ret(null, ch);
- }
- } else if (ch == ".") {
- if(type == "(")return ret("string", "string"); // allow url(../image.png)
- stream.eatWhile(/[\a-zA-Z0-9\-_]/);
- if(stream.peek() === " ")stream.eatSpace();
- if(stream.peek() === ")" || type === ":")return ret("number", "unit");//rgba(0,0,0,.25);
- else if(stream.current().length >1){
- if(state.stack[state.stack.length-1] === "rule" && !stream.match(/^[{,+(]/, false)) return ret("number", "unit");
- }
- return ret("tag", "tag");
- } else if (ch == "#") {
- //we don't eat white-space, we want the hex color and or id only
- stream.eatWhile(/[A-Za-z0-9]/);
- //check if there is a proper hex color length e.g. #eee || #eeeEEE
- if(stream.current().length == 4 || stream.current().length == 7){
- if(stream.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,false) != null){//is there a valid hex color value present in the current stream
- //when not a valid hex value, parse as id
- if(stream.current().substring(1) != stream.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,false))return ret("atom", "tag");
- //eat white-space
- stream.eatSpace();
- //when hex value declaration doesn't end with [;,] but is does with a slash/cc comment treat it as an id, just like the other hex values that don't end with[;,]
- if( /[\/<>.(){!$%^&*_\-\\?=+\|#'~`]/.test(stream.peek()) ){
- if(type === "select-op")return ret("number", "unit"); else return ret("atom", "tag");
- }
- //#time { color: #aaa }
- else if(stream.peek() == "}" )return ret("number", "unit");
- //we have a valid hex color value, parse as id whenever an element/class is defined after the hex(id) value e.g. #eee aaa || #eee .aaa
- else if( /[a-zA-Z\\]/.test(stream.peek()) )return ret("atom", "tag");
- //when a hex value is on the end of a line, parse as id
- else if(stream.eol())return ret("atom", "tag");
- //default
- else return ret("number", "unit");
- } else {//when not a valid hexvalue in the current stream e.g. #footer
- stream.eatWhile(/[\w\\\-]/);
- return ret("atom", stream.current());
- }
- } else {//when not a valid hexvalue length
- stream.eatWhile(/[\w\\\-]/);
- if(state.stack[state.stack.length-1] === "rule")return ret("atom", stream.current());return ret("atom", stream.current());
- return ret("atom", "tag");
- }
- } else if (ch == "&") {
- stream.eatWhile(/[\w\-]/);
- return ret(null, ch);
- } else {
- stream.eatWhile(/[\w\\\-_%.{]/);
- if(stream.current().match(/\\/) !== null){
- if(stream.current().charAt(stream.current().length-1) === "\\"){
- stream.eat(/\'|\"|\)|\(/);
- while(stream.eatWhile(/[\w\\\-_%.{]/)){
- stream.eat(/\'|\"|\)|\(/);
- }
- return ret("string", stream.current());
- }
- } //else if(type === "tag")return ret("tag", "tag");
- else if(type == "string"){
- if(state.stack[state.stack.length-1] === "{" && stream.peek() === ":")return ret("variable", "variable");
- if(stream.peek() === "/")stream.eatWhile(/[\w\\\-_%.{:\/]/);
- return ret(type, stream.current());
- } else if(stream.current().match(/(^http$|^https$)/) != null){
- stream.eatWhile(/[\w\\\-_%.{:\/]/);
- if(stream.peek() === "/")stream.eatWhile(/[\w\\\-_%.{:\/]/);
- return ret("string", "string");
- } else if(stream.peek() == "<" || stream.peek() == ">" || stream.peek() == "+"){
- if(type === "(" && (stream.current() === "n" || stream.current() === "-n"))return ret("string", stream.current());
- return ret("tag", "tag");
- } else if( /\(/.test(stream.peek()) ){
- if(stream.current() === "when")return ret("variable","variable");
- else if(state.stack[state.stack.length-1] === "@media" && stream.current() === "and")return ret("variable",stream.current());
- return ret(null, ch);
- } else if (stream.peek() == "/" && state.stack[state.stack.length-1] !== undefined){ // url(dir/center/image.png)
- if(stream.peek() === "/")stream.eatWhile(/[\w\\\-_%.{:\/]/);
- return ret("string", stream.current());
- } else if( stream.current().match(/\-\d|\-.\d/) ){ // match e.g.: -5px -0.4 etc... only colorize the minus sign
- //commment out these 2 comment if you want the minus sign to be parsed as null -500px
- //stream.backUp(stream.current().length-1);
- //return ret(null, ch);
- return ret("number", "unit");
- } else if( /\/|[\s\)]/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == "/")) && stream.current().indexOf(".") !== -1){
- if(stream.current().substring(stream.current().length-1,stream.current().length) == "{"){
- stream.backUp(1);
- return ret("tag", "tag");
- }//end if
- stream.eatSpace();
- if( /[{<>.a-zA-Z\/]/.test(stream.peek()) || stream.eol() )return ret("tag", "tag"); // e.g. button.icon-plus
- return ret("string", "string"); // let url(/images/logo.png) without quotes return as string
- } else if( stream.eol() || stream.peek() == "[" || stream.peek() == "#" || type == "tag" ){
-
- if(stream.current().substring(stream.current().length-1,stream.current().length) == "{")stream.backUp(1);
- else if(state.stack[state.stack.length-1] === "border-color" || state.stack[state.stack.length-1] === "background-position" || state.stack[state.stack.length-1] === "font-family")return ret(null, stream.current());
- else if(type === "tag")return ret("tag", "tag");
- else if((type === ":" || type === "unit") && state.stack[state.stack.length-1] === "rule")return ret(null, stream.current());
- else if(state.stack[state.stack.length-1] === "rule" && type === "tag")return ret("string", stream.current());
- else if(state.stack[state.stack.length-1] === ";" && type === ":")return ret(null, stream.current());
- //else if(state.stack[state.stack.length-1] === ";" || type === "")return ret("variable", stream.current());
- else if(stream.peek() === "#" && type !== undefined && type.match(/\+|,|tag|select\-op|}|{|;/g) === null)return ret("string", stream.current());
- else if(type === "variable")return ret(null, stream.current());
- else if(state.stack[state.stack.length-1] === "{" && type === "comment")return ret("variable", stream.current());
- else if(state.stack.length === 0 && (type === ";" || type === "comment"))return ret("tag", stream.current());
- else if((state.stack[state.stack.length-1] === "{" || type === ";") && state.stack[state.stack.length-1] !== "@media{")return ret("variable", stream.current());
- else if(state.stack[state.stack.length-2] === "{" && state.stack[state.stack.length-1] === ";")return ret("variable", stream.current());
-
- return ret("tag", "tag");
- } else if(type == "compare" || type == "a" || type == "("){
- return ret("string", "string");
- } else if(type == "|" || stream.current() == "-" || type == "["){
- if (type == "|" && stream.match(/^[\]=~]/, false)) return ret("number", stream.current());
- else if(type == "|" )return ret("tag", "tag");
- else if(type == "["){
- stream.eatWhile(/\w\-/);
- return ret("number", stream.current());
- }
- return ret(null, ch);
- } else if((stream.peek() == ":") || ( stream.eatSpace() && stream.peek() == ":")) {
- stream.next();
- var t_v = stream.peek() == ":" ? true : false;
- if(!t_v){
- var old_pos = stream.pos;
- var sc = stream.current().length;
- stream.eatWhile(/[a-z\\\-]/);
- var new_pos = stream.pos;
- if(stream.current().substring(sc-1).match(selectors) != null){
- stream.backUp(new_pos-(old_pos-1));
- return ret("tag", "tag");
- } else stream.backUp(new_pos-(old_pos-1));
- } else {
- stream.backUp(1);
- }
- if(t_v)return ret("tag", "tag"); else return ret("variable", "variable");
- } else if(state.stack[state.stack.length-1] === "font-family" || state.stack[state.stack.length-1] === "background-position" || state.stack[state.stack.length-1] === "border-color"){
- return ret(null, null);
- } else {
-
- if(state.stack[state.stack.length-1] === null && type === ":")return ret(null, stream.current());
-
- //else if((type === ")" && state.stack[state.stack.length-1] === "rule") || (state.stack[state.stack.length-2] === "{" && state.stack[state.stack.length-1] === "rule" && type === "variable"))return ret(null, stream.current());
-
- else if (/\^|\$/.test(stream.current()) && stream.match(/^[~=]/, false)) return ret("string", "string");//att^=val
-
- else if(type === "unit" && state.stack[state.stack.length-1] === "rule")return ret(null, "unit");
- else if(type === "unit" && state.stack[state.stack.length-1] === ";")return ret(null, "unit");
- else if(type === ")" && state.stack[state.stack.length-1] === "rule")return ret(null, "unit");
- else if(type && type.match("@") !== null && state.stack[state.stack.length-1] === "rule")return ret(null, "unit");
- //else if(type === "unit" && state.stack[state.stack.length-1] === "rule")return ret(null, stream.current());
-
- else if((type === ";" || type === "}" || type === ",") && state.stack[state.stack.length-1] === ";")return ret("tag", stream.current());
- else if((type === ";" && stream.peek() !== undefined && !stream.match(/^[{\.]/, false)) ||
- (type === ";" && stream.eatSpace() && !stream.match(/^[{\.]/))) return ret("variable", stream.current());
- else if((type === "@media" && state.stack[state.stack.length-1] === "@media") || type === "@namespace")return ret("tag", stream.current());
-
- else if(type === "{" && state.stack[state.stack.length-1] === ";" && stream.peek() === "{")return ret("tag", "tag");
- else if((type === "{" || type === ":") && state.stack[state.stack.length-1] === ";")return ret(null, stream.current());
- else if((state.stack[state.stack.length-1] === "{" && stream.eatSpace() && !stream.match(/^[\.#]/)) || type === "select-op" || (state.stack[state.stack.length-1] === "rule" && type === ",") )return ret("tag", "tag");
- else if(type === "variable" && state.stack[state.stack.length-1] === "rule")return ret("tag", "tag");
- else if((stream.eatSpace() && stream.peek() === "{") || stream.eol() || stream.peek() === "{")return ret("tag", "tag");
- //this one messes up indentation
- //else if((type === "}" && stream.peek() !== ":") || (type === "}" && stream.eatSpace() && stream.peek() !== ":"))return(type, "tag");
-
- else if(type === ")" && (stream.current() == "and" || stream.current() == "and "))return ret("variable", "variable");
- else if(type === ")" && (stream.current() == "when" || stream.current() == "when "))return ret("variable", "variable");
- else if(type === ")" || type === "comment" || type === "{")return ret("tag", "tag");
- else if(stream.sol())return ret("tag", "tag");
- else if((stream.eatSpace() && stream.peek() === "#") || stream.peek() === "#")return ret("tag", "tag");
- else if(state.stack.length === 0)return ret("tag", "tag");
- else if(type === ";" && stream.peek() !== undefined && stream.match(/^[\.|#]/g)) return ret("tag", "tag");
-
- else if(type === ":"){stream.eatSpace();return ret(null, stream.current());}
-
- else if(stream.current() === "and " || stream.current() === "and")return ret("variable", stream.current());
- else if(type === ";" && state.stack[state.stack.length-1] === "{")return ret("variable", stream.current());
-
- else if(state.stack[state.stack.length-1] === "rule")return ret(null, stream.current());
-
- return ret("tag", stream.current());
- }
- }
- }
-
- function tokenSComment(stream, state) { // SComment = Slash comment
- stream.skipToEnd();
- state.tokenize = tokenBase;
- return ret("comment", "comment");
- }
-
- function tokenCComment(stream, state) {
- var maybeEnd = false, ch;
- while ((ch = stream.next()) != null) {
- if (maybeEnd && ch == "/") {
- state.tokenize = tokenBase;
- break;
- }
- maybeEnd = (ch == "*");
- }
- return ret("comment", "comment");
- }
-
- function tokenSGMLComment(stream, state) {
- var dashes = 0, ch;
- while ((ch = stream.next()) != null) {
- if (dashes >= 2 && ch == ">") {
- state.tokenize = tokenBase;
- break;
- }
- dashes = (ch == "-") ? dashes + 1 : 0;
- }
- return ret("comment", "comment");
- }
-
- function tokenString(quote) {
- return function(stream, state) {
- var escaped = false, ch;
- while ((ch = stream.next()) != null) {
- if (ch == quote && !escaped)
- break;
- escaped = !escaped && ch == "\\";
- }
- if (!escaped) state.tokenize = tokenBase;
- return ret("string", "string");
- };
- }
-
- return {
- startState: function(base) {
- return {tokenize: tokenBase,
- baseIndent: base || 0,
- stack: []};
- },
-
- token: function(stream, state) {
- if (stream.eatSpace()) return null;
- var style = state.tokenize(stream, state);
-
- var context = state.stack[state.stack.length-1];
- if (type == "hash" && context == "rule") style = "atom";
- else if (style == "variable") {
- if (context == "rule") style = null; //"tag"
- else if (!context || context == "@media{") {
- style = stream.current() == "when" ? "variable" :
- /[\s,|\s\)|\s]/.test(stream.peek()) ? "tag" : type;
- }
- }
-
- if (context == "rule" && /^[\{\};]$/.test(type))
- state.stack.pop();
- if (type == "{") {
- if (context == "@media") state.stack[state.stack.length-1] = "@media{";
- else state.stack.push("{");
- }
- else if (type == "}") state.stack.pop();
- else if (type == "@media") state.stack.push("@media");
- else if (stream.current() === "font-family") state.stack[state.stack.length-1] = "font-family";
- else if (stream.current() === "background-position") state.stack[state.stack.length-1] = "background-position";
- else if (stream.current() === "border-color") state.stack[state.stack.length-1] = "border-color";
- else if (context == "{" && type != "comment" && type !== "tag") state.stack.push("rule");
- else if (stream.peek() === ":" && stream.current().match(/@|#/) === null) style = type;
- if(type === ";" && (state.stack[state.stack.length-1] == "font-family" || state.stack[state.stack.length-1] == "background-position" || state.stack[state.stack.length-1] == "border-color"))state.stack[state.stack.length-1] = stream.current();
- else if(type === "tag" && stream.peek() === ")" && stream.current().match(/\:/) === null){type = null; style = null;}
- // ????
- else if((type === "variable" && stream.peek() === ")") || (type === "variable" && stream.eatSpace() && stream.peek() === ")"))return ret(null,stream.current());
- return style;
- },
-
- indent: function(state, textAfter) {
- var n = state.stack.length;
- if (/^\}/.test(textAfter))
- n -= state.stack[state.stack.length-1] === "rule" ? 2 : 1;
- else if (state.stack[state.stack.length-2] === "{")
- n -= state.stack[state.stack.length-1] === "rule" ? 1 : 0;
- return state.baseIndent + n * indentUnit;
- },
-
- electricChars: "}",
- blockCommentStart: "/*",
- blockCommentEnd: "*/",
- lineComment: "//"
- };
-});
-
-CodeMirror.defineMIME("text/x-less", "less");
-if (!CodeMirror.mimeModes.hasOwnProperty("text/css"))
- CodeMirror.defineMIME("text/css", "less");
diff --git a/data/ext/editorText/codemirror/mode/livescript/index.html b/data/ext/editorText/codemirror/mode/livescript/index.html
index 3ce897485..f41547987 100644
--- a/data/ext/editorText/codemirror/mode/livescript/index.html
+++ b/data/ext/editorText/codemirror/mode/livescript/index.html
@@ -10,12 +10,12 @@
<script src="livescript.js"></script>
<style>.CodeMirror {font-size: 80%;border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/livescript/livescript.js b/data/ext/editorText/codemirror/mode/livescript/livescript.js
index fb925e6fb..4b26e0461 100644
--- a/data/ext/editorText/codemirror/mode/livescript/livescript.js
+++ b/data/ext/editorText/codemirror/mode/livescript/livescript.js
@@ -1,18 +1,31 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/**
* Link to the project's GitHub page:
* https://github.com/duralog/CodeMirror
*/
-(function() {
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
CodeMirror.defineMode('livescript', function(){
- var tokenBase, external;
- tokenBase = function(stream, state){
- var next_rule, nr, i$, len$, r, m;
- if (next_rule = state.next || 'start') {
+ var tokenBase = function(stream, state) {
+ var next_rule = state.next || "start";
+ if (next_rule) {
state.next = state.next;
- if (Array.isArray(nr = Rules[next_rule])) {
- for (i$ = 0, len$ = nr.length; i$ < len$; ++i$) {
- r = nr[i$];
- if (r.regex && (m = stream.match(r.regex))) {
+ var nr = Rules[next_rule];
+ if (nr.splice) {
+ for (var i$ = 0; i$ < nr.length; ++i$) {
+ var r = nr[i$];
+ if (r.regex && stream.match(r.regex)) {
state.next = r.next || state.next;
return r.token;
}
@@ -33,7 +46,7 @@
stream.next();
return 'error';
};
- external = {
+ var external = {
startState: function(){
return {
next: 'start',
@@ -41,8 +54,8 @@
};
},
token: function(stream, state){
- var style;
- style = tokenBase(stream, state);
+ while (stream.pos == stream.start)
+ var style = tokenBase(stream, state);
state.lastToken = {
style: style,
indent: stream.indentation(),
@@ -51,8 +64,7 @@
return style.replace(/\./g, ' ');
},
indent: function(state){
- var indentation;
- indentation = state.lastToken.indent;
+ var indentation = state.lastToken.indent;
if (state.lastToken.content.match(indenter)) {
indentation += 2;
}
@@ -251,7 +263,7 @@
};
for (var idx in Rules) {
var r = Rules[idx];
- if (Array.isArray(r)) {
+ if (r.splice) {
for (var i = 0, len = r.length; i < len; ++i) {
var rr = r[i];
if (typeof rr.regex === 'string') {
@@ -262,6 +274,7 @@
Rules[idx].regex = new RegExp('^' + r.regex);
}
}
-})();
-CodeMirror.defineMIME('text/x-livescript', 'livescript');
+ CodeMirror.defineMIME('text/x-livescript', 'livescript');
+
+});
diff --git a/data/ext/editorText/codemirror/mode/livescript/livescript.ls b/data/ext/editorText/codemirror/mode/livescript/livescript.ls
deleted file mode 100644
index 065242312..000000000
--- a/data/ext/editorText/codemirror/mode/livescript/livescript.ls
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * Link to the project's GitHub page:
- * https://github.com/duralog/CodeMirror
- */
-CodeMirror.defineMode 'livescript', (conf) ->
- tokenBase = (stream, state) ->
- #indent =
- if next_rule = state.next or \start
- state.next = state.next
- if Array.isArray nr = Rules[next_rule]
- for r in nr
- if r.regex and m = stream.match r.regex
- state.next = r.next
- return r.token
- stream.next!
- return \error
- if stream.match r = Rules[next_rule]
- if r.regex and stream.match r.regex
- state.next = r.next
- return r.token
- else
- stream.next!
- return \error
- stream.next!
- return 'error'
- external = {
- startState: (basecolumn) ->
- {
- next: \start
- lastToken: null
- }
- token: (stream, state) ->
- style = tokenBase stream, state #tokenLexer stream, state
- state.lastToken = {
- style: style
- indent: stream.indentation!
- content: stream.current!
- }
- style.replace /\./g, ' '
- indent: (state, textAfter) ->
- # XXX this won't work with backcalls
- indentation = state.lastToken.indent
- if state.lastToken.content.match indenter then indentation += 2
- return indentation
- }
- external
-
-### Highlight Rules
-# taken from mode-ls.ls
-
-indenter = // (?
- : [({[=:]
- | [-~]>
- | \b (?: e(?:lse|xport) | d(?:o|efault) | t(?:ry|hen) | finally |
- import (?:\s* all)? | const | var |
- let | new | catch (?:\s* #identifier)? )
- ) \s* $ //
-
-identifier = /(?![\d\s])[$\w\xAA-\uFFDC](?:(?!\s)[$\w\xAA-\uFFDC]|-[A-Za-z])*/$
-keywordend = /(?![$\w]|-[A-Za-z]|\s*:(?![:=]))/$
-stringfill = token: \string, regex: '.+'
-
-Rules =
- start:
- * token: \comment.doc
- regex: '/\\*'
- next : \comment
-
- * token: \comment
- regex: '#.*'
-
- * token: \keyword
- regex: //(?
- :t(?:h(?:is|row|en)|ry|ypeof!?)
- |c(?:on(?:tinue|st)|a(?:se|tch)|lass)
- |i(?:n(?:stanceof)?|mp(?:ort(?:\s+all)?|lements)|[fs])
- |d(?:e(?:fault|lete|bugger)|o)
- |f(?:or(?:\s+own)?|inally|unction)
- |s(?:uper|witch)
- |e(?:lse|x(?:tends|port)|val)
- |a(?:nd|rguments)
- |n(?:ew|ot)
- |un(?:less|til)
- |w(?:hile|ith)
- |o[fr]|return|break|let|var|loop
- )//$ + keywordend
-
- * token: \constant.language
- regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend
-
- * token: \invalid.illegal
- regex: '(?
- :p(?:ackage|r(?:ivate|otected)|ublic)
- |i(?:mplements|nterface)
- |enum|static|yield
- )' + keywordend
-
- * token: \language.support.class
- regex: '(?
- :R(?:e(?:gExp|ferenceError)|angeError)
- |S(?:tring|yntaxError)
- |E(?:rror|valError)
- |Array|Boolean|Date|Function|Number|Object|TypeError|URIError
- )' + keywordend
-
- * token: \language.support.function
- regex: '(?
- :is(?:NaN|Finite)
- |parse(?:Int|Float)
- |Math|JSON
- |(?:en|de)codeURI(?:Component)?
- )' + keywordend
-
- * token: \variable.language
- regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend
-
- * token: \identifier
- regex: identifier + /\s*:(?![:=])/$
-
- * token: \variable
- regex: identifier
-
- * token: \keyword.operator
- regex: /(?:\.{3}|\s+\?)/$
-
- * token: \keyword.variable
- regex: /(?:@+|::|\.\.)/$
- next : \key
-
- * token: \keyword.operator
- regex: /\.\s*/$
- next : \key
-
- * token: \string
- regex: /\\\S[^\s,;)}\]]*/$
-
- * token: \string.doc
- regex: \'''
- next : \qdoc
-
- * token: \string.doc
- regex: \"""
- next : \qqdoc
-
- * token: \string
- regex: \'
- next : \qstring
-
- * token: \string
- regex: \"
- next : \qqstring
-
- * token: \string
- regex: \`
- next : \js
-
- * token: \string
- regex: '<\\['
- next : \words
-
- * token: \string.regex
- regex: \//
- next : \heregex
-
- * token: \string.regex
- regex: //
- /(?: [^ [ / \n \\ ]*
- (?: (?: \\.
- | \[ [^\]\n\\]* (?:\\.[^\]\n\\]*)* \]
- ) [^ [ / \n \\ ]*
- )*
- )/ [gimy$]{0,4}
- //$
- next : \key
-
- * token: \constant.numeric
- regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*
- |(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*
- |(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)
- (?:e[+-]?\\d[\\d_]*)?[\\w$]*)'
-
- * token: \lparen
- regex: '[({[]'
-
- * token: \rparen
- regex: '[)}\\]]'
- next : \key
-
- * token: \keyword.operator
- regex: \\\S+
-
- * token: \text
- regex: \\\s+
-
- heregex:
- * token: \string.regex
- regex: '.*?//[gimy$?]{0,4}'
- next : \start
- * token: \string.regex
- regex: '\\s*#{'
- * token: \comment.regex
- regex: '\\s+(?:#.*)?'
- * token: \string.regex
- regex: '\\S+'
-
- key:
- * token: \keyword.operator
- regex: '[.?@!]+'
- * token: \identifier
- regex: identifier
- next : \start
- * token: \text
- regex: '.'
- next : \start
-
- comment:
- * token: \comment.doc
- regex: '.*?\\*/'
- next : \start
- * token: \comment.doc
- regex: '.+'
-
- qdoc:
- token: \string
- regex: ".*?'''"
- next : \key
- stringfill
-
- qqdoc:
- token: \string
- regex: '.*?"""'
- next : \key
- stringfill
-
- qstring:
- token: \string
- regex: /[^\\']*(?:\\.[^\\']*)*'/$
- next : \key
- stringfill
-
- qqstring:
- token: \string
- regex: /[^\\"]*(?:\\.[^\\"]*)*"/$
- next : \key
- stringfill
-
- js:
- token: \string
- regex: /[^\\`]*(?:\\.[^\\`]*)*`/$
- next : \key
- stringfill
-
- words:
- token: \string
- regex: '.*?\\]>'
- next : \key
- stringfill
-
-# for optimization, precompile the regexps
-for idx, r of Rules
- if Array.isArray r
- for rr, i in r
- if rr.regex then Rules[idx][i].regex = new RegExp '^'+rr.regex
- else if r.regex then Rules[idx].regex = new RegExp '^'+r.regex
-
-CodeMirror.defineMIME 'text/x-livescript', 'livescript'
diff --git a/data/ext/editorText/codemirror/mode/lua/index.html b/data/ext/editorText/codemirror/mode/lua/index.html
index 7f4eb2c84..fc98b9446 100644
--- a/data/ext/editorText/codemirror/mode/lua/index.html
+++ b/data/ext/editorText/codemirror/mode/lua/index.html
@@ -11,12 +11,12 @@
<script src="lua.js"></script>
<style>.CodeMirror {border: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/lua/lua.js b/data/ext/editorText/codemirror/mode/lua/lua.js
index b8deaa257..0b19abd30 100644
--- a/data/ext/editorText/codemirror/mode/lua/lua.js
+++ b/data/ext/editorText/codemirror/mode/lua/lua.js
@@ -1,7 +1,20 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
// LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's
// CodeMirror 1 mode.
// highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("lua", function(config, parserConfig) {
var indentUnit = config.indentUnit;
@@ -142,3 +155,5 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
});
CodeMirror.defineMIME("text/x-lua", "lua");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/markdown/index.html b/data/ext/editorText/codemirror/mode/markdown/index.html
index a6b541e2e..15660c261 100644
--- a/data/ext/editorText/codemirror/mode/markdown/index.html
+++ b/data/ext/editorText/codemirror/mode/markdown/index.html
@@ -16,12 +16,12 @@
.cm-s-default .cm-trailing-space-new-line:before {position: absolute; content: "\21B5"; color: #777;}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -350,8 +350,10 @@ Output:
});
</script>
- <p>Optionally depends on the XML mode for properly highlighted inline XML blocks.</p>
+ <p>You might want to use the <a href="../gfm/index.html">Github-Flavored Markdown mode</a> instead, which adds support for fenced code blocks and a few other things.</p>
+ <p>Optionally depends on the XML mode for properly highlighted inline XML blocks.</p>
+
<p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#markdown_*">normal</a>, <a href="../../test/index.html#verbose,markdown_*">verbose</a>.</p>
diff --git a/data/ext/editorText/codemirror/mode/markdown/markdown.js b/data/ext/editorText/codemirror/mode/markdown/markdown.js
index a571df294..2349ddf22 100644
--- a/data/ext/editorText/codemirror/mode/markdown/markdown.js
+++ b/data/ext/editorText/codemirror/mode/markdown/markdown.js
@@ -1,46 +1,29 @@
+// 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"), require("../xml/xml"), require("../meta"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../xml/xml", "../meta"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
- var aliases = {
- html: "htmlmixed",
- js: "javascript",
- json: "application/json",
- c: "text/x-csrc",
- "c++": "text/x-c++src",
- java: "text/x-java",
- csharp: "text/x-csharp",
- "c#": "text/x-csharp",
- scala: "text/x-scala"
- };
- var getMode = (function () {
- var i, modes = {}, mimes = {}, mime;
-
- var list = [];
- for (var m in CodeMirror.modes)
- if (CodeMirror.modes.propertyIsEnumerable(m)) list.push(m);
- for (i = 0; i < list.length; i++) {
- modes[list[i]] = list[i];
- }
- var mimesList = [];
- for (var m in CodeMirror.mimeModes)
- if (CodeMirror.mimeModes.propertyIsEnumerable(m))
- mimesList.push({mime: m, mode: CodeMirror.mimeModes[m]});
- for (i = 0; i < mimesList.length; i++) {
- mime = mimesList[i].mime;
- mimes[mime] = mimesList[i].mime;
+ function getMode(name) {
+ if (CodeMirror.findModeByName) {
+ var found = CodeMirror.findModeByName(name);
+ if (found) name = found.mime || found.mimes[0];
}
-
- for (var a in aliases) {
- if (aliases[a] in modes || aliases[a] in mimes)
- modes[a] = aliases[a];
- }
-
- return function (lang) {
- return modes[lang] ? CodeMirror.getMode(cmCfg, modes[lang]) : null;
- };
- }());
+ var mode = CodeMirror.getMode(cmCfg, name);
+ return mode.name == "null" ? null : mode;
+ }
// Should characters that affect highlighting be highlighted separate?
// Does not include characters that will be output (such as `1.` and `-` for lists)
@@ -56,37 +39,58 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (modeCfg.underscoresBreakWords === undefined)
modeCfg.underscoresBreakWords = true;
- // Turn on fenced code blocks? ("```" to start/end)
- if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false;
+ // Use `fencedCodeBlocks` to configure fenced code blocks. false to
+ // disable, string to specify a precise regexp that the fence should
+ // match, and true to allow three or more backticks or tildes (as
+ // per CommonMark).
// Turn on task lists? ("- [ ] " and "- [x] ")
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
+ // Turn on strikethrough syntax
+ if (modeCfg.strikethrough === undefined)
+ modeCfg.strikethrough = false;
+
+ // Allow token types to be overridden by user-provided token types.
+ if (modeCfg.tokenTypeOverrides === undefined)
+ modeCfg.tokenTypeOverrides = {};
+
var codeDepth = 0;
- var header = 'header'
- , code = 'comment'
- , quote = 'quote'
- , list1 = 'variable-2'
- , list2 = 'variable-3'
- , list3 = 'keyword'
- , hr = 'hr'
- , image = 'tag'
- , formatting = 'formatting'
- , linkinline = 'link'
- , linkemail = 'link'
- , linktext = 'link'
- , linkhref = 'string'
- , em = 'em'
- , strong = 'strong';
-
- var hrRE = /^([*\-=_])(?:\s*\1){2,}\s*$/
+ var tokenTypes = {
+ header: "header",
+ code: "comment",
+ quote: "quote",
+ list1: "variable-2",
+ list2: "variable-3",
+ list3: "keyword",
+ hr: "hr",
+ image: "tag",
+ formatting: "formatting",
+ linkInline: "link",
+ linkEmail: "link",
+ linkText: "link",
+ linkHref: "string",
+ em: "em",
+ strong: "strong",
+ strikethrough: "strikethrough"
+ };
+
+ for (var tokenType in tokenTypes) {
+ if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) {
+ tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType];
+ }
+ }
+
+ var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
, ulRE = /^[*\-+]\s+/
- , olRE = /^[0-9]+\.\s+/
+ , olRE = /^[0-9]+([.)])\s+/
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
- , atxHeaderRE = /^#+/
- , setextHeaderRE = /^(?:\={1,}|-{1,})$/
- , textRE = /^[^#!\[\]*_\\<>` "'(]+/;
+ , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
+ , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
+ , textRE = /^[^#!\[\]*_\\<>` "'(~]+/
+ , fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) +
+ ")[ \\t]*([\\w+#]*)");
function switchInline(stream, state, f) {
state.f = state.inline = f;
@@ -98,6 +102,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return f(stream, state);
}
+ function lineIsEmpty(line) {
+ return !line || !/\S/.test(line.string)
+ }
// Blocks
@@ -108,8 +115,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.em = false;
// Reset STRONG state
state.strong = false;
+ // Reset strikethrough state
+ state.strikethrough = false;
// Reset state.quote
state.quote = 0;
+ // Reset state.indentedCode
+ state.indentedCode = false;
if (!htmlFound && state.f == htmlBlock) {
state.f = inlineNormal;
state.block = blockNormal;
@@ -118,7 +129,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.trailingSpace = 0;
state.trailingSpaceNewLine = false;
// Mark this line as blank
- state.thisLineHasContent = false;
+ state.prevLine = state.thisLine
+ state.thisLine = null
return null;
}
@@ -126,39 +138,50 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
var sol = stream.sol();
- var prevLineIsList = (state.list !== false);
- if (state.list !== false && state.indentationDiff >= 0) { // Continued list
- if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
- state.indentation -= state.indentationDiff;
+ var prevLineIsList = state.list !== false,
+ prevLineIsIndentedCode = state.indentedCode;
+
+ state.indentedCode = false;
+
+ if (prevLineIsList) {
+ if (state.indentationDiff >= 0) { // Continued list
+ if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
+ state.indentation -= state.indentationDiff;
+ }
+ state.list = null;
+ } else if (state.indentation > 0) {
+ state.list = null;
+ state.listDepth = Math.floor(state.indentation / 4);
+ } else { // No longer a list
+ state.list = false;
+ state.listDepth = 0;
}
- state.list = null;
- } else if (state.list !== false && state.indentation > 0) {
- state.list = null;
- state.listDepth = Math.floor(state.indentation / 4);
- } else if (state.list !== false) { // No longer a list
- state.list = false;
- state.listDepth = 0;
}
var match = null;
if (state.indentationDiff >= 4) {
- state.indentation -= 4;
stream.skipToEnd();
- return code;
+ if (prevLineIsIndentedCode || lineIsEmpty(state.prevLine)) {
+ state.indentation -= 4;
+ state.indentedCode = true;
+ return tokenTypes.code;
+ } else {
+ return null;
+ }
} else if (stream.eatSpace()) {
return null;
- } else if (match = stream.match(atxHeaderRE)) {
- state.header = match[0].length <= 6 ? match[0].length : 6;
+ } else if ((match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
+ state.header = match[1].length;
if (modeCfg.highlightFormatting) state.formatting = "header";
state.f = state.inline;
return getType(state);
- } else if (state.prevLineHasContent && (match = stream.match(setextHeaderRE))) {
+ } else if (!lineIsEmpty(state.prevLine) && !state.quote && !prevLineIsList &&
+ !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
state.header = match[0].charAt(0) == '=' ? 1 : 2;
if (modeCfg.highlightFormatting) state.formatting = "header";
state.f = state.inline;
return getType(state);
} else if (stream.eat('>')) {
- state.indentation++;
state.quote = sol ? 1 : state.quote + 1;
if (modeCfg.highlightFormatting) state.formatting = "quote";
stream.eatSpace();
@@ -166,8 +189,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
} else if (stream.peek() === '[') {
return switchInline(stream, state, footnoteLink);
} else if (stream.match(hrRE, true)) {
- return hr;
- } else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
+ state.hr = true;
+ return tokenTypes.hr;
+ } else if ((lineIsEmpty(state.prevLine) || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
var listType = null;
if (stream.match(ulRE, true)) {
listType = 'ul';
@@ -175,7 +199,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
stream.match(olRE, true);
listType = 'ol';
}
- state.indentation += 4;
+ state.indentation = stream.column() + stream.current().length;
state.list = true;
state.listDepth++;
if (modeCfg.taskLists && stream.match(taskListRE, false)) {
@@ -184,11 +208,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.f = state.inline;
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
return getType(state);
- } else if (modeCfg.fencedCodeBlocks && stream.match(/^```([\w+#]*)/, true)) {
+ } else if (modeCfg.fencedCodeBlocks && (match = stream.match(fencedCodeRE, true))) {
+ state.fencedChars = match[1]
// try switching mode
- state.localMode = getMode(RegExp.$1);
+ state.localMode = getMode(match[2]);
if (state.localMode) state.localState = state.localMode.startState();
- switchBlock(stream, state, local);
+ state.f = state.block = local;
if (modeCfg.highlightFormatting) state.formatting = "code-block";
state.code = true;
return getType(state);
@@ -199,7 +224,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
function htmlBlock(stream, state) {
var style = htmlMode.token(stream, state.htmlState);
- if ((htmlFound && !state.htmlState.tagName && !state.htmlState.context) ||
+ if ((htmlFound && state.htmlState.tagStart === null &&
+ (!state.htmlState.context && state.htmlState.tokenize.isInText)) ||
(state.md_inside && stream.current().indexOf(">") > -1)) {
state.f = inlineNormal;
state.block = blockNormal;
@@ -209,44 +235,51 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}
function local(stream, state) {
- if (stream.sol() && stream.match(/^```/, true)) {
+ if (stream.sol() && state.fencedChars && stream.match(state.fencedChars, false)) {
state.localMode = state.localState = null;
- state.f = inlineNormal;
- state.block = blockNormal;
- if (modeCfg.highlightFormatting) state.formatting = "code-block";
- state.code = true;
- var returnType = getType(state);
- state.code = false;
- return returnType;
+ state.f = state.block = leavingLocal;
+ return null;
} else if (state.localMode) {
return state.localMode.token(stream, state.localState);
} else {
stream.skipToEnd();
- return code;
+ return tokenTypes.code;
}
}
+ function leavingLocal(stream, state) {
+ stream.match(state.fencedChars);
+ state.block = blockNormal;
+ state.f = inlineNormal;
+ state.fencedChars = null;
+ if (modeCfg.highlightFormatting) state.formatting = "code-block";
+ state.code = true;
+ var returnType = getType(state);
+ state.code = false;
+ return returnType;
+ }
+
// Inline
function getType(state) {
var styles = [];
if (state.formatting) {
- styles.push(formatting);
+ styles.push(tokenTypes.formatting);
if (typeof state.formatting === "string") state.formatting = [state.formatting];
for (var i = 0; i < state.formatting.length; i++) {
- styles.push(formatting + "-" + state.formatting[i]);
+ styles.push(tokenTypes.formatting + "-" + state.formatting[i]);
if (state.formatting[i] === "header") {
- styles.push(formatting + "-" + state.formatting[i] + "-" + state.header);
+ styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header);
}
// Add `formatting-quote` and `formatting-quote-#` for blockquotes
// Add `error` instead if the maximum blockquote nesting depth is passed
if (state.formatting[i] === "quote") {
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
- styles.push(formatting + "-" + state.formatting[i] + "-" + state.quote);
+ styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote);
} else {
styles.push("error");
}
@@ -264,38 +297,36 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}
if (state.linkHref) {
- styles.push(linkhref);
- return styles.length ? styles.join(' ') : null;
+ styles.push(tokenTypes.linkHref, "url");
+ } else { // Only apply inline styles to non-url text
+ if (state.strong) { styles.push(tokenTypes.strong); }
+ if (state.em) { styles.push(tokenTypes.em); }
+ if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
+ if (state.linkText) { styles.push(tokenTypes.linkText); }
+ if (state.code) { styles.push(tokenTypes.code); }
}
- if (state.strong) { styles.push(strong); }
- if (state.em) { styles.push(em); }
-
- if (state.linkText) { styles.push(linktext); }
-
- if (state.code) { styles.push(code); }
-
- if (state.header) { styles.push(header); styles.push(header + "-" + state.header); }
+ if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
if (state.quote) {
- styles.push(quote);
+ styles.push(tokenTypes.quote);
// Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
- styles.push(quote + "-" + state.quote);
+ styles.push(tokenTypes.quote + "-" + state.quote);
} else {
- styles.push(quote + "-" + modeCfg.maxBlockquoteDepth);
+ styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth);
}
}
if (state.list !== false) {
var listMod = (state.listDepth - 1) % 3;
if (!listMod) {
- styles.push(list1);
+ styles.push(tokenTypes.list1);
} else if (listMod === 1) {
- styles.push(list2);
+ styles.push(tokenTypes.list2);
} else {
- styles.push(list3);
+ styles.push(tokenTypes.list3);
}
}
@@ -347,15 +378,13 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
var ch = stream.next();
- if (state.escape) {
- state.escape = false;
- return getType(state);
- }
-
if (ch === '\\') {
- if (modeCfg.highlightFormatting) state.formatting = "escape";
- state.escape = true;
- return getType(state);
+ stream.next();
+ if (modeCfg.highlightFormatting) {
+ var type = getType(state);
+ var formattingEscape = tokenTypes.formatting + "-escape";
+ return type ? type + " " + formattingEscape : formattingEscape;
+ }
}
// Matches link titles present on next line
@@ -368,7 +397,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
if (stream.match(new RegExp(regex), true)) {
- return linkhref;
+ return tokenTypes.linkHref;
}
}
@@ -399,16 +428,16 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
stream.match(/\[[^\]]*\]/);
state.inline = state.f = linkHref;
- return image;
+ return tokenTypes.image;
}
- if (ch === '[' && stream.match(/.*\](\(| ?\[)/, false)) {
+ if (ch === '[' && stream.match(/.*\](\(.*\)| ?\[.*\])/, false)) {
state.linkText = true;
if (modeCfg.highlightFormatting) state.formatting = "link";
return getType(state);
}
- if (ch === ']' && state.linkText) {
+ if (ch === ']' && state.linkText && stream.match(/\(.*\)| ?\[.*\]/, false)) {
if (modeCfg.highlightFormatting) state.formatting = "link";
var type = getType(state);
state.linkText = false;
@@ -425,7 +454,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
} else {
type = "";
}
- return type + linkinline;
+ return type + tokenTypes.linkInline;
}
if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
@@ -437,15 +466,14 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
} else {
type = "";
}
- return type + linkemail;
+ return type + tokenTypes.linkEmail;
}
- if (ch === '<' && stream.match(/^\w/, false)) {
- if (stream.string.indexOf(">") != -1) {
- var atts = stream.string.substring(1,stream.string.indexOf(">"));
- if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
- state.md_inside = true;
- }
+ if (ch === '<' && stream.match(/^(!--|\w)/, false)) {
+ var end = stream.string.indexOf(">", stream.pos);
+ if (end != -1) {
+ var atts = stream.string.substring(stream.start, end);
+ if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true;
}
stream.backUp(1);
state.htmlState = CodeMirror.startState(htmlMode);
@@ -501,6 +529,29 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}
}
+ if (modeCfg.strikethrough) {
+ if (ch === '~' && stream.eatWhile(ch)) {
+ if (state.strikethrough) {// Remove strikethrough
+ if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
+ var t = getType(state);
+ state.strikethrough = false;
+ return t;
+ } else if (stream.match(/^[^\s]/, false)) {// Add strikethrough
+ state.strikethrough = true;
+ if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
+ return getType(state);
+ }
+ } else if (ch === ' ') {
+ if (stream.match(/^~~/, true)) { // Probably surrounded by space
+ if (stream.peek() === ' ') { // Surrounded by spaces, ignore
+ return getType(state);
+ } else { // Not surrounded by spaces, back up pointer
+ stream.backUp(2);
+ }
+ }
+ }
+ }
+
if (ch === ' ') {
if (stream.match(/ +$/, false)) {
state.trailingSpace++;
@@ -524,12 +575,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
} else {
type = "";
}
- return type + linkinline;
+ return type + tokenTypes.linkInline;
}
stream.match(/^[^>]+/, true);
- return linkinline;
+ return tokenTypes.linkInline;
}
function linkHref(stream, state) {
@@ -590,7 +641,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
stream.match(/^[^\]]+/, true);
- return linktext;
+ return tokenTypes.linkText;
}
function footnoteUrl(stream, state) {
@@ -607,7 +658,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
}
state.f = state.inline = inlineNormal;
- return linkhref;
+ return tokenTypes.linkHref + " url";
}
var savedInlineRE = [];
@@ -627,8 +678,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return {
f: blockNormal,
- prevLineHasContent: false,
- thisLineHasContent: false,
+ prevLine: null,
+ thisLine: null,
block: blockNormal,
htmlState: null,
@@ -637,7 +688,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
inline: inlineNormal,
text: handleText,
- escape: false,
formatting: false,
linkText: false,
linkHref: false,
@@ -645,12 +695,15 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
em: false,
strong: false,
header: 0,
+ hr: false,
taskList: false,
list: false,
listDepth: 0,
quote: 0,
trailingSpace: 0,
- trailingSpaceNewLine: false
+ trailingSpaceNewLine: false,
+ strikethrough: false,
+ fencedChars: null
};
},
@@ -658,8 +711,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return {
f: s.f,
- prevLineHasContent: s.prevLineHasContent,
- thisLineHasContent: s.thisLineHasContent,
+ prevLine: s.prevLine,
+ thisLine: s.this,
block: s.block,
htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
@@ -670,19 +723,23 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
inline: s.inline,
text: s.text,
- escape: false,
formatting: false,
linkTitle: s.linkTitle,
+ code: s.code,
em: s.em,
strong: s.strong,
+ strikethrough: s.strikethrough,
header: s.header,
+ hr: s.hr,
taskList: s.taskList,
list: s.list,
listDepth: s.listDepth,
quote: s.quote,
+ indentedCode: s.indentedCode,
trailingSpace: s.trailingSpace,
trailingSpaceNewLine: s.trailingSpaceNewLine,
- md_inside: s.md_inside
+ md_inside: s.md_inside,
+ fencedChars: s.fencedChars
};
},
@@ -691,29 +748,25 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
// Reset state.formatting
state.formatting = false;
- if (stream.sol()) {
- var forceBlankLine = stream.match(/^\s*$/, true) || state.header;
+ if (stream != state.thisLine) {
+ var forceBlankLine = state.header || state.hr;
- // Reset state.header
+ // Reset state.header and state.hr
state.header = 0;
+ state.hr = false;
- if (forceBlankLine) {
- state.prevLineHasContent = false;
- return blankLine(state);
- } else {
- state.prevLineHasContent = state.thisLineHasContent;
- state.thisLineHasContent = true;
+ if (stream.match(/^\s*$/, true) || forceBlankLine) {
+ blankLine(state);
+ if (!forceBlankLine) return null
+ state.prevLine = null
}
- // Reset state.escape
- state.escape = false;
+ state.prevLine = state.thisLine
+ state.thisLine = stream
// Reset state.taskList
state.taskList = false;
- // Reset state.code
- state.code = false;
-
// Reset state.trailingSpace
state.trailingSpace = 0;
state.trailingSpaceNewLine = false;
@@ -746,3 +799,5 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}, "xml");
CodeMirror.defineMIME("text/x-markdown", "markdown");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/markdown/test.js b/data/ext/editorText/codemirror/mode/markdown/test.js
index c3016d3a6..f9cc27c3b 100644
--- a/data/ext/editorText/codemirror/mode/markdown/test.js
+++ b/data/ext/editorText/codemirror/mode/markdown/test.js
@@ -1,8 +1,44 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "markdown");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "markdown", highlightFormatting: true});
function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
+ var modeAtxNoSpace = CodeMirror.getMode({tabSize: 4}, {name: "markdown", allowAtxHeaderWithoutSpace: true});
+ function AtxNoSpaceTest(name) { test.mode(name, modeAtxNoSpace, Array.prototype.slice.call(arguments, 1)); }
+ var modeFenced = CodeMirror.getMode({tabSize: 4}, {name: "markdown", fencedCodeBlocks: true});
+ function FencedTest(name) { test.mode(name, modeFenced, Array.prototype.slice.call(arguments, 1)); }
+ var modeOverrideClasses = CodeMirror.getMode({tabsize: 4}, {
+ name: "markdown",
+ strikethrough: true,
+ tokenTypeOverrides: {
+ "header" : "override-header",
+ "code" : "override-code",
+ "quote" : "override-quote",
+ "list1" : "override-list1",
+ "list2" : "override-list2",
+ "list3" : "override-list3",
+ "hr" : "override-hr",
+ "image" : "override-image",
+ "linkInline" : "override-link-inline",
+ "linkEmail" : "override-link-email",
+ "linkText" : "override-link-text",
+ "linkHref" : "override-link-href",
+ "em" : "override-em",
+ "strong" : "override-strong",
+ "strikethrough" : "override-strikethrough"
+ }});
+ function TokenTypeOverrideTest(name) { test.mode(name, modeOverrideClasses, Array.prototype.slice.call(arguments, 1)); }
+ var modeFormattingOverride = CodeMirror.getMode({tabsize: 4}, {
+ name: "markdown",
+ highlightFormatting: true,
+ tokenTypeOverrides: {
+ "formatting" : "override-formatting"
+ }});
+ function FormatTokenTypeOverrideTest(name) { test.mode(name, modeFormattingOverride, Array.prototype.slice.call(arguments, 1)); }
+
FT("formatting_emAsterisk",
"[em&formatting&formatting-em *][em foo][em&formatting&formatting-em *]");
@@ -23,7 +59,7 @@
"[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]");
FT("formatting_atxHeader",
- "[header&header-1&formatting&formatting-header&formatting-header-1 #][header&header-1 foo # bar ][header&header-1&formatting&formatting-header&formatting-header-1 #]");
+ "[header&header-1&formatting&formatting-header&formatting-header-1 # ][header&header-1 foo # bar ][header&header-1&formatting&formatting-header&formatting-header-1 #]");
FT("formatting_setextHeader",
"foo",
@@ -38,11 +74,11 @@
"[variable-2&formatting&formatting-list&formatting-list-ol 1. ][variable-2 foo]");
FT("formatting_link",
- "[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string (][string http://example.com/][string&formatting&formatting-link-string )]");
+ "[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string&url (][string&url http://example.com/][string&formatting&formatting-link-string&url )]");
FT("formatting_linkReference",
- "[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string [][string bar][string&formatting&formatting-link-string ]]]",
- "[link&formatting&formatting-link [][link bar][link&formatting&formatting-link ]]:] [string http://example.com/]");
+ "[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string&url [][string&url bar][string&formatting&formatting-link-string&url ]]]",
+ "[link&formatting&formatting-link [][link bar][link&formatting&formatting-link ]]:] [string&url http://example.com/]");
FT("formatting_linkWeb",
"[link&formatting&formatting-link <][link http://example.com/][link&formatting&formatting-link >]");
@@ -51,7 +87,7 @@
"[link&formatting&formatting-link <][link [email protected]][link&formatting&formatting-link >]");
FT("formatting_escape",
- "[formatting&formatting-escape \\]*");
+ "[formatting-escape \\*]");
MT("plainText",
"foo");
@@ -82,17 +118,24 @@
" [comment foo]",
"bar");
- // Code blocks using 4 spaces with internal indentation
- MT("codeBlocksUsing4SpacesIndentation",
- " foo",
- " [comment bar]",
- " [comment hello]",
- " [comment world]");
+ // Code blocks should end even after extra indented lines
+ MT("codeBlocksWithTrailingIndentedLine",
+ " [comment foo]",
+ " [comment bar]",
+ " [comment baz]",
+ " ",
+ "hello");
// Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value)
MT("codeBlocksUsing1Tab",
"\t[comment foo]");
+ // No code blocks directly after paragraph
+ // http://spec.commonmark.org/0.19/#example-65
+ MT("noCodeBlocksAfterParagraph",
+ "Foo",
+ " Bar");
+
// Inline code using backticks
MT("inlineCodeUsingBackticks",
"foo [comment `bar`]");
@@ -100,7 +143,7 @@
// Block code using single backtick (shouldn't work)
MT("blockCodeSingleBacktick",
"[comment `]",
- "foo",
+ "[comment foo]",
"[comment `]");
// Unclosed backticks
@@ -155,10 +198,23 @@
MT("atxH6",
"[header&header-6 ###### foo]");
- // H6 - 7x '#' should still be H6, per Dingus
- // http://daringfireball.net/projects/markdown/dingus
- MT("atxH6NotH7",
- "[header&header-6 ####### foo]");
+ // http://spec.commonmark.org/0.19/#example-24
+ MT("noAtxH7",
+ "####### foo");
+
+ // http://spec.commonmark.org/0.19/#example-25
+ MT("noAtxH1WithoutSpace",
+ "#5 bolt");
+
+ // CommonMark requires a space after # but most parsers don't
+ AtxNoSpaceTest("atxNoSpaceAllowed_H1NoSpace",
+ "[header&header-1 #foo]");
+
+ AtxNoSpaceTest("atxNoSpaceAllowed_H4NoSpace",
+ "[header&header-4 ####foo]");
+
+ AtxNoSpaceTest("atxNoSpaceAllowed_H1Space",
+ "[header&header-1 # foo]");
// Inline styles should be parsed inside headers
MT("atxH1inline",
@@ -191,6 +247,25 @@
"foo",
"[header&header-2 ---]");
+ // http://spec.commonmark.org/0.19/#example-45
+ MT("setextH2AllowSpaces",
+ "foo",
+ " [header&header-2 ---- ]");
+
+ // http://spec.commonmark.org/0.19/#example-44
+ MT("noSetextAfterIndentedCodeBlock",
+ " [comment foo]",
+ "[hr ---]");
+
+ // http://spec.commonmark.org/0.19/#example-51
+ MT("noSetextAfterQuote",
+ "[quote&quote-1 > foo]",
+ "[hr ---]");
+
+ MT("noSetextAfterList",
+ "[variable-2 - foo]",
+ "[hr ---]");
+
// Single-line blockquote with trailing space
MT("blockquoteSpace",
"[quote&quote-1 > foo]");
@@ -240,6 +315,13 @@
"",
"hello");
+ // Header with leading space after continued blockquote (#3287, negative indentation)
+ MT("headerAfterContinuedBlockquote",
+ "[quote&quote-1 > foo]",
+ "[quote&quote-1 bar]",
+ "",
+ " [header&header-1 # hello]");
+
// Check list types
MT("listAsterisk",
@@ -276,11 +358,21 @@
"1. bar",
"2. hello");
+ // List after hr
+ MT("listAfterHr",
+ "[hr ---]",
+ "[variable-2 - bar]");
+
// List after header
MT("listAfterHeader",
"[header&header-1 # foo]",
"[variable-2 - bar]");
+ // hr after list
+ MT("hrAfterList",
+ "[variable-2 - foo]",
+ "[hr -----]");
+
// Formatting in lists (*)
MT("listAsteriskFormatting",
"[variable-2 * ][variable-2&em *foo*][variable-2 bar]",
@@ -449,14 +541,14 @@
"",
" [variable-3 * bar]",
"",
- " [variable-2 hello]"
+ " [variable-3 hello]"
);
MT("listNested",
"[variable-2 * foo]",
"",
" [variable-3 * bar]",
"",
- " [variable-3 * foo]"
+ " [keyword * foo]"
);
// Code followed by text
@@ -487,39 +579,39 @@
// Inline link with title
MT("linkTitle",
- "[link [[foo]]][string (http://example.com/ \"bar\")] hello");
+ "[link [[foo]]][string&url (http://example.com/ \"bar\")] hello");
// Inline link without title
MT("linkNoTitle",
- "[link [[foo]]][string (http://example.com/)] bar");
+ "[link [[foo]]][string&url (http://example.com/)] bar");
// Inline link with image
MT("linkImage",
- "[link [[][tag ![[foo]]][string (http://example.com/)][link ]]][string (http://example.com/)] bar");
+ "[link [[][tag ![[foo]]][string&url (http://example.com/)][link ]]][string&url (http://example.com/)] bar");
// Inline link with Em
MT("linkEm",
- "[link [[][link&em *foo*][link ]]][string (http://example.com/)] bar");
+ "[link [[][link&em *foo*][link ]]][string&url (http://example.com/)] bar");
// Inline link with Strong
MT("linkStrong",
- "[link [[][link&strong **foo**][link ]]][string (http://example.com/)] bar");
+ "[link [[][link&strong **foo**][link ]]][string&url (http://example.com/)] bar");
// Inline link with EmStrong
MT("linkEmStrong",
- "[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string (http://example.com/)] bar");
+ "[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string&url (http://example.com/)] bar");
// Image with title
MT("imageTitle",
- "[tag ![[foo]]][string (http://example.com/ \"bar\")] hello");
+ "[tag ![[foo]]][string&url (http://example.com/ \"bar\")] hello");
// Image without title
MT("imageNoTitle",
- "[tag ![[foo]]][string (http://example.com/)] bar");
+ "[tag ![[foo]]][string&url (http://example.com/)] bar");
// Image with asterisks
MT("imageAsterisks",
- "[tag ![[*foo*]]][string (http://example.com/)] bar");
+ "[tag ![[*foo*]]][string&url (http://example.com/)] bar");
// Not a link. Should be normal text due to square brackets being used
// regularly in text, especially in quoted material, and no space is allowed
@@ -529,24 +621,24 @@
// Reference-style links
MT("linkReference",
- "[link [[foo]]][string [[bar]]] hello");
+ "[link [[foo]]][string&url [[bar]]] hello");
// Reference-style links with Em
MT("linkReferenceEm",
- "[link [[][link&em *foo*][link ]]][string [[bar]]] hello");
+ "[link [[][link&em *foo*][link ]]][string&url [[bar]]] hello");
// Reference-style links with Strong
MT("linkReferenceStrong",
- "[link [[][link&strong **foo**][link ]]][string [[bar]]] hello");
+ "[link [[][link&strong **foo**][link ]]][string&url [[bar]]] hello");
// Reference-style links with EmStrong
MT("linkReferenceEmStrong",
- "[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string [[bar]]] hello");
+ "[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string&url [[bar]]] hello");
// Reference-style links with optional space separator (per docuentation)
// "You can optionally use a space to separate the sets of brackets"
MT("linkReferenceSpace",
- "[link [[foo]]] [string [[bar]]] hello");
+ "[link [[foo]]] [string&url [[bar]]] hello");
// Should only allow a single space ("...use *a* space...")
MT("linkReferenceDoubleSpace",
@@ -554,7 +646,7 @@
// Reference-style links with implicit link name
MT("linkImplicit",
- "[link [[foo]]][string [[]]] hello");
+ "[link [[foo]]][string&url [[]]] hello");
// @todo It would be nice if, at some point, the document was actually
// checked to see if the referenced link exists
@@ -562,46 +654,46 @@
// Link label, for reference-style links (taken from documentation)
MT("labelNoTitle",
- "[link [[foo]]:] [string http://example.com/]");
+ "[link [[foo]]:] [string&url http://example.com/]");
MT("labelIndented",
- " [link [[foo]]:] [string http://example.com/]");
+ " [link [[foo]]:] [string&url http://example.com/]");
MT("labelSpaceTitle",
- "[link [[foo bar]]:] [string http://example.com/ \"hello\"]");
+ "[link [[foo bar]]:] [string&url http://example.com/ \"hello\"]");
MT("labelDoubleTitle",
- "[link [[foo bar]]:] [string http://example.com/ \"hello\"] \"world\"");
+ "[link [[foo bar]]:] [string&url http://example.com/ \"hello\"] \"world\"");
MT("labelTitleDoubleQuotes",
- "[link [[foo]]:] [string http://example.com/ \"bar\"]");
+ "[link [[foo]]:] [string&url http://example.com/ \"bar\"]");
MT("labelTitleSingleQuotes",
- "[link [[foo]]:] [string http://example.com/ 'bar']");
+ "[link [[foo]]:] [string&url http://example.com/ 'bar']");
MT("labelTitleParenthese",
- "[link [[foo]]:] [string http://example.com/ (bar)]");
+ "[link [[foo]]:] [string&url http://example.com/ (bar)]");
MT("labelTitleInvalid",
- "[link [[foo]]:] [string http://example.com/] bar");
+ "[link [[foo]]:] [string&url http://example.com/] bar");
MT("labelLinkAngleBrackets",
- "[link [[foo]]:] [string <http://example.com/> \"bar\"]");
+ "[link [[foo]]:] [string&url <http://example.com/> \"bar\"]");
MT("labelTitleNextDoubleQuotes",
- "[link [[foo]]:] [string http://example.com/]",
+ "[link [[foo]]:] [string&url http://example.com/]",
"[string \"bar\"] hello");
MT("labelTitleNextSingleQuotes",
- "[link [[foo]]:] [string http://example.com/]",
+ "[link [[foo]]:] [string&url http://example.com/]",
"[string 'bar'] hello");
MT("labelTitleNextParenthese",
- "[link [[foo]]:] [string http://example.com/]",
+ "[link [[foo]]:] [string&url http://example.com/]",
"[string (bar)] hello");
MT("labelTitleNextMixed",
- "[link [[foo]]:] [string http://example.com/]",
+ "[link [[foo]]:] [string&url http://example.com/]",
"(bar\" hello");
MT("linkWeb",
@@ -711,14 +803,145 @@
"\\",
"[em *foo*]");
+ // Class override tests
+ TokenTypeOverrideTest("overrideHeader1",
+ "[override-header&override-header-1 # Foo]");
+
+ TokenTypeOverrideTest("overrideHeader2",
+ "[override-header&override-header-2 ## Foo]");
+
+ TokenTypeOverrideTest("overrideHeader3",
+ "[override-header&override-header-3 ### Foo]");
+
+ TokenTypeOverrideTest("overrideHeader4",
+ "[override-header&override-header-4 #### Foo]");
+
+ TokenTypeOverrideTest("overrideHeader5",
+ "[override-header&override-header-5 ##### Foo]");
+
+ TokenTypeOverrideTest("overrideHeader6",
+ "[override-header&override-header-6 ###### Foo]");
+
+ TokenTypeOverrideTest("overrideCode",
+ "[override-code `foo`]");
+
+ TokenTypeOverrideTest("overrideCodeBlock",
+ "[override-code ```]",
+ "[override-code foo]",
+ "[override-code ```]");
+
+ TokenTypeOverrideTest("overrideQuote",
+ "[override-quote&override-quote-1 > foo]",
+ "[override-quote&override-quote-1 > bar]");
+
+ TokenTypeOverrideTest("overrideQuoteNested",
+ "[override-quote&override-quote-1 > foo]",
+ "[override-quote&override-quote-1 >][override-quote&override-quote-2 > bar]",
+ "[override-quote&override-quote-1 >][override-quote&override-quote-2 >][override-quote&override-quote-3 > baz]");
+
+ TokenTypeOverrideTest("overrideLists",
+ "[override-list1 - foo]",
+ "",
+ " [override-list2 + bar]",
+ "",
+ " [override-list3 * baz]",
+ "",
+ " [override-list1 1. qux]",
+ "",
+ " [override-list2 - quux]");
+
+ TokenTypeOverrideTest("overrideHr",
+ "[override-hr * * *]");
+
+ TokenTypeOverrideTest("overrideImage",
+ "[override-image ![[foo]]][override-link-href&url (http://example.com/)]")
+
+ TokenTypeOverrideTest("overrideLinkText",
+ "[override-link-text [[foo]]][override-link-href&url (http://example.com)]");
+
+ TokenTypeOverrideTest("overrideLinkEmailAndInline",
+ "[override-link-email <][override-link-inline [email protected]>]");
+
+ TokenTypeOverrideTest("overrideEm",
+ "[override-em *foo*]");
+
+ TokenTypeOverrideTest("overrideStrong",
+ "[override-strong **foo**]");
+
+ TokenTypeOverrideTest("overrideStrikethrough",
+ "[override-strikethrough ~~foo~~]");
+
+ FormatTokenTypeOverrideTest("overrideFormatting",
+ "[override-formatting-escape \\*]");
// Tests to make sure GFM-specific things aren't getting through
MT("taskList",
"[variable-2 * [ ]] bar]");
- MT("fencedCodeBlocks",
- "[comment ```]",
+ MT("noFencedCodeBlocks",
+ "~~~",
"foo",
- "[comment ```]");
+ "~~~");
+
+ FencedTest("fencedCodeBlocks",
+ "[comment ```]",
+ "[comment foo]",
+ "[comment ```]",
+ "bar");
+
+ FencedTest("fencedCodeBlocksMultipleChars",
+ "[comment `````]",
+ "[comment foo]",
+ "[comment ```]",
+ "[comment foo]",
+ "[comment `````]",
+ "bar");
+
+ FencedTest("fencedCodeBlocksTildes",
+ "[comment ~~~]",
+ "[comment foo]",
+ "[comment ~~~]",
+ "bar");
+
+ FencedTest("fencedCodeBlocksTildesMultipleChars",
+ "[comment ~~~~~]",
+ "[comment ~~~]",
+ "[comment foo]",
+ "[comment ~~~~~]",
+ "bar");
+
+ FencedTest("fencedCodeBlocksMultipleChars",
+ "[comment `````]",
+ "[comment foo]",
+ "[comment ```]",
+ "[comment foo]",
+ "[comment `````]",
+ "bar");
+
+ FencedTest("fencedCodeBlocksMixed",
+ "[comment ~~~]",
+ "[comment ```]",
+ "[comment foo]",
+ "[comment ~~~]",
+ "bar");
+
+ // Tests that require XML mode
+
+ MT("xmlMode",
+ "[tag&bracket <][tag div][tag&bracket >]",
+ "*foo*",
+ "[tag&bracket <][tag http://github.com][tag&bracket />]",
+ "[tag&bracket </][tag div][tag&bracket >]",
+ "[link <http://github.com/>]");
+
+ MT("xmlModeWithMarkdownInside",
+ "[tag&bracket <][tag div] [attribute markdown]=[string 1][tag&bracket >]",
+ "[em *foo*]",
+ "[link <http://github.com/>]",
+ "[tag </div>]",
+ "[link <http://github.com/>]",
+ "[tag&bracket <][tag div][tag&bracket >]",
+ "[tag&bracket </][tag div][tag&bracket >]");
+
})();
diff --git a/data/ext/editorText/codemirror/mode/mathematica/index.html b/data/ext/editorText/codemirror/mode/mathematica/index.html
new file mode 100644
index 000000000..57c429853
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mathematica/index.html
@@ -0,0 +1,72 @@
+<!doctype html>
+
+<title>CodeMirror: Mathematica mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel=stylesheet href=../../lib/codemirror.css>
+<script src=../../lib/codemirror.js></script>
+<script src=../../addon/edit/matchbrackets.js></script>
+<script src=mathematica.js></script>
+<style type=text/css>
+ .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
+</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Mathematica</a>
+ </ul>
+</div>
+
+<article>
+<h2>Mathematica mode</h2>
+
+
+<textarea id="mathematicaCode">
+(* example Mathematica code *)
+(* Dualisiert wird anhand einer Polarität an einer
+ Quadrik $x^t Q x = 0$ mit regulärer Matrix $Q$ (also
+ mit $det(Q) \neq 0$), z.B. die Identitätsmatrix.
+ $p$ ist eine Liste von Polynomen - ein Ideal. *)
+dualize::"singular" = "Q must be regular: found Det[Q]==0.";
+dualize[ Q_, p_ ] := Block[
+ { m, n, xv, lv, uv, vars, polys, dual },
+ If[Det[Q] == 0,
+ Message[dualize::"singular"],
+ m = Length[p];
+ n = Length[Q] - 1;
+ xv = Table[Subscript[x, i], {i, 0, n}];
+ lv = Table[Subscript[l, i], {i, 1, m}];
+ uv = Table[Subscript[u, i], {i, 0, n}];
+ (* Konstruiere Ideal polys. *)
+ If[m == 0,
+ polys = Q.uv,
+ polys = Join[p, Q.uv - Transpose[Outer[D, p, xv]].lv]
+ ];
+ (* Eliminiere die ersten n + 1 + m Variablen xv und lv
+ aus dem Ideal polys. *)
+ vars = Join[xv, lv];
+ dual = GroebnerBasis[polys, uv, vars];
+ (* Ersetze u mit x im Ergebnis. *)
+ ReplaceAll[dual, Rule[u, x]]
+ ]
+ ]
+</textarea>
+
+<script>
+ var mathematicaEditor = CodeMirror.fromTextArea(document.getElementById('mathematicaCode'), {
+ mode: 'text/x-mathematica',
+ lineNumbers: true,
+ matchBrackets: true
+ });
+</script>
+
+<p><strong>MIME types defined:</strong> <code>text/x-mathematica</code> (Mathematica).</p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/mathematica/mathematica.js b/data/ext/editorText/codemirror/mode/mathematica/mathematica.js
new file mode 100644
index 000000000..5ae6f55cb
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mathematica/mathematica.js
@@ -0,0 +1,175 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Mathematica mode copyright (c) 2015 by Calin Barbat
+// Based on code by Patrick Scheibe (halirutan)
+// See: https://github.com/halirutan/Mathematica-Source-Highlighting/tree/master/src/lang-mma.js
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.defineMode('mathematica', function(_config, _parserConfig) {
+
+ // used pattern building blocks
+ var Identifier = '[a-zA-Z\\$][a-zA-Z0-9\\$]*';
+ var pBase = "(?:\\d+)";
+ var pFloat = "(?:\\.\\d+|\\d+\\.\\d*|\\d+)";
+ var pFloatBase = "(?:\\.\\w+|\\w+\\.\\w*|\\w+)";
+ var pPrecision = "(?:`(?:`?"+pFloat+")?)";
+
+ // regular expressions
+ var reBaseForm = new RegExp('(?:'+pBase+'(?:\\^\\^'+pFloatBase+pPrecision+'?(?:\\*\\^[+-]?\\d+)?))');
+ var reFloatForm = new RegExp('(?:' + pFloat + pPrecision + '?(?:\\*\\^[+-]?\\d+)?)');
+ var reIdInContext = new RegExp('(?:`?)(?:' + Identifier + ')(?:`(?:' + Identifier + '))*(?:`?)');
+
+ function tokenBase(stream, state) {
+ var ch;
+
+ // get next character
+ ch = stream.next();
+
+ // string
+ if (ch === '"') {
+ state.tokenize = tokenString;
+ return state.tokenize(stream, state);
+ }
+
+ // comment
+ if (ch === '(') {
+ if (stream.eat('*')) {
+ state.commentLevel++;
+ state.tokenize = tokenComment;
+ return state.tokenize(stream, state);
+ }
+ }
+
+ // go back one character
+ stream.backUp(1);
+
+ // look for numbers
+ // Numbers in a baseform
+ if (stream.match(reBaseForm, true, false)) {
+ return 'number';
+ }
+
+ // Mathematica numbers. Floats (1.2, .2, 1.) can have optionally a precision (`float) or an accuracy definition
+ // (``float). Note: while 1.2` is possible 1.2`` is not. At the end an exponent (float*^+12) can follow.
+ if (stream.match(reFloatForm, true, false)) {
+ return 'number';
+ }
+
+ /* In[23] and Out[34] */
+ if (stream.match(/(?:In|Out)\[[0-9]*\]/, true, false)) {
+ return 'atom';
+ }
+
+ // usage
+ if (stream.match(/([a-zA-Z\$]+(?:`?[a-zA-Z0-9\$])*::usage)/, true, false)) {
+ return 'meta';
+ }
+
+ // message
+ if (stream.match(/([a-zA-Z\$]+(?:`?[a-zA-Z0-9\$])*::[a-zA-Z\$][a-zA-Z0-9\$]*):?/, true, false)) {
+ return 'string-2';
+ }
+
+ // this makes a look-ahead match for something like variable:{_Integer}
+ // the match is then forwarded to the mma-patterns tokenizer.
+ if (stream.match(/([a-zA-Z\$][a-zA-Z0-9\$]*\s*:)(?:(?:[a-zA-Z\$][a-zA-Z0-9\$]*)|(?:[^:=>~@\^\&\*\)\[\]'\?,\|])).*/, true, false)) {
+ return 'variable-2';
+ }
+
+ // catch variables which are used together with Blank (_), BlankSequence (__) or BlankNullSequence (___)
+ // Cannot start with a number, but can have numbers at any other position. Examples
+ // blub__Integer, a1_, b34_Integer32
+ if (stream.match(/[a-zA-Z\$][a-zA-Z0-9\$]*_+[a-zA-Z\$][a-zA-Z0-9\$]*/, true, false)) {
+ return 'variable-2';
+ }
+ if (stream.match(/[a-zA-Z\$][a-zA-Z0-9\$]*_+/, true, false)) {
+ return 'variable-2';
+ }
+ if (stream.match(/_+[a-zA-Z\$][a-zA-Z0-9\$]*/, true, false)) {
+ return 'variable-2';
+ }
+
+ // Named characters in Mathematica, like \[Gamma].
+ if (stream.match(/\\\[[a-zA-Z\$][a-zA-Z0-9\$]*\]/, true, false)) {
+ return 'variable-3';
+ }
+
+ // Match all braces separately
+ if (stream.match(/(?:\[|\]|{|}|\(|\))/, true, false)) {
+ return 'bracket';
+ }
+
+ // Catch Slots (#, ##, #3, ##9 and the V10 named slots #name). I have never seen someone using more than one digit after #, so we match
+ // only one.
+ if (stream.match(/(?:#[a-zA-Z\$][a-zA-Z0-9\$]*|#+[0-9]?)/, true, false)) {
+ return 'variable-2';
+ }
+
+ // Literals like variables, keywords, functions
+ if (stream.match(reIdInContext, true, false)) {
+ return 'keyword';
+ }
+
+ // operators. Note that operators like @@ or /; are matched separately for each symbol.
+ if (stream.match(/(?:\\|\+|\-|\*|\/|,|;|\.|:|@|~|=|>|<|&|\||_|`|'|\^|\?|!|%)/, true, false)) {
+ return 'operator';
+ }
+
+ // everything else is an error
+ return 'error';
+ }
+
+ function tokenString(stream, state) {
+ var next, end = false, escaped = false;
+ while ((next = stream.next()) != null) {
+ if (next === '"' && !escaped) {
+ end = true;
+ break;
+ }
+ escaped = !escaped && next === '\\';
+ }
+ if (end && !escaped) {
+ state.tokenize = tokenBase;
+ }
+ return 'string';
+ };
+
+ function tokenComment(stream, state) {
+ var prev, next;
+ while(state.commentLevel > 0 && (next = stream.next()) != null) {
+ if (prev === '(' && next === '*') state.commentLevel++;
+ if (prev === '*' && next === ')') state.commentLevel--;
+ prev = next;
+ }
+ if (state.commentLevel <= 0) {
+ state.tokenize = tokenBase;
+ }
+ return 'comment';
+ }
+
+ return {
+ startState: function() {return {tokenize: tokenBase, commentLevel: 0};},
+ token: function(stream, state) {
+ if (stream.eatSpace()) return null;
+ return state.tokenize(stream, state);
+ },
+ blockCommentStart: "(*",
+ blockCommentEnd: "*)"
+ };
+});
+
+CodeMirror.defineMIME('text/x-mathematica', {
+ name: 'mathematica'
+});
+
+});
diff --git a/data/ext/editorText/codemirror/mode/meta.js b/data/ext/editorText/codemirror/mode/meta.js
index 55a7d9654..7af51c1ec 100644
--- a/data/ext/editorText/codemirror/mode/meta.js
+++ b/data/ext/editorText/codemirror/mode/meta.js
@@ -1,97 +1,197 @@
-CodeMirror.modeInfo = [
- {name: 'APL', mime: 'text/apl', mode: 'apl'},
- {name: 'Asterisk', mime: 'text/x-asterisk', mode: 'asterisk'},
- {name: 'C', mime: 'text/x-csrc', mode: 'clike'},
- {name: 'C++', mime: 'text/x-c++src', mode: 'clike'},
- {name: 'Cobol', mime: 'text/x-cobol', mode: 'cobol'},
- {name: 'Java', mime: 'text/x-java', mode: 'clike'},
- {name: 'C#', mime: 'text/x-csharp', mode: 'clike'},
- {name: 'Scala', mime: 'text/x-scala', mode: 'clike'},
- {name: 'Clojure', mime: 'text/x-clojure', mode: 'clojure'},
- {name: 'CoffeeScript', mime: 'text/x-coffeescript', mode: 'coffeescript'},
- {name: 'Common Lisp', mime: 'text/x-common-lisp', mode: 'commonlisp'},
- {name: 'CSS', mime: 'text/css', mode: 'css'},
- {name: 'D', mime: 'text/x-d', mode: 'd'},
- {name: 'diff', mime: 'text/x-diff', mode: 'diff'},
- {name: 'DTD', mime: 'application/xml-dtd', mode: 'dtd'},
- {name: 'Dylan', mime: 'text/x-dylan', mode: 'dylan'},
- {name: 'ECL', mime: 'text/x-ecl', mode: 'ecl'},
- {name: 'Eiffel', mime: 'text/x-eiffel', mode: 'eiffel'},
- {name: 'Erlang', mime: 'text/x-erlang', mode: 'erlang'},
- {name: 'Fortran', mime: 'text/x-fortran', mode: 'fortran'},
- {name: 'F#', mime: 'text/x-fsharp', mode: 'mllike'},
- {name: 'Gas', mime: 'text/x-gas', mode: 'gas'},
- {name: 'Gherkin', mime: 'text/x-feature', mode: 'gherkin'},
- {name: 'GitHub Flavored Markdown', mime: 'text/x-gfm', mode: 'gfm'},
- {name: 'Go', mime: 'text/x-go', mode: 'go'},
- {name: 'Groovy', mime: 'text/x-groovy', mode: 'groovy'},
- {name: 'HAML', mime: 'text/x-haml', mode: 'haml'},
- {name: 'Haskell', mime: 'text/x-haskell', mode: 'haskell'},
- {name: 'Haxe', mime: 'text/x-haxe', mode: 'haxe'},
- {name: 'ASP.NET', mime: 'application/x-aspx', mode: 'htmlembedded'},
- {name: 'Embedded Javascript', mime: 'application/x-ejs', mode: 'htmlembedded'},
- {name: 'JavaServer Pages', mime: 'application/x-jsp', mode: 'htmlembedded'},
- {name: 'HTML', mime: 'text/html', mode: 'htmlmixed'},
- {name: 'HTTP', mime: 'message/http', mode: 'http'},
- {name: 'Jade', mime: 'text/x-jade', mode: 'jade'},
- {name: 'JavaScript', mime: 'text/javascript', mode: 'javascript'},
- {name: 'JSON', mime: 'application/x-json', mode: 'javascript'},
- {name: 'JSON', mime: 'application/json', mode: 'javascript'},
- {name: 'JSON-LD', mime: 'application/ld+json', mode: 'javascript'},
- {name: 'TypeScript', mime: 'application/typescript', mode: 'javascript'},
- {name: 'Jinja2', mime: null, mode: 'jinja2'},
- {name: 'Julia', mime: 'text/x-julia', mode: 'julia'},
- {name: 'LESS', mime: 'text/x-less', mode: 'less'},
- {name: 'LiveScript', mime: 'text/x-livescript', mode: 'livescript'},
- {name: 'Lua', mime: 'text/x-lua', mode: 'lua'},
- {name: 'Markdown (GitHub-flavour)', mime: 'text/x-markdown', mode: 'markdown'},
- {name: 'mIRC', mime: 'text/mirc', mode: 'mirc'},
- {name: 'Nginx', mime: 'text/x-nginx-conf', mode: 'nginx'},
- {name: 'NTriples', mime: 'text/n-triples', mode: 'ntriples'},
- {name: 'OCaml', mime: 'text/x-ocaml', mode: 'mllike'},
- {name: 'Octave', mime: 'text/x-octave', mode: 'octave'},
- {name: 'Pascal', mime: 'text/x-pascal', mode: 'pascal'},
- {name: 'PEG.js', mime: null, mode: 'pegjs'},
- {name: 'Perl', mime: 'text/x-perl', mode: 'perl'},
- {name: 'PHP', mime: 'text/x-php', mode: 'php'},
- {name: 'PHP(HTML)', mime: 'application/x-httpd-php', mode: 'php'},
- {name: 'Pig', mime: 'text/x-pig', mode: 'pig'},
- {name: 'Plain Text', mime: 'text/plain', mode: 'null'},
- {name: 'Properties files', mime: 'text/x-properties', mode: 'properties'},
- {name: 'Python', mime: 'text/x-python', mode: 'python'},
- {name: 'Puppet', mime: 'text/x-puppet', mode: 'puppet'},
- {name: 'Cython', mime: 'text/x-cython', mode: 'python'},
- {name: 'R', mime: 'text/x-rsrc', mode: 'r'},
- {name: 'reStructuredText', mime: 'text/x-rst', mode: 'rst'},
- {name: 'Ruby', mime: 'text/x-ruby', mode: 'ruby'},
- {name: 'Rust', mime: 'text/x-rustsrc', mode: 'rust'},
- {name: 'Sass', mime: 'text/x-sass', mode: 'sass'},
- {name: 'Scheme', mime: 'text/x-scheme', mode: 'scheme'},
- {name: 'SCSS', mime: 'text/x-scss', mode: 'css'},
- {name: 'Shell', mime: 'text/x-sh', mode: 'shell'},
- {name: 'Sieve', mime: 'application/sieve', mode: 'sieve'},
- {name: 'Smalltalk', mime: 'text/x-stsrc', mode: 'smalltalk'},
- {name: 'Smarty', mime: 'text/x-smarty', mode: 'smarty'},
- {name: 'SmartyMixed', mime: 'text/x-smarty', mode: 'smartymixed'},
- {name: 'Solr', mime: 'text/x-solr', mode: 'solr'},
- {name: 'SPARQL', mime: 'application/x-sparql-query', mode: 'sparql'},
- {name: 'SQL', mime: 'text/x-sql', mode: 'sql'},
- {name: 'MariaDB', mime: 'text/x-mariadb', mode: 'sql'},
- {name: 'sTeX', mime: 'text/x-stex', mode: 'stex'},
- {name: 'LaTeX', mime: 'text/x-latex', mode: 'stex'},
- {name: 'SystemVerilog', mime: 'text/x-systemverilog', mode: 'verilog'},
- {name: 'Tcl', mime: 'text/x-tcl', mode: 'tcl'},
- {name: 'TiddlyWiki ', mime: 'text/x-tiddlywiki', mode: 'tiddlywiki'},
- {name: 'Tiki wiki', mime: 'text/tiki', mode: 'tiki'},
- {name: 'TOML', mime: 'text/x-toml', mode: 'toml'},
- {name: 'Turtle', mime: 'text/turtle', mode: 'turtle'},
- {name: 'VB.NET', mime: 'text/x-vb', mode: 'vb'},
- {name: 'VBScript', mime: 'text/vbscript', mode: 'vbscript'},
- {name: 'Velocity', mime: 'text/velocity', mode: 'velocity'},
- {name: 'Verilog', mime: 'text/x-verilog', mode: 'verilog'},
- {name: 'XML', mime: 'application/xml', mode: 'xml'},
- {name: 'HTML', mime: 'text/html', mode: 'xml'},
- {name: 'XQuery', mime: 'application/xquery', mode: 'xquery'},
- {name: 'YAML', mime: 'text/x-yaml', mode: 'yaml'},
- {name: 'Z80', mime: 'text/x-z80', mode: 'z80'}
-];
+// 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";
+
+ 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: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]},
+ {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i},
+ {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]},
+ {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"]},
+ {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: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
+ {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"]},
+ {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
+ {name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
+ {name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
+ {name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
+ {name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"]},
+ {name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
+ {name: "Django", mime: "text/x-django", mode: "django"},
+ {name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile", file: /^Dockerfile$/},
+ {name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
+ {name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
+ {name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"},
+ {name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
+ {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
+ {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]},
+ {name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
+ {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
+ {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
+ {name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]},
+ {name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
+ {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
+ {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
+ {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
+ {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
+ {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
+ {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
+ {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy"]},
+ {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
+ {name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
+ {name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
+ {name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
+ {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
+ {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]},
+ {name: "HTTP", mime: "message/http", mode: "http"},
+ {name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
+ {name: "Jade", mime: "text/x-jade", mode: "jade", ext: ["jade"]},
+ {name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
+ {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
+ {name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
+ mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
+ {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
+ {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
+ {name: "Jinja2", mime: "null", mode: "jinja2"},
+ {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
+ {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
+ {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
+ {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
+ {name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
+ {name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]},
+ {name: "mIRC", mime: "text/mirc", mode: "mirc"},
+ {name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
+ {name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb"]},
+ {name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
+ {name: "MUMPS", mime: "text/x-mumps", mode: "mumps"},
+ {name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
+ {name: "MySQL", mime: "text/x-mysql", mode: "sql"},
+ {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i},
+ {name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]},
+ {name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]},
+ {name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"]},
+ {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
+ {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
+ {name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]},
+ {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
+ {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]},
+ {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
+ {name: "PHP", mime: "application/x-httpd-php", mode: "php", ext: ["php", "php3", "php4", "php5", "phtml"]},
+ {name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]},
+ {name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
+ {name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]},
+ {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
+ {name: "Python", mime: "text/x-python", mode: "python", ext: ["py", "pyw"]},
+ {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
+ {name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
+ {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"], alias: ["rscript"]},
+ {name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]},
+ {name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"},
+ {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]},
+ {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]},
+ {name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
+ {name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
+ {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
+ {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
+ {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
+ {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/},
+ {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]},
+ {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]},
+ {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
+ {name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
+ {name: "Solr", mime: "text/x-solr", mode: "solr"},
+ {name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]},
+ {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]},
+ {name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]},
+ {name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
+ {name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]},
+ {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]},
+ {name: "MariaDB", mime: "text/x-mariadb", mode: "sql"},
+ {name: "sTeX", mime: "text/x-stex", mode: "stex"},
+ {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]},
+ {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]},
+ {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
+ {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]},
+ {name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
+ {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: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"]},
+ {name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"]},
+ {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
+ {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]},
+ {name: "Twig", mime: "text/x-twig", mode: "twig"},
+ {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
+ {name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]},
+ {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
+ {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
+ {name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]},
+ {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"], alias: ["rss", "wsdl", "xsd"]},
+ {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
+ {name: "YAML", mime: "text/x-yaml", mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]},
+ {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
+ {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
+ {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
+ {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}
+ ];
+ // Ensure all modes have a mime property for backwards compatibility
+ for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
+ var info = CodeMirror.modeInfo[i];
+ if (info.mimes) info.mime = info.mimes[0];
+ }
+
+ CodeMirror.findModeByMIME = function(mime) {
+ mime = mime.toLowerCase();
+ for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
+ var info = CodeMirror.modeInfo[i];
+ if (info.mime == mime) return info;
+ if (info.mimes) for (var j = 0; j < info.mimes.length; j++)
+ if (info.mimes[j] == mime) return info;
+ }
+ };
+
+ CodeMirror.findModeByExtension = function(ext) {
+ for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
+ var info = CodeMirror.modeInfo[i];
+ if (info.ext) for (var j = 0; j < info.ext.length; j++)
+ if (info.ext[j] == ext) return info;
+ }
+ };
+
+ CodeMirror.findModeByFileName = function(filename) {
+ for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
+ var info = CodeMirror.modeInfo[i];
+ if (info.file && info.file.test(filename)) return info;
+ }
+ var dot = filename.lastIndexOf(".");
+ var ext = dot > -1 && filename.substring(dot + 1, filename.length);
+ if (ext) return CodeMirror.findModeByExtension(ext);
+ };
+
+ CodeMirror.findModeByName = function(name) {
+ name = name.toLowerCase();
+ for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
+ var info = CodeMirror.modeInfo[i];
+ if (info.name.toLowerCase() == name) return info;
+ if (info.alias) for (var j = 0; j < info.alias.length; j++)
+ if (info.alias[j].toLowerCase() == name) return info;
+ }
+ };
+});
diff --git a/data/ext/editorText/codemirror/mode/mirc/index.html b/data/ext/editorText/codemirror/mode/mirc/index.html
index c346f1c7e..fd2f34e4b 100644
--- a/data/ext/editorText/codemirror/mode/mirc/index.html
+++ b/data/ext/editorText/codemirror/mode/mirc/index.html
@@ -10,12 +10,12 @@
<script src="mirc.js"></script>
<style>.CodeMirror {border: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/mirc/mirc.js b/data/ext/editorText/codemirror/mode/mirc/mirc.js
index fc88bc56f..f0d5c6ad5 100644
--- a/data/ext/editorText/codemirror/mode/mirc/mirc.js
+++ b/data/ext/editorText/codemirror/mode/mirc/mirc.js
@@ -1,4 +1,18 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
//mIRC mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMIME("text/mirc", "mirc");
CodeMirror.defineMode("mirc", function() {
function parseWords(str) {
@@ -175,3 +189,5 @@ CodeMirror.defineMode("mirc", function() {
}
};
});
+
+});
diff --git a/data/ext/editorText/codemirror/mode/mllike/index.html b/data/ext/editorText/codemirror/mode/mllike/index.html
index 67bfef858..5923af8f8 100644
--- a/data/ext/editorText/codemirror/mode/mllike/index.html
+++ b/data/ext/editorText/codemirror/mode/mllike/index.html
@@ -12,12 +12,12 @@
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/mllike/mllike.js b/data/ext/editorText/codemirror/mode/mllike/mllike.js
index 1d64789a1..bf0b8a674 100644
--- a/data/ext/editorText/codemirror/mode/mllike/mllike.js
+++ b/data/ext/editorText/codemirror/mode/mllike/mllike.js
@@ -1,5 +1,17 @@
-CodeMirror.defineMode('mllike', function(_config, parserConfig) {
+// 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";
+CodeMirror.defineMode('mllike', function(_config, parserConfig) {
var words = {
'let': 'keyword',
'rec': 'keyword',
@@ -73,7 +85,7 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) {
}
stream.eatWhile(/\w/);
var cur = stream.current();
- return words[cur] || 'variable';
+ return words.hasOwnProperty(cur) ? words[cur] : 'variable';
}
function tokenString(stream, state) {
@@ -189,3 +201,5 @@ CodeMirror.defineMIME('text/x-fsharp', {
},
slashComments: true
});
+
+});
diff --git a/data/ext/editorText/codemirror/mode/modelica/index.html b/data/ext/editorText/codemirror/mode/modelica/index.html
new file mode 100644
index 000000000..408c3b17e
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/modelica/index.html
@@ -0,0 +1,67 @@
+<!doctype html>
+
+<title>CodeMirror: Modelica mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/edit/matchbrackets.js"></script>
+<link rel="stylesheet" href="../../addon/hint/show-hint.css">
+<script src="../../addon/hint/show-hint.js"></script>
+<script src="modelica.js"></script>
+<style>.CodeMirror {border: 2px inset #dee;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Modelica</a>
+ </ul>
+</div>
+
+<article>
+<h2>Modelica mode</h2>
+
+<div><textarea id="modelica">
+model BouncingBall
+ parameter Real e = 0.7;
+ parameter Real g = 9.81;
+ Real h(start=1);
+ Real v;
+ Boolean flying(start=true);
+ Boolean impact;
+ Real v_new;
+equation
+ impact = h <= 0.0;
+ der(v) = if flying then -g else 0;
+ der(h) = v;
+ when {h <= 0.0 and v <= 0.0, impact} then
+ v_new = if edge(impact) then -e*pre(v) else 0;
+ flying = v_new > 0;
+ reinit(v, v_new);
+ end when;
+ annotation (uses(Modelica(version="3.2")));
+end BouncingBall;
+</textarea></div>
+
+ <script>
+ var modelicaEditor = CodeMirror.fromTextArea(document.getElementById("modelica"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-modelica"
+ });
+ var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
+ CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
+ </script>
+
+ <p>Simple mode that tries to handle Modelica as well as it can.</p>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-modelica</code>
+ (Modlica code).</p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/modelica/modelica.js b/data/ext/editorText/codemirror/mode/modelica/modelica.js
new file mode 100644
index 000000000..77ec7a3c1
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/modelica/modelica.js
@@ -0,0 +1,245 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Modelica support for CodeMirror, copyright (c) by Lennart Ochel
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})
+
+(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineMode("modelica", function(config, parserConfig) {
+
+ var indentUnit = config.indentUnit;
+ var keywords = parserConfig.keywords || {};
+ var builtin = parserConfig.builtin || {};
+ var atoms = parserConfig.atoms || {};
+
+ var isSingleOperatorChar = /[;=\(:\),{}.*<>+\-\/^\[\]]/;
+ var isDoubleOperatorChar = /(:=|<=|>=|==|<>|\.\+|\.\-|\.\*|\.\/|\.\^)/;
+ var isDigit = /[0-9]/;
+ var isNonDigit = /[_a-zA-Z]/;
+
+ function tokenLineComment(stream, state) {
+ stream.skipToEnd();
+ state.tokenize = null;
+ return "comment";
+ }
+
+ function tokenBlockComment(stream, state) {
+ var maybeEnd = false, ch;
+ while (ch = stream.next()) {
+ if (maybeEnd && ch == "/") {
+ state.tokenize = null;
+ break;
+ }
+ maybeEnd = (ch == "*");
+ }
+ return "comment";
+ }
+
+ function tokenString(stream, state) {
+ var escaped = false, ch;
+ while ((ch = stream.next()) != null) {
+ if (ch == '"' && !escaped) {
+ state.tokenize = null;
+ state.sol = false;
+ break;
+ }
+ escaped = !escaped && ch == "\\";
+ }
+
+ return "string";
+ }
+
+ function tokenIdent(stream, state) {
+ stream.eatWhile(isDigit);
+ while (stream.eat(isDigit) || stream.eat(isNonDigit)) { }
+
+
+ var cur = stream.current();
+
+ if(state.sol && (cur == "package" || cur == "model" || cur == "when" || cur == "connector")) state.level++;
+ else if(state.sol && cur == "end" && state.level > 0) state.level--;
+
+ state.tokenize = null;
+ state.sol = false;
+
+ if (keywords.propertyIsEnumerable(cur)) return "keyword";
+ else if (builtin.propertyIsEnumerable(cur)) return "builtin";
+ else if (atoms.propertyIsEnumerable(cur)) return "atom";
+ else return "variable";
+ }
+
+ function tokenQIdent(stream, state) {
+ while (stream.eat(/[^']/)) { }
+
+ state.tokenize = null;
+ state.sol = false;
+
+ if(stream.eat("'"))
+ return "variable";
+ else
+ return "error";
+ }
+
+ function tokenUnsignedNuber(stream, state) {
+ stream.eatWhile(isDigit);
+ if (stream.eat('.')) {
+ stream.eatWhile(isDigit);
+ }
+ if (stream.eat('e') || stream.eat('E')) {
+ if (!stream.eat('-'))
+ stream.eat('+');
+ stream.eatWhile(isDigit);
+ }
+
+ state.tokenize = null;
+ state.sol = false;
+ return "number";
+ }
+
+ // Interface
+ return {
+ startState: function() {
+ return {
+ tokenize: null,
+ level: 0,
+ sol: true
+ };
+ },
+
+ token: function(stream, state) {
+ if(state.tokenize != null) {
+ return state.tokenize(stream, state);
+ }
+
+ if(stream.sol()) {
+ state.sol = true;
+ }
+
+ // WHITESPACE
+ if(stream.eatSpace()) {
+ state.tokenize = null;
+ return null;
+ }
+
+ var ch = stream.next();
+
+ // LINECOMMENT
+ if(ch == '/' && stream.eat('/')) {
+ state.tokenize = tokenLineComment;
+ }
+ // BLOCKCOMMENT
+ else if(ch == '/' && stream.eat('*')) {
+ state.tokenize = tokenBlockComment;
+ }
+ // TWO SYMBOL TOKENS
+ else if(isDoubleOperatorChar.test(ch+stream.peek())) {
+ stream.next();
+ state.tokenize = null;
+ return "operator";
+ }
+ // SINGLE SYMBOL TOKENS
+ else if(isSingleOperatorChar.test(ch)) {
+ state.tokenize = null;
+ return "operator";
+ }
+ // IDENT
+ else if(isNonDigit.test(ch)) {
+ state.tokenize = tokenIdent;
+ }
+ // Q-IDENT
+ else if(ch == "'" && stream.peek() && stream.peek() != "'") {
+ state.tokenize = tokenQIdent;
+ }
+ // STRING
+ else if(ch == '"') {
+ state.tokenize = tokenString;
+ }
+ // UNSIGNED_NUBER
+ else if(isDigit.test(ch)) {
+ state.tokenize = tokenUnsignedNuber;
+ }
+ // ERROR
+ else {
+ state.tokenize = null;
+ return "error";
+ }
+
+ return state.tokenize(stream, state);
+ },
+
+ indent: function(state, textAfter) {
+ if (state.tokenize != null) return CodeMirror.Pass;
+
+ var level = state.level;
+ if(/(algorithm)/.test(textAfter)) level--;
+ if(/(equation)/.test(textAfter)) level--;
+ if(/(initial algorithm)/.test(textAfter)) level--;
+ if(/(initial equation)/.test(textAfter)) level--;
+ if(/(end)/.test(textAfter)) level--;
+
+ if(level > 0)
+ return indentUnit*level;
+ else
+ return 0;
+ },
+
+ blockCommentStart: "/*",
+ blockCommentEnd: "*/",
+ lineComment: "//"
+ };
+ });
+
+ function words(str) {
+ var obj = {}, words = str.split(" ");
+ for (var i=0; i<words.length; ++i)
+ obj[words[i]] = true;
+ return obj;
+ }
+
+ var modelicaKeywords = "algorithm and annotation assert block break class connect connector constant constrainedby der discrete each else elseif elsewhen encapsulated end enumeration equation expandable extends external false final flow for function if import impure in initial inner input loop model not operator or outer output package parameter partial protected public pure record redeclare replaceable return stream then true type when while within";
+ var modelicaBuiltin = "abs acos actualStream asin atan atan2 cardinality ceil cos cosh delay div edge exp floor getInstanceName homotopy inStream integer log log10 mod pre reinit rem semiLinear sign sin sinh spatialDistribution sqrt tan tanh";
+ var modelicaAtoms = "Real Boolean Integer String";
+
+ function def(mimes, mode) {
+ if (typeof mimes == "string")
+ mimes = [mimes];
+
+ var words = [];
+
+ function add(obj) {
+ if (obj)
+ for (var prop in obj)
+ if (obj.hasOwnProperty(prop))
+ words.push(prop);
+ }
+
+ add(mode.keywords);
+ add(mode.builtin);
+ add(mode.atoms);
+
+ if (words.length) {
+ mode.helperType = mimes[0];
+ CodeMirror.registerHelper("hintWords", mimes[0], words);
+ }
+
+ for (var i=0; i<mimes.length; ++i)
+ CodeMirror.defineMIME(mimes[i], mode);
+ }
+
+ def(["text/x-modelica"], {
+ name: "modelica",
+ keywords: words(modelicaKeywords),
+ builtin: words(modelicaBuiltin),
+ atoms: words(modelicaAtoms)
+ });
+});
diff --git a/data/ext/editorText/codemirror/mode/mscgen/index.html b/data/ext/editorText/codemirror/mode/mscgen/index.html
new file mode 100644
index 000000000..0517825fb
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mscgen/index.html
@@ -0,0 +1,65 @@
+<!doctype html>
+
+<title>CodeMirror: Oz mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="mscgen.js"></script>
+<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">MscGen</a>
+ </ul>
+</div>
+
+<article>
+<h2>MscGen mode</h2>
+
+<div><textarea id="code">
+# Sample mscgen program
+# See http://www.mcternan.me.uk/mscgen or
+# https://sverweij.github.io/mscgen_js for more samples
+
+msc {
+ # options
+ hscale="1.2";
+
+ # entities/ lifelines
+ a [label="Entity A"],
+ b [label="Entity B", linecolor="red", arclinecolor="red", textbgcolor="pink"],
+ c [label="Entity C"];
+
+ # arcs/ messages
+ a => c [label="doSomething(args)"];
+ b => c [label="doSomething(args)"];
+ c >> * [label="everyone asked me", arcskip="1"];
+ c =>> c [label="doing something"];
+ c -x * [label="report back", arcskip="1"];
+ |||;
+ --- [label="shows's over, however ..."];
+ b => a [label="did you see c doing something?"];
+ a -> b [label="nope"];
+ b :> a [label="shall we ask again?"];
+ a => b [label="naah"];
+ ...;
+}
+</textarea></div>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "mscgen",
+ });
+ </script>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-mscgen</code></p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/mscgen/index_msgenny.html b/data/ext/editorText/codemirror/mode/mscgen/index_msgenny.html
new file mode 100644
index 000000000..1664f3051
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mscgen/index_msgenny.html
@@ -0,0 +1,44 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>CodeMirror: msgenny mode</title>
+ <link rel="stylesheet" href="../../lib/codemirror.css">
+ <script src="../../lib/codemirror.js"></script>
+ <script src="mscgen.js"></script>
+ <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+ </head>
+ <body>
+ <h1>CodeMirror: msgenny mode</h1>
+
+<div><textarea id="code">
+# Sample msgenny program
+# https://sverweij.github.io/mscgen_js for more samples
+
+a -> b : a -> b (signal);
+a => b : a => b (method);
+b >> a : b >> a (return value);
+a =>> b : a =>> b (callback);
+a -x b : a -x b (lost);
+a :> b : a :> b (emphasis);
+a .. b : a .. b (dotted);
+a -- b : "a -- b straight line";
+a note a : a note a\n(note),
+b box b : b box b\n(action);
+a rbox a : a rbox a\n(reference),
+b abox b : b abox b\n(state/ condition);
+||| : ||| (empty row);
+... : ... (omitted row);
+--- : --- (comment);
+</textarea></div>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "msgenny",
+ });
+ </script>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-msgenny</code></p>
+ </body>
+</html>
diff --git a/data/ext/editorText/codemirror/mode/mscgen/index_xu.html b/data/ext/editorText/codemirror/mode/mscgen/index_xu.html
new file mode 100644
index 000000000..2f7bf9ec0
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mscgen/index_xu.html
@@ -0,0 +1,70 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>CodeMirror: xu mode</title>
+ <link rel="stylesheet" href="../../lib/codemirror.css">
+ <script src="../../lib/codemirror.js"></script>
+ <script src="mscgen.js"></script>
+ <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+ </head>
+ <body>
+ <h1>CodeMirror: xù mode</h1>
+
+<div><textarea id="code">
+# test50 - expansions to mscgen to support inline expressions
+# for now in a separate language: xù
+msc {
+
+ hscale="0.8",
+ width="700";
+
+ a,
+ b [label="change store"],
+ c,
+ d [label="necro queue"],
+ e [label="natalis queue"],
+ f;
+
+ a =>> b [label="get change list()"];
+ a alt f [label="changes found"] { /* alt is a xu specific keyword*/
+ b >> a [label="list of changes"];
+ a =>> c [label="cull old stuff (list of changes)"];
+ b loop e [label="for each change"] { // loop is xu specific as well...
+ /*
+ * Here interesting stuff happens.
+ * TBD
+ */
+ c =>> b [label="get change()"];
+ b >> c [label="change"];
+ c alt e [label="change too old"] {
+ c =>> d [label="queue(change)"];
+ --- [label="change newer than latest run"];
+ c =>> e [label="queue(change)"];
+ --- [label="all other cases"];
+ ||| [label="leave well alone"];
+ };
+ };
+
+
+ c >> a [label="done
+ processing"];
+
+ /* shucks! nothing found ...*/
+ --- [label="nothing found"];
+ b >> a [label="nothing"];
+ a note a [label="silent exit"];
+ };
+}
+</textarea></div>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "xu",
+ });
+ </script>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-xu</code></p>
+ </body>
+</html>
diff --git a/data/ext/editorText/codemirror/mode/mscgen/mscgen.js b/data/ext/editorText/codemirror/mode/mscgen/mscgen.js
new file mode 100644
index 000000000..3cf4eb089
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mscgen/mscgen.js
@@ -0,0 +1,169 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// mode(s) for the sequence chart dsl's mscgen, xù and msgenny
+// For more information on mscgen, see the site of the original author:
+// http://www.mcternan.me.uk/mscgen
+//
+// This mode for mscgen and the two derivative languages were
+// originally made for use in the mscgen_js interpreter
+// (https://sverweij.github.io/mscgen_js)
+
+(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";
+
+ var languages = {
+ mscgen: {
+ "keywords" : ["msc"],
+ "options" : ["hscale", "width", "arcgradient", "wordwraparcs"],
+ "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"],
+ "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists
+ "arcsWords" : ["note", "abox", "rbox", "box"],
+ "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
+ "singlecomment" : ["//", "#"],
+ "operators" : ["="]
+ },
+ xu: {
+ "keywords" : ["msc"],
+ "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"],
+ "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"],
+ "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists
+ "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
+ "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
+ "singlecomment" : ["//", "#"],
+ "operators" : ["="]
+ },
+ msgenny: {
+ "keywords" : null,
+ "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"],
+ "attributes" : null,
+ "brackets" : ["\\{", "\\}"],
+ "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
+ "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
+ "singlecomment" : ["//", "#"],
+ "operators" : ["="]
+ }
+ }
+
+ CodeMirror.defineMode("mscgen", function(_, modeConfig) {
+ var language = languages[modeConfig && modeConfig.language || "mscgen"]
+ return {
+ startState: startStateFn,
+ copyState: copyStateFn,
+ token: produceTokenFunction(language),
+ lineComment : "#",
+ blockCommentStart : "/*",
+ blockCommentEnd : "*/"
+ };
+ });
+
+ CodeMirror.defineMIME("text/x-mscgen", "mscgen");
+ CodeMirror.defineMIME("text/x-xu", {name: "mscgen", language: "xu"});
+ CodeMirror.defineMIME("text/x-msgenny", {name: "mscgen", language: "msgenny"});
+
+ function wordRegexpBoundary(pWords) {
+ return new RegExp("\\b((" + pWords.join(")|(") + "))\\b", "i");
+ }
+
+ function wordRegexp(pWords) {
+ return new RegExp("((" + pWords.join(")|(") + "))", "i");
+ }
+
+ function startStateFn() {
+ return {
+ inComment : false,
+ inString : false,
+ inAttributeList : false,
+ inScript : false
+ };
+ }
+
+ function copyStateFn(pState) {
+ return {
+ inComment : pState.inComment,
+ inString : pState.inString,
+ inAttributeList : pState.inAttributeList,
+ inScript : pState.inScript
+ };
+ }
+
+ function produceTokenFunction(pConfig) {
+
+ return function(pStream, pState) {
+ if (pStream.match(wordRegexp(pConfig.brackets), true, true)) {
+ return "bracket";
+ }
+ /* comments */
+ if (!pState.inComment) {
+ if (pStream.match(/\/\*[^\*\/]*/, true, true)) {
+ pState.inComment = true;
+ return "comment";
+ }
+ if (pStream.match(wordRegexp(pConfig.singlecomment), true, true)) {
+ pStream.skipToEnd();
+ return "comment";
+ }
+ }
+ if (pState.inComment) {
+ if (pStream.match(/[^\*\/]*\*\//, true, true))
+ pState.inComment = false;
+ else
+ pStream.skipToEnd();
+ return "comment";
+ }
+ /* strings */
+ if (!pState.inString && pStream.match(/\"(\\\"|[^\"])*/, true, true)) {
+ pState.inString = true;
+ return "string";
+ }
+ if (pState.inString) {
+ if (pStream.match(/[^\"]*\"/, true, true))
+ pState.inString = false;
+ else
+ pStream.skipToEnd();
+ return "string";
+ }
+ /* keywords & operators */
+ if (!!pConfig.keywords && pStream.match(wordRegexpBoundary(pConfig.keywords), true, true))
+ return "keyword";
+
+ if (pStream.match(wordRegexpBoundary(pConfig.options), true, true))
+ return "keyword";
+
+ if (pStream.match(wordRegexpBoundary(pConfig.arcsWords), true, true))
+ return "keyword";
+
+ if (pStream.match(wordRegexp(pConfig.arcsOthers), true, true))
+ return "keyword";
+
+ if (!!pConfig.operators && pStream.match(wordRegexp(pConfig.operators), true, true))
+ return "operator";
+
+ /* attribute lists */
+ if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match(/\[/, true, true)) {
+ pConfig.inAttributeList = true;
+ return "bracket";
+ }
+ if (pConfig.inAttributeList) {
+ if (pConfig.attributes !== null && pStream.match(wordRegexpBoundary(pConfig.attributes), true, true)) {
+ return "attribute";
+ }
+ if (pStream.match(/]/, true, true)) {
+ pConfig.inAttributeList = false;
+ return "bracket";
+ }
+ }
+
+ pStream.next();
+ return "base";
+ };
+ }
+
+});
diff --git a/data/ext/editorText/codemirror/mode/mscgen/mscgen_test.js b/data/ext/editorText/codemirror/mode/mscgen/mscgen_test.js
new file mode 100644
index 000000000..e319a3997
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mscgen/mscgen_test.js
@@ -0,0 +1,75 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function() {
+ var mode = CodeMirror.getMode({indentUnit: 2}, "mscgen");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
+
+ MT("empty chart",
+ "[keyword msc][bracket {]",
+ "[base ]",
+ "[bracket }]"
+ );
+
+ MT("comments",
+ "[comment // a single line comment]",
+ "[comment # another single line comment /* and */ ignored here]",
+ "[comment /* A multi-line comment even though it contains]",
+ "[comment msc keywords and \"quoted text\"*/]");
+
+ MT("strings",
+ "[string \"// a string\"]",
+ "[string \"a string running over]",
+ "[string two lines\"]",
+ "[string \"with \\\"escaped quote\"]"
+ );
+
+ MT("xù/ msgenny keywords classify as 'base'",
+ "[base watermark]",
+ "[base alt loop opt ref else break par seq assert]"
+ );
+
+ MT("mscgen options classify as keyword",
+ "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
+ );
+
+ MT("mscgen arcs classify as keyword",
+ "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
+ "[keyword |||...---]", "[keyword ..--==::]",
+ "[keyword ->]", "[keyword <-]", "[keyword <->]",
+ "[keyword =>]", "[keyword <=]", "[keyword <=>]",
+ "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
+ "[keyword >>]", "[keyword <<]", "[keyword <<>>]",
+ "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
+ "[keyword :>]", "[keyword <:]", "[keyword <:>]"
+ );
+
+ MT("within an attribute list, attributes classify as attribute",
+ "[bracket [[][attribute label]",
+ "[attribute id]","[attribute url]","[attribute idurl]",
+ "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]",
+ "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]",
+ "[attribute arcskip][bracket ]]]"
+ );
+
+ MT("outside an attribute list, attributes classify as base",
+ "[base label]",
+ "[base id]","[base url]","[base idurl]",
+ "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]",
+ "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]",
+ "[base arcskip]"
+ );
+
+ MT("a typical program",
+ "[comment # typical mscgen program]",
+ "[keyword msc][base ][bracket {]",
+ "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]",
+ "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]",
+ "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
+ "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",
+ "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]",
+ "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]",
+ "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]",
+ "[bracket }]"
+ );
+})();
diff --git a/data/ext/editorText/codemirror/mode/mscgen/msgenny_test.js b/data/ext/editorText/codemirror/mode/mscgen/msgenny_test.js
new file mode 100644
index 000000000..80173de08
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mscgen/msgenny_test.js
@@ -0,0 +1,71 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function() {
+ var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-msgenny");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "msgenny"); }
+
+ MT("comments",
+ "[comment // a single line comment]",
+ "[comment # another single line comment /* and */ ignored here]",
+ "[comment /* A multi-line comment even though it contains]",
+ "[comment msc keywords and \"quoted text\"*/]");
+
+ MT("strings",
+ "[string \"// a string\"]",
+ "[string \"a string running over]",
+ "[string two lines\"]",
+ "[string \"with \\\"escaped quote\"]"
+ );
+
+ MT("xù/ msgenny keywords classify as 'keyword'",
+ "[keyword watermark]",
+ "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]"
+ );
+
+ MT("mscgen options classify as keyword",
+ "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
+ );
+
+ MT("mscgen arcs classify as keyword",
+ "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
+ "[keyword |||...---]", "[keyword ..--==::]",
+ "[keyword ->]", "[keyword <-]", "[keyword <->]",
+ "[keyword =>]", "[keyword <=]", "[keyword <=>]",
+ "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
+ "[keyword >>]", "[keyword <<]", "[keyword <<>>]",
+ "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
+ "[keyword :>]", "[keyword <:]", "[keyword <:>]"
+ );
+
+ MT("within an attribute list, mscgen/ xù attributes classify as base",
+ "[base [[label]",
+ "[base idurl id url]",
+ "[base linecolor linecolour textcolor textcolour textbgcolor textbgcolour]",
+ "[base arclinecolor arclinecolour arctextcolor arctextcolour arctextbgcolor arctextbgcolour]",
+ "[base arcskip]]]"
+ );
+
+ MT("outside an attribute list, mscgen/ xù attributes classify as base",
+ "[base label]",
+ "[base idurl id url]",
+ "[base linecolor linecolour textcolor textcolour textbgcolor textbgcolour]",
+ "[base arclinecolor arclinecolour arctextcolor arctextcolour arctextbgcolor arctextbgcolour]",
+ "[base arcskip]"
+ );
+
+ MT("a typical program",
+ "[comment # typical msgenny program]",
+ "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]",
+ "[base a : ][string \"Entity A\"][base ,]",
+ "[base b : Entity B,]",
+ "[base c : Entity C;]",
+ "[base a ][keyword =>>][base b: ][string \"Hello entity B\"][base ;]",
+ "[base a ][keyword alt][base c][bracket {]",
+ "[base a ][keyword <<][base b: ][string \"Here's an answer dude!\"][base ;]",
+ "[keyword ---][base : ][string \"sorry, won't march - comm glitch\"]",
+ "[base a ][keyword x-][base b: ][string \"Here's an answer dude! (won't arrive...)\"][base ;]",
+ "[bracket }]",
+ "[base c ][keyword :>][base *: What about me?;]"
+ );
+})();
diff --git a/data/ext/editorText/codemirror/mode/mscgen/xu_test.js b/data/ext/editorText/codemirror/mode/mscgen/xu_test.js
new file mode 100644
index 000000000..f9a50f0af
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mscgen/xu_test.js
@@ -0,0 +1,75 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function() {
+ var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-xu");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "xu"); }
+
+ MT("empty chart",
+ "[keyword msc][bracket {]",
+ "[base ]",
+ "[bracket }]"
+ );
+
+ MT("comments",
+ "[comment // a single line comment]",
+ "[comment # another single line comment /* and */ ignored here]",
+ "[comment /* A multi-line comment even though it contains]",
+ "[comment msc keywords and \"quoted text\"*/]");
+
+ MT("strings",
+ "[string \"// a string\"]",
+ "[string \"a string running over]",
+ "[string two lines\"]",
+ "[string \"with \\\"escaped quote\"]"
+ );
+
+ MT("xù/ msgenny keywords classify as 'keyword'",
+ "[keyword watermark]",
+ "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]"
+ );
+
+ MT("mscgen options classify as keyword",
+ "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
+ );
+
+ MT("mscgen arcs classify as keyword",
+ "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
+ "[keyword |||...---]", "[keyword ..--==::]",
+ "[keyword ->]", "[keyword <-]", "[keyword <->]",
+ "[keyword =>]", "[keyword <=]", "[keyword <=>]",
+ "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
+ "[keyword >>]", "[keyword <<]", "[keyword <<>>]",
+ "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
+ "[keyword :>]", "[keyword <:]", "[keyword <:>]"
+ );
+
+ MT("within an attribute list, attributes classify as attribute",
+ "[bracket [[][attribute label]",
+ "[attribute id]","[attribute url]","[attribute idurl]",
+ "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]",
+ "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]",
+ "[attribute arcskip][bracket ]]]"
+ );
+
+ MT("outside an attribute list, attributes classify as base",
+ "[base label]",
+ "[base id]","[base url]","[base idurl]",
+ "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]",
+ "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]",
+ "[base arcskip]"
+ );
+
+ MT("a typical program",
+ "[comment # typical mscgen program]",
+ "[keyword msc][base ][bracket {]",
+ "[keyword wordwraparcs][operator =][string \"true\"][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]",
+ "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]",
+ "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
+ "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",
+ "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]",
+ "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]",
+ "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]",
+ "[bracket }]"
+ );
+})();
diff --git a/data/ext/editorText/codemirror/mode/mumps/index.html b/data/ext/editorText/codemirror/mode/mumps/index.html
new file mode 100644
index 000000000..bd1f69aef
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mumps/index.html
@@ -0,0 +1,85 @@
+<!doctype html>
+
+<title>CodeMirror: MUMPS mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="mumps.js"></script>
+<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">MUMPS</a>
+ </ul>
+</div>
+
+<article>
+<h2>MUMPS mode</h2>
+
+
+<div><textarea id="code" name="code">
+ ; Lloyd Milligan
+ ; 03-30-2015
+ ;
+ ; MUMPS support for Code Mirror - Excerpts below from routine ^XUS
+ ;
+CHECKAV(X1) ;Check A/V code return DUZ or Zero. (Called from XUSRB)
+ N %,%1,X,Y,IEN,DA,DIK
+ S IEN=0
+ ;Start CCOW
+ I $E(X1,1,7)="~~TOK~~" D Q:IEN>0 IEN
+ . I $E(X1,8,9)="~1" S IEN=$$CHKASH^XUSRB4($E(X1,8,255))
+ . I $E(X1,8,9)="~2" S IEN=$$CHKCCOW^XUSRB4($E(X1,8,255))
+ . Q
+ ;End CCOW
+ S X1=$$UP(X1) S:X1[":" XUTT=1,X1=$TR(X1,":")
+ S X=$P(X1,";") Q:X="^" -1 S:XUF %1="Access: "_X
+ Q:X'?1.20ANP 0
+ S X=$$EN^XUSHSH(X) I '$D(^VA(200,"A",X)) D LBAV Q 0
+ S %1="",IEN=$O(^VA(200,"A",X,0)),XUF(.3)=IEN D USER(IEN)
+ S X=$P(X1,";",2) S:XUF %1="Verify: "_X S X=$$EN^XUSHSH(X)
+ I $P(XUSER(1),"^",2)'=X D LBAV Q 0
+ I $G(XUFAC(1)) S DIK="^XUSEC(4,",DA=XUFAC(1) D ^DIK
+ Q IEN
+ ;
+ ; Spell out commands
+ ;
+SET2() ;EF. Return error code (also called from XUSRB)
+ NEW %,X
+ SET XUNOW=$$HTFM^XLFDT($H),DT=$P(XUNOW,".")
+ KILL DUZ,XUSER
+ SET (DUZ,DUZ(2))=0,(DUZ(0),DUZ("AG"),XUSER(0),XUSER(1),XUTT,%UCI)=""
+ SET %=$$INHIBIT^XUSRB() IF %>0 QUIT %
+ SET X=$G(^%ZIS(1,XUDEV,"XUS")),XU1=$G(^(1))
+ IF $L(X) FOR I=1:1:15 IF $L($P(X,U,I)) SET $P(XOPT,U,I)=$P(X,U,I)
+ SET DTIME=600
+ IF '$P(XOPT,U,11),$D(^%ZIS(1,XUDEV,90)),^(90)>2800000,^(90)'>DT QUIT 8
+ QUIT 0
+ ;
+ ; Spell out commands and functions
+ ;
+ IF $PIECE(XUSER(0),U,11),$PIECE(XUSER(0),U,11)'>DT QUIT 11 ;Terminated
+ IF $DATA(DUZ("ASH")) QUIT 0 ;If auto handle, Allow to sign-on p434
+ IF $PIECE(XUSER(0),U,7) QUIT 5 ;Disuser flag set
+ IF '$LENGTH($PIECE(XUSER(1),U,2)) QUIT 21 ;p419, p434
+ Q 0
+ ;
+ </textarea>
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ mode: "mumps",
+ lineNumbers: true,
+ lineWrapping: true
+ });
+ </script>
+
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/mumps/mumps.js b/data/ext/editorText/codemirror/mode/mumps/mumps.js
new file mode 100644
index 000000000..469f8c3d1
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/mumps/mumps.js
@@ -0,0 +1,148 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+/*
+ This MUMPS Language script was constructed using vbscript.js as a template.
+*/
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineMode("mumps", function() {
+ function wordRegexp(words) {
+ return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
+ }
+
+ var singleOperators = new RegExp("^[\\+\\-\\*/&#!_?\\\\<>=\\'\\[\\]]");
+ var doubleOperators = new RegExp("^(('=)|(<=)|(>=)|('>)|('<)|([[)|(]])|(^$))");
+ var singleDelimiters = new RegExp("^[\\.,:]");
+ var brackets = new RegExp("[()]");
+ var identifiers = new RegExp("^[%A-Za-z][A-Za-z0-9]*");
+ var commandKeywords = ["break","close","do","else","for","goto", "halt", "hang", "if", "job","kill","lock","merge","new","open", "quit", "read", "set", "tcommit", "trollback", "tstart", "use", "view", "write", "xecute", "b","c","d","e","f","g", "h", "i", "j","k","l","m","n","o", "q", "r", "s", "tc", "tro", "ts", "u", "v", "w", "x"];
+ // The following list includes instrinsic functions _and_ special variables
+ var intrinsicFuncsWords = ["\\$ascii", "\\$char", "\\$data", "\\$ecode", "\\$estack", "\\$etrap", "\\$extract", "\\$find", "\\$fnumber", "\\$get", "\\$horolog", "\\$io", "\\$increment", "\\$job", "\\$justify", "\\$length", "\\$name", "\\$next", "\\$order", "\\$piece", "\\$qlength", "\\$qsubscript", "\\$query", "\\$quit", "\\$random", "\\$reverse", "\\$select", "\\$stack", "\\$test", "\\$text", "\\$translate", "\\$view", "\\$x", "\\$y", "\\$a", "\\$c", "\\$d", "\\$e", "\\$ec", "\\$es", "\\$et", "\\$f", "\\$fn", "\\$g", "\\$h", "\\$i", "\\$j", "\\$l", "\\$n", "\\$na", "\\$o", "\\$p", "\\$q", "\\$ql", "\\$qs", "\\$r", "\\$re", "\\$s", "\\$st", "\\$t", "\\$tr", "\\$v", "\\$z"];
+ var intrinsicFuncs = wordRegexp(intrinsicFuncsWords);
+ var command = wordRegexp(commandKeywords);
+
+ function tokenBase(stream, state) {
+ if (stream.sol()) {
+ state.label = true;
+ state.commandMode = 0;
+ }
+
+ // The <space> character has meaning in MUMPS. Ignoring consecutive
+ // spaces would interfere with interpreting whether the next non-space
+ // character belongs to the command or argument context.
+
+ // Examine each character and update a mode variable whose interpretation is:
+ // >0 => command 0 => argument <0 => command post-conditional
+ var ch = stream.peek();
+
+ if (ch == " " || ch == "\t") { // Pre-process <space>
+ state.label = false;
+ if (state.commandMode == 0)
+ state.commandMode = 1;
+ else if ((state.commandMode < 0) || (state.commandMode == 2))
+ state.commandMode = 0;
+ } else if ((ch != ".") && (state.commandMode > 0)) {
+ if (ch == ":")
+ state.commandMode = -1; // SIS - Command post-conditional
+ else
+ state.commandMode = 2;
+ }
+
+ // Do not color parameter list as line tag
+ if ((ch === "(") || (ch === "\u0009"))
+ state.label = false;
+
+ // MUMPS comment starts with ";"
+ if (ch === ";") {
+ stream.skipToEnd();
+ return "comment";
+ }
+
+ // Number Literals // SIS/RLM - MUMPS permits canonic number followed by concatenate operator
+ if (stream.match(/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?/))
+ return "number";
+
+ // Handle Strings
+ if (ch == '"') {
+ if (stream.skipTo('"')) {
+ stream.next();
+ return "string";
+ } else {
+ stream.skipToEnd();
+ return "error";
+ }
+ }
+
+ // Handle operators and Delimiters
+ if (stream.match(doubleOperators) || stream.match(singleOperators))
+ return "operator";
+
+ // Prevents leading "." in DO block from falling through to error
+ if (stream.match(singleDelimiters))
+ return null;
+
+ if (brackets.test(ch)) {
+ stream.next();
+ return "bracket";
+ }
+
+ if (state.commandMode > 0 && stream.match(command))
+ return "variable-2";
+
+ if (stream.match(intrinsicFuncs))
+ return "builtin";
+
+ if (stream.match(identifiers))
+ return "variable";
+
+ // Detect dollar-sign when not a documented intrinsic function
+ // "^" may introduce a GVN or SSVN - Color same as function
+ if (ch === "$" || ch === "^") {
+ stream.next();
+ return "builtin";
+ }
+
+ // MUMPS Indirection
+ if (ch === "@") {
+ stream.next();
+ return "string-2";
+ }
+
+ if (/[\w%]/.test(ch)) {
+ stream.eatWhile(/[\w%]/);
+ return "variable";
+ }
+
+ // Handle non-detected items
+ stream.next();
+ return "error";
+ }
+
+ return {
+ startState: function() {
+ return {
+ label: false,
+ commandMode: 0
+ };
+ },
+
+ token: function(stream, state) {
+ var style = tokenBase(stream, state);
+ if (state.label) return "tag";
+ return style;
+ }
+ };
+ });
+
+ CodeMirror.defineMIME("text/x-mumps", "mumps");
+});
diff --git a/data/ext/editorText/codemirror/mode/nginx/index.html b/data/ext/editorText/codemirror/mode/nginx/index.html
index 16be1eb61..5ffdc081c 100644
--- a/data/ext/editorText/codemirror/mode/nginx/index.html
+++ b/data/ext/editorText/codemirror/mode/nginx/index.html
@@ -21,12 +21,12 @@
}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/nginx/nginx.js b/data/ext/editorText/codemirror/mode/nginx/nginx.js
index c98c8a1dd..135b9cc7f 100644
--- a/data/ext/editorText/codemirror/mode/nginx/nginx.js
+++ b/data/ext/editorText/codemirror/mode/nginx/nginx.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("nginx", function(config) {
function words(str) {
@@ -161,3 +174,5 @@ CodeMirror.defineMode("nginx", function(config) {
});
CodeMirror.defineMIME("text/nginx", "text/x-nginx-conf");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/nsis/index.html b/data/ext/editorText/codemirror/mode/nsis/index.html
new file mode 100644
index 000000000..a1d7aaa58
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/nsis/index.html
@@ -0,0 +1,62 @@
+<!doctype html>
+
+<title>CodeMirror: NSIS mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel=stylesheet href=../../lib/codemirror.css>
+<script src=../../lib/codemirror.js></script>
+<script src="../../addon/mode/simple.js"></script>
+<script src="../../addon/edit/matchbrackets.js"></script>
+<script src=nsis.js></script>
+<style type=text/css>
+ .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
+</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">NSIS</a>
+ </ul>
+</div>
+
+<article>
+<h2>NSIS mode</h2>
+
+
+<textarea id=code>
+; This is a comment
+!ifdef ERROR
+ !error "Something went wrong"
+!endif
+
+OutFile "demo.exe"
+RequestExecutionLevel user
+
+!include "LogicLib.nsh"
+
+Section -mandatory
+ ${If} 1 > 0
+ MessageBox MB_OK "Hello world"
+ ${EndIf}
+SectionEnd
+</textarea>
+
+<script>
+ var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
+ mode: 'nsis',
+ indentWithTabs: true,
+ smartIndent: true,
+ lineNumbers: true,
+ matchBrackets: true
+ });
+</script>
+
+<p><strong>MIME types defined:</strong> <code>text/x-nsis</code>.</p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/nsis/nsis.js b/data/ext/editorText/codemirror/mode/nsis/nsis.js
new file mode 100644
index 000000000..93dd7421e
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/nsis/nsis.js
@@ -0,0 +1,63 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Author: Jan T. Sott (http://github.com/idleberg)
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.defineSimpleMode("nsis",{
+ start:[
+ // Numbers
+ {regex: /(?:[+-]?)(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\d+.?\d*)/, token: "number"},
+ // Compile Time Commands
+ {regex: /(?:\!(include|addincludedir|addplugindir|appendfile|cd|delfile|echo|error|execute|packhdr|finalize|getdllversion|system|tempfile|warning|verbose|define|undef|insertmacro|makensis|searchparse|searchreplace))\b/, token: "keyword"},
+ // Conditional Compilation
+ {regex: /(?:\!(if(?:n?def)?|ifmacron?def|macro))\b/, token: "keyword", indent: true},
+ {regex: /(?:\!(else|endif|macroend))\b/, token: "keyword", dedent: true},
+ // Runtime Commands
+ {regex: /(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|IntCmp|IntCmpU|IntFmt|IntOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetPluginUnload|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"},
+ {regex: /\b(?:Function|PageEx|Section(?:Group)?)\b/, token: "keyword", indent: true},
+ {regex: /\b(?:(Function|PageEx|Section(?:Group)?)End)\b/, token: "keyword", dedent: true},
+ // Options
+ {regex: /\b(?:ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HIDDEN|HKCC|HKCR|HKCU|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM|HKPD|HKU|IDABORT|IDCANCEL|IDD_DIR|IDD_INST|IDD_INSTFILES|IDD_LICENSE|IDD_SELCOM|IDD_UNINST|IDD_VERIFY|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|MB_YESNOCANCEL|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SW_HIDE|SW_SHOWDEFAULT|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED|SW_SHOWNORMAL|SYSTEM|TEMPORARY)\b/, token: "atom"},
+ {regex: /\b(?:admin|all|auto|both|bottom|bzip2|components|current|custom|directory|force|hide|highest|ifdiff|ifnewer|instfiles|lastused|leave|left|license|listonly|lzma|nevershow|none|normal|notset|right|show|silent|silentlog|textonly|top|try|un\.components|un\.custom|un\.directory|un\.instfiles|un\.license|uninstConfirm|user|Win10|Win7|Win8|WinVista|zlib)\b/, token: "builtin"},
+
+ // LogicLib
+ {regex: /\$\{(?:End(If|Unless|While)|Loop(?:Until)|Next)\}/, token: "variable-2", dedent: true},
+ {regex: /\$\{(?:Do(Until|While)|Else(?:If(?:Not)?)?|For(?:Each)?|(?:(?:And|Else|Or)?If(?:Cmd|Not|Then)?|Unless)|While)\}/, token: "variable-2", indent: true},
+
+ // Line Comment
+ {regex: /(#|;).*/, token: "comment"},
+ // Block Comment
+ {regex: /\/\*/, token: "comment", next: "comment"},
+ // Operator
+ {regex: /[-+\/*=<>!]+/, token: "operator"},
+ // Variable
+ {regex: /\$[\w]+/, token: "variable"},
+ // Constant
+ {regex: /\${[\w]+}/,token: "variable-2"},
+ // Language String
+ {regex: /\$\([\w]+\)/,token: "variable-3"}
+ ],
+ comment: [
+ {regex: /.*?\*\//, token: "comment", next: "start"},
+ {regex: /.*/, token: "comment"}
+ ],
+ meta: {
+ electricInput: /^\s*((Function|PageEx|Section|Section(Group)?)End|(\!(endif|macroend))|\$\{(End(If|Unless|While)|Loop(Until)|Next)\})$/,
+ blockCommentStart: "/*",
+ blockCommentEnd: "*/",
+ lineComment: ["#", ";"]
+ }
+});
+
+CodeMirror.defineMIME("text/x-nsis", "nsis");
+});
diff --git a/data/ext/editorText/codemirror/mode/ntriples/index.html b/data/ext/editorText/codemirror/mode/ntriples/index.html
index c8a67916d..1355e7189 100644
--- a/data/ext/editorText/codemirror/mode/ntriples/index.html
+++ b/data/ext/editorText/codemirror/mode/ntriples/index.html
@@ -13,12 +13,12 @@
}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/ntriples/ntriples.js b/data/ext/editorText/codemirror/mode/ntriples/ntriples.js
index ed0cee34b..0524b1e8a 100644
--- a/data/ext/editorText/codemirror/mode/ntriples/ntriples.js
+++ b/data/ext/editorText/codemirror/mode/ntriples/ntriples.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/**********************************************************
* This script provides syntax highlighting support for
* the Ntriples format.
@@ -25,6 +28,17 @@
-> ERROR
}
*/
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("ntriples", function() {
var Location = {
@@ -168,3 +182,5 @@ CodeMirror.defineMode("ntriples", function() {
});
CodeMirror.defineMIME("text/n-triples", "ntriples");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/octave/index.html b/data/ext/editorText/codemirror/mode/octave/index.html
index 573ce4238..79df58119 100644
--- a/data/ext/editorText/codemirror/mode/octave/index.html
+++ b/data/ext/editorText/codemirror/mode/octave/index.html
@@ -9,12 +9,12 @@
<script src="octave.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/octave/octave.js b/data/ext/editorText/codemirror/mode/octave/octave.js
index dbf4ce1d1..a7bec030c 100644
--- a/data/ext/editorText/codemirror/mode/octave/octave.js
+++ b/data/ext/editorText/codemirror/mode/octave/octave.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("octave", function() {
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b");
@@ -9,7 +22,7 @@ CodeMirror.defineMode("octave", function() {
var doubleDelimiters = new RegExp("^((!=)|(\\+=)|(\\-=)|(\\*=)|(/=)|(&=)|(\\|=)|(\\^=))");
var tripleDelimiters = new RegExp("^((>>=)|(<<=))");
var expressionEnd = new RegExp("^[\\]\\)]");
- var identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
+ var identifiers = new RegExp("^[_A-Za-z\xa1-\uffff][_A-Za-z0-9\xa1-\uffff]*");
var builtins = wordRegexp([
'error', 'eval', 'function', 'abs', 'acos', 'atan', 'asin', 'cos',
@@ -118,3 +131,5 @@ CodeMirror.defineMode("octave", function() {
});
CodeMirror.defineMIME("text/x-octave", "octave");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/oz/index.html b/data/ext/editorText/codemirror/mode/oz/index.html
new file mode 100644
index 000000000..febd82a59
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/oz/index.html
@@ -0,0 +1,59 @@
+<!doctype html>
+
+<title>CodeMirror: Oz mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="oz.js"></script>
+<script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
+<style>
+ .CodeMirror {border: 1px solid #aaa;}
+</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Oz</a>
+ </ul>
+</div>
+
+<article>
+<h2>Oz mode</h2>
+<textarea id="code" name="code">
+declare
+fun {Ints N Max}
+ if N == Max then nil
+ else
+ {Delay 1000}
+ N|{Ints N+1 Max}
+ end
+end
+
+fun {Sum S Stream}
+ case Stream of nil then S
+ [] H|T then S|{Sum H+S T} end
+end
+
+local X Y in
+ thread X = {Ints 0 1000} end
+ thread Y = {Sum 0 X} end
+ {Browse Y}
+end
+</textarea>
+<p>MIME type defined: <code>text/x-oz</code>.</p>
+
+<script type="text/javascript">
+var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "text/x-oz",
+ readOnly: false
+});
+</script>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/oz/oz.js b/data/ext/editorText/codemirror/mode/oz/oz.js
new file mode 100644
index 000000000..ee8cb0ad1
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/oz/oz.js
@@ -0,0 +1,252 @@
+// 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";
+
+CodeMirror.defineMode("oz", function (conf) {
+
+ function wordRegexp(words) {
+ return new RegExp("^((" + words.join(")|(") + "))\\b");
+ }
+
+ var singleOperators = /[\^@!\|<>#~\.\*\-\+\\/,=]/;
+ var doubleOperators = /(<-)|(:=)|(=<)|(>=)|(<=)|(<:)|(>:)|(=:)|(\\=)|(\\=:)|(!!)|(==)|(::)/;
+ var tripleOperators = /(:::)|(\.\.\.)|(=<:)|(>=:)/;
+
+ var middle = ["in", "then", "else", "of", "elseof", "elsecase", "elseif", "catch",
+ "finally", "with", "require", "prepare", "import", "export", "define", "do"];
+ var end = ["end"];
+
+ var atoms = wordRegexp(["true", "false", "nil", "unit"]);
+ var commonKeywords = wordRegexp(["andthen", "at", "attr", "declare", "feat", "from", "lex",
+ "mod", "mode", "orelse", "parser", "prod", "prop", "scanner", "self", "syn", "token"]);
+ var openingKeywords = wordRegexp(["local", "proc", "fun", "case", "class", "if", "cond", "or", "dis",
+ "choice", "not", "thread", "try", "raise", "lock", "for", "suchthat", "meth", "functor"]);
+ var middleKeywords = wordRegexp(middle);
+ var endKeywords = wordRegexp(end);
+
+ // Tokenizers
+ function tokenBase(stream, state) {
+ if (stream.eatSpace()) {
+ return null;
+ }
+
+ // Brackets
+ if(stream.match(/[{}]/)) {
+ return "bracket";
+ }
+
+ // Special [] keyword
+ if (stream.match(/(\[])/)) {
+ return "keyword"
+ }
+
+ // Operators
+ if (stream.match(tripleOperators) || stream.match(doubleOperators)) {
+ return "operator";
+ }
+
+ // Atoms
+ if(stream.match(atoms)) {
+ return 'atom';
+ }
+
+ // Opening keywords
+ var matched = stream.match(openingKeywords);
+ if (matched) {
+ if (!state.doInCurrentLine)
+ state.currentIndent++;
+ else
+ state.doInCurrentLine = false;
+
+ // Special matching for signatures
+ if(matched[0] == "proc" || matched[0] == "fun")
+ state.tokenize = tokenFunProc;
+ else if(matched[0] == "class")
+ state.tokenize = tokenClass;
+ else if(matched[0] == "meth")
+ state.tokenize = tokenMeth;
+
+ return 'keyword';
+ }
+
+ // Middle and other keywords
+ if (stream.match(middleKeywords) || stream.match(commonKeywords)) {
+ return "keyword"
+ }
+
+ // End keywords
+ if (stream.match(endKeywords)) {
+ state.currentIndent--;
+ return 'keyword';
+ }
+
+ // Eat the next char for next comparisons
+ var ch = stream.next();
+
+ // Strings
+ if (ch == '"' || ch == "'") {
+ state.tokenize = tokenString(ch);
+ return state.tokenize(stream, state);
+ }
+
+ // Numbers
+ if (/[~\d]/.test(ch)) {
+ if (ch == "~") {
+ if(! /^[0-9]/.test(stream.peek()))
+ return null;
+ else if (( stream.next() == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/))
+ return "number";
+ }
+
+ if ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/))
+ return "number";
+
+ return null;
+ }
+
+ // Comments
+ if (ch == "%") {
+ stream.skipToEnd();
+ return 'comment';
+ }
+ else if (ch == "/") {
+ if (stream.eat("*")) {
+ state.tokenize = tokenComment;
+ return tokenComment(stream, state);
+ }
+ }
+
+ // Single operators
+ if(singleOperators.test(ch)) {
+ return "operator";
+ }
+
+ // If nothing match, we skip the entire alphanumerical block
+ stream.eatWhile(/\w/);
+
+ return "variable";
+ }
+
+ function tokenClass(stream, state) {
+ if (stream.eatSpace()) {
+ return null;
+ }
+ stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)/);
+ state.tokenize = tokenBase;
+ return "variable-3"
+ }
+
+ function tokenMeth(stream, state) {
+ if (stream.eatSpace()) {
+ return null;
+ }
+ stream.match(/([a-zA-Z][A-Za-z0-9_]*)|(`.+`)/);
+ state.tokenize = tokenBase;
+ return "def"
+ }
+
+ function tokenFunProc(stream, state) {
+ if (stream.eatSpace()) {
+ return null;
+ }
+
+ if(!state.hasPassedFirstStage && stream.eat("{")) {
+ state.hasPassedFirstStage = true;
+ return "bracket";
+ }
+ else if(state.hasPassedFirstStage) {
+ stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)|\$/);
+ state.hasPassedFirstStage = false;
+ state.tokenize = tokenBase;
+ return "def"
+ }
+ else {
+ state.tokenize = tokenBase;
+ return null;
+ }
+ }
+
+ function tokenComment(stream, state) {
+ var maybeEnd = false, ch;
+ while (ch = stream.next()) {
+ if (ch == "/" && maybeEnd) {
+ state.tokenize = tokenBase;
+ break;
+ }
+ maybeEnd = (ch == "*");
+ }
+ return "comment";
+ }
+
+ function tokenString(quote) {
+ return function (stream, state) {
+ var escaped = false, next, end = false;
+ while ((next = stream.next()) != null) {
+ if (next == quote && !escaped) {
+ end = true;
+ break;
+ }
+ escaped = !escaped && next == "\\";
+ }
+ if (end || !escaped)
+ state.tokenize = tokenBase;
+ return "string";
+ };
+ }
+
+ function buildElectricInputRegEx() {
+ // Reindentation should occur on [] or on a match of any of
+ // the block closing keywords, at the end of a line.
+ var allClosings = middle.concat(end);
+ return new RegExp("[\\[\\]]|(" + allClosings.join("|") + ")$");
+ }
+
+ return {
+
+ startState: function () {
+ return {
+ tokenize: tokenBase,
+ currentIndent: 0,
+ doInCurrentLine: false,
+ hasPassedFirstStage: false
+ };
+ },
+
+ token: function (stream, state) {
+ if (stream.sol())
+ state.doInCurrentLine = 0;
+
+ return state.tokenize(stream, state);
+ },
+
+ indent: function (state, textAfter) {
+ var trueText = textAfter.replace(/^\s+|\s+$/g, '');
+
+ if (trueText.match(endKeywords) || trueText.match(middleKeywords) || trueText.match(/(\[])/))
+ return conf.indentUnit * (state.currentIndent - 1);
+
+ if (state.currentIndent < 0)
+ return 0;
+
+ return state.currentIndent * conf.indentUnit;
+ },
+ fold: "indent",
+ electricInput: buildElectricInputRegEx(),
+ lineComment: "%",
+ blockCommentStart: "/*",
+ blockCommentEnd: "*/"
+ };
+});
+
+CodeMirror.defineMIME("text/x-oz", "oz");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/pascal/index.html b/data/ext/editorText/codemirror/mode/pascal/index.html
index bf8ff0d63..f8a99ad01 100644
--- a/data/ext/editorText/codemirror/mode/pascal/index.html
+++ b/data/ext/editorText/codemirror/mode/pascal/index.html
@@ -9,12 +9,12 @@
<script src="pascal.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/pascal/pascal.js b/data/ext/editorText/codemirror/mode/pascal/pascal.js
index 09d9b0617..2d0c3d424 100644
--- a/data/ext/editorText/codemirror/mode/pascal/pascal.js
+++ b/data/ext/editorText/codemirror/mode/pascal/pascal.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("pascal", function() {
function words(str) {
var obj = {}, words = str.split(" ");
@@ -92,3 +105,5 @@ CodeMirror.defineMode("pascal", function() {
});
CodeMirror.defineMIME("text/x-pascal", "pascal");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/pegjs/index.html b/data/ext/editorText/codemirror/mode/pegjs/index.html
index 678b714d8..0c7460488 100644
--- a/data/ext/editorText/codemirror/mode/pegjs/index.html
+++ b/data/ext/editorText/codemirror/mode/pegjs/index.html
@@ -13,12 +13,12 @@
</head>
<body>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/pegjs/pegjs.js b/data/ext/editorText/codemirror/mode/pegjs/pegjs.js
index 6b2e27379..306e3768c 100644
--- a/data/ext/editorText/codemirror/mode/pegjs/pegjs.js
+++ b/data/ext/editorText/codemirror/mode/pegjs/pegjs.js
@@ -1,3 +1,16 @@
+// 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"), require("../javascript/javascript"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../javascript/javascript"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("pegjs", function (config) {
var jsMode = CodeMirror.getMode(config, "javascript");
@@ -97,3 +110,5 @@ CodeMirror.defineMode("pegjs", function (config) {
}
};
}, "javascript");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/perl/index.html b/data/ext/editorText/codemirror/mode/perl/index.html
index 2b7578efe..8c1021c42 100644
--- a/data/ext/editorText/codemirror/mode/perl/index.html
+++ b/data/ext/editorText/codemirror/mode/perl/index.html
@@ -9,12 +9,12 @@
<script src="perl.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/perl/perl.js b/data/ext/editorText/codemirror/mode/perl/perl.js
index 5954b1a61..bef62bc7d 100644
--- a/data/ext/editorText/codemirror/mode/perl/perl.js
+++ b/data/ext/editorText/codemirror/mode/perl/perl.js
@@ -1,5 +1,19 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
// CodeMirror2 mode/perl/perl.js (text/x-perl) beta 0.10 (2011-11-08)
// This is a part of CodeMirror from https://github.com/sabaca/CodeMirror_mode_perl ([email protected])
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("perl",function(){
// http://perldoc.perl.org
var PERL={ // null - magic touch
@@ -509,7 +523,7 @@ CodeMirror.defineMode("perl",function(){
return tokenSOMETHING(stream,state,'=cut');}
var ch=stream.next();
if(ch=='"'||ch=="'"){ // NOTE: ' or " or <<'SOMETHING'\n...\nSOMETHING\n or <<"SOMETHING"\n...\nSOMETHING\n
- if(stream.prefix(3)=="<<"+ch){
+ if(prefix(stream, 3)=="<<"+ch){
var p=stream.pos;
stream.eatWhile(/\w/);
var n=stream.current().substr(1);
@@ -518,94 +532,94 @@ CodeMirror.defineMode("perl",function(){
stream.pos=p;}
return tokenChain(stream,state,[ch],"string");}
if(ch=="q"){
- var c=stream.look(-2);
+ var c=look(stream, -2);
if(!(c&&/\w/.test(c))){
- c=stream.look(0);
+ c=look(stream, 0);
if(c=="x"){
- c=stream.look(1);
+ c=look(stream, 1);
if(c=="("){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],RXstyle,RXmodifiers);}
if(c=="["){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],RXstyle,RXmodifiers);}
if(c=="{"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],RXstyle,RXmodifiers);}
if(c=="<"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}
if(/[\^'"!~\/]/.test(c)){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],RXstyle,RXmodifiers);}}
else if(c=="q"){
- c=stream.look(1);
+ c=look(stream, 1);
if(c=="("){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],"string");}
if(c=="["){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],"string");}
if(c=="{"){
-stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],"string");}
if(c=="<"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],"string");}
if(/[\^'"!~\/]/.test(c)){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],"string");}}
else if(c=="w"){
- c=stream.look(1);
+ c=look(stream, 1);
if(c=="("){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],"bracket");}
if(c=="["){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],"bracket");}
if(c=="{"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],"bracket");}
if(c=="<"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],"bracket");}
if(/[\^'"!~\/]/.test(c)){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],"bracket");}}
else if(c=="r"){
- c=stream.look(1);
+ c=look(stream, 1);
if(c=="("){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],RXstyle,RXmodifiers);}
if(c=="["){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],RXstyle,RXmodifiers);}
if(c=="{"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],RXstyle,RXmodifiers);}
if(c=="<"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}
if(/[\^'"!~\/]/.test(c)){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],RXstyle,RXmodifiers);}}
else if(/[\^'"!~\/(\[{<]/.test(c)){
if(c=="("){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[")"],"string");}
if(c=="["){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,["]"],"string");}
if(c=="{"){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,["}"],"string");}
if(c=="<"){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[">"],"string");}
if(/[\^'"!~\/]/.test(c)){
return tokenChain(stream,state,[stream.eat(c)],"string");}}}}
if(ch=="m"){
- var c=stream.look(-2);
+ var c=look(stream, -2);
if(!(c&&/\w/.test(c))){
c=stream.eat(/[(\[{<\^'"!~\/]/);
if(c){
@@ -620,7 +634,7 @@ stream.eatSuffix(2);
if(c=="<"){
return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}}}}
if(ch=="s"){
- var c=/[\/>\]})\w]/.test(stream.look(-2));
+ var c=/[\/>\]})\w]/.test(look(stream, -2));
if(!c){
c=stream.eat(/[(\[{<\^'"!~\/]/);
if(c){
@@ -634,7 +648,7 @@ stream.eatSuffix(2);
return tokenChain(stream,state,[")",")"],RXstyle,RXmodifiers);
return tokenChain(stream,state,[c,c],RXstyle,RXmodifiers);}}}
if(ch=="y"){
- var c=/[\/>\]})\w]/.test(stream.look(-2));
+ var c=/[\/>\]})\w]/.test(look(stream, -2));
if(!c){
c=stream.eat(/[(\[{<\^'"!~\/]/);
if(c){
@@ -648,7 +662,7 @@ stream.eatSuffix(2);
return tokenChain(stream,state,[")",")"],RXstyle,RXmodifiers);
return tokenChain(stream,state,[c,c],RXstyle,RXmodifiers);}}}
if(ch=="t"){
- var c=/[\/>\]})\w]/.test(stream.look(-2));
+ var c=/[\/>\]})\w]/.test(look(stream, -2));
if(!c){
c=stream.eat("r");if(c){
c=stream.eat(/[(\[{<\^'"!~\/]/);
@@ -665,7 +679,7 @@ stream.eatSuffix(2);
if(ch=="`"){
return tokenChain(stream,state,[ch],"variable-2");}
if(ch=="/"){
- if(!/~\s*$/.test(stream.prefix()))
+ if(!/~\s*$/.test(prefix(stream)))
return "operator";
else
return tokenChain(stream,state,[ch],RXstyle,RXmodifiers);}
@@ -677,7 +691,7 @@ stream.eatSuffix(2);
stream.pos=p;}
if(/[$@%]/.test(ch)){
var p=stream.pos;
- if(stream.eat("^")&&stream.eat(/[A-Z]/)||!/[@$%&]/.test(stream.look(-2))&&stream.eat(/[=|\\\-#?@;:&`~\^!\[\]*'"$+.,\/<>()]/)){
+ if(stream.eat("^")&&stream.eat(/[A-Z]/)||!/[@$%&]/.test(look(stream, -2))&&stream.eat(/[=|\\\-#?@;:&`~\^!\[\]*'"$+.,\/<>()]/)){
var c=stream.current();
if(PERL[c])
return "variable-2";}
@@ -690,7 +704,7 @@ stream.eatSuffix(2);
else
return "variable";}}
if(ch=="#"){
- if(stream.look(-2)!="$"){
+ if(look(stream, -2)!="$"){
stream.skipToEnd();
return "comment";}}
if(/[:+\-\^*$&%@=<>!?|\/~\.]/.test(ch)){
@@ -702,23 +716,23 @@ stream.eatSuffix(2);
stream.pos=p;}
if(ch=="_"){
if(stream.pos==1){
- if(stream.suffix(6)=="_END__"){
+ if(suffix(stream, 6)=="_END__"){
return tokenChain(stream,state,['\0'],"comment");}
- else if(stream.suffix(7)=="_DATA__"){
+ else if(suffix(stream, 7)=="_DATA__"){
return tokenChain(stream,state,['\0'],"variable-2");}
- else if(stream.suffix(7)=="_C__"){
+ else if(suffix(stream, 7)=="_C__"){
return tokenChain(stream,state,['\0'],"string");}}}
if(/\w/.test(ch)){
var p=stream.pos;
- if(stream.look(-2)=="{"&&(stream.look(0)=="}"||stream.eatWhile(/\w/)&&stream.look(0)=="}"))
+ if(look(stream, -2)=="{"&&(look(stream, 0)=="}"||stream.eatWhile(/\w/)&&look(stream, 0)=="}"))
return "string";
else
stream.pos=p;}
if(/[A-Z]/.test(ch)){
- var l=stream.look(-2);
+ var l=look(stream, -2);
var p=stream.pos;
stream.eatWhile(/[A-Z_]/);
- if(/[\da-z]/.test(stream.look(0))){
+ if(/[\da-z]/.test(look(stream, 0))){
stream.pos=p;}
else{
var c=PERL[stream.current()];
@@ -742,7 +756,7 @@ stream.eatSuffix(2);
else
return "meta";}}
if(/[a-zA-Z_]/.test(ch)){
- var l=stream.look(-2);
+ var l=look(stream, -2);
stream.eatWhile(/\w/);
var c=PERL[stream.current()];
if(!c)
@@ -766,51 +780,58 @@ stream.eatSuffix(2);
return "meta";}
return null;}
- return{
- startState:function(){
- return{
- tokenize:tokenPerl,
- chain:null,
- style:null,
- tail:null};},
- token:function(stream,state){
- return (state.tokenize||tokenPerl)(stream,state);},
- electricChars:"{}"};});
+ return {
+ startState: function() {
+ return {
+ tokenize: tokenPerl,
+ chain: null,
+ style: null,
+ tail: null
+ };
+ },
+ token: function(stream, state) {
+ return (state.tokenize || tokenPerl)(stream, state);
+ },
+ lineComment: '#'
+ };
+});
+
+CodeMirror.registerHelper("wordChars", "perl", /[\w$]/);
CodeMirror.defineMIME("text/x-perl", "perl");
// it's like "peek", but need for look-ahead or look-behind if index < 0
-CodeMirror.StringStream.prototype.look=function(c){
- return this.string.charAt(this.pos+(c||0));};
+function look(stream, c){
+ return stream.string.charAt(stream.pos+(c||0));
+}
// return a part of prefix of current stream from current position
-CodeMirror.StringStream.prototype.prefix=function(c){
- if(c){
- var x=this.pos-c;
- return this.string.substr((x>=0?x:0),c);}
- else{
- return this.string.substr(0,this.pos-1);}};
+function prefix(stream, c){
+ if(c){
+ var x=stream.pos-c;
+ return stream.string.substr((x>=0?x:0),c);}
+ else{
+ return stream.string.substr(0,stream.pos-1);
+ }
+}
// return a part of suffix of current stream from current position
-CodeMirror.StringStream.prototype.suffix=function(c){
- var y=this.string.length;
- var x=y-this.pos+1;
- return this.string.substr(this.pos,(c&&c<y?c:x));};
-
-// return a part of suffix of current stream from current position and change current position
-CodeMirror.StringStream.prototype.nsuffix=function(c){
- var p=this.pos;
- var l=c||(this.string.length-this.pos+1);
- this.pos+=l;
- return this.string.substr(p,l);};
+function suffix(stream, c){
+ var y=stream.string.length;
+ var x=y-stream.pos+1;
+ return stream.string.substr(stream.pos,(c&&c<y?c:x));
+}
// eating and vomiting a part of stream from current position
-CodeMirror.StringStream.prototype.eatSuffix=function(c){
- var x=this.pos+c;
- var y;
- if(x<=0)
- this.pos=0;
- else if(x>=(y=this.string.length-1))
- this.pos=y;
- else
- this.pos=x;};
+function eatSuffix(stream, c){
+ var x=stream.pos+c;
+ var y;
+ if(x<=0)
+ stream.pos=0;
+ else if(x>=(y=stream.string.length-1))
+ stream.pos=y;
+ else
+ stream.pos=x;
+}
+
+});
diff --git a/data/ext/editorText/codemirror/mode/php/index.html b/data/ext/editorText/codemirror/mode/php/index.html
index dd25a5e78..adf6b1be2 100644
--- a/data/ext/editorText/codemirror/mode/php/index.html
+++ b/data/ext/editorText/codemirror/mode/php/index.html
@@ -15,12 +15,12 @@
<script src="php.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/php/php.js b/data/ext/editorText/codemirror/mode/php/php.js
index 46c70cccf..22494467b 100644
--- a/data/ext/editorText/codemirror/mode/php/php.js
+++ b/data/ext/editorText/codemirror/mode/php/php.js
@@ -1,43 +1,47 @@
-(function() {
+// 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"), require("../htmlmixed/htmlmixed"), require("../clike/clike"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../clike/clike"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
function keywords(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
- function heredoc(delim) {
- return function(stream, state) {
- if (stream.match(delim)) state.tokenize = null;
- else stream.skipToEnd();
- return "string";
- };
- }
- // Helper for stringWithEscapes
- function matchSequence(list) {
- if (list.length == 0) return stringWithEscapes;
+ // Helper for phpString
+ function matchSequence(list, end, escapes) {
+ if (list.length == 0) return phpString(end);
return function (stream, state) {
var patterns = list[0];
for (var i = 0; i < patterns.length; i++) if (stream.match(patterns[i][0])) {
- state.tokenize = matchSequence(list.slice(1));
+ state.tokenize = matchSequence(list.slice(1), end);
return patterns[i][1];
}
- state.tokenize = stringWithEscapes;
+ state.tokenize = phpString(end, escapes);
return "string";
};
}
- function stringWithEscapes(stream, state) {
- var escaped = false, next, end = false;
-
- if (stream.current() == '"') return "string";
-
+ function phpString(closing, escapes) {
+ return function(stream, state) { return phpString_(stream, state, closing, escapes); };
+ }
+ function phpString_(stream, state, closing, escapes) {
// "Complex" syntax
- if (stream.match("${", false) || stream.match("{$", false)) {
+ if (escapes !== false && stream.match("${", false) || stream.match("{$", false)) {
state.tokenize = null;
return "string";
}
// Simple syntax
- if (stream.match(/\$[a-zA-Z_][a-zA-Z0-9_]*/)) {
+ if (escapes !== false && stream.match(/^\$[a-zA-Z_][a-zA-Z0-9_]*/)) {
// After the variable name there may appear array or object operator.
if (stream.match("[", false)) {
// Match array operator
@@ -47,31 +51,30 @@
[/\$[a-zA-Z_][a-zA-Z0-9_]*/, "variable-2"],
[/[\w\$]+/, "variable"]],
[["]", null]]
- ]);
+ ], closing, escapes);
}
if (stream.match(/\-\>\w/, false)) {
// Match object operator
state.tokenize = matchSequence([
[["->", null]],
[[/[\w]+/, "variable"]]
- ]);
+ ], closing, escapes);
}
return "variable-2";
}
+ var escaped = false;
// Normal string
- while (
- !stream.eol() &&
- (!stream.match("{$", false)) &&
- (!stream.match(/(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false) || escaped)
- ) {
- next = stream.next();
- if (!escaped && next == '"') { end = true; break; }
- escaped = !escaped && next == "\\";
- }
- if (end) {
- state.tokenize = null;
- state.phpEncapsStack.pop();
+ while (!stream.eol() &&
+ (escaped || escapes === false ||
+ (!stream.match("{$", false) &&
+ !stream.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false)))) {
+ if (!escaped && stream.match(closing)) {
+ state.tokenize = null;
+ state.tokStack.pop(); state.tokStack.pop();
+ break;
+ }
+ escaped = stream.next() == "\\" && !escaped;
}
return "string";
}
@@ -83,14 +86,16 @@
"die echo empty exit eval include include_once isset list require require_once return " +
"print unset __halt_compiler self static parent yield insteadof finally";
var phpAtoms = "true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__";
- var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once";
+ var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents file_put_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once json_decode json_encode json_last_error json_last_error_msg curl_close curl_copy_handle curl_errno curl_error curl_escape curl_exec curl_file_create curl_getinfo curl_init curl_multi_add_handle curl_multi_close curl_multi_exec curl_multi_getcontent curl_multi_info_read curl_multi_init curl_multi_remove_handle curl_multi_select curl_multi_setopt curl_multi_strerror curl_pause curl_reset curl_setopt_array curl_setopt curl_share_close curl_share_init curl_share_setopt curl_strerror curl_unescape curl_version mysqli_affected_rows mysqli_autocommit mysqli_change_user mysqli_character_set_name mysqli_close mysqli_commit mysqli_connect_errno mysqli_connect_error mysqli_connect mysqli_data_seek mysqli_debug mysqli_dump_debug_info mysqli_errno mysqli_error_list mysqli_error mysqli_fetch_all mysqli_fetch_array mysqli_fetch_assoc mysqli_fetch_field_direct mysqli_fetch_field mysqli_fetch_fields mysqli_fetch_lengths mysqli_fetch_object mysqli_fetch_row mysqli_field_count mysqli_field_seek mysqli_field_tell mysqli_free_result mysqli_get_charset mysqli_get_client_info mysqli_get_client_stats mysqli_get_client_version mysqli_get_connection_stats mysqli_get_host_info mysqli_get_proto_info mysqli_get_server_info mysqli_get_server_version mysqli_info mysqli_init mysqli_insert_id mysqli_kill mysqli_more_results mysqli_multi_query mysqli_next_result mysqli_num_fields mysqli_num_rows mysqli_options mysqli_ping mysqli_prepare mysqli_query mysqli_real_connect mysqli_real_escape_string mysqli_real_query mysqli_reap_async_query mysqli_refresh mysqli_rollback mysqli_select_db mysqli_set_charset mysqli_set_local_infile_default mysqli_set_local_infile_handler mysqli_sqlstate mysqli_ssl_set mysqli_stat mysqli_stmt_init mysqli_store_result mysqli_thread_id mysqli_thread_safe mysqli_use_result mysqli_warning_count";
CodeMirror.registerHelper("hintWords", "php", [phpKeywords, phpAtoms, phpBuiltin].join(" ").split(" "));
+ CodeMirror.registerHelper("wordChars", "php", /[\w$]/);
var phpConfig = {
name: "clike",
helperType: "php",
keywords: keywords(phpKeywords),
blockKeywords: keywords("catch do else elseif for foreach if switch try while finally"),
+ defKeywords: keywords("class function interface namespace trait"),
atoms: keywords(phpAtoms),
builtin: keywords(phpBuiltin),
multiLineStrings: true,
@@ -100,10 +105,17 @@
return "variable-2";
},
"<": function(stream, state) {
- if (stream.match(/<</)) {
+ var before;
+ if (before = stream.match(/<<\s*/)) {
+ var quoted = stream.eat(/['"]/);
stream.eatWhile(/[\w\.]/);
- state.tokenize = heredoc(stream.current().slice(3));
- return state.tokenize(stream, state);
+ var delim = stream.current().slice(before[0].length + (quoted ? 2 : 1));
+ if (quoted) stream.eat(quoted);
+ if (delim) {
+ (state.tokStack || (state.tokStack = [])).push(delim, 0);
+ state.tokenize = phpString(delim, quoted != "'");
+ return "string";
+ }
}
return false;
},
@@ -118,22 +130,21 @@
}
return false;
},
- '"': function(stream, state) {
- if (!state.phpEncapsStack)
- state.phpEncapsStack = [];
- state.phpEncapsStack.push(0);
- state.tokenize = stringWithEscapes;
- return state.tokenize(stream, state);
+ '"': function(_stream, state) {
+ (state.tokStack || (state.tokStack = [])).push('"', 0);
+ state.tokenize = phpString('"');
+ return "string";
},
"{": function(_stream, state) {
- if (state.phpEncapsStack && state.phpEncapsStack.length > 0)
- state.phpEncapsStack[state.phpEncapsStack.length - 1]++;
+ if (state.tokStack && state.tokStack.length)
+ state.tokStack[state.tokStack.length - 1]++;
return false;
},
"}": function(_stream, state) {
- if (state.phpEncapsStack && state.phpEncapsStack.length > 0)
- if (--state.phpEncapsStack[state.phpEncapsStack.length - 1] == 0)
- state.tokenize = stringWithEscapes;
+ if (state.tokStack && state.tokStack.length > 0 &&
+ !--state.tokStack[state.tokStack.length - 1]) {
+ state.tokenize = phpString(state.tokStack[state.tokStack.length - 2]);
+ }
return false;
}
}
@@ -149,6 +160,7 @@
if (!isPHP) {
if (stream.match(/^<\?\w*/)) {
state.curMode = phpMode;
+ if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, ""))
state.curState = state.php;
return "meta";
}
@@ -172,16 +184,17 @@
} else if (isPHP && state.php.tokenize == null && stream.match("?>")) {
state.curMode = htmlMode;
state.curState = state.html;
+ if (!state.php.context.prev) state.php = null;
return "meta";
} else {
- var result = phpMode.token(stream, state.curState);
- return (stream.pos <= stream.start) ? phpMode.token(stream, state.curState) : result;
+ return phpMode.token(stream, state.curState);
}
}
return {
startState: function() {
- var html = CodeMirror.startState(htmlMode), php = CodeMirror.startState(phpMode);
+ var html = CodeMirror.startState(htmlMode)
+ var php = parserConfig.startOpen ? CodeMirror.startState(phpMode) : null
return {html: html,
php: php,
curMode: parserConfig.startOpen ? phpMode : htmlMode,
@@ -191,7 +204,7 @@
copyState: function(state) {
var html = state.html, htmlNew = CodeMirror.copyState(htmlMode, html),
- php = state.php, phpNew = CodeMirror.copyState(phpMode, php), cur;
+ php = state.php, phpNew = php && CodeMirror.copyState(phpMode, php), cur;
if (state.curMode == htmlMode) cur = htmlNew;
else cur = phpNew;
return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur,
@@ -218,4 +231,4 @@
CodeMirror.defineMIME("application/x-httpd-php", "php");
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
CodeMirror.defineMIME("text/x-php", phpConfig);
-})();
+});
diff --git a/data/ext/editorText/codemirror/mode/php/test.js b/data/ext/editorText/codemirror/mode/php/test.js
index db68d75de..e2ecefc18 100644
--- a/data/ext/editorText/codemirror/mode/php/test.js
+++ b/data/ext/editorText/codemirror/mode/php/test.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "php");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
@@ -142,4 +145,10 @@
'[keyword echo] ' + m3[2] + ';',
'[keyword echo] [string "end"];',
'[meta ?>]');
+
+ MT("variable_interpolation_heredoc",
+ "[meta <?php]",
+ "[string <<<here]",
+ "[string doc ][variable-2 $]{[variable yay]}[string more]",
+ "[string here]; [comment // normal]");
})();
diff --git a/data/ext/editorText/codemirror/mode/pig/index.html b/data/ext/editorText/codemirror/mode/pig/index.html
index 93744ae2d..984c9a183 100644
--- a/data/ext/editorText/codemirror/mode/pig/index.html
+++ b/data/ext/editorText/codemirror/mode/pig/index.html
@@ -9,12 +9,12 @@
<script src="pig.js"></script>
<style>.CodeMirror {border: 2px inset #dee;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/pig/pig.js b/data/ext/editorText/codemirror/mode/pig/pig.js
index 69e5e2758..5b567272e 100644
--- a/data/ext/editorText/codemirror/mode/pig/pig.js
+++ b/data/ext/editorText/codemirror/mode/pig/pig.js
@@ -1,9 +1,22 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/*
* Pig Latin Mode for CodeMirror 2
* @author Prasanth Jayachandran
* @link https://github.com/prasanthj/pig-codemirror-2
* This implementation is adapted from PL/SQL mode in CodeMirror 2.
*/
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("pig", function(_config, parserConfig) {
var keywords = parserConfig.keywords,
builtins = parserConfig.builtins,
@@ -17,12 +30,6 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
return f(stream, state);
}
- var type;
- function ret(tp, style) {
- type = tp;
- return style;
- }
-
function tokenComment(stream, state) {
var isEnd = false;
var ch;
@@ -33,7 +40,7 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
}
isEnd = (ch == "*");
}
- return ret("comment", "comment");
+ return "comment";
}
function tokenString(quote) {
@@ -47,10 +54,11 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
}
if (end || !(escaped || multiLineStrings))
state.tokenize = tokenBase;
- return ret("string", "error");
+ return "error";
};
}
+
function tokenBase(stream, state) {
var ch = stream.next();
@@ -59,11 +67,11 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
return chain(stream, state, tokenString(ch));
// is it one of the special chars
else if(/[\[\]{}\(\),;\.]/.test(ch))
- return ret(ch);
+ return null;
// is it a number?
else if(/\d/.test(ch)) {
stream.eatWhile(/[\w\.]/);
- return ret("number", "number");
+ return "number";
}
// multi line comment or operator
else if (ch == "/") {
@@ -72,47 +80,42 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
}
else {
stream.eatWhile(isOperatorChar);
- return ret("operator", "operator");
+ return "operator";
}
}
// single line comment or operator
else if (ch=="-") {
if(stream.eat("-")){
stream.skipToEnd();
- return ret("comment", "comment");
+ return "comment";
}
else {
stream.eatWhile(isOperatorChar);
- return ret("operator", "operator");
+ return "operator";
}
}
// is it an operator
else if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
- return ret("operator", "operator");
+ return "operator";
}
else {
// get the while word
stream.eatWhile(/[\w\$_]/);
// is it one of the listed keywords?
if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
- if (stream.eat(")") || stream.eat(".")) {
- //keywords can be used as variables like flatten(group), group.$0 etc..
- }
- else {
- return ("keyword", "keyword");
- }
+ //keywords can be used as variables like flatten(group), group.$0 etc..
+ if (!stream.eat(")") && !stream.eat("."))
+ return "keyword";
}
// is it one of the builtin functions?
if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase()))
- {
- return ("keyword", "variable-2");
- }
+ return "variable-2";
// is it one of the listed types?
if (types && types.propertyIsEnumerable(stream.current().toUpperCase()))
- return ("keyword", "variable-3");
+ return "variable-3";
// default is a 'variable'
- return ret("variable", "pig-word");
+ return "variable";
}
}
@@ -171,3 +174,5 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
CodeMirror.registerHelper("hintWords", "pig", (pBuiltins + pTypes + pKeywords).split(" "));
}());
+
+});
diff --git a/data/ext/editorText/codemirror/mode/properties/index.html b/data/ext/editorText/codemirror/mode/properties/index.html
index 40ee1a37b..f885302de 100644
--- a/data/ext/editorText/codemirror/mode/properties/index.html
+++ b/data/ext/editorText/codemirror/mode/properties/index.html
@@ -9,12 +9,12 @@
<script src="properties.js"></script>
<style>.CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/properties/properties.js b/data/ext/editorText/codemirror/mode/properties/properties.js
index d3a13c765..9da5baf42 100644
--- a/data/ext/editorText/codemirror/mode/properties/properties.js
+++ b/data/ext/editorText/codemirror/mode/properties/properties.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("properties", function() {
return {
token: function(stream, state) {
@@ -38,7 +51,7 @@ CodeMirror.defineMode("properties", function() {
state.position = "quote";
return null;
} else if (ch === "\\" && state.position === "quote") {
- if (stream.next() !== "u") { // u = Unicode sequence \u1234
+ if (stream.eol()) { // end of line?
// Multiline value
state.nextMultiline = true;
}
@@ -61,3 +74,5 @@ CodeMirror.defineMode("properties", function() {
CodeMirror.defineMIME("text/x-properties", "properties");
CodeMirror.defineMIME("text/x-ini", "properties");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/puppet/index.html b/data/ext/editorText/codemirror/mode/puppet/index.html
index f307636b2..5614c3695 100644
--- a/data/ext/editorText/codemirror/mode/puppet/index.html
+++ b/data/ext/editorText/codemirror/mode/puppet/index.html
@@ -13,12 +13,12 @@
.cm-s-default span.cm-arrow { color: red; }
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/puppet/puppet.js b/data/ext/editorText/codemirror/mode/puppet/puppet.js
index 0153c8012..e7f799f78 100644
--- a/data/ext/editorText/codemirror/mode/puppet/puppet.js
+++ b/data/ext/editorText/codemirror/mode/puppet/puppet.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("puppet", function () {
// Stores the words from the define method
var words = {};
@@ -127,11 +140,11 @@ CodeMirror.defineMode("puppet", function () {
return words[word];
}
// Is there a match on a reference?
- if (/(\s+)?[A-Z]/.test(word)) {
+ if (/(^|\s+)[A-Z][\w:_]+/.test(word)) {
// Negate the next()
stream.backUp(1);
// Match the full reference
- stream.match(/(\s+)?[A-Z][\w:_]+/);
+ stream.match(/(^|\s+)[A-Z][\w:_]+/);
return 'def';
}
// Have we matched the prior resource regex?
@@ -163,7 +176,7 @@ CodeMirror.defineMode("puppet", function () {
// Match characters that we are going to assume
// are trying to be regex
if (ch == '/') {
- stream.match(/.*\//);
+ stream.match(/.*?\//);
return 'variable-3';
}
// Match all the numbers
@@ -201,4 +214,7 @@ CodeMirror.defineMode("puppet", function () {
}
};
});
+
CodeMirror.defineMIME("text/x-puppet", "puppet");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/python/index.html b/data/ext/editorText/codemirror/mode/python/index.html
index a1d6d2d83..86eb3d52f 100644
--- a/data/ext/editorText/codemirror/mode/python/index.html
+++ b/data/ext/editorText/codemirror/mode/python/index.html
@@ -10,12 +10,12 @@
<script src="python.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -65,13 +65,25 @@ __a__
a.b
a.b.c
+#Unicode identifiers on Python3
+# a = x\ddot
+a⃗ = ẍ
+# a = v\dot
+a⃗ = v̇
+
+#F\vec = m \cdot a\vec
+F⃗ = m•a⃗
+
# Operators
+ - * / % & | ^ ~ < >
== != <= >= <> << >> // **
and or not in is
+#infix matrix multiplication operator (PEP 465)
+A @ B
+
# Delimiters
-() [] {} , : ` = ; @ . # Note that @ and . require the proper context.
+() [] {} , : ` = ; @ . # Note that @ and . require the proper context on Python 2.
+= -= *= /= %= &= |= ^=
//= >>= <<= **=
@@ -146,7 +158,7 @@ def pairwise_cython(double[:, ::1] X):
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: {name: "python",
- version: 2,
+ version: 3,
singleLineStringErrors: false},
lineNumbers: true,
indentUnit: 4,
@@ -171,12 +183,12 @@ def pairwise_cython(double[:, ::1] X):
<h2>Advanced Configuration Options:</h2>
<p>Usefull for superset of python syntax like Enthought enaml, IPython magics and questionmark help</p>
<ul>
- <li>singleOperators - RegEx - Regular Expression for single operator matching, default : <pre>^[\\+\\-\\*/%&amp;|\\^~&lt;&gt;!]</pre></li>
+ <li>singleOperators - RegEx - Regular Expression for single operator matching, default : <pre>^[\\+\\-\\*/%&amp;|\\^~&lt;&gt;!]</pre> including <pre>@</pre> on Python 3</li>
<li>singleDelimiters - RegEx - Regular Expression for single delimiter matching, default : <pre>^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]</pre></li>
<li>doubleOperators - RegEx - Regular Expression for double operators matching, default : <pre>^((==)|(!=)|(&lt;=)|(&gt;=)|(&lt;&gt;)|(&lt;&lt;)|(&gt;&gt;)|(//)|(\\*\\*))</pre></li>
<li>doubleDelimiters - RegEx - Regular Expressoin for double delimiters matching, default : <pre>^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&amp;=)|(\\|=)|(\\^=))</pre></li>
<li>tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default : <pre>^((//=)|(&gt;&gt;=)|(&lt;&lt;=)|(\\*\\*=))</pre></li>
- <li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre></li>
+ <li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre> on Python 2 and <pre>^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*</pre> on Python 3.</li>
<li>extra_keywords - list of string - List of extra words ton consider as keywords</li>
<li>extra_builtins - list of string - List of extra words ton consider as builtins</li>
</ul>
diff --git a/data/ext/editorText/codemirror/mode/python/python.js b/data/ext/editorText/codemirror/mode/python/python.js
index 2a7445209..e5a09719b 100644
--- a/data/ext/editorText/codemirror/mode/python/python.js
+++ b/data/ext/editorText/codemirror/mode/python/python.js
@@ -1,373 +1,352 @@
-CodeMirror.defineMode("python", function(conf, parserConf) {
- var ERRORCLASS = 'error';
-
- function wordRegexp(words) {
- return new RegExp("^((" + words.join(")|(") + "))\\b");
- }
+// 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";
- var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
- var singleDelimiters = parserConf.singleDelimiters || new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
+ function wordRegexp(words) {
+ return new RegExp("^((" + words.join(")|(") + "))\\b");
+ }
+
+ var wordOperators = wordRegexp(["and", "or", "not", "is"]);
+ var commonKeywords = ["as", "assert", "break", "class", "continue",
+ "def", "del", "elif", "else", "except", "finally",
+ "for", "from", "global", "if", "import",
+ "lambda", "pass", "raise", "return",
+ "try", "while", "with", "yield", "in"];
+ var commonBuiltins = ["abs", "all", "any", "bin", "bool", "bytearray", "callable", "chr",
+ "classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod",
+ "enumerate", "eval", "filter", "float", "format", "frozenset",
+ "getattr", "globals", "hasattr", "hash", "help", "hex", "id",
+ "input", "int", "isinstance", "issubclass", "iter", "len",
+ "list", "locals", "map", "max", "memoryview", "min", "next",
+ "object", "oct", "open", "ord", "pow", "property", "range",
+ "repr", "reversed", "round", "set", "setattr", "slice",
+ "sorted", "staticmethod", "str", "sum", "super", "tuple",
+ "type", "vars", "zip", "__import__", "NotImplemented",
+ "Ellipsis", "__debug__"];
+ var py2 = {builtins: ["apply", "basestring", "buffer", "cmp", "coerce", "execfile",
+ "file", "intern", "long", "raw_input", "reduce", "reload",
+ "unichr", "unicode", "xrange", "False", "True", "None"],
+ keywords: ["exec", "print"]};
+ var py3 = {builtins: ["ascii", "bytes", "exec", "print"],
+ keywords: ["nonlocal", "False", "True", "None", "async", "await"]};
+
+ CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins));
+
+ function top(state) {
+ return state.scopes[state.scopes.length - 1];
+ }
+
+ CodeMirror.defineMode("python", function(conf, parserConf) {
+ var ERRORCLASS = "error";
+
+ var singleDelimiters = parserConf.singleDelimiters || new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]");
var doubleOperators = parserConf.doubleOperators || new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
var doubleDelimiters = parserConf.doubleDelimiters || new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
var tripleDelimiters = parserConf.tripleDelimiters || new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))");
- var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
- var hangingIndent = parserConf.hangingIndent || parserConf.indentUnit;
-
- var wordOperators = wordRegexp(['and', 'or', 'not', 'is', 'in']);
- var commonkeywords = ['as', 'assert', 'break', 'class', 'continue',
- 'def', 'del', 'elif', 'else', 'except', 'finally',
- 'for', 'from', 'global', 'if', 'import',
- 'lambda', 'pass', 'raise', 'return',
- 'try', 'while', 'with', 'yield'];
- var commonBuiltins = ['abs', 'all', 'any', 'bin', 'bool', 'bytearray', 'callable', 'chr',
- 'classmethod', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod',
- 'enumerate', 'eval', 'filter', 'float', 'format', 'frozenset',
- 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
- 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len',
- 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next',
- 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range',
- 'repr', 'reversed', 'round', 'set', 'setattr', 'slice',
- 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple',
- 'type', 'vars', 'zip', '__import__', 'NotImplemented',
- 'Ellipsis', '__debug__'];
- var py2 = {'builtins': ['apply', 'basestring', 'buffer', 'cmp', 'coerce', 'execfile',
- 'file', 'intern', 'long', 'raw_input', 'reduce', 'reload',
- 'unichr', 'unicode', 'xrange', 'False', 'True', 'None'],
- 'keywords': ['exec', 'print']};
- var py3 = {'builtins': ['ascii', 'bytes', 'exec', 'print'],
- 'keywords': ['nonlocal', 'False', 'True', 'None']};
+ if (parserConf.version && parseInt(parserConf.version, 10) == 3){
+ // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
+ var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!@]");
+ var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*");
+ } else {
+ var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
+ var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
+ }
+
+ var hangingIndent = parserConf.hangingIndent || conf.indentUnit;
+
+ var myKeywords = commonKeywords, myBuiltins = commonBuiltins;
if(parserConf.extra_keywords != undefined){
- commonkeywords = commonkeywords.concat(parserConf.extra_keywords);
+ myKeywords = myKeywords.concat(parserConf.extra_keywords);
}
if(parserConf.extra_builtins != undefined){
- commonBuiltins = commonBuiltins.concat(parserConf.extra_builtins);
+ myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
}
- if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) {
- commonkeywords = commonkeywords.concat(py3.keywords);
- commonBuiltins = commonBuiltins.concat(py3.builtins);
- var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
+ if (parserConf.version && parseInt(parserConf.version, 10) == 3) {
+ myKeywords = myKeywords.concat(py3.keywords);
+ myBuiltins = myBuiltins.concat(py3.builtins);
+ var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
} else {
- commonkeywords = commonkeywords.concat(py2.keywords);
- commonBuiltins = commonBuiltins.concat(py2.builtins);
- var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
+ myKeywords = myKeywords.concat(py2.keywords);
+ myBuiltins = myBuiltins.concat(py2.builtins);
+ var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
}
- var keywords = wordRegexp(commonkeywords);
- var builtins = wordRegexp(commonBuiltins);
-
- var indentInfo = null;
+ var keywords = wordRegexp(myKeywords);
+ var builtins = wordRegexp(myBuiltins);
// tokenizers
function tokenBase(stream, state) {
- // Handle scope changes
- if (stream.sol()) {
- var scopeOffset = state.scopes[0].offset;
- if (stream.eatSpace()) {
- var lineOffset = stream.indentation();
- if (lineOffset > scopeOffset) {
- indentInfo = 'indent';
- } else if (lineOffset < scopeOffset) {
- indentInfo = 'dedent';
- }
- return null;
- } else {
- if (scopeOffset > 0) {
- dedent(stream, state);
- }
- }
- }
+ // Handle scope changes
+ if (stream.sol() && top(state).type == "py") {
+ var scopeOffset = top(state).offset;
if (stream.eatSpace()) {
- return null;
+ var lineOffset = stream.indentation();
+ if (lineOffset > scopeOffset)
+ pushScope(stream, state, "py");
+ else if (lineOffset < scopeOffset && dedent(stream, state))
+ state.errorToken = true;
+ return null;
+ } else {
+ var style = tokenBaseInner(stream, state);
+ if (scopeOffset > 0 && dedent(stream, state))
+ style += " " + ERRORCLASS;
+ return style;
}
+ }
+ return tokenBaseInner(stream, state);
+ }
- var ch = stream.peek();
-
- // Handle Comments
- if (ch === '#') {
- stream.skipToEnd();
- return 'comment';
+ function tokenBaseInner(stream, state) {
+ if (stream.eatSpace()) return null;
+
+ var ch = stream.peek();
+
+ // Handle Comments
+ if (ch == "#") {
+ stream.skipToEnd();
+ return "comment";
+ }
+
+ // Handle Number Literals
+ if (stream.match(/^[0-9\.]/, false)) {
+ var floatLiteral = false;
+ // Floats
+ if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; }
+ if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; }
+ if (stream.match(/^\.\d+/)) { floatLiteral = true; }
+ if (floatLiteral) {
+ // Float literals may be "imaginary"
+ stream.eat(/J/i);
+ return "number";
}
-
- // Handle Number Literals
- if (stream.match(/^[0-9\.]/, false)) {
- var floatLiteral = false;
- // Floats
- if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; }
- if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; }
- if (stream.match(/^\.\d+/)) { floatLiteral = true; }
- if (floatLiteral) {
- // Float literals may be "imaginary"
- stream.eat(/J/i);
- return 'number';
- }
- // Integers
- var intLiteral = false;
- // Hex
- if (stream.match(/^0x[0-9a-f]+/i)) { intLiteral = true; }
- // Binary
- if (stream.match(/^0b[01]+/i)) { intLiteral = true; }
- // Octal
- if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; }
- // Decimal
- if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
- // Decimal literals may be "imaginary"
- stream.eat(/J/i);
- // TODO - Can you have imaginary longs?
- intLiteral = true;
- }
- // Zero by itself with no other piece of number.
- if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
- if (intLiteral) {
- // Integer literals may be "long"
- stream.eat(/L/i);
- return 'number';
- }
+ // Integers
+ var intLiteral = false;
+ // Hex
+ if (stream.match(/^0x[0-9a-f]+/i)) intLiteral = true;
+ // Binary
+ if (stream.match(/^0b[01]+/i)) intLiteral = true;
+ // Octal
+ if (stream.match(/^0o[0-7]+/i)) intLiteral = true;
+ // Decimal
+ if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
+ // Decimal literals may be "imaginary"
+ stream.eat(/J/i);
+ // TODO - Can you have imaginary longs?
+ intLiteral = true;
}
-
- // Handle Strings
- if (stream.match(stringPrefixes)) {
- state.tokenize = tokenStringFactory(stream.current());
- return state.tokenize(stream, state);
+ // Zero by itself with no other piece of number.
+ if (stream.match(/^0(?![\dx])/i)) intLiteral = true;
+ if (intLiteral) {
+ // Integer literals may be "long"
+ stream.eat(/L/i);
+ return "number";
}
+ }
- // Handle operators and Delimiters
- if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
- return null;
- }
- if (stream.match(doubleOperators)
- || stream.match(singleOperators)
- || stream.match(wordOperators)) {
- return 'operator';
- }
- if (stream.match(singleDelimiters)) {
- return null;
- }
+ // Handle Strings
+ if (stream.match(stringPrefixes)) {
+ state.tokenize = tokenStringFactory(stream.current());
+ return state.tokenize(stream, state);
+ }
- if (stream.match(keywords)) {
- return 'keyword';
- }
+ // Handle operators and Delimiters
+ if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters))
+ return null;
- if (stream.match(builtins)) {
- return 'builtin';
- }
+ if (stream.match(doubleOperators) || stream.match(singleOperators))
+ return "operator";
- if (stream.match(/^(self|cls)\b/)) {
- return "variable-2";
- }
+ if (stream.match(singleDelimiters))
+ return null;
- if (stream.match(identifiers)) {
- if (state.lastToken == 'def' || state.lastToken == 'class') {
- return 'def';
- }
- return 'variable';
- }
+ if (stream.match(keywords) || stream.match(wordOperators))
+ return "keyword";
+
+ if (stream.match(builtins))
+ return "builtin";
+
+ if (stream.match(/^(self|cls)\b/))
+ return "variable-2";
- // Handle non-detected items
- stream.next();
- return ERRORCLASS;
+ if (stream.match(identifiers)) {
+ if (state.lastToken == "def" || state.lastToken == "class")
+ return "def";
+ return "variable";
+ }
+
+ // Handle non-detected items
+ stream.next();
+ return ERRORCLASS;
}
function tokenStringFactory(delimiter) {
- while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
- delimiter = delimiter.substr(1);
- }
- var singleline = delimiter.length == 1;
- var OUTCLASS = 'string';
-
- function tokenString(stream, state) {
- while (!stream.eol()) {
- stream.eatWhile(/[^'"\\]/);
- if (stream.eat('\\')) {
- stream.next();
- if (singleline && stream.eol()) {
- return OUTCLASS;
- }
- } else if (stream.match(delimiter)) {
- state.tokenize = tokenBase;
- return OUTCLASS;
- } else {
- stream.eat(/['"]/);
- }
- }
- if (singleline) {
- if (parserConf.singleLineStringErrors) {
- return ERRORCLASS;
- } else {
- state.tokenize = tokenBase;
- }
- }
+ while ("rub".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
+ delimiter = delimiter.substr(1);
+
+ var singleline = delimiter.length == 1;
+ var OUTCLASS = "string";
+
+ function tokenString(stream, state) {
+ while (!stream.eol()) {
+ stream.eatWhile(/[^'"\\]/);
+ if (stream.eat("\\")) {
+ stream.next();
+ if (singleline && stream.eol())
+ return OUTCLASS;
+ } else if (stream.match(delimiter)) {
+ state.tokenize = tokenBase;
return OUTCLASS;
+ } else {
+ stream.eat(/['"]/);
+ }
+ }
+ if (singleline) {
+ if (parserConf.singleLineStringErrors)
+ return ERRORCLASS;
+ else
+ state.tokenize = tokenBase;
}
- tokenString.isString = true;
- return tokenString;
+ return OUTCLASS;
+ }
+ tokenString.isString = true;
+ return tokenString;
}
- function indent(stream, state, type) {
- type = type || 'py';
- var indentUnit = 0;
- if (type === 'py') {
- if (state.scopes[0].type !== 'py') {
- state.scopes[0].offset = stream.indentation();
- return;
- }
- for (var i = 0; i < state.scopes.length; ++i) {
- if (state.scopes[i].type === 'py') {
- indentUnit = state.scopes[i].offset + conf.indentUnit;
- break;
- }
- }
- } else if (stream.match(/\s*($|#)/, false)) {
- // An open paren/bracket/brace with only space or comments after it
- // on the line will indent the next line a fixed amount, to make it
- // easier to put arguments, list items, etc. on their own lines.
- indentUnit = stream.indentation() + hangingIndent;
- } else {
- indentUnit = stream.column() + stream.current().length;
- }
- state.scopes.unshift({
- offset: indentUnit,
- type: type
- });
+ function pushScope(stream, state, type) {
+ var offset = 0, align = null;
+ if (type == "py") {
+ while (top(state).type != "py")
+ state.scopes.pop();
+ }
+ offset = top(state).offset + (type == "py" ? conf.indentUnit : hangingIndent);
+ if (type != "py" && !stream.match(/^(\s|#.*)*$/, false))
+ align = stream.column() + 1;
+ state.scopes.push({offset: offset, type: type, align: align});
}
- function dedent(stream, state, type) {
- type = type || 'py';
- if (state.scopes.length == 1) return;
- if (state.scopes[0].type === 'py') {
- var _indent = stream.indentation();
- var _indent_index = -1;
- for (var i = 0; i < state.scopes.length; ++i) {
- if (_indent === state.scopes[i].offset) {
- _indent_index = i;
- break;
- }
- }
- if (_indent_index === -1) {
- return true;
- }
- while (state.scopes[0].offset !== _indent) {
- state.scopes.shift();
- }
- return false;
- } else {
- if (type === 'py') {
- state.scopes[0].offset = stream.indentation();
- return false;
- } else {
- if (state.scopes[0].type != type) {
- return true;
- }
- state.scopes.shift();
- return false;
- }
- }
+ function dedent(stream, state) {
+ var indented = stream.indentation();
+ while (top(state).offset > indented) {
+ if (top(state).type != "py") return true;
+ state.scopes.pop();
+ }
+ return top(state).offset != indented;
}
function tokenLexer(stream, state) {
- indentInfo = null;
- var style = state.tokenize(stream, state);
- var current = stream.current();
-
- // Handle '.' connected identifiers
- if (current === '.') {
- style = stream.match(identifiers, false) ? null : ERRORCLASS;
- if (style === null && state.lastStyle === 'meta') {
- // Apply 'meta' style to '.' connected identifiers when
- // appropriate.
- style = 'meta';
- }
- return style;
- }
-
- // Handle decorators
- if (current === '@') {
- return stream.match(identifiers, false) ? 'meta' : ERRORCLASS;
- }
-
- if ((style === 'variable' || style === 'builtin')
- && state.lastStyle === 'meta') {
- style = 'meta';
+ var style = state.tokenize(stream, state);
+ var current = stream.current();
+
+ // Handle '.' connected identifiers
+ if (current == ".") {
+ style = stream.match(identifiers, false) ? null : ERRORCLASS;
+ if (style == null && state.lastStyle == "meta") {
+ // Apply 'meta' style to '.' connected identifiers when
+ // appropriate.
+ style = "meta";
}
+ return style;
+ }
- // Handle scope changes.
- if (current === 'pass' || current === 'return') {
- state.dedent += 1;
- }
- if (current === 'lambda') state.lambda = true;
- if ((current === ':' && !state.lambda && state.scopes[0].type == 'py')
- || indentInfo === 'indent') {
- indent(stream, state);
- }
- var delimiter_index = '[({'.indexOf(current);
- if (delimiter_index !== -1) {
- indent(stream, state, '])}'.slice(delimiter_index, delimiter_index+1));
- }
- if (indentInfo === 'dedent') {
- if (dedent(stream, state)) {
- return ERRORCLASS;
- }
- }
- delimiter_index = '])}'.indexOf(current);
- if (delimiter_index !== -1) {
- if (dedent(stream, state, current)) {
- return ERRORCLASS;
- }
- }
- if (state.dedent > 0 && stream.eol() && state.scopes[0].type == 'py') {
- if (state.scopes.length > 1) state.scopes.shift();
- state.dedent -= 1;
+ // Handle decorators
+ if (current == "@"){
+ if(parserConf.version && parseInt(parserConf.version, 10) == 3){
+ return stream.match(identifiers, false) ? "meta" : "operator";
+ } else {
+ return stream.match(identifiers, false) ? "meta" : ERRORCLASS;
}
-
- return style;
+ }
+
+ if ((style == "variable" || style == "builtin")
+ && state.lastStyle == "meta")
+ style = "meta";
+
+ // Handle scope changes.
+ if (current == "pass" || current == "return")
+ state.dedent += 1;
+
+ if (current == "lambda") state.lambda = true;
+ if (current == ":" && !state.lambda && top(state).type == "py")
+ pushScope(stream, state, "py");
+
+ var delimiter_index = current.length == 1 ? "[({".indexOf(current) : -1;
+ if (delimiter_index != -1)
+ pushScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
+
+ delimiter_index = "])}".indexOf(current);
+ if (delimiter_index != -1) {
+ if (top(state).type == current) state.scopes.pop();
+ else return ERRORCLASS;
+ }
+ if (state.dedent > 0 && stream.eol() && top(state).type == "py") {
+ if (state.scopes.length > 1) state.scopes.pop();
+ state.dedent -= 1;
+ }
+
+ return style;
}
var external = {
- startState: function(basecolumn) {
- return {
- tokenize: tokenBase,
- scopes: [{offset:basecolumn || 0, type:'py'}],
- lastStyle: null,
- lastToken: null,
- lambda: false,
- dedent: 0
- };
- },
-
- token: function(stream, state) {
- var style = tokenLexer(stream, state);
-
- state.lastStyle = style;
-
- var current = stream.current();
- if (current && style) {
- state.lastToken = current;
- }
-
- if (stream.eol() && state.lambda) {
- state.lambda = false;
- }
- return style;
- },
-
- indent: function(state) {
- if (state.tokenize != tokenBase) {
- return state.tokenize.isString ? CodeMirror.Pass : 0;
- }
-
- return state.scopes[0].offset;
- },
-
- lineComment: "#",
- fold: "indent"
+ startState: function(basecolumn) {
+ return {
+ tokenize: tokenBase,
+ scopes: [{offset: basecolumn || 0, type: "py", align: null}],
+ lastStyle: null,
+ lastToken: null,
+ lambda: false,
+ dedent: 0
+ };
+ },
+
+ token: function(stream, state) {
+ var addErr = state.errorToken;
+ if (addErr) state.errorToken = false;
+ var style = tokenLexer(stream, state);
+
+ state.lastStyle = style;
+
+ var current = stream.current();
+ if (current && style)
+ state.lastToken = current;
+
+ if (stream.eol() && state.lambda)
+ state.lambda = false;
+ return addErr ? style + " " + ERRORCLASS : style;
+ },
+
+ indent: function(state, textAfter) {
+ if (state.tokenize != tokenBase)
+ return state.tokenize.isString ? CodeMirror.Pass : 0;
+
+ var scope = top(state);
+ var closing = textAfter && textAfter.charAt(0) == scope.type;
+ if (scope.align != null)
+ return scope.align - (closing ? 1 : 0);
+ else if (closing && state.scopes.length > 1)
+ return state.scopes[state.scopes.length - 2].offset;
+ else
+ return scope.offset;
+ },
+
+ closeBrackets: {triples: "'\""},
+ lineComment: "#",
+ fold: "indent"
};
return external;
-});
+ });
-CodeMirror.defineMIME("text/x-python", "python");
+ CodeMirror.defineMIME("text/x-python", "python");
-(function() {
- "use strict";
- var words = function(str){return str.split(' ');};
+ var words = function(str) { return str.split(" "); };
CodeMirror.defineMIME("text/x-cython", {
name: "python",
@@ -375,4 +354,5 @@ CodeMirror.defineMIME("text/x-python", "python");
"extern gil include nogil property public"+
"readonly struct union DEF IF ELIF ELSE")
});
-})();
+
+});
diff --git a/data/ext/editorText/codemirror/mode/q/index.html b/data/ext/editorText/codemirror/mode/q/index.html
index 78ed3d88f..72785ba3b 100644
--- a/data/ext/editorText/codemirror/mode/q/index.html
+++ b/data/ext/editorText/codemirror/mode/q/index.html
@@ -10,12 +10,12 @@
<script src="q.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/q/q.js b/data/ext/editorText/codemirror/mode/q/q.js
index 56017e30a..a4af9383e 100644
--- a/data/ext/editorText/codemirror/mode/q/q.js
+++ b/data/ext/editorText/codemirror/mode/q/q.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("q",function(config){
var indentUnit=config.indentUnit,
curPunc,
@@ -122,3 +135,5 @@ CodeMirror.defineMode("q",function(config){
};
});
CodeMirror.defineMIME("text/x-q","q");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/r/index.html b/data/ext/editorText/codemirror/mode/r/index.html
index 397d5858a..6dd963465 100644
--- a/data/ext/editorText/codemirror/mode/r/index.html
+++ b/data/ext/editorText/codemirror/mode/r/index.html
@@ -15,12 +15,12 @@
.cm-s-default span.cm-arg-is { color: brown; }
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -80,6 +80,6 @@ powerful <- function(x) {list(x2=x*x, x3=x*x*x, x4=x*x*x*x)}
<p><strong>MIME types defined:</strong> <code>text/x-rsrc</code>.</p>
<p>Development of the CodeMirror R mode was kindly sponsored
- by <a href="http://ubalo.com/">Ubalo</a>.</p>
+ by <a href="https://twitter.com/ubalo">Ubalo</a>.</p>
</article>
diff --git a/data/ext/editorText/codemirror/mode/r/r.js b/data/ext/editorText/codemirror/mode/r/r.js
index 738540238..1ab4a9565 100644
--- a/data/ext/editorText/codemirror/mode/r/r.js
+++ b/data/ext/editorText/codemirror/mode/r/r.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("r", function(config) {
function wordObj(str) {
var words = str.split(" "), res = {};
@@ -145,3 +158,5 @@ CodeMirror.defineMode("r", function(config) {
});
CodeMirror.defineMIME("text/x-rsrc", "r");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/rpm/changes/changes.js b/data/ext/editorText/codemirror/mode/rpm/changes/changes.js
deleted file mode 100644
index 14a08d970..000000000
--- a/data/ext/editorText/codemirror/mode/rpm/changes/changes.js
+++ /dev/null
@@ -1,19 +0,0 @@
-CodeMirror.defineMode("changes", function() {
- var headerSeperator = /^-+$/;
- var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /;
- var simpleEmail = /^[\w+.-]+@[\w.-]+/;
-
- return {
- token: function(stream) {
- if (stream.sol()) {
- if (stream.match(headerSeperator)) { return 'tag'; }
- if (stream.match(headerLine)) { return 'tag'; }
- }
- if (stream.match(simpleEmail)) { return 'string'; }
- stream.next();
- return null;
- }
- };
-});
-
-CodeMirror.defineMIME("text/x-rpm-changes", "changes");
diff --git a/data/ext/editorText/codemirror/mode/rpm/changes/index.html b/data/ext/editorText/codemirror/mode/rpm/changes/index.html
index 0ade01796..6e5031bd1 100644
--- a/data/ext/editorText/codemirror/mode/rpm/changes/index.html
+++ b/data/ext/editorText/codemirror/mode/rpm/changes/index.html
@@ -11,12 +11,12 @@
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../../doc/logo.png"></a>
<ul>
<li><a href="../../../index.html">Home</a>
<li><a href="../../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/rpm/spec/index.html b/data/ext/editorText/codemirror/mode/rpm/index.html
similarity index 59%
rename from data/ext/editorText/codemirror/mode/rpm/spec/index.html
rename to data/ext/editorText/codemirror/mode/rpm/index.html
index 127b72ee9..9a34e6dfb 100644
--- a/data/ext/editorText/codemirror/mode/rpm/spec/index.html
+++ b/data/ext/editorText/codemirror/mode/rpm/index.html
@@ -1,34 +1,70 @@
<!doctype html>
-<title>CodeMirror: RPM spec mode</title>
+<title>CodeMirror: RPM changes mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
- <link rel="stylesheet" href="../../../lib/codemirror.css">
- <script src="../../../lib/codemirror.js"></script>
- <script src="spec.js"></script>
- <link rel="stylesheet" href="spec.css">
- <link rel="stylesheet" href="../../../doc/docs.css">
+ <link rel="stylesheet" href="../../lib/codemirror.css">
+ <script src="../../lib/codemirror.js"></script>
+ <script src="rpm.js"></script>
+ <link rel="stylesheet" href="../../doc/docs.css">
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
- <li><a href="../../../index.html">Home</a>
- <li><a href="../../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
- <li><a href="../../index.html">Language modes</a>
- <li><a class=active href="#">RPM spec</a>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">RPM</a>
</ul>
</div>
<article>
+<h2>RPM changes mode</h2>
+
+ <div><textarea id="code" name="code">
+-------------------------------------------------------------------
+Tue Oct 18 13:58:40 UTC 2011 - [email protected]
+
+- Update to r60.3
+- Fixes bug in the reflect package
+ * disallow Interface method on Value obtained via unexported name
+
+-------------------------------------------------------------------
+Thu Oct 6 08:14:24 UTC 2011 - [email protected]
+
+- Update to r60.2
+- Fixes memory leak in certain map types
+
+-------------------------------------------------------------------
+Wed Oct 5 14:34:10 UTC 2011 - [email protected]
+
+- Tweaks for gdb debugging
+- go.spec changes:
+ - move %go_arch definition to %prep section
+ - pass correct location of go specific gdb pretty printer and
+ functions to cpp as HOST_EXTRA_CFLAGS macro
+ - install go gdb functions & printer
+- gdb-printer.patch
+ - patch linker (src/cmd/ld/dwarf.c) to emit correct location of go
+ gdb functions and pretty printer
+</textarea></div>
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ mode: {name: "rpm-changes"},
+ lineNumbers: true,
+ indentUnit: 4
+ });
+ </script>
+
<h2>RPM spec mode</h2>
- <div><textarea id="code" name="code">
+ <div><textarea id="code2" name="code2">
#
# spec file for package minidlna
#
@@ -102,13 +138,12 @@ find %{buildroot} -type f -name '*.la' -exec rm -f {} ';'
%changelog</textarea></div>
<script>
- var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
- mode: {name: "spec"},
+ var editor = CodeMirror.fromTextArea(document.getElementById("code2"), {
+ mode: {name: "rpm-spec"},
lineNumbers: true,
indentUnit: 4
});
</script>
- <p><strong>MIME types defined:</strong> <code>text/x-rpm-spec</code>.</p>
-
+ <p><strong>MIME types defined:</strong> <code>text/x-rpm-spec</code>, <code>text/x-rpm-changes</code>.</p>
</article>
diff --git a/data/ext/editorText/codemirror/mode/rpm/rpm.js b/data/ext/editorText/codemirror/mode/rpm/rpm.js
new file mode 100644
index 000000000..87cde591a
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/rpm/rpm.js
@@ -0,0 +1,109 @@
+// 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";
+
+CodeMirror.defineMode("rpm-changes", function() {
+ var headerSeperator = /^-+$/;
+ var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /;
+ var simpleEmail = /^[\w+.-]+@[\w.-]+/;
+
+ return {
+ token: function(stream) {
+ if (stream.sol()) {
+ if (stream.match(headerSeperator)) { return 'tag'; }
+ if (stream.match(headerLine)) { return 'tag'; }
+ }
+ if (stream.match(simpleEmail)) { return 'string'; }
+ stream.next();
+ return null;
+ }
+ };
+});
+
+CodeMirror.defineMIME("text/x-rpm-changes", "rpm-changes");
+
+// Quick and dirty spec file highlighting
+
+CodeMirror.defineMode("rpm-spec", function() {
+ var arch = /^(i386|i586|i686|x86_64|ppc64le|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
+
+ var preamble = /^[a-zA-Z0-9()]+:/;
+ var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pretrans|posttrans|pre|post|triggerin|triggerun|verifyscript|check|triggerpostun|triggerprein|trigger)/;
+ var control_flow_complex = /^%(ifnarch|ifarch|if)/; // rpm control flow macros
+ var control_flow_simple = /^%(else|endif)/; // rpm control flow macros
+ var operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/; // operators in control flow macros
+
+ return {
+ startState: function () {
+ return {
+ controlFlow: false,
+ macroParameters: false,
+ section: false
+ };
+ },
+ token: function (stream, state) {
+ var ch = stream.peek();
+ if (ch == "#") { stream.skipToEnd(); return "comment"; }
+
+ if (stream.sol()) {
+ if (stream.match(preamble)) { return "header"; }
+ if (stream.match(section)) { return "atom"; }
+ }
+
+ if (stream.match(/^\$\w+/)) { return "def"; } // Variables like '$RPM_BUILD_ROOT'
+ if (stream.match(/^\$\{\w+\}/)) { return "def"; } // Variables like '${RPM_BUILD_ROOT}'
+
+ if (stream.match(control_flow_simple)) { return "keyword"; }
+ if (stream.match(control_flow_complex)) {
+ state.controlFlow = true;
+ return "keyword";
+ }
+ if (state.controlFlow) {
+ if (stream.match(operators)) { return "operator"; }
+ if (stream.match(/^(\d+)/)) { return "number"; }
+ if (stream.eol()) { state.controlFlow = false; }
+ }
+
+ if (stream.match(arch)) {
+ if (stream.eol()) { state.controlFlow = false; }
+ return "number";
+ }
+
+ // Macros like '%make_install' or '%attr(0775,root,root)'
+ if (stream.match(/^%[\w]+/)) {
+ if (stream.match(/^\(/)) { state.macroParameters = true; }
+ return "keyword";
+ }
+ if (state.macroParameters) {
+ if (stream.match(/^\d+/)) { return "number";}
+ if (stream.match(/^\)/)) {
+ state.macroParameters = false;
+ return "keyword";
+ }
+ }
+
+ // Macros like '%{defined fedora}'
+ if (stream.match(/^%\{\??[\w \-\:\!]+\}/)) {
+ if (stream.eol()) { state.controlFlow = false; }
+ return "def";
+ }
+
+ //TODO: Include bash script sub-parser (CodeMirror supports that)
+ stream.next();
+ return null;
+ }
+ };
+});
+
+CodeMirror.defineMIME("text/x-rpm-spec", "rpm-spec");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/rpm/spec/spec.css b/data/ext/editorText/codemirror/mode/rpm/spec/spec.css
deleted file mode 100644
index d0a5d430c..000000000
--- a/data/ext/editorText/codemirror/mode/rpm/spec/spec.css
+++ /dev/null
@@ -1,5 +0,0 @@
-.cm-s-default span.cm-preamble {color: #b26818; font-weight: bold;}
-.cm-s-default span.cm-macro {color: #b218b2;}
-.cm-s-default span.cm-section {color: green; font-weight: bold;}
-.cm-s-default span.cm-script {color: red;}
-.cm-s-default span.cm-issue {color: yellow;}
diff --git a/data/ext/editorText/codemirror/mode/rpm/spec/spec.js b/data/ext/editorText/codemirror/mode/rpm/spec/spec.js
deleted file mode 100644
index 0fab6c489..000000000
--- a/data/ext/editorText/codemirror/mode/rpm/spec/spec.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// Quick and dirty spec file highlighting
-
-CodeMirror.defineMode("spec", function() {
- var arch = /^(i386|i586|i686|x86_64|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
-
- var preamble = /^(Name|Version|Release|License|Summary|Url|Group|Source|BuildArch|BuildRequires|BuildRoot|AutoReqProv|Provides|Requires(\(\w+\))?|Obsoletes|Conflicts|Recommends|Source\d*|Patch\d*|ExclusiveArch|NoSource|Supplements):/;
- var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pre|post|triggerin|triggerun|pretrans|posttrans|verifyscript|check|triggerpostun|triggerprein|trigger)/;
- var control_flow_complex = /^%(ifnarch|ifarch|if)/; // rpm control flow macros
- var control_flow_simple = /^%(else|endif)/; // rpm control flow macros
- var operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/; // operators in control flow macros
-
- return {
- startState: function () {
- return {
- controlFlow: false,
- macroParameters: false,
- section: false
- };
- },
- token: function (stream, state) {
- var ch = stream.peek();
- if (ch == "#") { stream.skipToEnd(); return "comment"; }
-
- if (stream.sol()) {
- if (stream.match(preamble)) { return "preamble"; }
- if (stream.match(section)) { return "section"; }
- }
-
- if (stream.match(/^\$\w+/)) { return "def"; } // Variables like '$RPM_BUILD_ROOT'
- if (stream.match(/^\$\{\w+\}/)) { return "def"; } // Variables like '${RPM_BUILD_ROOT}'
-
- if (stream.match(control_flow_simple)) { return "keyword"; }
- if (stream.match(control_flow_complex)) {
- state.controlFlow = true;
- return "keyword";
- }
- if (state.controlFlow) {
- if (stream.match(operators)) { return "operator"; }
- if (stream.match(/^(\d+)/)) { return "number"; }
- if (stream.eol()) { state.controlFlow = false; }
- }
-
- if (stream.match(arch)) { return "number"; }
-
- // Macros like '%make_install' or '%attr(0775,root,root)'
- if (stream.match(/^%[\w]+/)) {
- if (stream.match(/^\(/)) { state.macroParameters = true; }
- return "macro";
- }
- if (state.macroParameters) {
- if (stream.match(/^\d+/)) { return "number";}
- if (stream.match(/^\)/)) {
- state.macroParameters = false;
- return "macro";
- }
- }
- if (stream.match(/^%\{\??[\w \-]+\}/)) { return "macro"; } // Macros like '%{defined fedora}'
-
- //TODO: Include bash script sub-parser (CodeMirror supports that)
- stream.next();
- return null;
- }
- };
-});
-
-CodeMirror.defineMIME("text/x-rpm-spec", "spec");
diff --git a/data/ext/editorText/codemirror/mode/rst/index.html b/data/ext/editorText/codemirror/mode/rst/index.html
index cb8269751..2902dea23 100644
--- a/data/ext/editorText/codemirror/mode/rst/index.html
+++ b/data/ext/editorText/codemirror/mode/rst/index.html
@@ -10,12 +10,12 @@
<script src="rst.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/rst/rst.js b/data/ext/editorText/codemirror/mode/rst/rst.js
index 4bb2219fa..bcf110c1a 100644
--- a/data/ext/editorText/codemirror/mode/rst/rst.js
+++ b/data/ext/editorText/codemirror/mode/rst/rst.js
@@ -1,3 +1,16 @@
+// 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"), require("../python/python"), require("../stex/stex"), require("../../addon/mode/overlay"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../python/python", "../stex/stex", "../../addon/mode/overlay"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode('rst', function (config, options) {
var rx_strong = /^\*\*[^\*\s](?:[^\*]*[^\*\s])?\*\*/;
@@ -67,19 +80,6 @@ CodeMirror.defineMode('rst-base', function (config) {
});
}
- function AssertException(message) {
- this.message = message;
- }
-
- AssertException.prototype.toString = function () {
- return 'AssertException: ' + this.message;
- };
-
- function assert(expression, message) {
- if (!expression) throw new AssertException(message);
- return expression;
- }
-
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
@@ -172,12 +172,12 @@ CodeMirror.defineMode('rst-base', function (config) {
switch (stage(state)) {
case 0:
change(state, to_normal, context(rx_role_pre, 1));
- assert(stream.match(/^:/));
+ stream.match(/^:/);
token = 'meta';
break;
case 1:
change(state, to_normal, context(rx_role_pre, 2));
- assert(stream.match(rx_NAME));
+ stream.match(rx_NAME);
token = 'keyword';
if (stream.current().match(/^(?:math|latex)/)) {
@@ -186,7 +186,7 @@ CodeMirror.defineMode('rst-base', function (config) {
break;
case 2:
change(state, to_normal, context(rx_role_pre, 3));
- assert(stream.match(/^:`/));
+ stream.match(/^:`/);
token = 'meta';
break;
case 3:
@@ -208,21 +208,20 @@ CodeMirror.defineMode('rst-base', function (config) {
}
change(state, to_normal, context(rx_role_pre, 4));
- assert(stream.match(rx_TEXT2));
+ stream.match(rx_TEXT2);
token = 'string';
break;
case 4:
change(state, to_normal, context(rx_role_pre, 5));
- assert(stream.match(/^`/));
+ stream.match(/^`/);
token = 'meta';
break;
case 5:
change(state, to_normal, context(rx_role_pre, 6));
- assert(stream.match(rx_TAIL));
+ stream.match(rx_TAIL);
break;
default:
change(state, to_normal);
- assert(stream.current() == '');
}
} else if (phase(state) == rx_role_suf ||
stream.match(rx_role_suf, false)) {
@@ -230,62 +229,60 @@ CodeMirror.defineMode('rst-base', function (config) {
switch (stage(state)) {
case 0:
change(state, to_normal, context(rx_role_suf, 1));
- assert(stream.match(/^`/));
+ stream.match(/^`/);
token = 'meta';
break;
case 1:
change(state, to_normal, context(rx_role_suf, 2));
- assert(stream.match(rx_TEXT2));
+ stream.match(rx_TEXT2);
token = 'string';
break;
case 2:
change(state, to_normal, context(rx_role_suf, 3));
- assert(stream.match(/^`:/));
+ stream.match(/^`:/);
token = 'meta';
break;
case 3:
change(state, to_normal, context(rx_role_suf, 4));
- assert(stream.match(rx_NAME));
+ stream.match(rx_NAME);
token = 'keyword';
break;
case 4:
change(state, to_normal, context(rx_role_suf, 5));
- assert(stream.match(/^:/));
+ stream.match(/^:/);
token = 'meta';
break;
case 5:
change(state, to_normal, context(rx_role_suf, 6));
- assert(stream.match(rx_TAIL));
+ stream.match(rx_TAIL);
break;
default:
change(state, to_normal);
- assert(stream.current() == '');
}
} else if (phase(state) == rx_role || stream.match(rx_role, false)) {
switch (stage(state)) {
case 0:
change(state, to_normal, context(rx_role, 1));
- assert(stream.match(/^:/));
+ stream.match(/^:/);
token = 'meta';
break;
case 1:
change(state, to_normal, context(rx_role, 2));
- assert(stream.match(rx_NAME));
+ stream.match(rx_NAME);
token = 'keyword';
break;
case 2:
change(state, to_normal, context(rx_role, 3));
- assert(stream.match(/^:/));
+ stream.match(/^:/);
token = 'meta';
break;
case 3:
change(state, to_normal, context(rx_role, 4));
- assert(stream.match(rx_TAIL));
+ stream.match(rx_TAIL);
break;
default:
change(state, to_normal);
- assert(stream.current() == '');
}
} else if (phase(state) == rx_substitution_ref ||
stream.match(rx_substitution_ref, false)) {
@@ -293,7 +290,7 @@ CodeMirror.defineMode('rst-base', function (config) {
switch (stage(state)) {
case 0:
change(state, to_normal, context(rx_substitution_ref, 1));
- assert(stream.match(rx_substitution_text));
+ stream.match(rx_substitution_text);
token = 'variable-2';
break;
case 1:
@@ -302,7 +299,6 @@ CodeMirror.defineMode('rst-base', function (config) {
break;
default:
change(state, to_normal);
- assert(stream.current() == '');
}
} else if (stream.match(rx_footnote_ref)) {
change(state, to_normal);
@@ -328,21 +324,20 @@ CodeMirror.defineMode('rst-base', function (config) {
break;
case 1:
change(state, to_normal, context(rx_link_ref2, 2));
- assert(stream.match(/^`/));
+ stream.match(/^`/);
token = 'link';
break;
case 2:
change(state, to_normal, context(rx_link_ref2, 3));
- assert(stream.match(rx_TEXT2));
+ stream.match(rx_TEXT2);
break;
case 3:
change(state, to_normal, context(rx_link_ref2, 4));
- assert(stream.match(/^`_/));
+ stream.match(/^`_/);
token = 'link';
break;
default:
change(state, to_normal);
- assert(stream.current() == '');
}
} else if (stream.match(rx_verbatim)) {
change(state, to_verbatim);
@@ -367,26 +362,25 @@ CodeMirror.defineMode('rst-base', function (config) {
switch (stage(state)) {
case 0:
change(state, to_explicit, context(rx_substitution, 1));
- assert(stream.match(rx_substitution_text));
+ stream.match(rx_substitution_text);
token = 'variable-2';
break;
case 1:
change(state, to_explicit, context(rx_substitution, 2));
- assert(stream.match(rx_substitution_sepa));
+ stream.match(rx_substitution_sepa);
break;
case 2:
change(state, to_explicit, context(rx_substitution, 3));
- assert(stream.match(rx_substitution_name));
+ stream.match(rx_substitution_name);
token = 'keyword';
break;
case 3:
change(state, to_explicit, context(rx_substitution, 4));
- assert(stream.match(rx_substitution_tail));
+ stream.match(rx_substitution_tail);
token = 'meta';
break;
default:
change(state, to_normal);
- assert(stream.current() == '');
}
} else if (phase(state) == rx_directive ||
stream.match(rx_directive, false)) {
@@ -394,7 +388,7 @@ CodeMirror.defineMode('rst-base', function (config) {
switch (stage(state)) {
case 0:
change(state, to_explicit, context(rx_directive, 1));
- assert(stream.match(rx_directive_name));
+ stream.match(rx_directive_name);
token = 'keyword';
if (stream.current().match(/^(?:math|latex)/))
@@ -404,7 +398,7 @@ CodeMirror.defineMode('rst-base', function (config) {
break;
case 1:
change(state, to_explicit, context(rx_directive, 2));
- assert(stream.match(rx_directive_tail));
+ stream.match(rx_directive_tail);
token = 'meta';
if (stream.match(/^latex\s*$/) || state.tmp_stex) {
@@ -423,25 +417,23 @@ CodeMirror.defineMode('rst-base', function (config) {
break;
default:
change(state, to_normal);
- assert(stream.current() == '');
}
} else if (phase(state) == rx_link || stream.match(rx_link, false)) {
switch (stage(state)) {
case 0:
change(state, to_explicit, context(rx_link, 1));
- assert(stream.match(rx_link_head));
- assert(stream.match(rx_link_name));
+ stream.match(rx_link_head);
+ stream.match(rx_link_name);
token = 'link';
break;
case 1:
change(state, to_explicit, context(rx_link, 2));
- assert(stream.match(rx_link_tail));
+ stream.match(rx_link_tail);
token = 'meta';
break;
default:
change(state, to_normal);
- assert(stream.current() == '');
}
} else if (stream.match(rx_footnote)) {
change(state, to_normal);
@@ -561,3 +553,5 @@ CodeMirror.defineMIME('text/x-rst', 'rst');
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
+
+});
diff --git a/data/ext/editorText/codemirror/mode/ruby/index.html b/data/ext/editorText/codemirror/mode/ruby/index.html
index 8f0ebca8e..97544babc 100644
--- a/data/ext/editorText/codemirror/mode/ruby/index.html
+++ b/data/ext/editorText/codemirror/mode/ruby/index.html
@@ -13,12 +13,12 @@
.cm-s-default span.cm-arrow { color: red; }
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -178,7 +178,6 @@ end
<p><strong>MIME types defined:</strong> <code>text/x-ruby</code>.</p>
<p>Development of the CodeMirror Ruby mode was kindly sponsored
- by <a href="http://ubalo.com/">Ubalo</a>, who hold
- the <a href="LICENSE">license</a>.</p>
+ by <a href="http://ubalo.com/">Ubalo</a>.</p>
</article>
diff --git a/data/ext/editorText/codemirror/mode/ruby/ruby.js b/data/ext/editorText/codemirror/mode/ruby/ruby.js
index 6a77e2d2a..089a971d4 100644
--- a/data/ext/editorText/codemirror/mode/ruby/ruby.js
+++ b/data/ext/editorText/codemirror/mode/ruby/ruby.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("ruby", function(config) {
function wordObj(words) {
var o = {};
@@ -12,7 +25,7 @@ CodeMirror.defineMode("ruby", function(config) {
"caller", "lambda", "proc", "public", "protected", "private", "require", "load",
"require_relative", "extend", "autoload", "__END__", "__FILE__", "__LINE__", "__dir__"
]);
- var indentWords = wordObj(["def", "class", "case", "for", "while", "module", "then",
+ var indentWords = wordObj(["def", "class", "case", "for", "while", "until", "module", "then",
"catch", "loop", "proc", "begin"]);
var dedentWords = wordObj(["end", "until"]);
var matching = {"[": "]", "{": "}", "(": ")"};
@@ -24,7 +37,6 @@ CodeMirror.defineMode("ruby", function(config) {
}
function tokenBase(stream, state) {
- curPunc = null;
if (stream.sol() && stream.match("=begin") && stream.eol()) {
state.tokenize.push(readBlockComment);
return "comment";
@@ -33,16 +45,30 @@ CodeMirror.defineMode("ruby", function(config) {
var ch = stream.next(), m;
if (ch == "`" || ch == "'" || ch == '"') {
return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
- } else if (ch == "/" && !stream.eol() && stream.peek() != " ") {
- if (stream.eat("=")) return "operator";
- return chain(readQuoted(ch, "string-2", true), stream, state);
+ } else if (ch == "/") {
+ var currentIndex = stream.current().length;
+ if (stream.skipTo("/")) {
+ var search_till = stream.current().length;
+ stream.backUp(stream.current().length - currentIndex);
+ var balance = 0; // balance brackets
+ while (stream.current().length < search_till) {
+ var chchr = stream.next();
+ if (chchr == "(") balance += 1;
+ else if (chchr == ")") balance -= 1;
+ if (balance < 0) break;
+ }
+ stream.backUp(stream.current().length - currentIndex);
+ if (balance == 0)
+ return chain(readQuoted(ch, "string-2", true), stream, state);
+ }
+ return "operator";
} else if (ch == "%") {
var style = "string", embed = true;
if (stream.eat("s")) style = "atom";
else if (stream.eat(/[WQ]/)) style = "string";
else if (stream.eat(/[r]/)) style = "string-2";
else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; }
- var delim = stream.eat(/[^\w\s]/);
+ var delim = stream.eat(/[^\w\s=]/);
if (!delim) return "operator";
if (matching.propertyIsEnumerable(delim)) delim = matching[delim];
return chain(readQuoted(delim, style, embed, true), stream, state);
@@ -80,16 +106,16 @@ CodeMirror.defineMode("ruby", function(config) {
}
// Symbols can't start by a digit
- if (stream.eat(/[a-zA-Z$@_]/)) {
- stream.eatWhile(/[\w]/);
+ if (stream.eat(/[a-zA-Z$@_\xa1-\uffff]/)) {
+ stream.eatWhile(/[\w$\xa1-\uffff]/);
// Only one ? ! = is allowed and only as the last character
stream.eat(/[\?\!\=]/);
return "atom";
}
return "operator";
- } else if (ch == "@" && stream.match(/^@?[a-zA-Z_]/)) {
+ } else if (ch == "@" && stream.match(/^@?[a-zA-Z_\xa1-\uffff]/)) {
stream.eat("@");
- stream.eatWhile(/[\w]/);
+ stream.eatWhile(/[\w\xa1-\uffff]/);
return "variable-2";
} else if (ch == "$") {
if (stream.eat(/[a-zA-Z_]/)) {
@@ -100,8 +126,8 @@ CodeMirror.defineMode("ruby", function(config) {
stream.next(); // Must be a special global like $: or $!
}
return "variable-3";
- } else if (/[a-zA-Z_]/.test(ch)) {
- stream.eatWhile(/[\w]/);
+ } else if (/[a-zA-Z_\xa1-\uffff]/.test(ch)) {
+ stream.eatWhile(/[\w\xa1-\uffff]/);
stream.eat(/[\?\!]/);
if (stream.eat(":")) return "atom";
return "ident";
@@ -114,24 +140,26 @@ CodeMirror.defineMode("ruby", function(config) {
} else if (ch == "-" && stream.eat(">")) {
return "arrow";
} else if (/[=+\-\/*:\.^%<>~|]/.test(ch)) {
- stream.eatWhile(/[=+\-\/*:\.^%<>~|]/);
+ var more = stream.eatWhile(/[=+\-\/*:\.^%<>~|]/);
+ if (ch == "." && !more) curPunc = ".";
return "operator";
} else {
return null;
}
}
- function tokenBaseUntilBrace() {
- var depth = 1;
+ function tokenBaseUntilBrace(depth) {
+ if (!depth) depth = 1;
return function(stream, state) {
if (stream.peek() == "}") {
- depth--;
- if (depth == 0) {
+ if (depth == 1) {
state.tokenize.pop();
return state.tokenize[state.tokenize.length-1](stream, state);
+ } else {
+ state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth - 1);
}
} else if (stream.peek() == "{") {
- depth++;
+ state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth + 1);
}
return tokenBase(stream, state);
};
@@ -203,22 +231,28 @@ CodeMirror.defineMode("ruby", function(config) {
},
token: function(stream, state) {
+ curPunc = null;
if (stream.sol()) state.indented = stream.indentation();
var style = state.tokenize[state.tokenize.length-1](stream, state), kwtype;
+ var thisTok = curPunc;
if (style == "ident") {
var word = stream.current();
- style = keywords.propertyIsEnumerable(stream.current()) ? "keyword"
+ style = state.lastTok == "." ? "property"
+ : keywords.propertyIsEnumerable(stream.current()) ? "keyword"
: /^[A-Z]/.test(word) ? "tag"
: (state.lastTok == "def" || state.lastTok == "class" || state.varList) ? "def"
: "variable";
- if (indentWords.propertyIsEnumerable(word)) kwtype = "indent";
- else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent";
- else if ((word == "if" || word == "unless") && stream.column() == stream.indentation())
- kwtype = "indent";
- else if (word == "do" && state.context.indented < state.indented)
- kwtype = "indent";
+ if (style == "keyword") {
+ thisTok = word;
+ if (indentWords.propertyIsEnumerable(word)) kwtype = "indent";
+ else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent";
+ else if ((word == "if" || word == "unless") && stream.column() == stream.indentation())
+ kwtype = "indent";
+ else if (word == "do" && state.context.indented < state.indented)
+ kwtype = "indent";
+ }
}
- if (curPunc || (style && style != "comment")) state.lastTok = word || curPunc || style;
+ if (curPunc || (style && style != "comment")) state.lastTok = thisTok;
if (curPunc == "|") state.varList = !state.varList;
if (kwtype == "indent" || /[\(\[\{]/.test(curPunc))
@@ -248,3 +282,4 @@ CodeMirror.defineMode("ruby", function(config) {
CodeMirror.defineMIME("text/x-ruby", "ruby");
+});
diff --git a/data/ext/editorText/codemirror/mode/ruby/test.js b/data/ext/editorText/codemirror/mode/ruby/test.js
index c97d10668..cade864ff 100644
--- a/data/ext/editorText/codemirror/mode/ruby/test.js
+++ b/data/ext/editorText/codemirror/mode/ruby/test.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "ruby");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
diff --git a/data/ext/editorText/codemirror/mode/rust/index.html b/data/ext/editorText/codemirror/mode/rust/index.html
index 4fc099922..1fe0ad1e6 100644
--- a/data/ext/editorText/codemirror/mode/rust/index.html
+++ b/data/ext/editorText/codemirror/mode/rust/index.html
@@ -6,15 +6,16 @@
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/mode/simple.js"></script>
<script src="rust.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -37,22 +38,25 @@ enum bar {
fn check_crate(x: int) {
let v = 10;
- alt foo {
- 1 to 3 {
- print_foo();
- if x {
- blah() + 10;
+ match foo {
+ 1 ... 3 {
+ print_foo();
+ if x {
+ blah().to_string();
+ }
}
- }
- (x, y) { "bye" }
- _ { "hi" }
+ (x, y) { "bye" }
+ _ { "hi" }
}
}
</textarea></div>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
- lineNumbers: true
+ lineNumbers: true,
+ lineWrapping: true,
+ indentUnit: 4,
+ mode: "rust"
});
</script>
diff --git a/data/ext/editorText/codemirror/mode/rust/rust.js b/data/ext/editorText/codemirror/mode/rust/rust.js
index c7530b6cc..1ce0c01ee 100644
--- a/data/ext/editorText/codemirror/mode/rust/rust.js
+++ b/data/ext/editorText/codemirror/mode/rust/rust.js
@@ -1,436 +1,58 @@
-CodeMirror.defineMode("rust", function() {
- var indentUnit = 4, altIndentUnit = 2;
- var valKeywords = {
- "if": "if-style", "while": "if-style", "else": "else-style",
- "do": "else-style", "ret": "else-style", "fail": "else-style",
- "break": "atom", "cont": "atom", "const": "let", "resource": "fn",
- "let": "let", "fn": "fn", "for": "for", "alt": "alt", "iface": "iface",
- "impl": "impl", "type": "type", "enum": "enum", "mod": "mod",
- "as": "op", "true": "atom", "false": "atom", "assert": "op", "check": "op",
- "claim": "op", "native": "ignore", "unsafe": "ignore", "import": "else-style",
- "export": "else-style", "copy": "op", "log": "op", "log_err": "op",
- "use": "op", "bind": "op", "self": "atom"
- };
- var typeKeywords = function() {
- var keywords = {"fn": "fn", "block": "fn", "obj": "obj"};
- var atoms = "bool uint int i8 i16 i32 i64 u8 u16 u32 u64 float f32 f64 str char".split(" ");
- for (var i = 0, e = atoms.length; i < e; ++i) keywords[atoms[i]] = "atom";
- return keywords;
- }();
- var operatorChar = /[+\-*&%=<>!?|\.@]/;
-
- // Tokenizer
-
- // Used as scratch variable to communicate multiple values without
- // consing up tons of objects.
- var tcat, content;
- function r(tc, style) {
- tcat = tc;
- return style;
- }
-
- function tokenBase(stream, state) {
- var ch = stream.next();
- if (ch == '"') {
- state.tokenize = tokenString;
- return state.tokenize(stream, state);
- }
- if (ch == "'") {
- tcat = "atom";
- if (stream.eat("\\")) {
- if (stream.skipTo("'")) { stream.next(); return "string"; }
- else { return "error"; }
- } else {
- stream.next();
- return stream.eat("'") ? "string" : "error";
- }
- }
- if (ch == "/") {
- if (stream.eat("/")) { stream.skipToEnd(); return "comment"; }
- if (stream.eat("*")) {
- state.tokenize = tokenComment(1);
- return state.tokenize(stream, state);
- }
- }
- if (ch == "#") {
- if (stream.eat("[")) { tcat = "open-attr"; return null; }
- stream.eatWhile(/\w/);
- return r("macro", "meta");
- }
- if (ch == ":" && stream.match(":<")) {
- return r("op", null);
- }
- if (ch.match(/\d/) || (ch == "." && stream.eat(/\d/))) {
- var flp = false;
- if (!stream.match(/^x[\da-f]+/i) && !stream.match(/^b[01]+/)) {
- stream.eatWhile(/\d/);
- if (stream.eat(".")) { flp = true; stream.eatWhile(/\d/); }
- if (stream.match(/^e[+\-]?\d+/i)) { flp = true; }
- }
- if (flp) stream.match(/^f(?:32|64)/);
- else stream.match(/^[ui](?:8|16|32|64)/);
- return r("atom", "number");
- }
- if (ch.match(/[()\[\]{}:;,]/)) return r(ch, null);
- if (ch == "-" && stream.eat(">")) return r("->", null);
- if (ch.match(operatorChar)) {
- stream.eatWhile(operatorChar);
- return r("op", null);
- }
- stream.eatWhile(/\w/);
- content = stream.current();
- if (stream.match(/^::\w/)) {
- stream.backUp(1);
- return r("prefix", "variable-2");
- }
- if (state.keywords.propertyIsEnumerable(content))
- return r(state.keywords[content], content.match(/true|false/) ? "atom" : "keyword");
- return r("name", "variable");
- }
-
- function tokenString(stream, state) {
- var ch, escaped = false;
- while (ch = stream.next()) {
- if (ch == '"' && !escaped) {
- state.tokenize = tokenBase;
- return r("atom", "string");
- }
- escaped = !escaped && ch == "\\";
- }
- // Hack to not confuse the parser when a string is split in
- // pieces.
- return r("op", "string");
- }
-
- function tokenComment(depth) {
- return function(stream, state) {
- var lastCh = null, ch;
- while (ch = stream.next()) {
- if (ch == "/" && lastCh == "*") {
- if (depth == 1) {
- state.tokenize = tokenBase;
- break;
- } else {
- state.tokenize = tokenComment(depth - 1);
- return state.tokenize(stream, state);
- }
- }
- if (ch == "*" && lastCh == "/") {
- state.tokenize = tokenComment(depth + 1);
- return state.tokenize(stream, state);
- }
- lastCh = ch;
- }
- return "comment";
- };
- }
-
- // Parser
-
- var cx = {state: null, stream: null, marked: null, cc: null};
- function pass() {
- for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
- }
- function cont() {
- pass.apply(null, arguments);
- return true;
- }
-
- function pushlex(type, info) {
- var result = function() {
- var state = cx.state;
- state.lexical = {indented: state.indented, column: cx.stream.column(),
- type: type, prev: state.lexical, info: info};
- };
- result.lex = true;
- return result;
- }
- function poplex() {
- var state = cx.state;
- if (state.lexical.prev) {
- if (state.lexical.type == ")")
- state.indented = state.lexical.indented;
- state.lexical = state.lexical.prev;
- }
- }
- function typecx() { cx.state.keywords = typeKeywords; }
- function valcx() { cx.state.keywords = valKeywords; }
- poplex.lex = typecx.lex = valcx.lex = true;
-
- function commasep(comb, end) {
- function more(type) {
- if (type == ",") return cont(comb, more);
- if (type == end) return cont();
- return cont(more);
- }
- return function(type) {
- if (type == end) return cont();
- return pass(comb, more);
- };
- }
-
- function stat_of(comb, tag) {
- return cont(pushlex("stat", tag), comb, poplex, block);
- }
- function block(type) {
- if (type == "}") return cont();
- if (type == "let") return stat_of(letdef1, "let");
- if (type == "fn") return stat_of(fndef);
- if (type == "type") return cont(pushlex("stat"), tydef, endstatement, poplex, block);
- if (type == "enum") return stat_of(enumdef);
- if (type == "mod") return stat_of(mod);
- if (type == "iface") return stat_of(iface);
- if (type == "impl") return stat_of(impl);
- if (type == "open-attr") return cont(pushlex("]"), commasep(expression, "]"), poplex);
- if (type == "ignore" || type.match(/[\]\);,]/)) return cont(block);
- return pass(pushlex("stat"), expression, poplex, endstatement, block);
- }
- function endstatement(type) {
- if (type == ";") return cont();
- return pass();
- }
- function expression(type) {
- if (type == "atom" || type == "name") return cont(maybeop);
- if (type == "{") return cont(pushlex("}"), exprbrace, poplex);
- if (type.match(/[\[\(]/)) return matchBrackets(type, expression);
- if (type.match(/[\]\)\};,]/)) return pass();
- if (type == "if-style") return cont(expression, expression);
- if (type == "else-style" || type == "op") return cont(expression);
- if (type == "for") return cont(pattern, maybetype, inop, expression, expression);
- if (type == "alt") return cont(expression, altbody);
- if (type == "fn") return cont(fndef);
- if (type == "macro") return cont(macro);
- return cont();
- }
- function maybeop(type) {
- if (content == ".") return cont(maybeprop);
- if (content == "::<"){return cont(typarams, maybeop);}
- if (type == "op" || content == ":") return cont(expression);
- if (type == "(" || type == "[") return matchBrackets(type, expression);
- return pass();
- }
- function maybeprop() {
- if (content.match(/^\w+$/)) {cx.marked = "variable"; return cont(maybeop);}
- return pass(expression);
- }
- function exprbrace(type) {
- if (type == "op") {
- if (content == "|") return cont(blockvars, poplex, pushlex("}", "block"), block);
- if (content == "||") return cont(poplex, pushlex("}", "block"), block);
- }
- if (content == "mutable" || (content.match(/^\w+$/) && cx.stream.peek() == ":"
- && !cx.stream.match("::", false)))
- return pass(record_of(expression));
- return pass(block);
- }
- function record_of(comb) {
- function ro(type) {
- if (content == "mutable" || content == "with") {cx.marked = "keyword"; return cont(ro);}
- if (content.match(/^\w*$/)) {cx.marked = "variable"; return cont(ro);}
- if (type == ":") return cont(comb, ro);
- if (type == "}") return cont();
- return cont(ro);
- }
- return ro;
- }
- function blockvars(type) {
- if (type == "name") {cx.marked = "def"; return cont(blockvars);}
- if (type == "op" && content == "|") return cont();
- return cont(blockvars);
- }
-
- function letdef1(type) {
- if (type.match(/[\]\)\};]/)) return cont();
- if (content == "=") return cont(expression, letdef2);
- if (type == ",") return cont(letdef1);
- return pass(pattern, maybetype, letdef1);
- }
- function letdef2(type) {
- if (type.match(/[\]\)\};,]/)) return pass(letdef1);
- else return pass(expression, letdef2);
- }
- function maybetype(type) {
- if (type == ":") return cont(typecx, rtype, valcx);
- return pass();
- }
- function inop(type) {
- if (type == "name" && content == "in") {cx.marked = "keyword"; return cont();}
- return pass();
- }
- function fndef(type) {
- if (content == "@" || content == "~") {cx.marked = "keyword"; return cont(fndef);}
- if (type == "name") {cx.marked = "def"; return cont(fndef);}
- if (content == "<") return cont(typarams, fndef);
- if (type == "{") return pass(expression);
- if (type == "(") return cont(pushlex(")"), commasep(argdef, ")"), poplex, fndef);
- if (type == "->") return cont(typecx, rtype, valcx, fndef);
- if (type == ";") return cont();
- return cont(fndef);
- }
- function tydef(type) {
- if (type == "name") {cx.marked = "def"; return cont(tydef);}
- if (content == "<") return cont(typarams, tydef);
- if (content == "=") return cont(typecx, rtype, valcx);
- return cont(tydef);
- }
- function enumdef(type) {
- if (type == "name") {cx.marked = "def"; return cont(enumdef);}
- if (content == "<") return cont(typarams, enumdef);
- if (content == "=") return cont(typecx, rtype, valcx, endstatement);
- if (type == "{") return cont(pushlex("}"), typecx, enumblock, valcx, poplex);
- return cont(enumdef);
- }
- function enumblock(type) {
- if (type == "}") return cont();
- if (type == "(") return cont(pushlex(")"), commasep(rtype, ")"), poplex, enumblock);
- if (content.match(/^\w+$/)) cx.marked = "def";
- return cont(enumblock);
- }
- function mod(type) {
- if (type == "name") {cx.marked = "def"; return cont(mod);}
- if (type == "{") return cont(pushlex("}"), block, poplex);
- return pass();
- }
- function iface(type) {
- if (type == "name") {cx.marked = "def"; return cont(iface);}
- if (content == "<") return cont(typarams, iface);
- if (type == "{") return cont(pushlex("}"), block, poplex);
- return pass();
- }
- function impl(type) {
- if (content == "<") return cont(typarams, impl);
- if (content == "of" || content == "for") {cx.marked = "keyword"; return cont(rtype, impl);}
- if (type == "name") {cx.marked = "def"; return cont(impl);}
- if (type == "{") return cont(pushlex("}"), block, poplex);
- return pass();
- }
- function typarams() {
- if (content == ">") return cont();
- if (content == ",") return cont(typarams);
- if (content == ":") return cont(rtype, typarams);
- return pass(rtype, typarams);
- }
- function argdef(type) {
- if (type == "name") {cx.marked = "def"; return cont(argdef);}
- if (type == ":") return cont(typecx, rtype, valcx);
- return pass();
- }
- function rtype(type) {
- if (type == "name") {cx.marked = "variable-3"; return cont(rtypemaybeparam); }
- if (content == "mutable") {cx.marked = "keyword"; return cont(rtype);}
- if (type == "atom") return cont(rtypemaybeparam);
- if (type == "op" || type == "obj") return cont(rtype);
- if (type == "fn") return cont(fntype);
- if (type == "{") return cont(pushlex("{"), record_of(rtype), poplex);
- return matchBrackets(type, rtype);
- }
- function rtypemaybeparam() {
- if (content == "<") return cont(typarams);
- return pass();
- }
- function fntype(type) {
- if (type == "(") return cont(pushlex("("), commasep(rtype, ")"), poplex, fntype);
- if (type == "->") return cont(rtype);
- return pass();
- }
- function pattern(type) {
- if (type == "name") {cx.marked = "def"; return cont(patternmaybeop);}
- if (type == "atom") return cont(patternmaybeop);
- if (type == "op") return cont(pattern);
- if (type.match(/[\]\)\};,]/)) return pass();
- return matchBrackets(type, pattern);
- }
- function patternmaybeop(type) {
- if (type == "op" && content == ".") return cont();
- if (content == "to") {cx.marked = "keyword"; return cont(pattern);}
- else return pass();
- }
- function altbody(type) {
- if (type == "{") return cont(pushlex("}", "alt"), altblock1, poplex);
- return pass();
- }
- function altblock1(type) {
- if (type == "}") return cont();
- if (type == "|") return cont(altblock1);
- if (content == "when") {cx.marked = "keyword"; return cont(expression, altblock2);}
- if (type.match(/[\]\);,]/)) return cont(altblock1);
- return pass(pattern, altblock2);
- }
- function altblock2(type) {
- if (type == "{") return cont(pushlex("}", "alt"), block, poplex, altblock1);
- else return pass(altblock1);
- }
-
- function macro(type) {
- if (type.match(/[\[\(\{]/)) return matchBrackets(type, expression);
- return pass();
- }
- function matchBrackets(type, comb) {
- if (type == "[") return cont(pushlex("]"), commasep(comb, "]"), poplex);
- if (type == "(") return cont(pushlex(")"), commasep(comb, ")"), poplex);
- if (type == "{") return cont(pushlex("}"), commasep(comb, "}"), poplex);
- return cont();
- }
-
- function parse(state, stream, style) {
- var cc = state.cc;
- // Communicate our context to the combinators.
- // (Less wasteful than consing up a hundred closures on every call.)
- cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
-
- while (true) {
- var combinator = cc.length ? cc.pop() : block;
- if (combinator(tcat)) {
- while(cc.length && cc[cc.length - 1].lex)
- cc.pop()();
- return cx.marked || style;
- }
- }
- }
-
- return {
- startState: function() {
- return {
- tokenize: tokenBase,
- cc: [],
- lexical: {indented: -indentUnit, column: 0, type: "top", align: false},
- keywords: valKeywords,
- indented: 0
- };
- },
-
- token: function(stream, state) {
- if (stream.sol()) {
- if (!state.lexical.hasOwnProperty("align"))
- state.lexical.align = false;
- state.indented = stream.indentation();
- }
- if (stream.eatSpace()) return null;
- tcat = content = null;
- var style = state.tokenize(stream, state);
- if (style == "comment") return style;
- if (!state.lexical.hasOwnProperty("align"))
- state.lexical.align = true;
- if (tcat == "prefix") return style;
- if (!content) content = stream.current();
- return parse(state, stream, style);
- },
-
- indent: function(state, textAfter) {
- if (state.tokenize != tokenBase) return 0;
- var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical,
- type = lexical.type, closing = firstChar == type;
- if (type == "stat") return lexical.indented + indentUnit;
- if (lexical.align) return lexical.column + (closing ? 0 : 1);
- return lexical.indented + (closing ? 0 : (lexical.info == "alt" ? altIndentUnit : indentUnit));
- },
-
- electricChars: "{}",
+// 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"), require("../../addon/mode/simple"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.defineSimpleMode("rust",{
+ start:[
+ // string and byte string
+ {regex: /b?"(?:[^\\]|\\.)*?"/, token: "string"},
+ // raw string and raw byte string
+ {regex: /(b?r)(#*)(".*?)("\2)/, token: ["string", "string", "string", "string"]},
+ // character
+ {regex: /'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/, token: "string-2"},
+ // byte
+ {regex: /b'(?:[^']|\\(?:['\\nrt0]|x[\da-fA-F]{2}))'/, token: "string-2"},
+
+ {regex: /(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/,
+ token: "number"},
+ {regex: /(let(?:\s+mut)?|fn|enum|mod|struct|type)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null, "def"]},
+ {regex: /(?:abstract|alignof|as|box|break|continue|const|crate|do|else|enum|extern|fn|for|final|if|impl|in|loop|macro|match|mod|move|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/, token: "keyword"},
+ {regex: /\b(?:Self|isize|usize|char|bool|u8|u16|u32|u64|f16|f32|f64|i8|i16|i32|i64|str|Option)\b/, token: "atom"},
+ {regex: /\b(?:true|false|Some|None|Ok|Err)\b/, token: "builtin"},
+ {regex: /\b(fn)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/,
+ token: ["keyword", null ,"def"]},
+ {regex: /#!?\[.*\]/, token: "meta"},
+ {regex: /\/\/.*/, token: "comment"},
+ {regex: /\/\*/, token: "comment", next: "comment"},
+ {regex: /[-+\/*=<>!]+/, token: "operator"},
+ {regex: /[a-zA-Z_]\w*!/,token: "variable-3"},
+ {regex: /[a-zA-Z_]\w*/, token: "variable"},
+ {regex: /[\{\[\(]/, indent: true},
+ {regex: /[\}\]\)]/, dedent: true}
+ ],
+ comment: [
+ {regex: /.*?\*\//, token: "comment", next: "start"},
+ {regex: /.*/, token: "comment"}
+ ],
+ meta: {
+ dontIndentStates: ["comment"],
+ electricInput: /^\s*\}$/,
blockCommentStart: "/*",
blockCommentEnd: "*/",
lineComment: "//",
fold: "brace"
- };
+ }
});
+
CodeMirror.defineMIME("text/x-rustsrc", "rust");
+});
diff --git a/data/ext/editorText/codemirror/mode/rust/test.js b/data/ext/editorText/codemirror/mode/rust/test.js
new file mode 100644
index 000000000..1a3c6e720
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/rust/test.js
@@ -0,0 +1,40 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function() {
+ var mode = CodeMirror.getMode({indentUnit: 4}, "rust");
+ function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));}
+
+ MT('integer_test',
+ '[number 123i32]',
+ '[number 123u32]',
+ '[number 123_u32]',
+ '[number 0xff_u8]',
+ '[number 0o70_i16]',
+ '[number 0b1111_1111_1001_0000_i32]',
+ '[number 0usize]');
+
+ MT('float_test',
+ '[number 123.0f64]',
+ '[number 0.1f64]',
+ '[number 0.1f32]',
+ '[number 12E+99_f64]');
+
+ MT('string-literals-test',
+ '[string "foo"]',
+ '[string r"foo"]',
+ '[string "\\"foo\\""]',
+ '[string r#""foo""#]',
+ '[string "foo #\\"# bar"]',
+ '[string r##"foo #"# bar"##]',
+
+ '[string b"foo"]',
+ '[string br"foo"]',
+ '[string b"\\"foo\\""]',
+ '[string br#""foo""#]',
+ '[string br##"foo #" bar"##]',
+
+ "[string-2 'h']",
+ "[string-2 b'h']");
+
+})();
diff --git a/data/ext/editorText/codemirror/mode/sass/index.html b/data/ext/editorText/codemirror/mode/sass/index.html
index 66d467784..9f4a79022 100644
--- a/data/ext/editorText/codemirror/mode/sass/index.html
+++ b/data/ext/editorText/codemirror/mode/sass/index.html
@@ -10,12 +10,12 @@
<script src="sass.js"></script>
<style>.CodeMirror {border: 1px solid #ddd; font-size:12px; height: 400px}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/sass/sass.js b/data/ext/editorText/codemirror/mode/sass/sass.js
index 9c9a0dae0..6973ece29 100644
--- a/data/ext/editorText/codemirror/mode/sass/sass.js
+++ b/data/ext/editorText/codemirror/mode/sass/sass.js
@@ -1,300 +1,379 @@
+// 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";
+
CodeMirror.defineMode("sass", function(config) {
- var tokenRegexp = function(words){
+ function tokenRegexp(words) {
return new RegExp("^" + words.join("|"));
- };
+ }
var keywords = ["true", "false", "null", "auto"];
var keywordsRegexp = new RegExp("^" + keywords.join("|"));
- var operators = ["\\(", "\\)", "=", ">", "<", "==", ">=", "<=", "\\+", "-", "\\!=", "/", "\\*", "%", "and", "or", "not"];
+ var operators = ["\\(", "\\)", "=", ">", "<", "==", ">=", "<=", "\\+", "-",
+ "\\!=", "/", "\\*", "%", "and", "or", "not", ";","\\{","\\}",":"];
var opRegexp = tokenRegexp(operators);
- var pseudoElementsRegexp = /^::?[\w\-]+/;
+ var pseudoElementsRegexp = /^::?[a-zA-Z_][\w\-]*/;
- var urlTokens = function(stream, state){
+ function urlTokens(stream, state) {
var ch = stream.peek();
- if (ch === ")"){
+ if (ch === ")") {
stream.next();
state.tokenizer = tokenBase;
return "operator";
- }else if (ch === "("){
+ } else if (ch === "(") {
stream.next();
stream.eatSpace();
return "operator";
- }else if (ch === "'" || ch === '"'){
+ } else if (ch === "'" || ch === '"') {
state.tokenizer = buildStringTokenizer(stream.next());
return "string";
- }else{
+ } else {
state.tokenizer = buildStringTokenizer(")", false);
return "string";
}
- };
- var multilineComment = function(stream, state) {
- if (stream.skipTo("*/")){
- stream.next();
- stream.next();
- state.tokenizer = tokenBase;
- }else {
- stream.next();
- }
+ }
+ function comment(indentation, multiLine) {
+ return function(stream, state) {
+ if (stream.sol() && stream.indentation() <= indentation) {
+ state.tokenizer = tokenBase;
+ return tokenBase(stream, state);
+ }
- return "comment";
- };
+ if (multiLine && stream.skipTo("*/")) {
+ stream.next();
+ stream.next();
+ state.tokenizer = tokenBase;
+ } else {
+ stream.skipToEnd();
+ }
- var buildStringTokenizer = function(quote, greedy){
- if(greedy == null){ greedy = true; }
+ return "comment";
+ };
+ }
- function stringTokenizer(stream, state){
+ function buildStringTokenizer(quote, greedy) {
+ if (greedy == null) { greedy = true; }
+
+ function stringTokenizer(stream, state) {
var nextChar = stream.next();
var peekChar = stream.peek();
var previousChar = stream.string.charAt(stream.pos-2);
var endingString = ((nextChar !== "\\" && peekChar === quote) || (nextChar === quote && previousChar !== "\\"));
- /*
- console.log("previousChar: " + previousChar);
- console.log("nextChar: " + nextChar);
- console.log("peekChar: " + peekChar);
- console.log("ending: " + endingString);
- */
-
- if (endingString){
+ if (endingString) {
if (nextChar !== quote && greedy) { stream.next(); }
state.tokenizer = tokenBase;
return "string";
- }else if (nextChar === "#" && peekChar === "{"){
+ } else if (nextChar === "#" && peekChar === "{") {
state.tokenizer = buildInterpolationTokenizer(stringTokenizer);
stream.next();
return "operator";
- }else {
+ } else {
return "string";
}
}
return stringTokenizer;
- };
+ }
- var buildInterpolationTokenizer = function(currentTokenizer){
- return function(stream, state){
- if (stream.peek() === "}"){
+ function buildInterpolationTokenizer(currentTokenizer) {
+ return function(stream, state) {
+ if (stream.peek() === "}") {
stream.next();
state.tokenizer = currentTokenizer;
return "operator";
- }else{
+ } else {
return tokenBase(stream, state);
}
};
- };
+ }
- var indent = function(state){
- if (state.indentCount == 0){
+ function indent(state) {
+ if (state.indentCount == 0) {
state.indentCount++;
var lastScopeOffset = state.scopes[0].offset;
var currentOffset = lastScopeOffset + config.indentUnit;
state.scopes.unshift({ offset:currentOffset });
}
- };
+ }
- var dedent = function(state){
- if (state.scopes.length == 1) { return; }
+ function dedent(state) {
+ if (state.scopes.length == 1) return;
state.scopes.shift();
- };
+ }
- var tokenBase = function(stream, state) {
+ function tokenBase(stream, state) {
var ch = stream.peek();
- // Single line Comment
- if (stream.match('//')) {
- stream.skipToEnd();
- return "comment";
+ // Comment
+ if (stream.match("/*")) {
+ state.tokenizer = comment(stream.indentation(), true);
+ return state.tokenizer(stream, state);
}
-
- // Multiline Comment
- if (stream.match('/*')){
- state.tokenizer = multilineComment;
+ if (stream.match("//")) {
+ state.tokenizer = comment(stream.indentation(), false);
return state.tokenizer(stream, state);
}
// Interpolation
- if (stream.match('#{')){
- state.tokenizer = buildInterpolationTokenizer(tokenBase);
+ if (stream.match("#{")) {
+ state.tokenizer = buildInterpolationTokenizer(tokenBase);
return "operator";
}
- if (ch === "."){
+ // Strings
+ if (ch === '"' || ch === "'") {
stream.next();
+ state.tokenizer = buildStringTokenizer(ch);
+ return "string";
+ }
- // Match class selectors
- if (stream.match(/^[\w-]+/)){
- indent(state);
- return "atom";
- }else if (stream.peek() === "#"){
- indent(state);
- return "atom";
- }else{
- return "operator";
+ if(!state.cursorHalf){// state.cursorHalf === 0
+ // first half i.e. before : for key-value pairs
+ // including selectors
+
+ if (ch === ".") {
+ stream.next();
+ if (stream.match(/^[\w-]+/)) {
+ indent(state);
+ return "atom";
+ } else if (stream.peek() === "#") {
+ indent(state);
+ return "atom";
+ }
}
- }
- if (ch === "#"){
- stream.next();
+ if (ch === "#") {
+ stream.next();
+ // ID selectors
+ if (stream.match(/^[\w-]+/)) {
+ indent(state);
+ return "atom";
+ }
+ if (stream.peek() === "#") {
+ indent(state);
+ return "atom";
+ }
+ }
- // Hex numbers
- if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){
- return "number";
+ // Variables
+ if (ch === "$") {
+ stream.next();
+ stream.eatWhile(/[\w-]/);
+ return "variable-2";
}
- // ID selectors
- if (stream.match(/^[\w-]+/)){
- indent(state);
+ // Numbers
+ if (stream.match(/^-?[0-9\.]+/))
+ return "number";
+
+ // Units
+ if (stream.match(/^(px|em|in)\b/))
+ return "unit";
+
+ if (stream.match(keywordsRegexp))
+ return "keyword";
+
+ if (stream.match(/^url/) && stream.peek() === "(") {
+ state.tokenizer = urlTokens;
return "atom";
}
- if (stream.peek() === "#"){
- indent(state);
- return "atom";
+ if (ch === "=") {
+ // Match shortcut mixin definition
+ if (stream.match(/^=[\w-]+/)) {
+ indent(state);
+ return "meta";
+ }
}
- }
- // Numbers
- if (stream.match(/^-?[0-9\.]+/)){
- return "number";
- }
+ if (ch === "+") {
+ // Match shortcut mixin definition
+ if (stream.match(/^\+[\w-]+/)){
+ return "variable-3";
+ }
+ }
- // Units
- if (stream.match(/^(px|em|in)\b/)){
- return "unit";
- }
+ if(ch === "@"){
+ if(stream.match(/@extend/)){
+ if(!stream.match(/\s*[\w]/))
+ dedent(state);
+ }
+ }
- if (stream.match(keywordsRegexp)){
- return "keyword";
- }
- if (stream.match(/^url/) && stream.peek() === "("){
- state.tokenizer = urlTokens;
- return "atom";
- }
+ // Indent Directives
+ if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) {
+ indent(state);
+ return "meta";
+ }
- // Variables
- if (ch === "$"){
- stream.next();
- stream.eatWhile(/[\w-]/);
+ // Other Directives
+ if (ch === "@") {
+ stream.next();
+ stream.eatWhile(/[\w-]/);
+ return "meta";
+ }
+
+ if (stream.eatWhile(/[\w-]/)){
+ if(stream.match(/ *: *[\w-\+\$#!\("']/,false)){
+ return "property";
+ }
+ else if(stream.match(/ *:/,false)){
+ indent(state);
+ state.cursorHalf = 1;
+ return "atom";
+ }
+ else if(stream.match(/ *,/,false)){
+ return "atom";
+ }
+ else{
+ indent(state);
+ return "atom";
+ }
+ }
- if (stream.peek() === ":"){
+ if(ch === ":"){
+ if (stream.match(pseudoElementsRegexp)){ // could be a pseudo-element
+ return "keyword";
+ }
stream.next();
- return "variable-2";
- }else{
- return "variable-3";
+ state.cursorHalf=1;
+ return "operator";
}
- }
- if (ch === "!"){
- stream.next();
+ } // cursorHalf===0 ends here
+ else{
- if (stream.match(/^[\w]+/)){
- return "keyword";
+ if (ch === "#") {
+ stream.next();
+ // Hex numbers
+ if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){
+ if(!stream.peek()){
+ state.cursorHalf = 0;
+ }
+ return "number";
+ }
}
- return "operator";
- }
+ // Numbers
+ if (stream.match(/^-?[0-9\.]+/)){
+ if(!stream.peek()){
+ state.cursorHalf = 0;
+ }
+ return "number";
+ }
- if (ch === "="){
- stream.next();
+ // Units
+ if (stream.match(/^(px|em|in)\b/)){
+ if(!stream.peek()){
+ state.cursorHalf = 0;
+ }
+ return "unit";
+ }
- // Match shortcut mixin definition
- if (stream.match(/^[\w-]+/)){
- indent(state);
- return "meta";
- }else {
- return "operator";
+ if (stream.match(keywordsRegexp)){
+ if(!stream.peek()){
+ state.cursorHalf = 0;
+ }
+ return "keyword";
}
- }
- if (ch === "+"){
- stream.next();
+ if (stream.match(/^url/) && stream.peek() === "(") {
+ state.tokenizer = urlTokens;
+ if(!stream.peek()){
+ state.cursorHalf = 0;
+ }
+ return "atom";
+ }
- // Match shortcut mixin definition
- if (stream.match(/^[\w-]+/)){
+ // Variables
+ if (ch === "$") {
+ stream.next();
+ stream.eatWhile(/[\w-]/);
+ if(!stream.peek()){
+ state.cursorHalf = 0;
+ }
return "variable-3";
- }else {
- return "operator";
}
- }
- // Indent Directives
- if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)){
- indent(state);
- return "meta";
- }
+ // bang character for !important, !default, etc.
+ if (ch === "!") {
+ stream.next();
+ if(!stream.peek()){
+ state.cursorHalf = 0;
+ }
+ return stream.match(/^[\w]+/) ? "keyword": "operator";
+ }
- // Other Directives
- if (ch === "@"){
- stream.next();
- stream.eatWhile(/[\w-]/);
- return "meta";
- }
+ if (stream.match(opRegexp)){
+ if(!stream.peek()){
+ state.cursorHalf = 0;
+ }
+ return "operator";
+ }
- // Strings
- if (ch === '"' || ch === "'"){
- stream.next();
- state.tokenizer = buildStringTokenizer(ch);
- return "string";
- }
+ // attributes
+ if (stream.eatWhile(/[\w-]/)) {
+ if(!stream.peek()){
+ state.cursorHalf = 0;
+ }
+ return "attribute";
+ }
- // Pseudo element selectors
- if (ch == ':' && stream.match(pseudoElementsRegexp)){
- return "keyword";
- }
+ //stream.eatSpace();
+ if(!stream.peek()){
+ state.cursorHalf = 0;
+ return null;
+ }
- // atoms
- if (stream.eatWhile(/[\w-&]/)){
- // matches a property definition
- if (stream.peek() === ":" && !stream.match(pseudoElementsRegexp, false))
- return "property";
- else
- return "atom";
- }
+ } // else ends here
- if (stream.match(opRegexp)){
+ if (stream.match(opRegexp))
return "operator";
- }
// If we haven't returned by now, we move 1 character
// and return an error
stream.next();
return null;
- };
+ }
- var tokenLexer = function(stream, state) {
- if (stream.sol()){
- state.indentCount = 0;
- }
+ function tokenLexer(stream, state) {
+ if (stream.sol()) state.indentCount = 0;
var style = state.tokenizer(stream, state);
var current = stream.current();
- if (current === "@return"){
+ if (current === "@return" || current === "}"){
dedent(state);
}
- if (style === "atom"){
- indent(state);
- }
-
- if (style !== null){
+ if (style !== null) {
var startOfToken = stream.pos - current.length;
+
var withCurrentIndent = startOfToken + (config.indentUnit * state.indentCount);
var newScopes = [];
- for (var i = 0; i < state.scopes.length; i++){
+ for (var i = 0; i < state.scopes.length; i++) {
var scope = state.scopes[i];
- if (scope.offset <= withCurrentIndent){
+ if (scope.offset <= withCurrentIndent)
newScopes.push(scope);
- }
}
state.scopes = newScopes;
@@ -302,13 +381,16 @@ CodeMirror.defineMode("sass", function(config) {
return style;
- };
+ }
return {
startState: function() {
return {
tokenizer: tokenBase,
- scopes: [{offset: 0, type: 'sass'}],
+ scopes: [{offset: 0, type: "sass"}],
+ indentCount: 0,
+ cursorHalf: 0, // cursor half tells us if cursor lies after (1)
+ // or before (0) colon (well... more or less)
definedVars: [],
definedMixins: []
};
@@ -328,3 +410,5 @@ CodeMirror.defineMode("sass", function(config) {
});
CodeMirror.defineMIME("text/x-sass", "sass");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/scheme/index.html b/data/ext/editorText/codemirror/mode/scheme/index.html
index 164d5da60..04d5c6a2a 100644
--- a/data/ext/editorText/codemirror/mode/scheme/index.html
+++ b/data/ext/editorText/codemirror/mode/scheme/index.html
@@ -9,12 +9,12 @@
<script src="scheme.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/scheme/scheme.js b/data/ext/editorText/codemirror/mode/scheme/scheme.js
index c5990ae92..223464591 100644
--- a/data/ext/editorText/codemirror/mode/scheme/scheme.js
+++ b/data/ext/editorText/codemirror/mode/scheme/scheme.js
@@ -1,6 +1,20 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/**
* Author: Koh Zi Han, based on implementation by Koh Zi Chun
*/
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("scheme", function () {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
ATOM = "atom", NUMBER = "number", BRACKET = "bracket";
@@ -225,8 +239,11 @@ CodeMirror.defineMode("scheme", function () {
return state.indentStack.indent;
},
+ closeBrackets: {pairs: "()[]{}\"\""},
lineComment: ";;"
};
});
CodeMirror.defineMIME("text/x-scheme", "scheme");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/shell/index.html b/data/ext/editorText/codemirror/mode/shell/index.html
index cf415e832..0b56300b1 100644
--- a/data/ext/editorText/codemirror/mode/shell/index.html
+++ b/data/ext/editorText/codemirror/mode/shell/index.html
@@ -12,12 +12,12 @@
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/shell/shell.js b/data/ext/editorText/codemirror/mode/shell/shell.js
index abfd21445..a684e8c23 100644
--- a/data/ext/editorText/codemirror/mode/shell/shell.js
+++ b/data/ext/editorText/codemirror/mode/shell/shell.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode('shell', function() {
var words = {};
@@ -23,10 +36,15 @@ CodeMirror.defineMode('shell', function() {
'touch vi vim wall wc wget who write yes zsh');
function tokenBase(stream, state) {
+ if (stream.eatSpace()) return null;
var sol = stream.sol();
var ch = stream.next();
+ if (ch === '\\') {
+ stream.next();
+ return null;
+ }
if (ch === '\'' || ch === '"' || ch === '`') {
state.tokens.unshift(tokenString(ch));
return tokenize(stream, state);
@@ -53,7 +71,7 @@ CodeMirror.defineMode('shell', function() {
}
if (/\d/.test(ch)) {
stream.eatWhile(/\d/);
- if(!/\w/.test(stream.peek())) {
+ if(stream.eol() || !/\w/.test(stream.peek())) {
return 'number';
}
}
@@ -109,10 +127,13 @@ CodeMirror.defineMode('shell', function() {
return {
startState: function() {return {tokens:[]};},
token: function(stream, state) {
- if (stream.eatSpace()) return null;
return tokenize(stream, state);
- }
+ },
+ lineComment: '#',
+ fold: "brace"
};
});
CodeMirror.defineMIME('text/x-sh', 'shell');
+
+});
diff --git a/data/ext/editorText/codemirror/mode/shell/test.js b/data/ext/editorText/codemirror/mode/shell/test.js
new file mode 100644
index 000000000..a413b5a40
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/shell/test.js
@@ -0,0 +1,58 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function() {
+ var mode = CodeMirror.getMode({}, "shell");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
+
+ MT("var",
+ "text [def $var] text");
+ MT("varBraces",
+ "text[def ${var}]text");
+ MT("varVar",
+ "text [def $a$b] text");
+ MT("varBracesVarBraces",
+ "text[def ${a}${b}]text");
+
+ MT("singleQuotedVar",
+ "[string 'text $var text']");
+ MT("singleQuotedVarBraces",
+ "[string 'text ${var} text']");
+
+ MT("doubleQuotedVar",
+ '[string "text ][def $var][string text"]');
+ MT("doubleQuotedVarBraces",
+ '[string "text][def ${var}][string text"]');
+ MT("doubleQuotedVarPunct",
+ '[string "text ][def $@][string text"]');
+ MT("doubleQuotedVarVar",
+ '[string "][def $a$b][string "]');
+ MT("doubleQuotedVarBracesVarBraces",
+ '[string "][def ${a}${b}][string "]');
+
+ MT("notAString",
+ "text\\'text");
+ MT("escapes",
+ "outside\\'\\\"\\`\\\\[string \"inside\\`\\'\\\"\\\\`\\$notAVar\"]outside\\$\\(notASubShell\\)");
+
+ MT("subshell",
+ "[builtin echo] [quote $(whoami)] s log, stardate [quote `date`].");
+ MT("doubleQuotedSubshell",
+ "[builtin echo] [string \"][quote $(whoami)][string 's log, stardate `date`.\"]");
+
+ MT("hashbang",
+ "[meta #!/bin/bash]");
+ MT("comment",
+ "text [comment # Blurb]");
+
+ MT("numbers",
+ "[number 0] [number 1] [number 2]");
+ MT("keywords",
+ "[keyword while] [atom true]; [keyword do]",
+ " [builtin sleep] [number 3]",
+ "[keyword done]");
+ MT("options",
+ "[builtin ls] [attribute -l] [attribute --human-readable]");
+ MT("operator",
+ "[def var][operator =]value");
+})();
diff --git a/data/ext/editorText/codemirror/mode/sieve/index.html b/data/ext/editorText/codemirror/mode/sieve/index.html
index 9d814a9d5..6f029b623 100644
--- a/data/ext/editorText/codemirror/mode/sieve/index.html
+++ b/data/ext/editorText/codemirror/mode/sieve/index.html
@@ -9,12 +9,12 @@
<script src="sieve.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/sieve/sieve.js b/data/ext/editorText/codemirror/mode/sieve/sieve.js
index 8ca2a4cb8..f67db2f55 100644
--- a/data/ext/editorText/codemirror/mode/sieve/sieve.js
+++ b/data/ext/editorText/codemirror/mode/sieve/sieve.js
@@ -1,7 +1,15 @@
-/*
- * See LICENSE in this directory for the license under which this code
- * is released.
- */
+// 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";
CodeMirror.defineMode("sieve", function(config) {
function words(str) {
@@ -181,3 +189,5 @@ CodeMirror.defineMode("sieve", function(config) {
});
CodeMirror.defineMIME("application/sieve", "sieve");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/slim/index.html b/data/ext/editorText/codemirror/mode/slim/index.html
new file mode 100644
index 000000000..7fa4e50df
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/slim/index.html
@@ -0,0 +1,96 @@
+<!doctype html>
+
+<title>CodeMirror: SLIM mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<link rel="stylesheet" href="../../theme/ambiance.css">
+<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
+<script src="https://code.jquery.com/ui/1.11.0/jquery-ui.min.js"></script>
+<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../xml/xml.js"></script>
+<script src="../htmlembedded/htmlembedded.js"></script>
+<script src="../htmlmixed/htmlmixed.js"></script>
+<script src="../coffeescript/coffeescript.js"></script>
+<script src="../javascript/javascript.js"></script>
+<script src="../ruby/ruby.js"></script>
+<script src="../markdown/markdown.js"></script>
+<script src="slim.js"></script>
+<style>.CodeMirror {background: #f8f8f8;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">SLIM</a>
+ </ul>
+</div>
+
+<article>
+ <h2>SLIM mode</h2>
+ <form><textarea id="code" name="code">
+body
+ table
+ - for user in users
+ td id="user_#{user.id}" class=user.role
+ a href=user_action(user, :edit) Edit #{user.name}
+ a href=(path_to_user user) = user.name
+body
+ h1(id="logo") = page_logo
+ h2[id="tagline" class="small tagline"] = page_tagline
+
+h2[id="tagline"
+ class="small tagline"] = page_tagline
+
+h1 id = "logo" = page_logo
+h2 [ id = "tagline" ] = page_tagline
+
+/ comment
+ second line
+/! html comment
+ second line
+<!-- html comment -->
+<a href="#{'hello' if set}">link</a>
+a.slim href="work" disabled=false running==:atom Text <b>bold</b>
+.clazz data-id="test" == 'hello' unless quark
+ | Text mode #{12}
+ Second line
+= x ||= :ruby_atom
+#menu.left
+ - @env.each do |x|
+ li: a = x
+*@dyntag attr="val"
+.first *{:class => [:second, :third]} Text
+.second class=["text","more"]
+.third class=:text,:symbol
+
+ </textarea></form>
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ theme: "ambiance",
+ mode: "application/x-slim"
+ });
+ $('.CodeMirror').resizable({
+ resize: function() {
+ editor.setSize($(this).width(), $(this).height());
+ //editor.refresh();
+ }
+ });
+ </script>
+
+ <p><strong>MIME types defined:</strong> <code>application/x-slim</code>.</p>
+
+ <p>
+ <strong>Parsing/Highlighting Tests:</strong>
+ <a href="../../test/index.html#slim_*">normal</a>,
+ <a href="../../test/index.html#verbose,slim_*">verbose</a>.
+ </p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/slim/slim.js b/data/ext/editorText/codemirror/mode/slim/slim.js
new file mode 100644
index 000000000..164464d06
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/slim/slim.js
@@ -0,0 +1,575 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Slim Highlighting for CodeMirror copyright (c) HicknHack Software Gmbh
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../ruby/ruby"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../ruby/ruby"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+ CodeMirror.defineMode("slim", function(config) {
+ var htmlMode = CodeMirror.getMode(config, {name: "htmlmixed"});
+ var rubyMode = CodeMirror.getMode(config, "ruby");
+ var modes = { html: htmlMode, ruby: rubyMode };
+ var embedded = {
+ ruby: "ruby",
+ javascript: "javascript",
+ css: "text/css",
+ sass: "text/x-sass",
+ scss: "text/x-scss",
+ less: "text/x-less",
+ styl: "text/x-styl", // no highlighting so far
+ coffee: "coffeescript",
+ asciidoc: "text/x-asciidoc",
+ markdown: "text/x-markdown",
+ textile: "text/x-textile", // no highlighting so far
+ creole: "text/x-creole", // no highlighting so far
+ wiki: "text/x-wiki", // no highlighting so far
+ mediawiki: "text/x-mediawiki", // no highlighting so far
+ rdoc: "text/x-rdoc", // no highlighting so far
+ builder: "text/x-builder", // no highlighting so far
+ nokogiri: "text/x-nokogiri", // no highlighting so far
+ erb: "application/x-erb"
+ };
+ var embeddedRegexp = function(map){
+ var arr = [];
+ for(var key in map) arr.push(key);
+ return new RegExp("^("+arr.join('|')+"):");
+ }(embedded);
+
+ var styleMap = {
+ "commentLine": "comment",
+ "slimSwitch": "operator special",
+ "slimTag": "tag",
+ "slimId": "attribute def",
+ "slimClass": "attribute qualifier",
+ "slimAttribute": "attribute",
+ "slimSubmode": "keyword special",
+ "closeAttributeTag": null,
+ "slimDoctype": null,
+ "lineContinuation": null
+ };
+ var closing = {
+ "{": "}",
+ "[": "]",
+ "(": ")"
+ };
+
+ var nameStartChar = "_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
+ var nameChar = nameStartChar + "\\-0-9\xB7\u0300-\u036F\u203F-\u2040";
+ var nameRegexp = new RegExp("^[:"+nameStartChar+"](?::["+nameChar+"]|["+nameChar+"]*)");
+ var attributeNameRegexp = new RegExp("^[:"+nameStartChar+"][:\\."+nameChar+"]*(?=\\s*=)");
+ var wrappedAttributeNameRegexp = new RegExp("^[:"+nameStartChar+"][:\\."+nameChar+"]*");
+ var classNameRegexp = /^\.-?[_a-zA-Z]+[\w\-]*/;
+ var classIdRegexp = /^#[_a-zA-Z]+[\w\-]*/;
+
+ function backup(pos, tokenize, style) {
+ var restore = function(stream, state) {
+ state.tokenize = tokenize;
+ if (stream.pos < pos) {
+ stream.pos = pos;
+ return style;
+ }
+ return state.tokenize(stream, state);
+ };
+ return function(stream, state) {
+ state.tokenize = restore;
+ return tokenize(stream, state);
+ };
+ }
+
+ function maybeBackup(stream, state, pat, offset, style) {
+ var cur = stream.current();
+ var idx = cur.search(pat);
+ if (idx > -1) {
+ state.tokenize = backup(stream.pos, state.tokenize, style);
+ stream.backUp(cur.length - idx - offset);
+ }
+ return style;
+ }
+
+ function continueLine(state, column) {
+ state.stack = {
+ parent: state.stack,
+ style: "continuation",
+ indented: column,
+ tokenize: state.line
+ };
+ state.line = state.tokenize;
+ }
+ function finishContinue(state) {
+ if (state.line == state.tokenize) {
+ state.line = state.stack.tokenize;
+ state.stack = state.stack.parent;
+ }
+ }
+
+ function lineContinuable(column, tokenize) {
+ return function(stream, state) {
+ finishContinue(state);
+ if (stream.match(/^\\$/)) {
+ continueLine(state, column);
+ return "lineContinuation";
+ }
+ var style = tokenize(stream, state);
+ if (stream.eol() && stream.current().match(/(?:^|[^\\])(?:\\\\)*\\$/)) {
+ stream.backUp(1);
+ }
+ return style;
+ };
+ }
+ function commaContinuable(column, tokenize) {
+ return function(stream, state) {
+ finishContinue(state);
+ var style = tokenize(stream, state);
+ if (stream.eol() && stream.current().match(/,$/)) {
+ continueLine(state, column);
+ }
+ return style;
+ };
+ }
+
+ function rubyInQuote(endQuote, tokenize) {
+ // TODO: add multi line support
+ return function(stream, state) {
+ var ch = stream.peek();
+ if (ch == endQuote && state.rubyState.tokenize.length == 1) {
+ // step out of ruby context as it seems to complete processing all the braces
+ stream.next();
+ state.tokenize = tokenize;
+ return "closeAttributeTag";
+ } else {
+ return ruby(stream, state);
+ }
+ };
+ }
+ function startRubySplat(tokenize) {
+ var rubyState;
+ var runSplat = function(stream, state) {
+ if (state.rubyState.tokenize.length == 1 && !state.rubyState.context.prev) {
+ stream.backUp(1);
+ if (stream.eatSpace()) {
+ state.rubyState = rubyState;
+ state.tokenize = tokenize;
+ return tokenize(stream, state);
+ }
+ stream.next();
+ }
+ return ruby(stream, state);
+ };
+ return function(stream, state) {
+ rubyState = state.rubyState;
+ state.rubyState = rubyMode.startState();
+ state.tokenize = runSplat;
+ return ruby(stream, state);
+ };
+ }
+
+ function ruby(stream, state) {
+ return rubyMode.token(stream, state.rubyState);
+ }
+
+ function htmlLine(stream, state) {
+ if (stream.match(/^\\$/)) {
+ return "lineContinuation";
+ }
+ return html(stream, state);
+ }
+ function html(stream, state) {
+ if (stream.match(/^#\{/)) {
+ state.tokenize = rubyInQuote("}", state.tokenize);
+ return null;
+ }
+ return maybeBackup(stream, state, /[^\\]#\{/, 1, htmlMode.token(stream, state.htmlState));
+ }
+
+ function startHtmlLine(lastTokenize) {
+ return function(stream, state) {
+ var style = htmlLine(stream, state);
+ if (stream.eol()) state.tokenize = lastTokenize;
+ return style;
+ };
+ }
+
+ function startHtmlMode(stream, state, offset) {
+ state.stack = {
+ parent: state.stack,
+ style: "html",
+ indented: stream.column() + offset, // pipe + space
+ tokenize: state.line
+ };
+ state.line = state.tokenize = html;
+ return null;
+ }
+
+ function comment(stream, state) {
+ stream.skipToEnd();
+ return state.stack.style;
+ }
+
+ function commentMode(stream, state) {
+ state.stack = {
+ parent: state.stack,
+ style: "comment",
+ indented: state.indented + 1,
+ tokenize: state.line
+ };
+ state.line = comment;
+ return comment(stream, state);
+ }
+
+ function attributeWrapper(stream, state) {
+ if (stream.eat(state.stack.endQuote)) {
+ state.line = state.stack.line;
+ state.tokenize = state.stack.tokenize;
+ state.stack = state.stack.parent;
+ return null;
+ }
+ if (stream.match(wrappedAttributeNameRegexp)) {
+ state.tokenize = attributeWrapperAssign;
+ return "slimAttribute";
+ }
+ stream.next();
+ return null;
+ }
+ function attributeWrapperAssign(stream, state) {
+ if (stream.match(/^==?/)) {
+ state.tokenize = attributeWrapperValue;
+ return null;
+ }
+ return attributeWrapper(stream, state);
+ }
+ function attributeWrapperValue(stream, state) {
+ var ch = stream.peek();
+ if (ch == '"' || ch == "\'") {
+ state.tokenize = readQuoted(ch, "string", true, false, attributeWrapper);
+ stream.next();
+ return state.tokenize(stream, state);
+ }
+ if (ch == '[') {
+ return startRubySplat(attributeWrapper)(stream, state);
+ }
+ if (stream.match(/^(true|false|nil)\b/)) {
+ state.tokenize = attributeWrapper;
+ return "keyword";
+ }
+ return startRubySplat(attributeWrapper)(stream, state);
+ }
+
+ function startAttributeWrapperMode(state, endQuote, tokenize) {
+ state.stack = {
+ parent: state.stack,
+ style: "wrapper",
+ indented: state.indented + 1,
+ tokenize: tokenize,
+ line: state.line,
+ endQuote: endQuote
+ };
+ state.line = state.tokenize = attributeWrapper;
+ return null;
+ }
+
+ function sub(stream, state) {
+ if (stream.match(/^#\{/)) {
+ state.tokenize = rubyInQuote("}", state.tokenize);
+ return null;
+ }
+ var subStream = new CodeMirror.StringStream(stream.string.slice(state.stack.indented), stream.tabSize);
+ subStream.pos = stream.pos - state.stack.indented;
+ subStream.start = stream.start - state.stack.indented;
+ subStream.lastColumnPos = stream.lastColumnPos - state.stack.indented;
+ subStream.lastColumnValue = stream.lastColumnValue - state.stack.indented;
+ var style = state.subMode.token(subStream, state.subState);
+ stream.pos = subStream.pos + state.stack.indented;
+ return style;
+ }
+ function firstSub(stream, state) {
+ state.stack.indented = stream.column();
+ state.line = state.tokenize = sub;
+ return state.tokenize(stream, state);
+ }
+
+ function createMode(mode) {
+ var query = embedded[mode];
+ var spec = CodeMirror.mimeModes[query];
+ if (spec) {
+ return CodeMirror.getMode(config, spec);
+ }
+ var factory = CodeMirror.modes[query];
+ if (factory) {
+ return factory(config, {name: query});
+ }
+ return CodeMirror.getMode(config, "null");
+ }
+
+ function getMode(mode) {
+ if (!modes.hasOwnProperty(mode)) {
+ return modes[mode] = createMode(mode);
+ }
+ return modes[mode];
+ }
+
+ function startSubMode(mode, state) {
+ var subMode = getMode(mode);
+ var subState = subMode.startState && subMode.startState();
+
+ state.subMode = subMode;
+ state.subState = subState;
+
+ state.stack = {
+ parent: state.stack,
+ style: "sub",
+ indented: state.indented + 1,
+ tokenize: state.line
+ };
+ state.line = state.tokenize = firstSub;
+ return "slimSubmode";
+ }
+
+ function doctypeLine(stream, _state) {
+ stream.skipToEnd();
+ return "slimDoctype";
+ }
+
+ function startLine(stream, state) {
+ var ch = stream.peek();
+ if (ch == '<') {
+ return (state.tokenize = startHtmlLine(state.tokenize))(stream, state);
+ }
+ if (stream.match(/^[|']/)) {
+ return startHtmlMode(stream, state, 1);
+ }
+ if (stream.match(/^\/(!|\[\w+])?/)) {
+ return commentMode(stream, state);
+ }
+ if (stream.match(/^(-|==?[<>]?)/)) {
+ state.tokenize = lineContinuable(stream.column(), commaContinuable(stream.column(), ruby));
+ return "slimSwitch";
+ }
+ if (stream.match(/^doctype\b/)) {
+ state.tokenize = doctypeLine;
+ return "keyword";
+ }
+
+ var m = stream.match(embeddedRegexp);
+ if (m) {
+ return startSubMode(m[1], state);
+ }
+
+ return slimTag(stream, state);
+ }
+
+ function slim(stream, state) {
+ if (state.startOfLine) {
+ return startLine(stream, state);
+ }
+ return slimTag(stream, state);
+ }
+
+ function slimTag(stream, state) {
+ if (stream.eat('*')) {
+ state.tokenize = startRubySplat(slimTagExtras);
+ return null;
+ }
+ if (stream.match(nameRegexp)) {
+ state.tokenize = slimTagExtras;
+ return "slimTag";
+ }
+ return slimClass(stream, state);
+ }
+ function slimTagExtras(stream, state) {
+ if (stream.match(/^(<>?|><?)/)) {
+ state.tokenize = slimClass;
+ return null;
+ }
+ return slimClass(stream, state);
+ }
+ function slimClass(stream, state) {
+ if (stream.match(classIdRegexp)) {
+ state.tokenize = slimClass;
+ return "slimId";
+ }
+ if (stream.match(classNameRegexp)) {
+ state.tokenize = slimClass;
+ return "slimClass";
+ }
+ return slimAttribute(stream, state);
+ }
+ function slimAttribute(stream, state) {
+ if (stream.match(/^([\[\{\(])/)) {
+ return startAttributeWrapperMode(state, closing[RegExp.$1], slimAttribute);
+ }
+ if (stream.match(attributeNameRegexp)) {
+ state.tokenize = slimAttributeAssign;
+ return "slimAttribute";
+ }
+ if (stream.peek() == '*') {
+ stream.next();
+ state.tokenize = startRubySplat(slimContent);
+ return null;
+ }
+ return slimContent(stream, state);
+ }
+ function slimAttributeAssign(stream, state) {
+ if (stream.match(/^==?/)) {
+ state.tokenize = slimAttributeValue;
+ return null;
+ }
+ // should never happen, because of forward lookup
+ return slimAttribute(stream, state);
+ }
+
+ function slimAttributeValue(stream, state) {
+ var ch = stream.peek();
+ if (ch == '"' || ch == "\'") {
+ state.tokenize = readQuoted(ch, "string", true, false, slimAttribute);
+ stream.next();
+ return state.tokenize(stream, state);
+ }
+ if (ch == '[') {
+ return startRubySplat(slimAttribute)(stream, state);
+ }
+ if (ch == ':') {
+ return startRubySplat(slimAttributeSymbols)(stream, state);
+ }
+ if (stream.match(/^(true|false|nil)\b/)) {
+ state.tokenize = slimAttribute;
+ return "keyword";
+ }
+ return startRubySplat(slimAttribute)(stream, state);
+ }
+ function slimAttributeSymbols(stream, state) {
+ stream.backUp(1);
+ if (stream.match(/^[^\s],(?=:)/)) {
+ state.tokenize = startRubySplat(slimAttributeSymbols);
+ return null;
+ }
+ stream.next();
+ return slimAttribute(stream, state);
+ }
+ function readQuoted(quote, style, embed, unescaped, nextTokenize) {
+ return function(stream, state) {
+ finishContinue(state);
+ var fresh = stream.current().length == 0;
+ if (stream.match(/^\\$/, fresh)) {
+ if (!fresh) return style;
+ continueLine(state, state.indented);
+ return "lineContinuation";
+ }
+ if (stream.match(/^#\{/, fresh)) {
+ if (!fresh) return style;
+ state.tokenize = rubyInQuote("}", state.tokenize);
+ return null;
+ }
+ var escaped = false, ch;
+ while ((ch = stream.next()) != null) {
+ if (ch == quote && (unescaped || !escaped)) {
+ state.tokenize = nextTokenize;
+ break;
+ }
+ if (embed && ch == "#" && !escaped) {
+ if (stream.eat("{")) {
+ stream.backUp(2);
+ break;
+ }
+ }
+ escaped = !escaped && ch == "\\";
+ }
+ if (stream.eol() && escaped) {
+ stream.backUp(1);
+ }
+ return style;
+ };
+ }
+ function slimContent(stream, state) {
+ if (stream.match(/^==?/)) {
+ state.tokenize = ruby;
+ return "slimSwitch";
+ }
+ if (stream.match(/^\/$/)) { // tag close hint
+ state.tokenize = slim;
+ return null;
+ }
+ if (stream.match(/^:/)) { // inline tag
+ state.tokenize = slimTag;
+ return "slimSwitch";
+ }
+ startHtmlMode(stream, state, 0);
+ return state.tokenize(stream, state);
+ }
+
+ var mode = {
+ // default to html mode
+ startState: function() {
+ var htmlState = htmlMode.startState();
+ var rubyState = rubyMode.startState();
+ return {
+ htmlState: htmlState,
+ rubyState: rubyState,
+ stack: null,
+ last: null,
+ tokenize: slim,
+ line: slim,
+ indented: 0
+ };
+ },
+
+ copyState: function(state) {
+ return {
+ htmlState : CodeMirror.copyState(htmlMode, state.htmlState),
+ rubyState: CodeMirror.copyState(rubyMode, state.rubyState),
+ subMode: state.subMode,
+ subState: state.subMode && CodeMirror.copyState(state.subMode, state.subState),
+ stack: state.stack,
+ last: state.last,
+ tokenize: state.tokenize,
+ line: state.line
+ };
+ },
+
+ token: function(stream, state) {
+ if (stream.sol()) {
+ state.indented = stream.indentation();
+ state.startOfLine = true;
+ state.tokenize = state.line;
+ while (state.stack && state.stack.indented > state.indented && state.last != "slimSubmode") {
+ state.line = state.tokenize = state.stack.tokenize;
+ state.stack = state.stack.parent;
+ state.subMode = null;
+ state.subState = null;
+ }
+ }
+ if (stream.eatSpace()) return null;
+ var style = state.tokenize(stream, state);
+ state.startOfLine = false;
+ if (style) state.last = style;
+ return styleMap.hasOwnProperty(style) ? styleMap[style] : style;
+ },
+
+ blankLine: function(state) {
+ if (state.subMode && state.subMode.blankLine) {
+ return state.subMode.blankLine(state.subState);
+ }
+ },
+
+ innerMode: function(state) {
+ if (state.subMode) return {state: state.subState, mode: state.subMode};
+ return {state: state, mode: mode};
+ }
+
+ //indent: function(state) {
+ // return state.indented;
+ //}
+ };
+ return mode;
+ }, "htmlmixed", "ruby");
+
+ CodeMirror.defineMIME("text/x-slim", "slim");
+ CodeMirror.defineMIME("application/x-slim", "slim");
+});
diff --git a/data/ext/editorText/codemirror/mode/slim/test.js b/data/ext/editorText/codemirror/mode/slim/test.js
new file mode 100644
index 000000000..be4ddacb6
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/slim/test.js
@@ -0,0 +1,96 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Slim Highlighting for CodeMirror copyright (c) HicknHack Software Gmbh
+
+(function() {
+ var mode = CodeMirror.getMode({tabSize: 4, indentUnit: 2}, "slim");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
+
+ // Requires at least one media query
+ MT("elementName",
+ "[tag h1] Hey There");
+
+ MT("oneElementPerLine",
+ "[tag h1] Hey There .h2");
+
+ MT("idShortcut",
+ "[attribute&def #test] Hey There");
+
+ MT("tagWithIdShortcuts",
+ "[tag h1][attribute&def #test] Hey There");
+
+ MT("classShortcut",
+ "[attribute&qualifier .hello] Hey There");
+
+ MT("tagWithIdAndClassShortcuts",
+ "[tag h1][attribute&def #test][attribute&qualifier .hello] Hey There");
+
+ MT("docType",
+ "[keyword doctype] xml");
+
+ MT("comment",
+ "[comment / Hello WORLD]");
+
+ MT("notComment",
+ "[tag h1] This is not a / comment ");
+
+ MT("attributes",
+ "[tag a]([attribute title]=[string \"test\"]) [attribute href]=[string \"link\"]}");
+
+ MT("multiLineAttributes",
+ "[tag a]([attribute title]=[string \"test\"]",
+ " ) [attribute href]=[string \"link\"]}");
+
+ MT("htmlCode",
+ "[tag&bracket <][tag h1][tag&bracket >]Title[tag&bracket </][tag h1][tag&bracket >]");
+
+ MT("rubyBlock",
+ "[operator&special =][variable-2 @item]");
+
+ MT("selectorRubyBlock",
+ "[tag a][attribute&qualifier .test][operator&special =] [variable-2 @item]");
+
+ MT("nestedRubyBlock",
+ "[tag a]",
+ " [operator&special =][variable puts] [string \"test\"]");
+
+ MT("multilinePlaintext",
+ "[tag p]",
+ " | Hello,",
+ " World");
+
+ MT("multilineRuby",
+ "[tag p]",
+ " [comment /# this is a comment]",
+ " [comment and this is a comment too]",
+ " | Date/Time",
+ " [operator&special -] [variable now] [operator =] [tag DateTime][operator .][property now]",
+ " [tag strong][operator&special =] [variable now]",
+ " [operator&special -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][property parse]([string \"December 31, 2006\"])",
+ " [operator&special =][string \"Happy\"]",
+ " [operator&special =][string \"Belated\"]",
+ " [operator&special =][string \"Birthday\"]");
+
+ MT("multilineComment",
+ "[comment /]",
+ " [comment Multiline]",
+ " [comment Comment]");
+
+ MT("hamlAfterRubyTag",
+ "[attribute&qualifier .block]",
+ " [tag strong][operator&special =] [variable now]",
+ " [attribute&qualifier .test]",
+ " [operator&special =][variable now]",
+ " [attribute&qualifier .right]");
+
+ MT("stretchedRuby",
+ "[operator&special =] [variable puts] [string \"Hello\"],",
+ " [string \"World\"]");
+
+ MT("interpolationInHashAttribute",
+ "[tag div]{[attribute id] = [string \"]#{[variable test]}[string _]#{[variable ting]}[string \"]} test");
+
+ MT("interpolationInHTMLAttribute",
+ "[tag div]([attribute title]=[string \"]#{[variable test]}[string _]#{[variable ting]()}[string \"]) Test");
+})();
diff --git a/data/ext/editorText/codemirror/mode/smalltalk/index.html b/data/ext/editorText/codemirror/mode/smalltalk/index.html
index 0d2b172e1..2155ebc2a 100644
--- a/data/ext/editorText/codemirror/mode/smalltalk/index.html
+++ b/data/ext/editorText/codemirror/mode/smalltalk/index.html
@@ -14,12 +14,12 @@
.CodeMirror-gutter pre {color: white; font-weight: bold;}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/smalltalk/smalltalk.js b/data/ext/editorText/codemirror/mode/smalltalk/smalltalk.js
index 86f749b31..bb510ba2e 100644
--- a/data/ext/editorText/codemirror/mode/smalltalk/smalltalk.js
+++ b/data/ext/editorText/codemirror/mode/smalltalk/smalltalk.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode('smalltalk', function(config) {
var specialChars = /[+\-\/\\*~<>=@%|&?!.,:;^]/;
@@ -40,7 +53,7 @@ CodeMirror.defineMode('smalltalk', function(config) {
stream.next();
token = nextSymbol(stream, new Context(nextSymbol, context));
} else {
- if (stream.eatWhile(/[^ .{}\[\]()]/))
+ if (stream.eatWhile(/[^\s.{}\[\]()]/))
token.name = 'string-2';
else
token.name = 'meta';
@@ -48,7 +61,7 @@ CodeMirror.defineMode('smalltalk', function(config) {
} else if (aChar === '$') {
if (stream.next() === '<') {
- stream.eatWhile(/[^ >]/);
+ stream.eatWhile(/[^\s>]/);
stream.next();
}
token.name = 'string-2';
@@ -151,3 +164,5 @@ CodeMirror.defineMode('smalltalk', function(config) {
});
CodeMirror.defineMIME('text/x-stsrc', {name: 'smalltalk'});
+
+});
diff --git a/data/ext/editorText/codemirror/mode/smarty/index.html b/data/ext/editorText/codemirror/mode/smarty/index.html
index d458aef0f..b19c8f09b 100644
--- a/data/ext/editorText/codemirror/mode/smarty/index.html
+++ b/data/ext/editorText/codemirror/mode/smarty/index.html
@@ -6,15 +6,16 @@
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
+<script src="../xml/xml.js"></script>
<script src="smarty.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -46,17 +47,24 @@
{/function}
{/if}</textarea></form>
- <script>
- var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
- lineNumbers: true,
- mode: "smarty"
- });
- </script>
+<p>Mode for Smarty version 2 or 3, which allows for custom delimiter tags.</p>
- <br />
+<p>Several configuration parameters are supported:</p>
- <h3>Smarty 2, custom delimiters</h3>
- <form><textarea id="code2" name="code2">
+<ul>
+ <li><code>leftDelimiter</code> and <code>rightDelimiter</code>,
+ which should be strings that determine where the Smarty syntax
+ starts and ends.</li>
+ <li><code>version</code>, which should be 2 or 3.</li>
+ <li><code>baseMode</code>, which can be a mode spec
+ like <code>"text/html"</code> to set a different background mode.</li>
+</ul>
+
+<p><strong>MIME types defined:</strong> <code>text/x-smarty</code></p>
+
+<h3>Smarty 2, custom delimiters</h3>
+
+<form><textarea id="code2" name="code2">
{--extends file="parent.tpl"--}
{--include file="template.tpl"--}
@@ -78,27 +86,14 @@
{--/function--}
{--/if--}</textarea></form>
- <script>
- var editor = CodeMirror.fromTextArea(document.getElementById("code2"), {
- lineNumbers: true,
- mode: {
- name: "smarty",
- leftDelimiter: "{--",
- rightDelimiter: "--}"
- }
- });
- </script>
-
- <br />
-
- <h3>Smarty 3</h3>
+<h3>Smarty 3</h3>
- <textarea id="code3" name="code3">
+<textarea id="code3" name="code3">
Nested tags {$foo={counter one=1 two={inception}}+3} are now valid in Smarty 3.
<script>
function test() {
- console.log("Smarty 3 permits single curly braces followed by whitespace to NOT slip into Smarty mode.");
+ console.log("Smarty 3 permits single curly braces followed by whitespace to NOT slip into Smarty mode.");
}
</script>
@@ -121,16 +116,23 @@ Smarty "dot" syntax (note: embedded {} are used to address ambiguities):
{$object->method1($x)->method2($y)}</textarea>
- <script>
- var editor = CodeMirror.fromTextArea(document.getElementById("code3"), {
- lineNumbers: true,
- mode: "smarty",
- smartyVersion: 3
- });
- </script>
-
-
- <p>A plain text/Smarty version 2 or 3 mode, which allows for custom delimiter tags.</p>
+<script>
+var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "smarty"
+});
+var editor = CodeMirror.fromTextArea(document.getElementById("code2"), {
+ lineNumbers: true,
+ mode: {
+ name: "smarty",
+ leftDelimiter: "{--",
+ rightDelimiter: "--}"
+ }
+});
+var editor = CodeMirror.fromTextArea(document.getElementById("code3"), {
+ lineNumbers: true,
+ mode: {name: "smarty", version: 3, baseMode: "text/html"}
+});
+</script>
- <p><strong>MIME types defined:</strong> <code>text/x-smarty</code></p>
- </article>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/smarty/smarty.js b/data/ext/editorText/codemirror/mode/smarty/smarty.js
index 826c2b966..6e0fbed42 100644
--- a/data/ext/editorText/codemirror/mode/smarty/smarty.js
+++ b/data/ext/editorText/codemirror/mode/smarty/smarty.js
@@ -1,132 +1,135 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/**
* Smarty 2 and 3 mode.
*/
-CodeMirror.defineMode("smarty", function(config) {
+
+(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";
- // our default settings; check to see if they're overridden
- var settings = {
- rightDelimiter: '}',
- leftDelimiter: '{',
- smartyVersion: 2 // for backward compatibility
- };
- if (config.hasOwnProperty("leftDelimiter")) {
- settings.leftDelimiter = config.leftDelimiter;
- }
- if (config.hasOwnProperty("rightDelimiter")) {
- settings.rightDelimiter = config.rightDelimiter;
- }
- if (config.hasOwnProperty("smartyVersion") && config.smartyVersion === 3) {
- settings.smartyVersion = 3;
- }
-
- var keyFunctions = ["debug", "extends", "function", "include", "literal"];
- var last;
- var regs = {
- operatorChars: /[+\-*&%=<>!?]/,
- validIdentifier: /[a-zA-Z0-9_]/,
- stringChar: /['"]/
- };
-
- var helpers = {
- cont: function(style, lastType) {
+ CodeMirror.defineMode("smarty", function(config, parserConf) {
+ var rightDelimiter = parserConf.rightDelimiter || "}";
+ var leftDelimiter = parserConf.leftDelimiter || "{";
+ var version = parserConf.version || 2;
+ var baseMode = CodeMirror.getMode(config, parserConf.baseMode || "null");
+
+ var keyFunctions = ["debug", "extends", "function", "include", "literal"];
+ var regs = {
+ operatorChars: /[+\-*&%=<>!?]/,
+ validIdentifier: /[a-zA-Z0-9_]/,
+ stringChar: /['"]/
+ };
+
+ var last;
+ function cont(style, lastType) {
last = lastType;
return style;
- },
- chain: function(stream, state, parser) {
+ }
+
+ function chain(stream, state, parser) {
state.tokenize = parser;
return parser(stream, state);
}
- };
-
- // our various parsers
- var parsers = {
+ // Smarty 3 allows { and } surrounded by whitespace to NOT slip into Smarty mode
+ function doesNotCount(stream, pos) {
+ if (pos == null) pos = stream.pos;
+ return version === 3 && leftDelimiter == "{" &&
+ (pos == stream.string.length || /\s/.test(stream.string.charAt(pos)));
+ }
- // the main tokenizer
- tokenizer: function(stream, state) {
- if (stream.match(settings.leftDelimiter, true)) {
+ function tokenTop(stream, state) {
+ var string = stream.string;
+ for (var scan = stream.pos;;) {
+ var nextMatch = string.indexOf(leftDelimiter, scan);
+ scan = nextMatch + leftDelimiter.length;
+ if (nextMatch == -1 || !doesNotCount(stream, nextMatch + leftDelimiter.length)) break;
+ }
+ if (nextMatch == stream.pos) {
+ stream.match(leftDelimiter);
if (stream.eat("*")) {
- return helpers.chain(stream, state, parsers.inBlock("comment", "*" + settings.rightDelimiter));
+ return chain(stream, state, tokenBlock("comment", "*" + rightDelimiter));
} else {
- // Smarty 3 allows { and } surrounded by whitespace to NOT slip into Smarty mode
state.depth++;
- var isEol = stream.eol();
- var isFollowedByWhitespace = /\s/.test(stream.peek());
- if (settings.smartyVersion === 3 && settings.leftDelimiter === "{" && (isEol || isFollowedByWhitespace)) {
- state.depth--;
- return null;
- } else {
- state.tokenize = parsers.smarty;
- last = "startTag";
- return "tag";
- }
+ state.tokenize = tokenSmarty;
+ last = "startTag";
+ return "tag";
}
- } else {
- stream.next();
- return null;
}
- },
+
+ if (nextMatch > -1) stream.string = string.slice(0, nextMatch);
+ var token = baseMode.token(stream, state.base);
+ if (nextMatch > -1) stream.string = string;
+ return token;
+ }
// parsing Smarty content
- smarty: function(stream, state) {
- if (stream.match(settings.rightDelimiter, true)) {
- if (settings.smartyVersion === 3) {
+ function tokenSmarty(stream, state) {
+ if (stream.match(rightDelimiter, true)) {
+ if (version === 3) {
state.depth--;
if (state.depth <= 0) {
- state.tokenize = parsers.tokenizer;
+ state.tokenize = tokenTop;
}
} else {
- state.tokenize = parsers.tokenizer;
+ state.tokenize = tokenTop;
}
- return helpers.cont("tag", null);
+ return cont("tag", null);
}
- if (stream.match(settings.leftDelimiter, true)) {
+ if (stream.match(leftDelimiter, true)) {
state.depth++;
- return helpers.cont("tag", "startTag");
+ return cont("tag", "startTag");
}
var ch = stream.next();
if (ch == "$") {
stream.eatWhile(regs.validIdentifier);
- return helpers.cont("variable-2", "variable");
+ return cont("variable-2", "variable");
} else if (ch == "|") {
- return helpers.cont("operator", "pipe");
+ return cont("operator", "pipe");
} else if (ch == ".") {
- return helpers.cont("operator", "property");
+ return cont("operator", "property");
} else if (regs.stringChar.test(ch)) {
- state.tokenize = parsers.inAttribute(ch);
- return helpers.cont("string", "string");
+ state.tokenize = tokenAttribute(ch);
+ return cont("string", "string");
} else if (regs.operatorChars.test(ch)) {
stream.eatWhile(regs.operatorChars);
- return helpers.cont("operator", "operator");
+ return cont("operator", "operator");
} else if (ch == "[" || ch == "]") {
- return helpers.cont("bracket", "bracket");
+ return cont("bracket", "bracket");
} else if (ch == "(" || ch == ")") {
- return helpers.cont("bracket", "operator");
+ return cont("bracket", "operator");
} else if (/\d/.test(ch)) {
stream.eatWhile(/\d/);
- return helpers.cont("number", "number");
+ return cont("number", "number");
} else {
if (state.last == "variable") {
if (ch == "@") {
stream.eatWhile(regs.validIdentifier);
- return helpers.cont("property", "property");
+ return cont("property", "property");
} else if (ch == "|") {
stream.eatWhile(regs.validIdentifier);
- return helpers.cont("qualifier", "modifier");
+ return cont("qualifier", "modifier");
}
} else if (state.last == "pipe") {
stream.eatWhile(regs.validIdentifier);
- return helpers.cont("qualifier", "modifier");
+ return cont("qualifier", "modifier");
} else if (state.last == "whitespace") {
stream.eatWhile(regs.validIdentifier);
- return helpers.cont("attribute", "modifier");
+ return cont("attribute", "modifier");
} if (state.last == "property") {
stream.eatWhile(regs.validIdentifier);
- return helpers.cont("property", null);
+ return cont("property", null);
} else if (/\s/.test(ch)) {
last = "whitespace";
return null;
@@ -142,37 +145,37 @@ CodeMirror.defineMode("smarty", function(config) {
}
for (var i=0, j=keyFunctions.length; i<j; i++) {
if (keyFunctions[i] == str) {
- return helpers.cont("keyword", "keyword");
+ return cont("keyword", "keyword");
}
}
if (/\s/.test(ch)) {
return null;
}
- return helpers.cont("tag", "tag");
+ return cont("tag", "tag");
}
- },
+ }
- inAttribute: function(quote) {
+ function tokenAttribute(quote) {
return function(stream, state) {
var prevChar = null;
var currChar = null;
while (!stream.eol()) {
currChar = stream.peek();
if (stream.next() == quote && prevChar !== '\\') {
- state.tokenize = parsers.smarty;
+ state.tokenize = tokenSmarty;
break;
}
prevChar = currChar;
}
return "string";
};
- },
+ }
- inBlock: function(style, terminator) {
+ function tokenBlock(style, terminator) {
return function(stream, state) {
while (!stream.eol()) {
if (stream.match(terminator)) {
- state.tokenize = parsers.tokenizer;
+ state.tokenize = tokenTop;
break;
}
stream.next();
@@ -180,26 +183,43 @@ CodeMirror.defineMode("smarty", function(config) {
return style;
};
}
- };
-
- // the public API for CodeMirror
- return {
- startState: function() {
- return {
- tokenize: parsers.tokenizer,
- mode: "smarty",
- last: null,
- depth: 0
- };
- },
- token: function(stream, state) {
- var style = state.tokenize(stream, state);
- state.last = last;
- return style;
- },
- electricChars: ""
- };
+ return {
+ startState: function() {
+ return {
+ base: CodeMirror.startState(baseMode),
+ tokenize: tokenTop,
+ last: null,
+ depth: 0
+ };
+ },
+ copyState: function(state) {
+ return {
+ base: CodeMirror.copyState(baseMode, state.base),
+ tokenize: state.tokenize,
+ last: state.last,
+ depth: state.depth
+ };
+ },
+ innerMode: function(state) {
+ if (state.tokenize == tokenTop)
+ return {mode: baseMode, state: state.base};
+ },
+ token: function(stream, state) {
+ var style = state.tokenize(stream, state);
+ state.last = last;
+ return style;
+ },
+ indent: function(state, text) {
+ if (state.tokenize == tokenTop && baseMode.indent)
+ return baseMode.indent(state.base, text);
+ else
+ return CodeMirror.Pass;
+ },
+ blockCommentStart: leftDelimiter + "*",
+ blockCommentEnd: "*" + rightDelimiter
+ };
+ });
+
+ CodeMirror.defineMIME("text/x-smarty", "smarty");
});
-
-CodeMirror.defineMIME("text/x-smarty", "smarty");
diff --git a/data/ext/editorText/codemirror/mode/smartymixed/index.html b/data/ext/editorText/codemirror/mode/smartymixed/index.html
deleted file mode 100644
index 47c805fac..000000000
--- a/data/ext/editorText/codemirror/mode/smartymixed/index.html
+++ /dev/null
@@ -1,114 +0,0 @@
-<!doctype html>
-
-<title>CodeMirror: Smarty mixed mode</title>
-<meta charset="utf-8"/>
-<link rel=stylesheet href="../../doc/docs.css">
-
-<link rel="stylesheet" href="../../lib/codemirror.css">
-<script src="../../lib/codemirror.js"></script>
-<script src="../../mode/xml/xml.js"></script>
-<script src="../../mode/javascript/javascript.js"></script>
-<script src="../../mode/css/css.js"></script>
-<script src="../../mode/htmlmixed/htmlmixed.js"></script>
-<script src="../../mode/smarty/smarty.js"></script>
-<script src="../../mode/smartymixed/smartymixed.js"></script>
-<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
-
- <ul>
- <li><a href="../../index.html">Home</a>
- <li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
- </ul>
- <ul>
- <li><a href="../index.html">Language modes</a>
- <li><a class=active href="#">Smarty mixed</a>
- </ul>
-</div>
-
-<article>
-<h2>Smarty mixed mode</h2>
-<form><textarea id="code" name="code">
-{**
-* @brief Smarty mixed mode
-* @author Ruslan Osmanov
-* @date 29.06.2013
-*}
-<html>
-<head>
- <title>{$title|htmlspecialchars|truncate:30}</title>
-</head>
-<body class="{$bodyclass}">
- {* Multiline smarty
- * comment, no {$variables} here
- *}
- {literal}
- {literal} is just an HTML text.
- <script type="text/javascript">//<![CDATA[
- var a = {$just_a_normal_js_object : "value"};
- var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
- mode : "smartymixed",
- tabSize : 2,
- indentUnit : 2,
- indentWithTabs : false,
- lineNumbers : true,
- smartyVersion : 3
- });
- // ]]>
- </script>
- <style>
- /* CSS content
- {$no_smarty} */
- .some-class { font-weight: bolder; color: "orange"; }
- </style>
- {/literal}
-
- {extends file="parent.tpl"}
- {include file="template.tpl"}
-
- {* some example Smarty content *}
- {if isset($name) && $name == 'Blog'}
- This is a {$var}.
- {$integer = 4511}, {$array[] = "a"}, {$stringvar = "string"}
- {$integer = 4512} {$array[] = "a"} {$stringvar = "string"}
- {assign var='bob' value=$var.prop}
- {elseif $name == $foo}
- {function name=menu level=0}
- {foreach $data as $entry}
- {if is_array($entry)}
- - {$entry@key}
- {menu data=$entry level=$level+1}
- {else}
- {$entry}
- {* One
- * Two
- * Three
- *}
- {/if}
- {/foreach}
- {/function}
- {/if}
- </body>
- <!-- R.O. -->
-</html>
-</textarea></form>
-
- <script type="text/javascript">
- var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
- mode : "smartymixed",
- tabSize : 2,
- indentUnit : 2,
- indentWithTabs : false,
- lineNumbers : true,
- smartyVersion : 3,
- matchBrackets : true,
- });
- </script>
-
- <p>The Smarty mixed mode depends on the Smarty and HTML mixed modes. HTML
- mixed mode itself depends on XML, JavaScript, and CSS modes.</p>
-
- <p>It takes the same options, as Smarty and HTML mixed modes.</p>
-
- <p><strong>MIME types defined:</strong> <code>text/x-smarty</code>.</p>
- </article>
diff --git a/data/ext/editorText/codemirror/mode/smartymixed/smartymixed.js b/data/ext/editorText/codemirror/mode/smartymixed/smartymixed.js
deleted file mode 100644
index 48dd1a675..000000000
--- a/data/ext/editorText/codemirror/mode/smartymixed/smartymixed.js
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
-* @file smartymixed.js
-* @brief Smarty Mixed Codemirror mode (Smarty + Mixed HTML)
-* @author Ruslan Osmanov <rrosmanov at gmail dot com>
-* @version 3.0
-* @date 05.07.2013
-*/
-CodeMirror.defineMode("smartymixed", function(config) {
- var settings, regs, helpers, parsers,
- htmlMixedMode = CodeMirror.getMode(config, "htmlmixed"),
- smartyMode = CodeMirror.getMode(config, "smarty"),
-
- settings = {
- rightDelimiter: '}',
- leftDelimiter: '{'
- };
-
- if (config.hasOwnProperty("leftDelimiter")) {
- settings.leftDelimiter = config.leftDelimiter;
- }
- if (config.hasOwnProperty("rightDelimiter")) {
- settings.rightDelimiter = config.rightDelimiter;
- }
-
- regs = {
- smartyComment: new RegExp("^" + settings.leftDelimiter + "\\*"),
- literalOpen: new RegExp(settings.leftDelimiter + "literal" + settings.rightDelimiter),
- literalClose: new RegExp(settings.leftDelimiter + "\/literal" + settings.rightDelimiter),
- hasLeftDelimeter: new RegExp(".*" + settings.leftDelimiter),
- htmlHasLeftDelimeter: new RegExp("[^<>]*" + settings.leftDelimiter)
- };
-
- helpers = {
- chain: function(stream, state, parser) {
- state.tokenize = parser;
- return parser(stream, state);
- },
-
- cleanChain: function(stream, state, parser) {
- state.tokenize = null;
- state.localState = null;
- state.localMode = null;
- return (typeof parser == "string") ? (parser ? parser : null) : parser(stream, state);
- },
-
- maybeBackup: function(stream, pat, style) {
- var cur = stream.current();
- var close = cur.search(pat),
- m;
- if (close > - 1) stream.backUp(cur.length - close);
- else if (m = cur.match(/<\/?$/)) {
- stream.backUp(cur.length);
- if (!stream.match(pat, false)) stream.match(cur[0]);
- }
- return style;
- }
- };
-
- parsers = {
- html: function(stream, state) {
- if (!state.inLiteral && stream.match(regs.htmlHasLeftDelimeter, false) && state.htmlMixedState.htmlState.tagName === null) {
- state.tokenize = parsers.smarty;
- state.localMode = smartyMode;
- state.localState = smartyMode.startState(htmlMixedMode.indent(state.htmlMixedState, ""));
- return helpers.maybeBackup(stream, settings.leftDelimiter, smartyMode.token(stream, state.localState));
- } else if (!state.inLiteral && stream.match(settings.leftDelimiter, false)) {
- state.tokenize = parsers.smarty;
- state.localMode = smartyMode;
- state.localState = smartyMode.startState(htmlMixedMode.indent(state.htmlMixedState, ""));
- return helpers.maybeBackup(stream, settings.leftDelimiter, smartyMode.token(stream, state.localState));
- }
- return htmlMixedMode.token(stream, state.htmlMixedState);
- },
-
- smarty: function(stream, state) {
- if (stream.match(settings.leftDelimiter, false)) {
- if (stream.match(regs.smartyComment, false)) {
- return helpers.chain(stream, state, parsers.inBlock("comment", "*" + settings.rightDelimiter));
- }
- } else if (stream.match(settings.rightDelimiter, false)) {
- stream.eat(settings.rightDelimiter);
- state.tokenize = parsers.html;
- state.localMode = htmlMixedMode;
- state.localState = state.htmlMixedState;
- return "tag";
- }
-
- return helpers.maybeBackup(stream, settings.rightDelimiter, smartyMode.token(stream, state.localState));
- },
-
- inBlock: function(style, terminator) {
- return function(stream, state) {
- while (!stream.eol()) {
- if (stream.match(terminator)) {
- helpers.cleanChain(stream, state, "");
- break;
- }
- stream.next();
- }
- return style;
- };
- }
- };
-
- return {
- startState: function() {
- var state = htmlMixedMode.startState();
- return {
- token: parsers.html,
- localMode: null,
- localState: null,
- htmlMixedState: state,
- tokenize: null,
- inLiteral: false
- };
- },
-
- copyState: function(state) {
- var local = null, tok = (state.tokenize || state.token);
- if (state.localState) {
- local = CodeMirror.copyState((tok != parsers.html ? smartyMode : htmlMixedMode), state.localState);
- }
- return {
- token: state.token,
- tokenize: state.tokenize,
- localMode: state.localMode,
- localState: local,
- htmlMixedState: CodeMirror.copyState(htmlMixedMode, state.htmlMixedState),
- inLiteral: state.inLiteral
- };
- },
-
- token: function(stream, state) {
- if (stream.match(settings.leftDelimiter, false)) {
- if (!state.inLiteral && stream.match(regs.literalOpen, true)) {
- state.inLiteral = true;
- return "keyword";
- } else if (state.inLiteral && stream.match(regs.literalClose, true)) {
- state.inLiteral = false;
- return "keyword";
- }
- }
- if (state.inLiteral && state.localState != state.htmlMixedState) {
- state.tokenize = parsers.html;
- state.localMode = htmlMixedMode;
- state.localState = state.htmlMixedState;
- }
-
- var style = (state.tokenize || state.token)(stream, state);
- return style;
- },
-
- indent: function(state, textAfter) {
- if (state.localMode == smartyMode
- || (state.inLiteral && !state.localMode)
- || regs.hasLeftDelimeter.test(textAfter)) {
- return CodeMirror.Pass;
- }
- return htmlMixedMode.indent(state.htmlMixedState, textAfter);
- },
-
- innerMode: function(state) {
- return {
- state: state.localState || state.htmlMixedState,
- mode: state.localMode || htmlMixedMode
- };
- }
- };
-},
-"htmlmixed");
-
-CodeMirror.defineMIME("text/x-smarty", "smartymixed");
-// vim: et ts=2 sts=2 sw=2
diff --git a/data/ext/editorText/codemirror/mode/solr/index.html b/data/ext/editorText/codemirror/mode/solr/index.html
index cb880244b..4b18c25b7 100644
--- a/data/ext/editorText/codemirror/mode/solr/index.html
+++ b/data/ext/editorText/codemirror/mode/solr/index.html
@@ -18,12 +18,12 @@
}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/solr/solr.js b/data/ext/editorText/codemirror/mode/solr/solr.js
index c732ff479..f7f708789 100644
--- a/data/ext/editorText/codemirror/mode/solr/solr.js
+++ b/data/ext/editorText/codemirror/mode/solr/solr.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("solr", function() {
"use strict";
@@ -87,3 +100,5 @@ CodeMirror.defineMode("solr", function() {
});
CodeMirror.defineMIME("text/x-solr", "solr");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/soy/index.html b/data/ext/editorText/codemirror/mode/soy/index.html
new file mode 100644
index 000000000..f0216f097
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/soy/index.html
@@ -0,0 +1,68 @@
+<!doctype html>
+
+<title>CodeMirror: Soy (Closure Template) mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/edit/matchbrackets.js"></script>
+<script src="../htmlmixed/htmlmixed.js"></script>
+<script src="../xml/xml.js"></script>
+<script src="../javascript/javascript.js"></script>
+<script src="../css/css.js"></script>
+<script src="soy.js"></script>
+<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Soy (Closure Template)</a>
+ </ul>
+</div>
+
+<article>
+<h2>Soy (Closure Template) mode</h2>
+<form><textarea id="code" name="code">
+{namespace example}
+
+/**
+ * Says hello to the world.
+ */
+{template .helloWorld}
+ {@param name: string}
+ {@param? score: number}
+ Hello <b>{$name}</b>!
+ <div>
+ {if $score}
+ <em>{$score} points</em>
+ {else}
+ no score
+ {/if}
+ </div>
+{/template}
+
+{template .alertHelloWorld kind="js"}
+ alert('Hello World');
+{/template}
+</textarea></form>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-soy",
+ indentUnit: 2,
+ indentWithTabs: false
+ });
+ </script>
+
+ <p>A mode for <a href="https://developers.google.com/closure/templates/">Closure Templates</a> (Soy).</p>
+ <p><strong>MIME type defined:</strong> <code>text/x-soy</code>.</p>
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/soy/soy.js b/data/ext/editorText/codemirror/mode/soy/soy.js
new file mode 100644
index 000000000..79bfc24df
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/soy/soy.js
@@ -0,0 +1,198 @@
+// 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"), require("../htmlmixed/htmlmixed"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../htmlmixed/htmlmixed"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ var indentingTags = ["template", "literal", "msg", "fallbackmsg", "let", "if", "elseif",
+ "else", "switch", "case", "default", "foreach", "ifempty", "for",
+ "call", "param", "deltemplate", "delcall", "log"];
+
+ CodeMirror.defineMode("soy", function(config) {
+ var textMode = CodeMirror.getMode(config, "text/plain");
+ var modes = {
+ html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFactor: 2, multilineTagIndentPastTag: false}),
+ attributes: textMode,
+ text: textMode,
+ uri: textMode,
+ css: CodeMirror.getMode(config, "text/css"),
+ js: CodeMirror.getMode(config, {name: "text/javascript", statementIndent: 2 * config.indentUnit})
+ };
+
+ function last(array) {
+ return array[array.length - 1];
+ }
+
+ function tokenUntil(stream, state, untilRegExp) {
+ var oldString = stream.string;
+ var match = untilRegExp.exec(oldString.substr(stream.pos));
+ if (match) {
+ // We don't use backUp because it backs up just the position, not the state.
+ // This uses an undocumented API.
+ stream.string = oldString.substr(0, stream.pos + match.index);
+ }
+ var result = stream.hideFirstChars(state.indent, function() {
+ return state.localMode.token(stream, state.localState);
+ });
+ stream.string = oldString;
+ return result;
+ }
+
+ return {
+ startState: function() {
+ return {
+ kind: [],
+ kindTag: [],
+ soyState: [],
+ indent: 0,
+ localMode: modes.html,
+ localState: CodeMirror.startState(modes.html)
+ };
+ },
+
+ copyState: function(state) {
+ return {
+ tag: state.tag, // Last seen Soy tag.
+ kind: state.kind.concat([]), // Values of kind="" attributes.
+ kindTag: state.kindTag.concat([]), // Opened tags with kind="" attributes.
+ soyState: state.soyState.concat([]),
+ indent: state.indent, // Indentation of the following line.
+ localMode: state.localMode,
+ localState: CodeMirror.copyState(state.localMode, state.localState)
+ };
+ },
+
+ token: function(stream, state) {
+ var match;
+
+ switch (last(state.soyState)) {
+ case "comment":
+ if (stream.match(/^.*?\*\//)) {
+ state.soyState.pop();
+ } else {
+ stream.skipToEnd();
+ }
+ return "comment";
+
+ case "variable":
+ if (stream.match(/^}/)) {
+ state.indent -= 2 * config.indentUnit;
+ state.soyState.pop();
+ return "variable-2";
+ }
+ stream.next();
+ return null;
+
+ case "tag":
+ if (stream.match(/^\/?}/)) {
+ if (state.tag == "/template" || state.tag == "/deltemplate") state.indent = 0;
+ else state.indent -= (stream.current() == "/}" || indentingTags.indexOf(state.tag) == -1 ? 2 : 1) * config.indentUnit;
+ state.soyState.pop();
+ return "keyword";
+ } else if (stream.match(/^([\w?]+)(?==)/)) {
+ if (stream.current() == "kind" && (match = stream.match(/^="([^"]+)/, false))) {
+ var kind = match[1];
+ state.kind.push(kind);
+ state.kindTag.push(state.tag);
+ state.localMode = modes[kind] || modes.html;
+ state.localState = CodeMirror.startState(state.localMode);
+ }
+ return "attribute";
+ } else if (stream.match(/^"/)) {
+ state.soyState.push("string");
+ return "string";
+ }
+ stream.next();
+ return null;
+
+ case "literal":
+ if (stream.match(/^(?=\{\/literal})/)) {
+ state.indent -= config.indentUnit;
+ state.soyState.pop();
+ return this.token(stream, state);
+ }
+ return tokenUntil(stream, state, /\{\/literal}/);
+
+ case "string":
+ if (stream.match(/^.*?"/)) {
+ state.soyState.pop();
+ } else {
+ stream.skipToEnd();
+ }
+ return "string";
+ }
+
+ if (stream.match(/^\/\*/)) {
+ state.soyState.push("comment");
+ return "comment";
+ } else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) {
+ return "comment";
+ } else if (stream.match(/^\{\$[\w?]*/)) {
+ state.indent += 2 * config.indentUnit;
+ state.soyState.push("variable");
+ return "variable-2";
+ } else if (stream.match(/^\{literal}/)) {
+ state.indent += config.indentUnit;
+ state.soyState.push("literal");
+ return "keyword";
+ } else if (match = stream.match(/^\{([\/@\\]?[\w?]*)/)) {
+ if (match[1] != "/switch")
+ state.indent += (/^(\/|(else|elseif|case|default)$)/.test(match[1]) && state.tag != "switch" ? 1 : 2) * config.indentUnit;
+ state.tag = match[1];
+ if (state.tag == "/" + last(state.kindTag)) {
+ // We found the tag that opened the current kind="".
+ state.kind.pop();
+ state.kindTag.pop();
+ state.localMode = modes[last(state.kind)] || modes.html;
+ state.localState = CodeMirror.startState(state.localMode);
+ }
+ state.soyState.push("tag");
+ return "keyword";
+ }
+
+ return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/);
+ },
+
+ indent: function(state, textAfter) {
+ var indent = state.indent, top = last(state.soyState);
+ if (top == "comment") return CodeMirror.Pass;
+
+ if (top == "literal") {
+ if (/^\{\/literal}/.test(textAfter)) indent -= config.indentUnit;
+ } else {
+ if (/^\s*\{\/(template|deltemplate)\b/.test(textAfter)) return 0;
+ if (/^\{(\/|(fallbackmsg|elseif|else|ifempty)\b)/.test(textAfter)) indent -= config.indentUnit;
+ if (state.tag != "switch" && /^\{(case|default)\b/.test(textAfter)) indent -= config.indentUnit;
+ if (/^\{\/switch\b/.test(textAfter)) indent -= config.indentUnit;
+ }
+ if (indent && state.localMode.indent)
+ indent += state.localMode.indent(state.localState, textAfter);
+ return indent;
+ },
+
+ innerMode: function(state) {
+ if (state.soyState.length && last(state.soyState) != "literal") return null;
+ else return {state: state.localState, mode: state.localMode};
+ },
+
+ electricInput: /^\s*\{(\/|\/template|\/deltemplate|\/switch|fallbackmsg|elseif|else|case|default|ifempty|\/literal\})$/,
+ lineComment: "//",
+ blockCommentStart: "/*",
+ blockCommentEnd: "*/",
+ blockCommentContinue: " * ",
+ fold: "indent"
+ };
+ }, "htmlmixed");
+
+ CodeMirror.registerHelper("hintWords", "soy", indentingTags.concat(
+ ["delpackage", "namespace", "alias", "print", "css", "debugger"]));
+
+ CodeMirror.defineMIME("text/x-soy", "soy");
+});
diff --git a/data/ext/editorText/codemirror/mode/sparql/index.html b/data/ext/editorText/codemirror/mode/sparql/index.html
index 5f19d647b..84ef4d363 100644
--- a/data/ext/editorText/codemirror/mode/sparql/index.html
+++ b/data/ext/editorText/codemirror/mode/sparql/index.html
@@ -10,12 +10,12 @@
<script src="sparql.js"></script>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -29,25 +29,33 @@
PREFIX a: &lt;http://www.w3.org/2000/10/annotation-ns#>
PREFIX dc: &lt;http://purl.org/dc/elements/1.1/>
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/>
+PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#>
# Comment!
SELECT ?given ?family
WHERE {
- ?annot a:annotates &lt;http://www.w3.org/TR/rdf-sparql-query/> .
- ?annot dc:creator ?c .
- OPTIONAL {?c foaf:given ?given ;
- foaf:family ?family } .
+ {
+ ?annot a:annotates &lt;http://www.w3.org/TR/rdf-sparql-query/> .
+ ?annot dc:creator ?c .
+ OPTIONAL {?c foaf:givenName ?given ;
+ foaf:familyName ?family }
+ } UNION {
+ ?c !foaf:knows/foaf:knows? ?thing.
+ ?thing rdfs
+ } MINUS {
+ ?thing rdfs:label "剛柔流"@jp
+ }
FILTER isBlank(?c)
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
- mode: "application/x-sparql-query",
+ mode: "application/sparql-query",
matchBrackets: true
});
</script>
- <p><strong>MIME types defined:</strong> <code>application/x-sparql-query</code>.</p>
+ <p><strong>MIME types defined:</strong> <code>application/sparql-query</code>.</p>
</article>
diff --git a/data/ext/editorText/codemirror/mode/sparql/sparql.js b/data/ext/editorText/codemirror/mode/sparql/sparql.js
index 0329057f6..bbf8a76a0 100644
--- a/data/ext/editorText/codemirror/mode/sparql/sparql.js
+++ b/data/ext/editorText/codemirror/mode/sparql/sparql.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("sparql", function(config) {
var indentUnit = config.indentUnit;
var curPunc;
@@ -6,18 +19,28 @@ CodeMirror.defineMode("sparql", function(config) {
return new RegExp("^(?:" + words.join("|") + ")$", "i");
}
var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
+ "iri", "uri", "bnode", "count", "sum", "min", "max", "avg", "sample",
+ "group_concat", "rand", "abs", "ceil", "floor", "round", "concat", "substr", "strlen",
+ "replace", "ucase", "lcase", "encode_for_uri", "contains", "strstarts", "strends",
+ "strbefore", "strafter", "year", "month", "day", "hours", "minutes", "seconds",
+ "timezone", "tz", "now", "uuid", "struuid", "md5", "sha1", "sha256", "sha384",
+ "sha512", "coalesce", "if", "strlang", "strdt", "isnumeric", "regex", "exists",
"isblank", "isliteral", "a"]);
var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",
"ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional",
"graph", "by", "asc", "desc", "as", "having", "undef", "values", "group",
"minus", "in", "not", "service", "silent", "using", "insert", "delete", "union",
+ "true", "false", "with",
"data", "copy", "to", "move", "add", "create", "drop", "clear", "load"]);
- var operatorChars = /[*+\-<>=&|]/;
+ var operatorChars = /[*+\-<>=&|\^\/!\?]/;
function tokenBase(stream, state) {
var ch = stream.next();
curPunc = null;
if (ch == "$" || ch == "?") {
+ if(ch == "?" && stream.match(/\s/, false)){
+ return "operator";
+ }
stream.match(/^[\w\d]*/);
return "variable-2";
}
@@ -31,7 +54,7 @@ CodeMirror.defineMode("sparql", function(config) {
}
else if (/[{}\(\),\.;\[\]]/.test(ch)) {
curPunc = ch;
- return null;
+ return "bracket";
}
else if (ch == "#") {
stream.skipToEnd();
@@ -39,12 +62,16 @@ CodeMirror.defineMode("sparql", function(config) {
}
else if (operatorChars.test(ch)) {
stream.eatWhile(operatorChars);
- return null;
+ return "operator";
}
else if (ch == ":") {
stream.eatWhile(/[\w\d\._\-]/);
return "atom";
}
+ else if (ch == "@") {
+ stream.eatWhile(/[a-z\d\-]/i);
+ return "meta";
+ }
else {
stream.eatWhile(/[_\w\d]/);
if (stream.eat(":")) {
@@ -53,7 +80,7 @@ CodeMirror.defineMode("sparql", function(config) {
}
var word = stream.current();
if (ops.test(word))
- return null;
+ return "builtin";
else if (keywords.test(word))
return "keyword";
else
@@ -142,4 +169,6 @@ CodeMirror.defineMode("sparql", function(config) {
};
});
-CodeMirror.defineMIME("application/x-sparql-query", "sparql");
+CodeMirror.defineMIME("application/sparql-query", "sparql");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/spreadsheet/index.html b/data/ext/editorText/codemirror/mode/spreadsheet/index.html
new file mode 100644
index 000000000..a52f76f05
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/spreadsheet/index.html
@@ -0,0 +1,42 @@
+<!doctype html>
+
+<title>CodeMirror: Spreadsheet mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/edit/matchbrackets.js"></script>
+<script src="spreadsheet.js"></script>
+<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Spreadsheet</a>
+ </ul>
+</div>
+
+<article>
+ <h2>Spreadsheet mode</h2>
+ <form><textarea id="code" name="code">=IF(A1:B2, TRUE, FALSE) / 100</textarea></form>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ extraKeys: {"Tab": "indentAuto"}
+ });
+ </script>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-spreadsheet</code>.</p>
+
+ <h3>The Spreadsheet Mode</h3>
+ <p> Created by <a href="https://github.com/robertleeplummerjr">Robert Plummer</a></p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/spreadsheet/spreadsheet.js b/data/ext/editorText/codemirror/mode/spreadsheet/spreadsheet.js
new file mode 100644
index 000000000..6fab00fdd
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/spreadsheet/spreadsheet.js
@@ -0,0 +1,109 @@
+// 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";
+
+ CodeMirror.defineMode("spreadsheet", function () {
+ return {
+ startState: function () {
+ return {
+ stringType: null,
+ stack: []
+ };
+ },
+ token: function (stream, state) {
+ if (!stream) return;
+
+ //check for state changes
+ if (state.stack.length === 0) {
+ //strings
+ if ((stream.peek() == '"') || (stream.peek() == "'")) {
+ state.stringType = stream.peek();
+ stream.next(); // Skip quote
+ state.stack.unshift("string");
+ }
+ }
+
+ //return state
+ //stack has
+ switch (state.stack[0]) {
+ case "string":
+ while (state.stack[0] === "string" && !stream.eol()) {
+ if (stream.peek() === state.stringType) {
+ stream.next(); // Skip quote
+ state.stack.shift(); // Clear flag
+ } else if (stream.peek() === "\\") {
+ stream.next();
+ stream.next();
+ } else {
+ stream.match(/^.[^\\\"\']*/);
+ }
+ }
+ return "string";
+
+ case "characterClass":
+ while (state.stack[0] === "characterClass" && !stream.eol()) {
+ if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./)))
+ state.stack.shift();
+ }
+ return "operator";
+ }
+
+ var peek = stream.peek();
+
+ //no stack
+ switch (peek) {
+ case "[":
+ stream.next();
+ state.stack.unshift("characterClass");
+ return "bracket";
+ case ":":
+ stream.next();
+ return "operator";
+ case "\\":
+ if (stream.match(/\\[a-z]+/)) return "string-2";
+ else return null;
+ case ".":
+ case ",":
+ case ";":
+ case "*":
+ case "-":
+ case "+":
+ case "^":
+ case "<":
+ case "/":
+ case "=":
+ stream.next();
+ return "atom";
+ case "$":
+ stream.next();
+ return "builtin";
+ }
+
+ if (stream.match(/\d+/)) {
+ if (stream.match(/^\w+/)) return "error";
+ return "number";
+ } else if (stream.match(/^[a-zA-Z_]\w*/)) {
+ if (stream.match(/(?=[\(.])/, false)) return "keyword";
+ return "variable-2";
+ } else if (["[", "]", "(", ")", "{", "}"].indexOf(peek) != -1) {
+ stream.next();
+ return "bracket";
+ } else if (!stream.eatSpace()) {
+ stream.next();
+ }
+ return null;
+ }
+ };
+ });
+
+ CodeMirror.defineMIME("text/x-spreadsheet", "spreadsheet");
+});
diff --git a/data/ext/editorText/codemirror/mode/sql/index.html b/data/ext/editorText/codemirror/mode/sql/index.html
index 79a2e74e0..a0d8d9e1b 100644
--- a/data/ext/editorText/codemirror/mode/sql/index.html
+++ b/data/ext/editorText/codemirror/mode/sql/index.html
@@ -7,6 +7,9 @@
<link rel="stylesheet" href="../../lib/codemirror.css" />
<script src="../../lib/codemirror.js"></script>
<script src="sql.js"></script>
+<link rel="stylesheet" href="../../addon/hint/show-hint.css" />
+<script src="../../addon/hint/show-hint.js"></script>
+<script src="../../addon/hint/sql-hint.js"></script>
<style>
.CodeMirror {
border-top: 1px solid black;
@@ -14,12 +17,12 @@
}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -68,7 +71,12 @@ window.onload = function() {
smartIndent: true,
lineNumbers: true,
matchBrackets : true,
- autofocus: true
+ autofocus: true,
+ extraKeys: {"Ctrl-Space": "autocomplete"},
+ hintOptions: {tables: {
+ users: {name: null, score: null, birthDate: null},
+ countries: {name: null, population: null, size: null}
+ }}
});
};
</script>
diff --git a/data/ext/editorText/codemirror/mode/sql/sql.js b/data/ext/editorText/codemirror/mode/sql/sql.js
index 176f80677..a90827715 100644
--- a/data/ext/editorText/codemirror/mode/sql/sql.js
+++ b/data/ext/editorText/codemirror/mode/sql/sql.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("sql", function(config, parserConfig) {
"use strict";
@@ -177,7 +190,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
indent: function(state, textAfter) {
var cx = state.context;
- if (!cx) return 0;
+ if (!cx) return CodeMirror.Pass;
var closing = textAfter.charAt(0) == cx.type;
if (cx.align) return cx.col + (closing ? 0 : 1);
else return cx.indent + (closing ? 0 : config.indentUnit);
@@ -200,7 +213,8 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
while ((ch = stream.next()) != null) {
if (ch == "`" && !stream.eat("`")) return "variable-2";
}
- return null;
+ stream.backUp(stream.current().length - 1);
+ return stream.eatWhile(/\w/) ? "variable-2" : null;
}
// variable token
@@ -243,7 +257,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
}
// these keywords are used by all SQL dialects (however, a mode can still overwrite it)
- var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from having in insert into is join like not on or order select set table union update values where ";
+ var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from group having in insert into is join like not on or order select set table union update values where ";
// turn a space-separated list into an array
function set(str) {
@@ -266,7 +280,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
CodeMirror.defineMIME("text/x-mssql", {
name: "sql",
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
- keywords: set(sqlKeywords + "begin trigger proc view index for add constraint key primary foreign collate clustered nonclustered"),
+ keywords: set(sqlKeywords + "begin trigger proc view index for add constraint key primary foreign collate clustered nonclustered declare"),
builtin: set("bigint numeric bit smallint decimal smallmoney int tinyint money float real char varchar text nchar nvarchar ntext binary varbinary image cursor timestamp hierarchyid uniqueidentifier sql_variant xml table "),
atoms: set("false true null unknown"),
operatorChars: /^[*+\-%<>!=]/,
@@ -279,7 +293,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
CodeMirror.defineMIME("text/x-mysql", {
name: "sql",
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
- keywords: set(sqlKeywords + "accessible action add after algorithm all analyze asensitive at authors auto_increment autocommit avg avg_row_length before binary binlog both btree cache call cascade cascaded case catalog_name chain change changed character check checkpoint checksum class_origin client_statistics close coalesce code collate collation collations column columns comment commit committed completion concurrent condition connection consistent constraint contains continue contributors convert cross current current_date current_time current_timestamp current_user cursor data database databases day_hour day_microsecond day_minute day_second deallocate dec declare default delay_key_write delayed delimiter des_key_file describe deterministic dev_pop dev_samp deviance diagnostics directory disable discard distinctrow div dual dumpfile each elseif enable enclosed end ends engine engines enum errors escape escaped even event events every execute exists exit explain extended fast fetch field fields first flush for force foreign found_rows full fulltext function general get global grant grants group groupby_concat handler hash help high_priority hosts hour_microsecond hour_minute hour_second if ignore ignore_server_ids import index index_statistics infile inner innodb inout insensitive insert_method install interval invoker isolation iterate key keys kill language last leading leave left level limit linear lines list load local localtime localtimestamp lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters match max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modifies modify mutex mysql_errno natural next no no_write_to_binlog offline offset one online open optimize option optionally out outer outfile pack_keys parser partition partitions password phase plugin plugins prepare preserve prev primary privileges procedure processlist profile profiles purge query quick range read read_write reads real rebuild recover references regexp relaylog release remove rename reorganize repair repeatable replace require resignal restrict resume return returns revoke right rlike rollback rollup row row_format rtree savepoint schedule schema schema_name schemas second_microsecond security sensitive separator serializable server session share show signal slave slow smallint snapshot soname spatial specific sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result sqlexception sqlstate sqlwarning ssl start starting starts status std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace temporary terminated to trailing transaction trigger triggers truncate uncommitted undo uninstall unique unlock upgrade usage use use_frm user user_resources user_statistics using utc_date utc_time utc_timestamp value variables varying view views warnings when while with work write xa xor year_month zerofill begin do then else loop repeat"),
+ keywords: set(sqlKeywords + "accessible action add after algorithm all analyze asensitive at authors auto_increment autocommit avg avg_row_length before binary binlog both btree cache call cascade cascaded case catalog_name chain change changed character check checkpoint checksum class_origin client_statistics close coalesce code collate collation collations column columns comment commit committed completion concurrent condition connection consistent constraint contains continue contributors convert cross current current_date current_time current_timestamp current_user cursor data database databases day_hour day_microsecond day_minute day_second deallocate dec declare default delay_key_write delayed delimiter des_key_file describe deterministic dev_pop dev_samp deviance diagnostics directory disable discard distinctrow div dual dumpfile each elseif enable enclosed end ends engine engines enum errors escape escaped even event events every execute exists exit explain extended fast fetch field fields first flush for force foreign found_rows full fulltext function general get global grant grants group group_concat handler hash help high_priority hosts hour_microsecond hour_minute hour_second if ignore ignore_server_ids import index index_statistics infile inner innodb inout insensitive insert_method install interval invoker isolation iterate key keys kill language last leading leave left level limit linear lines list load local localtime localtimestamp lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters match max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modifies modify mutex mysql_errno natural next no no_write_to_binlog offline offset one online open optimize option optionally out outer outfile pack_keys parser partition partitions password phase plugin plugins prepare preserve prev primary privileges procedure processlist profile profiles purge query quick range read read_write reads real rebuild recover references regexp relaylog release remove rename reorganize repair repeatable replace require resignal restrict resume return returns revoke right rlike rollback rollup row row_format rtree savepoint schedule schema schema_name schemas second_microsecond security sensitive separator serializable server session share show signal slave slow smallint snapshot soname spatial specific sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result sqlexception sqlstate sqlwarning ssl start starting starts status std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace temporary terminated to trailing transaction trigger triggers truncate uncommitted undo uninstall unique unlock upgrade usage use use_frm user user_resources user_statistics using utc_date utc_time utc_timestamp value variables varying view views warnings when while with work write xa xor year_month zerofill begin do then else loop repeat"),
builtin: set("bool boolean bit blob decimal double float long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision date datetime year unsigned signed numeric"),
atoms: set("false true null unknown"),
operatorChars: /^[*+\-%<>!=&|^]/,
@@ -313,9 +327,9 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
CodeMirror.defineMIME("text/x-cassandra", {
name: "sql",
client: { },
- keywords: set("use select from using consistency where limit first reversed first and in insert into values using consistency ttl update set delete truncate begin batch apply create keyspace with columnfamily primary key index on drop alter type add any one quorum all local_quorum each_quorum"),
- builtin: set("ascii bigint blob boolean counter decimal double float int text timestamp uuid varchar varint"),
- atoms: set("false true"),
+ keywords: set("add all allow alter and any apply as asc authorize batch begin by clustering columnfamily compact consistency count create custom delete desc distinct drop each_quorum exists filtering from grant if in index insert into key keyspace keyspaces level limit local_one local_quorum modify nan norecursive nosuperuser not of on one order password permission permissions primary quorum rename revoke schema select set storage superuser table three to token truncate ttl two type unlogged update use user users using values where with writetime"),
+ builtin: set("ascii bigint blob boolean counter decimal double float frozen inet int list map static text timestamp timeuuid tuple uuid varchar varint"),
+ atoms: set("false true infinity NaN"),
operatorChars: /^[<>=]/,
dateSQL: { },
support: set("commentSlashSlash decimallessFloat"),
@@ -345,14 +359,14 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
});
}());
+});
+
/*
How Properties of Mime Types are used by SQL Mode
=================================================
keywords:
A list of keywords you want to be highlighted.
- functions:
- A list of function names you want to be highlighted.
builtin:
A list of builtin types you want to be highlighted (if you want types to be of class "builtin" instead of "keyword").
operatorChars:
diff --git a/data/ext/editorText/codemirror/mode/stex/index.html b/data/ext/editorText/codemirror/mode/stex/index.html
index 28b8f64be..14679da4f 100644
--- a/data/ext/editorText/codemirror/mode/stex/index.html
+++ b/data/ext/editorText/codemirror/mode/stex/index.html
@@ -9,12 +9,12 @@
<script src="stex.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/stex/stex.js b/data/ext/editorText/codemirror/mode/stex/stex.js
index ca04c24f2..835ed46d1 100644
--- a/data/ext/editorText/codemirror/mode/stex/stex.js
+++ b/data/ext/editorText/codemirror/mode/stex/stex.js
@@ -1,60 +1,73 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/*
* Author: Constantin Jucovschi ([email protected])
* Licence: MIT
*/
-CodeMirror.defineMode("stex", function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineMode("stex", function() {
"use strict";
function pushCommand(state, command) {
- state.cmdState.push(command);
+ state.cmdState.push(command);
}
function peekCommand(state) {
- if (state.cmdState.length > 0) {
- return state.cmdState[state.cmdState.length - 1];
- } else {
- return null;
- }
+ if (state.cmdState.length > 0) {
+ return state.cmdState[state.cmdState.length - 1];
+ } else {
+ return null;
+ }
}
function popCommand(state) {
- var plug = state.cmdState.pop();
- if (plug) {
- plug.closeBracket();
- }
+ var plug = state.cmdState.pop();
+ if (plug) {
+ plug.closeBracket();
+ }
}
// returns the non-default plugin closest to the end of the list
function getMostPowerful(state) {
- var context = state.cmdState;
- for (var i = context.length - 1; i >= 0; i--) {
- var plug = context[i];
- if (plug.name == "DEFAULT") {
- continue;
- }
- return plug;
- }
- return { styleIdentifier: function() { return null; } };
+ var context = state.cmdState;
+ for (var i = context.length - 1; i >= 0; i--) {
+ var plug = context[i];
+ if (plug.name == "DEFAULT") {
+ continue;
+ }
+ return plug;
+ }
+ return { styleIdentifier: function() { return null; } };
}
function addPluginPattern(pluginName, cmdStyle, styles) {
- return function () {
- this.name = pluginName;
- this.bracketNo = 0;
- this.style = cmdStyle;
- this.styles = styles;
- this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin
-
- this.styleIdentifier = function() {
- return this.styles[this.bracketNo - 1] || null;
- };
- this.openBracket = function() {
- this.bracketNo++;
- return "bracket";
- };
- this.closeBracket = function() {};
+ return function () {
+ this.name = pluginName;
+ this.bracketNo = 0;
+ this.style = cmdStyle;
+ this.styles = styles;
+ this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin
+
+ this.styleIdentifier = function() {
+ return this.styles[this.bracketNo - 1] || null;
+ };
+ this.openBracket = function() {
+ this.bracketNo++;
+ return "bracket";
};
+ this.closeBracket = function() {};
+ };
}
var plugins = {};
@@ -66,181 +79,173 @@ CodeMirror.defineMode("stex", function() {
plugins["end"] = addPluginPattern("end", "tag", ["atom"]);
plugins["DEFAULT"] = function () {
- this.name = "DEFAULT";
- this.style = "tag";
+ this.name = "DEFAULT";
+ this.style = "tag";
- this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
+ this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
};
function setState(state, f) {
- state.f = f;
+ state.f = f;
}
// called when in a normal (no environment) context
function normal(source, state) {
- var plug;
- // Do we look like '\command' ? If so, attempt to apply the plugin 'command'
- if (source.match(/^\\[a-zA-Z@]+/)) {
- var cmdName = source.current().slice(1);
- plug = plugins[cmdName] || plugins["DEFAULT"];
- plug = new plug();
- pushCommand(state, plug);
- setState(state, beginParams);
- return plug.style;
- }
-
- // escape characters
- if (source.match(/^\\[$&%#{}_]/)) {
- return "tag";
- }
-
- // white space control characters
- if (source.match(/^\\[,;!\/\\]/)) {
- return "tag";
- }
-
- // find if we're starting various math modes
- if (source.match("\\[")) {
- setState(state, function(source, state){ return inMathMode(source, state, "\\]"); });
- return "keyword";
- }
- if (source.match("$$")) {
- setState(state, function(source, state){ return inMathMode(source, state, "$$"); });
- return "keyword";
- }
- if (source.match("$")) {
- setState(state, function(source, state){ return inMathMode(source, state, "$"); });
- return "keyword";
- }
-
- var ch = source.next();
- if (ch == "%") {
- // special case: % at end of its own line; stay in same state
- if (!source.eol()) {
- setState(state, inCComment);
- }
- return "comment";
- }
- else if (ch == '}' || ch == ']') {
- plug = peekCommand(state);
- if (plug) {
- plug.closeBracket(ch);
- setState(state, beginParams);
- } else {
- return "error";
- }
- return "bracket";
- } else if (ch == '{' || ch == '[') {
- plug = plugins["DEFAULT"];
- plug = new plug();
- pushCommand(state, plug);
- return "bracket";
- }
- else if (/\d/.test(ch)) {
- source.eatWhile(/[\w.%]/);
- return "atom";
- }
- else {
- source.eatWhile(/[\w\-_]/);
- plug = getMostPowerful(state);
- if (plug.name == 'begin') {
- plug.argument = source.current();
- }
- return plug.styleIdentifier();
- }
- }
-
- function inCComment(source, state) {
+ var plug;
+ // Do we look like '\command' ? If so, attempt to apply the plugin 'command'
+ if (source.match(/^\\[a-zA-Z@]+/)) {
+ var cmdName = source.current().slice(1);
+ plug = plugins[cmdName] || plugins["DEFAULT"];
+ plug = new plug();
+ pushCommand(state, plug);
+ setState(state, beginParams);
+ return plug.style;
+ }
+
+ // escape characters
+ if (source.match(/^\\[$&%#{}_]/)) {
+ return "tag";
+ }
+
+ // white space control characters
+ if (source.match(/^\\[,;!\/\\]/)) {
+ return "tag";
+ }
+
+ // find if we're starting various math modes
+ if (source.match("\\[")) {
+ setState(state, function(source, state){ return inMathMode(source, state, "\\]"); });
+ return "keyword";
+ }
+ if (source.match("$$")) {
+ setState(state, function(source, state){ return inMathMode(source, state, "$$"); });
+ return "keyword";
+ }
+ if (source.match("$")) {
+ setState(state, function(source, state){ return inMathMode(source, state, "$"); });
+ return "keyword";
+ }
+
+ var ch = source.next();
+ if (ch == "%") {
source.skipToEnd();
- setState(state, normal);
return "comment";
+ } else if (ch == '}' || ch == ']') {
+ plug = peekCommand(state);
+ if (plug) {
+ plug.closeBracket(ch);
+ setState(state, beginParams);
+ } else {
+ return "error";
+ }
+ return "bracket";
+ } else if (ch == '{' || ch == '[') {
+ plug = plugins["DEFAULT"];
+ plug = new plug();
+ pushCommand(state, plug);
+ return "bracket";
+ } else if (/\d/.test(ch)) {
+ source.eatWhile(/[\w.%]/);
+ return "atom";
+ } else {
+ source.eatWhile(/[\w\-_]/);
+ plug = getMostPowerful(state);
+ if (plug.name == 'begin') {
+ plug.argument = source.current();
+ }
+ return plug.styleIdentifier();
+ }
}
function inMathMode(source, state, endModeSeq) {
- if (source.eatSpace()) {
- return null;
- }
- if (source.match(endModeSeq)) {
- setState(state, normal);
- return "keyword";
- }
- if (source.match(/^\\[a-zA-Z@]+/)) {
- return "tag";
- }
- if (source.match(/^[a-zA-Z]+/)) {
- return "variable-2";
- }
- // escape characters
- if (source.match(/^\\[$&%#{}_]/)) {
- return "tag";
- }
- // white space control characters
- if (source.match(/^\\[,;!\/]/)) {
- return "tag";
- }
- // special math-mode characters
- if (source.match(/^[\^_&]/)) {
- return "tag";
- }
- // non-special characters
- if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) {
- return null;
- }
- if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) {
- return "number";
- }
- var ch = source.next();
- if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") {
- return "bracket";
- }
-
- // eat comments here, because inCComment returns us to normal state!
- if (ch == "%") {
- if (!source.eol()) {
- source.skipToEnd();
- }
- return "comment";
- }
- return "error";
+ if (source.eatSpace()) {
+ return null;
+ }
+ if (source.match(endModeSeq)) {
+ setState(state, normal);
+ return "keyword";
+ }
+ if (source.match(/^\\[a-zA-Z@]+/)) {
+ return "tag";
+ }
+ if (source.match(/^[a-zA-Z]+/)) {
+ return "variable-2";
+ }
+ // escape characters
+ if (source.match(/^\\[$&%#{}_]/)) {
+ return "tag";
+ }
+ // white space control characters
+ if (source.match(/^\\[,;!\/]/)) {
+ return "tag";
+ }
+ // special math-mode characters
+ if (source.match(/^[\^_&]/)) {
+ return "tag";
+ }
+ // non-special characters
+ if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) {
+ return null;
+ }
+ if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) {
+ return "number";
+ }
+ var ch = source.next();
+ if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") {
+ return "bracket";
+ }
+
+ if (ch == "%") {
+ source.skipToEnd();
+ return "comment";
+ }
+ return "error";
}
function beginParams(source, state) {
- var ch = source.peek(), lastPlug;
- if (ch == '{' || ch == '[') {
- lastPlug = peekCommand(state);
- lastPlug.openBracket(ch);
- source.eat(ch);
- setState(state, normal);
- return "bracket";
- }
- if (/[ \t\r]/.test(ch)) {
- source.eat(ch);
- return null;
- }
+ var ch = source.peek(), lastPlug;
+ if (ch == '{' || ch == '[') {
+ lastPlug = peekCommand(state);
+ lastPlug.openBracket(ch);
+ source.eat(ch);
setState(state, normal);
- popCommand(state);
-
- return normal(source, state);
+ return "bracket";
+ }
+ if (/[ \t\r]/.test(ch)) {
+ source.eat(ch);
+ return null;
+ }
+ setState(state, normal);
+ popCommand(state);
+
+ return normal(source, state);
}
return {
- startState: function() {
- return {
- cmdState: [],
- f: normal
- };
- },
- copyState: function(s) {
- return {
- cmdState: s.cmdState.slice(),
- f: s.f
- };
- },
- token: function(stream, state) {
- return state.f(stream, state);
- }
+ startState: function() {
+ return {
+ cmdState: [],
+ f: normal
+ };
+ },
+ copyState: function(s) {
+ return {
+ cmdState: s.cmdState.slice(),
+ f: s.f
+ };
+ },
+ token: function(stream, state) {
+ return state.f(stream, state);
+ },
+ blankLine: function(state) {
+ state.f = normal;
+ state.cmdState.length = 0;
+ },
+ lineComment: "%"
};
-});
+ });
+
+ CodeMirror.defineMIME("text/x-stex", "stex");
+ CodeMirror.defineMIME("text/x-latex", "stex");
-CodeMirror.defineMIME("text/x-stex", "stex");
-CodeMirror.defineMIME("text/x-latex", "stex");
+});
diff --git a/data/ext/editorText/codemirror/mode/stex/test.js b/data/ext/editorText/codemirror/mode/stex/test.js
index ab629e81e..22f027ec7 100644
--- a/data/ext/editorText/codemirror/mode/stex/test.js
+++ b/data/ext/editorText/codemirror/mode/stex/test.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "stex");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
diff --git a/data/ext/editorText/codemirror/mode/stylus/index.html b/data/ext/editorText/codemirror/mode/stylus/index.html
new file mode 100644
index 000000000..862c18f25
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/stylus/index.html
@@ -0,0 +1,106 @@
+<!doctype html>
+
+<title>CodeMirror: Stylus mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<link rel="stylesheet" href="../../addon/hint/show-hint.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="stylus.js"></script>
+<script src="../../addon/hint/show-hint.js"></script>
+<script src="../../addon/hint/css-hint.js"></script>
+<style>.CodeMirror {background: #f8f8f8;} form{margin-bottom: .7em;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Stylus</a>
+ </ul>
+</div>
+
+<article>
+<h2>Stylus mode</h2>
+<form><textarea id="code" name="code">
+/* Stylus mode */
+
+#id,
+.class,
+article
+ font-family Arial, sans-serif
+
+#id,
+.class,
+article {
+ font-family: Arial, sans-serif;
+}
+
+// Variables
+font-size-base = 16px
+line-height-base = 1.5
+font-family-base = "Helvetica Neue", Helvetica, Arial, sans-serif
+text-color = lighten(#000, 20%)
+
+body
+ font font-size-base/line-height-base font-family-base
+ color text-color
+
+body {
+ font: 400 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
+ color: #333;
+}
+
+// Variables
+link-color = darken(#428bca, 6.5%)
+link-hover-color = darken(link-color, 15%)
+link-decoration = none
+link-hover-decoration = false
+
+// Mixin
+tab-focus()
+ outline thin dotted
+ outline 5px auto -webkit-focus-ring-color
+ outline-offset -2px
+
+a
+ color link-color
+ if link-decoration
+ text-decoration link-decoration
+ &:hover
+ &:focus
+ color link-hover-color
+ if link-hover-decoration
+ text-decoration link-hover-decoration
+ &:focus
+ tab-focus()
+
+a {
+ color: #3782c4;
+ text-decoration: none;
+}
+a:hover,
+a:focus {
+ color: #2f6ea7;
+}
+a:focus {
+ outline: thin dotted;
+ outline: 5px auto -webkit-focus-ring-color;
+ outline-offset: -2px;
+}
+</textarea>
+</form>
+<script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ extraKeys: {"Ctrl-Space": "autocomplete"},
+ tabSize: 2
+ });
+</script>
+
+<p><strong>MIME types defined:</strong> <code>text/x-styl</code>.</p>
+<p>Created by <a href="https://github.com/dmitrykiselyov">Dmitry Kiselyov</a></p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/stylus/stylus.js b/data/ext/editorText/codemirror/mode/stylus/stylus.js
new file mode 100644
index 000000000..662cd03c0
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/stylus/stylus.js
@@ -0,0 +1,769 @@
+// 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"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineMode("stylus", function(config) {
+ 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", "comment"];
+ }
+ // Block comment
+ if (stream.match("/*")) {
+ state.tokenize = tokenCComment;
+ return tokenCComment(stream, state);
+ }
+ // String
+ if (ch == "\"" || ch == "'") {
+ stream.next();
+ state.tokenize = tokenString(ch);
+ return state.tokenize(stream, state);
+ }
+ // Def
+ if (ch == "@") {
+ stream.next();
+ stream.eatWhile(/[\w\\-]/);
+ return ["def", stream.current()];
+ }
+ // 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", "atom"];
+ }
+ // ID selector
+ if (stream.match(/^[a-z][\w-]*/i)) {
+ return ["builtin", "hash"];
+ }
+ }
+ // Vendor prefixes
+ if (stream.match(vendorPrefixesRegexp)) {
+ return ["meta", "vendor-prefixes"];
+ }
+ // Numbers
+ if (stream.match(/^-?[0-9]?\.?[0-9]/)) {
+ stream.eatWhile(/[a-z%]/i);
+ return ["number", "unit"];
+ }
+ // !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)) {
+ stream.backUp(1);
+ return ["keyword", "mixin"];
+ }
+ // Block mixins
+ if (stream.match(/^(\+|-)[a-z][\w-]*\(/i)) {
+ stream.backUp(1);
+ return ["keyword", "block-mixin"];
+ }
+ // 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"];
+ }
+ // Word operator
+ if (stream.match(wordOperatorKeywordsRegexp)) {
+ return ["operator", "operator"];
+ }
+ // Word
+ if (stream.match(/^\$?[-_]*[a-z0-9]+[\w-]*/i)) {
+ // Variable
+ if (stream.match(/^(\.|\[)[\w-\'\"\]]+/i, false)) {
+ if (!wordIsTag(stream.current())) {
+ stream.match(/\./);
+ return ["variable-2", "variable-name"];
+ }
+ }
+ return ["variable-2", "word"];
+ }
+ // Operators
+ if (stream.match(operatorsRegexp)) {
+ return ["operator", stream.current()];
+ }
+ // Delimiters
+ if (/[:;,{}\[\]\(\)]/.test(ch)) {
+ stream.next();
+ return [null, ch];
+ }
+ // Non-detected items
+ stream.next();
+ return [null, null];
+ }
+
+ /**
+ * 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"];
+ }
+
+ /**
+ * 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"];
+ };
+ }
+
+ /**
+ * Token parenthesized
+ */
+ function tokenParenthesized(stream, state) {
+ stream.next(); // Must be "("
+ if (!stream.match(/\s*[\"\')]/, false))
+ state.tokenize = tokenString(")");
+ else
+ state.tokenize = null;
+ return [null, "("];
+ }
+
+ /**
+ * Context management
+ */
+ function Context(type, indent, prev, line) {
+ this.type = type;
+ this.indent = indent;
+ this.prev = prev;
+ this.line = line || {firstWord: "", indent: 0};
+ }
+
+ function pushContext(state, stream, type, indent) {
+ indent = indent >= 0 ? indent : indentUnit;
+ state.context = new Context(type, stream.indentation() + indent, state.context);
+ return type;
+ }
+
+ 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;
+ }
+
+ function pass(type, stream, state) {
+ return states[state.context.type](type, stream, state);
+ }
+
+ function popAndPass(type, stream, state, n) {
+ for (var i = n || 1; i > 0; i--)
+ state.context = state.context.prev;
+ return pass(type, stream, state);
+ }
+
+
+ /**
+ * 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
+ else if (word.match(/^[A-Z]/)) override = "string";
+ return override;
+ }
+
+ function typeIsBlock(type, stream) {
+ return ((endOfLine(stream) && (type == "{" || type == "]" || type == "hash" || type == "qualifier")) || type == "block-mixin");
+ }
+
+ function typeIsInterpolation(type, stream) {
+ return type == "{" && stream.match(/^\s*\$?[\w-]+/i, false);
+ }
+
+ function typeIsPseudo(type, stream) {
+ return type == ":" && stream.match(/^[a-z-]+/, false);
+ }
+
+ 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*/, "") : "";
+ }
+
+
+ /**
+ * 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") {
+ if (stream.string.match(/^\s?\$[\w-\.\[\]\'\"]+$/) || wordIsBlock(firstWordOfLine(stream))) {
+ return pushContext(state, stream, "variableName");
+ }
+ else {
+ return pushContext(state, stream, "variableName", 0);
+ }
+ }
+ 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) == "@") {
+
+ // 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 (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 (override == "tag") {
+
+ // tag is a css value
+ if (/embed|menu|pre|progress|sub|table/.test(word)) {
+ if (wordIsProperty(firstWordOfLine(stream))) {
+ override = "atom";
+ return "block";
+ }
+ }
+
+ // tag is an attribute
+ if (stream.string.match(new RegExp("\\[\\s*" + word + "|" + word +"\\s*\\]"))) {
+ override = "atom";
+ return "block";
+ }
+
+ // 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";
+
+ // 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);
+
+ // Placeholder selector
+ if (override == "variable-2" && stream.string.match(/^\s?\$[\w-\.\[\]\'\"]+$/)) {
+ return pushContext(state, stream, "block");
+ }
+ }
+ return state.context.type;
+ };
+
+
+ /**
+ * 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;
+ };
+
+
+ /**
+ * Vendor prefixes
+ */
+ states.vendorPrefixes = function(type, stream, state) {
+ if (type == "word") {
+ override = "property";
+ return pushContext(state, stream, "block", 0);
+ }
+ return popContext(state);
+ };
+
+
+ /**
+ * 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);
+ };
+
+
+ /**
+ * 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;
+ };
+
+ 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");
+ }
+ 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);
+ };
+
+
+ /**
+ * 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;
+ };
+
+
+ /**
+ * 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;
+ };
+
+
+ /**
+ * 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);
+ };
+
+
+ /**
+ * 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";
+ return "variableName";
+ }
+ return popAndPass(type, stream, state);
+ };
+
+
+ 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"
+ };
+ });
+
+ // 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","row","row-reverse","wrap","wrap-reverse","column-reverse","flex-start","flex-end","space-between","space-around"];
+
+ 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;
+ return keys;
+ }
+
+ function escapeRegExp(text) {
+ return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+ }
+
+ CodeMirror.registerHelper("hintWords", "stylus", hintWords);
+ CodeMirror.defineMIME("text/x-styl", "stylus");
+});
diff --git a/data/ext/editorText/codemirror/mode/swift/index.html b/data/ext/editorText/codemirror/mode/swift/index.html
new file mode 100644
index 000000000..2649dc37c
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/swift/index.html
@@ -0,0 +1,88 @@
+<!doctype html>
+
+<title>CodeMirror: Swift mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/edit/matchbrackets.js"></script>
+<script src="./swift.js"></script>
+<style>
+ .CodeMirror { border: 2px inset #dee; }
+ </style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Swift</a>
+ </ul>
+</div>
+
+<article>
+<h2>Swift mode</h2>
+<form><textarea id="code" name="code">
+//
+// TipCalculatorModel.swift
+// TipCalculator
+//
+// Created by Main Account on 12/18/14.
+// Copyright (c) 2014 Razeware LLC. All rights reserved.
+//
+
+import Foundation
+
+class TipCalculatorModel {
+
+ var total: Double
+ var taxPct: Double
+ var subtotal: Double {
+ get {
+ return total / (taxPct + 1)
+ }
+ }
+
+ init(total: Double, taxPct: Double) {
+ self.total = total
+ self.taxPct = taxPct
+ }
+
+ func calcTipWithTipPct(tipPct: Double) -> Double {
+ return subtotal * tipPct
+ }
+
+ func returnPossibleTips() -> [Int: Double] {
+
+ let possibleTipsInferred = [0.15, 0.18, 0.20]
+ let possibleTipsExplicit:[Double] = [0.15, 0.18, 0.20]
+
+ var retval = [Int: Double]()
+ for possibleTip in possibleTipsInferred {
+ let intPct = Int(possibleTip*100)
+ retval[intPct] = calcTipWithTipPct(possibleTip)
+ }
+ return retval
+
+ }
+
+}
+</textarea></form>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-swift"
+ });
+ </script>
+
+ <p>A simple mode for Swift</p>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-swift</code> (Swift code)</p>
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/swift/swift.js b/data/ext/editorText/codemirror/mode/swift/swift.js
new file mode 100644
index 000000000..cf784feff
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/swift/swift.js
@@ -0,0 +1,203 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Swift mode created by Michael Kaminsky https://github.com/mkaminsky11
+
+(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"
+
+ function trim(str) { return /^\s*(.*?)\s*$/.exec(str)[1] }
+
+ var separators = [" ","\\\+","\\\-","\\\(","\\\)","\\\*","/",":","\\\?","\\\<","\\\>"," ","\\\."]
+ var tokens = new RegExp(separators.join("|"),"g")
+
+ function getWord(string, pos) {
+ var index = -1, count = 1
+ var words = string.split(tokens)
+ for (var i = 0; i < words.length; i++) {
+ for(var j = 1; j <= words[i].length; j++) {
+ if (count==pos) index = i
+ count++
+ }
+ count++
+ }
+ var ret = ["", ""]
+ if (pos == 0) {
+ ret[1] = words[0]
+ ret[0] = null
+ } else {
+ ret[1] = words[index]
+ ret[0] = words[index-1]
+ }
+ return ret
+ }
+
+ CodeMirror.defineMode("swift", function() {
+ var keywords=["var","let","class","deinit","enum","extension","func","import","init","let","protocol","static","struct","subscript","typealias","var","as","dynamicType","is","new","super","self","Self","Type","__COLUMN__","__FILE__","__FUNCTION__","__LINE__","break","case","continue","default","do","else","fallthrough","if","in","for","return","switch","where","while","associativity","didSet","get","infix","inout","left","mutating","none","nonmutating","operator","override","postfix","precedence","prefix","right","set","unowned","unowned(safe)","unowned(unsafe)","weak","willSet"]
+ var commonConstants=["Infinity","NaN","undefined","null","true","false","on","off","yes","no","nil","null","this","super"]
+ var types=["String","bool","int","string","double","Double","Int","Float","float","public","private","extension"]
+ var numbers=["0","1","2","3","4","5","6","7","8","9"]
+ var operators=["+","-","/","*","%","=","|","&","<",">"]
+ var punc=[";",",",".","(",")","{","}","[","]"]
+ var delimiters=/^(?:[()\[\]{},:`=;]|\.\.?\.?)/
+ var identifiers=/^[_A-Za-z$][_A-Za-z$0-9]*/
+ var properties=/^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*/
+ var regexPrefixes=/^(\/{3}|\/)/
+
+ return {
+ startState: function() {
+ return {
+ prev: false,
+ string: false,
+ escape: false,
+ inner: false,
+ comment: false,
+ num_left: 0,
+ num_right: 0,
+ doubleString: false,
+ singleString: false
+ }
+ },
+ token: function(stream, state) {
+ if (stream.eatSpace()) return null
+
+ var ch = stream.next()
+ if (state.string) {
+ if (state.escape) {
+ state.escape = false
+ return "string"
+ } else {
+ if ((ch == "\"" && (state.doubleString && !state.singleString) ||
+ (ch == "'" && (!state.doubleString && state.singleString))) &&
+ !state.escape) {
+ state.string = false
+ state.doubleString = false
+ state.singleString = false
+ return "string"
+ } else if (ch == "\\" && stream.peek() == "(") {
+ state.inner = true
+ state.string = false
+ return "keyword"
+ } else if (ch == "\\" && stream.peek() != "(") {
+ state.escape = true
+ state.string = true
+ return "string"
+ } else {
+ return "string"
+ }
+ }
+ } else if (state.comment) {
+ if (ch == "*" && stream.peek() == "/") {
+ state.prev = "*"
+ return "comment"
+ } else if (ch == "/" && state.prev == "*") {
+ state.prev = false
+ state.comment = false
+ return "comment"
+ }
+ return "comment"
+ } else {
+ if (ch == "/") {
+ if (stream.peek() == "/") {
+ stream.skipToEnd()
+ return "comment"
+ }
+ if (stream.peek() == "*") {
+ state.comment = true
+ return "comment"
+ }
+ }
+ if (ch == "(" && state.inner) {
+ state.num_left++
+ return null
+ }
+ if (ch == ")" && state.inner) {
+ state.num_right++
+ if (state.num_left == state.num_right) {
+ state.inner=false
+ state.string=true
+ }
+ return null
+ }
+
+ var ret = getWord(stream.string, stream.pos)
+ var the_word = ret[1]
+ var prev_word = ret[0]
+
+ if (operators.indexOf(ch + "") > -1) return "operator"
+ if (punc.indexOf(ch) > -1) return "punctuation"
+
+ if (typeof the_word != "undefined") {
+ the_word = trim(the_word)
+ if (typeof prev_word != "undefined") prev_word = trim(prev_word)
+ if (the_word.charAt(0) == "#") return null
+
+ if (types.indexOf(the_word) > -1) return "def"
+ if (commonConstants.indexOf(the_word) > -1) return "atom"
+ if (numbers.indexOf(the_word) > -1) return "number"
+
+ if ((numbers.indexOf(the_word.charAt(0) + "") > -1 ||
+ operators.indexOf(the_word.charAt(0) + "") > -1) &&
+ numbers.indexOf(ch) > -1) {
+ return "number"
+ }
+
+ if (keywords.indexOf(the_word) > -1 ||
+ keywords.indexOf(the_word.split(tokens)[0]) > -1)
+ return "keyword"
+ if (keywords.indexOf(prev_word) > -1) return "def"
+ }
+ if (ch == '"' && !state.doubleString) {
+ state.string = true
+ state.doubleString = true
+ return "string"
+ }
+ if (ch == "'" && !state.singleString) {
+ state.string = true
+ state.singleString = true
+ return "string"
+ }
+ if (ch == "(" && state.inner)
+ state.num_left++
+ if (ch == ")" && state.inner) {
+ state.num_right++
+ if (state.num_left == state.num_right) {
+ state.inner = false
+ state.string = true
+ }
+ return null
+ }
+ if (stream.match(/^-?[0-9\.]/, false)) {
+ if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i) ||
+ stream.match(/^-?\d+\.\d*/) ||
+ stream.match(/^-?\.\d+/)) {
+ if (stream.peek() == ".") stream.backUp(1)
+ return "number"
+ }
+ if (stream.match(/^-?0x[0-9a-f]+/i) ||
+ stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/) ||
+ stream.match(/^-?0(?![\dx])/i))
+ return "number"
+ }
+ if (stream.match(regexPrefixes)) {
+ if (stream.current()!="/" || stream.match(/^.*\//,false)) return "string"
+ else stream.backUp(1)
+ }
+ if (stream.match(delimiters)) return "punctuation"
+ if (stream.match(identifiers)) return "variable"
+ if (stream.match(properties)) return "property"
+ return "variable"
+ }
+ }
+ }
+ })
+
+ CodeMirror.defineMIME("text/x-swift","swift")
+})
diff --git a/data/ext/editorText/codemirror/mode/tcl/index.html b/data/ext/editorText/codemirror/mode/tcl/index.html
index c48e25324..ce4ad3423 100644
--- a/data/ext/editorText/codemirror/mode/tcl/index.html
+++ b/data/ext/editorText/codemirror/mode/tcl/index.html
@@ -10,12 +10,12 @@
<script src="tcl.js"></script>
<script src="../../addon/scroll/scrollpastend.js"></script>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/tcl/tcl.js b/data/ext/editorText/codemirror/mode/tcl/tcl.js
index ed2c69721..056accb2d 100644
--- a/data/ext/editorText/codemirror/mode/tcl/tcl.js
+++ b/data/ext/editorText/codemirror/mode/tcl/tcl.js
@@ -1,4 +1,18 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
//tcl mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("tcl", function() {
function parseWords(str) {
var obj = {}, words = str.split(" ");
@@ -64,7 +78,7 @@ CodeMirror.defineMode("tcl", function() {
return "comment";
}
else {
- stream.eatWhile(/[\w\$_{}]/);
+ stream.eatWhile(/[\w\$_{}\xa1-\uffff]/);
var word = stream.current().toLowerCase();
if (keywords && keywords.propertyIsEnumerable(word))
return "keyword";
@@ -129,3 +143,5 @@ CodeMirror.defineMode("tcl", function() {
};
});
CodeMirror.defineMIME("text/x-tcl", "tcl");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/textile/index.html b/data/ext/editorText/codemirror/mode/textile/index.html
new file mode 100644
index 000000000..42b156b1e
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/textile/index.html
@@ -0,0 +1,191 @@
+<!doctype html>
+
+<title>CodeMirror: Textile mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="textile.js"></script>
+<style>.CodeMirror {background: #f8f8f8;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class="active" href="#">Textile</a>
+ </ul>
+</div>
+
+<article>
+ <h2>Textile mode</h2>
+ <form><textarea id="code" name="code">
+h1. Textile Mode
+
+A paragraph without formatting.
+
+p. A simple Paragraph.
+
+
+h2. Phrase Modifiers
+
+Here are some simple phrase modifiers: *strong*, _emphasis_, **bold**, and __italic__.
+
+A ??citation??, -deleted text-, +inserted text+, some ^superscript^, and some ~subscript~.
+
+A %span element% and @code element@
+
+A "link":http://example.com, a "link with (alt text)":urlAlias
+
+[urlAlias]http://example.com/
+
+An image: !http://example.com/image.png! and an image with a link: !http://example.com/image.png!:http://example.com
+
+A sentence with a footnote.[123]
+
+fn123. The footnote is defined here.
+
+Registered(r), Trademark(tm), and Copyright(c)
+
+
+h2. Headers
+
+h1. Top level
+h2. Second level
+h3. Third level
+h4. Fourth level
+h5. Fifth level
+h6. Lowest level
+
+
+h2. Lists
+
+* An unordered list
+** foo bar
+*** foo bar
+**** foo bar
+** foo bar
+
+# An ordered list
+## foo bar
+### foo bar
+#### foo bar
+## foo bar
+
+- definition list := description
+- another item := foo bar
+- spanning ines :=
+ foo bar
+
+ foo bar =:
+
+
+h2. Attributes
+
+Layouts and phrase modifiers can be modified with various kinds of attributes: alignment, CSS ID, CSS class names, language, padding, and CSS styles.
+
+h3. Alignment
+
+div<. left align
+div>. right align
+
+h3. CSS ID and class name
+
+You are a %(my-id#my-classname) rad% person.
+
+h3. Language
+
+p[en_CA]. Strange weather, eh?
+
+h3. Horizontal Padding
+
+p(())). 2em left padding, 3em right padding
+
+h3. CSS styling
+
+p{background: red}. Fire!
+
+
+h2. Table
+
+|_. Header 1 |_. Header 2 |
+|{background:#ddd}. Cell with background| Normal |
+|\2. Cell spanning 2 columns |
+|/2. Cell spanning 2 rows |(cell-class). one |
+| two |
+|>. Right aligned cell |<. Left aligned cell |
+
+
+h3. A table with attributes:
+
+table(#prices).
+|Adults|$5|
+|Children|$2|
+
+
+h2. Code blocks
+
+bc.
+function factorial(n) {
+ if (n === 0) {
+ return 1;
+ }
+ return n * factorial(n - 1);
+}
+
+pre..
+ ,,,,,,
+ o#'9MMHb':'-,o,
+ .oH":HH$' "' ' -*R&o,
+ dMMM*""'`' .oM"HM?.
+ ,MMM' "HLbd< ?&H\
+ .:MH ."\ ` MM MM&b
+ . "*H - &MMMMMMMMMH:
+ . dboo MMMMMMMMMMMM.
+ . dMMMMMMb *MMMMMMMMMP.
+ . MMMMMMMP *MMMMMP .
+ `#MMMMM MM6P ,
+ ' `MMMP" HM*`,
+ ' :MM .- ,
+ '. `#?.. . ..'
+ -. . .-
+ ''-.oo,oo.-''
+
+\. _(9>
+ \==_)
+ -'=
+
+h2. Temporarily disabling textile markup
+
+notextile. Don't __touch this!__
+
+Surround text with double-equals to disable textile inline. Example: Use ==*asterisks*== for *strong* text.
+
+
+h2. HTML
+
+Some block layouts are simply textile versions of HTML tags with the same name, like @div@, @pre@, and @p@. HTML tags can also exist on their own line:
+
+<section>
+ <h1>Title</h1>
+ <p>Hello!</p>
+</section>
+
+</textarea></form>
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "text/x-textile"
+ });
+ </script>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-textile</code>.</p>
+
+ <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#textile_*">normal</a>, <a href="../../test/index.html#verbose,textile_*">verbose</a>.</p>
+
+</article>
diff --git a/data/ext/editorText/codemirror/mode/textile/test.js b/data/ext/editorText/codemirror/mode/textile/test.js
new file mode 100644
index 000000000..49cdaf9c9
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/textile/test.js
@@ -0,0 +1,417 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function() {
+ var mode = CodeMirror.getMode({tabSize: 4}, 'textile');
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
+
+ MT('simpleParagraphs',
+ 'Some text.',
+ '',
+ 'Some more text.');
+
+ /*
+ * Phrase Modifiers
+ */
+
+ MT('em',
+ 'foo [em _bar_]');
+
+ MT('emBoogus',
+ 'code_mirror');
+
+ MT('strong',
+ 'foo [strong *bar*]');
+
+ MT('strongBogus',
+ '3 * 3 = 9');
+
+ MT('italic',
+ 'foo [em __bar__]');
+
+ MT('italicBogus',
+ 'code__mirror');
+
+ MT('bold',
+ 'foo [strong **bar**]');
+
+ MT('boldBogus',
+ '3 ** 3 = 27');
+
+ MT('simpleLink',
+ '[link "CodeMirror":http://codemirror.net]');
+
+ MT('referenceLink',
+ '[link "CodeMirror":code_mirror]',
+ 'Normal Text.',
+ '[link [[code_mirror]]http://codemirror.net]');
+
+ MT('footCite',
+ 'foo bar[qualifier [[1]]]');
+
+ MT('footCiteBogus',
+ 'foo bar[[1a2]]');
+
+ MT('special-characters',
+ 'Registered [tag (r)], ' +
+ 'Trademark [tag (tm)], and ' +
+ 'Copyright [tag (c)] 2008');
+
+ MT('cite',
+ "A book is [keyword ??The Count of Monte Cristo??] by Dumas.");
+
+ MT('additionAndDeletion',
+ 'The news networks declared [negative -Al Gore-] ' +
+ '[positive +George W. Bush+] the winner in Florida.');
+
+ MT('subAndSup',
+ 'f(x, n) = log [builtin ~4~] x [builtin ^n^]');
+
+ MT('spanAndCode',
+ 'A [quote %span element%] and [atom @code element@]');
+
+ MT('spanBogus',
+ 'Percentage 25% is not a span.');
+
+ MT('citeBogus',
+ 'Question? is not a citation.');
+
+ MT('codeBogus',
+
+ MT('subBogus',
+ '~username');
+
+ MT('supBogus',
+ 'foo ^ bar');
+
+ MT('deletionBogus',
+ '3 - 3 = 0');
+
+ MT('additionBogus',
+ '3 + 3 = 6');
+
+ MT('image',
+ 'An image: [string !http://www.example.com/image.png!]');
+
+ MT('imageWithAltText',
+ 'An image: [string !http://www.example.com/image.png (Alt Text)!]');
+
+ MT('imageWithUrl',
+ 'An image: [string !http://www.example.com/image.png!:http://www.example.com/]');
+
+ /*
+ * Headers
+ */
+
+ MT('h1',
+ '[header&header-1 h1. foo]');
+
+ MT('h2',
+ '[header&header-2 h2. foo]');
+
+ MT('h3',
+ '[header&header-3 h3. foo]');
+
+ MT('h4',
+ '[header&header-4 h4. foo]');
+
+ MT('h5',
+ '[header&header-5 h5. foo]');
+
+ MT('h6',
+ '[header&header-6 h6. foo]');
+
+ MT('h7Bogus',
+ 'h7. foo');
+
+ MT('multipleHeaders',
+ '[header&header-1 h1. Heading 1]',
+ '',
+ 'Some text.',
+ '',
+ '[header&header-2 h2. Heading 2]',
+ '',
+ 'More text.');
+
+ MT('h1inline',
+ '[header&header-1 h1. foo ][header&header-1&em _bar_][header&header-1 baz]');
+
+ /*
+ * Lists
+ */
+
+ MT('ul',
+ 'foo',
+ 'bar',
+ '',
+ '[variable-2 * foo]',
+ '[variable-2 * bar]');
+
+ MT('ulNoBlank',
+ 'foo',
+ 'bar',
+ '[variable-2 * foo]',
+ '[variable-2 * bar]');
+
+ MT('ol',
+ 'foo',
+ 'bar',
+ '',
+ '[variable-2 # foo]',
+ '[variable-2 # bar]');
+
+ MT('olNoBlank',
+ 'foo',
+ 'bar',
+ '[variable-2 # foo]',
+ '[variable-2 # bar]');
+
+ MT('ulFormatting',
+ '[variable-2 * ][variable-2&em _foo_][variable-2 bar]',
+ '[variable-2 * ][variable-2&strong *][variable-2&em&strong _foo_]' +
+ '[variable-2&strong *][variable-2 bar]',
+ '[variable-2 * ][variable-2&strong *foo*][variable-2 bar]');
+
+ MT('olFormatting',
+ '[variable-2 # ][variable-2&em _foo_][variable-2 bar]',
+ '[variable-2 # ][variable-2&strong *][variable-2&em&strong _foo_]' +
+ '[variable-2&strong *][variable-2 bar]',
+ '[variable-2 # ][variable-2&strong *foo*][variable-2 bar]');
+
+ MT('ulNested',
+ '[variable-2 * foo]',
+ '[variable-3 ** bar]',
+ '[keyword *** bar]',
+ '[variable-2 **** bar]',
+ '[variable-3 ** bar]');
+
+ MT('olNested',
+ '[variable-2 # foo]',
+ '[variable-3 ## bar]',
+ '[keyword ### bar]',
+ '[variable-2 #### bar]',
+ '[variable-3 ## bar]');
+
+ MT('ulNestedWithOl',
+ '[variable-2 * foo]',
+ '[variable-3 ## bar]',
+ '[keyword *** bar]',
+ '[variable-2 #### bar]',
+ '[variable-3 ** bar]');
+
+ MT('olNestedWithUl',
+ '[variable-2 # foo]',
+ '[variable-3 ** bar]',
+ '[keyword ### bar]',
+ '[variable-2 **** bar]',
+ '[variable-3 ## bar]');
+
+ MT('definitionList',
+ '[number - coffee := Hot ][number&em _and_][number black]',
+ '',
+ 'Normal text.');
+
+ MT('definitionListSpan',
+ '[number - coffee :=]',
+ '',
+ '[number Hot ][number&em _and_][number black =:]',
+ '',
+ 'Normal text.');
+
+ MT('boo',
+ '[number - dog := woof woof]',
+ '[number - cat := meow meow]',
+ '[number - whale :=]',
+ '[number Whale noises.]',
+ '',
+ '[number Also, ][number&em _splashing_][number . =:]');
+
+ /*
+ * Attributes
+ */
+
+ MT('divWithAttribute',
+ '[punctuation div][punctuation&attribute (#my-id)][punctuation . foo bar]');
+
+ MT('divWithAttributeAnd2emRightPadding',
+ '[punctuation div][punctuation&attribute (#my-id)((][punctuation . foo bar]');
+
+ MT('divWithClassAndId',
+ '[punctuation div][punctuation&attribute (my-class#my-id)][punctuation . foo bar]');
+
+ MT('paragraphWithCss',
+ 'p[attribute {color:red;}]. foo bar');
+
+ MT('paragraphNestedStyles',
+ 'p. [strong *foo ][strong&em _bar_][strong *]');
+
+ MT('paragraphWithLanguage',
+ 'p[attribute [[fr]]]. Parlez-vous français?');
+
+ MT('paragraphLeftAlign',
+ 'p[attribute <]. Left');
+
+ MT('paragraphRightAlign',
+ 'p[attribute >]. Right');
+
+ MT('paragraphRightAlign',
+ 'p[attribute =]. Center');
+
+ MT('paragraphJustified',
+ 'p[attribute <>]. Justified');
+
+ MT('paragraphWithLeftIndent1em',
+ 'p[attribute (]. Left');
+
+ MT('paragraphWithRightIndent1em',
+ 'p[attribute )]. Right');
+
+ MT('paragraphWithLeftIndent2em',
+ 'p[attribute ((]. Left');
+
+ MT('paragraphWithRightIndent2em',
+ 'p[attribute ))]. Right');
+
+ MT('paragraphWithLeftIndent3emRightIndent2em',
+ 'p[attribute ((())]. Right');
+
+ MT('divFormatting',
+ '[punctuation div. ][punctuation&strong *foo ]' +
+ '[punctuation&strong&em _bar_][punctuation&strong *]');
+
+ MT('phraseModifierAttributes',
+ 'p[attribute (my-class)]. This is a paragraph that has a class and' +
+ ' this [em _][em&attribute (#special-phrase)][em emphasized phrase_]' +
+ ' has an id.');
+
+ MT('linkWithClass',
+ '[link "(my-class). This is a link with class":http://redcloth.org]');
+
+ /*
+ * Layouts
+ */
+
+ MT('paragraphLayouts',
+ 'p. This is one paragraph.',
+ '',
+ 'p. This is another.');
+
+ MT('div',
+ '[punctuation div. foo bar]');
+
+ MT('pre',
+ '[operator pre. Text]');
+
+ MT('bq.',
+ '[bracket bq. foo bar]',
+ '',
+ 'Normal text.');
+
+ MT('footnote',
+ '[variable fn123. foo ][variable&strong *bar*]');
+
+ /*
+ * Spanning Layouts
+ */
+
+ MT('bq..ThenParagraph',
+ '[bracket bq.. foo bar]',
+ '',
+ '[bracket More quote.]',
+ 'p. Normal Text');
+
+ MT('bq..ThenH1',
+ '[bracket bq.. foo bar]',
+ '',
+ '[bracket More quote.]',
+ '[header&header-1 h1. Header Text]');
+
+ MT('bc..ThenParagraph',
+ '[atom bc.. # Some ruby code]',
+ '[atom obj = {foo: :bar}]',
+ '[atom puts obj]',
+ '',
+ '[atom obj[[:love]] = "*love*"]',
+ '[atom puts obj.love.upcase]',
+ '',
+ 'p. Normal text.');
+
+ MT('fn1..ThenParagraph',
+ '[variable fn1.. foo bar]',
+ '',
+ '[variable More.]',
+ 'p. Normal Text');
+
+ MT('pre..ThenParagraph',
+ '[operator pre.. foo bar]',
+ '',
+ '[operator More.]',
+ 'p. Normal Text');
+
+ /*
+ * Tables
+ */
+
+ MT('table',
+ '[variable-3&operator |_. name |_. age|]',
+ '[variable-3 |][variable-3&strong *Walter*][variable-3 | 5 |]',
+ '[variable-3 |Florence| 6 |]',
+ '',
+ 'p. Normal text.');
+
+ MT('tableWithAttributes',
+ '[variable-3&operator |_. name |_. age|]',
+ '[variable-3 |][variable-3&attribute /2.][variable-3 Jim |]',
+ '[variable-3 |][variable-3&attribute \\2{color: red}.][variable-3 Sam |]');
+
+ /*
+ * HTML
+ */
+
+ MT('html',
+ '[comment <div id="wrapper">]',
+ '[comment <section id="introduction">]',
+ '',
+ '[header&header-1 h1. Welcome]',
+ '',
+ '[variable-2 * Item one]',
+ '[variable-2 * Item two]',
+ '',
+ '[comment <a href="http://example.com">Example</a>]',
+ '',
+ '[comment </section>]',
+ '[comment </div>]');
+
+ MT('inlineHtml',
+ 'I can use HTML directly in my [comment <span class="youbetcha">Textile</span>].');
+
+ /*
+ * No-Textile
+ */
+
+ MT('notextile',
+ '[string-2 notextile. *No* formatting]');
+
+ MT('notextileInline',
+ 'Use [string-2 ==*asterisks*==] for [strong *strong*] text.');
+
+ MT('notextileWithPre',
+ '[operator pre. *No* formatting]');
+
+ MT('notextileWithSpanningPre',
+ '[operator pre.. *No* formatting]',
+ '',
+ '[operator *No* formatting]');
+
+ /* Only toggling phrases between non-word chars. */
+
+ MT('phrase-in-word',
+ 'foo_bar_baz');
+
+ MT('phrase-non-word',
+ '[negative -x-] aaa-bbb ccc-ddd [negative -eee-] fff [negative -ggg-]');
+
+ MT('phrase-lone-dash',
+ 'foo - bar - baz');
+})();
diff --git a/data/ext/editorText/codemirror/mode/textile/textile.js b/data/ext/editorText/codemirror/mode/textile/textile.js
new file mode 100644
index 000000000..a6f757658
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/textile/textile.js
@@ -0,0 +1,469 @@
+// 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";
+
+ var TOKEN_STYLES = {
+ addition: "positive",
+ attributes: "attribute",
+ bold: "strong",
+ cite: "keyword",
+ code: "atom",
+ definitionList: "number",
+ deletion: "negative",
+ div: "punctuation",
+ em: "em",
+ footnote: "variable",
+ footCite: "qualifier",
+ header: "header",
+ html: "comment",
+ image: "string",
+ italic: "em",
+ link: "link",
+ linkDefinition: "link",
+ list1: "variable-2",
+ list2: "variable-3",
+ list3: "keyword",
+ notextile: "string-2",
+ pre: "operator",
+ p: "property",
+ quote: "bracket",
+ span: "quote",
+ specialChar: "tag",
+ strong: "strong",
+ sub: "builtin",
+ sup: "builtin",
+ table: "variable-3",
+ tableHeading: "operator"
+ };
+
+ function startNewLine(stream, state) {
+ state.mode = Modes.newLayout;
+ state.tableHeading = false;
+
+ if (state.layoutType === "definitionList" && state.spanningLayout &&
+ stream.match(RE("definitionListEnd"), false))
+ state.spanningLayout = false;
+ }
+
+ function handlePhraseModifier(stream, state, ch) {
+ if (ch === "_") {
+ if (stream.eat("_"))
+ return togglePhraseModifier(stream, state, "italic", /__/, 2);
+ else
+ return togglePhraseModifier(stream, state, "em", /_/, 1);
+ }
+
+ if (ch === "*") {
+ if (stream.eat("*")) {
+ return togglePhraseModifier(stream, state, "bold", /\*\*/, 2);
+ }
+ return togglePhraseModifier(stream, state, "strong", /\*/, 1);
+ }
+
+ if (ch === "[") {
+ if (stream.match(/\d+\]/)) state.footCite = true;
+ return tokenStyles(state);
+ }
+
+ if (ch === "(") {
+ var spec = stream.match(/^(r|tm|c)\)/);
+ if (spec)
+ return tokenStylesWith(state, TOKEN_STYLES.specialChar);
+ }
+
+ if (ch === "<" && stream.match(/(\w+)[^>]+>[^<]+<\/\1>/))
+ return tokenStylesWith(state, TOKEN_STYLES.html);
+
+ if (ch === "?" && stream.eat("?"))
+ return togglePhraseModifier(stream, state, "cite", /\?\?/, 2);
+
+ if (ch === "=" && stream.eat("="))
+ return togglePhraseModifier(stream, state, "notextile", /==/, 2);
+
+ if (ch === "-" && !stream.eat("-"))
+ return togglePhraseModifier(stream, state, "deletion", /-/, 1);
+
+ if (ch === "+")
+ return togglePhraseModifier(stream, state, "addition", /\+/, 1);
+
+ if (ch === "~")
+ return togglePhraseModifier(stream, state, "sub", /~/, 1);
+
+ if (ch === "^")
+ return togglePhraseModifier(stream, state, "sup", /\^/, 1);
+
+ if (ch === "%")
+ return togglePhraseModifier(stream, state, "span", /%/, 1);
+
+ if (ch === "@")
+ return togglePhraseModifier(stream, state, "code", /@/, 1);
+
+ if (ch === "!") {
+ var type = togglePhraseModifier(stream, state, "image", /(?:\([^\)]+\))?!/, 1);
+ stream.match(/^:\S+/); // optional Url portion
+ return type;
+ }
+ return tokenStyles(state);
+ }
+
+ function togglePhraseModifier(stream, state, phraseModifier, closeRE, openSize) {
+ var charBefore = stream.pos > openSize ? stream.string.charAt(stream.pos - openSize - 1) : null;
+ var charAfter = stream.peek();
+ if (state[phraseModifier]) {
+ if ((!charAfter || /\W/.test(charAfter)) && charBefore && /\S/.test(charBefore)) {
+ var type = tokenStyles(state);
+ state[phraseModifier] = false;
+ return type;
+ }
+ } else if ((!charBefore || /\W/.test(charBefore)) && charAfter && /\S/.test(charAfter) &&
+ stream.match(new RegExp("^.*\\S" + closeRE.source + "(?:\\W|$)"), false)) {
+ state[phraseModifier] = true;
+ state.mode = Modes.attributes;
+ }
+ return tokenStyles(state);
+ };
+
+ function tokenStyles(state) {
+ var disabled = textileDisabled(state);
+ if (disabled) return disabled;
+
+ var styles = [];
+ if (state.layoutType) styles.push(TOKEN_STYLES[state.layoutType]);
+
+ styles = styles.concat(activeStyles(
+ state, "addition", "bold", "cite", "code", "deletion", "em", "footCite",
+ "image", "italic", "link", "span", "strong", "sub", "sup", "table", "tableHeading"));
+
+ if (state.layoutType === "header")
+ styles.push(TOKEN_STYLES.header + "-" + state.header);
+
+ return styles.length ? styles.join(" ") : null;
+ }
+
+ function textileDisabled(state) {
+ var type = state.layoutType;
+
+ switch(type) {
+ case "notextile":
+ case "code":
+ case "pre":
+ return TOKEN_STYLES[type];
+ default:
+ if (state.notextile)
+ return TOKEN_STYLES.notextile + (type ? (" " + TOKEN_STYLES[type]) : "");
+ return null;
+ }
+ }
+
+ function tokenStylesWith(state, extraStyles) {
+ var disabled = textileDisabled(state);
+ if (disabled) return disabled;
+
+ var type = tokenStyles(state);
+ if (extraStyles)
+ return type ? (type + " " + extraStyles) : extraStyles;
+ else
+ return type;
+ }
+
+ function activeStyles(state) {
+ var styles = [];
+ for (var i = 1; i < arguments.length; ++i) {
+ if (state[arguments[i]])
+ styles.push(TOKEN_STYLES[arguments[i]]);
+ }
+ return styles;
+ }
+
+ function blankLine(state) {
+ var spanningLayout = state.spanningLayout, type = state.layoutType;
+
+ for (var key in state) if (state.hasOwnProperty(key))
+ delete state[key];
+
+ state.mode = Modes.newLayout;
+ if (spanningLayout) {
+ state.layoutType = type;
+ state.spanningLayout = true;
+ }
+ }
+
+ var REs = {
+ cache: {},
+ single: {
+ bc: "bc",
+ bq: "bq",
+ definitionList: /- [^(?::=)]+:=+/,
+ definitionListEnd: /.*=:\s*$/,
+ div: "div",
+ drawTable: /\|.*\|/,
+ foot: /fn\d+/,
+ header: /h[1-6]/,
+ html: /\s*<(?:\/)?(\w+)(?:[^>]+)?>(?:[^<]+<\/\1>)?/,
+ link: /[^"]+":\S/,
+ linkDefinition: /\[[^\s\]]+\]\S+/,
+ list: /(?:#+|\*+)/,
+ notextile: "notextile",
+ para: "p",
+ pre: "pre",
+ table: "table",
+ tableCellAttributes: /[\/\\]\d+/,
+ tableHeading: /\|_\./,
+ tableText: /[^"_\*\[\(\?\+~\^%@|-]+/,
+ text: /[^!"_=\*\[\(<\?\+~\^%@-]+/
+ },
+ attributes: {
+ align: /(?:<>|<|>|=)/,
+ selector: /\([^\(][^\)]+\)/,
+ lang: /\[[^\[\]]+\]/,
+ pad: /(?:\(+|\)+){1,2}/,
+ css: /\{[^\}]+\}/
+ },
+ createRe: function(name) {
+ switch (name) {
+ case "drawTable":
+ return REs.makeRe("^", REs.single.drawTable, "$");
+ case "html":
+ return REs.makeRe("^", REs.single.html, "(?:", REs.single.html, ")*", "$");
+ case "linkDefinition":
+ return REs.makeRe("^", REs.single.linkDefinition, "$");
+ case "listLayout":
+ return REs.makeRe("^", REs.single.list, RE("allAttributes"), "*\\s+");
+ case "tableCellAttributes":
+ return REs.makeRe("^", REs.choiceRe(REs.single.tableCellAttributes,
+ RE("allAttributes")), "+\\.");
+ case "type":
+ return REs.makeRe("^", RE("allTypes"));
+ case "typeLayout":
+ return REs.makeRe("^", RE("allTypes"), RE("allAttributes"),
+ "*\\.\\.?", "(\\s+|$)");
+ case "attributes":
+ return REs.makeRe("^", RE("allAttributes"), "+");
+
+ case "allTypes":
+ return REs.choiceRe(REs.single.div, REs.single.foot,
+ REs.single.header, REs.single.bc, REs.single.bq,
+ REs.single.notextile, REs.single.pre, REs.single.table,
+ REs.single.para);
+
+ case "allAttributes":
+ return REs.choiceRe(REs.attributes.selector, REs.attributes.css,
+ REs.attributes.lang, REs.attributes.align, REs.attributes.pad);
+
+ default:
+ return REs.makeRe("^", REs.single[name]);
+ }
+ },
+ makeRe: function() {
+ var pattern = "";
+ for (var i = 0; i < arguments.length; ++i) {
+ var arg = arguments[i];
+ pattern += (typeof arg === "string") ? arg : arg.source;
+ }
+ return new RegExp(pattern);
+ },
+ choiceRe: function() {
+ var parts = [arguments[0]];
+ for (var i = 1; i < arguments.length; ++i) {
+ parts[i * 2 - 1] = "|";
+ parts[i * 2] = arguments[i];
+ }
+
+ parts.unshift("(?:");
+ parts.push(")");
+ return REs.makeRe.apply(null, parts);
+ }
+ };
+
+ function RE(name) {
+ return (REs.cache[name] || (REs.cache[name] = REs.createRe(name)));
+ }
+
+ var Modes = {
+ newLayout: function(stream, state) {
+ if (stream.match(RE("typeLayout"), false)) {
+ state.spanningLayout = false;
+ return (state.mode = Modes.blockType)(stream, state);
+ }
+ var newMode;
+ if (!textileDisabled(state)) {
+ if (stream.match(RE("listLayout"), false))
+ newMode = Modes.list;
+ else if (stream.match(RE("drawTable"), false))
+ newMode = Modes.table;
+ else if (stream.match(RE("linkDefinition"), false))
+ newMode = Modes.linkDefinition;
+ else if (stream.match(RE("definitionList")))
+ newMode = Modes.definitionList;
+ else if (stream.match(RE("html"), false))
+ newMode = Modes.html;
+ }
+ return (state.mode = (newMode || Modes.text))(stream, state);
+ },
+
+ blockType: function(stream, state) {
+ var match, type;
+ state.layoutType = null;
+
+ if (match = stream.match(RE("type")))
+ type = match[0];
+ else
+ return (state.mode = Modes.text)(stream, state);
+
+ if (match = type.match(RE("header"))) {
+ state.layoutType = "header";
+ state.header = parseInt(match[0][1]);
+ } else if (type.match(RE("bq"))) {
+ state.layoutType = "quote";
+ } else if (type.match(RE("bc"))) {
+ state.layoutType = "code";
+ } else if (type.match(RE("foot"))) {
+ state.layoutType = "footnote";
+ } else if (type.match(RE("notextile"))) {
+ state.layoutType = "notextile";
+ } else if (type.match(RE("pre"))) {
+ state.layoutType = "pre";
+ } else if (type.match(RE("div"))) {
+ state.layoutType = "div";
+ } else if (type.match(RE("table"))) {
+ state.layoutType = "table";
+ }
+
+ state.mode = Modes.attributes;
+ return tokenStyles(state);
+ },
+
+ text: function(stream, state) {
+ if (stream.match(RE("text"))) return tokenStyles(state);
+
+ var ch = stream.next();
+ if (ch === '"')
+ return (state.mode = Modes.link)(stream, state);
+ return handlePhraseModifier(stream, state, ch);
+ },
+
+ attributes: function(stream, state) {
+ state.mode = Modes.layoutLength;
+
+ if (stream.match(RE("attributes")))
+ return tokenStylesWith(state, TOKEN_STYLES.attributes);
+ else
+ return tokenStyles(state);
+ },
+
+ layoutLength: function(stream, state) {
+ if (stream.eat(".") && stream.eat("."))
+ state.spanningLayout = true;
+
+ state.mode = Modes.text;
+ return tokenStyles(state);
+ },
+
+ list: function(stream, state) {
+ var match = stream.match(RE("list"));
+ state.listDepth = match[0].length;
+ var listMod = (state.listDepth - 1) % 3;
+ if (!listMod)
+ state.layoutType = "list1";
+ else if (listMod === 1)
+ state.layoutType = "list2";
+ else
+ state.layoutType = "list3";
+
+ state.mode = Modes.attributes;
+ return tokenStyles(state);
+ },
+
+ link: function(stream, state) {
+ state.mode = Modes.text;
+ if (stream.match(RE("link"))) {
+ stream.match(/\S+/);
+ return tokenStylesWith(state, TOKEN_STYLES.link);
+ }
+ return tokenStyles(state);
+ },
+
+ linkDefinition: function(stream, state) {
+ stream.skipToEnd();
+ return tokenStylesWith(state, TOKEN_STYLES.linkDefinition);
+ },
+
+ definitionList: function(stream, state) {
+ stream.match(RE("definitionList"));
+
+ state.layoutType = "definitionList";
+
+ if (stream.match(/\s*$/))
+ state.spanningLayout = true;
+ else
+ state.mode = Modes.attributes;
+
+ return tokenStyles(state);
+ },
+
+ html: function(stream, state) {
+ stream.skipToEnd();
+ return tokenStylesWith(state, TOKEN_STYLES.html);
+ },
+
+ table: function(stream, state) {
+ state.layoutType = "table";
+ return (state.mode = Modes.tableCell)(stream, state);
+ },
+
+ tableCell: function(stream, state) {
+ if (stream.match(RE("tableHeading")))
+ state.tableHeading = true;
+ else
+ stream.eat("|");
+
+ state.mode = Modes.tableCellAttributes;
+ return tokenStyles(state);
+ },
+
+ tableCellAttributes: function(stream, state) {
+ state.mode = Modes.tableText;
+
+ if (stream.match(RE("tableCellAttributes")))
+ return tokenStylesWith(state, TOKEN_STYLES.attributes);
+ else
+ return tokenStyles(state);
+ },
+
+ tableText: function(stream, state) {
+ if (stream.match(RE("tableText")))
+ return tokenStyles(state);
+
+ if (stream.peek() === "|") { // end of cell
+ state.mode = Modes.tableCell;
+ return tokenStyles(state);
+ }
+ return handlePhraseModifier(stream, state, stream.next());
+ }
+ };
+
+ CodeMirror.defineMode("textile", function() {
+ return {
+ startState: function() {
+ return { mode: Modes.newLayout };
+ },
+ token: function(stream, state) {
+ if (stream.sol()) startNewLine(stream, state);
+ return state.mode(stream, state);
+ },
+ blankLine: blankLine
+ };
+ });
+
+ CodeMirror.defineMIME("text/x-textile", "textile");
+});
diff --git a/data/ext/editorText/codemirror/mode/tiddlywiki/index.html b/data/ext/editorText/codemirror/mode/tiddlywiki/index.html
index 6ef64a4d0..77dd0457c 100644
--- a/data/ext/editorText/codemirror/mode/tiddlywiki/index.html
+++ b/data/ext/editorText/codemirror/mode/tiddlywiki/index.html
@@ -11,12 +11,12 @@
<script src="tiddlywiki.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/tiddlywiki/tiddlywiki.js b/data/ext/editorText/codemirror/mode/tiddlywiki/tiddlywiki.js
index 24a24786b..1df01647a 100644
--- a/data/ext/editorText/codemirror/mode/tiddlywiki/tiddlywiki.js
+++ b/data/ext/editorText/codemirror/mode/tiddlywiki/tiddlywiki.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/***
|''Name''|tiddlywiki.js|
|''Description''|Enables TiddlyWikiy syntax highlighting using CodeMirror|
@@ -14,6 +17,17 @@
CoreVersion parameter is needed for TiddlyWiki only!
***/
//{{{
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("tiddlywiki", function () {
// Tokenizer
var textwords = {};
@@ -57,16 +71,6 @@ CodeMirror.defineMode("tiddlywiki", function () {
return f(stream, state);
}
- // Used as scratch variables to communicate multiple values without
- // consing up tons of objects.
- var type, content;
-
- function ret(tp, style, cont) {
- type = tp;
- content = cont;
- return style;
- }
-
function jsTokenBase(stream, state) {
var sol = stream.sol(), ch;
@@ -81,16 +85,16 @@ CodeMirror.defineMode("tiddlywiki", function () {
return chain(stream, state, twTokenCode);
}
if (stream.match(reBlockQuote)) {
- return ret('quote', 'quote');
+ return 'quote';
}
if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop)) {
- return ret('code', 'comment');
+ return 'comment';
}
if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop)) {
- return ret('code', 'comment');
+ return 'comment';
}
if (stream.match(reHR)) {
- return ret('hr', 'hr');
+ return 'hr';
}
} // sol
ch = stream.next();
@@ -98,30 +102,30 @@ CodeMirror.defineMode("tiddlywiki", function () {
if (sol && /[\/\*!#;:>|]/.test(ch)) {
if (ch == "!") { // tw header
stream.skipToEnd();
- return ret("header", "header");
+ return "header";
}
if (ch == "*") { // tw list
stream.eatWhile('*');
- return ret("list", "comment");
+ return "comment";
}
if (ch == "#") { // tw numbered list
stream.eatWhile('#');
- return ret("list", "comment");
+ return "comment";
}
if (ch == ";") { // definition list, term
stream.eatWhile(';');
- return ret("list", "comment");
+ return "comment";
}
if (ch == ":") { // definition list, description
stream.eatWhile(':');
- return ret("list", "comment");
+ return "comment";
}
if (ch == ">") { // single line quote
stream.eatWhile(">");
- return ret("quote", "quote");
+ return "quote";
}
if (ch == '|') {
- return ret('table', 'header');
+ return 'header';
}
}
@@ -132,29 +136,29 @@ CodeMirror.defineMode("tiddlywiki", function () {
// rudimentary html:// file:// link matching. TW knows much more ...
if (/[hf]/i.test(ch)) {
if (/[ti]/i.test(stream.peek()) && stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i)) {
- return ret("link", "link");
+ return "link";
}
}
// just a little string indicator, don't want to have the whole string covered
if (ch == '"') {
- return ret('string', 'string');
+ return 'string';
}
if (ch == '~') { // _no_ CamelCase indicator should be bold
- return ret('text', 'brace');
+ return 'brace';
}
if (/[\[\]]/.test(ch)) { // check for [[..]]
if (stream.peek() == ch) {
stream.next();
- return ret('brace', 'brace');
+ return 'brace';
}
}
if (ch == "@") { // check for space link. TODO fix @@...@@ highlighting
stream.eatWhile(isSpaceName);
- return ret("link", "link");
+ return "link";
}
if (/\d/.test(ch)) { // numbers
stream.eatWhile(/\d/);
- return ret("number", "number");
+ return "number";
}
if (ch == "/") { // tw invisible comment
if (stream.eat("%")) {
@@ -177,7 +181,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
return chain(stream, state, twTokenStrike);
// mdash
if (stream.peek() == ' ')
- return ret('text', 'brace');
+ return 'brace';
}
}
if (ch == "'") { // tw bold
@@ -191,7 +195,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
}
}
else {
- return ret(ch);
+ return null;
}
// core macro handling
@@ -199,8 +203,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
var word = stream.current(),
known = textwords.propertyIsEnumerable(word) && textwords[word];
- return known ? ret(known.type, known.style, word) : ret("text", null, word);
-
+ return known ? known.style : null;
} // jsTokenBase()
// tw invisible comment
@@ -214,7 +217,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
}
maybeEnd = (ch == "%");
}
- return ret("comment", "comment");
+ return "comment";
}
// tw strong / bold
@@ -228,29 +231,29 @@ CodeMirror.defineMode("tiddlywiki", function () {
}
maybeEnd = (ch == "'");
}
- return ret("text", "strong");
+ return "strong";
}
// tw code
function twTokenCode(stream, state) {
- var ch, sb = state.block;
+ var sb = state.block;
if (sb && stream.current()) {
- return ret("code", "comment");
+ return "comment";
}
if (!sb && stream.match(reUntilCodeStop)) {
state.tokenize = jsTokenBase;
- return ret("code", "comment");
+ return "comment";
}
if (sb && stream.sol() && stream.match(reCodeBlockStop)) {
state.tokenize = jsTokenBase;
- return ret("code", "comment");
+ return "comment";
}
- ch = stream.next();
- return (sb) ? ret("code", "comment") : ret("code", "comment");
+ stream.next();
+ return "comment";
}
// tw em / italic
@@ -264,7 +267,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
}
maybeEnd = (ch == "/");
}
- return ret("text", "em");
+ return "em";
}
// tw underlined text
@@ -278,7 +281,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
}
maybeEnd = (ch == "_");
}
- return ret("text", "underlined");
+ return "underlined";
}
// tw strike through text looks ugly
@@ -293,7 +296,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
}
maybeEnd = (ch == "-");
}
- return ret("text", "strikethrough");
+ return "strikethrough";
}
// macro
@@ -301,19 +304,19 @@ CodeMirror.defineMode("tiddlywiki", function () {
var ch, word, known;
if (stream.current() == '<<') {
- return ret('brace', 'macro');
+ return 'macro';
}
ch = stream.next();
if (!ch) {
state.tokenize = jsTokenBase;
- return ret(ch);
+ return null;
}
if (ch == ">") {
if (stream.peek() == '>') {
stream.next();
state.tokenize = jsTokenBase;
- return ret("brace", "macro");
+ return "macro";
}
}
@@ -322,10 +325,10 @@ CodeMirror.defineMode("tiddlywiki", function () {
known = keywords.propertyIsEnumerable(word) && keywords[word];
if (known) {
- return ret(known.type, known.style, word);
+ return known.style, word;
}
else {
- return ret("macro", null, word);
+ return null, word;
}
}
@@ -350,4 +353,6 @@ CodeMirror.defineMode("tiddlywiki", function () {
});
CodeMirror.defineMIME("text/x-tiddlywiki", "tiddlywiki");
+});
+
//}}}
diff --git a/data/ext/editorText/codemirror/mode/tiki/index.html b/data/ext/editorText/codemirror/mode/tiki/index.html
index 5315dbfcd..091c5fb2a 100644
--- a/data/ext/editorText/codemirror/mode/tiki/index.html
+++ b/data/ext/editorText/codemirror/mode/tiki/index.html
@@ -10,12 +10,12 @@
<script src="tiki.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/tiki/tiki.js b/data/ext/editorText/codemirror/mode/tiki/tiki.js
index e789163dc..5e05b1ff0 100644
--- a/data/ext/editorText/codemirror/mode/tiki/tiki.js
+++ b/data/ext/editorText/codemirror/mode/tiki/tiki.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode('tiki', function(config) {
function inBlock(style, terminator, returnTokenizer) {
return function(stream, state) {
@@ -39,35 +52,27 @@ CodeMirror.defineMode('tiki', function(config) {
case "{": //plugin
stream.eat("/");
stream.eatSpace();
- var tagName = "";
- var c;
- while ((c = stream.eat(/[^\s\u00a0=\"\'\/?(}]/))) tagName += c;
+ stream.eatWhile(/[^\s\u00a0=\"\'\/?(}]/);
state.tokenize = inPlugin;
return "tag";
- break;
case "_": //bold
- if (stream.eat("_")) {
+ if (stream.eat("_"))
return chain(inBlock("strong", "__", inText));
- }
break;
case "'": //italics
- if (stream.eat("'")) {
- // Italic text
+ if (stream.eat("'"))
return chain(inBlock("em", "''", inText));
- }
break;
case "(":// Wiki Link
- if (stream.eat("(")) {
+ if (stream.eat("("))
return chain(inBlock("variable-2", "))", inText));
- }
break;
case "[":// Weblink
return chain(inBlock("variable-3", "]", inText));
break;
case "|": //table
- if (stream.eat("|")) {
+ if (stream.eat("|"))
return chain(inBlock("comment", "||"));
- }
break;
case "-":
if (stream.eat("=")) {//titleBar
@@ -77,22 +82,19 @@ CodeMirror.defineMode('tiki', function(config) {
}
break;
case "=": //underline
- if (stream.match("==")) {
+ if (stream.match("=="))
return chain(inBlock("tw-underline", "===", inText));
- }
break;
case ":":
- if (stream.eat(":")) {
+ if (stream.eat(":"))
return chain(inBlock("comment", "::"));
- }
break;
case "^": //box
return chain(inBlock("tw-box", "^"));
break;
case "~": //np
- if (stream.match("np~")) {
+ if (stream.match("np~"))
return chain(inBlock("meta", "~/np~"));
- }
break;
}
@@ -306,3 +308,5 @@ return {
});
CodeMirror.defineMIME("text/tiki", "tiki");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/toml/index.html b/data/ext/editorText/codemirror/mode/toml/index.html
index c59b4cc08..90a2a0215 100644
--- a/data/ext/editorText/codemirror/mode/toml/index.html
+++ b/data/ext/editorText/codemirror/mode/toml/index.html
@@ -9,12 +9,12 @@
<script src="toml.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/toml/toml.js b/data/ext/editorText/codemirror/mode/toml/toml.js
index 3f95bf9ba..baeca1556 100644
--- a/data/ext/editorText/codemirror/mode/toml/toml.js
+++ b/data/ext/editorText/codemirror/mode/toml/toml.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("toml", function () {
return {
startState: function () {
@@ -71,3 +84,5 @@ CodeMirror.defineMode("toml", function () {
});
CodeMirror.defineMIME('text/x-toml', 'toml');
+
+});
diff --git a/data/ext/editorText/codemirror/mode/tornado/index.html b/data/ext/editorText/codemirror/mode/tornado/index.html
new file mode 100644
index 000000000..8ee7ef56c
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/tornado/index.html
@@ -0,0 +1,63 @@
+<!doctype html>
+
+<title>CodeMirror: Tornado template mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/mode/overlay.js"></script>
+<script src="../xml/xml.js"></script>
+<script src="../htmlmixed/htmlmixed.js"></script>
+<script src="tornado.js"></script>
+<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Tornado</a>
+ </ul>
+</div>
+
+<article>
+<h2>Tornado template mode</h2>
+<form><textarea id="code" name="code">
+<!doctype html>
+<html>
+ <head>
+ <title>My Tornado web application</title>
+ </head>
+ <body>
+ <h1>
+ {{ title }}
+ </h1>
+ <ul class="my-list">
+ {% for item in items %}
+ <li>{% item.name %}</li>
+ {% empty %}
+ <li>You have no items in your list.</li>
+ {% end %}
+ </ul>
+ </body>
+</html>
+</textarea></form>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "tornado",
+ indentUnit: 4,
+ indentWithTabs: true
+ });
+ </script>
+
+ <p>Mode for HTML with embedded Tornado template markup.</p>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-tornado</code></p>
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/tornado/tornado.js b/data/ext/editorText/codemirror/mode/tornado/tornado.js
new file mode 100644
index 000000000..dbfbc3489
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/tornado/tornado.js
@@ -0,0 +1,68 @@
+// 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"), require("../htmlmixed/htmlmixed"),
+ require("../../addon/mode/overlay"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
+ "../../addon/mode/overlay"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineMode("tornado:inner", function() {
+ var keywords = ["and","as","assert","autoescape","block","break","class","comment","context",
+ "continue","datetime","def","del","elif","else","end","escape","except",
+ "exec","extends","false","finally","for","from","global","if","import","in",
+ "include","is","json_encode","lambda","length","linkify","load","module",
+ "none","not","or","pass","print","put","raise","raw","return","self","set",
+ "squeeze","super","true","try","url_escape","while","with","without","xhtml_escape","yield"];
+ keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b");
+
+ function tokenBase (stream, state) {
+ stream.eatWhile(/[^\{]/);
+ var ch = stream.next();
+ if (ch == "{") {
+ if (ch = stream.eat(/\{|%|#/)) {
+ state.tokenize = inTag(ch);
+ return "tag";
+ }
+ }
+ }
+ function inTag (close) {
+ if (close == "{") {
+ close = "}";
+ }
+ return function (stream, state) {
+ var ch = stream.next();
+ if ((ch == close) && stream.eat("}")) {
+ state.tokenize = tokenBase;
+ return "tag";
+ }
+ if (stream.match(keywords)) {
+ return "keyword";
+ }
+ return close == "#" ? "comment" : "string";
+ };
+ }
+ return {
+ startState: function () {
+ return {tokenize: tokenBase};
+ },
+ token: function (stream, state) {
+ return state.tokenize(stream, state);
+ }
+ };
+ });
+
+ CodeMirror.defineMode("tornado", function(config) {
+ var htmlBase = CodeMirror.getMode(config, "text/html");
+ var tornadoInner = CodeMirror.getMode(config, "tornado:inner");
+ return CodeMirror.overlayMode(htmlBase, tornadoInner);
+ });
+
+ CodeMirror.defineMIME("text/x-tornado", "tornado");
+});
diff --git a/data/ext/editorText/codemirror/mode/troff/index.html b/data/ext/editorText/codemirror/mode/troff/index.html
new file mode 100644
index 000000000..7c5a54e54
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/troff/index.html
@@ -0,0 +1,146 @@
+<!doctype html>
+
+<title>CodeMirror: troff mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel=stylesheet href=../../lib/codemirror.css>
+<script src=../../lib/codemirror.js></script>
+<script src="../../addon/edit/matchbrackets.js"></script>
+<script src=troff.js></script>
+<style type=text/css>
+ .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
+</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">troff</a>
+ </ul>
+</div>
+
+<article>
+<h2>troff</h2>
+
+
+<textarea id=code>
+'\" t
+.\" Title: mkvextract
+.TH "MKVEXTRACT" "1" "2015\-02\-28" "MKVToolNix 7\&.7\&.0" "User Commands"
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.SH "NAME"
+mkvextract \- extract tracks from Matroska(TM) files into other files
+.SH "SYNOPSIS"
+.HP \w'\fBmkvextract\fR\ 'u
+\fBmkvextract\fR {mode} {source\-filename} [options] [extraction\-spec]
+.SH "DESCRIPTION"
+.PP
+.B mkvextract
+extracts specific parts from a
+.I Matroska(TM)
+file to other useful formats\&. The first argument,
+\fBmode\fR, tells
+\fBmkvextract\fR(1)
+what to extract\&. Currently supported is the extraction of
+tracks,
+tags,
+attachments,
+chapters,
+CUE sheets,
+timecodes
+and
+cues\&. The second argument is the name of the source file\&. It must be a
+Matroska(TM)
+file\&. All following arguments are options and extraction specifications; both of which depend on the selected mode\&.
+.SS "Common options"
+.PP
+The following options are available in all modes and only described once in this section\&.
+.PP
+\fB\-f\fR, \fB\-\-parse\-fully\fR
+.RS 4
+Sets the parse mode to \*(Aqfull\*(Aq\&. The default mode does not parse the whole file but uses the meta seek elements for locating the required elements of a source file\&. In 99% of all cases this is enough\&. But for files that do not contain meta seek elements or which are damaged the user might have to use this mode\&. A full scan of a file can take a couple of minutes while a fast scan only takes seconds\&.
+.RE
+.PP
+\fB\-\-command\-line\-charset\fR \fIcharacter\-set\fR
+.RS 4
+Sets the character set to convert strings given on the command line from\&. It defaults to the character set given by system\*(Aqs current locale\&.
+.RE
+.PP
+\fB\-\-output\-charset\fR \fIcharacter\-set\fR
+.RS 4
+Sets the character set to which strings are converted that are to be output\&. It defaults to the character set given by system\*(Aqs current locale\&.
+.RE
+.PP
+\fB\-r\fR, \fB\-\-redirect\-output\fR \fIfile\-name\fR
+.RS 4
+Writes all messages to the file
+\fIfile\-name\fR
+instead of to the console\&. While this can be done easily with output redirection there are cases in which this option is needed: when the terminal reinterprets the output before writing it to a file\&. The character set set with
+\fB\-\-output\-charset\fR
+is honored\&.
+.RE
+.PP
+\fB\-\-ui\-language\fR \fIcode\fR
+.RS 4
+Forces the translations for the language
+\fIcode\fR
+to be used (e\&.g\&. \*(Aqde_DE\*(Aq for the German translations)\&. It is preferable to use the environment variables
+\fILANG\fR,
+\fILC_MESSAGES\fR
+and
+\fILC_ALL\fR
+though\&. Entering \*(Aqlist\*(Aq as the
+\fIcode\fR
+will cause
+\fBmkvextract\fR(1)
+to output a list of available translations\&.
+
+.\" [...]
+
+.SH "SEE ALSO"
+.PP
+\fBmkvmerge\fR(1),
+\fBmkvinfo\fR(1),
+\fBmkvpropedit\fR(1),
+\fBmmg\fR(1)
+.SH "WWW"
+.PP
+The latest version can always be found at
+\m[blue]\fBthe MKVToolNix homepage\fR\m[]\&\s-2\u[1]\d\s+2\&.
+.SH "AUTHOR"
+.PP
+\(co \fBMoritz Bunkus\fR <\&moritz@bunkus\&.org\&>
+.RS 4
+Developer
+.RE
+.SH "NOTES"
+.IP " 1." 4
+the MKVToolNix homepage
+.RS 4
+\%https://www.bunkus.org/videotools/mkvtoolnix/
+.RE
+</textarea>
+
+<script>
+ var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
+ mode: 'troff',
+ lineNumbers: true,
+ matchBrackets: false
+ });
+</script>
+
+<p><strong>MIME types defined:</strong> <code>troff</code>.</p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/troff/troff.js b/data/ext/editorText/codemirror/mode/troff/troff.js
new file mode 100644
index 000000000..beca778ee
--- /dev/null
+++ b/data/ext/editorText/codemirror/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');
+
+});
diff --git a/data/ext/editorText/codemirror/mode/ttcn-cfg/index.html b/data/ext/editorText/codemirror/mode/ttcn-cfg/index.html
new file mode 100644
index 000000000..4a4cd4571
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/ttcn-cfg/index.html
@@ -0,0 +1,115 @@
+<!doctype html>
+
+<title>CodeMirror: TTCN-CFG mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="ttcn-cfg.js"></script>
+<style type="text/css">
+ .CodeMirror {
+ border-top: 1px solid black;
+ border-bottom: 1px solid black;
+ }
+</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1>
+ <img id=logo src="../../doc/logo.png">
+ </a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="http://en.wikipedia.org/wiki/TTCN">TTCN-CFG</a>
+ </ul>
+</div>
+<article>
+ <h2>TTCN-CFG example</h2>
+ <div>
+ <textarea id="ttcn-cfg-code">
+[MODULE_PARAMETERS]
+# This section shall contain the values of all parameters that are defined in your TTCN-3 modules.
+
+[LOGGING]
+# In this section you can specify the name of the log file and the classes of events
+# you want to log into the file or display on console (standard error).
+
+LogFile := "logs/%e.%h-%r.%s"
+FileMask := LOG_ALL | DEBUG | MATCHING
+ConsoleMask := ERROR | WARNING | TESTCASE | STATISTICS | PORTEVENT
+
+LogSourceInfo := Yes
+AppendFile := No
+TimeStampFormat := DateTime
+LogEventTypes := Yes
+SourceInfoFormat := Single
+LogEntityName := Yes
+
+[TESTPORT_PARAMETERS]
+# In this section you can specify parameters that are passed to Test Ports.
+
+[DEFINE]
+# In this section you can create macro definitions,
+# that can be used in other configuration file sections except [INCLUDE].
+
+[INCLUDE]
+# To use configuration settings given in other configuration files,
+# the configuration files just need to be listed in this section, with their full or relative pathnames.
+
+[EXTERNAL_COMMANDS]
+# This section can define external commands (shell scripts) to be executed by the ETS
+# whenever a control part or test case is started or terminated.
+
+BeginTestCase := ""
+EndTestCase := ""
+BeginControlPart := ""
+EndControlPart := ""
+
+[EXECUTE]
+# In this section you can specify what parts of your test suite you want to execute.
+
+[GROUPS]
+# In this section you can specify groups of hosts. These groups can be used inside the
+# [COMPONENTS] section to restrict the creation of certain PTCs to a given set of hosts.
+
+[COMPONENTS]
+# This section consists of rules restricting the location of created PTCs.
+
+[MAIN_CONTROLLER]
+# The options herein control the behavior of MC.
+
+TCPPort := 0
+KillTimer := 10.0
+NumHCs := 0
+LocalAddress :=
+ </textarea>
+ </div>
+
+ <script>
+ var ttcnEditor = CodeMirror.fromTextArea(document.getElementById("ttcn-cfg-code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-ttcn-cfg"
+ });
+ ttcnEditor.setSize(600, 860);
+ var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
+ CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
+ </script>
+ <br/>
+ <p><strong>Language:</strong> Testing and Test Control Notation -
+ Configuration files
+ (<a href="http://en.wikipedia.org/wiki/TTCN">TTCN-CFG</a>)
+ </p>
+ <p><strong>MIME types defined:</strong> <code>text/x-ttcn-cfg</code>.</p>
+
+ <br/>
+ <p>The development of this mode has been sponsored by <a href="http://www.ericsson.com/">Ericsson
+ </a>.</p>
+ <p>Coded by Asmelash Tsegay Gebretsadkan </p>
+</article>
+
diff --git a/data/ext/editorText/codemirror/mode/ttcn-cfg/ttcn-cfg.js b/data/ext/editorText/codemirror/mode/ttcn-cfg/ttcn-cfg.js
new file mode 100644
index 000000000..e10805119
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/ttcn-cfg/ttcn-cfg.js
@@ -0,0 +1,214 @@
+// 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";
+
+ CodeMirror.defineMode("ttcn-cfg", function(config, parserConfig) {
+ var indentUnit = config.indentUnit,
+ keywords = parserConfig.keywords || {},
+ fileNCtrlMaskOptions = parserConfig.fileNCtrlMaskOptions || {},
+ externalCommands = parserConfig.externalCommands || {},
+ multiLineStrings = parserConfig.multiLineStrings,
+ indentStatements = parserConfig.indentStatements !== false;
+ var isOperatorChar = /[\|]/;
+ var curPunc;
+
+ function tokenBase(stream, state) {
+ var ch = stream.next();
+ if (ch == '"' || ch == "'") {
+ state.tokenize = tokenString(ch);
+ return state.tokenize(stream, state);
+ }
+ if (/[:=]/.test(ch)) {
+ curPunc = ch;
+ return "punctuation";
+ }
+ if (ch == "#"){
+ stream.skipToEnd();
+ return "comment";
+ }
+ if (/\d/.test(ch)) {
+ stream.eatWhile(/[\w\.]/);
+ return "number";
+ }
+ if (isOperatorChar.test(ch)) {
+ stream.eatWhile(isOperatorChar);
+ return "operator";
+ }
+ if (ch == "["){
+ stream.eatWhile(/[\w_\]]/);
+ return "number sectionTitle";
+ }
+
+ stream.eatWhile(/[\w\$_]/);
+ var cur = stream.current();
+ if (keywords.propertyIsEnumerable(cur)) return "keyword";
+ if (fileNCtrlMaskOptions.propertyIsEnumerable(cur))
+ return "negative fileNCtrlMaskOptions";
+ if (externalCommands.propertyIsEnumerable(cur)) return "negative externalCommands";
+
+ return "variable";
+ }
+
+ function tokenString(quote) {
+ return function(stream, state) {
+ var escaped = false, next, end = false;
+ while ((next = stream.next()) != null) {
+ if (next == quote && !escaped){
+ var afterNext = stream.peek();
+ //look if the character if the quote is like the B in '10100010'B
+ if (afterNext){
+ afterNext = afterNext.toLowerCase();
+ if(afterNext == "b" || afterNext == "h" || afterNext == "o")
+ stream.next();
+ }
+ end = true; break;
+ }
+ escaped = !escaped && next == "\\";
+ }
+ if (end || !(escaped || multiLineStrings))
+ state.tokenize = null;
+ return "string";
+ };
+ }
+
+ function Context(indented, column, type, align, prev) {
+ this.indented = indented;
+ this.column = column;
+ this.type = type;
+ this.align = align;
+ this.prev = prev;
+ }
+ function pushContext(state, col, type) {
+ var indent = state.indented;
+ if (state.context && state.context.type == "statement")
+ indent = state.context.indented;
+ return state.context = new Context(indent, col, type, null, state.context);
+ }
+ function popContext(state) {
+ var t = state.context.type;
+ if (t == ")" || t == "]" || t == "}")
+ state.indented = state.context.indented;
+ return state.context = state.context.prev;
+ }
+
+ //Interface
+ return {
+ startState: function(basecolumn) {
+ return {
+ tokenize: null,
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
+ indented: 0,
+ startOfLine: true
+ };
+ },
+
+ token: function(stream, state) {
+ var ctx = state.context;
+ if (stream.sol()) {
+ if (ctx.align == null) ctx.align = false;
+ state.indented = stream.indentation();
+ state.startOfLine = true;
+ }
+ if (stream.eatSpace()) return null;
+ curPunc = null;
+ var style = (state.tokenize || tokenBase)(stream, state);
+ if (style == "comment") return style;
+ if (ctx.align == null) ctx.align = true;
+
+ if ((curPunc == ";" || curPunc == ":" || curPunc == ",")
+ && ctx.type == "statement"){
+ popContext(state);
+ }
+ else if (curPunc == "{") pushContext(state, stream.column(), "}");
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
+ else if (curPunc == "}") {
+ while (ctx.type == "statement") ctx = popContext(state);
+ if (ctx.type == "}") ctx = popContext(state);
+ while (ctx.type == "statement") ctx = popContext(state);
+ }
+ else if (curPunc == ctx.type) popContext(state);
+ else if (indentStatements && (((ctx.type == "}" || ctx.type == "top")
+ && curPunc != ';') || (ctx.type == "statement"
+ && curPunc == "newstatement")))
+ pushContext(state, stream.column(), "statement");
+ state.startOfLine = false;
+ return style;
+ },
+
+ electricChars: "{}",
+ lineComment: "#",
+ fold: "brace"
+ };
+ });
+
+ function words(str) {
+ var obj = {}, words = str.split(" ");
+ for (var i = 0; i < words.length; ++i)
+ obj[words[i]] = true;
+ return obj;
+ }
+
+ CodeMirror.defineMIME("text/x-ttcn-cfg", {
+ name: "ttcn-cfg",
+ keywords: words("Yes No LogFile FileMask ConsoleMask AppendFile" +
+ " TimeStampFormat LogEventTypes SourceInfoFormat" +
+ " LogEntityName LogSourceInfo DiskFullAction" +
+ " LogFileNumber LogFileSize MatchingHints Detailed" +
+ " Compact SubCategories Stack Single None Seconds" +
+ " DateTime Time Stop Error Retry Delete TCPPort KillTimer" +
+ " NumHCs UnixSocketsEnabled LocalAddress"),
+ fileNCtrlMaskOptions: words("TTCN_EXECUTOR TTCN_ERROR TTCN_WARNING" +
+ " TTCN_PORTEVENT TTCN_TIMEROP TTCN_VERDICTOP" +
+ " TTCN_DEFAULTOP TTCN_TESTCASE TTCN_ACTION" +
+ " TTCN_USER TTCN_FUNCTION TTCN_STATISTICS" +
+ " TTCN_PARALLEL TTCN_MATCHING TTCN_DEBUG" +
+ " EXECUTOR ERROR WARNING PORTEVENT TIMEROP" +
+ " VERDICTOP DEFAULTOP TESTCASE ACTION USER" +
+ " FUNCTION STATISTICS PARALLEL MATCHING DEBUG" +
+ " LOG_ALL LOG_NOTHING ACTION_UNQUALIFIED" +
+ " DEBUG_ENCDEC DEBUG_TESTPORT" +
+ " DEBUG_UNQUALIFIED DEFAULTOP_ACTIVATE" +
+ " DEFAULTOP_DEACTIVATE DEFAULTOP_EXIT" +
+ " DEFAULTOP_UNQUALIFIED ERROR_UNQUALIFIED" +
+ " EXECUTOR_COMPONENT EXECUTOR_CONFIGDATA" +
+ " EXECUTOR_EXTCOMMAND EXECUTOR_LOGOPTIONS" +
+ " EXECUTOR_RUNTIME EXECUTOR_UNQUALIFIED" +
+ " FUNCTION_RND FUNCTION_UNQUALIFIED" +
+ " MATCHING_DONE MATCHING_MCSUCCESS" +
+ " MATCHING_MCUNSUCC MATCHING_MMSUCCESS" +
+ " MATCHING_MMUNSUCC MATCHING_PCSUCCESS" +
+ " MATCHING_PCUNSUCC MATCHING_PMSUCCESS" +
+ " MATCHING_PMUNSUCC MATCHING_PROBLEM" +
+ " MATCHING_TIMEOUT MATCHING_UNQUALIFIED" +
+ " PARALLEL_PORTCONN PARALLEL_PORTMAP" +
+ " PARALLEL_PTC PARALLEL_UNQUALIFIED" +
+ " PORTEVENT_DUALRECV PORTEVENT_DUALSEND" +
+ " PORTEVENT_MCRECV PORTEVENT_MCSEND" +
+ " PORTEVENT_MMRECV PORTEVENT_MMSEND" +
+ " PORTEVENT_MQUEUE PORTEVENT_PCIN" +
+ " PORTEVENT_PCOUT PORTEVENT_PMIN" +
+ " PORTEVENT_PMOUT PORTEVENT_PQUEUE" +
+ " PORTEVENT_STATE PORTEVENT_UNQUALIFIED" +
+ " STATISTICS_UNQUALIFIED STATISTICS_VERDICT" +
+ " TESTCASE_FINISH TESTCASE_START" +
+ " TESTCASE_UNQUALIFIED TIMEROP_GUARD" +
+ " TIMEROP_READ TIMEROP_START TIMEROP_STOP" +
+ " TIMEROP_TIMEOUT TIMEROP_UNQUALIFIED" +
+ " USER_UNQUALIFIED VERDICTOP_FINAL" +
+ " VERDICTOP_GETVERDICT VERDICTOP_SETVERDICT" +
+ " VERDICTOP_UNQUALIFIED WARNING_UNQUALIFIED"),
+ externalCommands: words("BeginControlPart EndControlPart BeginTestCase" +
+ " EndTestCase"),
+ multiLineStrings: true
+ });
+});
\ No newline at end of file
diff --git a/data/ext/editorText/codemirror/mode/ttcn/index.html b/data/ext/editorText/codemirror/mode/ttcn/index.html
new file mode 100644
index 000000000..f1ef81131
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/ttcn/index.html
@@ -0,0 +1,118 @@
+<!doctype html>
+
+<title>CodeMirror: TTCN mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="ttcn.js"></script>
+<style type="text/css">
+ .CodeMirror {
+ border-top: 1px solid black;
+ border-bottom: 1px solid black;
+ }
+</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1>
+ <img id=logo src="../../doc/logo.png">
+ </a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="http://en.wikipedia.org/wiki/TTCN">TTCN</a>
+ </ul>
+</div>
+<article>
+ <h2>TTCN example</h2>
+ <div>
+ <textarea id="ttcn-code">
+module Templates {
+ /* import types from ASN.1 */
+ import from Types language "ASN.1:1997" all;
+
+ /* During the conversion phase from ASN.1 to TTCN-3 */
+ /* - the minus sign (Message-Type) within the identifiers will be replaced by underscore (Message_Type)*/
+ /* - the ASN.1 identifiers matching a TTCN-3 keyword (objid) will be postfixed with an underscore (objid_)*/
+
+ // simple types
+
+ template SenderID localObjid := objid {itu_t(0) identified_organization(4) etsi(0)};
+
+ // complex types
+
+ /* ASN.1 Message-Type mapped to TTCN-3 Message_Type */
+ template Message receiveMsg(template (present) Message_Type p_messageType) := {
+ header := p_messageType,
+ body := ?
+ }
+
+ /* ASN.1 objid mapped to TTCN-3 objid_ */
+ template Message sendInviteMsg := {
+ header := inviteType,
+ body := {
+ /* optional fields may be assigned by omit or may be ignored/skipped */
+ description := "Invite Message",
+ data := 'FF'O,
+ objid_ := localObjid
+ }
+ }
+
+ template Message sendAcceptMsg modifies sendInviteMsg := {
+ header := acceptType,
+ body := {
+ description := "Accept Message"
+ }
+ };
+
+ template Message sendErrorMsg modifies sendInviteMsg := {
+ header := errorType,
+ body := {
+ description := "Error Message"
+ }
+ };
+
+ template Message expectedErrorMsg := {
+ header := errorType,
+ body := ?
+ };
+
+ template Message expectedInviteMsg modifies expectedErrorMsg := {
+ header := inviteType
+ };
+
+ template Message expectedAcceptMsg modifies expectedErrorMsg := {
+ header := acceptType
+ };
+
+} with { encode "BER:1997" }
+ </textarea>
+ </div>
+
+ <script>
+ var ttcnEditor = CodeMirror.fromTextArea(document.getElementById("ttcn-code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-ttcn"
+ });
+ ttcnEditor.setSize(600, 860);
+ var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
+ CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
+ </script>
+ <br/>
+ <p><strong>Language:</strong> Testing and Test Control Notation
+ (<a href="http://en.wikipedia.org/wiki/TTCN">TTCN</a>)
+ </p>
+ <p><strong>MIME types defined:</strong> <code>text/x-ttcn,
+ text/x-ttcn3, text/x-ttcnpp</code>.</p>
+ <br/>
+ <p>The development of this mode has been sponsored by <a href="http://www.ericsson.com/">Ericsson
+ </a>.</p>
+ <p>Coded by Asmelash Tsegay Gebretsadkan </p>
+</article>
+
diff --git a/data/ext/editorText/codemirror/mode/ttcn/ttcn.js b/data/ext/editorText/codemirror/mode/ttcn/ttcn.js
new file mode 100644
index 000000000..305185177
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/ttcn/ttcn.js
@@ -0,0 +1,283 @@
+// 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";
+
+ CodeMirror.defineMode("ttcn", function(config, parserConfig) {
+ var indentUnit = config.indentUnit,
+ keywords = parserConfig.keywords || {},
+ builtin = parserConfig.builtin || {},
+ timerOps = parserConfig.timerOps || {},
+ portOps = parserConfig.portOps || {},
+ configOps = parserConfig.configOps || {},
+ verdictOps = parserConfig.verdictOps || {},
+ sutOps = parserConfig.sutOps || {},
+ functionOps = parserConfig.functionOps || {},
+
+ verdictConsts = parserConfig.verdictConsts || {},
+ booleanConsts = parserConfig.booleanConsts || {},
+ otherConsts = parserConfig.otherConsts || {},
+
+ types = parserConfig.types || {},
+ visibilityModifiers = parserConfig.visibilityModifiers || {},
+ templateMatch = parserConfig.templateMatch || {},
+ multiLineStrings = parserConfig.multiLineStrings,
+ indentStatements = parserConfig.indentStatements !== false;
+ var isOperatorChar = /[+\-*&@=<>!\/]/;
+ var curPunc;
+
+ function tokenBase(stream, state) {
+ var ch = stream.next();
+
+ if (ch == '"' || ch == "'") {
+ state.tokenize = tokenString(ch);
+ return state.tokenize(stream, state);
+ }
+ if (/[\[\]{}\(\),;\\:\?\.]/.test(ch)) {
+ curPunc = ch;
+ return "punctuation";
+ }
+ if (ch == "#"){
+ stream.skipToEnd();
+ return "atom preprocessor";
+ }
+ if (ch == "%"){
+ stream.eatWhile(/\b/);
+ return "atom ttcn3Macros";
+ }
+ if (/\d/.test(ch)) {
+ stream.eatWhile(/[\w\.]/);
+ return "number";
+ }
+ if (ch == "/") {
+ if (stream.eat("*")) {
+ state.tokenize = tokenComment;
+ return tokenComment(stream, state);
+ }
+ if (stream.eat("/")) {
+ stream.skipToEnd();
+ return "comment";
+ }
+ }
+ if (isOperatorChar.test(ch)) {
+ if(ch == "@"){
+ if(stream.match("try") || stream.match("catch")
+ || stream.match("lazy")){
+ return "keyword";
+ }
+ }
+ stream.eatWhile(isOperatorChar);
+ return "operator";
+ }
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/);
+ var cur = stream.current();
+
+ if (keywords.propertyIsEnumerable(cur)) return "keyword";
+ if (builtin.propertyIsEnumerable(cur)) return "builtin";
+
+ if (timerOps.propertyIsEnumerable(cur)) return "def timerOps";
+ if (configOps.propertyIsEnumerable(cur)) return "def configOps";
+ if (verdictOps.propertyIsEnumerable(cur)) return "def verdictOps";
+ if (portOps.propertyIsEnumerable(cur)) return "def portOps";
+ if (sutOps.propertyIsEnumerable(cur)) return "def sutOps";
+ if (functionOps.propertyIsEnumerable(cur)) return "def functionOps";
+
+ if (verdictConsts.propertyIsEnumerable(cur)) return "string verdictConsts";
+ if (booleanConsts.propertyIsEnumerable(cur)) return "string booleanConsts";
+ if (otherConsts.propertyIsEnumerable(cur)) return "string otherConsts";
+
+ if (types.propertyIsEnumerable(cur)) return "builtin types";
+ if (visibilityModifiers.propertyIsEnumerable(cur))
+ return "builtin visibilityModifiers";
+ if (templateMatch.propertyIsEnumerable(cur)) return "atom templateMatch";
+
+ return "variable";
+ }
+
+ function tokenString(quote) {
+ return function(stream, state) {
+ var escaped = false, next, end = false;
+ while ((next = stream.next()) != null) {
+ if (next == quote && !escaped){
+ var afterQuote = stream.peek();
+ //look if the character after the quote is like the B in '10100010'B
+ if (afterQuote){
+ afterQuote = afterQuote.toLowerCase();
+ if(afterQuote == "b" || afterQuote == "h" || afterQuote == "o")
+ stream.next();
+ }
+ end = true; break;
+ }
+ escaped = !escaped && next == "\\";
+ }
+ if (end || !(escaped || multiLineStrings))
+ state.tokenize = null;
+ return "string";
+ };
+ }
+
+ function tokenComment(stream, state) {
+ var maybeEnd = false, ch;
+ while (ch = stream.next()) {
+ if (ch == "/" && maybeEnd) {
+ state.tokenize = null;
+ break;
+ }
+ maybeEnd = (ch == "*");
+ }
+ return "comment";
+ }
+
+ function Context(indented, column, type, align, prev) {
+ this.indented = indented;
+ this.column = column;
+ this.type = type;
+ this.align = align;
+ this.prev = prev;
+ }
+
+ function pushContext(state, col, type) {
+ var indent = state.indented;
+ if (state.context && state.context.type == "statement")
+ indent = state.context.indented;
+ return state.context = new Context(indent, col, type, null, state.context);
+ }
+
+ function popContext(state) {
+ var t = state.context.type;
+ if (t == ")" || t == "]" || t == "}")
+ state.indented = state.context.indented;
+ return state.context = state.context.prev;
+ }
+
+ //Interface
+ return {
+ startState: function(basecolumn) {
+ return {
+ tokenize: null,
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
+ indented: 0,
+ startOfLine: true
+ };
+ },
+
+ token: function(stream, state) {
+ var ctx = state.context;
+ if (stream.sol()) {
+ if (ctx.align == null) ctx.align = false;
+ state.indented = stream.indentation();
+ state.startOfLine = true;
+ }
+ if (stream.eatSpace()) return null;
+ curPunc = null;
+ var style = (state.tokenize || tokenBase)(stream, state);
+ if (style == "comment") return style;
+ if (ctx.align == null) ctx.align = true;
+
+ if ((curPunc == ";" || curPunc == ":" || curPunc == ",")
+ && ctx.type == "statement"){
+ popContext(state);
+ }
+ else if (curPunc == "{") pushContext(state, stream.column(), "}");
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
+ else if (curPunc == "}") {
+ while (ctx.type == "statement") ctx = popContext(state);
+ if (ctx.type == "}") ctx = popContext(state);
+ while (ctx.type == "statement") ctx = popContext(state);
+ }
+ else if (curPunc == ctx.type) popContext(state);
+ else if (indentStatements &&
+ (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') ||
+ (ctx.type == "statement" && curPunc == "newstatement")))
+ pushContext(state, stream.column(), "statement");
+
+ state.startOfLine = false;
+
+ return style;
+ },
+
+ electricChars: "{}",
+ blockCommentStart: "/*",
+ blockCommentEnd: "*/",
+ lineComment: "//",
+ fold: "brace"
+ };
+ });
+
+ function words(str) {
+ var obj = {}, words = str.split(" ");
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
+ return obj;
+ }
+
+ function def(mimes, mode) {
+ if (typeof mimes == "string") mimes = [mimes];
+ var words = [];
+ function add(obj) {
+ if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))
+ words.push(prop);
+ }
+
+ add(mode.keywords);
+ add(mode.builtin);
+ add(mode.timerOps);
+ add(mode.portOps);
+
+ if (words.length) {
+ mode.helperType = mimes[0];
+ CodeMirror.registerHelper("hintWords", mimes[0], words);
+ }
+
+ for (var i = 0; i < mimes.length; ++i)
+ CodeMirror.defineMIME(mimes[i], mode);
+ }
+
+ def(["text/x-ttcn", "text/x-ttcn3", "text/x-ttcnpp"], {
+ name: "ttcn",
+ keywords: words("activate address alive all alt altstep and and4b any" +
+ " break case component const continue control deactivate" +
+ " display do else encode enumerated except exception" +
+ " execute extends extension external for from function" +
+ " goto group if import in infinity inout interleave" +
+ " label language length log match message mixed mod" +
+ " modifies module modulepar mtc noblock not not4b nowait" +
+ " of on optional or or4b out override param pattern port" +
+ " procedure record recursive rem repeat return runs select" +
+ " self sender set signature system template testcase to" +
+ " type union value valueof var variant while with xor xor4b"),
+ builtin: words("bit2hex bit2int bit2oct bit2str char2int char2oct encvalue" +
+ " decomp decvalue float2int float2str hex2bit hex2int" +
+ " hex2oct hex2str int2bit int2char int2float int2hex" +
+ " int2oct int2str int2unichar isbound ischosen ispresent" +
+ " isvalue lengthof log2str oct2bit oct2char oct2hex oct2int" +
+ " oct2str regexp replace rnd sizeof str2bit str2float" +
+ " str2hex str2int str2oct substr unichar2int unichar2char" +
+ " enum2int"),
+ types: words("anytype bitstring boolean char charstring default float" +
+ " hexstring integer objid octetstring universal verdicttype timer"),
+ timerOps: words("read running start stop timeout"),
+ portOps: words("call catch check clear getcall getreply halt raise receive" +
+ " reply send trigger"),
+ configOps: words("create connect disconnect done kill killed map unmap"),
+ verdictOps: words("getverdict setverdict"),
+ sutOps: words("action"),
+ functionOps: words("apply derefers refers"),
+
+ verdictConsts: words("error fail inconc none pass"),
+ booleanConsts: words("true false"),
+ otherConsts: words("null NULL omit"),
+
+ visibilityModifiers: words("private public friend"),
+ templateMatch: words("complement ifpresent subset superset permutation"),
+ multiLineStrings: true
+ });
+});
diff --git a/data/ext/editorText/codemirror/mode/turtle/index.html b/data/ext/editorText/codemirror/mode/turtle/index.html
index 27689c34f..a4962b617 100644
--- a/data/ext/editorText/codemirror/mode/turtle/index.html
+++ b/data/ext/editorText/codemirror/mode/turtle/index.html
@@ -9,12 +9,12 @@
<script src="turtle.js"></script>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/turtle/turtle.js b/data/ext/editorText/codemirror/mode/turtle/turtle.js
index e118bfbce..0988f0a44 100644
--- a/data/ext/editorText/codemirror/mode/turtle/turtle.js
+++ b/data/ext/editorText/codemirror/mode/turtle/turtle.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("turtle", function(config) {
var indentUnit = config.indentUnit;
var curPunc;
@@ -138,8 +151,12 @@ CodeMirror.defineMode("turtle", function(config) {
return context.col + (closing ? 0 : 1);
else
return context.indent + (closing ? 0 : indentUnit);
- }
+ },
+
+ lineComment: "#"
};
});
CodeMirror.defineMIME("text/turtle", "turtle");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/twig/index.html b/data/ext/editorText/codemirror/mode/twig/index.html
new file mode 100644
index 000000000..02493a5cb
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/twig/index.html
@@ -0,0 +1,45 @@
+<!doctype html>
+
+<title>CodeMirror: Twig mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="twig.js"></script>
+<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Twig</a>
+ </ul>
+</div>
+
+<article>
+<h2>Twig mode</h2>
+<form><textarea id="code" name="code">
+{% extends "layout.twig" %}
+{% block title %}CodeMirror: Twig mode{% endblock %}
+{# this is a comment #}
+{% block content %}
+ {% for foo in bar if foo.baz is divisible by(3) %}
+ Hello {{ foo.world }}
+ {% else %}
+ {% set msg = "Result not found" %}
+ {% include "empty.twig" with { message: msg } %}
+ {% endfor %}
+{% endblock %}
+</textarea></form>
+ <script>
+ var editor =
+ CodeMirror.fromTextArea(document.getElementById("code"), {mode:
+ {name: "twig", htmlMode: true}});
+ </script>
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/twig/twig.js b/data/ext/editorText/codemirror/mode/twig/twig.js
new file mode 100644
index 000000000..aa676dc48
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/twig/twig.js
@@ -0,0 +1,132 @@
+// 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";
+
+ CodeMirror.defineMode("twig", function() {
+ var keywords = ["and", "as", "autoescape", "endautoescape", "block", "do", "endblock", "else", "elseif", "extends", "for", "endfor", "embed", "endembed", "filter", "endfilter", "flush", "from", "if", "endif", "in", "is", "include", "import", "not", "or", "set", "spaceless", "endspaceless", "with", "endwith", "trans", "endtrans", "blocktrans", "endblocktrans", "macro", "endmacro", "use", "verbatim", "endverbatim"],
+ operator = /^[+\-*&%=<>!?|~^]/,
+ sign = /^[:\[\(\{]/,
+ atom = ["true", "false", "null", "empty", "defined", "divisibleby", "divisible by", "even", "odd", "iterable", "sameas", "same as"],
+ number = /^(\d[+\-\*\/])?\d+(\.\d+)?/;
+
+ keywords = new RegExp("((" + keywords.join(")|(") + "))\\b");
+ atom = new RegExp("((" + atom.join(")|(") + "))\\b");
+
+ function tokenBase (stream, state) {
+ var ch = stream.peek();
+
+ //Comment
+ if (state.incomment) {
+ if (!stream.skipTo("#}")) {
+ stream.skipToEnd();
+ } else {
+ stream.eatWhile(/\#|}/);
+ state.incomment = false;
+ }
+ return "comment";
+ //Tag
+ } else if (state.intag) {
+ //After operator
+ if (state.operator) {
+ state.operator = false;
+ if (stream.match(atom)) {
+ return "atom";
+ }
+ if (stream.match(number)) {
+ return "number";
+ }
+ }
+ //After sign
+ if (state.sign) {
+ state.sign = false;
+ if (stream.match(atom)) {
+ return "atom";
+ }
+ if (stream.match(number)) {
+ return "number";
+ }
+ }
+
+ if (state.instring) {
+ if (ch == state.instring) {
+ state.instring = false;
+ }
+ stream.next();
+ return "string";
+ } else if (ch == "'" || ch == '"') {
+ state.instring = ch;
+ stream.next();
+ return "string";
+ } else if (stream.match(state.intag + "}") || stream.eat("-") && stream.match(state.intag + "}")) {
+ state.intag = false;
+ return "tag";
+ } else if (stream.match(operator)) {
+ state.operator = true;
+ return "operator";
+ } else if (stream.match(sign)) {
+ state.sign = true;
+ } else {
+ if (stream.eat(" ") || stream.sol()) {
+ if (stream.match(keywords)) {
+ return "keyword";
+ }
+ if (stream.match(atom)) {
+ return "atom";
+ }
+ if (stream.match(number)) {
+ return "number";
+ }
+ if (stream.sol()) {
+ stream.next();
+ }
+ } else {
+ stream.next();
+ }
+
+ }
+ return "variable";
+ } else if (stream.eat("{")) {
+ if (ch = stream.eat("#")) {
+ state.incomment = true;
+ if (!stream.skipTo("#}")) {
+ stream.skipToEnd();
+ } else {
+ stream.eatWhile(/\#|}/);
+ state.incomment = false;
+ }
+ return "comment";
+ //Open tag
+ } else if (ch = stream.eat(/\{|%/)) {
+ //Cache close tag
+ state.intag = ch;
+ if (ch == "{") {
+ state.intag = "}";
+ }
+ stream.eat("-");
+ return "tag";
+ }
+ }
+ stream.next();
+ };
+
+ return {
+ startState: function () {
+ return {};
+ },
+ token: function (stream, state) {
+ return tokenBase(stream, state);
+ }
+ };
+ });
+
+ CodeMirror.defineMIME("text/x-twig", "twig");
+});
diff --git a/data/ext/editorText/codemirror/mode/vb/index.html b/data/ext/editorText/codemirror/mode/vb/index.html
index 8b81a88b9..adcc44fd3 100644
--- a/data/ext/editorText/codemirror/mode/vb/index.html
+++ b/data/ext/editorText/codemirror/mode/vb/index.html
@@ -15,12 +15,12 @@
.CodeMirror pre { font-family: Inconsolata; font-size: 14px}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/vb/vb.js b/data/ext/editorText/codemirror/mode/vb/vb.js
index 27b227195..d78f91f70 100644
--- a/data/ext/editorText/codemirror/mode/vb/vb.js
+++ b/data/ext/editorText/codemirror/mode/vb/vb.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("vb", function(conf, parserConf) {
var ERRORCLASS = 'error';
@@ -16,13 +29,14 @@ CodeMirror.defineMode("vb", function(conf, parserConf) {
var middleKeywords = ['else','elseif','case', 'catch'];
var endKeywords = ['next','loop'];
- var wordOperators = wordRegexp(['and', 'or', 'not', 'xor', 'in']);
- var commonkeywords = ['as', 'dim', 'break', 'continue','optional', 'then', 'until',
+ var operatorKeywords = ['and', 'or', 'not', 'xor', 'in'];
+ var wordOperators = wordRegexp(operatorKeywords);
+ var commonKeywords = ['as', 'dim', 'break', 'continue','optional', 'then', 'until',
'goto', 'byval','byref','new','handles','property', 'return',
'const','private', 'protected', 'friend', 'public', 'shared', 'static', 'true','false'];
var commontypes = ['integer','string','double','decimal','boolean','short','char', 'float','single'];
- var keywords = wordRegexp(commonkeywords);
+ var keywords = wordRegexp(commonKeywords);
var types = wordRegexp(commontypes);
var stringPrefixes = '"';
@@ -34,8 +48,8 @@ CodeMirror.defineMode("vb", function(conf, parserConf) {
var indentInfo = null;
-
-
+ CodeMirror.registerHelper("hintWords", "vb", openingKeywords.concat(middleKeywords).concat(endKeywords)
+ .concat(operatorKeywords).concat(commonKeywords).concat(commontypes));
function indent(_stream, state) {
state.currentIndent++;
@@ -250,10 +264,13 @@ CodeMirror.defineMode("vb", function(conf, parserConf) {
if (trueText.match(closing) || trueText.match(doubleClosing) || trueText.match(middle)) return conf.indentUnit*(state.currentIndent-1);
if(state.currentIndent < 0) return 0;
return state.currentIndent * conf.indentUnit;
- }
+ },
+ lineComment: "'"
};
return external;
});
CodeMirror.defineMIME("text/x-vb", "vb");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/vbscript/index.html b/data/ext/editorText/codemirror/mode/vbscript/index.html
index 9b506b798..ad7532d7d 100644
--- a/data/ext/editorText/codemirror/mode/vbscript/index.html
+++ b/data/ext/editorText/codemirror/mode/vbscript/index.html
@@ -9,12 +9,12 @@
<script src="vbscript.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/vbscript/vbscript.js b/data/ext/editorText/codemirror/mode/vbscript/vbscript.js
index 0a97fb640..b66df2239 100644
--- a/data/ext/editorText/codemirror/mode/vbscript/vbscript.js
+++ b/data/ext/editorText/codemirror/mode/vbscript/vbscript.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
/*
For extra ASP classic objects, initialize CodeMirror instance with this option:
isASP: true
@@ -8,6 +11,17 @@ E.G.:
isASP: true
});
*/
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("vbscript", function(conf, parserConf) {
var ERRORCLASS = 'error';
@@ -277,7 +291,7 @@ CodeMirror.defineMode("vbscript", function(conf, parserConf) {
style = state.tokenize(stream, state);
current = stream.current();
- if (style.substr(0, 8) === 'variable' || style==='builtin' || style==='keyword'){//|| knownWords.indexOf(current.substring(1)) > -1) {
+ if (style && (style.substr(0, 8) === 'variable' || style==='builtin' || style==='keyword')){//|| knownWords.indexOf(current.substring(1)) > -1) {
if (style === 'builtin' || style === 'keyword') style='variable';
if (knownWords.indexOf(current.substr(1)) > -1) style='variable-2';
@@ -332,3 +346,5 @@ CodeMirror.defineMode("vbscript", function(conf, parserConf) {
});
CodeMirror.defineMIME("text/vbscript", "vbscript");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/velocity/index.html b/data/ext/editorText/codemirror/mode/velocity/index.html
index bd38b886b..274787866 100644
--- a/data/ext/editorText/codemirror/mode/velocity/index.html
+++ b/data/ext/editorText/codemirror/mode/velocity/index.html
@@ -10,12 +10,12 @@
<script src="velocity.js"></script>
<style>.CodeMirror {border: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/velocity/velocity.js b/data/ext/editorText/codemirror/mode/velocity/velocity.js
index 968d8799e..8fc4f95d0 100644
--- a/data/ext/editorText/codemirror/mode/velocity/velocity.js
+++ b/data/ext/editorText/codemirror/mode/velocity/velocity.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("velocity", function() {
function parseWords(str) {
var obj = {}, words = str.split(" ");
@@ -184,3 +197,5 @@ CodeMirror.defineMode("velocity", function() {
});
CodeMirror.defineMIME("text/velocity", "velocity");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/verilog/index.html b/data/ext/editorText/codemirror/mode/verilog/index.html
index 4c06cdaec..96b3d6476 100644
--- a/data/ext/editorText/codemirror/mode/verilog/index.html
+++ b/data/ext/editorText/codemirror/mode/verilog/index.html
@@ -10,12 +10,12 @@
<script src="verilog.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/verilog/test.js b/data/ext/editorText/codemirror/mode/verilog/test.js
index 6f5770b84..9c8c09494 100644
--- a/data/ext/editorText/codemirror/mode/verilog/test.js
+++ b/data/ext/editorText/codemirror/mode/verilog/test.js
@@ -1,8 +1,11 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({indentUnit: 4}, "verilog");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
- MT("Binary literals",
+ MT("binary_literals",
"[number 1'b0]",
"[number 1'b1]",
"[number 1'bx]",
@@ -27,14 +30,14 @@
"[number 'b0101]"
);
- MT("Octal literals",
+ MT("octal_literals",
"[number 3'o7]",
"[number 3'O7]",
"[number 3'so7]",
"[number 3'SO7]"
);
- MT("Decimal literals",
+ MT("decimal_literals",
"[number 0]",
"[number 1]",
"[number 7]",
@@ -49,7 +52,7 @@
"[number 32 'd 123]"
);
- MT("Hex literals",
+ MT("hex_literals",
"[number 4'h0]",
"[number 4'ha]",
"[number 4'hF]",
@@ -66,7 +69,7 @@
"[number 32'hFFF?]"
);
- MT("Real number literals",
+ MT("real_number_literals",
"[number 1.2]",
"[number 0.1]",
"[number 2394.26331]",
@@ -79,36 +82,192 @@
"[number 236.123_763_e-12]"
);
- MT("Operators",
+ MT("operators",
"[meta ^]"
);
- MT("Keywords",
+ MT("keywords",
"[keyword logic]",
"[keyword logic] [variable foo]",
"[keyword reg] [variable abc]"
);
- MT("Variables",
+ MT("variables",
"[variable _leading_underscore]",
"[variable _if]",
"[number 12] [variable foo]",
"[variable foo] [number 14]"
);
- MT("Tick defines",
+ MT("tick_defines",
"[def `FOO]",
"[def `foo]",
"[def `FOO_bar]"
);
- MT("System calls",
+ MT("system_calls",
"[meta $display]",
"[meta $vpi_printf]"
);
- MT("Line comment", "[comment // Hello world]");
+ MT("line_comment", "[comment // Hello world]");
+
+ // Alignment tests
+ MT("align_port_map_style1",
+ /**
+ * mod mod(.a(a),
+ * .b(b)
+ * );
+ */
+ "[variable mod] [variable mod][bracket (].[variable a][bracket (][variable a][bracket )],",
+ " .[variable b][bracket (][variable b][bracket )]",
+ " [bracket )];",
+ ""
+ );
+
+ MT("align_port_map_style2",
+ /**
+ * mod mod(
+ * .a(a),
+ * .b(b)
+ * );
+ */
+ "[variable mod] [variable mod][bracket (]",
+ " .[variable a][bracket (][variable a][bracket )],",
+ " .[variable b][bracket (][variable b][bracket )]",
+ "[bracket )];",
+ ""
+ );
+
+ // Indentation tests
+ MT("indent_single_statement_if",
+ "[keyword if] [bracket (][variable foo][bracket )]",
+ " [keyword break];",
+ ""
+ );
+
+ MT("no_indent_after_single_line_if",
+ "[keyword if] [bracket (][variable foo][bracket )] [keyword break];",
+ ""
+ );
+
+ MT("indent_after_if_begin_same_line",
+ "[keyword if] [bracket (][variable foo][bracket )] [keyword begin]",
+ " [keyword break];",
+ " [keyword break];",
+ "[keyword end]",
+ ""
+ );
+
+ MT("indent_after_if_begin_next_line",
+ "[keyword if] [bracket (][variable foo][bracket )]",
+ " [keyword begin]",
+ " [keyword break];",
+ " [keyword break];",
+ " [keyword end]",
+ ""
+ );
+
+ MT("indent_single_statement_if_else",
+ "[keyword if] [bracket (][variable foo][bracket )]",
+ " [keyword break];",
+ "[keyword else]",
+ " [keyword break];",
+ ""
+ );
+ MT("indent_if_else_begin_same_line",
+ "[keyword if] [bracket (][variable foo][bracket )] [keyword begin]",
+ " [keyword break];",
+ " [keyword break];",
+ "[keyword end] [keyword else] [keyword begin]",
+ " [keyword break];",
+ " [keyword break];",
+ "[keyword end]",
+ ""
+ );
+
+ MT("indent_if_else_begin_next_line",
+ "[keyword if] [bracket (][variable foo][bracket )]",
+ " [keyword begin]",
+ " [keyword break];",
+ " [keyword break];",
+ " [keyword end]",
+ "[keyword else]",
+ " [keyword begin]",
+ " [keyword break];",
+ " [keyword break];",
+ " [keyword end]",
+ ""
+ );
+
+ MT("indent_if_nested_without_begin",
+ "[keyword if] [bracket (][variable foo][bracket )]",
+ " [keyword if] [bracket (][variable foo][bracket )]",
+ " [keyword if] [bracket (][variable foo][bracket )]",
+ " [keyword break];",
+ ""
+ );
+ MT("indent_case",
+ "[keyword case] [bracket (][variable state][bracket )]",
+ " [variable FOO]:",
+ " [keyword break];",
+ " [variable BAR]:",
+ " [keyword break];",
+ "[keyword endcase]",
+ ""
+ );
+
+ MT("unindent_after_end_with_preceding_text",
+ "[keyword begin]",
+ " [keyword break]; [keyword end]",
+ ""
+ );
+
+ MT("export_function_one_line_does_not_indent",
+ "[keyword export] [string \"DPI-C\"] [keyword function] [variable helloFromSV];",
+ ""
+ );
+
+ MT("export_task_one_line_does_not_indent",
+ "[keyword export] [string \"DPI-C\"] [keyword task] [variable helloFromSV];",
+ ""
+ );
+
+ MT("export_function_two_lines_indents_properly",
+ "[keyword export]",
+ " [string \"DPI-C\"] [keyword function] [variable helloFromSV];",
+ ""
+ );
+
+ MT("export_task_two_lines_indents_properly",
+ "[keyword export]",
+ " [string \"DPI-C\"] [keyword task] [variable helloFromSV];",
+ ""
+ );
+
+ MT("import_function_one_line_does_not_indent",
+ "[keyword import] [string \"DPI-C\"] [keyword function] [variable helloFromC];",
+ ""
+ );
+
+ MT("import_task_one_line_does_not_indent",
+ "[keyword import] [string \"DPI-C\"] [keyword task] [variable helloFromC];",
+ ""
+ );
+
+ MT("import_package_single_line_does_not_indent",
+ "[keyword import] [variable p]::[variable x];",
+ "[keyword import] [variable p]::[variable y];",
+ ""
+ );
+
+ MT("covergoup_with_function_indents_properly",
+ "[keyword covergroup] [variable cg] [keyword with] [keyword function] [variable sample][bracket (][keyword bit] [variable b][bracket )];",
+ " [variable c] : [keyword coverpoint] [variable c];",
+ "[keyword endgroup]: [variable cg]",
+ ""
+ );
})();
diff --git a/data/ext/editorText/codemirror/mode/verilog/verilog.js b/data/ext/editorText/codemirror/mode/verilog/verilog.js
index 036531c54..9d2a4cd58 100644
--- a/data/ext/editorText/codemirror/mode/verilog/verilog.js
+++ b/data/ext/editorText/codemirror/mode/verilog/verilog.js
@@ -1,10 +1,24 @@
+// 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";
+
CodeMirror.defineMode("verilog", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
dontAlignCalls = parserConfig.dontAlignCalls,
noIndentKeywords = parserConfig.noIndentKeywords || [],
- multiLineStrings = parserConfig.multiLineStrings;
+ multiLineStrings = parserConfig.multiLineStrings,
+ hooks = parserConfig.hooks || {};
function words(str) {
var obj = {}, words = str.split(" ");
@@ -67,7 +81,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
// Block openings which are closed by a matching keyword in the form of ("end" + keyword)
// E.g. "task" => "endtask"
var blockKeywords = words(
- "case checker class clocking config function generate group interface module package" +
+ "case checker class clocking config function generate interface module package" +
"primitive program property specify sequence table task"
);
@@ -81,6 +95,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
openClose["casez"] = "endcase";
openClose["do" ] = "while";
openClose["fork" ] = "join;join_any;join_none";
+ openClose["covergroup"] = "endgroup";
for (var i in noIndentKeywords) {
var keyword = noIndentKeywords[i];
@@ -89,10 +104,15 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
}
}
- var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else for foreach forever if initial repeat while");
+ // Keywords which open statements that are ended with a semi-colon
+ var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else export for foreach forever if import initial repeat while");
function tokenBase(stream, state) {
- var ch = stream.peek();
+ var ch = stream.peek(), style;
+ if (hooks[ch] && (style = hooks[ch](stream, state)) != false) return style;
+ if (hooks.tokenBase && (style = hooks.tokenBase(stream, state)) != false)
+ return style;
+
if (/[,;:\.]/.test(ch)) {
curPunc = stream.next();
return null;
@@ -265,12 +285,14 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
electricInput: buildElectricInputRegEx(),
startState: function(basecolumn) {
- return {
+ var state = {
tokenize: null,
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
indented: 0,
startOfLine: true
};
+ if (hooks.startState) hooks.startState(state);
+ return state;
},
token: function(stream, state) {
@@ -280,6 +302,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
state.indented = stream.indentation();
state.startOfLine = true;
}
+ if (hooks.token) hooks.token(stream, state);
if (stream.eatSpace()) return null;
curPunc = null;
curKeyword = null;
@@ -289,21 +312,31 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
if (curPunc == ctx.type) {
popContext(state);
- }
- else if ((curPunc == ";" && ctx.type == "statement") ||
+ } else if ((curPunc == ";" && ctx.type == "statement") ||
(ctx.type && isClosing(curKeyword, ctx.type))) {
ctx = popContext(state);
while (ctx && ctx.type == "statement") ctx = popContext(state);
- }
- else if (curPunc == "{") { pushContext(state, stream.column(), "}"); }
- else if (curPunc == "[") { pushContext(state, stream.column(), "]"); }
- else if (curPunc == "(") { pushContext(state, stream.column(), ")"); }
- else if (ctx && ctx.type == "endcase" && curPunc == ":") { pushContext(state, stream.column(), "statement"); }
- else if (curPunc == "newstatement") {
+ } else if (curPunc == "{") {
+ pushContext(state, stream.column(), "}");
+ } else if (curPunc == "[") {
+ pushContext(state, stream.column(), "]");
+ } else if (curPunc == "(") {
+ pushContext(state, stream.column(), ")");
+ } else if (ctx && ctx.type == "endcase" && curPunc == ":") {
+ pushContext(state, stream.column(), "statement");
+ } else if (curPunc == "newstatement") {
pushContext(state, stream.column(), "statement");
} else if (curPunc == "newblock") {
- var close = openClose[curKeyword];
- pushContext(state, stream.column(), close);
+ if (curKeyword == "function" && ctx && (ctx.type == "statement" || ctx.type == "endgroup")) {
+ // The 'function' keyword can appear in some other contexts where it actually does not
+ // indicate a function (import/export DPI and covergroup definitions).
+ // Do nothing in this case
+ } else if (curKeyword == "task" && ctx && ctx.type == "statement") {
+ // Same thing for task
+ } else {
+ var close = openClose[curKeyword];
+ pushContext(state, stream.column(), close);
+ }
}
state.startOfLine = false;
@@ -312,13 +345,16 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
indent: function(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
+ if (hooks.indent) {
+ var fromHook = hooks.indent(state);
+ if (fromHook >= 0) return fromHook;
+ }
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
var closing = false;
var possibleClosing = textAfter.match(closingBracketOrWord);
- if (possibleClosing) {
+ if (possibleClosing)
closing = isClosing(possibleClosing[0], ctx.type);
- }
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
else if (closingBracket.test(ctx.type) && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1);
else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
@@ -331,9 +367,171 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
};
});
-CodeMirror.defineMIME("text/x-verilog", {
- name: "verilog"
-});
-CodeMirror.defineMIME("text/x-systemverilog", {
- name: "systemverilog"
+ CodeMirror.defineMIME("text/x-verilog", {
+ name: "verilog"
+ });
+
+ CodeMirror.defineMIME("text/x-systemverilog", {
+ name: "verilog"
+ });
+
+ // TLVVerilog mode
+
+ var tlvchScopePrefixes = {
+ ">": "property", "->": "property", "-": "hr", "|": "link", "?$": "qualifier", "?*": "qualifier",
+ "@-": "variable-3", "@": "variable-3", "?": "qualifier"
+ };
+
+ function tlvGenIndent(stream, state) {
+ var tlvindentUnit = 2;
+ var rtnIndent = -1, indentUnitRq = 0, curIndent = stream.indentation();
+ switch (state.tlvCurCtlFlowChar) {
+ case "\\":
+ curIndent = 0;
+ break;
+ case "|":
+ if (state.tlvPrevPrevCtlFlowChar == "@") {
+ indentUnitRq = -2; //-2 new pipe rq after cur pipe
+ break;
+ }
+ if (tlvchScopePrefixes[state.tlvPrevCtlFlowChar])
+ indentUnitRq = 1; // +1 new scope
+ break;
+ case "M": // m4
+ if (state.tlvPrevPrevCtlFlowChar == "@") {
+ indentUnitRq = -2; //-2 new inst rq after pipe
+ break;
+ }
+ if (tlvchScopePrefixes[state.tlvPrevCtlFlowChar])
+ indentUnitRq = 1; // +1 new scope
+ break;
+ case "@":
+ if (state.tlvPrevCtlFlowChar == "S")
+ indentUnitRq = -1; // new pipe stage after stmts
+ if (state.tlvPrevCtlFlowChar == "|")
+ indentUnitRq = 1; // 1st pipe stage
+ break;
+ case "S":
+ if (state.tlvPrevCtlFlowChar == "@")
+ indentUnitRq = 1; // flow in pipe stage
+ if (tlvchScopePrefixes[state.tlvPrevCtlFlowChar])
+ indentUnitRq = 1; // +1 new scope
+ break;
+ }
+ var statementIndentUnit = tlvindentUnit;
+ rtnIndent = curIndent + (indentUnitRq*statementIndentUnit);
+ return rtnIndent >= 0 ? rtnIndent : curIndent;
+ }
+
+ CodeMirror.defineMIME("text/x-tlv", {
+ name: "verilog",
+ hooks: {
+ "\\": function(stream, state) {
+ var vxIndent = 0, style = false;
+ var curPunc = stream.string;
+ if ((stream.sol()) && ((/\\SV/.test(stream.string)) || (/\\TLV/.test(stream.string)))) {
+ curPunc = (/\\TLV_version/.test(stream.string))
+ ? "\\TLV_version" : stream.string;
+ stream.skipToEnd();
+ if (curPunc == "\\SV" && state.vxCodeActive) {state.vxCodeActive = false;};
+ if ((/\\TLV/.test(curPunc) && !state.vxCodeActive)
+ || (curPunc=="\\TLV_version" && state.vxCodeActive)) {state.vxCodeActive = true;};
+ style = "keyword";
+ state.tlvCurCtlFlowChar = state.tlvPrevPrevCtlFlowChar
+ = state.tlvPrevCtlFlowChar = "";
+ if (state.vxCodeActive == true) {
+ state.tlvCurCtlFlowChar = "\\";
+ vxIndent = tlvGenIndent(stream, state);
+ }
+ state.vxIndentRq = vxIndent;
+ }
+ return style;
+ },
+ tokenBase: function(stream, state) {
+ var vxIndent = 0, style = false;
+ var tlvisOperatorChar = /[\[\]=:]/;
+ var tlvkpScopePrefixs = {
+ "**":"variable-2", "*":"variable-2", "$$":"variable", "$":"variable",
+ "^^":"attribute", "^":"attribute"};
+ var ch = stream.peek();
+ var vxCurCtlFlowCharValueAtStart = state.tlvCurCtlFlowChar;
+ if (state.vxCodeActive == true) {
+ if (/[\[\]{}\(\);\:]/.test(ch)) {
+ // bypass nesting and 1 char punc
+ style = "meta";
+ stream.next();
+ } else if (ch == "/") {
+ stream.next();
+ if (stream.eat("/")) {
+ stream.skipToEnd();
+ style = "comment";
+ state.tlvCurCtlFlowChar = "S";
+ } else {
+ stream.backUp(1);
+ }
+ } else if (ch == "@") {
+ // pipeline stage
+ style = tlvchScopePrefixes[ch];
+ state.tlvCurCtlFlowChar = "@";
+ stream.next();
+ stream.eatWhile(/[\w\$_]/);
+ } else if (stream.match(/\b[mM]4+/, true)) { // match: function(pattern, consume, caseInsensitive)
+ // m4 pre proc
+ stream.skipTo("(");
+ style = "def";
+ state.tlvCurCtlFlowChar = "M";
+ } else if (ch == "!" && stream.sol()) {
+ // v stmt in tlv region
+ // state.tlvCurCtlFlowChar = "S";
+ style = "comment";
+ stream.next();
+ } else if (tlvisOperatorChar.test(ch)) {
+ // operators
+ stream.eatWhile(tlvisOperatorChar);
+ style = "operator";
+ } else if (ch == "#") {
+ // phy hier
+ state.tlvCurCtlFlowChar = (state.tlvCurCtlFlowChar == "")
+ ? ch : state.tlvCurCtlFlowChar;
+ stream.next();
+ stream.eatWhile(/[+-]\d/);
+ style = "tag";
+ } else if (tlvkpScopePrefixs.propertyIsEnumerable(ch)) {
+ // special TLV operators
+ style = tlvkpScopePrefixs[ch];
+ state.tlvCurCtlFlowChar = state.tlvCurCtlFlowChar == "" ? "S" : state.tlvCurCtlFlowChar; // stmt
+ stream.next();
+ stream.match(/[a-zA-Z_0-9]+/);
+ } else if (style = tlvchScopePrefixes[ch] || false) {
+ // special TLV operators
+ state.tlvCurCtlFlowChar = state.tlvCurCtlFlowChar == "" ? ch : state.tlvCurCtlFlowChar;
+ stream.next();
+ stream.match(/[a-zA-Z_0-9]+/);
+ }
+ if (state.tlvCurCtlFlowChar != vxCurCtlFlowCharValueAtStart) { // flow change
+ vxIndent = tlvGenIndent(stream, state);
+ state.vxIndentRq = vxIndent;
+ }
+ }
+ return style;
+ },
+ token: function(stream, state) {
+ if (state.vxCodeActive == true && stream.sol() && state.tlvCurCtlFlowChar != "") {
+ state.tlvPrevPrevCtlFlowChar = state.tlvPrevCtlFlowChar;
+ state.tlvPrevCtlFlowChar = state.tlvCurCtlFlowChar;
+ state.tlvCurCtlFlowChar = "";
+ }
+ },
+ indent: function(state) {
+ return (state.vxCodeActive == true) ? state.vxIndentRq : -1;
+ },
+ startState: function(state) {
+ state.tlvCurCtlFlowChar = "";
+ state.tlvPrevCtlFlowChar = "";
+ state.tlvPrevPrevCtlFlowChar = "";
+ state.vxCodeActive = true;
+ state.vxIndentRq = 0;
+ }
+ }
+ });
});
diff --git a/data/ext/editorText/codemirror/mode/vhdl/index.html b/data/ext/editorText/codemirror/mode/vhdl/index.html
new file mode 100644
index 000000000..3051bc37e
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/vhdl/index.html
@@ -0,0 +1,95 @@
+<!doctype html>
+
+<title>CodeMirror: VHDL mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/edit/matchbrackets.js"></script>
+<script src="vhdl.js"></script>
+<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">VHDL</a>
+ </ul>
+</div>
+
+<article>
+<h2>VHDL mode</h2>
+
+<div><textarea id="code" name="code">
+LIBRARY ieee;
+USE ieee.std_logic_1164.ALL;
+USE ieee.numeric_std.ALL;
+
+ENTITY tb IS
+END tb;
+
+ARCHITECTURE behavior OF tb IS
+ --Inputs
+ signal a : unsigned(2 downto 0) := (others => '0');
+ signal b : unsigned(2 downto 0) := (others => '0');
+ --Outputs
+ signal a_eq_b : std_logic;
+ signal a_le_b : std_logic;
+ signal a_gt_b : std_logic;
+
+ signal i,j : integer;
+
+BEGIN
+
+ -- Instantiate the Unit Under Test (UUT)
+ uut: entity work.comparator PORT MAP (
+ a => a,
+ b => b,
+ a_eq_b => a_eq_b,
+ a_le_b => a_le_b,
+ a_gt_b => a_gt_b
+ );
+
+ -- Stimulus process
+ stim_proc: process
+ begin
+ for i in 0 to 8 loop
+ for j in 0 to 8 loop
+ a <= to_unsigned(i,3); --integer to unsigned type conversion
+ b <= to_unsigned(j,3);
+ wait for 10 ns;
+ end loop;
+ end loop;
+ end process;
+
+END;
+</textarea></div>
+
+<script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: {
+ name: "vhdl",
+ }
+ });
+</script>
+
+<p>
+Syntax highlighting and indentation for the VHDL language.
+<h2>Configuration options:</h2>
+ <ul>
+ <li><strong>atoms</strong> - List of atom words. Default: "null"</li>
+ <li><strong>hooks</strong> - List of meta hooks. Default: ["`", "$"]</li>
+ <li><strong>multiLineStrings</strong> - Whether multi-line strings are accepted. Default: false</li>
+ </ul>
+</p>
+
+<p><strong>MIME types defined:</strong> <code>text/x-vhdl</code>.</p>
+</article>
diff --git a/data/ext/editorText/codemirror/mode/vhdl/vhdl.js b/data/ext/editorText/codemirror/mode/vhdl/vhdl.js
new file mode 100644
index 000000000..d3b555aa0
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/vhdl/vhdl.js
@@ -0,0 +1,189 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Originally written by Alf Nielsen, re-written by Michael Zhou
+(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 words(str) {
+ var obj = {}, words = str.split(",");
+ for (var i = 0; i < words.length; ++i) {
+ var allCaps = words[i].toUpperCase();
+ var firstCap = words[i].charAt(0).toUpperCase() + words[i].slice(1);
+ obj[words[i]] = true;
+ obj[allCaps] = true;
+ obj[firstCap] = true;
+ }
+ return obj;
+}
+
+function metaHook(stream) {
+ stream.eatWhile(/[\w\$_]/);
+ return "meta";
+}
+
+CodeMirror.defineMode("vhdl", function(config, parserConfig) {
+ var indentUnit = config.indentUnit,
+ atoms = parserConfig.atoms || words("null"),
+ hooks = parserConfig.hooks || {"`": metaHook, "$": metaHook},
+ multiLineStrings = parserConfig.multiLineStrings;
+
+ var keywords = words("abs,access,after,alias,all,and,architecture,array,assert,attribute,begin,block," +
+ "body,buffer,bus,case,component,configuration,constant,disconnent,downto,else,elsif,end,end block,end case," +
+ "end component,end for,end generate,end if,end loop,end process,end record,end units,entity,exit,file,for," +
+ "function,generate,generic,generic map,group,guarded,if,impure,in,inertial,inout,is,label,library,linkage," +
+ "literal,loop,map,mod,nand,new,next,nor,null,of,on,open,or,others,out,package,package body,port,port map," +
+ "postponed,procedure,process,pure,range,record,register,reject,rem,report,return,rol,ror,select,severity,signal," +
+ "sla,sll,sra,srl,subtype,then,to,transport,type,unaffected,units,until,use,variable,wait,when,while,with,xnor,xor");
+
+ var blockKeywords = words("architecture,entity,begin,case,port,else,elsif,end,for,function,if");
+
+ var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/;
+ var curPunc;
+
+ function tokenBase(stream, state) {
+ var ch = stream.next();
+ if (hooks[ch]) {
+ var result = hooks[ch](stream, state);
+ if (result !== false) return result;
+ }
+ if (ch == '"') {
+ state.tokenize = tokenString2(ch);
+ return state.tokenize(stream, state);
+ }
+ if (ch == "'") {
+ state.tokenize = tokenString(ch);
+ return state.tokenize(stream, state);
+ }
+ if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
+ curPunc = ch;
+ return null;
+ }
+ if (/[\d']/.test(ch)) {
+ stream.eatWhile(/[\w\.']/);
+ return "number";
+ }
+ if (ch == "-") {
+ if (stream.eat("-")) {
+ stream.skipToEnd();
+ return "comment";
+ }
+ }
+ if (isOperatorChar.test(ch)) {
+ stream.eatWhile(isOperatorChar);
+ return "operator";
+ }
+ stream.eatWhile(/[\w\$_]/);
+ var cur = stream.current();
+ if (keywords.propertyIsEnumerable(cur.toLowerCase())) {
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
+ return "keyword";
+ }
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
+ return "variable";
+ }
+
+ function tokenString(quote) {
+ return function(stream, state) {
+ var escaped = false, next, end = false;
+ while ((next = stream.next()) != null) {
+ if (next == quote && !escaped) {end = true; break;}
+ escaped = !escaped && next == "--";
+ }
+ if (end || !(escaped || multiLineStrings))
+ state.tokenize = tokenBase;
+ return "string";
+ };
+ }
+ function tokenString2(quote) {
+ return function(stream, state) {
+ var escaped = false, next, end = false;
+ while ((next = stream.next()) != null) {
+ if (next == quote && !escaped) {end = true; break;}
+ escaped = !escaped && next == "--";
+ }
+ if (end || !(escaped || multiLineStrings))
+ state.tokenize = tokenBase;
+ return "string-2";
+ };
+ }
+
+ function Context(indented, column, type, align, prev) {
+ this.indented = indented;
+ this.column = column;
+ this.type = type;
+ this.align = align;
+ this.prev = prev;
+ }
+ function pushContext(state, col, type) {
+ return state.context = new Context(state.indented, col, type, null, state.context);
+ }
+ function popContext(state) {
+ var t = state.context.type;
+ if (t == ")" || t == "]" || t == "}")
+ state.indented = state.context.indented;
+ return state.context = state.context.prev;
+ }
+
+ // Interface
+ return {
+ startState: function(basecolumn) {
+ return {
+ tokenize: null,
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
+ indented: 0,
+ startOfLine: true
+ };
+ },
+
+ token: function(stream, state) {
+ var ctx = state.context;
+ if (stream.sol()) {
+ if (ctx.align == null) ctx.align = false;
+ state.indented = stream.indentation();
+ state.startOfLine = true;
+ }
+ if (stream.eatSpace()) return null;
+ curPunc = null;
+ var style = (state.tokenize || tokenBase)(stream, state);
+ if (style == "comment" || style == "meta") return style;
+ if (ctx.align == null) ctx.align = true;
+
+ if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
+ else if (curPunc == "{") pushContext(state, stream.column(), "}");
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
+ else if (curPunc == "}") {
+ while (ctx.type == "statement") ctx = popContext(state);
+ if (ctx.type == "}") ctx = popContext(state);
+ while (ctx.type == "statement") ctx = popContext(state);
+ }
+ else if (curPunc == ctx.type) popContext(state);
+ else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
+ pushContext(state, stream.column(), "statement");
+ state.startOfLine = false;
+ return style;
+ },
+
+ indent: function(state, textAfter) {
+ if (state.tokenize != tokenBase && state.tokenize != null) return 0;
+ var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
+ if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
+ else if (ctx.align) return ctx.column + (closing ? 0 : 1);
+ else return ctx.indented + (closing ? 0 : indentUnit);
+ },
+
+ electricChars: "{}"
+ };
+});
+
+CodeMirror.defineMIME("text/x-vhdl", "vhdl");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/vue/index.html b/data/ext/editorText/codemirror/mode/vue/index.html
new file mode 100644
index 000000000..cccb9764f
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/vue/index.html
@@ -0,0 +1,69 @@
+<!doctype html>
+
+<title>CodeMirror: Vue.js mode</title>
+<meta charset="utf-8"/>
+<link rel=stylesheet href="../../doc/docs.css">
+
+<link rel="stylesheet" href="../../lib/codemirror.css">
+<script src="../../lib/codemirror.js"></script>
+<script src="../../addon/mode/overlay.js"></script>
+<script src="../../addon/mode/simple.js"></script>
+<script src="../../addon/selection/selection-pointer.js"></script>
+<script src="../xml/xml.js"></script>
+<script src="../javascript/javascript.js"></script>
+<script src="../css/css.js"></script>
+<script src="../coffeescript/coffeescript.js"></script>
+<script src="../sass/sass.js"></script>
+<script src="../jade/jade.js"></script>
+
+<script src="../handlebars/handlebars.js"></script>
+<script src="../htmlmixed/htmlmixed.js"></script>
+<script src="vue.js"></script>
+<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+<div id=nav>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
+
+ <ul>
+ <li><a href="../../index.html">Home</a>
+ <li><a href="../../doc/manual.html">Manual</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
+ </ul>
+ <ul>
+ <li><a href="../index.html">Language modes</a>
+ <li><a class=active href="#">Vue.js mode</a>
+ </ul>
+</div>
+
+<article>
+<h2>Vue.js mode</h2>
+<form><textarea id="code" name="code">
+<template>
+ <div class="sass">Im am a {{mustache-like}} template</div>
+</template>
+
+<script lang="coffee">
+ module.exports =
+ props: ['one', 'two', 'three']
+</script>
+
+<style lang="sass">
+.sass
+ font-size: 18px
+</style>
+
+</textarea></form>
+ <script>
+ // Define an extended mixed-mode that understands vbscript and
+ // leaves mustache/handlebars embedded templates in html mode
+ var mixedMode = {
+ name: "vue"
+ };
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ mode: mixedMode,
+ selectionPointer: true
+ });
+ </script>
+
+ <p><strong>MIME types defined:</strong> <code>text/x-vue</code></p>
+
+ </article>
diff --git a/data/ext/editorText/codemirror/mode/vue/vue.js b/data/ext/editorText/codemirror/mode/vue/vue.js
new file mode 100644
index 000000000..d89a55238
--- /dev/null
+++ b/data/ext/editorText/codemirror/mode/vue/vue.js
@@ -0,0 +1,69 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function (mod) {
+ "use strict";
+ if (typeof exports === "object" && typeof module === "object") {// CommonJS
+ mod(require("../../lib/codemirror"),
+ require("../../addon/mode/overlay"),
+ require("../xml/xml"),
+ require("../javascript/javascript"),
+ require("../coffeescript/coffeescript"),
+ require("../css/css"),
+ require("../sass/sass"),
+ require("../stylus/stylus"),
+ require("../jade/jade"),
+ require("../handlebars/handlebars"));
+ } else if (typeof define === "function" && define.amd) { // AMD
+ define(["../../lib/codemirror",
+ "../../addon/mode/overlay",
+ "../xml/xml",
+ "../javascript/javascript",
+ "../coffeescript/coffeescript",
+ "../css/css",
+ "../sass/sass",
+ "../stylus/stylus",
+ "../jade/jade",
+ "../handlebars/handlebars"], mod);
+ } else { // Plain browser env
+ mod(CodeMirror);
+ }
+})(function (CodeMirror) {
+ var tagLanguages = {
+ script: [
+ ["lang", /coffee(script)?/, "coffeescript"],
+ ["type", /^(?:text|application)\/(?:x-)?coffee(?:script)?$/, "coffeescript"]
+ ],
+ style: [
+ ["lang", /^stylus$/i, "stylus"],
+ ["lang", /^sass$/i, "sass"],
+ ["type", /^(text\/)?(x-)?styl(us)?$/i, "stylus"],
+ ["type", /^text\/sass/i, "sass"]
+ ],
+ template: [
+ ["lang", /^vue-template$/i, "vue"],
+ ["lang", /^jade$/i, "jade"],
+ ["lang", /^handlebars$/i, "handlebars"],
+ ["type", /^(text\/)?(x-)?jade$/i, "jade"],
+ ["type", /^text\/x-handlebars-template$/i, "handlebars"],
+ [null, null, "vue-template"]
+ ]
+ };
+
+ CodeMirror.defineMode("vue-template", function (config, parserConfig) {
+ var mustacheOverlay = {
+ token: function (stream) {
+ if (stream.match(/^\{\{.*?\}\}/)) return "meta mustache";
+ while (stream.next() && !stream.match("{{", false)) {}
+ return null;
+ }
+ };
+ return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), mustacheOverlay);
+ });
+
+ CodeMirror.defineMode("vue", function (config) {
+ return CodeMirror.getMode(config, {name: "htmlmixed", tags: tagLanguages});
+ }, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "jade", "handlebars");
+
+ CodeMirror.defineMIME("script/x-vue", "vue");
+});
diff --git a/data/ext/editorText/codemirror/mode/xml/index.html b/data/ext/editorText/codemirror/mode/xml/index.html
index 60ebd2017..7149f06b2 100644
--- a/data/ext/editorText/codemirror/mode/xml/index.html
+++ b/data/ext/editorText/codemirror/mode/xml/index.html
@@ -9,12 +9,12 @@
<script src="xml.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/xml/test.js b/data/ext/editorText/codemirror/mode/xml/test.js
index 1b9d9d176..f48156b51 100644
--- a/data/ext/editorText/codemirror/mode/xml/test.js
+++ b/data/ext/editorText/codemirror/mode/xml/test.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "xml"), mname = "xml";
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), mname); }
diff --git a/data/ext/editorText/codemirror/mode/xml/xml.js b/data/ext/editorText/codemirror/mode/xml/xml.js
index 920406334..5ad21720f 100644
--- a/data/ext/editorText/codemirror/mode/xml/xml.js
+++ b/data/ext/editorText/codemirror/mode/xml/xml.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("xml", function(config, parserConfig) {
var indentUnit = config.indentUnit;
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
@@ -8,7 +21,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
- 'track': true, 'wbr': true},
+ 'track': true, 'wbr': true, 'menuitem': true},
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
'th': true, 'tr': true},
@@ -96,6 +109,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
return null;
}
}
+ inText.isInText = true;
function inTag(stream, state) {
var ch = stream.next();
@@ -111,7 +125,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
state.state = baseState;
state.tagName = state.tagStart = null;
var next = state.tokenize(stream, state);
- return next ? next + " error" : "error";
+ return next ? next + " tag error" : "tag error";
} else if (/[\'\"]/.test(ch)) {
state.tokenize = inAttribute(ch);
state.stringStartCol = stream.column();
@@ -233,6 +247,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
return closeStateErr;
}
}
+
function closeState(type, _stream, state) {
if (type != "endTag") {
setStyle = "error";
@@ -326,7 +341,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
return state.tagStart + indentUnit * multilineTagIndentFactor;
}
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
- var tagAfter = textAfter && /^<(\/)?(\w*)/.exec(textAfter);
+ var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
if (tagAfter && tagAfter[1]) { // Closing tag spotted
while (context) {
if (context.tagName == tagAfter[2]) {
@@ -353,7 +368,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
else return 0;
},
- electricChars: "/",
+ electricInput: /<\/[\s\w:]+>$/,
blockCommentStart: "<!--",
blockCommentEnd: "-->",
@@ -366,3 +381,5 @@ CodeMirror.defineMIME("text/xml", "xml");
CodeMirror.defineMIME("application/xml", "xml");
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
+
+});
diff --git a/data/ext/editorText/codemirror/mode/xquery/index.html b/data/ext/editorText/codemirror/mode/xquery/index.html
index 3baf5e3e3..7ac5aaeff 100644
--- a/data/ext/editorText/codemirror/mode/xquery/index.html
+++ b/data/ext/editorText/codemirror/mode/xquery/index.html
@@ -15,12 +15,12 @@
}
</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/xquery/test.js b/data/ext/editorText/codemirror/mode/xquery/test.js
index 41719dd16..1f148cdbb 100644
--- a/data/ext/editorText/codemirror/mode/xquery/test.js
+++ b/data/ext/editorText/codemirror/mode/xquery/test.js
@@ -1,3 +1,6 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
// Don't take these too seriously -- the expected results appear to be
// based on the results of actual runs without any serious manual
// verification. If a change you made causes them to fail, the test is
diff --git a/data/ext/editorText/codemirror/mode/xquery/xquery.js b/data/ext/editorText/codemirror/mode/xquery/xquery.js
index be1798463..c642ee58f 100644
--- a/data/ext/editorText/codemirror/mode/xquery/xquery.js
+++ b/data/ext/editorText/codemirror/mode/xquery/xquery.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("xquery", function() {
// The keywords object is set to the result of this self executing
@@ -55,15 +68,6 @@ CodeMirror.defineMode("xquery", function() {
return kwObj;
}();
- // Used as scratch variables to communicate multiple values without
- // consing up tons of objects.
- var type, content;
-
- function ret(tp, style, cont) {
- type = tp; content = cont;
- return style;
- }
-
function chain(stream, state, f) {
state.tokenize = f;
return f(stream, state);
@@ -82,7 +86,7 @@ CodeMirror.defineMode("xquery", function() {
if(stream.match("![CDATA", false)) {
state.tokenize = tokenCDATA;
- return ret("tag", "tag");
+ return "tag";
}
if(stream.match("?", false)) {
@@ -99,28 +103,28 @@ CodeMirror.defineMode("xquery", function() {
// start code block
else if(ch == "{") {
pushStateStack(state,{ type: "codeblock"});
- return ret("", null);
+ return null;
}
// end code block
else if(ch == "}") {
popStateStack(state);
- return ret("", null);
+ return null;
}
// if we're in an XML block
else if(isInXmlBlock(state)) {
if(ch == ">")
- return ret("tag", "tag");
+ return "tag";
else if(ch == "/" && stream.eat(">")) {
popStateStack(state);
- return ret("tag", "tag");
+ return "tag";
}
else
- return ret("word", "variable");
+ return "variable";
}
// if a number
else if (/\d/.test(ch)) {
stream.match(/^\d*(?:\.\d*)?(?:E[+\-]?\d+)?/);
- return ret("number", "atom");
+ return "atom";
}
// comment start
else if (ch === "(" && stream.eat(":")) {
@@ -136,27 +140,27 @@ CodeMirror.defineMode("xquery", function() {
}
// assignment
else if(ch ===":" && stream.eat("=")) {
- return ret("operator", "keyword");
+ return "keyword";
}
// open paren
else if(ch === "(") {
pushStateStack(state, { type: "paren"});
- return ret("", null);
+ return null;
}
// close paren
else if(ch === ")") {
popStateStack(state);
- return ret("", null);
+ return null;
}
// open paren
else if(ch === "[") {
pushStateStack(state, { type: "bracket"});
- return ret("", null);
+ return null;
}
// close paren
else if(ch === "]") {
popStateStack(state);
- return ret("", null);
+ return null;
}
else {
var known = keywords.propertyIsEnumerable(ch) && keywords[ch];
@@ -191,15 +195,14 @@ CodeMirror.defineMode("xquery", function() {
// if the previous word was element, attribute, axis specifier, this word should be the name of that
if(isInXmlConstructor(state)) {
popStateStack(state);
- return ret("word", "variable", word);
+ return "variable";
}
// as previously checked, if the word is element,attribute, axis specifier, call it an "xmlconstructor" and
// push the stack so we know to look for it on the next word
if(word == "element" || word == "attribute" || known.type == "axis_specifier") pushStateStack(state, {type: "xmlconstructor"});
// if the word is known, return the details of that else just call this a generic 'word'
- return known ? ret(known.type, known.style, word) :
- ret("word", "variable", word);
+ return known ? known.style : "variable";
}
}
@@ -222,7 +225,7 @@ CodeMirror.defineMode("xquery", function() {
maybeNested = (ch == "(");
}
- return ret("comment", "comment");
+ return "comment";
}
// tokenizer for string literals
@@ -234,7 +237,7 @@ CodeMirror.defineMode("xquery", function() {
if(isInString(state) && stream.current() == quote) {
popStateStack(state);
if(f) state.tokenize = f;
- return ret("string", "string");
+ return "string";
}
pushStateStack(state, { type: "string", name: quote, tokenize: tokenString(quote, f) });
@@ -242,7 +245,7 @@ CodeMirror.defineMode("xquery", function() {
// if we're in a string and in an XML block, allow an embedded code block
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
state.tokenize = tokenBase;
- return ret("string", "string");
+ return "string";
}
@@ -256,13 +259,13 @@ CodeMirror.defineMode("xquery", function() {
// if we're in a string and in an XML block, allow an embedded code block in an attribute
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
state.tokenize = tokenBase;
- return ret("string", "string");
+ return "string";
}
}
}
- return ret("string", "string");
+ return "string";
};
}
@@ -280,7 +283,7 @@ CodeMirror.defineMode("xquery", function() {
}
stream.eatWhile(isVariableChar);
state.tokenize = tokenBase;
- return ret("variable", "variable");
+ return "variable";
}
// tokenizer for XML tags
@@ -290,19 +293,19 @@ CodeMirror.defineMode("xquery", function() {
if(isclose && stream.eat(">")) {
popStateStack(state);
state.tokenize = tokenBase;
- return ret("tag", "tag");
+ return "tag";
}
// self closing tag without attributes?
if(!stream.eat("/"))
pushStateStack(state, { type: "tag", name: name, tokenize: tokenBase});
if(!stream.eat(">")) {
state.tokenize = tokenAttribute;
- return ret("tag", "tag");
+ return "tag";
}
else {
state.tokenize = tokenBase;
}
- return ret("tag", "tag");
+ return "tag";
};
}
@@ -313,14 +316,14 @@ CodeMirror.defineMode("xquery", function() {
if(ch == "/" && stream.eat(">")) {
if(isInXmlAttributeBlock(state)) popStateStack(state);
if(isInXmlBlock(state)) popStateStack(state);
- return ret("tag", "tag");
+ return "tag";
}
if(ch == ">") {
if(isInXmlAttributeBlock(state)) popStateStack(state);
- return ret("tag", "tag");
+ return "tag";
}
if(ch == "=")
- return ret("", null);
+ return null;
// quoted string
if (ch == '"' || ch == "'")
return chain(stream, state, tokenString(ch, tokenAttribute));
@@ -338,7 +341,7 @@ CodeMirror.defineMode("xquery", function() {
state.tokenize = tokenBase;
}
- return ret("attribute", "attribute");
+ return "attribute";
}
// handle comments, including nested
@@ -347,7 +350,7 @@ CodeMirror.defineMode("xquery", function() {
while (ch = stream.next()) {
if (ch == "-" && stream.match("->", true)) {
state.tokenize = tokenBase;
- return ret("comment", "comment");
+ return "comment";
}
}
}
@@ -359,7 +362,7 @@ CodeMirror.defineMode("xquery", function() {
while (ch = stream.next()) {
if (ch == "]" && stream.match("]", true)) {
state.tokenize = tokenBase;
- return ret("comment", "comment");
+ return "comment";
}
}
}
@@ -370,7 +373,7 @@ CodeMirror.defineMode("xquery", function() {
while (ch = stream.next()) {
if (ch == "?" && stream.match(">", true)) {
state.tokenize = tokenBase;
- return ret("comment", "comment meta");
+ return "comment meta";
}
}
}
@@ -430,3 +433,5 @@ CodeMirror.defineMode("xquery", function() {
});
CodeMirror.defineMIME("application/xquery", "xquery");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/yaml/index.html b/data/ext/editorText/codemirror/mode/yaml/index.html
index bbb40a3c7..be9b63236 100644
--- a/data/ext/editorText/codemirror/mode/yaml/index.html
+++ b/data/ext/editorText/codemirror/mode/yaml/index.html
@@ -9,12 +9,12 @@
<script src="yaml.js"></script>
<style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
diff --git a/data/ext/editorText/codemirror/mode/yaml/yaml.js b/data/ext/editorText/codemirror/mode/yaml/yaml.js
index efacd7d56..b7015e599 100644
--- a/data/ext/editorText/codemirror/mode/yaml/yaml.js
+++ b/data/ext/editorText/codemirror/mode/yaml/yaml.js
@@ -1,3 +1,16 @@
+// 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";
+
CodeMirror.defineMode("yaml", function() {
var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
@@ -10,8 +23,13 @@ CodeMirror.defineMode("yaml", function() {
state.escaped = false;
/* comments */
if (ch == "#" && (stream.pos == 0 || /\s/.test(stream.string.charAt(stream.pos - 1)))) {
- stream.skipToEnd(); return "comment";
+ stream.skipToEnd();
+ return "comment";
}
+
+ if (stream.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))
+ return "string";
+
if (state.literal && stream.indentation() > state.keyCol) {
stream.skipToEnd(); return "string";
} else if (state.literal) { state.literal = false; }
@@ -67,7 +85,7 @@ CodeMirror.defineMode("yaml", function() {
}
/* pairs (associative arrays) -> key */
- if (!state.pair && stream.match(/^\s*\S+(?=\s*:($|\s))/i)) {
+ if (!state.pair && stream.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)) {
state.pair = true;
state.keyCol = stream.indentation();
return "atom";
@@ -95,3 +113,5 @@ CodeMirror.defineMode("yaml", function() {
});
CodeMirror.defineMIME("text/x-yaml", "yaml");
+
+});
diff --git a/data/ext/editorText/codemirror/mode/z80/index.html b/data/ext/editorText/codemirror/mode/z80/index.html
index b63c9621a..a41b7473e 100644
--- a/data/ext/editorText/codemirror/mode/z80/index.html
+++ b/data/ext/editorText/codemirror/mode/z80/index.html
@@ -9,12 +9,12 @@
<script src="z80.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
- <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
+ <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
- <li><a href="https://github.com/marijnh/codemirror">Code</a>
+ <li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
@@ -29,17 +29,18 @@
<div><textarea id="code" name="code">
#include "ti83plus.inc"
#define progStart $9D95
-.org progStart-2
-.db $BB,$6D
+ .org progStart-2
+ .db $BB,$6D
+
bcall(_ClrLCDFull)
- ld HL, 0
- ld (PenCol), HL
- ld HL, Message
+ ld hl,0
+ ld (CurCol),hl
+ ld hl,Message
bcall(_PutS) ; Displays the string
bcall(_NewLine)
ret
Message:
-.db "Hello world!",0
+ .db "Hello world!",0
</textarea></div>
<script>
@@ -48,5 +49,5 @@ Message:
});
</script>
- <p><strong>MIME type defined:</strong> <code>text/x-z80</code>.</p>
+ <p><strong>MIME types defined:</strong> <code>text/x-z80</code>, <code>text/x-ez80</code>.</p>
</article>
diff --git a/data/ext/editorText/codemirror/mode/z80/z80.js b/data/ext/editorText/codemirror/mode/z80/z80.js
index ff43d32b5..aae70216f 100644
--- a/data/ext/editorText/codemirror/mode/z80/z80.js
+++ b/data/ext/editorText/codemirror/mode/z80/z80.js
@@ -1,15 +1,37 @@
-CodeMirror.defineMode('z80', function() {
- var keywords1 = /^(exx?|(ld|cp|in)([di]r?)?|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|rst|[de]i|halt|im|ot[di]r|out[di]?)\b/i;
- var keywords2 = /^(call|j[pr]|ret[in]?)\b/i;
- var keywords3 = /^b_?(call|jump)\b/i;
+// 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";
+
+CodeMirror.defineMode('z80', function(_config, parserConfig) {
+ var ez80 = parserConfig.ez80;
+ var keywords1, keywords2;
+ if (ez80) {
+ keywords1 = /^(exx?|(ld|cp)([di]r?)?|[lp]ea|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|[de]i|halt|im|in([di]mr?|ir?|irx|2r?)|ot(dmr?|[id]rx|imr?)|out(0?|[di]r?|[di]2r?)|tst(io)?|slp)(\.([sl]?i)?[sl])?\b/i;
+ keywords2 = /^(((call|j[pr]|rst|ret[in]?)(\.([sl]?i)?[sl])?)|(rs|st)mix)\b/i;
+ } else {
+ keywords1 = /^(exx?|(ld|cp|in)([di]r?)?|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|rst|[de]i|halt|im|ot[di]r|out[di]?)\b/i;
+ keywords2 = /^(call|j[pr]|ret[in]?|b_?(call|jump))\b/i;
+ }
+
var variables1 = /^(af?|bc?|c|de?|e|hl?|l|i[xy]?|r|sp)\b/i;
var variables2 = /^(n?[zc]|p[oe]?|m)\b/i;
var errors = /^([hl][xy]|i[xy][hl]|slia|sll)\b/i;
- var numbers = /^([\da-f]+h|[0-7]+o|[01]+b|\d+)\b/i;
+ var numbers = /^([\da-f]+h|[0-7]+o|[01]+b|\d+d?)\b/i;
return {
startState: function() {
- return {context: 0};
+ return {
+ context: 0
+ };
},
token: function(stream, state) {
if (!stream.column())
@@ -21,14 +43,21 @@ CodeMirror.defineMode('z80', function() {
var w;
if (stream.eatWhile(/\w/)) {
+ if (ez80 && stream.eat('.')) {
+ stream.eatWhile(/\w/);
+ }
w = stream.current();
if (stream.indentation()) {
- if (state.context == 1 && variables1.test(w))
- return 'variable-2';
+ if ((state.context == 1 || state.context == 4) && variables1.test(w)) {
+ state.context = 4;
+ return 'var2';
+ }
- if (state.context == 2 && variables2.test(w))
- return 'variable-3';
+ if (state.context == 2 && variables2.test(w)) {
+ state.context = 4;
+ return 'var3';
+ }
if (keywords1.test(w)) {
state.context = 1;
@@ -36,14 +65,13 @@ CodeMirror.defineMode('z80', function() {
} else if (keywords2.test(w)) {
state.context = 2;
return 'keyword';
- } else if (keywords3.test(w)) {
- state.context = 3;
- return 'keyword';
+ } else if (state.context == 4 && numbers.test(w)) {
+ return 'number';
}
if (errors.test(w))
return 'error';
- } else if (numbers.test(w)) {
+ } else if (stream.match(numbers)) {
return 'number';
} else {
return null;
@@ -64,7 +92,7 @@ CodeMirror.defineMode('z80', function() {
if (stream.match(/\\?.'/))
return 'number';
} else if (stream.eat('.') || stream.sol() && stream.eat('#')) {
- state.context = 4;
+ state.context = 5;
if (stream.eatWhile(/\w/))
return 'def';
@@ -83,3 +111,6 @@ CodeMirror.defineMode('z80', function() {
});
CodeMirror.defineMIME("text/x-z80", "z80");
+CodeMirror.defineMIME("text/x-ez80", { name: "z80", ez80: true });
+
+});
diff --git a/data/ext/editorText/codemirror/theme/3024-day.css b/data/ext/editorText/codemirror/theme/3024-day.css
index cbb9a4fa4..713265530 100644
--- a/data/ext/editorText/codemirror/theme/3024-day.css
+++ b/data/ext/editorText/codemirror/theme/3024-day.css
@@ -8,27 +8,34 @@
*/
-.cm-s-3024-day.CodeMirror {background: #f7f7f7; color: #3a3432;}
-.cm-s-3024-day div.CodeMirror-selected {background: #d6d5d4 !important;}
-.cm-s-3024-day .CodeMirror-gutters {background: #f7f7f7; border-right: 0px;}
-.cm-s-3024-day .CodeMirror-linenumber {color: #807d7c;}
-.cm-s-3024-day .CodeMirror-cursor {border-left: 1px solid #5c5855 !important;}
-
-.cm-s-3024-day span.cm-comment {color: #cdab53;}
-.cm-s-3024-day span.cm-atom {color: #a16a94;}
-.cm-s-3024-day span.cm-number {color: #a16a94;}
-
-.cm-s-3024-day span.cm-property, .cm-s-3024-day span.cm-attribute {color: #01a252;}
-.cm-s-3024-day span.cm-keyword {color: #db2d20;}
-.cm-s-3024-day span.cm-string {color: #fded02;}
-
-.cm-s-3024-day span.cm-variable {color: #01a252;}
-.cm-s-3024-day span.cm-variable-2 {color: #01a0e4;}
-.cm-s-3024-day span.cm-def {color: #e8bbd0;}
-.cm-s-3024-day span.cm-bracket {color: #3a3432;}
-.cm-s-3024-day span.cm-tag {color: #db2d20;}
-.cm-s-3024-day span.cm-link {color: #a16a94;}
-.cm-s-3024-day span.cm-error {background: #db2d20; color: #5c5855;}
-
-.cm-s-3024-day .CodeMirror-activeline-background {background: #e8f2ff !important;}
-.cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-3024-day.CodeMirror { background: #f7f7f7; color: #3a3432; }
+.cm-s-3024-day div.CodeMirror-selected { background: #d6d5d4; }
+
+.cm-s-3024-day .CodeMirror-line::selection, .cm-s-3024-day .CodeMirror-line > span::selection, .cm-s-3024-day .CodeMirror-line > span > span::selection { background: #d6d5d4; }
+.cm-s-3024-day .CodeMirror-line::-moz-selection, .cm-s-3024-day .CodeMirror-line > span::-moz-selection, .cm-s-3024-day .CodeMirror-line > span > span::selection { background: #d9d9d9; }
+
+.cm-s-3024-day .CodeMirror-gutters { background: #f7f7f7; border-right: 0px; }
+.cm-s-3024-day .CodeMirror-guttermarker { color: #db2d20; }
+.cm-s-3024-day .CodeMirror-guttermarker-subtle { color: #807d7c; }
+.cm-s-3024-day .CodeMirror-linenumber { color: #807d7c; }
+
+.cm-s-3024-day .CodeMirror-cursor { border-left: 1px solid #5c5855; }
+
+.cm-s-3024-day span.cm-comment { color: #cdab53; }
+.cm-s-3024-day span.cm-atom { color: #a16a94; }
+.cm-s-3024-day span.cm-number { color: #a16a94; }
+
+.cm-s-3024-day span.cm-property, .cm-s-3024-day span.cm-attribute { color: #01a252; }
+.cm-s-3024-day span.cm-keyword { color: #db2d20; }
+.cm-s-3024-day span.cm-string { color: #fded02; }
+
+.cm-s-3024-day span.cm-variable { color: #01a252; }
+.cm-s-3024-day span.cm-variable-2 { color: #01a0e4; }
+.cm-s-3024-day span.cm-def { color: #e8bbd0; }
+.cm-s-3024-day span.cm-bracket { color: #3a3432; }
+.cm-s-3024-day span.cm-tag { color: #db2d20; }
+.cm-s-3024-day span.cm-link { color: #a16a94; }
+.cm-s-3024-day span.cm-error { background: #db2d20; color: #5c5855; }
+
+.cm-s-3024-day .CodeMirror-activeline-background { background: #e8f2ff; }
+.cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: #a16a94 !important; }
diff --git a/data/ext/editorText/codemirror/theme/3024-night.css b/data/ext/editorText/codemirror/theme/3024-night.css
index 2c62e221b..adc5900ad 100644
--- a/data/ext/editorText/codemirror/theme/3024-night.css
+++ b/data/ext/editorText/codemirror/theme/3024-night.css
@@ -8,27 +8,32 @@
*/
-.cm-s-3024-night.CodeMirror {background: #090300; color: #d6d5d4;}
-.cm-s-3024-night div.CodeMirror-selected {background: #3a3432 !important;}
-.cm-s-3024-night .CodeMirror-gutters {background: #090300; border-right: 0px;}
-.cm-s-3024-night .CodeMirror-linenumber {color: #5c5855;}
-.cm-s-3024-night .CodeMirror-cursor {border-left: 1px solid #807d7c !important;}
-
-.cm-s-3024-night span.cm-comment {color: #cdab53;}
-.cm-s-3024-night span.cm-atom {color: #a16a94;}
-.cm-s-3024-night span.cm-number {color: #a16a94;}
-
-.cm-s-3024-night span.cm-property, .cm-s-3024-night span.cm-attribute {color: #01a252;}
-.cm-s-3024-night span.cm-keyword {color: #db2d20;}
-.cm-s-3024-night span.cm-string {color: #fded02;}
-
-.cm-s-3024-night span.cm-variable {color: #01a252;}
-.cm-s-3024-night span.cm-variable-2 {color: #01a0e4;}
-.cm-s-3024-night span.cm-def {color: #e8bbd0;}
-.cm-s-3024-night span.cm-bracket {color: #d6d5d4;}
-.cm-s-3024-night span.cm-tag {color: #db2d20;}
-.cm-s-3024-night span.cm-link {color: #a16a94;}
-.cm-s-3024-night span.cm-error {background: #db2d20; color: #807d7c;}
-
-.cm-s-3024-night .CodeMirror-activeline-background {background: #2F2F2F !important;}
-.cm-s-3024-night .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-3024-night.CodeMirror { background: #090300; color: #d6d5d4; }
+.cm-s-3024-night div.CodeMirror-selected { background: #3a3432; }
+.cm-s-3024-night .CodeMirror-line::selection, .cm-s-3024-night .CodeMirror-line > span::selection, .cm-s-3024-night .CodeMirror-line > span > span::selection { background: rgba(58, 52, 50, .99); }
+.cm-s-3024-night .CodeMirror-line::-moz-selection, .cm-s-3024-night .CodeMirror-line > span::-moz-selection, .cm-s-3024-night .CodeMirror-line > span > span::-moz-selection { background: rgba(58, 52, 50, .99); }
+.cm-s-3024-night .CodeMirror-gutters { background: #090300; border-right: 0px; }
+.cm-s-3024-night .CodeMirror-guttermarker { color: #db2d20; }
+.cm-s-3024-night .CodeMirror-guttermarker-subtle { color: #5c5855; }
+.cm-s-3024-night .CodeMirror-linenumber { color: #5c5855; }
+
+.cm-s-3024-night .CodeMirror-cursor { border-left: 1px solid #807d7c; }
+
+.cm-s-3024-night span.cm-comment { color: #cdab53; }
+.cm-s-3024-night span.cm-atom { color: #a16a94; }
+.cm-s-3024-night span.cm-number { color: #a16a94; }
+
+.cm-s-3024-night span.cm-property, .cm-s-3024-night span.cm-attribute { color: #01a252; }
+.cm-s-3024-night span.cm-keyword { color: #db2d20; }
+.cm-s-3024-night span.cm-string { color: #fded02; }
+
+.cm-s-3024-night span.cm-variable { color: #01a252; }
+.cm-s-3024-night span.cm-variable-2 { color: #01a0e4; }
+.cm-s-3024-night span.cm-def { color: #e8bbd0; }
+.cm-s-3024-night span.cm-bracket { color: #d6d5d4; }
+.cm-s-3024-night span.cm-tag { color: #db2d20; }
+.cm-s-3024-night span.cm-link { color: #a16a94; }
+.cm-s-3024-night span.cm-error { background: #db2d20; color: #807d7c; }
+
+.cm-s-3024-night .CodeMirror-activeline-background { background: #2F2F2F; }
+.cm-s-3024-night .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
diff --git a/data/ext/editorText/codemirror/theme/abcdef.css b/data/ext/editorText/codemirror/theme/abcdef.css
new file mode 100644
index 000000000..7f9d78870
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/abcdef.css
@@ -0,0 +1,32 @@
+.cm-s-abcdef.CodeMirror { background: #0f0f0f; color: #defdef; }
+.cm-s-abcdef div.CodeMirror-selected { background: #515151; }
+.cm-s-abcdef .CodeMirror-line::selection, .cm-s-abcdef .CodeMirror-line > span::selection, .cm-s-abcdef .CodeMirror-line > span > span::selection { background: rgba(56, 56, 56, 0.99); }
+.cm-s-abcdef .CodeMirror-line::-moz-selection, .cm-s-abcdef .CodeMirror-line > span::-moz-selection, .cm-s-abcdef .CodeMirror-line > span > span::-moz-selection { background: rgba(56, 56, 56, 0.99); }
+.cm-s-abcdef .CodeMirror-gutters { background: #555; border-right: 2px solid #314151; }
+.cm-s-abcdef .CodeMirror-guttermarker { color: #222; }
+.cm-s-abcdef .CodeMirror-guttermarker-subtle { color: azure; }
+.cm-s-abcdef .CodeMirror-linenumber { color: #FFFFFF; }
+.cm-s-abcdef .CodeMirror-cursor { border-left: 1px solid #00FF00; }
+
+.cm-s-abcdef span.cm-keyword { color: darkgoldenrod; font-weight: bold; }
+.cm-s-abcdef span.cm-atom { color: #77F; }
+.cm-s-abcdef span.cm-number { color: violet; }
+.cm-s-abcdef span.cm-def { color: #fffabc; }
+.cm-s-abcdef span.cm-variable { color: #abcdef; }
+.cm-s-abcdef span.cm-variable-2 { color: #cacbcc; }
+.cm-s-abcdef span.cm-variable-3 { color: #def; }
+.cm-s-abcdef span.cm-property { color: #fedcba; }
+.cm-s-abcdef span.cm-operator { color: #ff0; }
+.cm-s-abcdef span.cm-comment { color: #7a7b7c; font-style: italic;}
+.cm-s-abcdef span.cm-string { color: #2b4; }
+.cm-s-abcdef span.cm-meta { color: #C9F; }
+.cm-s-abcdef span.cm-qualifier { color: #FFF700; }
+.cm-s-abcdef span.cm-builtin { color: #30aabc; }
+.cm-s-abcdef span.cm-bracket { color: #8a8a8a; }
+.cm-s-abcdef span.cm-tag { color: #FFDD44; }
+.cm-s-abcdef span.cm-attribute { color: #DDFF00; }
+.cm-s-abcdef span.cm-error { color: #FF0000; }
+.cm-s-abcdef span.cm-header { color: aquamarine; font-weight: bold; }
+.cm-s-abcdef span.cm-link { color: blueviolet; }
+
+.cm-s-abcdef .CodeMirror-activeline-background { background: #314151; }
diff --git a/data/ext/editorText/codemirror/theme/ambiance.css b/data/ext/editorText/codemirror/theme/ambiance.css
index 48ba091fb..bce344649 100644
--- a/data/ext/editorText/codemirror/theme/ambiance.css
+++ b/data/ext/editorText/codemirror/theme/ambiance.css
@@ -2,6 +2,9 @@
/* Color scheme */
+.cm-s-ambiance .cm-header { color: blue; }
+.cm-s-ambiance .cm-quote { color: #24C2C7; }
+
.cm-s-ambiance .cm-keyword { color: #cda869; }
.cm-s-ambiance .cm-atom { color: #CF7EA9; }
.cm-s-ambiance .cm-number { color: #78CF8A; }
@@ -10,7 +13,7 @@
.cm-s-ambiance .cm-variable-2 { color: #eed1b3; }
.cm-s-ambiance .cm-variable-3 { color: #faded3; }
.cm-s-ambiance .cm-property { color: #eed1b3; }
-.cm-s-ambiance .cm-operator {color: #fa8d6a;}
+.cm-s-ambiance .cm-operator { color: #fa8d6a; }
.cm-s-ambiance .cm-comment { color: #555; font-style:italic; }
.cm-s-ambiance .cm-string { color: #8f9d6a; }
.cm-s-ambiance .cm-string-2 { color: #9d937c; }
@@ -18,10 +21,8 @@
.cm-s-ambiance .cm-qualifier { color: yellow; }
.cm-s-ambiance .cm-builtin { color: #9999cc; }
.cm-s-ambiance .cm-bracket { color: #24C2C7; }
-.cm-s-ambiance .cm-tag { color: #fee4ff }
-.cm-s-ambiance .cm-attribute { color: #9B859D; }
-.cm-s-ambiance .cm-header {color: blue;}
-.cm-s-ambiance .cm-quote { color: #24C2C7; }
+.cm-s-ambiance .cm-tag { color: #fee4ff; }
+.cm-s-ambiance .cm-attribute { color: #9B859D; }
.cm-s-ambiance .cm-hr { color: pink; }
.cm-s-ambiance .cm-link { color: #F4C20B; }
.cm-s-ambiance .cm-special { color: #FF9D00; }
@@ -30,12 +31,10 @@
.cm-s-ambiance .CodeMirror-matchingbracket { color: #0f0; }
.cm-s-ambiance .CodeMirror-nonmatchingbracket { color: #f22; }
-.cm-s-ambiance .CodeMirror-selected {
- background: rgba(255, 255, 255, 0.15);
-}
-.cm-s-ambiance.CodeMirror-focused .CodeMirror-selected {
- background: rgba(255, 255, 255, 0.10);
-}
+.cm-s-ambiance div.CodeMirror-selected { background: rgba(255, 255, 255, 0.15); }
+.cm-s-ambiance.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
+.cm-s-ambiance .CodeMirror-line::selection, .cm-s-ambiance .CodeMirror-line > span::selection, .cm-s-ambiance .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
+.cm-s-ambiance .CodeMirror-line::-moz-selection, .cm-s-ambiance .CodeMirror-line > span::-moz-selection, .cm-s-ambiance .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
/* Editor styling */
@@ -56,13 +55,14 @@
.cm-s-ambiance .CodeMirror-linenumber {
text-shadow: 0px 1px 1px #4d4d4d;
- color: #222;
+ color: #111;
padding: 0 5px;
}
-.cm-s-ambiance .CodeMirror-lines .CodeMirror-cursor {
- border-left: 1px solid #7991E8;
-}
+.cm-s-ambiance .CodeMirror-guttermarker { color: #aaa; }
+.cm-s-ambiance .CodeMirror-guttermarker-subtle { color: #111; }
+
+.cm-s-ambiance .CodeMirror-cursor { border-left: 1px solid #7991E8; }
.cm-s-ambiance .CodeMirror-activeline-background {
background: none repeat scroll 0% 0% rgba(255, 255, 255, 0.031);
diff --git a/data/ext/editorText/codemirror/theme/base16-dark.css b/data/ext/editorText/codemirror/theme/base16-dark.css
index 3b7b21c7a..026a81689 100644
--- a/data/ext/editorText/codemirror/theme/base16-dark.css
+++ b/data/ext/editorText/codemirror/theme/base16-dark.css
@@ -3,32 +3,36 @@
Name: Base16 Default Dark
Author: Chris Kempson (http://chriskempson.com)
- CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
+ CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
*/
-.cm-s-base16-dark.CodeMirror {background: #151515; color: #e0e0e0;}
-.cm-s-base16-dark div.CodeMirror-selected {background: #202020 !important;}
-.cm-s-base16-dark .CodeMirror-gutters {background: #151515; border-right: 0px;}
-.cm-s-base16-dark .CodeMirror-linenumber {color: #505050;}
-.cm-s-base16-dark .CodeMirror-cursor {border-left: 1px solid #b0b0b0 !important;}
-
-.cm-s-base16-dark span.cm-comment {color: #8f5536;}
-.cm-s-base16-dark span.cm-atom {color: #aa759f;}
-.cm-s-base16-dark span.cm-number {color: #aa759f;}
-
-.cm-s-base16-dark span.cm-property, .cm-s-base16-dark span.cm-attribute {color: #90a959;}
-.cm-s-base16-dark span.cm-keyword {color: #ac4142;}
-.cm-s-base16-dark span.cm-string {color: #f4bf75;}
-
-.cm-s-base16-dark span.cm-variable {color: #90a959;}
-.cm-s-base16-dark span.cm-variable-2 {color: #6a9fb5;}
-.cm-s-base16-dark span.cm-def {color: #d28445;}
-.cm-s-base16-dark span.cm-bracket {color: #e0e0e0;}
-.cm-s-base16-dark span.cm-tag {color: #ac4142;}
-.cm-s-base16-dark span.cm-link {color: #aa759f;}
-.cm-s-base16-dark span.cm-error {background: #ac4142; color: #b0b0b0;}
-
-.cm-s-base16-dark .CodeMirror-activeline-background {background: #2F2F2F !important;}
-.cm-s-base16-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-base16-dark.CodeMirror { background: #151515; color: #e0e0e0; }
+.cm-s-base16-dark div.CodeMirror-selected { background: #303030; }
+.cm-s-base16-dark .CodeMirror-line::selection, .cm-s-base16-dark .CodeMirror-line > span::selection, .cm-s-base16-dark .CodeMirror-line > span > span::selection { background: rgba(48, 48, 48, .99); }
+.cm-s-base16-dark .CodeMirror-line::-moz-selection, .cm-s-base16-dark .CodeMirror-line > span::-moz-selection, .cm-s-base16-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(48, 48, 48, .99); }
+.cm-s-base16-dark .CodeMirror-gutters { background: #151515; border-right: 0px; }
+.cm-s-base16-dark .CodeMirror-guttermarker { color: #ac4142; }
+.cm-s-base16-dark .CodeMirror-guttermarker-subtle { color: #505050; }
+.cm-s-base16-dark .CodeMirror-linenumber { color: #505050; }
+.cm-s-base16-dark .CodeMirror-cursor { border-left: 1px solid #b0b0b0; }
+
+.cm-s-base16-dark span.cm-comment { color: #8f5536; }
+.cm-s-base16-dark span.cm-atom { color: #aa759f; }
+.cm-s-base16-dark span.cm-number { color: #aa759f; }
+
+.cm-s-base16-dark span.cm-property, .cm-s-base16-dark span.cm-attribute { color: #90a959; }
+.cm-s-base16-dark span.cm-keyword { color: #ac4142; }
+.cm-s-base16-dark span.cm-string { color: #f4bf75; }
+
+.cm-s-base16-dark span.cm-variable { color: #90a959; }
+.cm-s-base16-dark span.cm-variable-2 { color: #6a9fb5; }
+.cm-s-base16-dark span.cm-def { color: #d28445; }
+.cm-s-base16-dark span.cm-bracket { color: #e0e0e0; }
+.cm-s-base16-dark span.cm-tag { color: #ac4142; }
+.cm-s-base16-dark span.cm-link { color: #aa759f; }
+.cm-s-base16-dark span.cm-error { background: #ac4142; color: #b0b0b0; }
+
+.cm-s-base16-dark .CodeMirror-activeline-background { background: #202020; }
+.cm-s-base16-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
diff --git a/data/ext/editorText/codemirror/theme/base16-light.css b/data/ext/editorText/codemirror/theme/base16-light.css
index 5aa4b5389..474e0ca9d 100644
--- a/data/ext/editorText/codemirror/theme/base16-light.css
+++ b/data/ext/editorText/codemirror/theme/base16-light.css
@@ -3,32 +3,36 @@
Name: Base16 Default Light
Author: Chris Kempson (http://chriskempson.com)
- CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
+ CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
*/
-.cm-s-base16-light.CodeMirror {background: #f5f5f5; color: #202020;}
-.cm-s-base16-light div.CodeMirror-selected {background: #e0e0e0 !important;}
-.cm-s-base16-light .CodeMirror-gutters {background: #f5f5f5; border-right: 0px;}
-.cm-s-base16-light .CodeMirror-linenumber {color: #b0b0b0;}
-.cm-s-base16-light .CodeMirror-cursor {border-left: 1px solid #505050 !important;}
-
-.cm-s-base16-light span.cm-comment {color: #8f5536;}
-.cm-s-base16-light span.cm-atom {color: #aa759f;}
-.cm-s-base16-light span.cm-number {color: #aa759f;}
-
-.cm-s-base16-light span.cm-property, .cm-s-base16-light span.cm-attribute {color: #90a959;}
-.cm-s-base16-light span.cm-keyword {color: #ac4142;}
-.cm-s-base16-light span.cm-string {color: #f4bf75;}
-
-.cm-s-base16-light span.cm-variable {color: #90a959;}
-.cm-s-base16-light span.cm-variable-2 {color: #6a9fb5;}
-.cm-s-base16-light span.cm-def {color: #d28445;}
-.cm-s-base16-light span.cm-bracket {color: #202020;}
-.cm-s-base16-light span.cm-tag {color: #ac4142;}
-.cm-s-base16-light span.cm-link {color: #aa759f;}
-.cm-s-base16-light span.cm-error {background: #ac4142; color: #505050;}
-
-.cm-s-base16-light .CodeMirror-activeline-background {background: #DDDCDC !important;}
-.cm-s-base16-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-base16-light.CodeMirror { background: #f5f5f5; color: #202020; }
+.cm-s-base16-light div.CodeMirror-selected { background: #e0e0e0; }
+.cm-s-base16-light .CodeMirror-line::selection, .cm-s-base16-light .CodeMirror-line > span::selection, .cm-s-base16-light .CodeMirror-line > span > span::selection { background: #e0e0e0; }
+.cm-s-base16-light .CodeMirror-line::-moz-selection, .cm-s-base16-light .CodeMirror-line > span::-moz-selection, .cm-s-base16-light .CodeMirror-line > span > span::-moz-selection { background: #e0e0e0; }
+.cm-s-base16-light .CodeMirror-gutters { background: #f5f5f5; border-right: 0px; }
+.cm-s-base16-light .CodeMirror-guttermarker { color: #ac4142; }
+.cm-s-base16-light .CodeMirror-guttermarker-subtle { color: #b0b0b0; }
+.cm-s-base16-light .CodeMirror-linenumber { color: #b0b0b0; }
+.cm-s-base16-light .CodeMirror-cursor { border-left: 1px solid #505050; }
+
+.cm-s-base16-light span.cm-comment { color: #8f5536; }
+.cm-s-base16-light span.cm-atom { color: #aa759f; }
+.cm-s-base16-light span.cm-number { color: #aa759f; }
+
+.cm-s-base16-light span.cm-property, .cm-s-base16-light span.cm-attribute { color: #90a959; }
+.cm-s-base16-light span.cm-keyword { color: #ac4142; }
+.cm-s-base16-light span.cm-string { color: #f4bf75; }
+
+.cm-s-base16-light span.cm-variable { color: #90a959; }
+.cm-s-base16-light span.cm-variable-2 { color: #6a9fb5; }
+.cm-s-base16-light span.cm-def { color: #d28445; }
+.cm-s-base16-light span.cm-bracket { color: #202020; }
+.cm-s-base16-light span.cm-tag { color: #ac4142; }
+.cm-s-base16-light span.cm-link { color: #aa759f; }
+.cm-s-base16-light span.cm-error { background: #ac4142; color: #505050; }
+
+.cm-s-base16-light .CodeMirror-activeline-background { background: #DDDCDC; }
+.cm-s-base16-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
diff --git a/data/ext/editorText/codemirror/theme/bespin.css b/data/ext/editorText/codemirror/theme/bespin.css
new file mode 100644
index 000000000..60913ba93
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/bespin.css
@@ -0,0 +1,34 @@
+/*
+
+ Name: Bespin
+ Author: Mozilla / Jan T. Sott
+
+ CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
+ Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
+
+*/
+
+.cm-s-bespin.CodeMirror {background: #28211c; color: #9d9b97;}
+.cm-s-bespin div.CodeMirror-selected {background: #36312e !important;}
+.cm-s-bespin .CodeMirror-gutters {background: #28211c; border-right: 0px;}
+.cm-s-bespin .CodeMirror-linenumber {color: #666666;}
+.cm-s-bespin .CodeMirror-cursor {border-left: 1px solid #797977 !important;}
+
+.cm-s-bespin span.cm-comment {color: #937121;}
+.cm-s-bespin span.cm-atom {color: #9b859d;}
+.cm-s-bespin span.cm-number {color: #9b859d;}
+
+.cm-s-bespin span.cm-property, .cm-s-bespin span.cm-attribute {color: #54be0d;}
+.cm-s-bespin span.cm-keyword {color: #cf6a4c;}
+.cm-s-bespin span.cm-string {color: #f9ee98;}
+
+.cm-s-bespin span.cm-variable {color: #54be0d;}
+.cm-s-bespin span.cm-variable-2 {color: #5ea6ea;}
+.cm-s-bespin span.cm-def {color: #cf7d34;}
+.cm-s-bespin span.cm-error {background: #cf6a4c; color: #797977;}
+.cm-s-bespin span.cm-bracket {color: #9d9b97;}
+.cm-s-bespin span.cm-tag {color: #cf6a4c;}
+.cm-s-bespin span.cm-link {color: #9b859d;}
+
+.cm-s-bespin .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-bespin .CodeMirror-activeline-background { background: #404040; }
diff --git a/data/ext/editorText/codemirror/theme/blackboard.css b/data/ext/editorText/codemirror/theme/blackboard.css
index 8b7608472..b6eaedb18 100644
--- a/data/ext/editorText/codemirror/theme/blackboard.css
+++ b/data/ext/editorText/codemirror/theme/blackboard.css
@@ -1,17 +1,21 @@
/* Port of TextMate's Blackboard theme */
.cm-s-blackboard.CodeMirror { background: #0C1021; color: #F8F8F8; }
-.cm-s-blackboard .CodeMirror-selected { background: #253B76 !important; }
+.cm-s-blackboard div.CodeMirror-selected { background: #253B76; }
+.cm-s-blackboard .CodeMirror-line::selection, .cm-s-blackboard .CodeMirror-line > span::selection, .cm-s-blackboard .CodeMirror-line > span > span::selection { background: rgba(37, 59, 118, .99); }
+.cm-s-blackboard .CodeMirror-line::-moz-selection, .cm-s-blackboard .CodeMirror-line > span::-moz-selection, .cm-s-blackboard .CodeMirror-line > span > span::-moz-selection { background: rgba(37, 59, 118, .99); }
.cm-s-blackboard .CodeMirror-gutters { background: #0C1021; border-right: 0; }
+.cm-s-blackboard .CodeMirror-guttermarker { color: #FBDE2D; }
+.cm-s-blackboard .CodeMirror-guttermarker-subtle { color: #888; }
.cm-s-blackboard .CodeMirror-linenumber { color: #888; }
-.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7 !important; }
+.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7; }
.cm-s-blackboard .cm-keyword { color: #FBDE2D; }
.cm-s-blackboard .cm-atom { color: #D8FA3C; }
.cm-s-blackboard .cm-number { color: #D8FA3C; }
.cm-s-blackboard .cm-def { color: #8DA6CE; }
.cm-s-blackboard .cm-variable { color: #FF6400; }
-.cm-s-blackboard .cm-operator { color: #FBDE2D;}
+.cm-s-blackboard .cm-operator { color: #FBDE2D; }
.cm-s-blackboard .cm-comment { color: #AEAEAE; }
.cm-s-blackboard .cm-string { color: #61CE3C; }
.cm-s-blackboard .cm-string-2 { color: #61CE3C; }
@@ -24,5 +28,5 @@
.cm-s-blackboard .cm-link { color: #8DA6CE; }
.cm-s-blackboard .cm-error { background: #9D1E15; color: #F8F8F8; }
-.cm-s-blackboard .CodeMirror-activeline-background {background: #3C3636 !important;}
-.cm-s-blackboard .CodeMirror-matchingbracket {outline:1px solid grey;color:white !important}
\ No newline at end of file
+.cm-s-blackboard .CodeMirror-activeline-background { background: #3C3636; }
+.cm-s-blackboard .CodeMirror-matchingbracket { outline:1px solid grey;color:white !important; }
diff --git a/data/ext/editorText/codemirror/theme/cobalt.css b/data/ext/editorText/codemirror/theme/cobalt.css
index b4a917736..d88223ed8 100644
--- a/data/ext/editorText/codemirror/theme/cobalt.css
+++ b/data/ext/editorText/codemirror/theme/cobalt.css
@@ -1,8 +1,12 @@
.cm-s-cobalt.CodeMirror { background: #002240; color: white; }
-.cm-s-cobalt div.CodeMirror-selected { background: #b36539 !important; }
+.cm-s-cobalt div.CodeMirror-selected { background: #b36539; }
+.cm-s-cobalt .CodeMirror-line::selection, .cm-s-cobalt .CodeMirror-line > span::selection, .cm-s-cobalt .CodeMirror-line > span > span::selection { background: rgba(179, 101, 57, .99); }
+.cm-s-cobalt .CodeMirror-line::-moz-selection, .cm-s-cobalt .CodeMirror-line > span::-moz-selection, .cm-s-cobalt .CodeMirror-line > span > span::-moz-selection { background: rgba(179, 101, 57, .99); }
.cm-s-cobalt .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
+.cm-s-cobalt .CodeMirror-guttermarker { color: #ffee80; }
+.cm-s-cobalt .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
.cm-s-cobalt .CodeMirror-linenumber { color: #d0d0d0; }
-.cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white !important; }
+.cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white; }
.cm-s-cobalt span.cm-comment { color: #08f; }
.cm-s-cobalt span.cm-atom { color: #845dc4; }
@@ -17,5 +21,5 @@
.cm-s-cobalt span.cm-link { color: #845dc4; }
.cm-s-cobalt span.cm-error { color: #9d1e15; }
-.cm-s-cobalt .CodeMirror-activeline-background {background: #002D57 !important;}
-.cm-s-cobalt .CodeMirror-matchingbracket {outline:1px solid grey;color:white !important}
+.cm-s-cobalt .CodeMirror-activeline-background { background: #002D57; }
+.cm-s-cobalt .CodeMirror-matchingbracket { outline:1px solid grey;color:white !important; }
diff --git a/data/ext/editorText/codemirror/theme/colorforth.css b/data/ext/editorText/codemirror/theme/colorforth.css
new file mode 100644
index 000000000..606899f30
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/colorforth.css
@@ -0,0 +1,33 @@
+.cm-s-colorforth.CodeMirror { background: #000000; color: #f8f8f8; }
+.cm-s-colorforth .CodeMirror-gutters { background: #0a001f; border-right: 1px solid #aaa; }
+.cm-s-colorforth .CodeMirror-guttermarker { color: #FFBD40; }
+.cm-s-colorforth .CodeMirror-guttermarker-subtle { color: #78846f; }
+.cm-s-colorforth .CodeMirror-linenumber { color: #bababa; }
+.cm-s-colorforth .CodeMirror-cursor { border-left: 1px solid white; }
+
+.cm-s-colorforth span.cm-comment { color: #ededed; }
+.cm-s-colorforth span.cm-def { color: #ff1c1c; font-weight:bold; }
+.cm-s-colorforth span.cm-keyword { color: #ffd900; }
+.cm-s-colorforth span.cm-builtin { color: #00d95a; }
+.cm-s-colorforth span.cm-variable { color: #73ff00; }
+.cm-s-colorforth span.cm-string { color: #007bff; }
+.cm-s-colorforth span.cm-number { color: #00c4ff; }
+.cm-s-colorforth span.cm-atom { color: #606060; }
+
+.cm-s-colorforth span.cm-variable-2 { color: #EEE; }
+.cm-s-colorforth span.cm-variable-3 { color: #DDD; }
+.cm-s-colorforth span.cm-property {}
+.cm-s-colorforth span.cm-operator {}
+
+.cm-s-colorforth span.cm-meta { color: yellow; }
+.cm-s-colorforth span.cm-qualifier { color: #FFF700; }
+.cm-s-colorforth span.cm-bracket { color: #cc7; }
+.cm-s-colorforth span.cm-tag { color: #FFBD40; }
+.cm-s-colorforth span.cm-attribute { color: #FFF700; }
+.cm-s-colorforth span.cm-error { color: #f00; }
+
+.cm-s-colorforth div.CodeMirror-selected { background: #333d53; }
+
+.cm-s-colorforth span.cm-compilation { background: rgba(255, 255, 255, 0.12); }
+
+.cm-s-colorforth .CodeMirror-activeline-background { background: #253540; }
diff --git a/data/ext/editorText/codemirror/theme/dracula.css b/data/ext/editorText/codemirror/theme/dracula.css
new file mode 100644
index 000000000..57f979ae6
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/dracula.css
@@ -0,0 +1,41 @@
+/*
+
+ Name: dracula
+ Author: Michael Kaminsky (http://github.com/mkaminsky11)
+
+ Original dracula color scheme by Zeno Rocha (https://github.com/zenorocha/dracula-theme)
+
+*/
+
+
+.cm-s-dracula.CodeMirror, .cm-s-dracula .CodeMirror-gutters {
+ background-color: #282a36 !important;
+ color: #f8f8f2 !important;
+ border: none;
+}
+.cm-s-dracula .CodeMirror-gutters { color: #282a36; }
+.cm-s-dracula .CodeMirror-cursor { border-left: solid thin #f8f8f0; }
+.cm-s-dracula .CodeMirror-linenumber { color: #6D8A88; }
+.cm-s-dracula.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
+.cm-s-dracula .CodeMirror-line::selection, .cm-s-dracula .CodeMirror-line > span::selection, .cm-s-dracula .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
+.cm-s-dracula .CodeMirror-line::-moz-selection, .cm-s-dracula .CodeMirror-line > span::-moz-selection, .cm-s-dracula .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
+.cm-s-dracula span.cm-comment { color: #6272a4; }
+.cm-s-dracula span.cm-string, .cm-s-dracula span.cm-string-2 { color: #f1fa8c; }
+.cm-s-dracula span.cm-number { color: #bd93f9; }
+.cm-s-dracula span.cm-variable { color: #50fa7b; }
+.cm-s-dracula span.cm-variable-2 { color: white; }
+.cm-s-dracula span.cm-def { color: #ffb86c; }
+.cm-s-dracula span.cm-keyword { color: #ff79c6; }
+.cm-s-dracula span.cm-operator { color: #ff79c6; }
+.cm-s-dracula span.cm-keyword { color: #ff79c6; }
+.cm-s-dracula span.cm-atom { color: #bd93f9; }
+.cm-s-dracula span.cm-meta { color: #f8f8f2; }
+.cm-s-dracula span.cm-tag { color: #ff79c6; }
+.cm-s-dracula span.cm-attribute { color: #50fa7b; }
+.cm-s-dracula span.cm-qualifier { color: #50fa7b; }
+.cm-s-dracula span.cm-property { color: #66d9ef; }
+.cm-s-dracula span.cm-builtin { color: #50fa7b; }
+.cm-s-dracula span.cm-variable-3 { color: #50fa7b; }
+
+.cm-s-dracula .CodeMirror-activeline-background { background: rgba(255,255,255,0.1); }
+.cm-s-dracula .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
diff --git a/data/ext/editorText/codemirror/theme/eclipse.css b/data/ext/editorText/codemirror/theme/eclipse.css
index 317218e3d..1bde460e9 100644
--- a/data/ext/editorText/codemirror/theme/eclipse.css
+++ b/data/ext/editorText/codemirror/theme/eclipse.css
@@ -1,23 +1,23 @@
-.cm-s-eclipse span.cm-meta {color: #FF1717;}
+.cm-s-eclipse span.cm-meta { color: #FF1717; }
.cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
-.cm-s-eclipse span.cm-atom {color: #219;}
-.cm-s-eclipse span.cm-number {color: #164;}
-.cm-s-eclipse span.cm-def {color: #00f;}
-.cm-s-eclipse span.cm-variable {color: black;}
-.cm-s-eclipse span.cm-variable-2 {color: #0000C0;}
-.cm-s-eclipse span.cm-variable-3 {color: #0000C0;}
-.cm-s-eclipse span.cm-property {color: black;}
-.cm-s-eclipse span.cm-operator {color: black;}
-.cm-s-eclipse span.cm-comment {color: #3F7F5F;}
-.cm-s-eclipse span.cm-string {color: #2A00FF;}
-.cm-s-eclipse span.cm-string-2 {color: #f50;}
-.cm-s-eclipse span.cm-qualifier {color: #555;}
-.cm-s-eclipse span.cm-builtin {color: #30a;}
-.cm-s-eclipse span.cm-bracket {color: #cc7;}
-.cm-s-eclipse span.cm-tag {color: #170;}
-.cm-s-eclipse span.cm-attribute {color: #00c;}
-.cm-s-eclipse span.cm-link {color: #219;}
-.cm-s-eclipse span.cm-error {color: #f00;}
+.cm-s-eclipse span.cm-atom { color: #219; }
+.cm-s-eclipse span.cm-number { color: #164; }
+.cm-s-eclipse span.cm-def { color: #00f; }
+.cm-s-eclipse span.cm-variable { color: black; }
+.cm-s-eclipse span.cm-variable-2 { color: #0000C0; }
+.cm-s-eclipse span.cm-variable-3 { color: #0000C0; }
+.cm-s-eclipse span.cm-property { color: black; }
+.cm-s-eclipse span.cm-operator { color: black; }
+.cm-s-eclipse span.cm-comment { color: #3F7F5F; }
+.cm-s-eclipse span.cm-string { color: #2A00FF; }
+.cm-s-eclipse span.cm-string-2 { color: #f50; }
+.cm-s-eclipse span.cm-qualifier { color: #555; }
+.cm-s-eclipse span.cm-builtin { color: #30a; }
+.cm-s-eclipse span.cm-bracket { color: #cc7; }
+.cm-s-eclipse span.cm-tag { color: #170; }
+.cm-s-eclipse span.cm-attribute { color: #00c; }
+.cm-s-eclipse span.cm-link { color: #219; }
+.cm-s-eclipse span.cm-error { color: #f00; }
-.cm-s-eclipse .CodeMirror-activeline-background {background: #e8f2ff !important;}
-.cm-s-eclipse .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
+.cm-s-eclipse .CodeMirror-activeline-background { background: #e8f2ff; }
+.cm-s-eclipse .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }
diff --git a/data/ext/editorText/codemirror/theme/elegant.css b/data/ext/editorText/codemirror/theme/elegant.css
index dd7df7b73..45b3ea655 100644
--- a/data/ext/editorText/codemirror/theme/elegant.css
+++ b/data/ext/editorText/codemirror/theme/elegant.css
@@ -1,13 +1,13 @@
-.cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
-.cm-s-elegant span.cm-comment {color: #262; font-style: italic; line-height: 1em;}
-.cm-s-elegant span.cm-meta {color: #555; font-style: italic; line-height: 1em;}
-.cm-s-elegant span.cm-variable {color: black;}
-.cm-s-elegant span.cm-variable-2 {color: #b11;}
-.cm-s-elegant span.cm-qualifier {color: #555;}
-.cm-s-elegant span.cm-keyword {color: #730;}
-.cm-s-elegant span.cm-builtin {color: #30a;}
-.cm-s-elegant span.cm-link {color: #762;}
-.cm-s-elegant span.cm-error {background-color: #fdd;}
+.cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom { color: #762; }
+.cm-s-elegant span.cm-comment { color: #262; font-style: italic; line-height: 1em; }
+.cm-s-elegant span.cm-meta { color: #555; font-style: italic; line-height: 1em; }
+.cm-s-elegant span.cm-variable { color: black; }
+.cm-s-elegant span.cm-variable-2 { color: #b11; }
+.cm-s-elegant span.cm-qualifier { color: #555; }
+.cm-s-elegant span.cm-keyword { color: #730; }
+.cm-s-elegant span.cm-builtin { color: #30a; }
+.cm-s-elegant span.cm-link { color: #762; }
+.cm-s-elegant span.cm-error { background-color: #fdd; }
-.cm-s-elegant .CodeMirror-activeline-background {background: #e8f2ff !important;}
-.cm-s-elegant .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
+.cm-s-elegant .CodeMirror-activeline-background { background: #e8f2ff; }
+.cm-s-elegant .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }
diff --git a/data/ext/editorText/codemirror/theme/erlang-dark.css b/data/ext/editorText/codemirror/theme/erlang-dark.css
index db56b1084..65fe4814c 100644
--- a/data/ext/editorText/codemirror/theme/erlang-dark.css
+++ b/data/ext/editorText/codemirror/theme/erlang-dark.css
@@ -1,9 +1,14 @@
.cm-s-erlang-dark.CodeMirror { background: #002240; color: white; }
-.cm-s-erlang-dark div.CodeMirror-selected { background: #b36539 !important; }
+.cm-s-erlang-dark div.CodeMirror-selected { background: #b36539; }
+.cm-s-erlang-dark .CodeMirror-line::selection, .cm-s-erlang-dark .CodeMirror-line > span::selection, .cm-s-erlang-dark .CodeMirror-line > span > span::selection { background: rgba(179, 101, 57, .99); }
+.cm-s-erlang-dark .CodeMirror-line::-moz-selection, .cm-s-erlang-dark .CodeMirror-line > span::-moz-selection, .cm-s-erlang-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(179, 101, 57, .99); }
.cm-s-erlang-dark .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
+.cm-s-erlang-dark .CodeMirror-guttermarker { color: white; }
+.cm-s-erlang-dark .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
.cm-s-erlang-dark .CodeMirror-linenumber { color: #d0d0d0; }
-.cm-s-erlang-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
+.cm-s-erlang-dark .CodeMirror-cursor { border-left: 1px solid white; }
+.cm-s-erlang-dark span.cm-quote { color: #ccc; }
.cm-s-erlang-dark span.cm-atom { color: #f133f1; }
.cm-s-erlang-dark span.cm-attribute { color: #ff80e1; }
.cm-s-erlang-dark span.cm-bracket { color: #ff9d00; }
@@ -16,7 +21,6 @@
.cm-s-erlang-dark span.cm-operator { color: #d55; }
.cm-s-erlang-dark span.cm-property { color: #ccc; }
.cm-s-erlang-dark span.cm-qualifier { color: #ccc; }
-.cm-s-erlang-dark span.cm-quote { color: #ccc; }
.cm-s-erlang-dark span.cm-special { color: #ffbbbb; }
.cm-s-erlang-dark span.cm-string { color: #3ad900; }
.cm-s-erlang-dark span.cm-string-2 { color: #ccc; }
@@ -26,5 +30,5 @@
.cm-s-erlang-dark span.cm-variable-3 { color: #ccc; }
.cm-s-erlang-dark span.cm-error { color: #9d1e15; }
-.cm-s-erlang-dark .CodeMirror-activeline-background {background: #013461 !important;}
-.cm-s-erlang-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
+.cm-s-erlang-dark .CodeMirror-activeline-background { background: #013461; }
+.cm-s-erlang-dark .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
diff --git a/data/ext/editorText/codemirror/theme/hopscotch.css b/data/ext/editorText/codemirror/theme/hopscotch.css
new file mode 100644
index 000000000..7d05431bd
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/hopscotch.css
@@ -0,0 +1,34 @@
+/*
+
+ Name: Hopscotch
+ Author: Jan T. Sott
+
+ CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
+ Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
+
+*/
+
+.cm-s-hopscotch.CodeMirror {background: #322931; color: #d5d3d5;}
+.cm-s-hopscotch div.CodeMirror-selected {background: #433b42 !important;}
+.cm-s-hopscotch .CodeMirror-gutters {background: #322931; border-right: 0px;}
+.cm-s-hopscotch .CodeMirror-linenumber {color: #797379;}
+.cm-s-hopscotch .CodeMirror-cursor {border-left: 1px solid #989498 !important;}
+
+.cm-s-hopscotch span.cm-comment {color: #b33508;}
+.cm-s-hopscotch span.cm-atom {color: #c85e7c;}
+.cm-s-hopscotch span.cm-number {color: #c85e7c;}
+
+.cm-s-hopscotch span.cm-property, .cm-s-hopscotch span.cm-attribute {color: #8fc13e;}
+.cm-s-hopscotch span.cm-keyword {color: #dd464c;}
+.cm-s-hopscotch span.cm-string {color: #fdcc59;}
+
+.cm-s-hopscotch span.cm-variable {color: #8fc13e;}
+.cm-s-hopscotch span.cm-variable-2 {color: #1290bf;}
+.cm-s-hopscotch span.cm-def {color: #fd8b19;}
+.cm-s-hopscotch span.cm-error {background: #dd464c; color: #989498;}
+.cm-s-hopscotch span.cm-bracket {color: #d5d3d5;}
+.cm-s-hopscotch span.cm-tag {color: #dd464c;}
+.cm-s-hopscotch span.cm-link {color: #c85e7c;}
+
+.cm-s-hopscotch .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-hopscotch .CodeMirror-activeline-background { background: #302020; }
diff --git a/data/ext/editorText/codemirror/theme/icecoder.css b/data/ext/editorText/codemirror/theme/icecoder.css
new file mode 100644
index 000000000..d70d26e82
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/icecoder.css
@@ -0,0 +1,43 @@
+/*
+ICEcoder default theme by Matt Pass, used in code editor available at https://icecoder.net
+*/
+
+.cm-s-icecoder { color: #666; background: #141612; }
+
+.cm-s-icecoder span.cm-keyword { color: #eee; font-weight:bold; } /* off-white 1 */
+.cm-s-icecoder span.cm-atom { color: #e1c76e; } /* yellow */
+.cm-s-icecoder span.cm-number { color: #6cb5d9; } /* blue */
+.cm-s-icecoder span.cm-def { color: #b9ca4a; } /* green */
+
+.cm-s-icecoder span.cm-variable { color: #6cb5d9; } /* blue */
+.cm-s-icecoder span.cm-variable-2 { color: #cc1e5c; } /* pink */
+.cm-s-icecoder span.cm-variable-3 { color: #f9602c; } /* orange */
+
+.cm-s-icecoder span.cm-property { color: #eee; } /* off-white 1 */
+.cm-s-icecoder span.cm-operator { color: #9179bb; } /* purple */
+.cm-s-icecoder span.cm-comment { color: #97a3aa; } /* grey-blue */
+
+.cm-s-icecoder span.cm-string { color: #b9ca4a; } /* green */
+.cm-s-icecoder span.cm-string-2 { color: #6cb5d9; } /* blue */
+
+.cm-s-icecoder span.cm-meta { color: #555; } /* grey */
+
+.cm-s-icecoder span.cm-qualifier { color: #555; } /* grey */
+.cm-s-icecoder span.cm-builtin { color: #214e7b; } /* bright blue */
+.cm-s-icecoder span.cm-bracket { color: #cc7; } /* grey-yellow */
+
+.cm-s-icecoder span.cm-tag { color: #e8e8e8; } /* off-white 2 */
+.cm-s-icecoder span.cm-attribute { color: #099; } /* teal */
+
+.cm-s-icecoder span.cm-header { color: #6a0d6a; } /* purple-pink */
+.cm-s-icecoder span.cm-quote { color: #186718; } /* dark green */
+.cm-s-icecoder span.cm-hr { color: #888; } /* mid-grey */
+.cm-s-icecoder span.cm-link { color: #e1c76e; } /* yellow */
+.cm-s-icecoder span.cm-error { color: #d00; } /* red */
+
+.cm-s-icecoder .CodeMirror-cursor { border-left: 1px solid white; }
+.cm-s-icecoder div.CodeMirror-selected { color: #fff; background: #037; }
+.cm-s-icecoder .CodeMirror-gutters { background: #141612; min-width: 41px; border-right: 0; }
+.cm-s-icecoder .CodeMirror-linenumber { color: #555; cursor: default; }
+.cm-s-icecoder .CodeMirror-matchingbracket { border: 1px solid grey; color: black !important; }
+.cm-s-icecoder .CodeMirror-activeline-background { background: #000; }
\ No newline at end of file
diff --git a/data/ext/editorText/codemirror/theme/isotope.css b/data/ext/editorText/codemirror/theme/isotope.css
new file mode 100644
index 000000000..d0d6263cf
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/isotope.css
@@ -0,0 +1,34 @@
+/*
+
+ Name: Isotope
+ Author: David Desandro / Jan T. Sott
+
+ CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
+ Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
+
+*/
+
+.cm-s-isotope.CodeMirror {background: #000000; color: #e0e0e0;}
+.cm-s-isotope div.CodeMirror-selected {background: #404040 !important;}
+.cm-s-isotope .CodeMirror-gutters {background: #000000; border-right: 0px;}
+.cm-s-isotope .CodeMirror-linenumber {color: #808080;}
+.cm-s-isotope .CodeMirror-cursor {border-left: 1px solid #c0c0c0 !important;}
+
+.cm-s-isotope span.cm-comment {color: #3300ff;}
+.cm-s-isotope span.cm-atom {color: #cc00ff;}
+.cm-s-isotope span.cm-number {color: #cc00ff;}
+
+.cm-s-isotope span.cm-property, .cm-s-isotope span.cm-attribute {color: #33ff00;}
+.cm-s-isotope span.cm-keyword {color: #ff0000;}
+.cm-s-isotope span.cm-string {color: #ff0099;}
+
+.cm-s-isotope span.cm-variable {color: #33ff00;}
+.cm-s-isotope span.cm-variable-2 {color: #0066ff;}
+.cm-s-isotope span.cm-def {color: #ff9900;}
+.cm-s-isotope span.cm-error {background: #ff0000; color: #c0c0c0;}
+.cm-s-isotope span.cm-bracket {color: #e0e0e0;}
+.cm-s-isotope span.cm-tag {color: #ff0000;}
+.cm-s-isotope span.cm-link {color: #cc00ff;}
+
+.cm-s-isotope .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-isotope .CodeMirror-activeline-background { background: #202020; }
diff --git a/data/ext/editorText/codemirror/theme/lesser-dark.css b/data/ext/editorText/codemirror/theme/lesser-dark.css
index b8e77c279..690c183d7 100644
--- a/data/ext/editorText/codemirror/theme/lesser-dark.css
+++ b/data/ext/editorText/codemirror/theme/lesser-dark.css
@@ -6,38 +6,42 @@ Ported to CodeMirror by Peter Kroon
line-height: 1.3em;
}
.cm-s-lesser-dark.CodeMirror { background: #262626; color: #EBEFE7; text-shadow: 0 -1px 1px #262626; }
-.cm-s-lesser-dark div.CodeMirror-selected {background: #45443B !important;} /* 33322B*/
-.cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
+.cm-s-lesser-dark div.CodeMirror-selected { background: #45443B; } /* 33322B*/
+.cm-s-lesser-dark .CodeMirror-line::selection, .cm-s-lesser-dark .CodeMirror-line > span::selection, .cm-s-lesser-dark .CodeMirror-line > span > span::selection { background: rgba(69, 68, 59, .99); }
+.cm-s-lesser-dark .CodeMirror-line::-moz-selection, .cm-s-lesser-dark .CodeMirror-line > span::-moz-selection, .cm-s-lesser-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(69, 68, 59, .99); }
+.cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white; }
.cm-s-lesser-dark pre { padding: 0 8px; }/*editable code holder*/
.cm-s-lesser-dark.CodeMirror span.CodeMirror-matchingbracket { color: #7EFC7E; }/*65FC65*/
.cm-s-lesser-dark .CodeMirror-gutters { background: #262626; border-right:1px solid #aaa; }
+.cm-s-lesser-dark .CodeMirror-guttermarker { color: #599eff; }
+.cm-s-lesser-dark .CodeMirror-guttermarker-subtle { color: #777; }
.cm-s-lesser-dark .CodeMirror-linenumber { color: #777; }
+.cm-s-lesser-dark span.cm-header { color: #a0a; }
+.cm-s-lesser-dark span.cm-quote { color: #090; }
.cm-s-lesser-dark span.cm-keyword { color: #599eff; }
.cm-s-lesser-dark span.cm-atom { color: #C2B470; }
.cm-s-lesser-dark span.cm-number { color: #B35E4D; }
-.cm-s-lesser-dark span.cm-def {color: white;}
+.cm-s-lesser-dark span.cm-def { color: white; }
.cm-s-lesser-dark span.cm-variable { color:#D9BF8C; }
.cm-s-lesser-dark span.cm-variable-2 { color: #669199; }
.cm-s-lesser-dark span.cm-variable-3 { color: white; }
-.cm-s-lesser-dark span.cm-property {color: #92A75C;}
-.cm-s-lesser-dark span.cm-operator {color: #92A75C;}
+.cm-s-lesser-dark span.cm-property { color: #92A75C; }
+.cm-s-lesser-dark span.cm-operator { color: #92A75C; }
.cm-s-lesser-dark span.cm-comment { color: #666; }
.cm-s-lesser-dark span.cm-string { color: #BCD279; }
-.cm-s-lesser-dark span.cm-string-2 {color: #f50;}
+.cm-s-lesser-dark span.cm-string-2 { color: #f50; }
.cm-s-lesser-dark span.cm-meta { color: #738C73; }
-.cm-s-lesser-dark span.cm-qualifier {color: #555;}
+.cm-s-lesser-dark span.cm-qualifier { color: #555; }
.cm-s-lesser-dark span.cm-builtin { color: #ff9e59; }
.cm-s-lesser-dark span.cm-bracket { color: #EBEFE7; }
.cm-s-lesser-dark span.cm-tag { color: #669199; }
-.cm-s-lesser-dark span.cm-attribute {color: #00c;}
-.cm-s-lesser-dark span.cm-header {color: #a0a;}
-.cm-s-lesser-dark span.cm-quote {color: #090;}
-.cm-s-lesser-dark span.cm-hr {color: #999;}
-.cm-s-lesser-dark span.cm-link {color: #00c;}
+.cm-s-lesser-dark span.cm-attribute { color: #00c; }
+.cm-s-lesser-dark span.cm-hr { color: #999; }
+.cm-s-lesser-dark span.cm-link { color: #00c; }
.cm-s-lesser-dark span.cm-error { color: #9d1e15; }
-.cm-s-lesser-dark .CodeMirror-activeline-background {background: #3C3A3A !important;}
-.cm-s-lesser-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
+.cm-s-lesser-dark .CodeMirror-activeline-background { background: #3C3A3A; }
+.cm-s-lesser-dark .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
diff --git a/data/ext/editorText/codemirror/theme/liquibyte.css b/data/ext/editorText/codemirror/theme/liquibyte.css
new file mode 100644
index 000000000..9db8bde73
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/liquibyte.css
@@ -0,0 +1,95 @@
+.cm-s-liquibyte.CodeMirror {
+ background-color: #000;
+ color: #fff;
+ line-height: 1.2em;
+ font-size: 1em;
+}
+.cm-s-liquibyte .CodeMirror-focused .cm-matchhighlight {
+ text-decoration: underline;
+ text-decoration-color: #0f0;
+ text-decoration-style: wavy;
+}
+.cm-s-liquibyte .cm-trailingspace {
+ text-decoration: line-through;
+ text-decoration-color: #f00;
+ text-decoration-style: dotted;
+}
+.cm-s-liquibyte .cm-tab {
+ text-decoration: line-through;
+ text-decoration-color: #404040;
+ text-decoration-style: dotted;
+}
+.cm-s-liquibyte .CodeMirror-gutters { background-color: #262626; border-right: 1px solid #505050; padding-right: 0.8em; }
+.cm-s-liquibyte .CodeMirror-gutter-elt div { font-size: 1.2em; }
+.cm-s-liquibyte .CodeMirror-guttermarker { }
+.cm-s-liquibyte .CodeMirror-guttermarker-subtle { }
+.cm-s-liquibyte .CodeMirror-linenumber { color: #606060; padding-left: 0; }
+.cm-s-liquibyte .CodeMirror-cursor { border-left: 1px solid #eee; }
+
+.cm-s-liquibyte span.cm-comment { color: #008000; }
+.cm-s-liquibyte span.cm-def { color: #ffaf40; font-weight: bold; }
+.cm-s-liquibyte span.cm-keyword { color: #c080ff; font-weight: bold; }
+.cm-s-liquibyte span.cm-builtin { color: #ffaf40; font-weight: bold; }
+.cm-s-liquibyte span.cm-variable { color: #5967ff; font-weight: bold; }
+.cm-s-liquibyte span.cm-string { color: #ff8000; }
+.cm-s-liquibyte span.cm-number { color: #0f0; font-weight: bold; }
+.cm-s-liquibyte span.cm-atom { color: #bf3030; font-weight: bold; }
+
+.cm-s-liquibyte span.cm-variable-2 { color: #007f7f; font-weight: bold; }
+.cm-s-liquibyte span.cm-variable-3 { color: #c080ff; font-weight: bold; }
+.cm-s-liquibyte span.cm-property { color: #999; font-weight: bold; }
+.cm-s-liquibyte span.cm-operator { color: #fff; }
+
+.cm-s-liquibyte span.cm-meta { color: #0f0; }
+.cm-s-liquibyte span.cm-qualifier { color: #fff700; font-weight: bold; }
+.cm-s-liquibyte span.cm-bracket { color: #cc7; }
+.cm-s-liquibyte span.cm-tag { color: #ff0; font-weight: bold; }
+.cm-s-liquibyte span.cm-attribute { color: #c080ff; font-weight: bold; }
+.cm-s-liquibyte span.cm-error { color: #f00; }
+
+.cm-s-liquibyte div.CodeMirror-selected { background-color: rgba(255, 0, 0, 0.25); }
+
+.cm-s-liquibyte span.cm-compilation { background-color: rgba(255, 255, 255, 0.12); }
+
+.cm-s-liquibyte .CodeMirror-activeline-background { background-color: rgba(0, 255, 0, 0.15); }
+
+/* Default styles for common addons */
+.cm-s-liquibyte .CodeMirror span.CodeMirror-matchingbracket { color: #0f0; font-weight: bold; }
+.cm-s-liquibyte .CodeMirror span.CodeMirror-nonmatchingbracket { color: #f00; font-weight: bold; }
+.CodeMirror-matchingtag { background-color: rgba(150, 255, 0, .3); }
+/* Scrollbars */
+/* Simple */
+.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div:hover, div.CodeMirror-simplescroll-vertical div:hover {
+ background-color: rgba(80, 80, 80, .7);
+}
+.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div, div.CodeMirror-simplescroll-vertical div {
+ background-color: rgba(80, 80, 80, .3);
+ border: 1px solid #404040;
+ border-radius: 5px;
+}
+.cm-s-liquibyte div.CodeMirror-simplescroll-vertical div {
+ border-top: 1px solid #404040;
+ border-bottom: 1px solid #404040;
+}
+.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div {
+ border-left: 1px solid #404040;
+ border-right: 1px solid #404040;
+}
+.cm-s-liquibyte div.CodeMirror-simplescroll-vertical {
+ background-color: #262626;
+}
+.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal {
+ background-color: #262626;
+ border-top: 1px solid #404040;
+}
+/* Overlay */
+.cm-s-liquibyte div.CodeMirror-overlayscroll-horizontal div, div.CodeMirror-overlayscroll-vertical div {
+ background-color: #404040;
+ border-radius: 5px;
+}
+.cm-s-liquibyte div.CodeMirror-overlayscroll-vertical div {
+ border: 1px solid #404040;
+}
+.cm-s-liquibyte div.CodeMirror-overlayscroll-horizontal div {
+ border: 1px solid #404040;
+}
diff --git a/data/ext/editorText/codemirror/theme/material.css b/data/ext/editorText/codemirror/theme/material.css
new file mode 100644
index 000000000..26005e280
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/material.css
@@ -0,0 +1,53 @@
+/*
+
+ Name: material
+ Author: Michael Kaminsky (http://github.com/mkaminsky11)
+
+ Original material color scheme by Mattia Astorino (https://github.com/equinusocio/material-theme)
+
+*/
+
+.cm-s-material {
+ background-color: #263238;
+ color: rgba(233, 237, 237, 1);
+}
+.cm-s-material .CodeMirror-gutters {
+ background: #263238;
+ color: rgb(83,127,126);
+ border: none;
+}
+.cm-s-material .CodeMirror-guttermarker, .cm-s-material .CodeMirror-guttermarker-subtle, .cm-s-material .CodeMirror-linenumber { color: rgb(83,127,126); }
+.cm-s-material .CodeMirror-cursor { border-left: 1px solid #f8f8f0; }
+.cm-s-material div.CodeMirror-selected { background: rgba(255, 255, 255, 0.15); }
+.cm-s-material.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
+.cm-s-material .CodeMirror-line::selection, .cm-s-material .CodeMirror-line > span::selection, .cm-s-material .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
+.cm-s-material .CodeMirror-line::-moz-selection, .cm-s-material .CodeMirror-line > span::-moz-selection, .cm-s-material .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
+
+.cm-s-material .CodeMirror-activeline-background { background: rgba(0, 0, 0, 0); }
+.cm-s-material .cm-keyword { color: rgba(199, 146, 234, 1); }
+.cm-s-material .cm-operator { color: rgba(233, 237, 237, 1); }
+.cm-s-material .cm-variable-2 { color: #80CBC4; }
+.cm-s-material .cm-variable-3 { color: #82B1FF; }
+.cm-s-material .cm-builtin { color: #DECB6B; }
+.cm-s-material .cm-atom { color: #F77669; }
+.cm-s-material .cm-number { color: #F77669; }
+.cm-s-material .cm-def { color: rgba(233, 237, 237, 1); }
+.cm-s-material .cm-error {
+ color: rgba(255, 255, 255, 1.0);
+ background-color: #EC5F67;
+}
+.cm-s-material .cm-string { color: #C3E88D; }
+.cm-s-material .cm-string-2 { color: #80CBC4; }
+.cm-s-material .cm-comment { color: #546E7A; }
+.cm-s-material .cm-variable { color: #82B1FF; }
+.cm-s-material .cm-tag { color: #80CBC4; }
+.cm-s-material .cm-meta { color: #80CBC4; }
+.cm-s-material .cm-attribute { color: #FFCB6B; }
+.cm-s-material .cm-property { color: #80CBAE; }
+.cm-s-material .cm-qualifier { color: #DECB6B; }
+.cm-s-material .cm-variable-3 { color: #DECB6B; }
+.cm-s-material .cm-tag { color: rgba(255, 83, 112, 1); }
+.cm-s-material .CodeMirror-matchingbracket {
+ text-decoration: underline;
+ color: white !important;
+}
diff --git a/data/ext/editorText/codemirror/theme/mbo.css b/data/ext/editorText/codemirror/theme/mbo.css
index bb52e6d17..59ff5da7c 100644
--- a/data/ext/editorText/codemirror/theme/mbo.css
+++ b/data/ext/editorText/codemirror/theme/mbo.css
@@ -1,37 +1,37 @@
-/* Based on mbonaci's Brackets mbo theme */
+/****************************************************************/
+/* Based on mbonaci's Brackets mbo theme */
+/* https://github.com/mbonaci/global/blob/master/Mbo.tmTheme */
+/* Create your own: http://tmtheme-editor.herokuapp.com */
+/****************************************************************/
-.cm-s-mbo.CodeMirror {background: #2c2c2c; color: #ffffe9;}
-.cm-s-mbo div.CodeMirror-selected {background: #716C62 !important;}
-.cm-s-mbo .CodeMirror-gutters {background: #4e4e4e; border-right: 0px;}
-.cm-s-mbo .CodeMirror-linenumber {color: #dadada;}
-.cm-s-mbo .CodeMirror-cursor {border-left: 1px solid #ffffec !important;}
+.cm-s-mbo.CodeMirror { background: #2c2c2c; color: #ffffec; }
+.cm-s-mbo div.CodeMirror-selected { background: #716C62; }
+.cm-s-mbo .CodeMirror-line::selection, .cm-s-mbo .CodeMirror-line > span::selection, .cm-s-mbo .CodeMirror-line > span > span::selection { background: rgba(113, 108, 98, .99); }
+.cm-s-mbo .CodeMirror-line::-moz-selection, .cm-s-mbo .CodeMirror-line > span::-moz-selection, .cm-s-mbo .CodeMirror-line > span > span::-moz-selection { background: rgba(113, 108, 98, .99); }
+.cm-s-mbo .CodeMirror-gutters { background: #4e4e4e; border-right: 0px; }
+.cm-s-mbo .CodeMirror-guttermarker { color: white; }
+.cm-s-mbo .CodeMirror-guttermarker-subtle { color: grey; }
+.cm-s-mbo .CodeMirror-linenumber { color: #dadada; }
+.cm-s-mbo .CodeMirror-cursor { border-left: 1px solid #ffffec; }
-.cm-s-mbo span.cm-comment {color: #95958a;}
-.cm-s-mbo span.cm-atom {color: #00a8c6;}
-.cm-s-mbo span.cm-number {color: #00a8c6;}
+.cm-s-mbo span.cm-comment { color: #95958a; }
+.cm-s-mbo span.cm-atom { color: #00a8c6; }
+.cm-s-mbo span.cm-number { color: #00a8c6; }
-.cm-s-mbo span.cm-property, .cm-s-mbo span.cm-attribute {color: #9ddfe9;}
-.cm-s-mbo span.cm-keyword {color: #ffb928;}
-.cm-s-mbo span.cm-string {color: #ffcf6c;}
+.cm-s-mbo span.cm-property, .cm-s-mbo span.cm-attribute { color: #9ddfe9; }
+.cm-s-mbo span.cm-keyword { color: #ffb928; }
+.cm-s-mbo span.cm-string { color: #ffcf6c; }
+.cm-s-mbo span.cm-string.cm-property { color: #ffffec; }
-.cm-s-mbo span.cm-variable {color: #ffffec;}
-.cm-s-mbo span.cm-variable-2 {color: #00a8c6;}
-.cm-s-mbo span.cm-def {color: #ffffec;}
-.cm-s-mbo span.cm-bracket {color: #fffffc; font-weight: bold;}
-.cm-s-mbo span.cm-tag {color: #9ddfe9;}
-.cm-s-mbo span.cm-link {color: #f54b07;}
-.cm-s-mbo span.cm-error {background: #636363; color: #ffffec;}
+.cm-s-mbo span.cm-variable { color: #ffffec; }
+.cm-s-mbo span.cm-variable-2 { color: #00a8c6; }
+.cm-s-mbo span.cm-def { color: #ffffec; }
+.cm-s-mbo span.cm-bracket { color: #fffffc; font-weight: bold; }
+.cm-s-mbo span.cm-tag { color: #9ddfe9; }
+.cm-s-mbo span.cm-link { color: #f54b07; }
+.cm-s-mbo span.cm-error { border-bottom: #636363; color: #ffffec; }
+.cm-s-mbo span.cm-qualifier { color: #ffffec; }
-.cm-s-mbo .CodeMirror-activeline-background {background: #494b41 !important;}
-.cm-s-mbo .CodeMirror-matchingbracket {
- text-decoration: underline;
- color: #f5e107 !important;
- }
-
-.cm-s-mbo .CodeMirror-matchingtag {background: #4e4e4e;}
-
-.cm-s-mbo span.cm-searching {
- background-color: none;
- background: none;
- box-shadow: 0 0 0 1px #ffffec;
-}
+.cm-s-mbo .CodeMirror-activeline-background { background: #494b41; }
+.cm-s-mbo .CodeMirror-matchingbracket { color: #222 !important; }
+.cm-s-mbo .CodeMirror-matchingtag { background: rgba(255, 255, 255, .37); }
diff --git a/data/ext/editorText/codemirror/theme/mdn-like.css b/data/ext/editorText/codemirror/theme/mdn-like.css
index 1e20b9e21..f325d4500 100644
--- a/data/ext/editorText/codemirror/theme/mdn-like.css
+++ b/data/ext/editorText/codemirror/theme/mdn-like.css
@@ -1,20 +1,22 @@
/*
MDN-LIKE Theme - Mozilla
Ported to CodeMirror by Peter Kroon <[email protected]>
- Report bugs/issues here: https://github.com/marijnh/CodeMirror/issues
+ Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
GitHub: @peterkroon
The mdn-like theme is inspired on the displayed code examples at: https://developer.mozilla.org/en-US/docs/Web/CSS/animation
*/
.cm-s-mdn-like.CodeMirror { color: #999; background-color: #fff; }
-.cm-s-mdn-like .CodeMirror-selected { background: #cfc !important; }
+.cm-s-mdn-like div.CodeMirror-selected { background: #cfc; }
+.cm-s-mdn-like .CodeMirror-line::selection, .cm-s-mdn-like .CodeMirror-line > span::selection, .cm-s-mdn-like .CodeMirror-line > span > span::selection { background: #cfc; }
+.cm-s-mdn-like .CodeMirror-line::-moz-selection, .cm-s-mdn-like .CodeMirror-line > span::-moz-selection, .cm-s-mdn-like .CodeMirror-line > span > span::-moz-selection { background: #cfc; }
.cm-s-mdn-like .CodeMirror-gutters { background: #f8f8f8; border-left: 6px solid rgba(0,83,159,0.65); color: #333; }
-.cm-s-mdn-like .CodeMirror-linenumber { color: #aaa; margin-left: 3px; }
-div.cm-s-mdn-like .CodeMirror-cursor { border-left: 2px solid #222; }
+.cm-s-mdn-like .CodeMirror-linenumber { color: #aaa; padding-left: 8px; }
+.cm-s-mdn-like .CodeMirror-cursor { border-left: 2px solid #222; }
-.cm-s-mdn-like .cm-keyword { color: #6262FF; }
+.cm-s-mdn-like .cm-keyword { color: #6262FF; }
.cm-s-mdn-like .cm-atom { color: #F90; }
.cm-s-mdn-like .cm-number { color: #ca7841; }
.cm-s-mdn-like .cm-def { color: #8DA6CE; }
@@ -35,10 +37,10 @@ div.cm-s-mdn-like .CodeMirror-cursor { border-left: 2px solid #222; }
.cm-s-mdn-like .cm-attribute { color: #d6bb6d; } /*?*/
.cm-s-mdn-like .cm-header { color: #FF6400; }
.cm-s-mdn-like .cm-hr { color: #AEAEAE; }
-.cm-s-mdn-like .cm-link { color:#ad9361; font-style:italic; text-decoration:none; }
+.cm-s-mdn-like .cm-link { color:#ad9361; font-style:italic; text-decoration:none; }
.cm-s-mdn-like .cm-error { border-bottom: 1px solid red; }
-div.cm-s-mdn-like .CodeMirror-activeline-background {background: #efefff;}
-div.cm-s-mdn-like span.CodeMirror-matchingbracket {outline:1px solid grey; color: inherit;}
+div.cm-s-mdn-like .CodeMirror-activeline-background { background: #efefff; }
+div.cm-s-mdn-like span.CodeMirror-matchingbracket { outline:1px solid grey; color: inherit; }
.cm-s-mdn-like.CodeMirror { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFcAAAAyCAYAAAAp8UeFAAAHvklEQVR42s2b63bcNgyEQZCSHCdt2vd/0tWF7I+Q6XgMXiTtuvU5Pl57ZQKkKHzEAOtF5KeIJBGJ8uvL599FRFREZhFx8DeXv8trn68RuGaC8TRfo3SNp9dlDDHedyLyTUTeRWStXKPZrjtpZxaRw5hPqozRs1N8/enzIiQRWcCgy4MUA0f+XWliDhyL8Lfyvx7ei/Ae3iQFHyw7U/59pQVIMEEPEz0G7XiwdRjzSfC3UTtz9vchIntxvry5iMgfIhJoEflOz2CQr3F5h/HfeFe+GTdLaKcu9L8LTeQb/R/7GgbsfKedyNdoHsN31uRPWrfZ5wsj/NzzRQHuToIdU3ahwnsKPxXCjJITuOsi7XLc7SG/v5GdALs7wf8JjTFiB5+QvTEfRyGOfX3Lrx8wxyQi3sNq46O7QahQiCsRFgqddjBouVEHOKDgXAQHD9gJCr5sMKkEdjwsarG/ww3BMHBU7OBjXnzdyY7SfCxf5/z6ATccrwlKuwC/jhznnPF4CgVzhhVf4xp2EixcBActO75iZ8/fM9zAs2OMzKdslgXWJ9XG8PQoOAMA5fGcsvORgv0doBXyHrCwfLJAOwo71QLNkb8n2Pl6EWiR7OCibtkPaz4Kc/0NNAze2gju3zOwekALDaCFPI5vjPFmgGY5AZqyGEvH1x7QfIb8YtxMnA/b+QQ0aQDAwc6JMFg8CbQZ4qoYEEHbRwNojuK3EHwd7VALSgq+MNDKzfT58T8qdpADrgW0GmgcAS1lhzztJmkAzcPNOQbsWEALBDSlMKUG0Eq4CLAQWvEVQ9WU57gZJwZtgPO3r9oBTQ9WO8TjqXINx8R0EYpiZEUWOF3FxkbJkgU9B2f41YBrIj5ZfsQa0M5kTgiAAqM3ShXLgu8XMqcrQBvJ0CL5pnTsfMB13oB8athpAq2XOQmcGmoACCLydx7nToa23ATaSIY2ichfOdPTGxlasXMLaL0MLZAOwAKIM+y8CmicobGdCcbbK9DzN+yYGVoNNI5iUKTMyYOjPse4A8SM1MmcXgU0toOq1yO/v8FOxlASyc7TgeYaAMBJHcY1CcCwGI/TK4AmDbDyKYBBtFUkRwto8gygiQEaByFgJ00BH2M8JWwQS1nafDXQCidWyOI8AcjDCSjCLk8ngObuAm3JAHAdubAmOaK06V8MNEsKPJOhobSprwQa6gD7DclRQdqcwL4zxqgBrQcabUiBLclRDKAlWp+etPkBaNMA0AKlrHwTdEByZAA4GM+SNluSY6wAzcMNewxmgig5Ks0nkrSpBvSaQHMdKTBAnLojOdYyGpQ254602ZILPdTD1hdlggdIm74jbTp8vDwF5ZYUeLWGJpWsh6XNyXgcYwVoJQTEhhTYkxzZjiU5npU2TaB979TQehlaAVq4kaGpiPwwwLkYUuBbQwocyQTv1tA0+1UFWoJF3iv1oq+qoSk8EQdJmwHkziIF7oOZk14EGitibAdjLYYK78H5vZOhtWpoI0ATGHs0Q8OMb4Ey+2bU2UYztCtA0wFAs7TplGLRVQCcqaFdGSPCeTI1QNIC52iWNzof6Uib7xjEp07mNNoUYmVosVItHrHzRlLgBn9LFyRHaQCtVUMbtTNhoXWiTOO9k/V8BdAc1Oq0ArSQs6/5SU0hckNy9NnXqQY0PGYo5dWJ7nINaN6o958FWin27aBaWRka1r5myvLOAm0j30eBJqCxHLReVclxhxOEN2JfDWjxBtAC7MIH1fVaGdoOp4qJYDgKtKPSFNID2gSnGldrCqkFZ+5UeQXQBIRrSwocbdZYQT/2LwRahBPBXoHrB8nxaGROST62DKUbQOMMzZIC9abkuELfQzQALWTnDNAm8KHWFOJgJ5+SHIvTPcmx1xQyZRhNL5Qci689aXMEaN/uNIWkEwDAvFpOZmgsBaaGnbs1NPa1Jm32gBZAIh1pCtG7TSH4aE0y1uVY4uqoFPisGlpP2rSA5qTecWn5agK6BzSpgAyD+wFaqhnYoSZ1Vwr8CmlTQbrcO3ZaX0NAEyMbYaAlyquFoLKK3SPby9CeVUPThrSJmkCAE0CrKUQadi4DrdSlWhmah0YL9z9vClH59YGbHx1J8VZTyAjQepJjmXwAKTDQI3omc3p1U4gDUf6RfcdYfrUp5ClAi2J3Ba6UOXGo+K+bQrjjssitG2SJzshaLwMtXgRagUNpYYoVkMSBLM+9GGiJZMvduG6DRZ4qc04DMPtQQxOjEtACmhO7K1AbNbQDEggZyJwscFpAGwENhoBeUwh3bWolhe8BTYVKxQEWrSUn/uhcM5KhvUu/+eQu0Lzhi+VrK0PrZZNDQKs9cpYUuFYgMVpD4/NxenJTiMCNqdUEUf1qZWjppLT5qSkkUZbCwkbZMSuVnu80hfSkzRbQeqCZSAh6huR4VtoM2gHAlLf72smuWgE+VV7XpE25Ab2WFDgyhnSuKbs4GuGzCjR+tIoUuMFg3kgcWKLTwRqanJQ2W00hAsenfaApRC42hbCvK1SlE0HtE9BGgneJO+ELamitD1YjjOYnNYVcraGhtKkW0EqVVeDx733I2NH581k1NNxNLG0i0IJ8/NjVaOZ0tYZ2Vtr0Xv7tPV3hkWp9EFkgS/J0vosngTaSoaG06WHi+xObQkaAdlbanP8B2+2l0f90LmUAAAAASUVORK5CYII=); }
diff --git a/data/ext/editorText/codemirror/theme/midnight.css b/data/ext/editorText/codemirror/theme/midnight.css
index 468d87daf..e41f10560 100644
--- a/data/ext/editorText/codemirror/theme/midnight.css
+++ b/data/ext/editorText/codemirror/theme/midnight.css
@@ -5,37 +5,39 @@
.cm-s-midnight.CodeMirror-focused span.CodeMirror-matchhighlight { background: #314D67 !important; }
/*<!--activeline-->*/
-.cm-s-midnight .CodeMirror-activeline-background {background: #253540 !important;}
+.cm-s-midnight .CodeMirror-activeline-background { background: #253540; }
.cm-s-midnight.CodeMirror {
background: #0F192A;
color: #D1EDFF;
}
-.cm-s-midnight.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
-
-.cm-s-midnight div.CodeMirror-selected {background: #314D67 !important;}
-.cm-s-midnight .CodeMirror-gutters {background: #0F192A; border-right: 1px solid;}
-.cm-s-midnight .CodeMirror-linenumber {color: #D0D0D0;}
-.cm-s-midnight .CodeMirror-cursor {
- border-left: 1px solid #F8F8F0 !important;
-}
-
-.cm-s-midnight span.cm-comment {color: #428BDD;}
-.cm-s-midnight span.cm-atom {color: #AE81FF;}
-.cm-s-midnight span.cm-number {color: #D1EDFF;}
-
-.cm-s-midnight span.cm-property, .cm-s-midnight span.cm-attribute {color: #A6E22E;}
-.cm-s-midnight span.cm-keyword {color: #E83737;}
-.cm-s-midnight span.cm-string {color: #1DC116;}
-
-.cm-s-midnight span.cm-variable {color: #FFAA3E;}
-.cm-s-midnight span.cm-variable-2 {color: #FFAA3E;}
-.cm-s-midnight span.cm-def {color: #4DD;}
-.cm-s-midnight span.cm-bracket {color: #D1EDFF;}
-.cm-s-midnight span.cm-tag {color: #449;}
-.cm-s-midnight span.cm-link {color: #AE81FF;}
-.cm-s-midnight span.cm-error {background: #F92672; color: #F8F8F0;}
+.cm-s-midnight.CodeMirror { border-top: 1px solid black; border-bottom: 1px solid black; }
+
+.cm-s-midnight div.CodeMirror-selected { background: #314D67; }
+.cm-s-midnight .CodeMirror-line::selection, .cm-s-midnight .CodeMirror-line > span::selection, .cm-s-midnight .CodeMirror-line > span > span::selection { background: rgba(49, 77, 103, .99); }
+.cm-s-midnight .CodeMirror-line::-moz-selection, .cm-s-midnight .CodeMirror-line > span::-moz-selection, .cm-s-midnight .CodeMirror-line > span > span::-moz-selection { background: rgba(49, 77, 103, .99); }
+.cm-s-midnight .CodeMirror-gutters { background: #0F192A; border-right: 1px solid; }
+.cm-s-midnight .CodeMirror-guttermarker { color: white; }
+.cm-s-midnight .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
+.cm-s-midnight .CodeMirror-linenumber { color: #D0D0D0; }
+.cm-s-midnight .CodeMirror-cursor { border-left: 1px solid #F8F8F0; }
+
+.cm-s-midnight span.cm-comment { color: #428BDD; }
+.cm-s-midnight span.cm-atom { color: #AE81FF; }
+.cm-s-midnight span.cm-number { color: #D1EDFF; }
+
+.cm-s-midnight span.cm-property, .cm-s-midnight span.cm-attribute { color: #A6E22E; }
+.cm-s-midnight span.cm-keyword { color: #E83737; }
+.cm-s-midnight span.cm-string { color: #1DC116; }
+
+.cm-s-midnight span.cm-variable { color: #FFAA3E; }
+.cm-s-midnight span.cm-variable-2 { color: #FFAA3E; }
+.cm-s-midnight span.cm-def { color: #4DD; }
+.cm-s-midnight span.cm-bracket { color: #D1EDFF; }
+.cm-s-midnight span.cm-tag { color: #449; }
+.cm-s-midnight span.cm-link { color: #AE81FF; }
+.cm-s-midnight span.cm-error { background: #F92672; color: #F8F8F0; }
.cm-s-midnight .CodeMirror-matchingbracket {
text-decoration: underline;
diff --git a/data/ext/editorText/codemirror/theme/monokai.css b/data/ext/editorText/codemirror/theme/monokai.css
index 7ac601a13..6910f793e 100644
--- a/data/ext/editorText/codemirror/theme/monokai.css
+++ b/data/ext/editorText/codemirror/theme/monokai.css
@@ -1,28 +1,34 @@
/* Based on Sublime Text's Monokai theme */
-.cm-s-monokai.CodeMirror {background: #272822; color: #f8f8f2;}
-.cm-s-monokai div.CodeMirror-selected {background: #49483E !important;}
-.cm-s-monokai .CodeMirror-gutters {background: #272822; border-right: 0px;}
-.cm-s-monokai .CodeMirror-linenumber {color: #d0d0d0;}
-.cm-s-monokai .CodeMirror-cursor {border-left: 1px solid #f8f8f0 !important;}
+.cm-s-monokai.CodeMirror { background: #272822; color: #f8f8f2; }
+.cm-s-monokai div.CodeMirror-selected { background: #49483E; }
+.cm-s-monokai .CodeMirror-line::selection, .cm-s-monokai .CodeMirror-line > span::selection, .cm-s-monokai .CodeMirror-line > span > span::selection { background: rgba(73, 72, 62, .99); }
+.cm-s-monokai .CodeMirror-line::-moz-selection, .cm-s-monokai .CodeMirror-line > span::-moz-selection, .cm-s-monokai .CodeMirror-line > span > span::-moz-selection { background: rgba(73, 72, 62, .99); }
+.cm-s-monokai .CodeMirror-gutters { background: #272822; border-right: 0px; }
+.cm-s-monokai .CodeMirror-guttermarker { color: white; }
+.cm-s-monokai .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
+.cm-s-monokai .CodeMirror-linenumber { color: #d0d0d0; }
+.cm-s-monokai .CodeMirror-cursor { border-left: 1px solid #f8f8f0; }
-.cm-s-monokai span.cm-comment {color: #75715e;}
-.cm-s-monokai span.cm-atom {color: #ae81ff;}
-.cm-s-monokai span.cm-number {color: #ae81ff;}
+.cm-s-monokai span.cm-comment { color: #75715e; }
+.cm-s-monokai span.cm-atom { color: #ae81ff; }
+.cm-s-monokai span.cm-number { color: #ae81ff; }
-.cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute {color: #a6e22e;}
-.cm-s-monokai span.cm-keyword {color: #f92672;}
-.cm-s-monokai span.cm-string {color: #e6db74;}
+.cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute { color: #a6e22e; }
+.cm-s-monokai span.cm-keyword { color: #f92672; }
+.cm-s-monokai span.cm-string { color: #e6db74; }
-.cm-s-monokai span.cm-variable {color: #a6e22e;}
-.cm-s-monokai span.cm-variable-2 {color: #9effff;}
-.cm-s-monokai span.cm-def {color: #fd971f;}
-.cm-s-monokai span.cm-bracket {color: #f8f8f2;}
-.cm-s-monokai span.cm-tag {color: #f92672;}
-.cm-s-monokai span.cm-link {color: #ae81ff;}
-.cm-s-monokai span.cm-error {background: #f92672; color: #f8f8f0;}
+.cm-s-monokai span.cm-variable { color: #f8f8f2; }
+.cm-s-monokai span.cm-variable-2 { color: #9effff; }
+.cm-s-monokai span.cm-variable-3 { color: #66d9ef; }
+.cm-s-monokai span.cm-def { color: #fd971f; }
+.cm-s-monokai span.cm-bracket { color: #f8f8f2; }
+.cm-s-monokai span.cm-tag { color: #f92672; }
+.cm-s-monokai span.cm-header { color: #ae81ff; }
+.cm-s-monokai span.cm-link { color: #ae81ff; }
+.cm-s-monokai span.cm-error { background: #f92672; color: #f8f8f0; }
-.cm-s-monokai .CodeMirror-activeline-background {background: #373831 !important;}
+.cm-s-monokai .CodeMirror-activeline-background { background: #373831; }
.cm-s-monokai .CodeMirror-matchingbracket {
text-decoration: underline;
color: white !important;
diff --git a/data/ext/editorText/codemirror/theme/neat.css b/data/ext/editorText/codemirror/theme/neat.css
index 115083b81..4267b1a37 100644
--- a/data/ext/editorText/codemirror/theme/neat.css
+++ b/data/ext/editorText/codemirror/theme/neat.css
@@ -5,8 +5,8 @@
.cm-s-neat span.cm-special { line-height: 1em; font-weight: bold; color: #0aa; }
.cm-s-neat span.cm-variable { color: black; }
.cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
-.cm-s-neat span.cm-meta {color: #555;}
+.cm-s-neat span.cm-meta { color: #555; }
.cm-s-neat span.cm-link { color: #3a3; }
-.cm-s-neat .CodeMirror-activeline-background {background: #e8f2ff !important;}
-.cm-s-neat .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
+.cm-s-neat .CodeMirror-activeline-background { background: #e8f2ff; }
+.cm-s-neat .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }
diff --git a/data/ext/editorText/codemirror/theme/neo.css b/data/ext/editorText/codemirror/theme/neo.css
new file mode 100644
index 000000000..b28d5c65f
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/neo.css
@@ -0,0 +1,43 @@
+/* neo theme for codemirror */
+
+/* Color scheme */
+
+.cm-s-neo.CodeMirror {
+ background-color:#ffffff;
+ color:#2e383c;
+ line-height:1.4375;
+}
+.cm-s-neo .cm-comment { color:#75787b; }
+.cm-s-neo .cm-keyword, .cm-s-neo .cm-property { color:#1d75b3; }
+.cm-s-neo .cm-atom,.cm-s-neo .cm-number { color:#75438a; }
+.cm-s-neo .cm-node,.cm-s-neo .cm-tag { color:#9c3328; }
+.cm-s-neo .cm-string { color:#b35e14; }
+.cm-s-neo .cm-variable,.cm-s-neo .cm-qualifier { color:#047d65; }
+
+
+/* Editor styling */
+
+.cm-s-neo pre {
+ padding:0;
+}
+
+.cm-s-neo .CodeMirror-gutters {
+ border:none;
+ border-right:10px solid transparent;
+ background-color:transparent;
+}
+
+.cm-s-neo .CodeMirror-linenumber {
+ padding:0;
+ color:#e0e2e5;
+}
+
+.cm-s-neo .CodeMirror-guttermarker { color: #1d75b3; }
+.cm-s-neo .CodeMirror-guttermarker-subtle { color: #e0e2e5; }
+
+.cm-s-neo .CodeMirror-cursor {
+ width: auto;
+ border: 0;
+ background: rgba(155,157,162,0.37);
+ z-index: 1;
+}
diff --git a/data/ext/editorText/codemirror/theme/night.css b/data/ext/editorText/codemirror/theme/night.css
index 016e55ee7..4dbb86624 100644
--- a/data/ext/editorText/codemirror/theme/night.css
+++ b/data/ext/editorText/codemirror/theme/night.css
@@ -1,10 +1,14 @@
/* Loosely based on the Midnight Textmate theme */
.cm-s-night.CodeMirror { background: #0a001f; color: #f8f8f8; }
-.cm-s-night div.CodeMirror-selected { background: #447 !important; }
+.cm-s-night div.CodeMirror-selected { background: #447; }
+.cm-s-night .CodeMirror-line::selection, .cm-s-night .CodeMirror-line > span::selection, .cm-s-night .CodeMirror-line > span > span::selection { background: rgba(68, 68, 119, .99); }
+.cm-s-night .CodeMirror-line::-moz-selection, .cm-s-night .CodeMirror-line > span::-moz-selection, .cm-s-night .CodeMirror-line > span > span::-moz-selection { background: rgba(68, 68, 119, .99); }
.cm-s-night .CodeMirror-gutters { background: #0a001f; border-right: 1px solid #aaa; }
+.cm-s-night .CodeMirror-guttermarker { color: white; }
+.cm-s-night .CodeMirror-guttermarker-subtle { color: #bbb; }
.cm-s-night .CodeMirror-linenumber { color: #f8f8f8; }
-.cm-s-night .CodeMirror-cursor { border-left: 1px solid white !important; }
+.cm-s-night .CodeMirror-cursor { border-left: 1px solid white; }
.cm-s-night span.cm-comment { color: #6900a1; }
.cm-s-night span.cm-atom { color: #845dc4; }
@@ -20,5 +24,5 @@
.cm-s-night span.cm-link { color: #845dc4; }
.cm-s-night span.cm-error { color: #9d1e15; }
-.cm-s-night .CodeMirror-activeline-background {background: #1C005A !important;}
-.cm-s-night .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
+.cm-s-night .CodeMirror-activeline-background { background: #1C005A; }
+.cm-s-night .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
diff --git a/data/ext/editorText/codemirror/theme/paraiso-dark.css b/data/ext/editorText/codemirror/theme/paraiso-dark.css
index ddefc55d2..aa9d207e6 100644
--- a/data/ext/editorText/codemirror/theme/paraiso-dark.css
+++ b/data/ext/editorText/codemirror/theme/paraiso-dark.css
@@ -8,27 +8,31 @@
*/
-.cm-s-paraiso-dark.CodeMirror {background: #2f1e2e; color: #b9b6b0;}
-.cm-s-paraiso-dark div.CodeMirror-selected {background: #41323f !important;}
-.cm-s-paraiso-dark .CodeMirror-gutters {background: #2f1e2e; border-right: 0px;}
-.cm-s-paraiso-dark .CodeMirror-linenumber {color: #776e71;}
-.cm-s-paraiso-dark .CodeMirror-cursor {border-left: 1px solid #8d8687 !important;}
-
-.cm-s-paraiso-dark span.cm-comment {color: #e96ba8;}
-.cm-s-paraiso-dark span.cm-atom {color: #815ba4;}
-.cm-s-paraiso-dark span.cm-number {color: #815ba4;}
-
-.cm-s-paraiso-dark span.cm-property, .cm-s-paraiso-dark span.cm-attribute {color: #48b685;}
-.cm-s-paraiso-dark span.cm-keyword {color: #ef6155;}
-.cm-s-paraiso-dark span.cm-string {color: #fec418;}
-
-.cm-s-paraiso-dark span.cm-variable {color: #48b685;}
-.cm-s-paraiso-dark span.cm-variable-2 {color: #06b6ef;}
-.cm-s-paraiso-dark span.cm-def {color: #f99b15;}
-.cm-s-paraiso-dark span.cm-bracket {color: #b9b6b0;}
-.cm-s-paraiso-dark span.cm-tag {color: #ef6155;}
-.cm-s-paraiso-dark span.cm-link {color: #815ba4;}
-.cm-s-paraiso-dark span.cm-error {background: #ef6155; color: #8d8687;}
-
-.cm-s-paraiso-dark .CodeMirror-activeline-background {background: #4D344A !important;}
-.cm-s-paraiso-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-paraiso-dark.CodeMirror { background: #2f1e2e; color: #b9b6b0; }
+.cm-s-paraiso-dark div.CodeMirror-selected { background: #41323f; }
+.cm-s-paraiso-dark .CodeMirror-line::selection, .cm-s-paraiso-dark .CodeMirror-line > span::selection, .cm-s-paraiso-dark .CodeMirror-line > span > span::selection { background: rgba(65, 50, 63, .99); }
+.cm-s-paraiso-dark .CodeMirror-line::-moz-selection, .cm-s-paraiso-dark .CodeMirror-line > span::-moz-selection, .cm-s-paraiso-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(65, 50, 63, .99); }
+.cm-s-paraiso-dark .CodeMirror-gutters { background: #2f1e2e; border-right: 0px; }
+.cm-s-paraiso-dark .CodeMirror-guttermarker { color: #ef6155; }
+.cm-s-paraiso-dark .CodeMirror-guttermarker-subtle { color: #776e71; }
+.cm-s-paraiso-dark .CodeMirror-linenumber { color: #776e71; }
+.cm-s-paraiso-dark .CodeMirror-cursor { border-left: 1px solid #8d8687; }
+
+.cm-s-paraiso-dark span.cm-comment { color: #e96ba8; }
+.cm-s-paraiso-dark span.cm-atom { color: #815ba4; }
+.cm-s-paraiso-dark span.cm-number { color: #815ba4; }
+
+.cm-s-paraiso-dark span.cm-property, .cm-s-paraiso-dark span.cm-attribute { color: #48b685; }
+.cm-s-paraiso-dark span.cm-keyword { color: #ef6155; }
+.cm-s-paraiso-dark span.cm-string { color: #fec418; }
+
+.cm-s-paraiso-dark span.cm-variable { color: #48b685; }
+.cm-s-paraiso-dark span.cm-variable-2 { color: #06b6ef; }
+.cm-s-paraiso-dark span.cm-def { color: #f99b15; }
+.cm-s-paraiso-dark span.cm-bracket { color: #b9b6b0; }
+.cm-s-paraiso-dark span.cm-tag { color: #ef6155; }
+.cm-s-paraiso-dark span.cm-link { color: #815ba4; }
+.cm-s-paraiso-dark span.cm-error { background: #ef6155; color: #8d8687; }
+
+.cm-s-paraiso-dark .CodeMirror-activeline-background { background: #4D344A; }
+.cm-s-paraiso-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
diff --git a/data/ext/editorText/codemirror/theme/paraiso-light.css b/data/ext/editorText/codemirror/theme/paraiso-light.css
index 8afb14be4..ae0c755f8 100644
--- a/data/ext/editorText/codemirror/theme/paraiso-light.css
+++ b/data/ext/editorText/codemirror/theme/paraiso-light.css
@@ -8,27 +8,31 @@
*/
-.cm-s-paraiso-light.CodeMirror {background: #e7e9db; color: #41323f;}
-.cm-s-paraiso-light div.CodeMirror-selected {background: #b9b6b0 !important;}
-.cm-s-paraiso-light .CodeMirror-gutters {background: #e7e9db; border-right: 0px;}
-.cm-s-paraiso-light .CodeMirror-linenumber {color: #8d8687;}
-.cm-s-paraiso-light .CodeMirror-cursor {border-left: 1px solid #776e71 !important;}
-
-.cm-s-paraiso-light span.cm-comment {color: #e96ba8;}
-.cm-s-paraiso-light span.cm-atom {color: #815ba4;}
-.cm-s-paraiso-light span.cm-number {color: #815ba4;}
-
-.cm-s-paraiso-light span.cm-property, .cm-s-paraiso-light span.cm-attribute {color: #48b685;}
-.cm-s-paraiso-light span.cm-keyword {color: #ef6155;}
-.cm-s-paraiso-light span.cm-string {color: #fec418;}
-
-.cm-s-paraiso-light span.cm-variable {color: #48b685;}
-.cm-s-paraiso-light span.cm-variable-2 {color: #06b6ef;}
-.cm-s-paraiso-light span.cm-def {color: #f99b15;}
-.cm-s-paraiso-light span.cm-bracket {color: #41323f;}
-.cm-s-paraiso-light span.cm-tag {color: #ef6155;}
-.cm-s-paraiso-light span.cm-link {color: #815ba4;}
-.cm-s-paraiso-light span.cm-error {background: #ef6155; color: #776e71;}
-
-.cm-s-paraiso-light .CodeMirror-activeline-background {background: #CFD1C4 !important;}
-.cm-s-paraiso-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-paraiso-light.CodeMirror { background: #e7e9db; color: #41323f; }
+.cm-s-paraiso-light div.CodeMirror-selected { background: #b9b6b0; }
+.cm-s-paraiso-light .CodeMirror-line::selection, .cm-s-paraiso-light .CodeMirror-line > span::selection, .cm-s-paraiso-light .CodeMirror-line > span > span::selection { background: #b9b6b0; }
+.cm-s-paraiso-light .CodeMirror-line::-moz-selection, .cm-s-paraiso-light .CodeMirror-line > span::-moz-selection, .cm-s-paraiso-light .CodeMirror-line > span > span::-moz-selection { background: #b9b6b0; }
+.cm-s-paraiso-light .CodeMirror-gutters { background: #e7e9db; border-right: 0px; }
+.cm-s-paraiso-light .CodeMirror-guttermarker { color: black; }
+.cm-s-paraiso-light .CodeMirror-guttermarker-subtle { color: #8d8687; }
+.cm-s-paraiso-light .CodeMirror-linenumber { color: #8d8687; }
+.cm-s-paraiso-light .CodeMirror-cursor { border-left: 1px solid #776e71; }
+
+.cm-s-paraiso-light span.cm-comment { color: #e96ba8; }
+.cm-s-paraiso-light span.cm-atom { color: #815ba4; }
+.cm-s-paraiso-light span.cm-number { color: #815ba4; }
+
+.cm-s-paraiso-light span.cm-property, .cm-s-paraiso-light span.cm-attribute { color: #48b685; }
+.cm-s-paraiso-light span.cm-keyword { color: #ef6155; }
+.cm-s-paraiso-light span.cm-string { color: #fec418; }
+
+.cm-s-paraiso-light span.cm-variable { color: #48b685; }
+.cm-s-paraiso-light span.cm-variable-2 { color: #06b6ef; }
+.cm-s-paraiso-light span.cm-def { color: #f99b15; }
+.cm-s-paraiso-light span.cm-bracket { color: #41323f; }
+.cm-s-paraiso-light span.cm-tag { color: #ef6155; }
+.cm-s-paraiso-light span.cm-link { color: #815ba4; }
+.cm-s-paraiso-light span.cm-error { background: #ef6155; color: #776e71; }
+
+.cm-s-paraiso-light .CodeMirror-activeline-background { background: #CFD1C4; }
+.cm-s-paraiso-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
diff --git a/data/ext/editorText/codemirror/theme/pastel-on-dark.css b/data/ext/editorText/codemirror/theme/pastel-on-dark.css
index 72a247527..719750920 100644
--- a/data/ext/editorText/codemirror/theme/pastel-on-dark.css
+++ b/data/ext/editorText/codemirror/theme/pastel-on-dark.css
@@ -13,14 +13,19 @@
line-height: 1.5;
font-size: 14px;
}
-.cm-s-pastel-on-dark div.CodeMirror-selected { background: rgba(221,240,255,0.2) !important; }
+.cm-s-pastel-on-dark div.CodeMirror-selected { background: rgba(221,240,255,0.2); }
+.cm-s-pastel-on-dark .CodeMirror-line::selection, .cm-s-pastel-on-dark .CodeMirror-line > span::selection, .cm-s-pastel-on-dark .CodeMirror-line > span > span::selection { background: rgba(221,240,255,0.2); }
+.cm-s-pastel-on-dark .CodeMirror-line::-moz-selection, .cm-s-pastel-on-dark .CodeMirror-line > span::-moz-selection, .cm-s-pastel-on-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(221,240,255,0.2); }
+
.cm-s-pastel-on-dark .CodeMirror-gutters {
background: #34302f;
border-right: 0px;
padding: 0 3px;
}
+.cm-s-pastel-on-dark .CodeMirror-guttermarker { color: white; }
+.cm-s-pastel-on-dark .CodeMirror-guttermarker-subtle { color: #8F938F; }
.cm-s-pastel-on-dark .CodeMirror-linenumber { color: #8F938F; }
-.cm-s-pastel-on-dark .CodeMirror-cursor { border-left: 1px solid #A7A7A7 !important; }
+.cm-s-pastel-on-dark .CodeMirror-cursor { border-left: 1px solid #A7A7A7; }
.cm-s-pastel-on-dark span.cm-comment { color: #A6C6FF; }
.cm-s-pastel-on-dark span.cm-atom { color: #DE8E30; }
.cm-s-pastel-on-dark span.cm-number { color: #CCCCCC; }
@@ -40,7 +45,7 @@
background: #757aD8;
color: #f8f8f0;
}
-.cm-s-pastel-on-dark .CodeMirror-activeline-background { background: rgba(255, 255, 255, 0.031) !important; }
+.cm-s-pastel-on-dark .CodeMirror-activeline-background { background: rgba(255, 255, 255, 0.031); }
.cm-s-pastel-on-dark .CodeMirror-matchingbracket {
border: 1px solid rgba(255,255,255,0.25);
color: #8F938F !important;
diff --git a/data/ext/editorText/codemirror/theme/railscasts.css b/data/ext/editorText/codemirror/theme/railscasts.css
new file mode 100644
index 000000000..aeff0449d
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/railscasts.css
@@ -0,0 +1,34 @@
+/*
+
+ Name: Railscasts
+ Author: Ryan Bates (http://railscasts.com)
+
+ CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
+ Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
+
+*/
+
+.cm-s-railscasts.CodeMirror {background: #2b2b2b; color: #f4f1ed;}
+.cm-s-railscasts div.CodeMirror-selected {background: #272935 !important;}
+.cm-s-railscasts .CodeMirror-gutters {background: #2b2b2b; border-right: 0px;}
+.cm-s-railscasts .CodeMirror-linenumber {color: #5a647e;}
+.cm-s-railscasts .CodeMirror-cursor {border-left: 1px solid #d4cfc9 !important;}
+
+.cm-s-railscasts span.cm-comment {color: #bc9458;}
+.cm-s-railscasts span.cm-atom {color: #b6b3eb;}
+.cm-s-railscasts span.cm-number {color: #b6b3eb;}
+
+.cm-s-railscasts span.cm-property, .cm-s-railscasts span.cm-attribute {color: #a5c261;}
+.cm-s-railscasts span.cm-keyword {color: #da4939;}
+.cm-s-railscasts span.cm-string {color: #ffc66d;}
+
+.cm-s-railscasts span.cm-variable {color: #a5c261;}
+.cm-s-railscasts span.cm-variable-2 {color: #6d9cbe;}
+.cm-s-railscasts span.cm-def {color: #cc7833;}
+.cm-s-railscasts span.cm-error {background: #da4939; color: #d4cfc9;}
+.cm-s-railscasts span.cm-bracket {color: #f4f1ed;}
+.cm-s-railscasts span.cm-tag {color: #da4939;}
+.cm-s-railscasts span.cm-link {color: #b6b3eb;}
+
+.cm-s-railscasts .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-railscasts .CodeMirror-activeline-background { background: #303040; }
diff --git a/data/ext/editorText/codemirror/theme/rubyblue.css b/data/ext/editorText/codemirror/theme/rubyblue.css
index 47fae0da9..76d33e779 100644
--- a/data/ext/editorText/codemirror/theme/rubyblue.css
+++ b/data/ext/editorText/codemirror/theme/rubyblue.css
@@ -1,8 +1,12 @@
.cm-s-rubyblue.CodeMirror { background: #112435; color: white; }
-.cm-s-rubyblue div.CodeMirror-selected { background: #38566F !important; }
+.cm-s-rubyblue div.CodeMirror-selected { background: #38566F; }
+.cm-s-rubyblue .CodeMirror-line::selection, .cm-s-rubyblue .CodeMirror-line > span::selection, .cm-s-rubyblue .CodeMirror-line > span > span::selection { background: rgba(56, 86, 111, 0.99); }
+.cm-s-rubyblue .CodeMirror-line::-moz-selection, .cm-s-rubyblue .CodeMirror-line > span::-moz-selection, .cm-s-rubyblue .CodeMirror-line > span > span::-moz-selection { background: rgba(56, 86, 111, 0.99); }
.cm-s-rubyblue .CodeMirror-gutters { background: #1F4661; border-right: 7px solid #3E7087; }
+.cm-s-rubyblue .CodeMirror-guttermarker { color: white; }
+.cm-s-rubyblue .CodeMirror-guttermarker-subtle { color: #3E7087; }
.cm-s-rubyblue .CodeMirror-linenumber { color: white; }
-.cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white !important; }
+.cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white; }
.cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; line-height: 1em; }
.cm-s-rubyblue span.cm-atom { color: #F4C20B; }
@@ -18,4 +22,4 @@
.cm-s-rubyblue span.cm-builtin, .cm-s-rubyblue span.cm-special { color: #FF9D00; }
.cm-s-rubyblue span.cm-error { color: #AF2018; }
-.cm-s-rubyblue .CodeMirror-activeline-background {background: #173047 !important;}
+.cm-s-rubyblue .CodeMirror-activeline-background { background: #173047; }
diff --git a/data/ext/editorText/codemirror/theme/seti.css b/data/ext/editorText/codemirror/theme/seti.css
new file mode 100644
index 000000000..6632d3fc7
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/seti.css
@@ -0,0 +1,44 @@
+/*
+
+ Name: seti
+ Author: Michael Kaminsky (http://github.com/mkaminsky11)
+
+ Original seti color scheme by Jesse Weed (https://github.com/jesseweed/seti-syntax)
+
+*/
+
+
+.cm-s-seti.CodeMirror {
+ background-color: #151718 !important;
+ color: #CFD2D1 !important;
+ border: none;
+}
+.cm-s-seti .CodeMirror-gutters {
+ color: #404b53;
+ background-color: #0E1112;
+ border: none;
+}
+.cm-s-seti .CodeMirror-cursor { border-left: solid thin #f8f8f0; }
+.cm-s-seti .CodeMirror-linenumber { color: #6D8A88; }
+.cm-s-seti.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
+.cm-s-seti .CodeMirror-line::selection, .cm-s-seti .CodeMirror-line > span::selection, .cm-s-seti .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
+.cm-s-seti .CodeMirror-line::-moz-selection, .cm-s-seti .CodeMirror-line > span::-moz-selection, .cm-s-seti .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
+.cm-s-seti span.cm-comment { color: #41535b; }
+.cm-s-seti span.cm-string, .cm-s-seti span.cm-string-2 { color: #55b5db; }
+.cm-s-seti span.cm-number { color: #cd3f45; }
+.cm-s-seti span.cm-variable { color: #55b5db; }
+.cm-s-seti span.cm-variable-2 { color: #a074c4; }
+.cm-s-seti span.cm-def { color: #55b5db; }
+.cm-s-seti span.cm-keyword { color: #ff79c6; }
+.cm-s-seti span.cm-operator { color: #9fca56; }
+.cm-s-seti span.cm-keyword { color: #e6cd69; }
+.cm-s-seti span.cm-atom { color: #cd3f45; }
+.cm-s-seti span.cm-meta { color: #55b5db; }
+.cm-s-seti span.cm-tag { color: #55b5db; }
+.cm-s-seti span.cm-attribute { color: #9fca56; }
+.cm-s-seti span.cm-qualifier { color: #9fca56; }
+.cm-s-seti span.cm-property { color: #a074c4; }
+.cm-s-seti span.cm-variable-3 { color: #9fca56; }
+.cm-s-seti span.cm-builtin { color: #9fca56; }
+.cm-s-seti .CodeMirror-activeline-background { background: #101213; }
+.cm-s-seti .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
diff --git a/data/ext/editorText/codemirror/theme/solarized.css b/data/ext/editorText/codemirror/theme/solarized.css
index 39fc83d7c..7882c9376 100644
--- a/data/ext/editorText/codemirror/theme/solarized.css
+++ b/data/ext/editorText/codemirror/theme/solarized.css
@@ -47,18 +47,20 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
text-shadow: none;
}
+.cm-s-solarized .cm-header { color: #586e75; }
+.cm-s-solarized .cm-quote { color: #93a1a1; }
-.cm-s-solarized .cm-keyword { color: #cb4b16 }
+.cm-s-solarized .cm-keyword { color: #cb4b16; }
.cm-s-solarized .cm-atom { color: #d33682; }
.cm-s-solarized .cm-number { color: #d33682; }
.cm-s-solarized .cm-def { color: #2aa198; }
-.cm-s-solarized .cm-variable { color: #268bd2; }
+.cm-s-solarized .cm-variable { color: #839496; }
.cm-s-solarized .cm-variable-2 { color: #b58900; }
.cm-s-solarized .cm-variable-3 { color: #6c71c4; }
.cm-s-solarized .cm-property { color: #2aa198; }
-.cm-s-solarized .cm-operator {color: #6c71c4;}
+.cm-s-solarized .cm-operator { color: #6c71c4; }
.cm-s-solarized .cm-comment { color: #586e75; font-style:italic; }
@@ -71,10 +73,8 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
.cm-s-solarized .cm-bracket { color: #cb4b16; }
.cm-s-solarized .CodeMirror-matchingbracket { color: #859900; }
.cm-s-solarized .CodeMirror-nonmatchingbracket { color: #dc322f; }
-.cm-s-solarized .cm-tag { color: #93a1a1 }
-.cm-s-solarized .cm-attribute { color: #2aa198; }
-.cm-s-solarized .cm-header { color: #586e75; }
-.cm-s-solarized .cm-quote { color: #93a1a1; }
+.cm-s-solarized .cm-tag { color: #93a1a1; }
+.cm-s-solarized .cm-attribute { color: #2aa198; }
.cm-s-solarized .cm-hr {
color: transparent;
border-top: 1px solid #586e75;
@@ -88,24 +88,19 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
text-decoration-style: dotted;
}
.cm-s-solarized .cm-strong { color: #eee; }
-.cm-s-solarized .cm-tab:before {
- content: "➤"; /*visualize tab character*/
- color: #586e75;
- position:absolute;
-}
.cm-s-solarized .cm-error,
.cm-s-solarized .cm-invalidchar {
color: #586e75;
border-bottom: 1px dotted #dc322f;
}
-.cm-s-solarized.cm-s-dark .CodeMirror-selected {
- background: #073642;
-}
+.cm-s-solarized.cm-s-dark div.CodeMirror-selected { background: #073642; }
+.cm-s-solarized.cm-s-dark.CodeMirror ::selection { background: rgba(7, 54, 66, 0.99); }
+.cm-s-solarized.cm-s-dark .CodeMirror-line::-moz-selection, .cm-s-dark .CodeMirror-line > span::-moz-selection, .cm-s-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(7, 54, 66, 0.99); }
-.cm-s-solarized.cm-s-light .CodeMirror-selected {
- background: #eee8d5;
-}
+.cm-s-solarized.cm-s-light div.CodeMirror-selected { background: #eee8d5; }
+.cm-s-solarized.cm-s-light .CodeMirror-line::selection, .cm-s-light .CodeMirror-line > span::selection, .cm-s-light .CodeMirror-line > span > span::selection { background: #eee8d5; }
+.cm-s-solarized.cm-s-light .CodeMirror-line::-moz-selection, .cm-s-ligh .CodeMirror-line > span::-moz-selection, .cm-s-ligh .CodeMirror-line > span > span::-moz-selection { background: #eee8d5; }
/* Editor styling */
@@ -146,14 +141,15 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
color: #586e75;
padding: 0 5px;
}
+.cm-s-solarized .CodeMirror-guttermarker-subtle { color: #586e75; }
+.cm-s-solarized.cm-s-dark .CodeMirror-guttermarker { color: #ddd; }
+.cm-s-solarized.cm-s-light .CodeMirror-guttermarker { color: #cb4b16; }
.cm-s-solarized .CodeMirror-gutter .CodeMirror-gutter-text {
color: #586e75;
}
-.cm-s-solarized .CodeMirror-lines .CodeMirror-cursor {
- border-left: 1px solid #819090;
-}
+.cm-s-solarized .CodeMirror-cursor { border-left: 1px solid #819090; }
/*
Active line. Negative margin compensates left padding of the text in the
diff --git a/data/ext/editorText/codemirror/theme/the-matrix.css b/data/ext/editorText/codemirror/theme/the-matrix.css
index 0c3704a62..3912a8dbd 100644
--- a/data/ext/editorText/codemirror/theme/the-matrix.css
+++ b/data/ext/editorText/codemirror/theme/the-matrix.css
@@ -1,26 +1,30 @@
.cm-s-the-matrix.CodeMirror { background: #000000; color: #00FF00; }
-.cm-s-the-matrix div.CodeMirror-selected { background: #2D2D2D !important; }
+.cm-s-the-matrix div.CodeMirror-selected { background: #2D2D2D; }
+.cm-s-the-matrix .CodeMirror-line::selection, .cm-s-the-matrix .CodeMirror-line > span::selection, .cm-s-the-matrix .CodeMirror-line > span > span::selection { background: rgba(45, 45, 45, 0.99); }
+.cm-s-the-matrix .CodeMirror-line::-moz-selection, .cm-s-the-matrix .CodeMirror-line > span::-moz-selection, .cm-s-the-matrix .CodeMirror-line > span > span::-moz-selection { background: rgba(45, 45, 45, 0.99); }
.cm-s-the-matrix .CodeMirror-gutters { background: #060; border-right: 2px solid #00FF00; }
+.cm-s-the-matrix .CodeMirror-guttermarker { color: #0f0; }
+.cm-s-the-matrix .CodeMirror-guttermarker-subtle { color: white; }
.cm-s-the-matrix .CodeMirror-linenumber { color: #FFFFFF; }
-.cm-s-the-matrix .CodeMirror-cursor { border-left: 1px solid #00FF00 !important; }
+.cm-s-the-matrix .CodeMirror-cursor { border-left: 1px solid #00FF00; }
-.cm-s-the-matrix span.cm-keyword {color: #008803; font-weight: bold;}
-.cm-s-the-matrix span.cm-atom {color: #3FF;}
-.cm-s-the-matrix span.cm-number {color: #FFB94F;}
-.cm-s-the-matrix span.cm-def {color: #99C;}
-.cm-s-the-matrix span.cm-variable {color: #F6C;}
-.cm-s-the-matrix span.cm-variable-2 {color: #C6F;}
-.cm-s-the-matrix span.cm-variable-3 {color: #96F;}
-.cm-s-the-matrix span.cm-property {color: #62FFA0;}
-.cm-s-the-matrix span.cm-operator {color: #999}
-.cm-s-the-matrix span.cm-comment {color: #CCCCCC;}
-.cm-s-the-matrix span.cm-string {color: #39C;}
-.cm-s-the-matrix span.cm-meta {color: #C9F;}
-.cm-s-the-matrix span.cm-qualifier {color: #FFF700;}
-.cm-s-the-matrix span.cm-builtin {color: #30a;}
-.cm-s-the-matrix span.cm-bracket {color: #cc7;}
-.cm-s-the-matrix span.cm-tag {color: #FFBD40;}
-.cm-s-the-matrix span.cm-attribute {color: #FFF700;}
-.cm-s-the-matrix span.cm-error {color: #FF0000;}
+.cm-s-the-matrix span.cm-keyword { color: #008803; font-weight: bold; }
+.cm-s-the-matrix span.cm-atom { color: #3FF; }
+.cm-s-the-matrix span.cm-number { color: #FFB94F; }
+.cm-s-the-matrix span.cm-def { color: #99C; }
+.cm-s-the-matrix span.cm-variable { color: #F6C; }
+.cm-s-the-matrix span.cm-variable-2 { color: #C6F; }
+.cm-s-the-matrix span.cm-variable-3 { color: #96F; }
+.cm-s-the-matrix span.cm-property { color: #62FFA0; }
+.cm-s-the-matrix span.cm-operator { color: #999; }
+.cm-s-the-matrix span.cm-comment { color: #CCCCCC; }
+.cm-s-the-matrix span.cm-string { color: #39C; }
+.cm-s-the-matrix span.cm-meta { color: #C9F; }
+.cm-s-the-matrix span.cm-qualifier { color: #FFF700; }
+.cm-s-the-matrix span.cm-builtin { color: #30a; }
+.cm-s-the-matrix span.cm-bracket { color: #cc7; }
+.cm-s-the-matrix span.cm-tag { color: #FFBD40; }
+.cm-s-the-matrix span.cm-attribute { color: #FFF700; }
+.cm-s-the-matrix span.cm-error { color: #FF0000; }
-.cm-s-the-matrix .CodeMirror-activeline-background {background: #040;}
+.cm-s-the-matrix .CodeMirror-activeline-background { background: #040; }
diff --git a/data/ext/editorText/codemirror/theme/tomorrow-night-bright.css b/data/ext/editorText/codemirror/theme/tomorrow-night-bright.css
new file mode 100644
index 000000000..b6dd4a927
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/tomorrow-night-bright.css
@@ -0,0 +1,35 @@
+/*
+
+ Name: Tomorrow Night - Bright
+ Author: Chris Kempson
+
+ Port done by Gerard Braad <[email protected]>
+
+*/
+
+.cm-s-tomorrow-night-bright.CodeMirror { background: #000000; color: #eaeaea; }
+.cm-s-tomorrow-night-bright div.CodeMirror-selected { background: #424242; }
+.cm-s-tomorrow-night-bright .CodeMirror-gutters { background: #000000; border-right: 0px; }
+.cm-s-tomorrow-night-bright .CodeMirror-guttermarker { color: #e78c45; }
+.cm-s-tomorrow-night-bright .CodeMirror-guttermarker-subtle { color: #777; }
+.cm-s-tomorrow-night-bright .CodeMirror-linenumber { color: #424242; }
+.cm-s-tomorrow-night-bright .CodeMirror-cursor { border-left: 1px solid #6A6A6A; }
+
+.cm-s-tomorrow-night-bright span.cm-comment { color: #d27b53; }
+.cm-s-tomorrow-night-bright span.cm-atom { color: #a16a94; }
+.cm-s-tomorrow-night-bright span.cm-number { color: #a16a94; }
+
+.cm-s-tomorrow-night-bright span.cm-property, .cm-s-tomorrow-night-bright span.cm-attribute { color: #99cc99; }
+.cm-s-tomorrow-night-bright span.cm-keyword { color: #d54e53; }
+.cm-s-tomorrow-night-bright span.cm-string { color: #e7c547; }
+
+.cm-s-tomorrow-night-bright span.cm-variable { color: #b9ca4a; }
+.cm-s-tomorrow-night-bright span.cm-variable-2 { color: #7aa6da; }
+.cm-s-tomorrow-night-bright span.cm-def { color: #e78c45; }
+.cm-s-tomorrow-night-bright span.cm-bracket { color: #eaeaea; }
+.cm-s-tomorrow-night-bright span.cm-tag { color: #d54e53; }
+.cm-s-tomorrow-night-bright span.cm-link { color: #a16a94; }
+.cm-s-tomorrow-night-bright span.cm-error { background: #d54e53; color: #6A6A6A; }
+
+.cm-s-tomorrow-night-bright .CodeMirror-activeline-background { background: #2a2a2a; }
+.cm-s-tomorrow-night-bright .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
diff --git a/data/ext/editorText/codemirror/theme/tomorrow-night-eighties.css b/data/ext/editorText/codemirror/theme/tomorrow-night-eighties.css
index 85c2a4a78..2a9debc32 100644
--- a/data/ext/editorText/codemirror/theme/tomorrow-night-eighties.css
+++ b/data/ext/editorText/codemirror/theme/tomorrow-night-eighties.css
@@ -8,27 +8,31 @@
*/
-.cm-s-tomorrow-night-eighties.CodeMirror {background: #000000; color: #CCCCCC;}
-.cm-s-tomorrow-night-eighties div.CodeMirror-selected {background: #2D2D2D !important;}
-.cm-s-tomorrow-night-eighties .CodeMirror-gutters {background: #000000; border-right: 0px;}
-.cm-s-tomorrow-night-eighties .CodeMirror-linenumber {color: #515151;}
-.cm-s-tomorrow-night-eighties .CodeMirror-cursor {border-left: 1px solid #6A6A6A !important;}
-
-.cm-s-tomorrow-night-eighties span.cm-comment {color: #d27b53;}
-.cm-s-tomorrow-night-eighties span.cm-atom {color: #a16a94;}
-.cm-s-tomorrow-night-eighties span.cm-number {color: #a16a94;}
-
-.cm-s-tomorrow-night-eighties span.cm-property, .cm-s-tomorrow-night-eighties span.cm-attribute {color: #99cc99;}
-.cm-s-tomorrow-night-eighties span.cm-keyword {color: #f2777a;}
-.cm-s-tomorrow-night-eighties span.cm-string {color: #ffcc66;}
-
-.cm-s-tomorrow-night-eighties span.cm-variable {color: #99cc99;}
-.cm-s-tomorrow-night-eighties span.cm-variable-2 {color: #6699cc;}
-.cm-s-tomorrow-night-eighties span.cm-def {color: #f99157;}
-.cm-s-tomorrow-night-eighties span.cm-bracket {color: #CCCCCC;}
-.cm-s-tomorrow-night-eighties span.cm-tag {color: #f2777a;}
-.cm-s-tomorrow-night-eighties span.cm-link {color: #a16a94;}
-.cm-s-tomorrow-night-eighties span.cm-error {background: #f2777a; color: #6A6A6A;}
-
-.cm-s-tomorrow-night-eighties .CodeMirror-activeline-background {background: #343600 !important;}
-.cm-s-tomorrow-night-eighties .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-tomorrow-night-eighties.CodeMirror { background: #000000; color: #CCCCCC; }
+.cm-s-tomorrow-night-eighties div.CodeMirror-selected { background: #2D2D2D; }
+.cm-s-tomorrow-night-eighties .CodeMirror-line::selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span::selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span > span::selection { background: rgba(45, 45, 45, 0.99); }
+.cm-s-tomorrow-night-eighties .CodeMirror-line::-moz-selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span::-moz-selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span > span::-moz-selection { background: rgba(45, 45, 45, 0.99); }
+.cm-s-tomorrow-night-eighties .CodeMirror-gutters { background: #000000; border-right: 0px; }
+.cm-s-tomorrow-night-eighties .CodeMirror-guttermarker { color: #f2777a; }
+.cm-s-tomorrow-night-eighties .CodeMirror-guttermarker-subtle { color: #777; }
+.cm-s-tomorrow-night-eighties .CodeMirror-linenumber { color: #515151; }
+.cm-s-tomorrow-night-eighties .CodeMirror-cursor { border-left: 1px solid #6A6A6A; }
+
+.cm-s-tomorrow-night-eighties span.cm-comment { color: #d27b53; }
+.cm-s-tomorrow-night-eighties span.cm-atom { color: #a16a94; }
+.cm-s-tomorrow-night-eighties span.cm-number { color: #a16a94; }
+
+.cm-s-tomorrow-night-eighties span.cm-property, .cm-s-tomorrow-night-eighties span.cm-attribute { color: #99cc99; }
+.cm-s-tomorrow-night-eighties span.cm-keyword { color: #f2777a; }
+.cm-s-tomorrow-night-eighties span.cm-string { color: #ffcc66; }
+
+.cm-s-tomorrow-night-eighties span.cm-variable { color: #99cc99; }
+.cm-s-tomorrow-night-eighties span.cm-variable-2 { color: #6699cc; }
+.cm-s-tomorrow-night-eighties span.cm-def { color: #f99157; }
+.cm-s-tomorrow-night-eighties span.cm-bracket { color: #CCCCCC; }
+.cm-s-tomorrow-night-eighties span.cm-tag { color: #f2777a; }
+.cm-s-tomorrow-night-eighties span.cm-link { color: #a16a94; }
+.cm-s-tomorrow-night-eighties span.cm-error { background: #f2777a; color: #6A6A6A; }
+
+.cm-s-tomorrow-night-eighties .CodeMirror-activeline-background { background: #343600; }
+.cm-s-tomorrow-night-eighties .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
diff --git a/data/ext/editorText/codemirror/theme/ttcn.css b/data/ext/editorText/codemirror/theme/ttcn.css
new file mode 100644
index 000000000..b3d465645
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/ttcn.css
@@ -0,0 +1,64 @@
+.cm-s-ttcn .cm-quote { color: #090; }
+.cm-s-ttcn .cm-negative { color: #d44; }
+.cm-s-ttcn .cm-positive { color: #292; }
+.cm-s-ttcn .cm-header, .cm-strong { font-weight: bold; }
+.cm-s-ttcn .cm-em { font-style: italic; }
+.cm-s-ttcn .cm-link { text-decoration: underline; }
+.cm-s-ttcn .cm-strikethrough { text-decoration: line-through; }
+.cm-s-ttcn .cm-header { color: #00f; font-weight: bold; }
+
+.cm-s-ttcn .cm-atom { color: #219; }
+.cm-s-ttcn .cm-attribute { color: #00c; }
+.cm-s-ttcn .cm-bracket { color: #997; }
+.cm-s-ttcn .cm-comment { color: #333333; }
+.cm-s-ttcn .cm-def { color: #00f; }
+.cm-s-ttcn .cm-em { font-style: italic; }
+.cm-s-ttcn .cm-error { color: #f00; }
+.cm-s-ttcn .cm-hr { color: #999; }
+.cm-s-ttcn .cm-invalidchar { color: #f00; }
+.cm-s-ttcn .cm-keyword { font-weight:bold; }
+.cm-s-ttcn .cm-link { color: #00c; text-decoration: underline; }
+.cm-s-ttcn .cm-meta { color: #555; }
+.cm-s-ttcn .cm-negative { color: #d44; }
+.cm-s-ttcn .cm-positive { color: #292; }
+.cm-s-ttcn .cm-qualifier { color: #555; }
+.cm-s-ttcn .cm-strikethrough { text-decoration: line-through; }
+.cm-s-ttcn .cm-string { color: #006400; }
+.cm-s-ttcn .cm-string-2 { color: #f50; }
+.cm-s-ttcn .cm-strong { font-weight: bold; }
+.cm-s-ttcn .cm-tag { color: #170; }
+.cm-s-ttcn .cm-variable { color: #8B2252; }
+.cm-s-ttcn .cm-variable-2 { color: #05a; }
+.cm-s-ttcn .cm-variable-3 { color: #085; }
+
+.cm-s-ttcn .cm-invalidchar { color: #f00; }
+
+/* ASN */
+.cm-s-ttcn .cm-accessTypes,
+.cm-s-ttcn .cm-compareTypes { color: #27408B; }
+.cm-s-ttcn .cm-cmipVerbs { color: #8B2252; }
+.cm-s-ttcn .cm-modifier { color:#D2691E; }
+.cm-s-ttcn .cm-status { color:#8B4545; }
+.cm-s-ttcn .cm-storage { color:#A020F0; }
+.cm-s-ttcn .cm-tags { color:#006400; }
+
+/* CFG */
+.cm-s-ttcn .cm-externalCommands { color: #8B4545; font-weight:bold; }
+.cm-s-ttcn .cm-fileNCtrlMaskOptions,
+.cm-s-ttcn .cm-sectionTitle { color: #2E8B57; font-weight:bold; }
+
+/* TTCN */
+.cm-s-ttcn .cm-booleanConsts,
+.cm-s-ttcn .cm-otherConsts,
+.cm-s-ttcn .cm-verdictConsts { color: #006400; }
+.cm-s-ttcn .cm-configOps,
+.cm-s-ttcn .cm-functionOps,
+.cm-s-ttcn .cm-portOps,
+.cm-s-ttcn .cm-sutOps,
+.cm-s-ttcn .cm-timerOps,
+.cm-s-ttcn .cm-verdictOps { color: #0000FF; }
+.cm-s-ttcn .cm-preprocessor,
+.cm-s-ttcn .cm-templateMatch,
+.cm-s-ttcn .cm-ttcn3Macros { color: #27408B; }
+.cm-s-ttcn .cm-types { color: #A52A2A; font-weight:bold; }
+.cm-s-ttcn .cm-visibilityModifiers { font-weight:bold; }
diff --git a/data/ext/editorText/codemirror/theme/twilight.css b/data/ext/editorText/codemirror/theme/twilight.css
index 19d6abadd..d342b899f 100644
--- a/data/ext/editorText/codemirror/theme/twilight.css
+++ b/data/ext/editorText/codemirror/theme/twilight.css
@@ -1,11 +1,15 @@
.cm-s-twilight.CodeMirror { background: #141414; color: #f7f7f7; } /**/
-.cm-s-twilight .CodeMirror-selected { background: #323232 !important; } /**/
+.cm-s-twilight div.CodeMirror-selected { background: #323232; } /**/
+.cm-s-twilight .CodeMirror-line::selection, .cm-s-twilight .CodeMirror-line > span::selection, .cm-s-twilight .CodeMirror-line > span > span::selection { background: rgba(50, 50, 50, 0.99); }
+.cm-s-twilight .CodeMirror-line::-moz-selection, .cm-s-twilight .CodeMirror-line > span::-moz-selection, .cm-s-twilight .CodeMirror-line > span > span::-moz-selection { background: rgba(50, 50, 50, 0.99); }
.cm-s-twilight .CodeMirror-gutters { background: #222; border-right: 1px solid #aaa; }
+.cm-s-twilight .CodeMirror-guttermarker { color: white; }
+.cm-s-twilight .CodeMirror-guttermarker-subtle { color: #aaa; }
.cm-s-twilight .CodeMirror-linenumber { color: #aaa; }
-.cm-s-twilight .CodeMirror-cursor { border-left: 1px solid white !important; }
+.cm-s-twilight .CodeMirror-cursor { border-left: 1px solid white; }
-.cm-s-twilight .cm-keyword { color: #f9ee98; } /**/
+.cm-s-twilight .cm-keyword { color: #f9ee98; } /**/
.cm-s-twilight .cm-atom { color: #FC0; }
.cm-s-twilight .cm-number { color: #ca7841; } /**/
.cm-s-twilight .cm-def { color: #8DA6CE; }
@@ -14,15 +18,15 @@
.cm-s-twilight .cm-operator { color: #cda869; } /**/
.cm-s-twilight .cm-comment { color:#777; font-style:italic; font-weight:normal; } /**/
.cm-s-twilight .cm-string { color:#8f9d6a; font-style:italic; } /**/
-.cm-s-twilight .cm-string-2 { color:#bd6b18 } /*?*/
+.cm-s-twilight .cm-string-2 { color:#bd6b18; } /*?*/
.cm-s-twilight .cm-meta { background-color:#141414; color:#f7f7f7; } /*?*/
.cm-s-twilight .cm-builtin { color: #cda869; } /*?*/
.cm-s-twilight .cm-tag { color: #997643; } /**/
.cm-s-twilight .cm-attribute { color: #d6bb6d; } /*?*/
.cm-s-twilight .cm-header { color: #FF6400; }
.cm-s-twilight .cm-hr { color: #AEAEAE; }
-.cm-s-twilight .cm-link { color:#ad9361; font-style:italic; text-decoration:none; } /**/
+.cm-s-twilight .cm-link { color:#ad9361; font-style:italic; text-decoration:none; } /**/
.cm-s-twilight .cm-error { border-bottom: 1px solid red; }
-.cm-s-twilight .CodeMirror-activeline-background {background: #27282E !important;}
-.cm-s-twilight .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
+.cm-s-twilight .CodeMirror-activeline-background { background: #27282E; }
+.cm-s-twilight .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
diff --git a/data/ext/editorText/codemirror/theme/vibrant-ink.css b/data/ext/editorText/codemirror/theme/vibrant-ink.css
index 0206225bf..ac4ec6d87 100644
--- a/data/ext/editorText/codemirror/theme/vibrant-ink.css
+++ b/data/ext/editorText/codemirror/theme/vibrant-ink.css
@@ -1,22 +1,26 @@
/* Taken from the popular Visual Studio Vibrant Ink Schema */
.cm-s-vibrant-ink.CodeMirror { background: black; color: white; }
-.cm-s-vibrant-ink .CodeMirror-selected { background: #35493c !important; }
+.cm-s-vibrant-ink div.CodeMirror-selected { background: #35493c; }
+.cm-s-vibrant-ink .CodeMirror-line::selection, .cm-s-vibrant-ink .CodeMirror-line > span::selection, .cm-s-vibrant-ink .CodeMirror-line > span > span::selection { background: rgba(53, 73, 60, 0.99); }
+.cm-s-vibrant-ink .CodeMirror-line::-moz-selection, .cm-s-vibrant-ink .CodeMirror-line > span::-moz-selection, .cm-s-vibrant-ink .CodeMirror-line > span > span::-moz-selection { background: rgba(53, 73, 60, 0.99); }
.cm-s-vibrant-ink .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
+.cm-s-vibrant-ink .CodeMirror-guttermarker { color: white; }
+.cm-s-vibrant-ink .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
.cm-s-vibrant-ink .CodeMirror-linenumber { color: #d0d0d0; }
-.cm-s-vibrant-ink .CodeMirror-cursor { border-left: 1px solid white !important; }
+.cm-s-vibrant-ink .CodeMirror-cursor { border-left: 1px solid white; }
-.cm-s-vibrant-ink .cm-keyword { color: #CC7832; }
+.cm-s-vibrant-ink .cm-keyword { color: #CC7832; }
.cm-s-vibrant-ink .cm-atom { color: #FC0; }
.cm-s-vibrant-ink .cm-number { color: #FFEE98; }
.cm-s-vibrant-ink .cm-def { color: #8DA6CE; }
-.cm-s-vibrant-ink span.cm-variable-2, .cm-s-vibrant span.cm-tag { color: #FFC66D }
-.cm-s-vibrant-ink span.cm-variable-3, .cm-s-vibrant span.cm-def { color: #FFC66D }
+.cm-s-vibrant-ink span.cm-variable-2, .cm-s-vibrant span.cm-tag { color: #FFC66D; }
+.cm-s-vibrant-ink span.cm-variable-3, .cm-s-vibrant span.cm-def { color: #FFC66D; }
.cm-s-vibrant-ink .cm-operator { color: #888; }
.cm-s-vibrant-ink .cm-comment { color: gray; font-weight: bold; }
-.cm-s-vibrant-ink .cm-string { color: #A5C25C }
-.cm-s-vibrant-ink .cm-string-2 { color: red }
+.cm-s-vibrant-ink .cm-string { color: #A5C25C; }
+.cm-s-vibrant-ink .cm-string-2 { color: red; }
.cm-s-vibrant-ink .cm-meta { color: #D8FA3C; }
.cm-s-vibrant-ink .cm-builtin { color: #8DA6CE; }
.cm-s-vibrant-ink .cm-tag { color: #8DA6CE; }
@@ -26,5 +30,5 @@
.cm-s-vibrant-ink .cm-link { color: blue; }
.cm-s-vibrant-ink .cm-error { border-bottom: 1px solid red; }
-.cm-s-vibrant-ink .CodeMirror-activeline-background {background: #27282E !important;}
-.cm-s-vibrant-ink .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
+.cm-s-vibrant-ink .CodeMirror-activeline-background { background: #27282E; }
+.cm-s-vibrant-ink .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
diff --git a/data/ext/editorText/codemirror/theme/xq-dark.css b/data/ext/editorText/codemirror/theme/xq-dark.css
index 4a0b2138c..e3bd960bb 100644
--- a/data/ext/editorText/codemirror/theme/xq-dark.css
+++ b/data/ext/editorText/codemirror/theme/xq-dark.css
@@ -21,29 +21,33 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
.cm-s-xq-dark.CodeMirror { background: #0a001f; color: #f8f8f8; }
-.cm-s-xq-dark .CodeMirror-selected { background: #27007A !important; }
+.cm-s-xq-dark div.CodeMirror-selected { background: #27007A; }
+.cm-s-xq-dark .CodeMirror-line::selection, .cm-s-xq-dark .CodeMirror-line > span::selection, .cm-s-xq-dark .CodeMirror-line > span > span::selection { background: rgba(39, 0, 122, 0.99); }
+.cm-s-xq-dark .CodeMirror-line::-moz-selection, .cm-s-xq-dark .CodeMirror-line > span::-moz-selection, .cm-s-xq-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(39, 0, 122, 0.99); }
.cm-s-xq-dark .CodeMirror-gutters { background: #0a001f; border-right: 1px solid #aaa; }
+.cm-s-xq-dark .CodeMirror-guttermarker { color: #FFBD40; }
+.cm-s-xq-dark .CodeMirror-guttermarker-subtle { color: #f8f8f8; }
.cm-s-xq-dark .CodeMirror-linenumber { color: #f8f8f8; }
-.cm-s-xq-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
+.cm-s-xq-dark .CodeMirror-cursor { border-left: 1px solid white; }
-.cm-s-xq-dark span.cm-keyword {color: #FFBD40;}
-.cm-s-xq-dark span.cm-atom {color: #6C8CD5;}
-.cm-s-xq-dark span.cm-number {color: #164;}
-.cm-s-xq-dark span.cm-def {color: #FFF; text-decoration:underline;}
-.cm-s-xq-dark span.cm-variable {color: #FFF;}
-.cm-s-xq-dark span.cm-variable-2 {color: #EEE;}
-.cm-s-xq-dark span.cm-variable-3 {color: #DDD;}
+.cm-s-xq-dark span.cm-keyword { color: #FFBD40; }
+.cm-s-xq-dark span.cm-atom { color: #6C8CD5; }
+.cm-s-xq-dark span.cm-number { color: #164; }
+.cm-s-xq-dark span.cm-def { color: #FFF; text-decoration:underline; }
+.cm-s-xq-dark span.cm-variable { color: #FFF; }
+.cm-s-xq-dark span.cm-variable-2 { color: #EEE; }
+.cm-s-xq-dark span.cm-variable-3 { color: #DDD; }
.cm-s-xq-dark span.cm-property {}
.cm-s-xq-dark span.cm-operator {}
-.cm-s-xq-dark span.cm-comment {color: gray;}
-.cm-s-xq-dark span.cm-string {color: #9FEE00;}
-.cm-s-xq-dark span.cm-meta {color: yellow;}
-.cm-s-xq-dark span.cm-qualifier {color: #FFF700;}
-.cm-s-xq-dark span.cm-builtin {color: #30a;}
-.cm-s-xq-dark span.cm-bracket {color: #cc7;}
-.cm-s-xq-dark span.cm-tag {color: #FFBD40;}
-.cm-s-xq-dark span.cm-attribute {color: #FFF700;}
-.cm-s-xq-dark span.cm-error {color: #f00;}
+.cm-s-xq-dark span.cm-comment { color: gray; }
+.cm-s-xq-dark span.cm-string { color: #9FEE00; }
+.cm-s-xq-dark span.cm-meta { color: yellow; }
+.cm-s-xq-dark span.cm-qualifier { color: #FFF700; }
+.cm-s-xq-dark span.cm-builtin { color: #30a; }
+.cm-s-xq-dark span.cm-bracket { color: #cc7; }
+.cm-s-xq-dark span.cm-tag { color: #FFBD40; }
+.cm-s-xq-dark span.cm-attribute { color: #FFF700; }
+.cm-s-xq-dark span.cm-error { color: #f00; }
-.cm-s-xq-dark .CodeMirror-activeline-background {background: #27282E !important;}
-.cm-s-xq-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
\ No newline at end of file
+.cm-s-xq-dark .CodeMirror-activeline-background { background: #27282E; }
+.cm-s-xq-dark .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
diff --git a/data/ext/editorText/codemirror/theme/xq-light.css b/data/ext/editorText/codemirror/theme/xq-light.css
index 20b5c7961..8d2fcb667 100644
--- a/data/ext/editorText/codemirror/theme/xq-light.css
+++ b/data/ext/editorText/codemirror/theme/xq-light.css
@@ -20,24 +20,24 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-.cm-s-xq-light span.cm-keyword {line-height: 1em; font-weight: bold; color: #5A5CAD; }
-.cm-s-xq-light span.cm-atom {color: #6C8CD5;}
-.cm-s-xq-light span.cm-number {color: #164;}
-.cm-s-xq-light span.cm-def {text-decoration:underline;}
-.cm-s-xq-light span.cm-variable {color: black; }
-.cm-s-xq-light span.cm-variable-2 {color:black;}
-.cm-s-xq-light span.cm-variable-3 {color: black; }
+.cm-s-xq-light span.cm-keyword { line-height: 1em; font-weight: bold; color: #5A5CAD; }
+.cm-s-xq-light span.cm-atom { color: #6C8CD5; }
+.cm-s-xq-light span.cm-number { color: #164; }
+.cm-s-xq-light span.cm-def { text-decoration:underline; }
+.cm-s-xq-light span.cm-variable { color: black; }
+.cm-s-xq-light span.cm-variable-2 { color:black; }
+.cm-s-xq-light span.cm-variable-3 { color: black; }
.cm-s-xq-light span.cm-property {}
.cm-s-xq-light span.cm-operator {}
-.cm-s-xq-light span.cm-comment {color: #0080FF; font-style: italic;}
-.cm-s-xq-light span.cm-string {color: red;}
-.cm-s-xq-light span.cm-meta {color: yellow;}
-.cm-s-xq-light span.cm-qualifier {color: grey}
-.cm-s-xq-light span.cm-builtin {color: #7EA656;}
-.cm-s-xq-light span.cm-bracket {color: #cc7;}
-.cm-s-xq-light span.cm-tag {color: #3F7F7F;}
-.cm-s-xq-light span.cm-attribute {color: #7F007F;}
-.cm-s-xq-light span.cm-error {color: #f00;}
+.cm-s-xq-light span.cm-comment { color: #0080FF; font-style: italic; }
+.cm-s-xq-light span.cm-string { color: red; }
+.cm-s-xq-light span.cm-meta { color: yellow; }
+.cm-s-xq-light span.cm-qualifier { color: grey; }
+.cm-s-xq-light span.cm-builtin { color: #7EA656; }
+.cm-s-xq-light span.cm-bracket { color: #cc7; }
+.cm-s-xq-light span.cm-tag { color: #3F7F7F; }
+.cm-s-xq-light span.cm-attribute { color: #7F007F; }
+.cm-s-xq-light span.cm-error { color: #f00; }
-.cm-s-xq-light .CodeMirror-activeline-background {background: #e8f2ff !important;}
-.cm-s-xq-light .CodeMirror-matchingbracket {outline:1px solid grey;color:black !important;background:yellow;}
\ No newline at end of file
+.cm-s-xq-light .CodeMirror-activeline-background { background: #e8f2ff; }
+.cm-s-xq-light .CodeMirror-matchingbracket { outline:1px solid grey;color:black !important;background:yellow; }
diff --git a/data/ext/editorText/codemirror/theme/yeti.css b/data/ext/editorText/codemirror/theme/yeti.css
new file mode 100644
index 000000000..c70d4d214
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/yeti.css
@@ -0,0 +1,44 @@
+/*
+
+ Name: yeti
+ Author: Michael Kaminsky (http://github.com/mkaminsky11)
+
+ Original yeti color scheme by Jesse Weed (https://github.com/jesseweed/yeti-syntax)
+
+*/
+
+
+.cm-s-yeti.CodeMirror {
+ background-color: #ECEAE8 !important;
+ color: #d1c9c0 !important;
+ border: none;
+}
+
+.cm-s-yeti .CodeMirror-gutters {
+ color: #adaba6;
+ background-color: #E5E1DB;
+ border: none;
+}
+.cm-s-yeti .CodeMirror-cursor { border-left: solid thin #d1c9c0; }
+.cm-s-yeti .CodeMirror-linenumber { color: #adaba6; }
+.cm-s-yeti.CodeMirror-focused div.CodeMirror-selected { background: #DCD8D2; }
+.cm-s-yeti .CodeMirror-line::selection, .cm-s-yeti .CodeMirror-line > span::selection, .cm-s-yeti .CodeMirror-line > span > span::selection { background: #DCD8D2; }
+.cm-s-yeti .CodeMirror-line::-moz-selection, .cm-s-yeti .CodeMirror-line > span::-moz-selection, .cm-s-yeti .CodeMirror-line > span > span::-moz-selection { background: #DCD8D2; }
+.cm-s-yeti span.cm-comment { color: #d4c8be; }
+.cm-s-yeti span.cm-string, .cm-s-yeti span.cm-string-2 { color: #96c0d8; }
+.cm-s-yeti span.cm-number { color: #a074c4; }
+.cm-s-yeti span.cm-variable { color: #55b5db; }
+.cm-s-yeti span.cm-variable-2 { color: #a074c4; }
+.cm-s-yeti span.cm-def { color: #55b5db; }
+.cm-s-yeti span.cm-operator { color: #9fb96e; }
+.cm-s-yeti span.cm-keyword { color: #9fb96e; }
+.cm-s-yeti span.cm-atom { color: #a074c4; }
+.cm-s-yeti span.cm-meta { color: #96c0d8; }
+.cm-s-yeti span.cm-tag { color: #96c0d8; }
+.cm-s-yeti span.cm-attribute { color: #9fb96e; }
+.cm-s-yeti span.cm-qualifier { color: #96c0d8; }
+.cm-s-yeti span.cm-property { color: #a074c4; }
+.cm-s-yeti span.cm-builtin { color: #a074c4; }
+.cm-s-yeti span.cm-variable-3 { color: #96c0d8; }
+.cm-s-yeti .CodeMirror-activeline-background { background: #E7E4E0; }
+.cm-s-yeti .CodeMirror-matchingbracket { text-decoration: underline; }
diff --git a/data/ext/editorText/codemirror/theme/zenburn.css b/data/ext/editorText/codemirror/theme/zenburn.css
new file mode 100644
index 000000000..781c40aca
--- /dev/null
+++ b/data/ext/editorText/codemirror/theme/zenburn.css
@@ -0,0 +1,37 @@
+/**
+ * "
+ * Using Zenburn color palette from the Emacs Zenburn Theme
+ * https://github.com/bbatsov/zenburn-emacs/blob/master/zenburn-theme.el
+ *
+ * Also using parts of https://github.com/xavi/coderay-lighttable-theme
+ * "
+ * From: https://github.com/wisenomad/zenburn-lighttable-theme/blob/master/zenburn.css
+ */
+
+.cm-s-zenburn .CodeMirror-gutters { background: #3f3f3f !important; }
+.cm-s-zenburn .CodeMirror-foldgutter-open, .CodeMirror-foldgutter-folded { color: #999; }
+.cm-s-zenburn .CodeMirror-cursor { border-left: 1px solid white; }
+.cm-s-zenburn { background-color: #3f3f3f; color: #dcdccc; }
+.cm-s-zenburn span.cm-builtin { color: #dcdccc; font-weight: bold; }
+.cm-s-zenburn span.cm-comment { color: #7f9f7f; }
+.cm-s-zenburn span.cm-keyword { color: #f0dfaf; font-weight: bold; }
+.cm-s-zenburn span.cm-atom { color: #bfebbf; }
+.cm-s-zenburn span.cm-def { color: #dcdccc; }
+.cm-s-zenburn span.cm-variable { color: #dfaf8f; }
+.cm-s-zenburn span.cm-variable-2 { color: #dcdccc; }
+.cm-s-zenburn span.cm-string { color: #cc9393; }
+.cm-s-zenburn span.cm-string-2 { color: #cc9393; }
+.cm-s-zenburn span.cm-number { color: #dcdccc; }
+.cm-s-zenburn span.cm-tag { color: #93e0e3; }
+.cm-s-zenburn span.cm-property { color: #dfaf8f; }
+.cm-s-zenburn span.cm-attribute { color: #dfaf8f; }
+.cm-s-zenburn span.cm-qualifier { color: #7cb8bb; }
+.cm-s-zenburn span.cm-meta { color: #f0dfaf; }
+.cm-s-zenburn span.cm-header { color: #f0efd0; }
+.cm-s-zenburn span.cm-operator { color: #f0efd0; }
+.cm-s-zenburn span.CodeMirror-matchingbracket { box-sizing: border-box; background: transparent; border-bottom: 1px solid; }
+.cm-s-zenburn span.CodeMirror-nonmatchingbracket { border-bottom: 1px solid; background: none; }
+.cm-s-zenburn .CodeMirror-activeline { background: #000000; }
+.cm-s-zenburn .CodeMirror-activeline-background { background: #000000; }
+.cm-s-zenburn div.CodeMirror-selected { background: #545454; }
+.cm-s-zenburn .CodeMirror-focused div.CodeMirror-selected { background: #4f4f4f; }