1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 13:19:43 +02:00

Update CodeMirror dep to v5.42.2

Affects Code and Markdown section types
This commit is contained in:
Harvey Kandola 2019-01-08 14:48:23 +00:00
parent c706edec47
commit 479a61a3ef
347 changed files with 21845 additions and 20770 deletions

View file

@ -6,8 +6,6 @@
} }
} }
/* BASICS */ /* BASICS */
.CodeMirror { .CodeMirror {
@ -280,7 +278,7 @@
.CodeMirror-linewidget { .CodeMirror-linewidget {
position: relative; position: relative;
z-index: 2; z-index: 2;
overflow: auto; padding: 0.1px; /* Force widget margins to stay inside of the container */
} }
.CodeMirror-widget {} .CodeMirror-widget {}
@ -357,7 +355,6 @@
/* /*
Name: material Name: material
@ -368,92 +365,261 @@
*/ */
.cm-s-material.CodeMirror { .cm-s-material.CodeMirror {
background-color: #263238; background-color: #263238;
color: rgba(233, 237, 237, 1); color: rgba(233, 237, 237, 1);
} }
.cm-s-material .CodeMirror-gutters { .cm-s-material .CodeMirror-gutters {
background: #263238; background: #263238;
color: rgb(83,127,126); color: rgb(83,127,126);
border: none; 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-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 .CodeMirror-cursor { border-left: 1px solid #f8f8f0; }
.cm-s-material div.CodeMirror-selected { background: rgba(255, 255, 255, 0.15); } .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-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::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-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 .CodeMirror-activeline-background { background: rgba(0, 0, 0, 0); }
.cm-s-material .cm-keyword { color: rgba(199, 146, 234, 1); } .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-operator { color: rgba(233, 237, 237, 1); }
.cm-s-material .cm-variable-2 { color: #80CBC4; } .cm-s-material .cm-variable-2 { color: #80CBC4; }
.cm-s-material .cm-variable-3 { color: #82B1FF; } .cm-s-material .cm-variable-3 { color: #82B1FF; }
.cm-s-material .cm-builtin { color: #DECB6B; } .cm-s-material .cm-builtin { color: #DECB6B; }
.cm-s-material .cm-atom { color: #F77669; } .cm-s-material .cm-atom { color: #F77669; }
.cm-s-material .cm-number { color: #F77669; } .cm-s-material .cm-number { color: #F77669; }
.cm-s-material .cm-def { color: rgba(233, 237, 237, 1); } .cm-s-material .cm-def { color: rgba(233, 237, 237, 1); }
.cm-s-material .cm-string { color: #C3E88D; } .cm-s-material .cm-string { color: #C3E88D; }
.cm-s-material .cm-string-2 { color: #80CBC4; } .cm-s-material .cm-string-2 { color: #80CBC4; }
.cm-s-material .cm-comment { color: #546E7A; } .cm-s-material .cm-comment { color: #546E7A; }
.cm-s-material .cm-variable { color: #82B1FF; } .cm-s-material .cm-variable { color: #82B1FF; }
.cm-s-material .cm-tag { color: #80CBC4; } .cm-s-material .cm-tag { color: #80CBC4; }
.cm-s-material .cm-meta { color: #80CBC4; } .cm-s-material .cm-meta { color: #80CBC4; }
.cm-s-material .cm-attribute { color: #FFCB6B; } .cm-s-material .cm-attribute { color: #FFCB6B; }
.cm-s-material .cm-property { color: #80CBAE; } .cm-s-material .cm-property { color: #80CBAE; }
.cm-s-material .cm-qualifier { color: #DECB6B; } .cm-s-material .cm-qualifier { color: #DECB6B; }
.cm-s-material .cm-variable-3 { color: #DECB6B; } .cm-s-material .cm-variable-3 { color: #DECB6B; }
.cm-s-material .cm-tag { color: rgba(255, 83, 112, 1); } .cm-s-material .cm-tag { color: rgba(255, 83, 112, 1); }
.cm-s-material .cm-error { .cm-s-material .cm-error {
color: rgba(255, 255, 255, 1.0); color: rgba(255, 255, 255, 1.0);
background-color: #EC5F67; background-color: #EC5F67;
} }
.cm-s-material .CodeMirror-matchingbracket { .cm-s-material .CodeMirror-matchingbracket {
text-decoration: underline; text-decoration: underline;
color: white !important; color: white !important;
} }
/*
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; }
/* /*
Solarized theme for code-mirror
Name: yeti http://ethanschoonover.com/solarized
Author: Michael Kaminsky (http://github.com/mkaminsky11)
Original yeti color scheme by Jesse Weed (https://github.com/jesseweed/yeti-syntax)
*/ */
/*
Solarized color palette
http://ethanschoonover.com/solarized/img/solarized-palette.png
*/
.cm-s-yeti.CodeMirror { .solarized.base03 { color: #002b36; }
background-color: #ECEAE8 !important; .solarized.base02 { color: #073642; }
color: #d1c9c0 !important; .solarized.base01 { color: #586e75; }
border: none; .solarized.base00 { color: #657b83; }
.solarized.base0 { color: #839496; }
.solarized.base1 { color: #93a1a1; }
.solarized.base2 { color: #eee8d5; }
.solarized.base3 { color: #fdf6e3; }
.solarized.solar-yellow { color: #b58900; }
.solarized.solar-orange { color: #cb4b16; }
.solarized.solar-red { color: #dc322f; }
.solarized.solar-magenta { color: #d33682; }
.solarized.solar-violet { color: #6c71c4; }
.solarized.solar-blue { color: #268bd2; }
.solarized.solar-cyan { color: #2aa198; }
.solarized.solar-green { color: #859900; }
/* Color scheme for code-mirror */
.cm-s-solarized {
line-height: 1.45em;
color-profile: sRGB;
rendering-intent: auto;
}
.cm-s-solarized.cm-s-dark {
color: #839496;
background-color: #002b36;
text-shadow: #002b36 0 1px;
}
.cm-s-solarized.cm-s-light {
background-color: #fdf6e3;
color: #657b83;
text-shadow: #eee8d5 0 1px;
} }
.cm-s-yeti .CodeMirror-gutters { .cm-s-solarized .CodeMirror-widget {
color: #adaba6; text-shadow: none;
background-color: #E5E1DB; }
border: 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-atom { color: #d33682; }
.cm-s-solarized .cm-number { color: #d33682; }
.cm-s-solarized .cm-def { color: #2aa198; }
.cm-s-solarized .cm-variable { color: #839496; }
.cm-s-solarized .cm-variable-2 { color: #b58900; }
.cm-s-solarized .cm-variable-3, .cm-s-solarized .cm-type { color: #6c71c4; }
.cm-s-solarized .cm-property { color: #2aa198; }
.cm-s-solarized .cm-operator { color: #6c71c4; }
.cm-s-solarized .cm-comment { color: #586e75; font-style:italic; }
.cm-s-solarized .cm-string { color: #859900; }
.cm-s-solarized .cm-string-2 { color: #b58900; }
.cm-s-solarized .cm-meta { color: #859900; }
.cm-s-solarized .cm-qualifier { color: #b58900; }
.cm-s-solarized .cm-builtin { color: #d33682; }
.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-hr {
color: transparent;
border-top: 1px solid #586e75;
display: block;
}
.cm-s-solarized .cm-link { color: #93a1a1; cursor: pointer; }
.cm-s-solarized .cm-special { color: #6c71c4; }
.cm-s-solarized .cm-em {
color: #999;
text-decoration: underline;
text-decoration-style: dotted;
}
.cm-s-solarized .cm-error,
.cm-s-solarized .cm-invalidchar {
color: #586e75;
border-bottom: 1px dotted #dc322f;
}
.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 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 */
/* Little shadow on the view-port of the buffer view */
.cm-s-solarized.CodeMirror {
-moz-box-shadow: inset 7px 0 12px -6px #000;
-webkit-box-shadow: inset 7px 0 12px -6px #000;
box-shadow: inset 7px 0 12px -6px #000;
}
/* Remove gutter border */
.cm-s-solarized .CodeMirror-gutters {
border-right: 0;
}
/* Gutter colors and line number styling based of color scheme (dark / light) */
/* Dark */
.cm-s-solarized.cm-s-dark .CodeMirror-gutters {
background-color: #073642;
}
.cm-s-solarized.cm-s-dark .CodeMirror-linenumber {
color: #586e75;
text-shadow: #021014 0 -1px;
}
/* Light */
.cm-s-solarized.cm-s-light .CodeMirror-gutters {
background-color: #eee8d5;
}
.cm-s-solarized.cm-s-light .CodeMirror-linenumber {
color: #839496;
}
/* Common */
.cm-s-solarized .CodeMirror-linenumber {
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;
}
/* Cursor */
.cm-s-solarized .CodeMirror-cursor { border-left: 1px solid #819090; }
/* Fat cursor */
.cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #77ee77; }
.cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #77ee77; }
.cm-s-solarized.cm-s-dark.cm-fat-cursor .CodeMirror-cursor { background: #586e75; }
.cm-s-solarized.cm-s-dark .cm-animate-fat-cursor { background-color: #586e75; }
/* Active line */
.cm-s-solarized.cm-s-dark .CodeMirror-activeline-background {
background: rgba(255, 255, 255, 0.06);
}
.cm-s-solarized.cm-s-light .CodeMirror-activeline-background {
background: rgba(0, 0, 0, 0.06);
} }
.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; }

View file

@ -53,7 +53,7 @@
.start-section { .start-section {
@extend .no-select; @extend .no-select;
text-align: right; text-align: right;
margin: 0; margin: 0.5rem 0;
display: block; display: block;
> i { > i {

View file

@ -63,7 +63,8 @@ module.exports = function (defaults) {
app.import('vendor/sortable.js'); app.import('vendor/sortable.js');
app.import('vendor/table-editor.min.js'); app.import('vendor/table-editor.min.js');
app.import('vendor/underscore.js'); app.import('vendor/underscore.js');
app.import('vendor/codemirror.js'); // boot-up files app.import('vendor/codemirror.js'); // core lib
app.import('vendor/codemirror-boot.js'); // boot-up files
app.import('vendor/bootstrap.bundle.min.js'); app.import('vendor/bootstrap.bundle.min.js');

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Open simple dialogs on top of an editor. Relies on dialog.css. // Open simple dialogs on top of an editor. Relies on dialog.css.

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS
@ -17,13 +17,15 @@
var info = this.state.panels; var info = this.state.panels;
var wrapper = info.wrapper; var wrapper = info.wrapper;
var cmWrapper = this.getWrapperElement(); var cmWrapper = this.getWrapperElement();
var replace = options.replace instanceof Panel && !options.replace.cleared;
if (options.after instanceof Panel && !options.after.cleared) { if (options.after instanceof Panel && !options.after.cleared) {
wrapper.insertBefore(node, options.before.node.nextSibling); wrapper.insertBefore(node, options.before.node.nextSibling);
} else if (options.before instanceof Panel && !options.before.cleared) { } else if (options.before instanceof Panel && !options.before.cleared) {
wrapper.insertBefore(node, options.before.node); wrapper.insertBefore(node, options.before.node);
} else if (options.replace instanceof Panel && !options.replace.cleared) { } else if (replace) {
wrapper.insertBefore(node, options.replace.node); wrapper.insertBefore(node, options.replace.node);
info.panels++;
options.replace.clear(); options.replace.clear();
} else if (options.position == "bottom") { } else if (options.position == "bottom") {
wrapper.appendChild(node); wrapper.appendChild(node);
@ -37,7 +39,9 @@
var height = (options && options.height) || node.offsetHeight; var height = (options && options.height) || node.offsetHeight;
this._setSize(null, info.heightLeft -= height); this._setSize(null, info.heightLeft -= height);
info.panels++; if (!replace) {
info.panels++;
}
if (options.stable && isAtTop(this, node)) if (options.stable && isAtTop(this, node))
this.scrollTo(null, this.getScrollInfo().top + height) this.scrollTo(null, this.getScrollInfo().top + height)

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS
@ -136,9 +136,7 @@
var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur) var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur)
if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both"; if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both";
else return CodeMirror.Pass; else return CodeMirror.Pass;
} else if (opening && (cm.getLine(cur.line).length == cur.ch || } else if (opening) {
isClosingBracket(next, pairs) ||
/\s/.test(next))) {
curType = "both"; curType = "both";
} else { } else {
return CodeMirror.Pass; return CodeMirror.Pass;
@ -175,11 +173,6 @@
}); });
} }
function isClosingBracket(ch, pairs) {
var pos = pairs.lastIndexOf(ch);
return pos > -1 && pos % 2 == 1;
}
function charsAround(cm, pos) { function charsAround(cm, pos) {
var str = cm.getRange(Pos(pos.line, pos.ch - 1), var str = cm.getRange(Pos(pos.line, pos.ch - 1),
Pos(pos.line, pos.ch + 1)); Pos(pos.line, pos.ch + 1));

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
/** /**
* Tag-closer extension for CodeMirror. * Tag-closer extension for CodeMirror.

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS
@ -14,20 +14,25 @@
var Pos = CodeMirror.Pos; var Pos = CodeMirror.Pos;
var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"}; var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"};
function bracketRegex(config) {
return config && config.bracketRegex || /[(){}[\]]/
}
function findMatchingBracket(cm, where, config) { function findMatchingBracket(cm, where, config) {
var line = cm.getLineHandle(where.line), pos = where.ch - 1; var line = cm.getLineHandle(where.line), pos = where.ch - 1;
var afterCursor = config && config.afterCursor var afterCursor = config && config.afterCursor
if (afterCursor == null) if (afterCursor == null)
afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className) afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
var re = bracketRegex(config)
// A cursor is defined as between two characters, but in in vim command mode // A cursor is defined as between two characters, but in in vim command mode
// (i.e. not insert mode), the cursor is visually represented as a // (i.e. not insert mode), the cursor is visually represented as a
// highlighted box on top of the 2nd character. Otherwise, we allow matches // highlighted box on top of the 2nd character. Otherwise, we allow matches
// from before or after the cursor. // from before or after the cursor.
var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) || var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) ||
matching[line.text.charAt(++pos)]; re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)];
if (!match) return null; if (!match) return null;
var dir = match.charAt(1) == ">" ? 1 : -1; var dir = match.charAt(1) == ">" ? 1 : -1;
if (config && config.strict && (dir > 0) != (pos == where.ch)) return null; if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
@ -51,7 +56,7 @@
var maxScanLines = (config && config.maxScanLines) || 1000; var maxScanLines = (config && config.maxScanLines) || 1000;
var stack = []; var stack = [];
var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/; var re = bracketRegex(config)
var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1) var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
: Math.max(cm.firstLine() - 1, where.line - maxScanLines); : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) { for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS
@ -54,7 +54,7 @@ CodeMirror.registerHelper("fold", "brace", function(cm, start) {
++pos; ++pos;
} }
} }
if (end == null || line == end && endCh == startCh) return; if (end == null || line == end) return;
return {from: CodeMirror.Pos(line, startCh), return {from: CodeMirror.Pos(line, startCh),
to: CodeMirror.Pos(end, endCh)}; to: CodeMirror.Pos(end, endCh)};
}); });

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS
@ -46,6 +46,10 @@
completion.update(true); completion.update(true);
}); });
CodeMirror.defineExtension("closeHint", function() {
if (this.state.completionActive) this.state.completionActive.close()
})
function Completion(cm, options) { function Completion(cm, options) {
this.cm = cm; this.cm = cm;
this.options = options; this.options = options;
@ -98,7 +102,7 @@
var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line); var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);
if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch || if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
pos.ch < this.startPos.ch || this.cm.somethingSelected() || pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
(pos.ch && this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) { (!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
this.close(); this.close();
} else { } else {
var self = this; var self = this;
@ -198,19 +202,22 @@
this.data = data; this.data = data;
this.picked = false; this.picked = false;
var widget = this, cm = completion.cm; var widget = this, cm = completion.cm;
var ownerDocument = cm.getInputField().ownerDocument;
var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow;
var hints = this.hints = document.createElement("ul"); var hints = this.hints = ownerDocument.createElement("ul");
hints.className = "CodeMirror-hints"; var theme = completion.cm.options.theme;
hints.className = "CodeMirror-hints " + theme;
this.selectedHint = data.selectedHint || 0; this.selectedHint = data.selectedHint || 0;
var completions = data.list; var completions = data.list;
for (var i = 0; i < completions.length; ++i) { for (var i = 0; i < completions.length; ++i) {
var elt = hints.appendChild(document.createElement("li")), cur = completions[i]; var elt = hints.appendChild(ownerDocument.createElement("li")), cur = completions[i];
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS); var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
if (cur.className != null) className = cur.className + " " + className; if (cur.className != null) className = cur.className + " " + className;
elt.className = className; elt.className = className;
if (cur.render) cur.render(elt, data, cur); if (cur.render) cur.render(elt, data, cur);
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur))); else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur)));
elt.hintId = i; elt.hintId = i;
} }
@ -219,9 +226,9 @@
hints.style.left = left + "px"; hints.style.left = left + "px";
hints.style.top = top + "px"; hints.style.top = top + "px";
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor. // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth); var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth);
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight); var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight);
(completion.options.container || document.body).appendChild(hints); (completion.options.container || ownerDocument.body).appendChild(hints);
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH; var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
var scrolls = hints.scrollHeight > hints.clientHeight + 1 var scrolls = hints.scrollHeight > hints.clientHeight + 1
var startScroll = cm.getScrollInfo(); var startScroll = cm.getScrollInfo();
@ -272,7 +279,7 @@
cm.on("scroll", this.onScroll = function() { cm.on("scroll", this.onScroll = function() {
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect(); var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
var newTop = top + startScroll.top - curScroll.top; var newTop = top + startScroll.top - curScroll.top;
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop); var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop);
if (!below) point += hints.offsetHeight; if (!below) point += hints.offsetHeight;
if (point <= editor.top || point >= editor.bottom) return completion.close(); if (point <= editor.top || point >= editor.bottom) return completion.close();
hints.style.top = newTop + "px"; hints.style.top = newTop + "px";

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js // Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Depends on csslint.js from https://github.com/stubbornella/csslint // Depends on csslint.js from https://github.com/stubbornella/csslint

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js // Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Depends on jsonlint.js from https://github.com/zaach/jsonlint // Depends on jsonlint.js from https://github.com/zaach/jsonlint

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS
@ -23,7 +23,7 @@ CodeMirror.registerHelper("lint", "yaml", function(text) {
} }
return found; return found;
} }
try { jsyaml.load(text); } try { jsyaml.loadAll(text); }
catch(e) { catch(e) {
var loc = e.mark, var loc = e.mark,
// js-yaml YAMLException doesn't always provide an accurate lineno // js-yaml YAMLException doesn't always provide an accurate lineno

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL // declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL
@ -43,6 +43,7 @@
if (!this.edit.state.trackAlignable) this.edit.state.trackAlignable = new TrackAlignable(this.edit) if (!this.edit.state.trackAlignable) this.edit.state.trackAlignable = new TrackAlignable(this.edit)
this.orig.state.trackAlignable = new TrackAlignable(this.orig) this.orig.state.trackAlignable = new TrackAlignable(this.orig)
} }
this.lockButton.title = this.edit.phrase("Toggle locked scrolling");
this.orig.state.diffViews = [this]; this.orig.state.diffViews = [this];
var classLocation = options.chunkClassLocation || "background"; var classLocation = options.chunkClassLocation || "background";
@ -500,7 +501,7 @@
var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc", var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc",
"CodeMirror-merge-copy")); "CodeMirror-merge-copy"));
var editOriginals = dv.mv.options.allowEditingOriginals; var editOriginals = dv.mv.options.allowEditingOriginals;
copy.title = editOriginals ? "Push to left" : "Revert chunk"; copy.title = dv.edit.phrase(editOriginals ? "Push to left" : "Revert chunk");
copy.chunk = chunk; copy.chunk = chunk;
copy.style.top = (chunk.origTo > chunk.origFrom ? top : dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit) + "px"; copy.style.top = (chunk.origTo > chunk.origFrom ? top : dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit) + "px";
@ -594,7 +595,6 @@
function buildGap(dv) { function buildGap(dv) {
var lock = dv.lockButton = elt("div", null, "CodeMirror-merge-scrolllock"); var lock = dv.lockButton = elt("div", null, "CodeMirror-merge-scrolllock");
lock.title = "Toggle locked scrolling";
var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap"); var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap");
CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); }); CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); });
var gapElts = [lockWrap]; var gapElts = [lockWrap];
@ -728,7 +728,7 @@
cm.addLineClass(from, "wrap", "CodeMirror-merge-collapsed-line"); cm.addLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
var widget = document.createElement("span"); var widget = document.createElement("span");
widget.className = "CodeMirror-merge-collapsed-widget"; widget.className = "CodeMirror-merge-collapsed-widget";
widget.title = "Identical text collapsed. Click to expand."; widget.title = cm.phrase("Identical text collapsed. Click to expand.");
var mark = cm.markText(Pos(from, 0), Pos(to - 1), { var mark = cm.markText(Pos(from, 0), Pos(to - 1), {
inclusiveLeft: true, inclusiveLeft: true,
inclusiveRight: true, inclusiveRight: true,

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function() { (function() {
CodeMirror.defineMode("markdown_with_stex", function(){ CodeMirror.defineMode("markdown_with_stex", function(){

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Utility function that allows modes to be combined. The mode given // Utility function that allows modes to be combined. The mode given
// as the base argument takes care of most of the normal mode // as the base argument takes care of most of the normal mode

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
window.CodeMirror = {}; window.CodeMirror = {};

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
/* Just enough of CodeMirror to run runMode under node.js */ /* Just enough of CodeMirror to run runMode under node.js */

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Defines jumpToLine command. Uses dialog.js if present. // Defines jumpToLine command. Uses dialog.js if present.
@ -18,8 +18,9 @@
else f(prompt(shortText, deflt)); else f(prompt(shortText, deflt));
} }
var jumpDialog = function getJumpDialog(cm) {
'Jump to line: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use line:column or scroll% syntax)</span>'; return cm.phrase("Jump to line:") + ' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">' + cm.phrase("(Use line:column or scroll% syntax)") + '</span>';
}
function interpretLine(cm, string) { function interpretLine(cm, string) {
var num = Number(string) var num = Number(string)
@ -29,7 +30,7 @@
CodeMirror.commands.jumpToLine = function(cm) { CodeMirror.commands.jumpToLine = function(cm) {
var cur = cm.getCursor(); var cur = cm.getCursor();
dialog(cm, jumpDialog, "Jump to line:", (cur.line + 1) + ":" + cur.ch, function(posStr) { dialog(cm, getJumpDialog(cm), cm.phrase("Jump to line:"), (cur.line + 1) + ":" + cur.ch, function(posStr) {
if (!posStr) return; if (!posStr) return;
var match; var match;

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Highlighting text that matches the selection // Highlighting text that matches the selection
// //

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Define search commands. Depends on dialog.js or another // Define search commands. Depends on dialog.js or another
// implementation of the openDialog method. // implementation of the openDialog method.
@ -98,9 +98,6 @@
return query; return query;
} }
var queryDialog =
'<span class="CodeMirror-search-label">Search:</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
function startSearch(cm, state, query) { function startSearch(cm, state, query) {
state.queryText = query; state.queryText = query;
state.query = parseQuery(query); state.query = parseQuery(query);
@ -136,7 +133,7 @@
(hiding = dialog).style.opacity = .4 (hiding = dialog).style.opacity = .4
}) })
}; };
persistentDialog(cm, queryDialog, q, searchNext, function(event, query) { persistentDialog(cm, getQueryDialog(cm), q, searchNext, function(event, query) {
var keyName = CodeMirror.keyName(event) var keyName = CodeMirror.keyName(event)
var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName] var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
if (cmd == "findNext" || cmd == "findPrev" || if (cmd == "findNext" || cmd == "findPrev" ||
@ -154,7 +151,7 @@
findNext(cm, rev); findNext(cm, rev);
} }
} else { } else {
dialog(cm, queryDialog, "Search for:", q, function(query) { dialog(cm, getQueryDialog(cm), "Search for:", q, function(query) {
if (query && !state.query) cm.operation(function() { if (query && !state.query) cm.operation(function() {
startSearch(cm, state, query); startSearch(cm, state, query);
state.posFrom = state.posTo = cm.getCursor(); state.posFrom = state.posTo = cm.getCursor();
@ -186,10 +183,19 @@
if (state.annotate) { state.annotate.clear(); state.annotate = null; } if (state.annotate) { state.annotate.clear(); state.annotate = null; }
});} });}
var replaceQueryDialog =
' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>'; function getQueryDialog(cm) {
var replacementQueryDialog = '<span class="CodeMirror-search-label">With:</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/>'; return '<span class="CodeMirror-search-label">' + cm.phrase("Search:") + '</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">' + cm.phrase("(Use /re/ syntax for regexp search)") + '</span>';
var doReplaceConfirm = '<span class="CodeMirror-search-label">Replace?</span> <button>Yes</button> <button>No</button> <button>All</button> <button>Stop</button>'; }
function getReplaceQueryDialog(cm) {
return ' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">' + cm.phrase("(Use /re/ syntax for regexp search)") + '</span>';
}
function getReplacementQueryDialog(cm) {
return '<span class="CodeMirror-search-label">' + cm.phrase("With:") + '</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
}
function getDoReplaceConfirm(cm) {
return '<span class="CodeMirror-search-label">' + cm.phrase("Replace?") + '</span> <button>' + cm.phrase("Yes") + '</button> <button>' + cm.phrase("No") + '</button> <button>' + cm.phrase("All") + '</button> <button>' + cm.phrase("Stop") + '</button> ';
}
function replaceAll(cm, query, text) { function replaceAll(cm, query, text) {
cm.operation(function() { cm.operation(function() {
@ -205,11 +211,11 @@
function replace(cm, all) { function replace(cm, all) {
if (cm.getOption("readOnly")) return; if (cm.getOption("readOnly")) return;
var query = cm.getSelection() || getSearchState(cm).lastQuery; var query = cm.getSelection() || getSearchState(cm).lastQuery;
var dialogText = '<span class="CodeMirror-search-label">' + (all ? 'Replace all:' : 'Replace:') + '</span>'; var dialogText = '<span class="CodeMirror-search-label">' + (all ? cm.phrase("Replace all:") : cm.phrase("Replace:")) + '</span>';
dialog(cm, dialogText + replaceQueryDialog, dialogText, query, function(query) { dialog(cm, dialogText + getReplaceQueryDialog(cm), dialogText, query, function(query) {
if (!query) return; if (!query) return;
query = parseQuery(query); query = parseQuery(query);
dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) { dialog(cm, getReplacementQueryDialog(cm), cm.phrase("Replace with:"), "", function(text) {
text = parseString(text) text = parseString(text)
if (all) { if (all) {
replaceAll(cm, query, text) replaceAll(cm, query, text)
@ -225,7 +231,7 @@
} }
cm.setSelection(cursor.from(), cursor.to()); cm.setSelection(cursor.from(), cursor.to());
cm.scrollIntoView({from: cursor.from(), to: cursor.to()}); cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
confirmDialog(cm, doReplaceConfirm, "Replace?", confirmDialog(cm, getDoReplaceConfirm(cm), cm.phrase("Replace?"),
[function() {doReplace(match);}, advance, [function() {doReplace(match);}, advance,
function() {replaceAll(cm, query, text)}]); function() {replaceAll(cm, query, text)}]);
}; };

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Because sometimes you need to mark the selected *text*. // Because sometimes you need to mark the selected *text*.
// //

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Glue code between CodeMirror and Tern. // Glue code between CodeMirror and Tern.
// //

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// declare global: tern, server // declare global: tern, server

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS
@ -52,6 +52,7 @@
var lines = cm.getRange(from, to, false); var lines = cm.getRange(from, to, false);
if (!lines.length) return null; if (!lines.length) return null;
var leadingSpace = lines[0].match(/^[ \t]*/)[0]; var leadingSpace = lines[0].match(/^[ \t]*/)[0];
if (leadingSpace.length >= column) column = leadingSpace.length + 1
for (var i = 0; i < lines.length; ++i) { for (var i = 0; i < lines.length; ++i) {
var text = lines[i], oldLen = curLine.length, spaceInserted = 0; var text = lines[i], oldLen = curLine.length, spaceInserted = 0;

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -12,7 +12,7 @@
.CodeMirror { border: 2px inset #dee; } .CodeMirror { border: 2px inset #dee; }
</style> </style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -9,7 +9,7 @@
<script src="asciiarmor.js"></script> <script src="asciiarmor.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style> <style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -6,15 +6,16 @@
<link rel="stylesheet" href="../../lib/codemirror.css"> <link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script> <script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="asn.1.js"></script> <script src="asn.1.js"></script>
<style type="text/css"> <style>
.CodeMirror { .CodeMirror {
border-top: 1px solid black; border-top: 1px solid black;
border-bottom: 1px solid black; border-bottom: 1px solid black;
} }
</style> </style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1> <a href="https://codemirror.net"><h1>CodeMirror</h1>
<img id=logo src="../../doc/logo.png"> <img id=logo src="../../doc/logo.png">
</a> </a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
/* /*
* ===================================================================================== * =====================================================================================

View file

@ -6,13 +6,14 @@
<link rel="stylesheet" href="../../lib/codemirror.css"> <link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script> <script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="asterisk.js"></script> <script src="asterisk.js"></script>
<style> <style>
.CodeMirror {border: 1px solid #999;} .CodeMirror {border: 1px solid #999;}
.cm-s-default span.cm-arrow { color: red; } .cm-s-default span.cm-arrow { color: red; }
</style> </style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>
@ -145,7 +146,7 @@ exten => 8500,n,Goto(s,6)
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: "text/x-asterisk", mode: "text/x-asterisk",
matchBrackets: true, matchBrackets: true,
lineNumber: true lineNumbers: true
}); });
</script> </script>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// Brainfuck mode created by Michael Kaminsky https://github.com/mkaminsky11 // Brainfuck mode created by Michael Kaminsky https://github.com/mkaminsky11

View file

@ -12,7 +12,7 @@
.CodeMirror { border: 2px inset #dee; } .CodeMirror { border: 2px inset #dee; }
</style> </style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS
@ -65,7 +65,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
numberStart = parserConfig.numberStart || /[\d\.]/, numberStart = parserConfig.numberStart || /[\d\.]/,
number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i, number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/, isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/; isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/,
// An optional function that takes a {string} token and returns true if it
// should be treated as a builtin.
isReservedIdentifier = parserConfig.isReservedIdentifier || false;
var curPunc, isDefKeyword; var curPunc, isDefKeyword;
@ -113,7 +116,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
return "keyword"; return "keyword";
} }
if (contains(types, cur)) return "type"; if (contains(types, cur)) return "type";
if (contains(builtin, cur)) { if (contains(builtin, cur)
|| (isReservedIdentifier && isReservedIdentifier(cur))) {
if (contains(blockKeywords, cur)) curPunc = "newstatement"; if (contains(blockKeywords, cur)) curPunc = "newstatement";
return "builtin"; return "builtin";
} }
@ -216,15 +220,15 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
indent: function(state, textAfter) { indent: function(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass; if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
var closing = firstChar == ctx.type;
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev; if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
if (parserConfig.dontIndentStatements) if (parserConfig.dontIndentStatements)
while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info)) while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info))
ctx = ctx.prev ctx = ctx.prev
if (hooks.indent) { if (hooks.indent) {
var hook = hooks.indent(state, ctx, textAfter); var hook = hooks.indent(state, ctx, textAfter, indentUnit);
if (typeof hook == "number") return hook if (typeof hook == "number") return hook
} }
var closing = firstChar == ctx.type;
var switchBlock = ctx.prev && ctx.prev.info == "switch"; var switchBlock = ctx.prev && ctx.prev.info == "switch";
if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) { if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev
@ -263,8 +267,33 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
} }
} }
var cKeywords = "auto if break case register continue return default do sizeof " + var cKeywords = "auto if break case register continue return default do sizeof " +
"static else struct switch extern typedef union for goto while enum const volatile"; "static else struct switch extern typedef union for goto while enum const " +
var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t"; "volatile inline restrict asm fortran";
// Do not use this. Use the cTypes function below. This is global just to avoid
// excessive calls when cTypes is being called multiple times during a parse.
var basicCTypes = words("int long char short double float unsigned signed " +
"void bool");
// Do not use this. Use the objCTypes function below. This is global just to avoid
// excessive calls when objCTypes is being called multiple times during a parse.
var basicObjCTypes = words("SEL instancetype id Class Protocol BOOL");
// Returns true if identifier is a "C" type.
// C type is defined as those that are reserved by the compiler (basicTypes),
// and those that end in _t (Reserved by POSIX for types)
// http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html
function cTypes(identifier) {
return contains(basicCTypes, identifier) || /.+_t/.test(identifier);
}
// Returns true if identifier is a "Objective C" type.
function objCTypes(identifier) {
return cTypes(identifier) || contains(basicObjCTypes, identifier);
}
var cBlockKeywords = "case do else for if switch while struct enum union";
var cDefKeywords = "struct enum union";
function cppHook(stream, state) { function cppHook(stream, state) {
if (!state.startOfLine) return false if (!state.startOfLine) return false
@ -286,6 +315,14 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
return false; return false;
} }
// For C and C++ (and ObjC): identifiers starting with __
// or _ followed by a capital letter are reserved for the compiler.
function cIsReservedIdentifier(token) {
if (!token || token.length < 2) return false;
if (token[0] != '_') return false;
return (token[1] == '_') || (token[1] !== token[1].toLowerCase());
}
function cpp14Literal(stream) { function cpp14Literal(stream) {
stream.eatWhile(/[\w\.']/); stream.eatWhile(/[\w\.']/);
return "number"; return "number";
@ -368,31 +405,36 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
def(["text/x-csrc", "text/x-c", "text/x-chdr"], { def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
name: "clike", name: "clike",
keywords: words(cKeywords), keywords: words(cKeywords),
types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " + types: cTypes,
"int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " + blockKeywords: words(cBlockKeywords),
"uint32_t uint64_t"), defKeywords: words(cDefKeywords),
blockKeywords: words("case do else for if switch while struct"),
defKeywords: words("struct"),
typeFirstDefinitions: true, typeFirstDefinitions: true,
atoms: words("NULL true false"), atoms: words("NULL true false"),
hooks: {"#": cppHook, "*": pointerHook}, isReservedIdentifier: cIsReservedIdentifier,
hooks: {
"#": cppHook,
"*": pointerHook,
},
modeProps: {fold: ["brace", "include"]} modeProps: {fold: ["brace", "include"]}
}); });
def(["text/x-c++src", "text/x-c++hdr"], { def(["text/x-c++src", "text/x-c++hdr"], {
name: "clike", name: "clike",
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " + // Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.
"static_cast typeid catch operator template typename class friend private " + keywords: words(cKeywords + "alignas alignof and and_eq audit axiom bitand bitor catch " +
"this using const_cast inline public throw virtual delete mutable protected " + "class compl concept constexpr const_cast decltype delete dynamic_cast " +
"alignas alignof constexpr decltype nullptr noexcept thread_local final " + "explicit export final friend import module mutable namespace new noexcept " +
"static_assert override"), "not not_eq operator or or_eq override private protected public " +
types: words(cTypes + " bool wchar_t"), "reinterpret_cast requires static_assert static_cast template this " +
blockKeywords: words("catch class do else finally for if struct switch try while"), "thread_local throw try typeid typename using virtual xor xor_eq"),
defKeywords: words("class namespace struct enum union"), types: cTypes,
blockKeywords: words(cBlockKeywords + " class try catch"),
defKeywords: words(cDefKeywords + " class namespace"),
typeFirstDefinitions: true, typeFirstDefinitions: true,
atoms: words("true false NULL"), atoms: words("true false NULL nullptr"),
dontIndentStatements: /^template$/, dontIndentStatements: /^template$/,
isIdentifierChar: /[\w\$_~\xa1-\uffff]/, isIdentifierChar: /[\w\$_~\xa1-\uffff]/,
isReservedIdentifier: cIsReservedIdentifier,
hooks: { hooks: {
"#": cppHook, "#": cppHook,
"*": pointerHook, "*": pointerHook,
@ -513,7 +555,6 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
def("text/x-scala", { def("text/x-scala", {
name: "clike", name: "clike",
keywords: words( keywords: words(
/* scala */ /* scala */
"abstract case catch class def do else extends 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 " + "implicit import lazy match new null object override package private protected return " +
@ -573,7 +614,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
return state.tokenize(stream, state) return state.tokenize(stream, state)
} }
}, },
modeProps: {closeBrackets: {triples: '"'}} modeProps: {closeBrackets: {pairs: '()[]{}""', triples: '"'}}
}); });
function tokenKotlinString(tripleString){ function tokenKotlinString(tripleString){
@ -628,9 +669,23 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
stream.eatWhile(/[\w\$_]/); stream.eatWhile(/[\w\$_]/);
return "meta"; return "meta";
}, },
'*': function(_stream, state) {
return state.prevToken == '.' ? 'variable' : 'operator';
},
'"': function(stream, state) { '"': function(stream, state) {
state.tokenize = tokenKotlinString(stream.match('""')); state.tokenize = tokenKotlinString(stream.match('""'));
return state.tokenize(stream, state); return state.tokenize(stream, state);
},
indent: function(state, ctx, textAfter, indentUnit) {
var firstChar = textAfter && textAfter.charAt(0);
if ((state.prevToken == "}" || state.prevToken == ")") && textAfter == "")
return state.indented;
if (state.prevToken == "operator" && textAfter != "}" ||
state.prevToken == "variable" && firstChar == "." ||
(state.prevToken == "}" || state.prevToken == ")") && firstChar == ".")
return indentUnit * 2 + ctx.indented;
if (ctx.align && ctx.type == "}")
return ctx.indented + (state.context.type == (textAfter || "").charAt(0) ? 0 : indentUnit);
} }
}, },
modeProps: {closeBrackets: {triples: '"'}} modeProps: {closeBrackets: {triples: '"'}}
@ -697,11 +752,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
def("text/x-nesc", { def("text/x-nesc", {
name: "clike", name: "clike",
keywords: words(cKeywords + "as atomic async call command component components configuration event generic " + 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 " + "implementation includes interface module new norace nx_struct nx_union post provides " +
"signal task uses abstract extends"), "signal task uses abstract extends"),
types: words(cTypes), types: cTypes,
blockKeywords: words("case do else for if switch while struct"), blockKeywords: words(cBlockKeywords),
atoms: words("null true false"), atoms: words("null true false"),
hooks: {"#": cppHook}, hooks: {"#": cppHook},
modeProps: {fold: ["brace", "include"]} modeProps: {fold: ["brace", "include"]}
@ -709,28 +764,34 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
def("text/x-objectivec", { def("text/x-objectivec", {
name: "clike", name: "clike",
keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginary BOOL Class bycopy byref id IMP in " + keywords: words(cKeywords + " bycopy byref in inout oneway out self super atomic nonatomic retain copy " +
"inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"), "readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " +
types: words(cTypes), "@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
atoms: words("YES NO NULL NILL ON OFF true false"), "@public @package @private @protected @required @optional @try @catch @finally @import " +
"@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available"),
types: objCTypes,
builtin: words("FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION NS_RETURNS_RETAINED " +
"NS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER NS_DESIGNATED_INITIALIZER " +
"NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION NS_ASSUME_NONNULL_BEGIN " +
"NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT"),
blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized"),
defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class"),
dontIndentStatements: /^@.*$/,
typeFirstDefinitions: true,
atoms: words("YES NO NULL Nil nil true false nullptr"),
isReservedIdentifier: cIsReservedIdentifier,
hooks: { hooks: {
"@": function(stream) {
stream.eatWhile(/[\w\$]/);
return "keyword";
},
"#": cppHook, "#": cppHook,
indent: function(_state, ctx, textAfter) { "*": pointerHook,
if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented
}
}, },
modeProps: {fold: "brace"} modeProps: {fold: ["brace", "include"]}
}); });
def("text/x-squirrel", { def("text/x-squirrel", {
name: "clike", name: "clike",
keywords: words("base break clone continue const default delete enum extends function in class" + 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"), " foreach local resume return this throw typeof yield constructor instanceof static"),
types: words(cTypes), types: cTypes,
blockKeywords: words("case catch class else for foreach if switch try while"), blockKeywords: words("case catch class else for foreach if switch try while"),
defKeywords: words("function local class"), defKeywords: words("function local class"),
typeFirstDefinitions: true, typeFirstDefinitions: true,

View file

@ -12,7 +12,7 @@
<script src="clike.js"></script> <script src="clike.js"></script>
<style>.CodeMirror {border: 2px inset #dee;}</style> <style>.CodeMirror {border: 2px inset #dee;}</style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>
@ -147,16 +147,36 @@ This is a longer comment
That spans two lines That spans two lines
*/ */
#import <Test/Test.h> #import "MyClass.h"
#import <AFramework/AFrameork.h>
@import BFrameworkModule;
NS_ENUM(SomeValues) {
aValue = 1;
};
// A Class Extension with some properties
@interface MyClass ()<AProtocol>
@property(atomic, readwrite, assign) NSInteger anInt;
@property(nonatomic, strong, nullable) NSString *aString;
@end
@implementation YourAppDelegate @implementation YourAppDelegate
// This is a one-line comment - (instancetype)initWithString:(NSString *)aStringVar {
if ((self = [super init])) {
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ aString = aStringVar;
char myString[] = "This is a C character array"; }
int test = 5; return self;
return YES;
} }
- (BOOL)doSomething:(float)progress {
NSString *myString = @"This is a ObjC string %f ";
myString = [[NSString stringWithFormat:myString, progress] stringByAppendingString:self.aString];
return myString.length > 100 ? NO : YES;
}
@end
</textarea></div> </textarea></div>
<h2>Java example</h2> <h2>Java example</h2>

View file

@ -10,7 +10,7 @@
<script src="../../addon/edit/matchbrackets.js"></script> <script src="../../addon/edit/matchbrackets.js"></script>
<script src="clike.js"></script> <script src="clike.js"></script>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function() { (function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c"); var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c");
@ -23,6 +23,8 @@
MT("def", MT("def",
"[type void] [def foo]() {}", "[type void] [def foo]() {}",
"[keyword struct] [def bar]{}", "[keyword struct] [def bar]{}",
"[keyword enum] [def zot]{}",
"[keyword union] [def ugh]{}",
"[type int] [type *][def baz]() {}"); "[type int] [type *][def baz]() {}");
MT("def_new_line", MT("def_new_line",
@ -43,6 +45,26 @@
"[type unsigned] [type int] [variable bar] [operator =] [number 8];", "[type unsigned] [type int] [variable bar] [operator =] [number 8];",
"[meta #include <baz> ][comment // comment]") "[meta #include <baz> ][comment // comment]")
MT("c_underscores",
"[builtin __FOO];",
"[builtin _Complex];",
"[builtin __aName];",
"[variable _aName];");
MT("c_types",
"[type int];",
"[type long];",
"[type char];",
"[type short];",
"[type double];",
"[type float];",
"[type unsigned];",
"[type signed];",
"[type void];",
"[type bool];",
"[type foo_t];",
"[variable foo_T];",
"[variable _t];");
var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src"); 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)); } function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
@ -57,6 +79,54 @@
"[def Foo::Foo]() {}", "[def Foo::Foo]() {}",
"[def Foo::~Foo]() {}"); "[def Foo::~Foo]() {}");
MTCPP("cpp_underscores",
"[builtin __FOO];",
"[builtin _Complex];",
"[builtin __aName];",
"[variable _aName];");
var mode_objc = CodeMirror.getMode({indentUnit: 2}, "text/x-objectivec");
function MTOBJC(name) { test.mode(name, mode_objc, Array.prototype.slice.call(arguments, 1)); }
MTOBJC("objc_underscores",
"[builtin __FOO];",
"[builtin _Complex];",
"[builtin __aName];",
"[variable _aName];");
MTOBJC("objc_interface",
"[keyword @interface] [def foo] {",
" [type int] [variable bar];",
"}",
"[keyword @property] ([keyword atomic], [keyword nullable]) [variable NSString][operator *] [variable a];",
"[keyword @property] ([keyword nonatomic], [keyword assign]) [type int] [variable b];",
"[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] " +
"[builtin NS_DESIGNATED_INITIALIZER];",
"[keyword @end]");
MTOBJC("objc_implementation",
"[keyword @implementation] [def foo] {",
" [type int] [variable bar];",
"}",
"[keyword @property] ([keyword readwrite]) [type SEL] [variable a];",
"[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] {",
" [keyword if](([keyword self] [operator =] [[[keyword super] [variable init] ]])) {}",
" [keyword return] [keyword self];",
"}",
"[keyword @end]");
MTOBJC("objc_types",
"[type int];",
"[type foo_t];",
"[variable foo_T];",
"[type id];",
"[type SEL];",
"[type instancetype];",
"[type Class];",
"[type Protocol];",
"[type BOOL];"
);
var mode_scala = CodeMirror.getMode({indentUnit: 2}, "text/x-scala"); var mode_scala = CodeMirror.getMode({indentUnit: 2}, "text/x-scala");
function MTSCALA(name) { test.mode("scala_" + name, mode_scala, Array.prototype.slice.call(arguments, 1)); } function MTSCALA(name) { test.mode("scala_" + name, mode_scala, Array.prototype.slice.call(arguments, 1)); }
MTSCALA("nested_comments", MTSCALA("nested_comments",

View file

@ -1,15 +1,10 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://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) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports === "object" && typeof module === "object") // CommonJS
mod(require("../../lib/codemirror")); mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD else if (typeof define === "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod); define(["../../lib/codemirror"], mod);
else // Plain browser env else // Plain browser env
mod(CodeMirror); mod(CodeMirror);
@ -17,286 +12,277 @@
"use strict"; "use strict";
CodeMirror.defineMode("clojure", function (options) { CodeMirror.defineMode("clojure", function (options) {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2", var atoms = ["false", "nil", "true"];
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword", VAR = "variable"; var specialForms = [".", "catch", "def", "do", "if", "monitor-enter",
var INDENT_WORD_SKIP = options.indentUnit || 2; "monitor-exit", "new", "quote", "recur", "set!", "throw", "try", "var"];
var NORMAL_INDENT_UNIT = options.indentUnit || 2; var coreSymbols = ["*", "*'", "*1", "*2", "*3", "*agent*",
"*allow-unresolved-vars*", "*assert*", "*clojure-version*",
"*command-line-args*", "*compile-files*", "*compile-path*",
"*compiler-options*", "*data-readers*", "*default-data-reader-fn*", "*e",
"*err*", "*file*", "*flush-on-newline*", "*fn-loader*", "*in*",
"*math-context*", "*ns*", "*out*", "*print-dup*", "*print-length*",
"*print-level*", "*print-meta*", "*print-namespace-maps*",
"*print-readably*", "*read-eval*", "*reader-resolver*", "*source-path*",
"*suppress-read*", "*unchecked-math*", "*use-context-classloader*",
"*verbose-defrecords*", "*warn-on-reflection*", "+", "+'", "-", "-'",
"->", "->>", "->ArrayChunk", "->Eduction", "->Vec", "->VecNode",
"->VecSeq", "-cache-protocol-fn", "-reset-methods", "..", "/", "<", "<=",
"=", "==", ">", ">=", "EMPTY-NODE", "Inst", "StackTraceElement->vec",
"Throwable->map", "accessor", "aclone", "add-classpath", "add-watch",
"agent", "agent-error", "agent-errors", "aget", "alength", "alias",
"all-ns", "alter", "alter-meta!", "alter-var-root", "amap", "ancestors",
"and", "any?", "apply", "areduce", "array-map", "as->", "aset",
"aset-boolean", "aset-byte", "aset-char", "aset-double", "aset-float",
"aset-int", "aset-long", "aset-short", "assert", "assoc", "assoc!",
"assoc-in", "associative?", "atom", "await", "await-for", "await1",
"bases", "bean", "bigdec", "bigint", "biginteger", "binding", "bit-and",
"bit-and-not", "bit-clear", "bit-flip", "bit-not", "bit-or", "bit-set",
"bit-shift-left", "bit-shift-right", "bit-test", "bit-xor", "boolean",
"boolean-array", "boolean?", "booleans", "bound-fn", "bound-fn*",
"bound?", "bounded-count", "butlast", "byte", "byte-array", "bytes",
"bytes?", "case", "cast", "cat", "char", "char-array",
"char-escape-string", "char-name-string", "char?", "chars", "chunk",
"chunk-append", "chunk-buffer", "chunk-cons", "chunk-first", "chunk-next",
"chunk-rest", "chunked-seq?", "class", "class?", "clear-agent-errors",
"clojure-version", "coll?", "comment", "commute", "comp", "comparator",
"compare", "compare-and-set!", "compile", "complement", "completing",
"concat", "cond", "cond->", "cond->>", "condp", "conj", "conj!", "cons",
"constantly", "construct-proxy", "contains?", "count", "counted?",
"create-ns", "create-struct", "cycle", "dec", "dec'", "decimal?",
"declare", "dedupe", "default-data-readers", "definline", "definterface",
"defmacro", "defmethod", "defmulti", "defn", "defn-", "defonce",
"defprotocol", "defrecord", "defstruct", "deftype", "delay", "delay?",
"deliver", "denominator", "deref", "derive", "descendants", "destructure",
"disj", "disj!", "dissoc", "dissoc!", "distinct", "distinct?", "doall",
"dorun", "doseq", "dosync", "dotimes", "doto", "double", "double-array",
"double?", "doubles", "drop", "drop-last", "drop-while", "eduction",
"empty", "empty?", "ensure", "ensure-reduced", "enumeration-seq",
"error-handler", "error-mode", "eval", "even?", "every-pred", "every?",
"ex-data", "ex-info", "extend", "extend-protocol", "extend-type",
"extenders", "extends?", "false?", "ffirst", "file-seq", "filter",
"filterv", "find", "find-keyword", "find-ns", "find-protocol-impl",
"find-protocol-method", "find-var", "first", "flatten", "float",
"float-array", "float?", "floats", "flush", "fn", "fn?", "fnext", "fnil",
"for", "force", "format", "frequencies", "future", "future-call",
"future-cancel", "future-cancelled?", "future-done?", "future?",
"gen-class", "gen-interface", "gensym", "get", "get-in", "get-method",
"get-proxy-class", "get-thread-bindings", "get-validator", "group-by",
"halt-when", "hash", "hash-combine", "hash-map", "hash-ordered-coll",
"hash-set", "hash-unordered-coll", "ident?", "identical?", "identity",
"if-let", "if-not", "if-some", "ifn?", "import", "in-ns", "inc", "inc'",
"indexed?", "init-proxy", "inst-ms", "inst-ms*", "inst?", "instance?",
"int", "int-array", "int?", "integer?", "interleave", "intern",
"interpose", "into", "into-array", "ints", "io!", "isa?", "iterate",
"iterator-seq", "juxt", "keep", "keep-indexed", "key", "keys", "keyword",
"keyword?", "last", "lazy-cat", "lazy-seq", "let", "letfn", "line-seq",
"list", "list*", "list?", "load", "load-file", "load-reader",
"load-string", "loaded-libs", "locking", "long", "long-array", "longs",
"loop", "macroexpand", "macroexpand-1", "make-array", "make-hierarchy",
"map", "map-entry?", "map-indexed", "map?", "mapcat", "mapv", "max",
"max-key", "memfn", "memoize", "merge", "merge-with", "meta",
"method-sig", "methods", "min", "min-key", "mix-collection-hash", "mod",
"munge", "name", "namespace", "namespace-munge", "nat-int?", "neg-int?",
"neg?", "newline", "next", "nfirst", "nil?", "nnext", "not", "not-any?",
"not-empty", "not-every?", "not=", "ns", "ns-aliases", "ns-imports",
"ns-interns", "ns-map", "ns-name", "ns-publics", "ns-refers",
"ns-resolve", "ns-unalias", "ns-unmap", "nth", "nthnext", "nthrest",
"num", "number?", "numerator", "object-array", "odd?", "or", "parents",
"partial", "partition", "partition-all", "partition-by", "pcalls", "peek",
"persistent!", "pmap", "pop", "pop!", "pop-thread-bindings", "pos-int?",
"pos?", "pr", "pr-str", "prefer-method", "prefers",
"primitives-classnames", "print", "print-ctor", "print-dup",
"print-method", "print-simple", "print-str", "printf", "println",
"println-str", "prn", "prn-str", "promise", "proxy",
"proxy-call-with-super", "proxy-mappings", "proxy-name", "proxy-super",
"push-thread-bindings", "pvalues", "qualified-ident?",
"qualified-keyword?", "qualified-symbol?", "quot", "rand", "rand-int",
"rand-nth", "random-sample", "range", "ratio?", "rational?",
"rationalize", "re-find", "re-groups", "re-matcher", "re-matches",
"re-pattern", "re-seq", "read", "read-line", "read-string",
"reader-conditional", "reader-conditional?", "realized?", "record?",
"reduce", "reduce-kv", "reduced", "reduced?", "reductions", "ref",
"ref-history-count", "ref-max-history", "ref-min-history", "ref-set",
"refer", "refer-clojure", "reify", "release-pending-sends", "rem",
"remove", "remove-all-methods", "remove-method", "remove-ns",
"remove-watch", "repeat", "repeatedly", "replace", "replicate", "require",
"reset!", "reset-meta!", "reset-vals!", "resolve", "rest",
"restart-agent", "resultset-seq", "reverse", "reversible?", "rseq",
"rsubseq", "run!", "satisfies?", "second", "select-keys", "send",
"send-off", "send-via", "seq", "seq?", "seqable?", "seque", "sequence",
"sequential?", "set", "set-agent-send-executor!",
"set-agent-send-off-executor!", "set-error-handler!", "set-error-mode!",
"set-validator!", "set?", "short", "short-array", "shorts", "shuffle",
"shutdown-agents", "simple-ident?", "simple-keyword?", "simple-symbol?",
"slurp", "some", "some->", "some->>", "some-fn", "some?", "sort",
"sort-by", "sorted-map", "sorted-map-by", "sorted-set", "sorted-set-by",
"sorted?", "special-symbol?", "spit", "split-at", "split-with", "str",
"string?", "struct", "struct-map", "subs", "subseq", "subvec", "supers",
"swap!", "swap-vals!", "symbol", "symbol?", "sync", "tagged-literal",
"tagged-literal?", "take", "take-last", "take-nth", "take-while", "test",
"the-ns", "thread-bound?", "time", "to-array", "to-array-2d",
"trampoline", "transduce", "transient", "tree-seq", "true?", "type",
"unchecked-add", "unchecked-add-int", "unchecked-byte", "unchecked-char",
"unchecked-dec", "unchecked-dec-int", "unchecked-divide-int",
"unchecked-double", "unchecked-float", "unchecked-inc",
"unchecked-inc-int", "unchecked-int", "unchecked-long",
"unchecked-multiply", "unchecked-multiply-int", "unchecked-negate",
"unchecked-negate-int", "unchecked-remainder-int", "unchecked-short",
"unchecked-subtract", "unchecked-subtract-int", "underive", "unquote",
"unquote-splicing", "unreduced", "unsigned-bit-shift-right", "update",
"update-in", "update-proxy", "uri?", "use", "uuid?", "val", "vals",
"var-get", "var-set", "var?", "vary-meta", "vec", "vector", "vector-of",
"vector?", "volatile!", "volatile?", "vreset!", "vswap!", "when",
"when-first", "when-let", "when-not", "when-some", "while",
"with-bindings", "with-bindings*", "with-in-str", "with-loading-context",
"with-local-vars", "with-meta", "with-open", "with-out-str",
"with-precision", "with-redefs", "with-redefs-fn", "xml-seq", "zero?",
"zipmap"];
var haveBodyParameter = [
"->", "->>", "as->", "binding", "bound-fn", "case", "catch", "comment",
"cond", "cond->", "cond->>", "condp", "def", "definterface", "defmethod",
"defn", "defmacro", "defprotocol", "defrecord", "defstruct", "deftype",
"do", "doseq", "dotimes", "doto", "extend", "extend-protocol",
"extend-type", "fn", "for", "future", "if", "if-let", "if-not", "if-some",
"let", "letfn", "locking", "loop", "ns", "proxy", "reify", "struct-map",
"some->", "some->>", "try", "when", "when-first", "when-let", "when-not",
"when-some", "while", "with-bindings", "with-bindings*", "with-in-str",
"with-loading-context", "with-local-vars", "with-meta", "with-open",
"with-out-str", "with-precision", "with-redefs", "with-redefs-fn"];
function makeKeywords(str) { CodeMirror.registerHelper("hintWords", "clojure",
var obj = {}, words = str.split(" "); [].concat(atoms, specialForms, coreSymbols));
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj; var atom = createLookupMap(atoms);
var specialForm = createLookupMap(specialForms);
var coreSymbol = createLookupMap(coreSymbols);
var hasBodyParameter = createLookupMap(haveBodyParameter);
var delimiter = /^(?:[\\\[\]\s"(),;@^`{}~]|$)/;
var numberLiteral = /^(?:[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?(?=[\\\[\]\s"#'(),;@^`{}~]|$))/;
var characterLiteral = /^(?:\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?(?=[\\\[\]\s"(),;@^`{}~]|$))/;
// simple-namespace := /^[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*/
// simple-symbol := /^(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)/
// qualified-symbol := (<simple-namespace>(<.><simple-namespace>)*</>)?<simple-symbol>
var qualifiedSymbol = /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/;
function base(stream, state) {
if (stream.eatSpace()) return ["space", null];
if (stream.match(numberLiteral)) return [null, "number"];
if (stream.match(characterLiteral)) return [null, "string-2"];
if (stream.eat(/^"/)) return (state.tokenize = inString)(stream, state);
if (stream.eat(/^[(\[{]/)) return ["open", "bracket"];
if (stream.eat(/^[)\]}]/)) return ["close", "bracket"];
if (stream.eat(/^;/)) {stream.skipToEnd(); return ["space", "comment"];}
if (stream.eat(/^[#'@^`~]/)) return [null, "meta"];
var matches = stream.match(qualifiedSymbol);
var symbol = matches && matches[0];
if (!symbol) {
// advance stream by at least one character so we don't get stuck.
stream.next();
stream.eatWhile(function (c) {return !is(c, delimiter);});
return [null, "error"];
} }
var atoms = makeKeywords("true false nil"); if (symbol === "comment" && state.lastToken === "(")
return (state.tokenize = inComment)(stream, state);
if (is(symbol, atom) || symbol.charAt(0) === ":") return ["symbol", "atom"];
if (is(symbol, specialForm) || is(symbol, coreSymbol)) return ["symbol", "keyword"];
if (state.lastToken === "(") return ["symbol", "builtin"]; // other operator
var keywords = makeKeywords( return ["symbol", "variable"];
"defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject deftest " + }
"slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn " +
"do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync " +
"doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars " +
"binding gen-class gen-and-load-class gen-and-save-class handler-case handle");
var builtins = makeKeywords( function inString(stream, state) {
"* *' *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* *command-line-args* *compile-files* " + var escaped = false, next;
"*compile-path* *compiler-options* *data-readers* *e *err* *file* *flush-on-newline* *fn-loader* *in* " +
"*math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* " +
"*source-path* *unchecked-math* *use-context-classloader* *verbose-defrecords* *warn-on-reflection* + +' - -' -> " +
"->> ->ArrayChunk ->Vec ->VecNode ->VecSeq -cache-protocol-fn -reset-methods .. / < <= = == > >= EMPTY-NODE accessor " +
"aclone add-classpath add-watch agent agent-error agent-errors aget alength alias all-ns alter alter-meta! " +
"alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double " +
"aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 " +
"bases bean bigdec bigint biginteger binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set " +
"bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* bound? butlast " +
"byte byte-array bytes case cat cast char char-array char-escape-string char-name-string char? chars chunk chunk-append " +
"chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors " +
"clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement completing concat cond condp " +
"conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec dec' decimal? " +
"declare dedupe default-data-readers definline definterface defmacro defmethod defmulti defn defn- defonce defprotocol " +
"defrecord defstruct deftype delay delay? deliver denominator deref derive descendants destructure disj disj! dissoc " +
"dissoc! distinct distinct? doall dorun doseq dosync dotimes doto double double-array doubles drop drop-last " +
"drop-while eduction empty empty? ensure enumeration-seq error-handler error-mode eval even? every-pred every? ex-data ex-info " +
"extend extend-protocol extend-type extenders extends? false? ffirst file-seq filter filterv find find-keyword " +
"find-ns find-protocol-impl find-protocol-method find-var first flatten float float-array float? floats flush fn fn? " +
"fnext fnil for force format frequencies future future-call future-cancel future-cancelled? future-done? future? " +
"gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator group-by hash " +
"hash-combine hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc inc' init-proxy instance? " +
"int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt keep " +
"keep-indexed key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file " +
"load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array " +
"make-hierarchy map map-indexed map? mapcat mapv max max-key memfn memoize merge merge-with meta method-sig methods " +
"min min-key mod munge name namespace namespace-munge neg? newline next nfirst nil? nnext not not-any? not-empty " +
"not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias " +
"ns-unmap nth nthnext nthrest num number? numerator object-array odd? or parents partial partition partition-all " +
"partition-by pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers " +
"primitives-classnames print print-ctor print-dup print-method print-simple print-str printf println println-str " +
"prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues " +
"quot rand rand-int rand-nth random-sample range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern " +
"re-seq read read-line read-string realized? reduce reduce-kv reductions ref ref-history-count ref-max-history " +
"ref-min-history ref-set refer refer-clojure reify release-pending-sends rem remove remove-all-methods " +
"remove-method remove-ns remove-watch repeat repeatedly replace replicate require reset! reset-meta! resolve rest " +
"restart-agent resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? " +
"seque sequence sequential? set set-error-handler! set-error-mode! set-validator! set? short short-array shorts " +
"shuffle shutdown-agents slurp some some-fn sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? " +
"special-symbol? spit split-at split-with str string? struct struct-map subs subseq subvec supers swap! symbol " +
"symbol? sync take take-last take-nth take-while test the-ns thread-bound? time to-array to-array-2d trampoline transduce " +
"transient tree-seq true? type unchecked-add unchecked-add-int unchecked-byte unchecked-char unchecked-dec " +
"unchecked-dec-int unchecked-divide-int unchecked-double unchecked-float unchecked-inc unchecked-inc-int " +
"unchecked-int unchecked-long unchecked-multiply unchecked-multiply-int unchecked-negate unchecked-negate-int "+
"unchecked-remainder-int unchecked-short unchecked-subtract unchecked-subtract-int underive unquote " +
"unquote-splicing update update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector-of " +
"vector? volatile! volatile? vreset! vswap! when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context " +
"with-local-vars with-meta with-open with-out-str with-precision with-redefs with-redefs-fn xml-seq zero? zipmap " +
"*default-data-reader-fn* as-> cond-> cond->> reduced reduced? send-via set-agent-send-executor! " +
"set-agent-send-off-executor! some-> some->>");
var indentKeys = makeKeywords( while (next = stream.next()) {
// Built-ins if (next === "\"" && !escaped) {state.tokenize = base; break;}
"ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto " + escaped = !escaped && next === "\\";
"locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type " +
"try catch " +
// Binding forms
"let letfn binding loop for doseq dotimes when-let if-let " +
// Data structures
"defstruct struct-map assoc " +
// clojure.test
"testing deftest " +
// contrib
"handler-case handle dotrace deftrace");
var tests = {
digit: /\d/,
digit_or_colon: /[\d:]/,
hex: /[0-9a-f]/i,
sign: /[+-]/,
exponent: /e/i,
keyword_char: /[^\s\(\[\;\)\]]/,
symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/,
block_indent: /^(?:def|with)[^\/]+$|\/(?:def|with)/
};
function stateStack(indent, type, prev) { // represents a state stack object
this.indent = indent;
this.type = type;
this.prev = prev;
} }
function pushStack(state, indent, type) { return [null, "string"];
state.indentStack = new stateStack(indent, type, state.indentStack); }
function inComment(stream, state) {
var parenthesisCount = 1;
var next;
while (next = stream.next()) {
if (next === ")") parenthesisCount--;
if (next === "(") parenthesisCount++;
if (parenthesisCount === 0) {
stream.backUp(1);
state.tokenize = base;
break;
}
} }
function popStack(state) { return ["space", "comment"];
state.indentStack = state.indentStack.prev; }
}
function isNumber(ch, stream){ function createLookupMap(words) {
// hex var obj = {};
if ( ch === '0' && stream.eat(/x/i) ) {
stream.eatWhile(tests.hex); for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return true;
return obj;
}
function is(value, test) {
if (test instanceof RegExp) return test.test(value);
if (test instanceof Object) return test.propertyIsEnumerable(value);
}
return {
startState: function () {
return {
ctx: {prev: null, start: 0, indentTo: 0},
lastToken: null,
tokenize: base
};
},
token: function (stream, state) {
if (stream.sol() && (typeof state.ctx.indentTo !== "number"))
state.ctx.indentTo = state.ctx.start + 1;
var typeStylePair = state.tokenize(stream, state);
var type = typeStylePair[0];
var style = typeStylePair[1];
var current = stream.current();
if (type !== "space") {
if (state.lastToken === "(" && state.ctx.indentTo === null) {
if (type === "symbol" && is(current, hasBodyParameter))
state.ctx.indentTo = state.ctx.start + options.indentUnit;
else state.ctx.indentTo = "next";
} else if (state.ctx.indentTo === "next") {
state.ctx.indentTo = stream.column();
} }
// leading sign state.lastToken = current;
if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) { }
stream.eat(tests.sign);
ch = stream.next();
}
if ( tests.digit.test(ch) ) { if (type === "open")
stream.eat(ch); state.ctx = {prev: state.ctx, start: stream.column(), indentTo: null};
stream.eatWhile(tests.digit); else if (type === "close") state.ctx = state.ctx.prev || state.ctx;
if ( '.' == stream.peek() ) { return style;
stream.eat('.'); },
stream.eatWhile(tests.digit);
} else if ('/' == stream.peek() ) {
stream.eat('/');
stream.eatWhile(tests.digit);
}
if ( stream.eat(tests.exponent) ) { indent: function (state) {
stream.eat(tests.sign); var i = state.ctx.indentTo;
stream.eatWhile(tests.digit);
}
return true; return (typeof i === "number") ?
} i :
state.ctx.start + 1;
},
return false; closeBrackets: {pairs: "()[]{}\"\""},
} lineComment: ";;"
};
// Eat character that starts after backslash \
function eatCharacter(stream) {
var first = stream.next();
// Read special literals: backspace, newline, space, return.
// Just read all lowercase letters.
if (first && first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) {
return;
}
// Read unicode character: \u1000 \uA0a1
if (first === "u") {
stream.match(/[0-9a-z]{4}/i, true);
}
}
return {
startState: function () {
return {
indentStack: null,
indentation: 0,
mode: false
};
},
token: function (stream, state) {
if (state.indentStack == null && stream.sol()) {
// update indentation, but only if indentStack is empty
state.indentation = stream.indentation();
}
// skip spaces
if (state.mode != "string" && stream.eatSpace()) {
return null;
}
var returnType = null;
switch(state.mode){
case "string": // multi-line string parsing mode
var next, escaped = false;
while ((next = stream.next()) != null) {
if (next == "\"" && !escaped) {
state.mode = false;
break;
}
escaped = !escaped && next == "\\";
}
returnType = STRING; // continue on in string mode
break;
default: // default parsing mode
var ch = stream.next();
if (ch == "\"") {
state.mode = "string";
returnType = STRING;
} else if (ch == "\\") {
eatCharacter(stream);
returnType = CHARACTER;
} else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
returnType = ATOM;
} else if (ch == ";") { // comment
stream.skipToEnd(); // rest of the line is a comment
returnType = COMMENT;
} else if (isNumber(ch,stream)){
returnType = NUMBER;
} else if (ch == "(" || ch == "[" || ch == "{" ) {
var keyWord = '', indentTemp = stream.column(), letter;
/**
Either
(indent-word ..
(non-indent-word ..
(;something else, bracket, etc.
*/
if (ch == "(") while ((letter = stream.eat(tests.keyword_char)) != null) {
keyWord += letter;
}
if (keyWord.length > 0 && (indentKeys.propertyIsEnumerable(keyWord) ||
tests.block_indent.test(keyWord))) { // indent-word
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
} else { // non-indent word
// we continue eating the spaces
stream.eatSpace();
if (stream.eol() || stream.peek() == ";") {
// nothing significant after
// we restart indentation the user defined spaces after
pushStack(state, indentTemp + NORMAL_INDENT_UNIT, ch);
} else {
pushStack(state, indentTemp + stream.current().length, ch); // else we match
}
}
stream.backUp(stream.current().length - 1); // undo all the eating
returnType = BRACKET;
} else if (ch == ")" || ch == "]" || ch == "}") {
returnType = BRACKET;
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : (ch == "]" ? "[" :"{"))) {
popStack(state);
}
} else if ( ch == ":" ) {
stream.eatWhile(tests.symbol);
return ATOM;
} else {
stream.eatWhile(tests.symbol);
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
returnType = KEYWORD;
} else if (builtins && builtins.propertyIsEnumerable(stream.current())) {
returnType = BUILTIN;
} else if (atoms && atoms.propertyIsEnumerable(stream.current())) {
returnType = ATOM;
} else {
returnType = VAR;
}
}
}
return returnType;
},
indent: function (state) {
if (state.indentStack == null) return state.indentation;
return state.indentStack.indent;
},
closeBrackets: {pairs: "()[]{}\"\""},
lineComment: ";;"
};
}); });
CodeMirror.defineMIME("text/x-clojure", "clojure"); CodeMirror.defineMIME("text/x-clojure", "clojure");

View file

@ -6,10 +6,12 @@
<link rel="stylesheet" href="../../lib/codemirror.css"> <link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script> <script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/closebrackets.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="clojure.js"></script> <script src="clojure.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style> <style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>
@ -25,65 +27,67 @@
<article> <article>
<h2>Clojure mode</h2> <h2>Clojure mode</h2>
<form><textarea id="code" name="code"> <form><textarea id="code" name="code">
; Conway's Game of Life, based on the work of: (ns game-of-life
;; Laurent Petit https://gist.github.com/1200343 "Conway's Game of Life, based on the work of
;; Christophe Grand http://clj-me.cgrand.net/2011/08/19/conways-game-of-life Christophe Grand (http://clj-me.cgrand.net/2011/08/19/conways-game-of-life)
and Laurent Petit (https://gist.github.com/1200343).")
(ns ^{:doc "Conway's Game of Life."} ;;; Core game of life's algorithm functions
game-of-life)
;; Core game of life's algorithm functions (defn neighbors
"Given a cell's coordinates `[x y]`, returns the coordinates of its
(defn neighbours neighbors."
"Given a cell's coordinates, returns the coordinates of its neighbours."
[[x y]] [[x y]]
(for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])] (for [dx [-1 0 1]
dy (if (zero? dx)
[-1 1]
[-1 0 1])]
[(+ dx x) (+ dy y)])) [(+ dx x) (+ dy y)]))
(defn step (defn step
"Given a set of living cells, computes the new set of living cells." "Given a set of living `cells`, computes the new set of living cells."
[cells] [cells]
(set (for [[cell n] (frequencies (mapcat neighbours cells)) (set (for [[cell n] (frequencies (mapcat neighbors cells))
:when (or (= n 3) (and (= n 2) (cells cell)))] :when (or (= n 3)
(and (= n 2)
(cells cell)))]
cell))) cell)))
;; Utility methods for displaying game on a text terminal ;;; Utility methods for displaying game on a text terminal
(defn print-board (defn print-grid
"Prints a board on *out*, representing a step in the game." "Prints a `grid` of `w` columns and `h` rows, on *out*, representing a
[board w h] step in the game."
(doseq [x (range (inc w)) y (range (inc h))] [grid w h]
(if (= y 0) (print "\n")) (doseq [x (range (inc w))
(print (if (board [x y]) "[X]" " . ")))) y (range (inc h))]
(when (= y 0) (println))
(print (if (grid [x y])
"[X]"
" . "))))
(defn display-grids (defn print-grids
"Prints a squence of boards on *out*, representing several steps." "Prints a sequence of `grids` of `w` columns and `h` rows on *out*,
representing several steps."
[grids w h] [grids w h]
(doseq [board grids] (doseq [grid grids]
(print-board board w h) (print-grid grid w h)
(print "\n"))) (println)))
;; Launches an example board ;;; Launches an example grid
(def (def grid
^{:doc "board represents the initial set of living cells"} "`grid` represents the initial set of living cells"
board #{[2 1] [2 2] [2 3]}) #{[2 1] [2 2] [2 3]})
(display-grids (take 3 (iterate step board)) 5 5) (print-grids (take 3 (iterate step grid)) 5 5)</textarea></form>
;; Let's play with characters
(println \1 \a \# \\
\" \( \newline
\} \" \space
\tab \return \backspace
\u1000 \uAaAa \u9F9F)
;; Let's play with numbers
(+ 1 -1 1/2 -1/2 -0.5 0.5)
</textarea></form>
<script> <script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {}); var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
autoCloseBrackets: true,
lineNumbers: true,
matchBrackets: true,
mode: 'text/x-clojure'
});
</script> </script>
<p><strong>MIME types defined:</strong> <code>text/x-clojure</code>.</p> <p><strong>MIME types defined:</strong> <code>text/x-clojure</code>.</p>

View file

@ -0,0 +1,384 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function () {
var mode = CodeMirror.getMode({indentUnit: 2}, "clojure");
function MT(name) {
test.mode(name, mode, Array.prototype.slice.call(arguments, 1));
}
MT("atoms",
"[atom false]",
"[atom nil]",
"[atom true]"
);
MT("keywords",
"[atom :foo]",
"[atom ::bar]",
"[atom :foo/bar]",
"[atom :foo.bar/baz]"
);
MT("numbers",
"[number 42] [number +42] [number -421]",
"[number 42N] [number +42N] [number -42N]",
"[number 0.42] [number +0.42] [number -0.42]",
"[number 42M] [number +42M] [number -42M]",
"[number 42.42M] [number +42.42M] [number -42.42M]",
"[number 1/42] [number +1/42] [number -1/42]",
"[number 0x42af] [number +0x42af] [number -0x42af]",
"[number 0x42AF] [number +0x42AF] [number -0x42AF]",
"[number 1e2] [number 1e+2] [number 1e-2]",
"[number +1e2] [number +1e+2] [number +1e-2]",
"[number -1e2] [number -1e+2] [number -1e-2]",
"[number -1.0e2] [number -0.1e+2] [number -1.01e-2]",
"[number 1E2] [number 1E+2] [number 1E-2]",
"[number +1E2] [number +1E+2] [number +1E-2]",
"[number -1E2] [number -1E+2] [number -1E-2]",
"[number -1.0E2] [number -0.1E+2] [number -1.01E-2]",
"[number 2r101010] [number +2r101010] [number -2r101010]",
"[number 2r101010] [number +2r101010] [number -2r101010]",
"[number 8r52] [number +8r52] [number -8r52]",
"[number 36rhello] [number +36rhello] [number -36rhello]",
"[number 36rz] [number +36rz] [number -36rz]",
"[number 36rZ] [number +36rZ] [number -36rZ]",
// invalid numbers
"[error 42foo]",
"[error 42Nfoo]",
"[error 42Mfoo]",
"[error 42.42Mfoo]",
"[error 42.42M!]",
"[error 42!]",
"[error 0x42afm]"
);
MT("characters",
"[string-2 \\1]",
"[string-2 \\a]",
"[string-2 \\a\\b\\c]",
"[string-2 \\#]",
"[string-2 \\\\]",
"[string-2 \\\"]",
"[string-2 \\(]",
"[string-2 \\A]",
"[string-2 \\backspace]",
"[string-2 \\formfeed]",
"[string-2 \\newline]",
"[string-2 \\space]",
"[string-2 \\return]",
"[string-2 \\tab]",
"[string-2 \\u1000]",
"[string-2 \\uAaAa]",
"[string-2 \\u9F9F]",
"[string-2 \\o123]",
"[string-2 \\符]",
"[string-2 \\シ]",
"[string-2 \\ۇ]",
// FIXME
// "[string-2 \\🙂]",
// invalid character literals
"[error \\abc]",
"[error \\a123]",
"[error \\a!]",
"[error \\newlines]",
"[error \\NEWLINE]",
"[error \\u9F9FF]",
"[error \\o1234]"
);
MT("strings",
"[string \"I'm a teapot.\"]",
"[string \"I'm a \\\"teapot\\\".\"]",
"[string \"I'm]", // this is
"[string a]", // a multi-line
"[string teapot.\"]" // string
// TODO unterminated (multi-line) strings?
);
MT("comments",
"[comment ; this is an in-line comment.]",
"[comment ;; this is a line comment.]",
"[keyword comment]",
"[bracket (][comment comment (foo 1 2 3)][bracket )]"
);
MT("reader macro characters",
"[meta #][variable _]",
"[meta #][variable -Inf]",
"[meta ##][variable Inf]",
"[meta ##][variable NaN]",
"[meta @][variable x]",
"[meta ^][bracket {][atom :tag] [variable String][bracket }]",
"[meta `][bracket (][builtin f] [variable x][bracket )]",
"[meta ~][variable foo#]",
"[meta '][number 1]",
"[meta '][atom :foo]",
"[meta '][string \"foo\"]",
"[meta '][variable x]",
"[meta '][bracket (][builtin a] [variable b] [variable c][bracket )]",
"[meta '][bracket [[][variable a] [variable b] [variable c][bracket ]]]",
"[meta '][bracket {][variable a] [number 1] [atom :foo] [number 2] [variable c] [number 3][bracket }]",
"[meta '#][bracket {][variable a] [number 1] [atom :foo][bracket }]"
);
MT("symbols",
"[variable foo!]",
"[variable foo#]",
"[variable foo$]",
"[variable foo&]",
"[variable foo']",
"[variable foo*]",
"[variable foo+]",
"[variable foo-]",
"[variable foo.]",
"[variable foo/bar]",
"[variable foo:bar]",
"[variable foo<]",
"[variable foo=]",
"[variable foo>]",
"[variable foo?]",
"[variable foo_]",
"[variable foo|]",
"[variable foobarBaz]",
"[variable foo¡]",
"[variable 符号]",
"[variable シンボル]",
"[variable ئۇيغۇر]",
"[variable 🙂❤🇺🇸]",
// invalid symbols
"[error 3foo]",
"[error 3+]",
"[error 3|]",
"[error 3_]"
);
MT("numbers and other forms",
"[number 42][bracket (][builtin foo][bracket )]",
"[number 42][bracket [[][variable foo][bracket ]]]",
"[number 42][meta #][bracket {][variable foo][bracket }]",
"[number 42][bracket {][atom :foo] [variable bar][bracket }]",
"[number 42][meta `][variable foo]",
"[number 42][meta ~][variable foo]",
"[number 42][meta #][variable foo]"
);
var specialForms = [".", "catch", "def", "do", "if", "monitor-enter",
"monitor-exit", "new", "quote", "recur", "set!", "throw", "try", "var"];
MT("should highlight special forms as keywords",
typeTokenPairs("keyword", specialForms)
);
var coreSymbols1 = [
"*", "*'", "*1", "*2", "*3", "*agent*", "*allow-unresolved-vars*", "*assert*",
"*clojure-version*", "*command-line-args*", "*compile-files*", "*compile-path*", "*compiler-options*",
"*data-readers*", "*default-data-reader-fn*", "*e", "*err*", "*file*", "*flush-on-newline*", "*fn-loader*",
"*in*", "*math-context*", "*ns*", "*out*", "*print-dup*", "*print-length*", "*print-level*", "*print-meta*",
"*print-namespace-maps*", "*print-readably*", "*read-eval*", "*reader-resolver*", "*source-path*",
"*suppress-read*", "*unchecked-math*", "*use-context-classloader*", "*verbose-defrecords*",
"*warn-on-reflection*", "+", "+'", "-", "-'", "->", "->>", "->ArrayChunk", "->Eduction", "->Vec", "->VecNode",
"->VecSeq", "-cache-protocol-fn", "-reset-methods", "..", "/", "<", "<=", "=", "==", ">", ">=",
"EMPTY-NODE", "Inst", "StackTraceElement->vec", "Throwable->map", "accessor", "aclone", "add-classpath",
"add-watch", "agent", "agent-error", "agent-errors", "aget", "alength", "alias", "all-ns", "alter",
"alter-meta!", "alter-var-root", "amap", "ancestors", "and", "any?", "apply", "areduce", "array-map",
"as->", "aset", "aset-boolean", "aset-byte", "aset-char", "aset-double", "aset-float", "aset-int",
"aset-long", "aset-short", "assert", "assoc", "assoc!", "assoc-in", "associative?", "atom", "await",
"await-for", "await1", "bases", "bean", "bigdec", "bigint", "biginteger", "binding", "bit-and", "bit-and-not",
"bit-clear", "bit-flip", "bit-not", "bit-or", "bit-set", "bit-shift-left", "bit-shift-right", "bit-test",
"bit-xor", "boolean", "boolean-array", "boolean?", "booleans", "bound-fn", "bound-fn*", "bound?",
"bounded-count", "butlast", "byte", "byte-array", "bytes", "bytes?", "case", "cast", "cat", "char",
"char-array", "char-escape-string", "char-name-string", "char?", "chars", "chunk", "chunk-append",
"chunk-buffer", "chunk-cons", "chunk-first", "chunk-next", "chunk-rest", "chunked-seq?", "class", "class?",
"clear-agent-errors", "clojure-version", "coll?", "comment", "commute", "comp", "comparator", "compare",
"compare-and-set!", "compile", "complement", "completing", "concat", "cond", "cond->", "cond->>", "condp",
"conj", "conj!", "cons", "constantly", "construct-proxy", "contains?", "count", "counted?", "create-ns",
"create-struct", "cycle", "dec", "dec'", "decimal?", "declare", "dedupe", "default-data-readers", "definline",
"definterface", "defmacro", "defmethod", "defmulti", "defn", "defn-", "defonce", "defprotocol", "defrecord",
"defstruct", "deftype", "delay", "delay?", "deliver", "denominator", "deref", "derive", "descendants",
"destructure", "disj", "disj!", "dissoc", "dissoc!", "distinct", "distinct?", "doall", "dorun", "doseq",
"dosync", "dotimes", "doto", "double", "double-array", "double?", "doubles", "drop", "drop-last", "drop-while",
"eduction", "empty", "empty?", "ensure", "ensure-reduced", "enumeration-seq", "error-handler", "error-mode",
"eval", "even?", "every-pred", "every?", "ex-data", "ex-info", "extend", "extend-protocol", "extend-type",
"extenders", "extends?", "false?", "ffirst", "file-seq", "filter", "filterv", "find", "find-keyword", "find-ns",
"find-protocol-impl", "find-protocol-method", "find-var", "first", "flatten", "float", "float-array", "float?",
"floats", "flush", "fn", "fn?", "fnext", "fnil", "for", "force", "format", "frequencies", "future", "future-call",
"future-cancel", "future-cancelled?", "future-done?", "future?", "gen-class", "gen-interface", "gensym", "get",
"get-in", "get-method", "get-proxy-class", "get-thread-bindings", "get-validator", "group-by", "halt-when", "hash",
"hash-combine", "hash-map", "hash-ordered-coll", "hash-set", "hash-unordered-coll", "ident?", "identical?",
"identity", "if-let", "if-not", "if-some", "ifn?", "import", "in-ns", "inc", "inc'", "indexed?", "init-proxy",
"inst-ms", "inst-ms*", "inst?", "instance?", "int", "int-array", "int?", "integer?", "interleave", "intern",
"interpose", "into", "into-array", "ints", "io!", "isa?", "iterate", "iterator-seq", "juxt", "keep", "keep-indexed",
"key", "keys", "keyword", "keyword?", "last", "lazy-cat", "lazy-seq", "let", "letfn", "line-seq", "list", "list*",
"list?", "load", "load-file", "load-reader", "load-string", "loaded-libs", "locking", "long", "long-array", "longs",
"loop", "macroexpand", "macroexpand-1", "make-array", "make-hierarchy", "map", "map-entry?", "map-indexed", "map?",
"mapcat", "mapv", "max", "max-key", "memfn", "memoize", "merge", "merge-with", "meta", "method-sig", "methods"];
var coreSymbols2 = [
"min", "min-key", "mix-collection-hash", "mod", "munge", "name", "namespace", "namespace-munge", "nat-int?",
"neg-int?", "neg?", "newline", "next", "nfirst", "nil?", "nnext", "not", "not-any?", "not-empty", "not-every?",
"not=", "ns", "ns-aliases", "ns-imports", "ns-interns", "ns-map", "ns-name", "ns-publics", "ns-refers", "ns-resolve",
"ns-unalias", "ns-unmap", "nth", "nthnext", "nthrest", "num", "number?", "numerator", "object-array", "odd?", "or",
"parents", "partial", "partition", "partition-all", "partition-by", "pcalls", "peek", "persistent!", "pmap", "pop",
"pop!", "pop-thread-bindings", "pos-int?", "pos?", "pr", "pr-str", "prefer-method", "prefers",
"primitives-classnames", "print", "print-ctor", "print-dup", "print-method", "print-simple", "print-str", "printf",
"println", "println-str", "prn", "prn-str", "promise", "proxy", "proxy-call-with-super", "proxy-mappings",
"proxy-name", "proxy-super", "push-thread-bindings", "pvalues", "qualified-ident?", "qualified-keyword?",
"qualified-symbol?", "quot", "rand", "rand-int", "rand-nth", "random-sample", "range", "ratio?", "rational?",
"rationalize", "re-find", "re-groups", "re-matcher", "re-matches", "re-pattern", "re-seq", "read", "read-line",
"read-string", "reader-conditional", "reader-conditional?", "realized?", "record?", "reduce", "reduce-kv", "reduced",
"reduced?", "reductions", "ref", "ref-history-count", "ref-max-history", "ref-min-history", "ref-set", "refer",
"refer-clojure", "reify", "release-pending-sends", "rem", "remove", "remove-all-methods", "remove-method", "remove-ns",
"remove-watch", "repeat", "repeatedly", "replace", "replicate", "require", "reset!", "reset-meta!", "reset-vals!",
"resolve", "rest", "restart-agent", "resultset-seq", "reverse", "reversible?", "rseq", "rsubseq", "run!", "satisfies?",
"second", "select-keys", "send", "send-off", "send-via", "seq", "seq?", "seqable?", "seque", "sequence", "sequential?",
"set", "set-agent-send-executor!", "set-agent-send-off-executor!", "set-error-handler!", "set-error-mode!",
"set-validator!", "set?", "short", "short-array", "shorts", "shuffle", "shutdown-agents", "simple-ident?",
"simple-keyword?", "simple-symbol?", "slurp", "some", "some->", "some->>", "some-fn", "some?", "sort", "sort-by",
"sorted-map", "sorted-map-by", "sorted-set", "sorted-set-by", "sorted?", "special-symbol?", "spit", "split-at",
"split-with", "str", "string?", "struct", "struct-map", "subs", "subseq", "subvec", "supers", "swap!", "swap-vals!",
"symbol", "symbol?", "sync", "tagged-literal", "tagged-literal?", "take", "take-last", "take-nth", "take-while", "test",
"the-ns", "thread-bound?", "time", "to-array", "to-array-2d", "trampoline", "transduce", "transient", "tree-seq",
"true?", "type", "unchecked-add", "unchecked-add-int", "unchecked-byte", "unchecked-char", "unchecked-dec",
"unchecked-dec-int", "unchecked-divide-int", "unchecked-double", "unchecked-float", "unchecked-inc", "unchecked-inc-int",
"unchecked-int", "unchecked-long", "unchecked-multiply", "unchecked-multiply-int", "unchecked-negate",
"unchecked-negate-int", "unchecked-remainder-int", "unchecked-short", "unchecked-subtract", "unchecked-subtract-int",
"underive", "unquote", "unquote-splicing", "unreduced", "unsigned-bit-shift-right", "update", "update-in",
"update-proxy", "uri?", "use", "uuid?", "val", "vals", "var-get", "var-set", "var?", "vary-meta", "vec", "vector",
"vector-of", "vector?", "volatile!", "volatile?", "vreset!", "vswap!", "when", "when-first", "when-let", "when-not",
"when-some", "while", "with-bindings", "with-bindings*", "with-in-str", "with-loading-context", "with-local-vars",
"with-meta", "with-open", "with-out-str", "with-precision", "with-redefs", "with-redefs-fn", "xml-seq", "zero?",
"zipmap"
];
MT("should highlight core symbols as keywords (part 1/2)",
typeTokenPairs("keyword", coreSymbols1)
);
MT("should highlight core symbols as keywords (part 2/2)",
typeTokenPairs("keyword", coreSymbols2)
);
MT("should properly indent forms in list literals",
"[bracket (][builtin foo] [atom :a] [number 1] [atom true] [atom nil][bracket )]",
"",
"[bracket (][builtin foo] [atom :a]",
" [number 1]",
" [atom true]",
" [atom nil][bracket )]",
"",
"[bracket (][builtin foo] [atom :a] [number 1]",
" [atom true]",
" [atom nil][bracket )]",
"",
"[bracket (]",
" [builtin foo]",
" [atom :a]",
" [number 1]",
" [atom true]",
" [atom nil][bracket )]",
"",
"[bracket (][builtin foo] [bracket [[][atom :a][bracket ]]]",
" [number 1]",
" [atom true]",
" [atom nil][bracket )]"
);
MT("should properly indent forms in vector literals",
"[bracket [[][atom :a] [number 1] [atom true] [atom nil][bracket ]]]",
"",
"[bracket [[][atom :a]",
" [number 1]",
" [atom true]",
" [atom nil][bracket ]]]",
"",
"[bracket [[][atom :a] [number 1]",
" [atom true]",
" [atom nil][bracket ]]]",
"",
"[bracket [[]",
" [variable foo]",
" [atom :a]",
" [number 1]",
" [atom true]",
" [atom nil][bracket ]]]"
);
MT("should properly indent forms in map literals",
"[bracket {][atom :a] [atom :a] [atom :b] [number 1] [atom :c] [atom true] [atom :d] [atom nil] [bracket }]",
"",
"[bracket {][atom :a] [atom :a]",
" [atom :b] [number 1]",
" [atom :c] [atom true]",
" [atom :d] [atom nil][bracket }]",
"",
"[bracket {][atom :a]",
" [atom :a]",
" [atom :b]",
" [number 1]",
" [atom :c]",
" [atom true]",
" [atom :d]",
" [atom nil][bracket }]",
"",
"[bracket {]",
" [atom :a] [atom :a]",
" [atom :b] [number 1]",
" [atom :c] [atom true]",
" [atom :d] [atom nil][bracket }]"
);
MT("should properly indent forms in set literals",
"[meta #][bracket {][atom :a] [number 1] [atom true] [atom nil] [bracket }]",
"",
"[meta #][bracket {][atom :a]",
" [number 1]",
" [atom true]",
" [atom nil][bracket }]",
"",
"[meta #][bracket {]",
" [atom :a]",
" [number 1]",
" [atom true]",
" [atom nil][bracket }]"
);
var haveBodyParameter = [
"->", "->>", "as->", "binding", "bound-fn", "case", "catch", "cond",
"cond->", "cond->>", "condp", "def", "definterface", "defmethod", "defn",
"defmacro", "defprotocol", "defrecord", "defstruct", "deftype", "do",
"doseq", "dotimes", "doto", "extend", "extend-protocol", "extend-type",
"fn", "for", "future", "if", "if-let", "if-not", "if-some", "let",
"letfn", "locking", "loop", "ns", "proxy", "reify", "some->", "some->>",
"struct-map", "try", "when", "when-first", "when-let", "when-not",
"when-some", "while", "with-bindings", "with-bindings*", "with-in-str",
"with-loading-context", "with-local-vars", "with-meta", "with-open",
"with-out-str", "with-precision", "with-redefs", "with-redefs-fn"];
function testFormsThatHaveBodyParameter(forms) {
for (var i = 0; i < forms.length; i++) {
MT("should indent body argument of `" + forms[i] + "` by `options.indentUnit` spaces",
"[bracket (][keyword " + forms[i] + "] [variable foo] [variable bar]",
" [variable baz]",
" [variable qux][bracket )]"
);
}
}
testFormsThatHaveBodyParameter(haveBodyParameter);
MT("should indent body argument of `comment` by `options.indentUnit` spaces",
"[bracket (][comment comment foo bar]",
"[comment baz]",
"[comment qux][bracket )]"
);
function typeTokenPairs(type, tokens) {
return "[" + type + " " + tokens.join("] [" + type + " ") + "]";
}
})();

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") if (typeof exports == "object" && typeof module == "object")

View file

@ -13,7 +13,7 @@
.cm-s-default span.cm-arrow { color: red; } .cm-s-default span.cm-arrow { color: red; }
</style> </style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
/** /**
* Author: Gautam Mehta * Author: Gautam Mehta

View file

@ -39,7 +39,7 @@
.CodeMirror-activeline-background {background: #555555 !important;} .CodeMirror-activeline-background {background: #555555 !important;}
</style> </style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
/** /**
* Link to the project's GitHub page: * Link to the project's GitHub page:

View file

@ -9,7 +9,7 @@
<script src="coffeescript.js"></script> <script src="coffeescript.js"></script>
<style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style> <style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -9,7 +9,7 @@
<script src="commonlisp.js"></script> <script src="commonlisp.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style> <style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS

View file

@ -14,7 +14,7 @@
</style> </style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS
@ -63,7 +63,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
if (/[\d.]/.test(stream.peek())) { if (/[\d.]/.test(stream.peek())) {
stream.eatWhile(/[\w.%]/); stream.eatWhile(/[\w.%]/);
return ret("number", "unit"); return ret("number", "unit");
} else if (stream.match(/^-[\w\\\-]+/)) { } else if (stream.match(/^-[\w\\\-]*/)) {
stream.eatWhile(/[\w\\\-]/); stream.eatWhile(/[\w\\\-]/);
if (stream.match(/^\s*:/, false)) if (stream.match(/^\s*:/, false))
return ret("variable-2", "variable-definition"); return ret("variable-2", "variable-definition");
@ -501,7 +501,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"margin-bottom", "margin-left", "margin-right", "margin-top", "margin-bottom", "margin-left", "margin-right", "margin-top",
"marks", "marquee-direction", "marquee-loop", "marks", "marquee-direction", "marquee-loop",
"marquee-play-count", "marquee-speed", "marquee-style", "max-height", "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
"max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", "max-width", "min-height", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index",
"nav-left", "nav-right", "nav-up", "object-fit", "object-position", "nav-left", "nav-right", "nav-up", "object-fit", "object-position",
"opacity", "order", "orphans", "outline", "opacity", "order", "orphans", "outline",
"outline-color", "outline-offset", "outline-style", "outline-width", "outline-color", "outline-offset", "outline-style", "outline-width",

View file

@ -8,11 +8,12 @@
<link rel="stylesheet" href="../../addon/hint/show-hint.css"> <link rel="stylesheet" href="../../addon/hint/show-hint.css">
<script src="../../lib/codemirror.js"></script> <script src="../../lib/codemirror.js"></script>
<script src="css.js"></script> <script src="css.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="../../addon/hint/show-hint.js"></script> <script src="../../addon/hint/show-hint.js"></script>
<script src="../../addon/hint/css-hint.js"></script> <script src="../../addon/hint/css-hint.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style> <style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>
@ -90,7 +91,7 @@ body {
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
extraKeys: {"Ctrl-Space": "autocomplete"}, extraKeys: {"Ctrl-Space": "autocomplete"},
lineNumbers: true, lineNumbers: true,
matchBrackets: "text/x-less", matchBrackets: true,
mode: "text/x-gss" mode: "text/x-gss"
}); });
</script> </script>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function() { (function() {
"use strict"; "use strict";

View file

@ -12,7 +12,7 @@
<script src="../../addon/hint/css-hint.js"></script> <script src="../../addon/hint/css-hint.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style> <style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -10,7 +10,7 @@
<script src="css.js"></script> <script src="css.js"></script>
<style>.CodeMirror {border: 1px solid #ddd; line-height: 1.2;}</style> <style>.CodeMirror {border: 1px solid #ddd; line-height: 1.2;}</style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>
@ -140,8 +140,8 @@ fieldset span button, fieldset span input[type="file"] {
</textarea></form> </textarea></form>
<script> <script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers : true, lineNumbers: true,
matchBrackets : true, matchBrackets: true,
mode: "text/x-less" mode: "text/x-less"
}); });
</script> </script>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function() { (function() {
"use strict"; "use strict";

View file

@ -6,10 +6,11 @@
<link rel="stylesheet" href="../../lib/codemirror.css"> <link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script> <script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="css.js"></script> <script src="css.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style> <style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav> <div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul> <ul>
<li><a href="../../index.html">Home</a> <li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function() { (function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-scss"); var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-scss");

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
(function() { (function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "css"); var mode = CodeMirror.getMode({indentUnit: 2}, "css");
@ -149,6 +149,14 @@
" [property color]: [atom var]([variable-2 --main-color]);", " [property color]: [atom var]([variable-2 --main-color]);",
"}"); "}");
MT("blank_css_variable",
":[variable-3 root] {",
" [variable-2 --]: [atom #06c];",
"}",
"[tag h1][builtin #foo] {",
" [property color]: [atom var]([variable-2 --]);",
"}");
MT("supports", MT("supports",
"[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {", "[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];", " [property text-align-last]: [atom justify];",

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// By the Neo4j Team and contributors. // By the Neo4j Team and contributors.
// https://github.com/neo4j-contrib/CodeMirror // https://github.com/neo4j-contrib/CodeMirror

Some files were not shown because too many files have changed in this diff Show more