Merge remote-tracking branch 'remotes/origin/master'
This commit is contained in:
commit
067a1ee68b
60 changed files with 11531 additions and 2886 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,6 +2,7 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.swp
|
*.swp
|
||||||
*.tmp
|
*.tmp
|
||||||
|
*~
|
||||||
|
|
||||||
# Project files that should not be in the repo
|
# Project files that should not be in the repo
|
||||||
.*
|
.*
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ function demo() {
|
||||||
|
|
||||||
function changeComments(data) {
|
function changeComments(data) {
|
||||||
return (data
|
return (data
|
||||||
|
.replace("doc/site/images/ace-logo.png", "demo/kitchen-sink/ace-logo.png")
|
||||||
.replace(/<!\-\-DEVEL[\d\D]*?DEVEL\-\->/g, "")
|
.replace(/<!\-\-DEVEL[\d\D]*?DEVEL\-\->/g, "")
|
||||||
.replace(/PACKAGE\-\->|<!\-\-PACKAGE/g, "")
|
.replace(/PACKAGE\-\->|<!\-\-PACKAGE/g, "")
|
||||||
.replace(/\/\*DEVEL[\d\D]*?DEVEL\*\//g, "")
|
.replace(/\/\*DEVEL[\d\D]*?DEVEL\*\//g, "")
|
||||||
|
|
|
||||||
2
build
2
build
|
|
@ -1 +1 @@
|
||||||
Subproject commit 45d3068aa7190f08396bcfe134e505fe144c1ccb
|
Subproject commit a4e495d8901876c6bafe3870a35cb8e32c827e97
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
var dom = require("ace/lib/dom");
|
||||||
|
var Range = require("ace/range").Range;
|
||||||
// allow easy access to ace in console, but not in ace code which uses strict
|
// allow easy access to ace in console, but not in ace code which uses strict
|
||||||
function isStrict() {
|
function isStrict() {
|
||||||
try { return !arguments.callee.caller.caller.caller}
|
try { return !arguments.callee.caller.caller.caller}
|
||||||
|
|
@ -59,21 +61,155 @@ def(window, "session", function(){ warn(); return window.env.editor.session });
|
||||||
def(window, "split", function(){ warn(); return window.env.split });
|
def(window, "split", function(){ warn(); return window.env.split });
|
||||||
|
|
||||||
|
|
||||||
/* for textinput debuggging
|
def(window, "devUtil", function(){ warn(); return exports });
|
||||||
dom.importCssString("\
|
exports.showTextArea = function(argument) {
|
||||||
.ace_text-input {\
|
dom.importCssString("\
|
||||||
position: absolute;\
|
.ace_text-input {\
|
||||||
z-index: 10!important;\
|
position: absolute;\
|
||||||
width: 6em!important;\
|
z-index: 10!important;\
|
||||||
height: 1em;\
|
width: 6em!important;\
|
||||||
opacity: 1!important;\
|
height: 1em;\
|
||||||
background: rgba(0, 92, 255, 0.11);\
|
opacity: 1!important;\
|
||||||
border: none;\
|
background: rgba(0, 92, 255, 0.11);\
|
||||||
font: inherit;\
|
border: none;\
|
||||||
padding: 0 1px;\
|
font: inherit;\
|
||||||
margin: 0 -1px;\
|
padding: 0 1px;\
|
||||||
text-indent: 0em;\
|
margin: 0 -1px;\
|
||||||
}\
|
text-indent: 0em;\
|
||||||
")*/
|
}\
|
||||||
|
");
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.addGlobals = function() {
|
||||||
|
window.oop = require("ace/lib/oop");
|
||||||
|
window.dom = require("ace/lib/dom");
|
||||||
|
window.Range = require("ace/range").Range;
|
||||||
|
window.Editor = require("ace/editor").Editor;
|
||||||
|
window.assert = require("ace/test/asyncjs/assert");
|
||||||
|
window.asyncjs = require("ace/test/asyncjs/async");
|
||||||
|
window.UndoManager = require("ace/undomanager").UndoManager;
|
||||||
|
window.EditSession = require("ace/edit_session").EditSession;
|
||||||
|
window.MockRenderer = require("ace/test/mockrenderer").MockRenderer;
|
||||||
|
window.EventEmitter = require("ace/lib/event_emitter").EventEmitter;
|
||||||
|
|
||||||
|
window.getSelection = getSelection;
|
||||||
|
window.setSelection = setSelection;
|
||||||
|
window.testSelection = testSelection;
|
||||||
|
};
|
||||||
|
|
||||||
|
function getSelection(editor) {
|
||||||
|
var data = editor.multiSelect.toJSON();
|
||||||
|
if (!data.length) data = [data];
|
||||||
|
data = data.map(function(x) {
|
||||||
|
var a, c;
|
||||||
|
if (x.isBackwards) {
|
||||||
|
a = x.end;
|
||||||
|
c = x.start;
|
||||||
|
} else {
|
||||||
|
c = x.end;
|
||||||
|
a = x.start;
|
||||||
|
}
|
||||||
|
return Range.comparePoints(a, c)
|
||||||
|
? [a.row, a.column, c.row, c.column]
|
||||||
|
: [a.row, a.column];
|
||||||
|
});
|
||||||
|
return data.length > 1 ? data : data[0];
|
||||||
|
}
|
||||||
|
function setSelection(editor, data) {
|
||||||
|
if (typeof data[0] == "number")
|
||||||
|
data = [data];
|
||||||
|
editor.selection.fromJSON(data.map(function(x) {
|
||||||
|
var start = {row: x[0], column: x[1]};
|
||||||
|
var end = x.length == 2 ? start : {row: x[2], column: x[3]};
|
||||||
|
var isBackwards = Range.comparePoints(start, end) > 0;
|
||||||
|
return isBackwards ? {
|
||||||
|
start: end,
|
||||||
|
end: start,
|
||||||
|
isBackwards: true
|
||||||
|
} : {
|
||||||
|
start: start,
|
||||||
|
end: end,
|
||||||
|
isBackwards: true
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
function testSelection(editor, data) {
|
||||||
|
assert.equal(getSelection(editor) + "", data + "");
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.recordTestCase = function() {
|
||||||
|
exports.addGlobals();
|
||||||
|
var editor = window.editor;
|
||||||
|
var testcase = window.testcase = [];
|
||||||
|
var assert;
|
||||||
|
|
||||||
|
testcase.push({
|
||||||
|
type: "setValue",
|
||||||
|
data: editor.getValue()
|
||||||
|
}, {
|
||||||
|
type: "setSelection",
|
||||||
|
data: getSelection(editor)
|
||||||
|
});
|
||||||
|
editor.commands.on("afterExec", function(e) {
|
||||||
|
testcase.push({
|
||||||
|
type: "exec",
|
||||||
|
data: e
|
||||||
|
});
|
||||||
|
testcase.push({
|
||||||
|
type: "value",
|
||||||
|
data: editor.getValue()
|
||||||
|
});
|
||||||
|
testcase.push({
|
||||||
|
type: "selection",
|
||||||
|
data: getSelection(editor)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
editor.on("mouseup", function() {
|
||||||
|
testcase.push({
|
||||||
|
type: "setSelection",
|
||||||
|
data: getSelection(editor)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testcase.toString = function() {
|
||||||
|
var lastValue = "";
|
||||||
|
// var lastSelection = ""
|
||||||
|
var str = this.map(function(x) {
|
||||||
|
var data = x.data;
|
||||||
|
switch (x.type) {
|
||||||
|
case "exec":
|
||||||
|
return 'editor.execCommand("'
|
||||||
|
+ data.command.name
|
||||||
|
+ (data.args ? '", ' + JSON.stringify(data.args) : '"')
|
||||||
|
+ ')';
|
||||||
|
case "setSelection":
|
||||||
|
return 'setSelection(editor, ' + JSON.stringify(data) + ')';
|
||||||
|
case "setValue":
|
||||||
|
if (lastValue != data) {
|
||||||
|
lastValue = data;
|
||||||
|
return 'editor.setValue(' + JSON.stringify(data) + ', -1)';
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case "selection":
|
||||||
|
return 'testSelection(editor, ' + JSON.stringify(data) + ')';
|
||||||
|
case "value":
|
||||||
|
if (lastValue != data) {
|
||||||
|
lastValue = data;
|
||||||
|
return 'assert.equal('
|
||||||
|
+ 'editor.getValue(),'
|
||||||
|
+ JSON.stringify(data)
|
||||||
|
+ ')';
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}).filter(Boolean).join("\n");
|
||||||
|
|
||||||
|
return getSelection + "\n"
|
||||||
|
+ testSelection + "\n"
|
||||||
|
+ setSelection + "\n"
|
||||||
|
+ "\n" + str + "\n";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,12 @@ var ownSource = {
|
||||||
/* filled from require*/
|
/* filled from require*/
|
||||||
};
|
};
|
||||||
|
|
||||||
var hugeDocs = {
|
var hugeDocs = require.toUrl ? {
|
||||||
"build/src/ace.js": "",
|
"build/src/ace.js": "",
|
||||||
"build/src-min/ace.js": ""
|
"build/src-min/ace.js": ""
|
||||||
|
} : {
|
||||||
|
"src/ace.js": "",
|
||||||
|
"src-min/ace.js": ""
|
||||||
};
|
};
|
||||||
|
|
||||||
modelist.modes.forEach(function(m) {
|
modelist.modes.forEach(function(m) {
|
||||||
|
|
|
||||||
52
demo/kitchen-sink/docs/mask.mask
Normal file
52
demo/kitchen-sink/docs/mask.mask
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
/* Mask Syntax Demo */
|
||||||
|
|
||||||
|
div > ' Test ~[name]';
|
||||||
|
|
||||||
|
define :userProfile {
|
||||||
|
header {
|
||||||
|
h4 > @title;
|
||||||
|
button.close;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:userProfile {
|
||||||
|
@title > ' Hello ~[: username.toUpperCase()]'
|
||||||
|
}
|
||||||
|
|
||||||
|
style {
|
||||||
|
html, body {
|
||||||
|
background: url('name.png') 0 0 no-repeat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
event click (e) {
|
||||||
|
this.textContent = `name ${e.clientX} !`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
md > """
|
||||||
|
|
||||||
|
- div
|
||||||
|
- span
|
||||||
|
|
||||||
|
Hello
|
||||||
|
|
||||||
|
[one](http://google.com)
|
||||||
|
|
||||||
|
""";
|
||||||
|
|
||||||
|
|
||||||
|
header .foo > 'Heading'
|
||||||
|
|
||||||
|
button .baz x-signal='click: test' disabled > "
|
||||||
|
Hello,
|
||||||
|
world
|
||||||
|
\"Buddy\"
|
||||||
|
"
|
||||||
|
|
||||||
|
var a = {
|
||||||
|
name: `name ${window.innerWidth}`
|
||||||
|
};
|
||||||
|
|
||||||
|
span .foo > "~[bind: a.name]"
|
||||||
47
index.html
47
index.html
|
|
@ -795,9 +795,9 @@ if (match) {
|
||||||
<a href="http://plnkr.co/edit/">Plunker</a>
|
<a href="http://plnkr.co/edit/">Plunker</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<img src="doc/site/images/ac-logo.png"
|
<img src="https://raw.githubusercontent.com/dart-lang/chromedeveditor/master/ide/web/images/icon_128.png"
|
||||||
style="left: 4px; top: 25px;" />
|
style="left: 0px;top: -15px;width: 100px;" />
|
||||||
<a href="http://www.applicationcraft.com/">Application Craft</a>
|
<a href="https://github.com/dart-lang/chromedeveditor">Chrome Dev Editor</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<img src="doc/site/images/sassmeister-logo.png"
|
<img src="doc/site/images/sassmeister-logo.png"
|
||||||
|
|
@ -838,7 +838,7 @@ if (match) {
|
||||||
<a href="http://habitat.inkling.com">Inkling Habitat</a>
|
<a href="http://habitat.inkling.com">Inkling Habitat</a>
|
||||||
</li>
|
</li>
|
||||||
<li style="width: 248px;">
|
<li style="width: 248px;">
|
||||||
<img src="http://codecombat.com/images/pages/base/logo.png" style="left: 48px; top: 10px;">
|
<img src="http://codecombat.com/images/pages/base/logo.png" style="left: 0px; top: 1px; width: 248px">
|
||||||
<a href="http://codecombat.com">Code Combat</a>
|
<a href="http://codecombat.com">Code Combat</a>
|
||||||
</li>
|
</li>
|
||||||
<!--seems to be down <li>
|
<!--seems to be down <li>
|
||||||
|
|
@ -969,6 +969,11 @@ if (match) {
|
||||||
<div class="text-logo" style="margin-left:-17px;font-family:'Henny Penny',cursive;">ChocolateJs</div>
|
<div class="text-logo" style="margin-left:-17px;font-family:'Henny Penny',cursive;">ChocolateJs</div>
|
||||||
<a href="https://chocolatejs.org">Chocolatejs</a>
|
<a href="https://chocolatejs.org">Chocolatejs</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<img src="doc/site/images/ac-logo.png"
|
||||||
|
style="left: 4px; top: 25px;" />
|
||||||
|
<a href="http://www.applicationcraft.com/">Application Craft</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<img src="http://playir.com/common/icon_playir.png"
|
<img src="http://playir.com/common/icon_playir.png"
|
||||||
style="left: 11px; width: 96px;top: -17px;">
|
style="left: 11px; width: 96px;top: -17px;">
|
||||||
|
|
@ -978,10 +983,6 @@ if (match) {
|
||||||
<div class="text-logo" style="font-size: 23px;">Runnable</div>
|
<div class="text-logo" style="font-size: 23px;">Runnable</div>
|
||||||
<a href="http://runnable.com">Runnable</a>
|
<a href="http://runnable.com">Runnable</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<div class="text-logo" style="font-size: 22px;margin-left: -5px;">DocsCamp</div>
|
|
||||||
<a href="http://docscamp.com/">DocsCamp</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<img src="http://joshnuss.github.io/mruby-web-irb/images/favicon.png"
|
<img src="http://joshnuss.github.io/mruby-web-irb/images/favicon.png"
|
||||||
style="left: 4px; width: 90px;top: -17px;">
|
style="left: 4px; width: 90px;top: -17px;">
|
||||||
|
|
@ -1025,7 +1026,7 @@ if (match) {
|
||||||
<a href="http://iknode.com/">iKnode</a>
|
<a href="http://iknode.com/">iKnode</a>
|
||||||
</li>
|
</li>
|
||||||
<li title="Online conference and code review tool">
|
<li title="Online conference and code review tool">
|
||||||
<div style="width: 90px; left: 5px; top: 0px;background:rgb(24,73,92);color: white;position: absolute;
|
<div style="width: 90px; left: 10px; top: 0px;background:rgb(24,73,92);color: white;position: absolute;
|
||||||
font-size: 68px;text-align: center;font-weight: bold;font-family: inherit;line-height: normal;">sT</div>
|
font-size: 68px;text-align: center;font-weight: bold;font-family: inherit;line-height: normal;">sT</div>
|
||||||
<a href="http://sourcetalk.net/">SourceTalk</a>
|
<a href="http://sourcetalk.net/">SourceTalk</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
@ -1257,14 +1258,30 @@ if (match) {
|
||||||
background-position: 19px;"></div>
|
background-position: 19px;"></div>
|
||||||
<a href="http://apiary.io/">Apiary</a>
|
<a href="http://apiary.io/">Apiary</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<img src="https://dirigible.hana.ondemand.com/dirigible/web/welcome/img/logo/dirigible-logo.png" style="width: 80px; left: 10px; top: 10px;">
|
|
||||||
<a href="https://dirigible.io/">Dirigible</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<img src="http://exist-db.org/exist/apps/eXide/resources/images/logo.png" style="width: 120px; left: -10px; top: 15px;">
|
<img src="http://exist-db.org/exist/apps/eXide/resources/images/logo.png" style="width: 120px; left: -10px; top: 15px;">
|
||||||
<a href="http://exist-db.org">ExistDB</a>
|
<a href="http://exist-db.org">ExistDB</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<img src="https://jscalc.io/img/icons/jscalc_full_bleed_24.svg" style="width: 90px; left: 5px; top: -10px;">
|
||||||
|
<a href="https://jscalc.io/">JSCalc</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<img src="http://tworld-ai.com/imgs/web-app/rob_face.png" style="width: 90px; left: 5px; top: -10px;">
|
||||||
|
<a href="http://tworld-ai.com/imgs/web-app/rob_face.png">T-World</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<img src="https://www.gestixi.com/assets/img/icons/gestixi-64.png" style="width: 90px; left: 5px; top: 20px;">
|
||||||
|
<a href="https://www.gestixi.com/">GestiXi</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<div class="text-logo">Clicpilot</div>
|
||||||
|
<a href="http://www.clicpilot.com/">clicpilot</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<div class="text-logo" style="font-size:22px;text-shadow:none;margin-top:13px">Code-Fight.Club</div>
|
||||||
|
<a href="http://code-fight.club">Code-Fight.Club</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="https://cloud.formcycle.de/formcycle/fd2/">Formcycle</a>
|
<a href="https://cloud.formcycle.de/formcycle/fd2/">Formcycle</a>
|
||||||
|
|
@ -1325,8 +1342,8 @@ if (match) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
||||||
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>
|
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>
|
||||||
<script src="./doc/template/resources/javascripts/bbq.js"></script>
|
<script src="./doc/template/resources/javascripts/bbq.js"></script>
|
||||||
<script src="./api/resources/javascripts/ux.js"></script>
|
<script src="./api/resources/javascripts/ux.js"></script>
|
||||||
<script src="./doc/site/js/main.js"></script>
|
<script src="./doc/site/js/main.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,9 @@
|
||||||
<a href="http://ace.c9.io">
|
<a href="http://ace.c9.io">
|
||||||
<img id="ace-logo" src="doc/site/images/ace-logo.png" style="width: 134px;margin: 46px 0px 4px 66px;">
|
<img id="ace-logo" src="doc/site/images/ace-logo.png" style="width: 134px;margin: 46px 0px 4px 66px;">
|
||||||
</a>
|
</a>
|
||||||
|
<div><a target="_test" href="./lib/ace/test/tests.html"
|
||||||
|
style="color: whitesmoke; text-align: left; padding: 1em;">tests</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ var snippetManager = require("./snippets").snippetManager;
|
||||||
var Autocomplete = function() {
|
var Autocomplete = function() {
|
||||||
this.autoInsert = true;
|
this.autoInsert = true;
|
||||||
this.autoSelect = true;
|
this.autoSelect = true;
|
||||||
|
this.exactMatch = false;
|
||||||
this.keyboardHandler = new HashHandler();
|
this.keyboardHandler = new HashHandler();
|
||||||
this.keyboardHandler.bindKeys(this.commands);
|
this.keyboardHandler.bindKeys(this.commands);
|
||||||
|
|
||||||
|
|
@ -306,6 +307,10 @@ var Autocomplete = function() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.completions = new FilteredList(matches);
|
this.completions = new FilteredList(matches);
|
||||||
|
|
||||||
|
if (this.exactMatch)
|
||||||
|
this.completions.exactMatch = true;
|
||||||
|
|
||||||
this.completions.setFilter(prefix);
|
this.completions.setFilter(prefix);
|
||||||
var filtered = this.completions.filtered;
|
var filtered = this.completions.filtered;
|
||||||
|
|
||||||
|
|
@ -416,6 +421,7 @@ var FilteredList = function(array, filterText, mutateData) {
|
||||||
this.all = array;
|
this.all = array;
|
||||||
this.filtered = array;
|
this.filtered = array;
|
||||||
this.filterText = filterText || "";
|
this.filterText = filterText || "";
|
||||||
|
this.exactMatch = false;
|
||||||
};
|
};
|
||||||
(function(){
|
(function(){
|
||||||
this.setFilter = function(str) {
|
this.setFilter = function(str) {
|
||||||
|
|
@ -452,23 +458,29 @@ var FilteredList = function(array, filterText, mutateData) {
|
||||||
var matchMask = 0;
|
var matchMask = 0;
|
||||||
var penalty = 0;
|
var penalty = 0;
|
||||||
var index, distance;
|
var index, distance;
|
||||||
// caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf
|
|
||||||
for (var j = 0; j < needle.length; j++) {
|
if (this.exactMatch) {
|
||||||
// TODO add penalty on case mismatch
|
if (needle !== caption.substr(0, needle.length))
|
||||||
var i1 = caption.indexOf(lower[j], lastIndex + 1);
|
|
||||||
var i2 = caption.indexOf(upper[j], lastIndex + 1);
|
|
||||||
index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
|
|
||||||
if (index < 0)
|
|
||||||
continue loop;
|
continue loop;
|
||||||
distance = index - lastIndex - 1;
|
}else{
|
||||||
if (distance > 0) {
|
// caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf
|
||||||
// first char mismatch should be more sensitive
|
for (var j = 0; j < needle.length; j++) {
|
||||||
if (lastIndex === -1)
|
// TODO add penalty on case mismatch
|
||||||
penalty += 10;
|
var i1 = caption.indexOf(lower[j], lastIndex + 1);
|
||||||
penalty += distance;
|
var i2 = caption.indexOf(upper[j], lastIndex + 1);
|
||||||
|
index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
|
||||||
|
if (index < 0)
|
||||||
|
continue loop;
|
||||||
|
distance = index - lastIndex - 1;
|
||||||
|
if (distance > 0) {
|
||||||
|
// first char mismatch should be more sensitive
|
||||||
|
if (lastIndex === -1)
|
||||||
|
penalty += 10;
|
||||||
|
penalty += distance;
|
||||||
|
}
|
||||||
|
matchMask = matchMask | (1 << index);
|
||||||
|
lastIndex = index;
|
||||||
}
|
}
|
||||||
matchMask = matchMask | (1 << index);
|
|
||||||
lastIndex = index;
|
|
||||||
}
|
}
|
||||||
item.matchMask = matchMask;
|
item.matchMask = matchMask;
|
||||||
item.exactMatch = penalty ? 0 : 1;
|
item.exactMatch = penalty ? 0 : 1;
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,8 @@ var AcePopup = function(parentNode) {
|
||||||
return this.screenWidth = 0;
|
return this.screenWidth = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
popup.$blockScrolling = Infinity;
|
||||||
|
|
||||||
// public
|
// public
|
||||||
popup.isOpen = false;
|
popup.isOpen = false;
|
||||||
popup.isTopdown = false;
|
popup.isTopdown = false;
|
||||||
|
|
@ -241,6 +243,7 @@ var AcePopup = function(parentNode) {
|
||||||
popup.on("changeSelection", function() {
|
popup.on("changeSelection", function() {
|
||||||
if (popup.isOpen)
|
if (popup.isOpen)
|
||||||
popup.setRow(popup.selection.lead.row);
|
popup.setRow(popup.selection.lead.row);
|
||||||
|
popup.renderer.scrollCursorIntoView();
|
||||||
});
|
});
|
||||||
|
|
||||||
popup.hide = function() {
|
popup.hide = function() {
|
||||||
|
|
|
||||||
|
|
@ -205,12 +205,14 @@ exports.commands = [{
|
||||||
bindKey: bindKey("Shift-Up", "Shift-Up"),
|
bindKey: bindKey("Shift-Up", "Shift-Up"),
|
||||||
exec: function(editor) { editor.getSelection().selectUp(); },
|
exec: function(editor) { editor.getSelection().selectUp(); },
|
||||||
multiSelectAction: "forEach",
|
multiSelectAction: "forEach",
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readOnly: true
|
readOnly: true
|
||||||
}, {
|
}, {
|
||||||
name: "golineup",
|
name: "golineup",
|
||||||
bindKey: bindKey("Up", "Up|Ctrl-P"),
|
bindKey: bindKey("Up", "Up|Ctrl-P"),
|
||||||
exec: function(editor, args) { editor.navigateUp(args.times); },
|
exec: function(editor, args) { editor.navigateUp(args.times); },
|
||||||
multiSelectAction: "forEach",
|
multiSelectAction: "forEach",
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readOnly: true
|
readOnly: true
|
||||||
}, {
|
}, {
|
||||||
name: "selecttoend",
|
name: "selecttoend",
|
||||||
|
|
@ -395,12 +397,21 @@ exports.commands = [{
|
||||||
bindKey: bindKey("Ctrl-P", "Ctrl-P"),
|
bindKey: bindKey("Ctrl-P", "Ctrl-P"),
|
||||||
exec: function(editor) { editor.jumpToMatching(); },
|
exec: function(editor) { editor.jumpToMatching(); },
|
||||||
multiSelectAction: "forEach",
|
multiSelectAction: "forEach",
|
||||||
|
scrollIntoView: "animate",
|
||||||
readOnly: true
|
readOnly: true
|
||||||
}, {
|
}, {
|
||||||
name: "selecttomatching",
|
name: "selecttomatching",
|
||||||
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
|
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
|
||||||
exec: function(editor) { editor.jumpToMatching(true); },
|
exec: function(editor) { editor.jumpToMatching(true); },
|
||||||
multiSelectAction: "forEach",
|
multiSelectAction: "forEach",
|
||||||
|
scrollIntoView: "animate",
|
||||||
|
readOnly: true
|
||||||
|
}, {
|
||||||
|
name: "expandToMatching",
|
||||||
|
bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
|
||||||
|
exec: function(editor) { editor.jumpToMatching(true, true); },
|
||||||
|
multiSelectAction: "forEach",
|
||||||
|
scrollIntoView: "animate",
|
||||||
readOnly: true
|
readOnly: true
|
||||||
}, {
|
}, {
|
||||||
name: "passKeysToBrowser",
|
name: "passKeysToBrowser",
|
||||||
|
|
@ -458,11 +469,13 @@ exports.commands = [{
|
||||||
name: "modifyNumberUp",
|
name: "modifyNumberUp",
|
||||||
bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
|
bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
|
||||||
exec: function(editor) { editor.modifyNumber(1); },
|
exec: function(editor) { editor.modifyNumber(1); },
|
||||||
|
scrollIntoView: "cursor",
|
||||||
multiSelectAction: "forEach"
|
multiSelectAction: "forEach"
|
||||||
}, {
|
}, {
|
||||||
name: "modifyNumberDown",
|
name: "modifyNumberDown",
|
||||||
bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
|
bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
|
||||||
exec: function(editor) { editor.modifyNumber(-1); },
|
exec: function(editor) { editor.modifyNumber(-1); },
|
||||||
|
scrollIntoView: "cursor",
|
||||||
multiSelectAction: "forEach"
|
multiSelectAction: "forEach"
|
||||||
}, {
|
}, {
|
||||||
name: "replace",
|
name: "replace",
|
||||||
|
|
@ -629,7 +642,7 @@ exports.commands = [{
|
||||||
var isBackwards = editor.selection.isBackwards();
|
var isBackwards = editor.selection.isBackwards();
|
||||||
var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
|
var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
|
||||||
var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
|
var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
|
||||||
var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length
|
var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
|
||||||
var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
|
var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
|
||||||
var selectedCount = selectedText.replace(/\n\s*/, " ").length;
|
var selectedCount = selectedText.replace(/\n\s*/, " ").length;
|
||||||
var insertLine = editor.session.doc.getLine(selectionStart.row);
|
var insertLine = editor.session.doc.getLine(selectionStart.row);
|
||||||
|
|
@ -640,7 +653,7 @@ exports.commands = [{
|
||||||
curLine = " " + curLine;
|
curLine = " " + curLine;
|
||||||
}
|
}
|
||||||
insertLine += curLine;
|
insertLine += curLine;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
|
if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
|
||||||
// Don't insert a newline at the end of the document
|
// Don't insert a newline at the end of the document
|
||||||
|
|
|
||||||
|
|
@ -35,41 +35,49 @@ exports.defaultCommands = [{
|
||||||
name: "addCursorAbove",
|
name: "addCursorAbove",
|
||||||
exec: function(editor) { editor.selectMoreLines(-1); },
|
exec: function(editor) { editor.selectMoreLines(-1); },
|
||||||
bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
|
bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readonly: true
|
readonly: true
|
||||||
}, {
|
}, {
|
||||||
name: "addCursorBelow",
|
name: "addCursorBelow",
|
||||||
exec: function(editor) { editor.selectMoreLines(1); },
|
exec: function(editor) { editor.selectMoreLines(1); },
|
||||||
bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
|
bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readonly: true
|
readonly: true
|
||||||
}, {
|
}, {
|
||||||
name: "addCursorAboveSkipCurrent",
|
name: "addCursorAboveSkipCurrent",
|
||||||
exec: function(editor) { editor.selectMoreLines(-1, true); },
|
exec: function(editor) { editor.selectMoreLines(-1, true); },
|
||||||
bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
|
bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readonly: true
|
readonly: true
|
||||||
}, {
|
}, {
|
||||||
name: "addCursorBelowSkipCurrent",
|
name: "addCursorBelowSkipCurrent",
|
||||||
exec: function(editor) { editor.selectMoreLines(1, true); },
|
exec: function(editor) { editor.selectMoreLines(1, true); },
|
||||||
bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
|
bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readonly: true
|
readonly: true
|
||||||
}, {
|
}, {
|
||||||
name: "selectMoreBefore",
|
name: "selectMoreBefore",
|
||||||
exec: function(editor) { editor.selectMore(-1); },
|
exec: function(editor) { editor.selectMore(-1); },
|
||||||
bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
|
bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readonly: true
|
readonly: true
|
||||||
}, {
|
}, {
|
||||||
name: "selectMoreAfter",
|
name: "selectMoreAfter",
|
||||||
exec: function(editor) { editor.selectMore(1); },
|
exec: function(editor) { editor.selectMore(1); },
|
||||||
bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
|
bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readonly: true
|
readonly: true
|
||||||
}, {
|
}, {
|
||||||
name: "selectNextBefore",
|
name: "selectNextBefore",
|
||||||
exec: function(editor) { editor.selectMore(-1, true); },
|
exec: function(editor) { editor.selectMore(-1, true); },
|
||||||
bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
|
bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readonly: true
|
readonly: true
|
||||||
}, {
|
}, {
|
||||||
name: "selectNextAfter",
|
name: "selectNextAfter",
|
||||||
exec: function(editor) { editor.selectMore(1, true); },
|
exec: function(editor) { editor.selectMore(1, true); },
|
||||||
bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
|
bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readonly: true
|
readonly: true
|
||||||
}, {
|
}, {
|
||||||
name: "splitIntoLines",
|
name: "splitIntoLines",
|
||||||
|
|
@ -79,11 +87,13 @@ exports.defaultCommands = [{
|
||||||
}, {
|
}, {
|
||||||
name: "alignCursors",
|
name: "alignCursors",
|
||||||
exec: function(editor) { editor.alignCursors(); },
|
exec: function(editor) { editor.alignCursors(); },
|
||||||
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"}
|
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
|
||||||
|
scrollIntoView: "cursor"
|
||||||
}, {
|
}, {
|
||||||
name: "findAll",
|
name: "findAll",
|
||||||
exec: function(editor) { editor.findAll(); },
|
exec: function(editor) { editor.findAll(); },
|
||||||
bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
|
bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readonly: true
|
readonly: true
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
@ -92,6 +102,7 @@ exports.multiSelectCommands = [{
|
||||||
name: "singleSelection",
|
name: "singleSelection",
|
||||||
bindKey: "esc",
|
bindKey: "esc",
|
||||||
exec: function(editor) { editor.exitMultiSelectMode(); },
|
exec: function(editor) { editor.exitMultiSelectMode(); },
|
||||||
|
scrollIntoView: "cursor",
|
||||||
readonly: true,
|
readonly: true,
|
||||||
isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
|
isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
|
||||||
}];
|
}];
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,9 @@ define(function(require, exports, module) {
|
||||||
var lang = require("./lib/lang");
|
var lang = require("./lib/lang");
|
||||||
var oop = require("./lib/oop");
|
var oop = require("./lib/oop");
|
||||||
var net = require("./lib/net");
|
var net = require("./lib/net");
|
||||||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
var AppConfig = require("./lib/app_config").AppConfig;
|
||||||
|
|
||||||
|
module.exports = exports = new AppConfig();
|
||||||
|
|
||||||
var global = (function() {
|
var global = (function() {
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -69,8 +71,6 @@ exports.all = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// module loading
|
// module loading
|
||||||
oop.implement(exports, EventEmitter);
|
|
||||||
|
|
||||||
exports.moduleUrl = function(name, component) {
|
exports.moduleUrl = function(name, component) {
|
||||||
if (options.$moduleUrls[name])
|
if (options.$moduleUrls[name])
|
||||||
return options.$moduleUrls[name];
|
return options.$moduleUrls[name];
|
||||||
|
|
@ -142,7 +142,6 @@ exports.loadModule = function(moduleName, onLoad) {
|
||||||
net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
|
net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// initialization
|
// initialization
|
||||||
function init(packaged) {
|
function init(packaged) {
|
||||||
options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
|
options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
|
||||||
|
|
@ -200,102 +199,4 @@ function deHyphenate(str) {
|
||||||
return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
|
return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
var optionsProvider = {
|
|
||||||
setOptions: function(optList) {
|
|
||||||
Object.keys(optList).forEach(function(key) {
|
|
||||||
this.setOption(key, optList[key]);
|
|
||||||
}, this);
|
|
||||||
},
|
|
||||||
getOptions: function(optionNames) {
|
|
||||||
var result = {};
|
|
||||||
if (!optionNames) {
|
|
||||||
optionNames = Object.keys(this.$options);
|
|
||||||
} else if (!Array.isArray(optionNames)) {
|
|
||||||
result = optionNames;
|
|
||||||
optionNames = Object.keys(result);
|
|
||||||
}
|
|
||||||
optionNames.forEach(function(key) {
|
|
||||||
result[key] = this.getOption(key);
|
|
||||||
}, this);
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
setOption: function(name, value) {
|
|
||||||
if (this["$" + name] === value)
|
|
||||||
return;
|
|
||||||
var opt = this.$options[name];
|
|
||||||
if (!opt) {
|
|
||||||
if (typeof console != "undefined" && console.warn)
|
|
||||||
console.warn('misspelled option "' + name + '"');
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (opt.forwardTo)
|
|
||||||
return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
|
|
||||||
|
|
||||||
if (!opt.handlesSet)
|
|
||||||
this["$" + name] = value;
|
|
||||||
if (opt && opt.set)
|
|
||||||
opt.set.call(this, value);
|
|
||||||
},
|
|
||||||
getOption: function(name) {
|
|
||||||
var opt = this.$options[name];
|
|
||||||
if (!opt) {
|
|
||||||
if (typeof console != "undefined" && console.warn)
|
|
||||||
console.warn('misspelled option "' + name + '"');
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (opt.forwardTo)
|
|
||||||
return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
|
|
||||||
return opt && opt.get ? opt.get.call(this) : this["$" + name];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var defaultOptions = {};
|
|
||||||
/*
|
|
||||||
* option {name, value, initialValue, setterName, set, get }
|
|
||||||
*/
|
|
||||||
exports.defineOptions = function(obj, path, options) {
|
|
||||||
if (!obj.$options)
|
|
||||||
defaultOptions[path] = obj.$options = {};
|
|
||||||
|
|
||||||
Object.keys(options).forEach(function(key) {
|
|
||||||
var opt = options[key];
|
|
||||||
if (typeof opt == "string")
|
|
||||||
opt = {forwardTo: opt};
|
|
||||||
|
|
||||||
opt.name || (opt.name = key);
|
|
||||||
obj.$options[opt.name] = opt;
|
|
||||||
if ("initialValue" in opt)
|
|
||||||
obj["$" + opt.name] = opt.initialValue;
|
|
||||||
});
|
|
||||||
|
|
||||||
// implement option provider interface
|
|
||||||
oop.implement(obj, optionsProvider);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.resetOptions = function(obj) {
|
|
||||||
Object.keys(obj.$options).forEach(function(key) {
|
|
||||||
var opt = obj.$options[key];
|
|
||||||
if ("value" in opt)
|
|
||||||
obj.setOption(key, opt.value);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.setDefaultValue = function(path, name, value) {
|
|
||||||
var opts = defaultOptions[path] || (defaultOptions[path] = {});
|
|
||||||
if (opts[name]) {
|
|
||||||
if (opts.forwardTo)
|
|
||||||
exports.setDefaultValue(opts.forwardTo, name, value);
|
|
||||||
else
|
|
||||||
opts[name].value = value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.setDefaultValues = function(path, optionHash) {
|
|
||||||
Object.keys(optionHash).forEach(function(key) {
|
|
||||||
exports.setDefaultValue(path, key, optionHash[key]);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -118,11 +118,18 @@ module.exports = {
|
||||||
o.setOption("initialValue", 7);
|
o.setOption("initialValue", 7);
|
||||||
assert.equal(o.getOption("opt2"), 7);
|
assert.equal(o.getOption("opt2"), 7);
|
||||||
|
|
||||||
|
config.setDefaultValues("test_object", {
|
||||||
|
opt1: 1,
|
||||||
|
forwarded: 2
|
||||||
|
});
|
||||||
|
config.resetOptions(o);
|
||||||
|
assert.equal(o.getOption("opt1"), 1);
|
||||||
|
assert.equal(o.getOption("forwarded"), 2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs").test.testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -968,10 +968,7 @@ var EditSession = function(text, mode) {
|
||||||
try {
|
try {
|
||||||
this.$worker = this.$mode.createWorker(this);
|
this.$worker = this.$mode.createWorker(this);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (typeof console == "object") {
|
config.warn("Could not load worker", e);
|
||||||
console.log("Could not load worker");
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
this.$worker = null;
|
this.$worker = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -696,7 +696,8 @@ function Folding() {
|
||||||
|
|
||||||
this.$foldMode = foldMode;
|
this.$foldMode = foldMode;
|
||||||
|
|
||||||
this.removeListener('change', this.$updateFoldWidgets);
|
this.off('change', this.$updateFoldWidgets);
|
||||||
|
this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
|
||||||
this._emit("changeAnnotation");
|
this._emit("changeAnnotation");
|
||||||
|
|
||||||
if (!foldMode || this.$foldStyle == "manual") {
|
if (!foldMode || this.$foldStyle == "manual") {
|
||||||
|
|
@ -709,8 +710,9 @@ function Folding() {
|
||||||
this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
|
this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
|
||||||
|
|
||||||
this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
|
this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
|
||||||
|
this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
|
||||||
this.on('change', this.$updateFoldWidgets);
|
this.on('change', this.$updateFoldWidgets);
|
||||||
|
this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getParentFoldRangeData = function (row, ignoreCurrent) {
|
this.getParentFoldRangeData = function (row, ignoreCurrent) {
|
||||||
|
|
@ -841,7 +843,13 @@ function Folding() {
|
||||||
this.foldWidgets.splice.apply(this.foldWidgets, args);
|
this.foldWidgets.splice.apply(this.foldWidgets, args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
this.tokenizerUpdateFoldWidgets = function(e) {
|
||||||
|
var rows = e.data;
|
||||||
|
if (rows.first != rows.last) {
|
||||||
|
if (this.foldWidgets.length > rows.first)
|
||||||
|
this.foldWidgets.splice(rows.first, this.foldWidgets.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Folding = Folding;
|
exports.Folding = Folding;
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,8 @@ var Editor = function(renderer, session) {
|
||||||
args: commadEvent.args,
|
args: commadEvent.args,
|
||||||
scrollTop: this.renderer.scrollTop
|
scrollTop: this.renderer.scrollTop
|
||||||
};
|
};
|
||||||
|
if (this.curOp.command.name)
|
||||||
|
this.$blockScrolling++;
|
||||||
// this.selections.push(this.selection.toJSON());
|
// this.selections.push(this.selection.toJSON());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -158,8 +159,10 @@ var Editor = function(renderer, session) {
|
||||||
if (this.curOp) {
|
if (this.curOp) {
|
||||||
if (e && e.returnValue === false)
|
if (e && e.returnValue === false)
|
||||||
return this.curOp = null;
|
return this.curOp = null;
|
||||||
|
this._signal("beforeEndOperation");
|
||||||
var command = this.curOp.command;
|
var command = this.curOp.command;
|
||||||
|
if (command.name && this.$blockScrolling)
|
||||||
|
this.$blockScrolling--;
|
||||||
if (command && command.scrollIntoView) {
|
if (command && command.scrollIntoView) {
|
||||||
switch (command.scrollIntoView) {
|
switch (command.scrollIntoView) {
|
||||||
case "center":
|
case "center":
|
||||||
|
|
@ -536,12 +539,15 @@ var Editor = function(renderer, session) {
|
||||||
var iterator = new TokenIterator(self.session, pos.row, pos.column);
|
var iterator = new TokenIterator(self.session, pos.row, pos.column);
|
||||||
var token = iterator.getCurrentToken();
|
var token = iterator.getCurrentToken();
|
||||||
|
|
||||||
if (!token || token.type.indexOf('tag-name') === -1) {
|
if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
|
||||||
session.removeMarker(session.$tagHighlight);
|
session.removeMarker(session.$tagHighlight);
|
||||||
session.$tagHighlight = null;
|
session.$tagHighlight = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (token.type.indexOf("tag-open") != -1)
|
||||||
|
token = iterator.stepForward();
|
||||||
|
|
||||||
var tag = token.value;
|
var tag = token.value;
|
||||||
var depth = 0;
|
var depth = 0;
|
||||||
var prevToken = iterator.stepBackward();
|
var prevToken = iterator.stepBackward();
|
||||||
|
|
@ -709,6 +715,10 @@ var Editor = function(renderer, session) {
|
||||||
this.$cursorChange();
|
this.$cursorChange();
|
||||||
|
|
||||||
if (!this.$blockScrolling) {
|
if (!this.$blockScrolling) {
|
||||||
|
config.warn("Automatically scrolling cursor into view after selection change",
|
||||||
|
"this will be disabled in the next version",
|
||||||
|
"set editor.$blockScrolling = Infinity to disable this message"
|
||||||
|
);
|
||||||
this.renderer.scrollCursorIntoView();
|
this.renderer.scrollCursorIntoView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -897,9 +907,28 @@ var Editor = function(renderer, session) {
|
||||||
// todo this should change when paste becomes a command
|
// todo this should change when paste becomes a command
|
||||||
if (this.$readOnly)
|
if (this.$readOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var e = {text: text};
|
var e = {text: text};
|
||||||
this._signal("paste", e);
|
this._signal("paste", e);
|
||||||
this.insert(e.text, true);
|
text = e.text;
|
||||||
|
if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
|
||||||
|
this.insert(text);
|
||||||
|
} else {
|
||||||
|
var lines = text.split(/\r\n|\r|\n/);
|
||||||
|
var ranges = this.selection.rangeList.ranges;
|
||||||
|
|
||||||
|
if (lines.length > ranges.length || lines.length < 2 || !lines[1])
|
||||||
|
return this.commands.exec("insertstring", this, text);
|
||||||
|
|
||||||
|
for (var i = ranges.length; i--;) {
|
||||||
|
var range = ranges[i];
|
||||||
|
if (!range.isEmpty())
|
||||||
|
this.session.remove(range);
|
||||||
|
|
||||||
|
this.session.insert(range.start, lines[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.renderer.scrollCursorIntoView();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.execCommand = function(command, args) {
|
this.execCommand = function(command, args) {
|
||||||
|
|
@ -1616,9 +1645,7 @@ var Editor = function(renderer, session) {
|
||||||
* @related EditSession.moveLinesUp
|
* @related EditSession.moveLinesUp
|
||||||
**/
|
**/
|
||||||
this.moveLinesDown = function() {
|
this.moveLinesDown = function() {
|
||||||
this.$moveLines(function(firstRow, lastRow) {
|
this.$moveLines(1, false);
|
||||||
return this.session.moveLinesDown(firstRow, lastRow);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1627,9 +1654,7 @@ var Editor = function(renderer, session) {
|
||||||
* @related EditSession.moveLinesDown
|
* @related EditSession.moveLinesDown
|
||||||
**/
|
**/
|
||||||
this.moveLinesUp = function() {
|
this.moveLinesUp = function() {
|
||||||
this.$moveLines(function(firstRow, lastRow) {
|
this.$moveLines(-1, false);
|
||||||
return this.session.moveLinesUp(firstRow, lastRow);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1653,10 +1678,7 @@ var Editor = function(renderer, session) {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.copyLinesUp = function() {
|
this.copyLinesUp = function() {
|
||||||
this.$moveLines(function(firstRow, lastRow) {
|
this.$moveLines(-1, true);
|
||||||
this.session.duplicateLines(firstRow, lastRow);
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1666,51 +1688,61 @@ var Editor = function(renderer, session) {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.copyLinesDown = function() {
|
this.copyLinesDown = function() {
|
||||||
this.$moveLines(function(firstRow, lastRow) {
|
this.$moveLines(1, true);
|
||||||
return this.session.duplicateLines(firstRow, lastRow);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a specific function, which can be anything that manipulates selected lines, such as copying them, duplicating them, or shifting them.
|
* for internal use
|
||||||
* @param {Function} mover A method to call on each selected row
|
* @ignore
|
||||||
*
|
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.$moveLines = function(mover) {
|
this.$moveLines = function(dir, copy) {
|
||||||
|
var rows, moved;
|
||||||
var selection = this.selection;
|
var selection = this.selection;
|
||||||
if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
|
if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
|
||||||
var range = selection.toOrientedRange();
|
var range = selection.toOrientedRange();
|
||||||
var rows = this.$getSelectedRows(range);
|
rows = this.$getSelectedRows(range);
|
||||||
var linesMoved = mover.call(this, rows.first, rows.last);
|
moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
|
||||||
range.moveBy(linesMoved, 0);
|
if (copy && dir == -1) moved = 0;
|
||||||
|
range.moveBy(moved, 0);
|
||||||
selection.fromOrientedRange(range);
|
selection.fromOrientedRange(range);
|
||||||
} else {
|
} else {
|
||||||
var ranges = selection.rangeList.ranges;
|
var ranges = selection.rangeList.ranges;
|
||||||
selection.rangeList.detach(this.session);
|
selection.rangeList.detach(this.session);
|
||||||
|
this.inVirtualSelectionMode = true;
|
||||||
|
|
||||||
for (var i = ranges.length; i--; ) {
|
var diff = 0;
|
||||||
|
var totalDiff = 0;
|
||||||
|
var l = ranges.length;
|
||||||
|
for (var i = 0; i < l; i++) {
|
||||||
var rangeIndex = i;
|
var rangeIndex = i;
|
||||||
var rows = ranges[i].collapseRows();
|
ranges[i].moveBy(diff, 0);
|
||||||
var last = rows.end.row;
|
rows = this.$getSelectedRows(ranges[i]);
|
||||||
var first = rows.start.row;
|
var first = rows.first;
|
||||||
while (i--) {
|
var last = rows.last;
|
||||||
rows = ranges[i].collapseRows();
|
while (++i < l) {
|
||||||
if (first - rows.end.row <= 1)
|
if (totalDiff) ranges[i].moveBy(totalDiff, 0);
|
||||||
first = rows.end.row;
|
var subRows = this.$getSelectedRows(ranges[i]);
|
||||||
else
|
if (copy && subRows.first != last)
|
||||||
break;
|
break;
|
||||||
|
else if (!copy && subRows.first > last + 1)
|
||||||
|
break;
|
||||||
|
last = subRows.last;
|
||||||
}
|
}
|
||||||
i++;
|
i--;
|
||||||
|
diff = this.session.$moveLines(first, last, copy ? 0 : dir);
|
||||||
var linesMoved = mover.call(this, first, last);
|
if (copy && dir == -1) rangeIndex = i + 1;
|
||||||
while (rangeIndex >= i) {
|
while (rangeIndex <= i) {
|
||||||
ranges[rangeIndex].moveBy(linesMoved, 0);
|
ranges[rangeIndex].moveBy(diff, 0);
|
||||||
rangeIndex--;
|
rangeIndex++;
|
||||||
}
|
}
|
||||||
|
if (!copy) diff = 0;
|
||||||
|
totalDiff += diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
selection.fromOrientedRange(selection.ranges[0]);
|
selection.fromOrientedRange(selection.ranges[0]);
|
||||||
selection.rangeList.attach(this.session);
|
selection.rangeList.attach(this.session);
|
||||||
|
this.inVirtualSelectionMode = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1723,8 +1755,8 @@ var Editor = function(renderer, session) {
|
||||||
*
|
*
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
**/
|
**/
|
||||||
this.$getSelectedRows = function() {
|
this.$getSelectedRows = function(range) {
|
||||||
var range = this.getSelectionRange().collapseRows();
|
range = (range || this.getSelectionRange()).collapseRows();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
first: this.session.getRowFoldStart(range.start.row),
|
first: this.session.getRowFoldStart(range.start.row),
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ var supportedModes = {
|
||||||
Lucene: ["lucene"],
|
Lucene: ["lucene"],
|
||||||
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
|
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
|
||||||
Markdown: ["md|markdown"],
|
Markdown: ["md|markdown"],
|
||||||
|
Mask: ["mask"],
|
||||||
MATLAB: ["matlab"],
|
MATLAB: ["matlab"],
|
||||||
MEL: ["mel"],
|
MEL: ["mel"],
|
||||||
MUSHCode: ["mc|mush"],
|
MUSHCode: ["mc|mush"],
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,10 @@ var TextInput = function(parentNode, host) {
|
||||||
if (useragent.isTouchPad)
|
if (useragent.isTouchPad)
|
||||||
text.setAttribute("x-palm-disable-auto-cap", true);
|
text.setAttribute("x-palm-disable-auto-cap", true);
|
||||||
|
|
||||||
text.wrap = "off";
|
text.setAttribute("wrap", "off");
|
||||||
text.autocorrect = "off";
|
text.setAttribute("autocorrect", "off");
|
||||||
text.autocapitalize = "off";
|
text.setAttribute("autocapitalize", "off");
|
||||||
text.spellcheck = false;
|
text.setAttribute("spellcheck", false);
|
||||||
|
|
||||||
text.style.opacity = "0";
|
text.style.opacity = "0";
|
||||||
if (useragent.isOldIE) text.style.top = "-100px";
|
if (useragent.isOldIE) text.style.top = "-100px";
|
||||||
|
|
@ -75,7 +75,14 @@ var TextInput = function(parentNode, host) {
|
||||||
host.onFocus(e);
|
host.onFocus(e);
|
||||||
resetSelection();
|
resetSelection();
|
||||||
});
|
});
|
||||||
this.focus = function() { text.focus(); };
|
this.focus = function() {
|
||||||
|
text.style.position = "fixed";
|
||||||
|
text.style.top = "-10000000px";
|
||||||
|
text.focus();
|
||||||
|
setTimeout(function() {
|
||||||
|
text.style.position = "";
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
this.blur = function() { text.blur(); };
|
this.blur = function() { text.blur(); };
|
||||||
this.isFocused = function() {
|
this.isFocused = function() {
|
||||||
return isFocused;
|
return isFocused;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,618 +0,0 @@
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Distributed under the BSD license:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
|
||||||
|
|
||||||
"never use strict";
|
|
||||||
|
|
||||||
var lang = require("../../lib/lang");
|
|
||||||
var util = require("./maps/util");
|
|
||||||
var motions = require("./maps/motions");
|
|
||||||
var operators = require("./maps/operators");
|
|
||||||
var alias = require("./maps/aliases");
|
|
||||||
var registers = require("./registers");
|
|
||||||
|
|
||||||
var NUMBER = 1;
|
|
||||||
var OPERATOR = 2;
|
|
||||||
var MOTION = 3;
|
|
||||||
var ACTION = 4;
|
|
||||||
var HMARGIN = 8; // Minimum amount of line separation between margins;
|
|
||||||
|
|
||||||
var repeat = function repeat(fn, count, args) {
|
|
||||||
while (0 < count--)
|
|
||||||
fn.apply(this, args);
|
|
||||||
};
|
|
||||||
|
|
||||||
var ensureScrollMargin = function(editor) {
|
|
||||||
var renderer = editor.renderer;
|
|
||||||
var pos = renderer.$cursorLayer.getPixelPosition();
|
|
||||||
|
|
||||||
var top = pos.top;
|
|
||||||
|
|
||||||
var margin = HMARGIN * renderer.layerConfig.lineHeight;
|
|
||||||
if (2 * margin > renderer.$size.scrollerHeight)
|
|
||||||
margin = renderer.$size.scrollerHeight / 2;
|
|
||||||
|
|
||||||
if (renderer.scrollTop > top - margin) {
|
|
||||||
renderer.session.setScrollTop(top - margin);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (renderer.scrollTop + renderer.$size.scrollerHeight < top + margin + renderer.lineHeight) {
|
|
||||||
renderer.session.setScrollTop(top + margin + renderer.lineHeight - renderer.$size.scrollerHeight);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var actions = exports.actions = {
|
|
||||||
"z": {
|
|
||||||
param: true,
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
switch (param) {
|
|
||||||
case "z":
|
|
||||||
editor.renderer.alignCursor(null, 0.5);
|
|
||||||
break;
|
|
||||||
case "t":
|
|
||||||
editor.renderer.alignCursor(null, 0);
|
|
||||||
break;
|
|
||||||
case "b":
|
|
||||||
editor.renderer.alignCursor(null, 1);
|
|
||||||
break;
|
|
||||||
case "c":
|
|
||||||
editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
|
|
||||||
break;
|
|
||||||
case "o":
|
|
||||||
editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
|
|
||||||
break;
|
|
||||||
case "C":
|
|
||||||
editor.session.foldAll();
|
|
||||||
break;
|
|
||||||
case "O":
|
|
||||||
editor.session.unfold();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"r": {
|
|
||||||
param: true,
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
if (param && param.length) {
|
|
||||||
if (param.length > 1)
|
|
||||||
param = param == "return" ? "\n" : param == "tab" ? "\t" : param;
|
|
||||||
repeat(function() { editor.insert(param); }, count || 1);
|
|
||||||
editor.navigateLeft();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"R": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
util.insertMode(editor);
|
|
||||||
editor.setOverwrite(true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"~": {
|
|
||||||
fn: function(editor, range, count) {
|
|
||||||
repeat(function() {
|
|
||||||
var range = editor.selection.getRange();
|
|
||||||
if (range.isEmpty())
|
|
||||||
range.end.column++;
|
|
||||||
var text = editor.session.getTextRange(range);
|
|
||||||
var toggled = text.toUpperCase();
|
|
||||||
if (toggled != text)
|
|
||||||
editor.session.replace(range, toggled);
|
|
||||||
else if (text.toLowerCase() != text)
|
|
||||||
editor.session.replace(range, text.toLowerCase())
|
|
||||||
else
|
|
||||||
editor.navigateRight();
|
|
||||||
}, count || 1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"*": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
editor.selection.selectWord();
|
|
||||||
editor.findNext();
|
|
||||||
ensureScrollMargin(editor);
|
|
||||||
var r = editor.selection.getRange();
|
|
||||||
editor.selection.setSelectionRange(r, true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"#": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
editor.selection.selectWord();
|
|
||||||
editor.findPrevious();
|
|
||||||
ensureScrollMargin(editor);
|
|
||||||
var r = editor.selection.getRange();
|
|
||||||
editor.selection.setSelectionRange(r, true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"m": {
|
|
||||||
param: true,
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
var s = editor.session;
|
|
||||||
var markers = s.vimMarkers || (s.vimMarkers = {});
|
|
||||||
var c = editor.getCursorPosition();
|
|
||||||
if (!markers[param]) {
|
|
||||||
markers[param] = editor.session.doc.createAnchor(c);
|
|
||||||
}
|
|
||||||
markers[param].setPosition(c.row, c.column, true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"n": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
var options = editor.getLastSearchOptions();
|
|
||||||
options.backwards = false;
|
|
||||||
options.start = null;
|
|
||||||
|
|
||||||
editor.selection.moveCursorRight();
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
editor.findNext(options);
|
|
||||||
|
|
||||||
ensureScrollMargin(editor);
|
|
||||||
var r = editor.selection.getRange();
|
|
||||||
r.end.row = r.start.row;
|
|
||||||
r.end.column = r.start.column;
|
|
||||||
editor.selection.setSelectionRange(r, true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"N": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
var options = editor.getLastSearchOptions();
|
|
||||||
options.backwards = true;
|
|
||||||
options.start = null;
|
|
||||||
|
|
||||||
editor.findPrevious(options);
|
|
||||||
ensureScrollMargin(editor);
|
|
||||||
var r = editor.selection.getRange();
|
|
||||||
r.end.row = r.start.row;
|
|
||||||
r.end.column = r.start.column;
|
|
||||||
editor.selection.setSelectionRange(r, true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"v": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
editor.selection.selectRight();
|
|
||||||
util.visualMode(editor, false);
|
|
||||||
},
|
|
||||||
acceptsMotion: true
|
|
||||||
},
|
|
||||||
"V": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
//editor.selection.selectLine();
|
|
||||||
//editor.selection.selectLeft();
|
|
||||||
var row = editor.getCursorPosition().row;
|
|
||||||
editor.selection.moveTo(row, 0);
|
|
||||||
editor.selection.selectLineEnd();
|
|
||||||
editor.selection.visualLineStart = row;
|
|
||||||
|
|
||||||
util.visualMode(editor, true);
|
|
||||||
},
|
|
||||||
acceptsMotion: true
|
|
||||||
},
|
|
||||||
"Y": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
util.copyLine(editor);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"p": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
var defaultReg = registers._default;
|
|
||||||
|
|
||||||
editor.setOverwrite(false);
|
|
||||||
if (defaultReg.isLine) {
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
pos.column = editor.session.getLine(pos.row).length;
|
|
||||||
var text = lang.stringRepeat("\n" + defaultReg.text, count || 1);
|
|
||||||
editor.session.insert(pos, text);
|
|
||||||
editor.moveCursorTo(pos.row + 1, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
editor.navigateRight();
|
|
||||||
editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
|
|
||||||
editor.navigateLeft();
|
|
||||||
}
|
|
||||||
editor.setOverwrite(true);
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"P": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
var defaultReg = registers._default;
|
|
||||||
editor.setOverwrite(false);
|
|
||||||
|
|
||||||
if (defaultReg.isLine) {
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
pos.column = 0;
|
|
||||||
var text = lang.stringRepeat(defaultReg.text + "\n", count || 1);
|
|
||||||
editor.session.insert(pos, text);
|
|
||||||
editor.moveCursorToPosition(pos);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
|
|
||||||
}
|
|
||||||
editor.setOverwrite(true);
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"J": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
var session = editor.session;
|
|
||||||
range = editor.getSelectionRange();
|
|
||||||
var pos = {row: range.start.row, column: range.start.column};
|
|
||||||
count = count || range.end.row - range.start.row;
|
|
||||||
var maxRow = Math.min(pos.row + (count || 1), session.getLength() - 1);
|
|
||||||
|
|
||||||
range.start.column = session.getLine(pos.row).length;
|
|
||||||
range.end.column = session.getLine(maxRow).length;
|
|
||||||
range.end.row = maxRow;
|
|
||||||
|
|
||||||
var text = "";
|
|
||||||
for (var i = pos.row; i < maxRow; i++) {
|
|
||||||
var nextLine = session.getLine(i + 1);
|
|
||||||
text += " " + /^\s*(.*)$/.exec(nextLine)[1] || "";
|
|
||||||
}
|
|
||||||
|
|
||||||
session.replace(range, text);
|
|
||||||
editor.moveCursorTo(pos.row, pos.column);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"u": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
count = parseInt(count || 1, 10);
|
|
||||||
for (var i = 0; i < count; i++) {
|
|
||||||
editor.undo();
|
|
||||||
}
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ctrl-r": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
count = parseInt(count || 1, 10);
|
|
||||||
for (var i = 0; i < count; i++) {
|
|
||||||
editor.redo();
|
|
||||||
}
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
":": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
var val = ":";
|
|
||||||
if (count > 1)
|
|
||||||
val = ".,.+" + count + val;
|
|
||||||
if (editor.showCommandLine)
|
|
||||||
editor.showCommandLine(val);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
if (editor.showCommandLine)
|
|
||||||
editor.showCommandLine("/");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"?": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
if (editor.showCommandLine)
|
|
||||||
editor.showCommandLine("?");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
".": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
util.onInsertReplaySequence = inputBuffer.lastInsertCommands;
|
|
||||||
var previous = inputBuffer.previous;
|
|
||||||
if (previous) // If there is a previous action
|
|
||||||
inputBuffer.exec(editor, previous.action, previous.param);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ctrl-x": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
editor.modifyNumber(-(count || 1));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ctrl-a": {
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
editor.modifyNumber(count || 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var inputBuffer = exports.inputBuffer = {
|
|
||||||
accepting: [NUMBER, OPERATOR, MOTION, ACTION],
|
|
||||||
currentCmd: null,
|
|
||||||
//currentMode: 0,
|
|
||||||
currentCount: "",
|
|
||||||
pendingCount: "",
|
|
||||||
status: "",
|
|
||||||
|
|
||||||
// Types
|
|
||||||
operator: null,
|
|
||||||
motion: null,
|
|
||||||
|
|
||||||
lastInsertCommands: [],
|
|
||||||
|
|
||||||
push: function(editor, ch, keyId) {
|
|
||||||
var status = this.status;
|
|
||||||
var isKeyHandled = true;
|
|
||||||
this.idle = false;
|
|
||||||
var wObj = this.waitingForParam;
|
|
||||||
if (/^numpad\d+$/i.test(ch))
|
|
||||||
ch = ch.substr(6);
|
|
||||||
|
|
||||||
if (wObj) {
|
|
||||||
this.exec(editor, wObj, ch);
|
|
||||||
}
|
|
||||||
// If input is a number (that doesn't start with 0)
|
|
||||||
else if (!(ch === "0" && !this.currentCount.length) &&
|
|
||||||
(/^\d+$/.test(ch) && this.isAccepting(NUMBER))) {
|
|
||||||
// Assuming that ch is always of type String, and not Number
|
|
||||||
this.currentCount += ch;
|
|
||||||
this.currentCmd = NUMBER;
|
|
||||||
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
|
|
||||||
}
|
|
||||||
else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) {
|
|
||||||
this.operator = {
|
|
||||||
ch: ch,
|
|
||||||
count: this.getCount()
|
|
||||||
};
|
|
||||||
this.currentCmd = OPERATOR;
|
|
||||||
this.accepting = [NUMBER, MOTION, ACTION];
|
|
||||||
this.exec(editor, { operator: this.operator });
|
|
||||||
}
|
|
||||||
else if (motions[ch] && this.isAccepting(MOTION)) {
|
|
||||||
this.currentCmd = MOTION;
|
|
||||||
|
|
||||||
var ctx = {
|
|
||||||
operator: this.operator,
|
|
||||||
motion: {
|
|
||||||
ch: ch,
|
|
||||||
count: this.getCount()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (motions[ch].param)
|
|
||||||
this.waitForParam(ctx);
|
|
||||||
else
|
|
||||||
this.exec(editor, ctx);
|
|
||||||
}
|
|
||||||
else if (alias[ch] && this.isAccepting(MOTION)) {
|
|
||||||
alias[ch].operator.count = this.getCount();
|
|
||||||
this.exec(editor, alias[ch]);
|
|
||||||
}
|
|
||||||
else if (actions[ch] && this.isAccepting(ACTION)) {
|
|
||||||
var actionObj = {
|
|
||||||
action: {
|
|
||||||
fn: actions[ch].fn,
|
|
||||||
count: this.getCount()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (actions[ch].param) {
|
|
||||||
this.waitForParam(actionObj);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.exec(editor, actionObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (actions[ch].acceptsMotion)
|
|
||||||
this.idle = false;
|
|
||||||
}
|
|
||||||
else if (this.operator) {
|
|
||||||
this.operator.count = this.getCount();
|
|
||||||
this.exec(editor, { operator: this.operator }, ch);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
isKeyHandled = ch.length == 1;
|
|
||||||
this.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.waitingForParam || this.motion || this.operator) {
|
|
||||||
this.status += ch;
|
|
||||||
} else if (this.currentCount) {
|
|
||||||
this.status = this.currentCount;
|
|
||||||
} else if (this.status) {
|
|
||||||
this.status = "";
|
|
||||||
}
|
|
||||||
if (this.status != status)
|
|
||||||
editor._emit("changeStatus");
|
|
||||||
return isKeyHandled;
|
|
||||||
},
|
|
||||||
|
|
||||||
waitForParam: function(cmd) {
|
|
||||||
this.waitingForParam = cmd;
|
|
||||||
},
|
|
||||||
|
|
||||||
getCount: function() {
|
|
||||||
var count = this.currentCount || this.pendingCount;
|
|
||||||
this.currentCount = "";
|
|
||||||
this.pendingCount = count;
|
|
||||||
return count && parseInt(count, 10);
|
|
||||||
},
|
|
||||||
|
|
||||||
exec: function(editor, action, param) {
|
|
||||||
var m = action.motion;
|
|
||||||
var o = action.operator;
|
|
||||||
var a = action.action;
|
|
||||||
|
|
||||||
if (!param)
|
|
||||||
param = action.param;
|
|
||||||
|
|
||||||
if (o) {
|
|
||||||
this.previous = {
|
|
||||||
action: action,
|
|
||||||
param: param
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o && !editor.selection.isEmpty()) {
|
|
||||||
if (operators[o.ch].selFn) {
|
|
||||||
operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
|
|
||||||
this.reset();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is an operator, but no motion or action. We try to pass the
|
|
||||||
// current ch to the operator to see if it responds to it (an example
|
|
||||||
// of this is the 'dd' operator).
|
|
||||||
else if (!m && !a && o && param) {
|
|
||||||
operators[o.ch].fn(editor, null, o.count, param);
|
|
||||||
this.reset();
|
|
||||||
}
|
|
||||||
else if (m) {
|
|
||||||
var run = function(fn) {
|
|
||||||
if (fn && typeof fn === "function") { // There should always be a motion
|
|
||||||
if (m.count && !motionObj.handlesCount)
|
|
||||||
repeat(fn, m.count, [editor, null, m.count, param]);
|
|
||||||
else
|
|
||||||
fn(editor, null, m.count, param);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var motionObj = motions[m.ch];
|
|
||||||
var selectable = motionObj.sel;
|
|
||||||
|
|
||||||
if (!o) {
|
|
||||||
if ((util.onVisualMode || util.onVisualLineMode) && selectable)
|
|
||||||
run(motionObj.sel);
|
|
||||||
else
|
|
||||||
run(motionObj.nav);
|
|
||||||
}
|
|
||||||
else if (selectable) {
|
|
||||||
repeat(function() {
|
|
||||||
run(motionObj.sel);
|
|
||||||
operators[o.ch].fn(editor, editor.getSelectionRange(),
|
|
||||||
o.count, motionObj.param ? motionObj : param);
|
|
||||||
}, o.count || 1);
|
|
||||||
}
|
|
||||||
this.reset();
|
|
||||||
}
|
|
||||||
else if (a) {
|
|
||||||
a.fn(editor, editor.getSelectionRange(), a.count, param);
|
|
||||||
this.reset();
|
|
||||||
}
|
|
||||||
handleCursorMove(editor);
|
|
||||||
},
|
|
||||||
|
|
||||||
isAccepting: function(type) {
|
|
||||||
return this.accepting.indexOf(type) !== -1;
|
|
||||||
},
|
|
||||||
|
|
||||||
reset: function() {
|
|
||||||
this.operator = null;
|
|
||||||
this.motion = null;
|
|
||||||
this.currentCount = "";
|
|
||||||
this.pendingCount = "";
|
|
||||||
this.status = "";
|
|
||||||
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
|
|
||||||
this.idle = true;
|
|
||||||
this.waitingForParam = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function setPreviousCommand(fn) {
|
|
||||||
inputBuffer.previous = { action: { action: { fn: fn } } };
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.coreCommands = {
|
|
||||||
start: {
|
|
||||||
exec: function start(editor) {
|
|
||||||
util.insertMode(editor);
|
|
||||||
setPreviousCommand(start);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
startBeginning: {
|
|
||||||
exec: function startBeginning(editor) {
|
|
||||||
editor.navigateLineStart();
|
|
||||||
util.insertMode(editor);
|
|
||||||
setPreviousCommand(startBeginning);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Stop Insert mode as soon as possible. Works like typing <Esc> in
|
|
||||||
// insert mode.
|
|
||||||
stop: {
|
|
||||||
exec: function stop(editor) {
|
|
||||||
inputBuffer.reset();
|
|
||||||
util.onVisualMode = false;
|
|
||||||
util.onVisualLineMode = false;
|
|
||||||
inputBuffer.lastInsertCommands = util.normalMode(editor);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
append: {
|
|
||||||
exec: function append(editor) {
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
var lineLen = editor.session.getLine(pos.row).length;
|
|
||||||
if (lineLen)
|
|
||||||
editor.navigateRight();
|
|
||||||
util.insertMode(editor);
|
|
||||||
setPreviousCommand(append);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
appendEnd: {
|
|
||||||
exec: function appendEnd(editor) {
|
|
||||||
editor.navigateLineEnd();
|
|
||||||
util.insertMode(editor);
|
|
||||||
setPreviousCommand(appendEnd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var handleCursorMove = exports.onCursorMove = function(editor, e) {
|
|
||||||
if (util.currentMode === 'insert' || handleCursorMove.running)
|
|
||||||
return;
|
|
||||||
else if(!editor.selection.isEmpty()) {
|
|
||||||
handleCursorMove.running = true;
|
|
||||||
if (util.onVisualLineMode) {
|
|
||||||
var originRow = editor.selection.visualLineStart;
|
|
||||||
var cursorRow = editor.getCursorPosition().row;
|
|
||||||
if(originRow <= cursorRow) {
|
|
||||||
var endLine = editor.session.getLine(cursorRow);
|
|
||||||
editor.selection.moveTo(originRow, 0);
|
|
||||||
editor.selection.selectTo(cursorRow, endLine.length);
|
|
||||||
} else {
|
|
||||||
var endLine = editor.session.getLine(originRow);
|
|
||||||
editor.selection.moveTo(originRow, endLine.length);
|
|
||||||
editor.selection.selectTo(cursorRow, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handleCursorMove.running = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (e && (util.onVisualLineMode || util.onVisualMode)) {
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
util.normalMode(editor);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleCursorMove.running = true;
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
var lineLen = editor.session.getLine(pos.row).length;
|
|
||||||
|
|
||||||
if (lineLen && pos.column === lineLen)
|
|
||||||
editor.navigateLeft();
|
|
||||||
handleCursorMove.running = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
@ -1,681 +0,0 @@
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Distributed under the BSD license:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var util = require("./util");
|
|
||||||
|
|
||||||
var keepScrollPosition = function(editor, fn) {
|
|
||||||
var scrollTopRow = editor.renderer.getScrollTopRow();
|
|
||||||
var initialRow = editor.getCursorPosition().row;
|
|
||||||
var diff = initialRow - scrollTopRow;
|
|
||||||
fn && fn.call(editor);
|
|
||||||
editor.renderer.scrollToRow(editor.getCursorPosition().row - diff);
|
|
||||||
};
|
|
||||||
|
|
||||||
function Motion(m) {
|
|
||||||
if (typeof m == "function") {
|
|
||||||
var getPos = m;
|
|
||||||
m = this;
|
|
||||||
} else {
|
|
||||||
var getPos = m.getPos;
|
|
||||||
}
|
|
||||||
m.nav = function(editor, range, count, param) {
|
|
||||||
var a = getPos(editor, range, count, param, false);
|
|
||||||
if (!a)
|
|
||||||
return;
|
|
||||||
editor.selection.moveTo(a.row, a.column);
|
|
||||||
};
|
|
||||||
m.sel = function(editor, range, count, param) {
|
|
||||||
var a = getPos(editor, range, count, param, true);
|
|
||||||
if (!a)
|
|
||||||
return;
|
|
||||||
editor.selection.selectTo(a.row, a.column);
|
|
||||||
};
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
|
|
||||||
var wordSeparatorRe = /[.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
|
|
||||||
var whiteRe = /\s/;
|
|
||||||
var StringStream = function(editor, cursor) {
|
|
||||||
var sel = editor.selection;
|
|
||||||
this.range = sel.getRange();
|
|
||||||
cursor = cursor || sel.selectionLead;
|
|
||||||
this.row = cursor.row;
|
|
||||||
this.col = cursor.column;
|
|
||||||
var line = editor.session.getLine(this.row);
|
|
||||||
var maxRow = editor.session.getLength();
|
|
||||||
this.ch = line[this.col] || '\n';
|
|
||||||
this.skippedLines = 0;
|
|
||||||
|
|
||||||
this.next = function() {
|
|
||||||
this.ch = line[++this.col] || this.handleNewLine(1);
|
|
||||||
//this.debug()
|
|
||||||
return this.ch;
|
|
||||||
};
|
|
||||||
this.prev = function() {
|
|
||||||
this.ch = line[--this.col] || this.handleNewLine(-1);
|
|
||||||
//this.debug()
|
|
||||||
return this.ch;
|
|
||||||
};
|
|
||||||
this.peek = function(dir) {
|
|
||||||
var ch = line[this.col + dir];
|
|
||||||
if (ch)
|
|
||||||
return ch;
|
|
||||||
if (dir == -1)
|
|
||||||
return '\n';
|
|
||||||
if (this.col == line.length - 1)
|
|
||||||
return '\n';
|
|
||||||
return editor.session.getLine(this.row + 1)[0] || '\n';
|
|
||||||
};
|
|
||||||
|
|
||||||
this.handleNewLine = function(dir) {
|
|
||||||
if (dir == 1){
|
|
||||||
if (this.col == line.length)
|
|
||||||
return '\n';
|
|
||||||
if (this.row == maxRow - 1)
|
|
||||||
return '';
|
|
||||||
this.col = 0;
|
|
||||||
this.row ++;
|
|
||||||
line = editor.session.getLine(this.row);
|
|
||||||
this.skippedLines++;
|
|
||||||
return line[0] || '\n';
|
|
||||||
}
|
|
||||||
if (dir == -1) {
|
|
||||||
if (this.row === 0)
|
|
||||||
return '';
|
|
||||||
this.row --;
|
|
||||||
line = editor.session.getLine(this.row);
|
|
||||||
this.col = line.length;
|
|
||||||
this.skippedLines--;
|
|
||||||
return '\n';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.debug = function() {
|
|
||||||
console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1));
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var Search = require("../../../search").Search;
|
|
||||||
var search = new Search();
|
|
||||||
|
|
||||||
function find(editor, needle, dir) {
|
|
||||||
search.$options.needle = needle;
|
|
||||||
search.$options.backwards = dir == -1;
|
|
||||||
return search.find(editor.session);
|
|
||||||
}
|
|
||||||
|
|
||||||
var Range = require("../../../range").Range;
|
|
||||||
|
|
||||||
var LAST_SEARCH_MOTION = {};
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
"w": new Motion(function(editor) {
|
|
||||||
var str = new StringStream(editor);
|
|
||||||
|
|
||||||
if (str.ch && wordSeparatorRe.test(str.ch)) {
|
|
||||||
while (str.ch && wordSeparatorRe.test(str.ch))
|
|
||||||
str.next();
|
|
||||||
} else {
|
|
||||||
while (str.ch && !nonWordRe.test(str.ch))
|
|
||||||
str.next();
|
|
||||||
}
|
|
||||||
while (str.ch && whiteRe.test(str.ch) && str.skippedLines < 2)
|
|
||||||
str.next();
|
|
||||||
|
|
||||||
str.skippedLines == 2 && str.prev();
|
|
||||||
return {column: str.col, row: str.row};
|
|
||||||
}),
|
|
||||||
"W": new Motion(function(editor) {
|
|
||||||
var str = new StringStream(editor);
|
|
||||||
while(str.ch && !(whiteRe.test(str.ch) && !whiteRe.test(str.peek(1))) && str.skippedLines < 2)
|
|
||||||
str.next();
|
|
||||||
if (str.skippedLines == 2)
|
|
||||||
str.prev();
|
|
||||||
else
|
|
||||||
str.next();
|
|
||||||
|
|
||||||
return {column: str.col, row: str.row};
|
|
||||||
}),
|
|
||||||
"b": new Motion(function(editor) {
|
|
||||||
var str = new StringStream(editor);
|
|
||||||
|
|
||||||
str.prev();
|
|
||||||
while (str.ch && whiteRe.test(str.ch) && str.skippedLines > -2)
|
|
||||||
str.prev();
|
|
||||||
|
|
||||||
if (str.ch && wordSeparatorRe.test(str.ch)) {
|
|
||||||
while (str.ch && wordSeparatorRe.test(str.ch))
|
|
||||||
str.prev();
|
|
||||||
} else {
|
|
||||||
while (str.ch && !nonWordRe.test(str.ch))
|
|
||||||
str.prev();
|
|
||||||
}
|
|
||||||
str.ch && str.next();
|
|
||||||
return {column: str.col, row: str.row};
|
|
||||||
}),
|
|
||||||
"B": new Motion(function(editor) {
|
|
||||||
var str = new StringStream(editor);
|
|
||||||
str.prev();
|
|
||||||
while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2)
|
|
||||||
str.prev();
|
|
||||||
|
|
||||||
if (str.skippedLines == -2)
|
|
||||||
str.next();
|
|
||||||
|
|
||||||
return {column: str.col, row: str.row};
|
|
||||||
}),
|
|
||||||
"e": new Motion(function(editor) {
|
|
||||||
var str = new StringStream(editor);
|
|
||||||
|
|
||||||
str.next();
|
|
||||||
while (str.ch && whiteRe.test(str.ch))
|
|
||||||
str.next();
|
|
||||||
|
|
||||||
if (str.ch && wordSeparatorRe.test(str.ch)) {
|
|
||||||
while (str.ch && wordSeparatorRe.test(str.ch))
|
|
||||||
str.next();
|
|
||||||
} else {
|
|
||||||
while (str.ch && !nonWordRe.test(str.ch))
|
|
||||||
str.next();
|
|
||||||
}
|
|
||||||
str.ch && str.prev();
|
|
||||||
return {column: str.col, row: str.row};
|
|
||||||
}),
|
|
||||||
"E": new Motion(function(editor) {
|
|
||||||
var str = new StringStream(editor);
|
|
||||||
str.next();
|
|
||||||
while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(1))))
|
|
||||||
str.next();
|
|
||||||
|
|
||||||
return {column: str.col, row: str.row};
|
|
||||||
}),
|
|
||||||
|
|
||||||
"l": {
|
|
||||||
nav: function(editor) {
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
var col = pos.column;
|
|
||||||
var lineLen = editor.session.getLine(pos.row).length;
|
|
||||||
if (lineLen && col !== lineLen)
|
|
||||||
editor.navigateRight();
|
|
||||||
},
|
|
||||||
sel: function(editor) {
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
var col = pos.column;
|
|
||||||
var lineLen = editor.session.getLine(pos.row).length;
|
|
||||||
|
|
||||||
// Solving the behavior at the end of the line due to the
|
|
||||||
// different 0 index-based colum positions in ACE.
|
|
||||||
if (lineLen && col !== lineLen) //In selection mode you can select the newline
|
|
||||||
editor.selection.selectRight();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"h": {
|
|
||||||
nav: function(editor) {
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
if (pos.column > 0)
|
|
||||||
editor.navigateLeft();
|
|
||||||
},
|
|
||||||
sel: function(editor) {
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
if (pos.column > 0)
|
|
||||||
editor.selection.selectLeft();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"H": {
|
|
||||||
nav: function(editor) {
|
|
||||||
var row = editor.renderer.getScrollTopRow();
|
|
||||||
editor.moveCursorTo(row);
|
|
||||||
},
|
|
||||||
sel: function(editor) {
|
|
||||||
var row = editor.renderer.getScrollTopRow();
|
|
||||||
editor.selection.selectTo(row);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"M": {
|
|
||||||
nav: function(editor) {
|
|
||||||
var topRow = editor.renderer.getScrollTopRow();
|
|
||||||
var bottomRow = editor.renderer.getScrollBottomRow();
|
|
||||||
var row = topRow + ((bottomRow - topRow) / 2);
|
|
||||||
editor.moveCursorTo(row);
|
|
||||||
},
|
|
||||||
sel: function(editor) {
|
|
||||||
var topRow = editor.renderer.getScrollTopRow();
|
|
||||||
var bottomRow = editor.renderer.getScrollBottomRow();
|
|
||||||
var row = topRow + ((bottomRow - topRow) / 2);
|
|
||||||
editor.selection.selectTo(row);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"L": {
|
|
||||||
nav: function(editor) {
|
|
||||||
var row = editor.renderer.getScrollBottomRow();
|
|
||||||
editor.moveCursorTo(row);
|
|
||||||
},
|
|
||||||
sel: function(editor) {
|
|
||||||
var row = editor.renderer.getScrollBottomRow();
|
|
||||||
editor.selection.selectTo(row);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"k": {
|
|
||||||
nav: function(editor) {
|
|
||||||
editor.navigateUp();
|
|
||||||
},
|
|
||||||
sel: function(editor) {
|
|
||||||
editor.selection.selectUp();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"j": {
|
|
||||||
nav: function(editor) {
|
|
||||||
editor.navigateDown();
|
|
||||||
},
|
|
||||||
sel: function(editor) {
|
|
||||||
editor.selection.selectDown();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"i": {
|
|
||||||
param: true,
|
|
||||||
sel: function(editor, range, count, param) {
|
|
||||||
switch (param) {
|
|
||||||
case "w":
|
|
||||||
editor.selection.selectWord();
|
|
||||||
break;
|
|
||||||
case "W":
|
|
||||||
editor.selection.selectAWord();
|
|
||||||
break;
|
|
||||||
case "(":
|
|
||||||
case "{":
|
|
||||||
case "[":
|
|
||||||
var cursor = editor.getCursorPosition();
|
|
||||||
var end = editor.session.$findClosingBracket(param, cursor, /paren/);
|
|
||||||
if (!end)
|
|
||||||
return;
|
|
||||||
var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
|
|
||||||
if (!start)
|
|
||||||
return;
|
|
||||||
start.column ++;
|
|
||||||
editor.selection.setSelectionRange(Range.fromPoints(start, end));
|
|
||||||
break;
|
|
||||||
case "'":
|
|
||||||
case '"':
|
|
||||||
case "/":
|
|
||||||
var end = find(editor, param, 1);
|
|
||||||
if (!end)
|
|
||||||
return;
|
|
||||||
var start = find(editor, param, -1);
|
|
||||||
if (!start)
|
|
||||||
return;
|
|
||||||
editor.selection.setSelectionRange(Range.fromPoints(start.end, end.start));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"a": {
|
|
||||||
param: true,
|
|
||||||
sel: function(editor, range, count, param) {
|
|
||||||
switch (param) {
|
|
||||||
case "w":
|
|
||||||
editor.selection.selectAWord();
|
|
||||||
break;
|
|
||||||
case "W":
|
|
||||||
editor.selection.selectAWord();
|
|
||||||
break;
|
|
||||||
case ")":
|
|
||||||
case "}":
|
|
||||||
case "]":
|
|
||||||
param = editor.session.$brackets[param];
|
|
||||||
case "(":
|
|
||||||
case "{":
|
|
||||||
case "[":
|
|
||||||
var cursor = editor.getCursorPosition();
|
|
||||||
var end = editor.session.$findClosingBracket(param, cursor, /paren/);
|
|
||||||
if (!end)
|
|
||||||
return;
|
|
||||||
var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
|
|
||||||
if (!start)
|
|
||||||
return;
|
|
||||||
end.column ++;
|
|
||||||
editor.selection.setSelectionRange(Range.fromPoints(start, end));
|
|
||||||
break;
|
|
||||||
case "'":
|
|
||||||
case "\"":
|
|
||||||
case "/":
|
|
||||||
var end = find(editor, param, 1);
|
|
||||||
if (!end)
|
|
||||||
return;
|
|
||||||
var start = find(editor, param, -1);
|
|
||||||
if (!start)
|
|
||||||
return;
|
|
||||||
end.column ++;
|
|
||||||
editor.selection.setSelectionRange(Range.fromPoints(start.start, end.end));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"f": new Motion({
|
|
||||||
param: true,
|
|
||||||
handlesCount: true,
|
|
||||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
|
||||||
if (param == "space") param = " ";
|
|
||||||
if (!isRepeat)
|
|
||||||
LAST_SEARCH_MOTION = {ch: "f", param: param};
|
|
||||||
var cursor = editor.getCursorPosition();
|
|
||||||
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
|
||||||
|
|
||||||
if (typeof column === "number") {
|
|
||||||
cursor.column += column + (isSel ? 2 : 1);
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
"F": new Motion({
|
|
||||||
param: true,
|
|
||||||
handlesCount: true,
|
|
||||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
|
||||||
if (param == "space") param = " ";
|
|
||||||
if (!isRepeat)
|
|
||||||
LAST_SEARCH_MOTION = {ch: "F", param: param};
|
|
||||||
var cursor = editor.getCursorPosition();
|
|
||||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
|
||||||
|
|
||||||
if (typeof column === "number") {
|
|
||||||
cursor.column -= column + 1;
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
"t": new Motion({
|
|
||||||
param: true,
|
|
||||||
handlesCount: true,
|
|
||||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
|
||||||
if (param == "space") param = " ";
|
|
||||||
if (!isRepeat)
|
|
||||||
LAST_SEARCH_MOTION = {ch: "t", param: param};
|
|
||||||
var cursor = editor.getCursorPosition();
|
|
||||||
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
|
||||||
|
|
||||||
if (isRepeat && column == 0 && !(count > 1))
|
|
||||||
column = util.getRightNthChar(editor, cursor, param, 2);
|
|
||||||
|
|
||||||
if (typeof column === "number") {
|
|
||||||
cursor.column += column + (isSel ? 1 : 0);
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
"T": new Motion({
|
|
||||||
param: true,
|
|
||||||
handlesCount: true,
|
|
||||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
|
||||||
if (param == "space") param = " ";
|
|
||||||
if (!isRepeat)
|
|
||||||
LAST_SEARCH_MOTION = {ch: "T", param: param};
|
|
||||||
var cursor = editor.getCursorPosition();
|
|
||||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
|
||||||
|
|
||||||
if (isRepeat && column === 0 && !(count > 1))
|
|
||||||
column = util.getLeftNthChar(editor, cursor, param, 2);
|
|
||||||
|
|
||||||
if (typeof column === "number") {
|
|
||||||
cursor.column -= column;
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
";": new Motion({
|
|
||||||
handlesCount: true,
|
|
||||||
getPos: function(editor, range, count, param, isSel) {
|
|
||||||
var ch = LAST_SEARCH_MOTION.ch;
|
|
||||||
if (!ch)
|
|
||||||
return;
|
|
||||||
return module.exports[ch].getPos(
|
|
||||||
editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
",": new Motion({
|
|
||||||
handlesCount: true,
|
|
||||||
getPos: function(editor, range, count, param, isSel) {
|
|
||||||
var ch = LAST_SEARCH_MOTION.ch;
|
|
||||||
if (!ch)
|
|
||||||
return;
|
|
||||||
var up = ch.toUpperCase();
|
|
||||||
ch = ch === up ? ch.toLowerCase() : up;
|
|
||||||
|
|
||||||
return module.exports[ch].getPos(
|
|
||||||
editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
"^": {
|
|
||||||
nav: function(editor) {
|
|
||||||
editor.navigateLineStart();
|
|
||||||
},
|
|
||||||
sel: function(editor) {
|
|
||||||
editor.selection.selectLineStart();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"$": {
|
|
||||||
handlesCount: true,
|
|
||||||
nav: function(editor, range, count, param) {
|
|
||||||
if (count > 1) {
|
|
||||||
editor.navigateDown(count-1);
|
|
||||||
}
|
|
||||||
editor.navigateLineEnd();
|
|
||||||
},
|
|
||||||
sel: function(editor, range, count, param) {
|
|
||||||
if (count > 1) {
|
|
||||||
editor.selection.moveCursorBy(count-1, 0);
|
|
||||||
}
|
|
||||||
editor.selection.selectLineEnd();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"0": new Motion(function(ed) {
|
|
||||||
return {row: ed.selection.lead.row, column: 0};
|
|
||||||
}),
|
|
||||||
"G": {
|
|
||||||
nav: function(editor, range, count, param) {
|
|
||||||
if (!count && count !== 0) { // Stupid JS
|
|
||||||
count = editor.session.getLength();
|
|
||||||
}
|
|
||||||
editor.gotoLine(count);
|
|
||||||
},
|
|
||||||
sel: function(editor, range, count, param) {
|
|
||||||
if (!count && count !== 0) { // Stupid JS
|
|
||||||
count = editor.session.getLength();
|
|
||||||
}
|
|
||||||
editor.selection.selectTo(count, 0);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"g": {
|
|
||||||
param: true,
|
|
||||||
nav: function(editor, range, count, param) {
|
|
||||||
switch(param) {
|
|
||||||
case "m":
|
|
||||||
console.log("Middle line");
|
|
||||||
break;
|
|
||||||
case "e":
|
|
||||||
console.log("End of prev word");
|
|
||||||
break;
|
|
||||||
case "g":
|
|
||||||
editor.gotoLine(count || 0);
|
|
||||||
case "u":
|
|
||||||
editor.gotoLine(count || 0);
|
|
||||||
case "U":
|
|
||||||
editor.gotoLine(count || 0);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
sel: function(editor, range, count, param) {
|
|
||||||
switch(param) {
|
|
||||||
case "m":
|
|
||||||
console.log("Middle line");
|
|
||||||
break;
|
|
||||||
case "e":
|
|
||||||
console.log("End of prev word");
|
|
||||||
break;
|
|
||||||
case "g":
|
|
||||||
editor.selection.selectTo(count || 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"o": {
|
|
||||||
nav: function(editor, range, count, param) {
|
|
||||||
count = count || 1;
|
|
||||||
var content = "";
|
|
||||||
while (0 < count--)
|
|
||||||
content += "\n";
|
|
||||||
|
|
||||||
if (content.length) {
|
|
||||||
editor.navigateLineEnd();
|
|
||||||
editor.insert(content);
|
|
||||||
util.insertMode(editor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"O": {
|
|
||||||
nav: function(editor, range, count, param) {
|
|
||||||
var row = editor.getCursorPosition().row;
|
|
||||||
count = count || 1;
|
|
||||||
var content = "";
|
|
||||||
while (0 < count--)
|
|
||||||
content += "\n";
|
|
||||||
|
|
||||||
if (content.length) {
|
|
||||||
if(row > 0) {
|
|
||||||
editor.navigateUp();
|
|
||||||
editor.navigateLineEnd();
|
|
||||||
editor.insert(content);
|
|
||||||
} else {
|
|
||||||
editor.session.insert({row: 0, column: 0}, content);
|
|
||||||
editor.navigateUp();
|
|
||||||
}
|
|
||||||
util.insertMode(editor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"%": new Motion(function(editor){
|
|
||||||
var brRe = /[\[\]{}()]/g;
|
|
||||||
var cursor = editor.getCursorPosition();
|
|
||||||
var ch = editor.session.getLine(cursor.row)[cursor.column];
|
|
||||||
if (!brRe.test(ch)) {
|
|
||||||
var range = find(editor, brRe);
|
|
||||||
if (!range)
|
|
||||||
return;
|
|
||||||
cursor = range.start;
|
|
||||||
}
|
|
||||||
var match = editor.session.findMatchingBracket({
|
|
||||||
row: cursor.row,
|
|
||||||
column: cursor.column + 1
|
|
||||||
});
|
|
||||||
|
|
||||||
return match;
|
|
||||||
}),
|
|
||||||
"{": new Motion(function(ed) {
|
|
||||||
var session = ed.session;
|
|
||||||
var row = session.selection.lead.row;
|
|
||||||
while(row > 0 && !/\S/.test(session.getLine(row)))
|
|
||||||
row--;
|
|
||||||
while(/\S/.test(session.getLine(row)))
|
|
||||||
row--;
|
|
||||||
return {column: 0, row: row};
|
|
||||||
}),
|
|
||||||
"}": new Motion(function(ed) {
|
|
||||||
var session = ed.session;
|
|
||||||
var l = session.getLength();
|
|
||||||
var row = session.selection.lead.row;
|
|
||||||
while(row < l && !/\S/.test(session.getLine(row)))
|
|
||||||
row++;
|
|
||||||
while(/\S/.test(session.getLine(row)))
|
|
||||||
row++;
|
|
||||||
return {column: 0, row: row};
|
|
||||||
}),
|
|
||||||
"ctrl-d": {
|
|
||||||
nav: function(editor, range, count, param) {
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
keepScrollPosition(editor, editor.gotoPageDown);
|
|
||||||
},
|
|
||||||
sel: function(editor, range, count, param) {
|
|
||||||
keepScrollPosition(editor, editor.selectPageDown);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ctrl-u": {
|
|
||||||
nav: function(editor, range, count, param) {
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
keepScrollPosition(editor, editor.gotoPageUp);
|
|
||||||
},
|
|
||||||
sel: function(editor, range, count, param) {
|
|
||||||
keepScrollPosition(editor, editor.selectPageUp);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"`": new Motion({
|
|
||||||
param: true,
|
|
||||||
handlesCount: true,
|
|
||||||
getPos: function(editor, range, count, param, isSel) {
|
|
||||||
var s = editor.session;
|
|
||||||
var marker = s.vimMarkers && s.vimMarkers[param];
|
|
||||||
if (marker) {
|
|
||||||
return marker.getPosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
"'": new Motion({
|
|
||||||
param: true,
|
|
||||||
handlesCount: true,
|
|
||||||
getPos: function(editor, range, count, param, isSel) {
|
|
||||||
var s = editor.session;
|
|
||||||
var marker = s.vimMarkers && s.vimMarkers[param];
|
|
||||||
if (marker) {
|
|
||||||
var pos = marker.getPosition();
|
|
||||||
var line = editor.session.getLine(pos.row);
|
|
||||||
pos.column = line.search(/\S/);
|
|
||||||
if (pos.column == -1)
|
|
||||||
pos.column = line.length;
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
isLine: true
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.backspace = module.exports.left = module.exports.h;
|
|
||||||
module.exports.space = module.exports['return'] = module.exports.right = module.exports.l;
|
|
||||||
module.exports.up = module.exports.k;
|
|
||||||
module.exports.down = module.exports.j;
|
|
||||||
module.exports.pagedown = module.exports["ctrl-d"];
|
|
||||||
module.exports.pageup = module.exports["ctrl-u"];
|
|
||||||
module.exports.home = module.exports["0"];
|
|
||||||
module.exports.end = module.exports["$"];
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
@ -1,201 +0,0 @@
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Distributed under the BSD license:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var util = require("./util");
|
|
||||||
var registers = require("../registers");
|
|
||||||
var Range = require("../../../range").Range;
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
"d": {
|
|
||||||
selFn: function(editor, range, count, param) {
|
|
||||||
registers._default.text = editor.getCopyText();
|
|
||||||
registers._default.isLine = util.onVisualLineMode;
|
|
||||||
if(util.onVisualLineMode)
|
|
||||||
editor.removeLines();
|
|
||||||
else
|
|
||||||
editor.session.remove(range);
|
|
||||||
util.normalMode(editor);
|
|
||||||
},
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
count = count || 1;
|
|
||||||
switch (param) {
|
|
||||||
case "d":
|
|
||||||
registers._default.text = "";
|
|
||||||
registers._default.isLine = true;
|
|
||||||
for (var i = 0; i < count; i++) {
|
|
||||||
editor.selection.selectLine();
|
|
||||||
registers._default.text += editor.getCopyText();
|
|
||||||
var selRange = editor.getSelectionRange();
|
|
||||||
// check if end of the document was reached
|
|
||||||
if (!selRange.isMultiLine()) {
|
|
||||||
var row = selRange.start.row - 1;
|
|
||||||
var col = editor.session.getLine(row).length
|
|
||||||
selRange.setStart(row, col);
|
|
||||||
editor.session.remove(selRange);
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
editor.session.remove(selRange);
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
}
|
|
||||||
registers._default.text = registers._default.text.replace(/\n$/, "");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (range) {
|
|
||||||
editor.selection.setSelectionRange(range);
|
|
||||||
registers._default.text = editor.getCopyText();
|
|
||||||
registers._default.isLine = false;
|
|
||||||
editor.session.remove(range);
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"c": {
|
|
||||||
selFn: function(editor, range, count, param) {
|
|
||||||
editor.session.remove(range);
|
|
||||||
util.insertMode(editor);
|
|
||||||
},
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
count = count || 1;
|
|
||||||
switch (param) {
|
|
||||||
case "c":
|
|
||||||
editor.$blockScrolling++;
|
|
||||||
editor.selection.$moveSelection(function() {
|
|
||||||
editor.selection.moveCursorBy(count - 1, 0);
|
|
||||||
});
|
|
||||||
var rows = editor.$getSelectedRows();
|
|
||||||
range = new Range(rows.first, 0, rows.last, Infinity);
|
|
||||||
editor.session.remove(range);
|
|
||||||
editor.$blockScrolling--;
|
|
||||||
util.insertMode(editor);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (range) {
|
|
||||||
// range.end.column ++;
|
|
||||||
editor.session.remove(range);
|
|
||||||
util.insertMode(editor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"y": {
|
|
||||||
selFn: function(editor, range, count, param) {
|
|
||||||
registers._default.text = editor.getCopyText();
|
|
||||||
registers._default.isLine = util.onVisualLineMode;
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
util.normalMode(editor);
|
|
||||||
},
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
count = count || 1;
|
|
||||||
if (param && param.isLine)
|
|
||||||
param = "y";
|
|
||||||
switch (param) {
|
|
||||||
case "y":
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
editor.selection.selectLine();
|
|
||||||
for (var i = 0; i < count - 1; i++) {
|
|
||||||
editor.selection.moveCursorDown();
|
|
||||||
}
|
|
||||||
registers._default.text = editor.getCopyText().replace(/\n$/, "");
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
registers._default.isLine = true;
|
|
||||||
editor.moveCursorToPosition(pos);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (range) {
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
editor.selection.setSelectionRange(range);
|
|
||||||
registers._default.text = editor.getCopyText();
|
|
||||||
registers._default.isLine = false;
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
editor.moveCursorTo(pos.row, pos.column);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
">": {
|
|
||||||
selFn: function(editor, range, count, param) {
|
|
||||||
count = count || 1;
|
|
||||||
for (var i = 0; i < count; i++) {
|
|
||||||
editor.indent();
|
|
||||||
}
|
|
||||||
util.normalMode(editor);
|
|
||||||
},
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
count = parseInt(count || 1, 10);
|
|
||||||
switch (param) {
|
|
||||||
case ">":
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
editor.selection.selectLine();
|
|
||||||
for (var i = 0; i < count - 1; i++) {
|
|
||||||
editor.selection.moveCursorDown();
|
|
||||||
}
|
|
||||||
editor.indent();
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
editor.moveCursorToPosition(pos);
|
|
||||||
editor.navigateLineEnd();
|
|
||||||
editor.navigateLineStart();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"<": {
|
|
||||||
selFn: function(editor, range, count, param) {
|
|
||||||
count = count || 1;
|
|
||||||
for (var i = 0; i < count; i++) {
|
|
||||||
editor.blockOutdent();
|
|
||||||
}
|
|
||||||
util.normalMode(editor);
|
|
||||||
},
|
|
||||||
fn: function(editor, range, count, param) {
|
|
||||||
count = count || 1;
|
|
||||||
switch (param) {
|
|
||||||
case "<":
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
editor.selection.selectLine();
|
|
||||||
for (var i = 0; i < count - 1; i++) {
|
|
||||||
editor.selection.moveCursorDown();
|
|
||||||
}
|
|
||||||
editor.blockOutdent();
|
|
||||||
editor.selection.clearSelection();
|
|
||||||
editor.moveCursorToPosition(pos);
|
|
||||||
editor.navigateLineEnd();
|
|
||||||
editor.navigateLineStart();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
@ -1,132 +0,0 @@
|
||||||
define(function(require, exports, module) {
|
|
||||||
var registers = require("../registers");
|
|
||||||
|
|
||||||
var dom = require("../../../lib/dom");
|
|
||||||
dom.importCssString('.insert-mode .ace_cursor{\
|
|
||||||
border-left: 2px solid #333333;\
|
|
||||||
}\
|
|
||||||
.ace_dark.insert-mode .ace_cursor{\
|
|
||||||
border-left: 2px solid #eeeeee;\
|
|
||||||
}\
|
|
||||||
.normal-mode .ace_cursor{\
|
|
||||||
border: 0!important;\
|
|
||||||
background-color: red;\
|
|
||||||
opacity: 0.5;\
|
|
||||||
}', 'vimMode');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
onVisualMode: false,
|
|
||||||
onVisualLineMode: false,
|
|
||||||
currentMode: 'normal',
|
|
||||||
noMode: function(editor) {
|
|
||||||
editor.unsetStyle('insert-mode');
|
|
||||||
editor.unsetStyle('normal-mode');
|
|
||||||
if (editor.commands.recording)
|
|
||||||
editor.commands.toggleRecording(editor);
|
|
||||||
editor.setOverwrite(false);
|
|
||||||
},
|
|
||||||
insertMode: function(editor) {
|
|
||||||
this.currentMode = 'insert';
|
|
||||||
// Switch editor to insert mode
|
|
||||||
editor.setStyle('insert-mode');
|
|
||||||
editor.unsetStyle('normal-mode');
|
|
||||||
|
|
||||||
editor.setOverwrite(false);
|
|
||||||
editor.keyBinding.$data.buffer = "";
|
|
||||||
editor.keyBinding.$data.vimState = "insertMode";
|
|
||||||
this.onVisualMode = false;
|
|
||||||
this.onVisualLineMode = false;
|
|
||||||
if(this.onInsertReplaySequence) {
|
|
||||||
// Ok, we're apparently replaying ("."), so let's do it
|
|
||||||
editor.commands.macro = this.onInsertReplaySequence;
|
|
||||||
editor.commands.replay(editor);
|
|
||||||
this.onInsertReplaySequence = null;
|
|
||||||
this.normalMode(editor);
|
|
||||||
} else {
|
|
||||||
editor._emit("changeStatus");
|
|
||||||
// Record any movements, insertions in insert mode
|
|
||||||
if(!editor.commands.recording)
|
|
||||||
editor.commands.toggleRecording(editor);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
normalMode: function(editor) {
|
|
||||||
// Switch editor to normal mode
|
|
||||||
this.currentMode = 'normal';
|
|
||||||
|
|
||||||
editor.unsetStyle('insert-mode');
|
|
||||||
editor.setStyle('normal-mode');
|
|
||||||
editor.clearSelection();
|
|
||||||
|
|
||||||
var pos;
|
|
||||||
if (!editor.getOverwrite()) {
|
|
||||||
pos = editor.getCursorPosition();
|
|
||||||
if (pos.column > 0)
|
|
||||||
editor.navigateLeft();
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.setOverwrite(true);
|
|
||||||
editor.keyBinding.$data.buffer = "";
|
|
||||||
editor.keyBinding.$data.vimState = "start";
|
|
||||||
this.onVisualMode = false;
|
|
||||||
this.onVisualLineMode = false;
|
|
||||||
editor._emit("changeStatus");
|
|
||||||
// Save recorded keystrokes
|
|
||||||
if (editor.commands.recording) {
|
|
||||||
editor.commands.toggleRecording(editor);
|
|
||||||
return editor.commands.macro;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
visualMode: function(editor, lineMode) {
|
|
||||||
if (
|
|
||||||
(this.onVisualLineMode && lineMode)
|
|
||||||
|| (this.onVisualMode && !lineMode)
|
|
||||||
) {
|
|
||||||
this.normalMode(editor);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.setStyle('insert-mode');
|
|
||||||
editor.unsetStyle('normal-mode');
|
|
||||||
|
|
||||||
editor._emit("changeStatus");
|
|
||||||
if (lineMode) {
|
|
||||||
this.onVisualLineMode = true;
|
|
||||||
} else {
|
|
||||||
this.onVisualMode = true;
|
|
||||||
this.onVisualLineMode = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getRightNthChar: function(editor, cursor, ch, n) {
|
|
||||||
var line = editor.getSession().getLine(cursor.row);
|
|
||||||
var matches = line.substr(cursor.column + 1).split(ch);
|
|
||||||
|
|
||||||
return n < matches.length ? matches.slice(0, n).join(ch).length : null;
|
|
||||||
},
|
|
||||||
getLeftNthChar: function(editor, cursor, ch, n) {
|
|
||||||
var line = editor.getSession().getLine(cursor.row);
|
|
||||||
var matches = line.substr(0, cursor.column).split(ch);
|
|
||||||
|
|
||||||
return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
|
|
||||||
},
|
|
||||||
toRealChar: function(ch) {
|
|
||||||
if (ch.length === 1)
|
|
||||||
return ch;
|
|
||||||
|
|
||||||
if (/^shift-./.test(ch))
|
|
||||||
return ch[ch.length - 1].toUpperCase();
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
},
|
|
||||||
copyLine: function(editor) {
|
|
||||||
var pos = editor.getCursorPosition();
|
|
||||||
editor.selection.moveTo(pos.row, pos.column);
|
|
||||||
editor.selection.selectLine();
|
|
||||||
registers._default.isLine = true;
|
|
||||||
registers._default.text = editor.getCopyText().replace(/\n$/, "");
|
|
||||||
editor.selection.moveTo(pos.row, pos.column);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Distributed under the BSD license:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
|
||||||
|
|
||||||
"never use strict";
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
_default: {
|
|
||||||
text: "",
|
|
||||||
isLine: false
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -196,10 +196,14 @@ var Cursor = function(parentEl) {
|
||||||
|
|
||||||
var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
|
var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
|
||||||
|
|
||||||
style.left = pixelPos.left + "px";
|
if (!this.drawCursor) {
|
||||||
style.top = pixelPos.top + "px";
|
style.left = pixelPos.left + "px";
|
||||||
style.width = config.characterWidth + "px";
|
style.top = pixelPos.top + "px";
|
||||||
style.height = config.lineHeight + "px";
|
style.width = config.characterWidth + "px";
|
||||||
|
style.height = config.lineHeight + "px";
|
||||||
|
} else {
|
||||||
|
this.drawCursor(style, pixelPos, config, selections[i], this.session);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (this.cursors.length > cursorIndex)
|
while (this.cursors.length > cursorIndex)
|
||||||
this.removeCursor();
|
this.removeCursor();
|
||||||
|
|
@ -212,6 +216,8 @@ var Cursor = function(parentEl) {
|
||||||
this.restartTimer();
|
this.restartTimer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.drawCursor = null;
|
||||||
|
|
||||||
this.$setOverwrite = function(overwrite) {
|
this.$setOverwrite = function(overwrite) {
|
||||||
if (overwrite != this.overwrite) {
|
if (overwrite != this.overwrite) {
|
||||||
this.overwrite = overwrite;
|
this.overwrite = overwrite;
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,9 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
|
||||||
|
|
||||||
this.$setMeasureNodeStyles = function(style, isRoot) {
|
this.$setMeasureNodeStyles = function(style, isRoot) {
|
||||||
style.width = style.height = "auto";
|
style.width = style.height = "auto";
|
||||||
style.left = style.top = "-100px";
|
style.left = style.top = "0px";
|
||||||
style.visibility = "hidden";
|
style.visibility = "hidden";
|
||||||
style.position = "fixed";
|
style.position = "absolute";
|
||||||
style.whiteSpace = "pre";
|
style.whiteSpace = "pre";
|
||||||
|
|
||||||
if (useragent.isIE < 8) {
|
if (useragent.isIE < 8) {
|
||||||
|
|
|
||||||
157
lib/ace/lib/app_config.js
Normal file
157
lib/ace/lib/app_config.js
Normal file
|
|
@ -0,0 +1,157 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Distributed under the BSD license:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010, Ajax.org B.V.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of Ajax.org B.V. nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"no use strict";
|
||||||
|
|
||||||
|
var oop = require("./oop");
|
||||||
|
var EventEmitter = require("./event_emitter").EventEmitter;
|
||||||
|
|
||||||
|
var optionsProvider = {
|
||||||
|
setOptions: function(optList) {
|
||||||
|
Object.keys(optList).forEach(function(key) {
|
||||||
|
this.setOption(key, optList[key]);
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
getOptions: function(optionNames) {
|
||||||
|
var result = {};
|
||||||
|
if (!optionNames) {
|
||||||
|
optionNames = Object.keys(this.$options);
|
||||||
|
} else if (!Array.isArray(optionNames)) {
|
||||||
|
result = optionNames;
|
||||||
|
optionNames = Object.keys(result);
|
||||||
|
}
|
||||||
|
optionNames.forEach(function(key) {
|
||||||
|
result[key] = this.getOption(key);
|
||||||
|
}, this);
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
setOption: function(name, value) {
|
||||||
|
if (this["$" + name] === value)
|
||||||
|
return;
|
||||||
|
var opt = this.$options[name];
|
||||||
|
if (!opt) {
|
||||||
|
return warn('misspelled option "' + name + '"');
|
||||||
|
}
|
||||||
|
if (opt.forwardTo)
|
||||||
|
return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
|
||||||
|
|
||||||
|
if (!opt.handlesSet)
|
||||||
|
this["$" + name] = value;
|
||||||
|
if (opt && opt.set)
|
||||||
|
opt.set.call(this, value);
|
||||||
|
},
|
||||||
|
getOption: function(name) {
|
||||||
|
var opt = this.$options[name];
|
||||||
|
if (!opt) {
|
||||||
|
return warn('misspelled option "' + name + '"');
|
||||||
|
}
|
||||||
|
if (opt.forwardTo)
|
||||||
|
return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
|
||||||
|
return opt && opt.get ? opt.get.call(this) : this["$" + name];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function warn(message) {
|
||||||
|
if (typeof console != "undefined" && console.warn)
|
||||||
|
console.warn.apply(console, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reportError(msg, data) {
|
||||||
|
var e = new Error(msg);
|
||||||
|
e.data = data;
|
||||||
|
if (typeof console == "object" && console.error)
|
||||||
|
console.error(e);
|
||||||
|
setTimeout(function() { throw e; });
|
||||||
|
}
|
||||||
|
|
||||||
|
var AppConfig = function() {
|
||||||
|
this.$defaultOptions = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
// module loading
|
||||||
|
oop.implement(this, EventEmitter);
|
||||||
|
/*
|
||||||
|
* option {name, value, initialValue, setterName, set, get }
|
||||||
|
*/
|
||||||
|
this.defineOptions = function(obj, path, options) {
|
||||||
|
if (!obj.$options)
|
||||||
|
this.$defaultOptions[path] = obj.$options = {};
|
||||||
|
|
||||||
|
Object.keys(options).forEach(function(key) {
|
||||||
|
var opt = options[key];
|
||||||
|
if (typeof opt == "string")
|
||||||
|
opt = {forwardTo: opt};
|
||||||
|
|
||||||
|
opt.name || (opt.name = key);
|
||||||
|
obj.$options[opt.name] = opt;
|
||||||
|
if ("initialValue" in opt)
|
||||||
|
obj["$" + opt.name] = opt.initialValue;
|
||||||
|
});
|
||||||
|
|
||||||
|
// implement option provider interface
|
||||||
|
oop.implement(obj, optionsProvider);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.resetOptions = function(obj) {
|
||||||
|
Object.keys(obj.$options).forEach(function(key) {
|
||||||
|
var opt = obj.$options[key];
|
||||||
|
if ("value" in opt)
|
||||||
|
obj.setOption(key, opt.value);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
this.setDefaultValue = function(path, name, value) {
|
||||||
|
var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
|
||||||
|
if (opts[name]) {
|
||||||
|
if (opts.forwardTo)
|
||||||
|
this.setDefaultValue(opts.forwardTo, name, value);
|
||||||
|
else
|
||||||
|
opts[name].value = value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.setDefaultValues = function(path, optionHash) {
|
||||||
|
Object.keys(optionHash).forEach(function(key) {
|
||||||
|
this.setDefaultValue(path, key, optionHash[key]);
|
||||||
|
}, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.warn = warn;
|
||||||
|
this.reportError = reportError;
|
||||||
|
|
||||||
|
}).call(AppConfig.prototype);
|
||||||
|
|
||||||
|
exports.AppConfig = AppConfig;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -31,9 +31,6 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
if (typeof document == "undefined")
|
|
||||||
return;
|
|
||||||
|
|
||||||
var XHTML_NS = "http://www.w3.org/1999/xhtml";
|
var XHTML_NS = "http://www.w3.org/1999/xhtml";
|
||||||
|
|
||||||
exports.getDocumentHead = function(doc) {
|
exports.getDocumentHead = function(doc) {
|
||||||
|
|
@ -175,6 +172,10 @@ exports.getInnerHeight = function(element) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (typeof document == "undefined")
|
||||||
|
return;
|
||||||
|
|
||||||
if (window.pageYOffset !== undefined) {
|
if (window.pageYOffset !== undefined) {
|
||||||
exports.getPageScrollTop = function() {
|
exports.getPageScrollTop = function() {
|
||||||
return window.pageYOffset;
|
return window.pageYOffset;
|
||||||
|
|
|
||||||
302
lib/ace/mode/_test/tokens_mask.json
Normal file
302
lib/ace/mode/_test/tokens_mask.json
Normal file
|
|
@ -0,0 +1,302 @@
|
||||||
|
[[
|
||||||
|
"start",
|
||||||
|
["comment","/* Mask Syntax Demo */"]
|
||||||
|
],[
|
||||||
|
"start"
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["keyword.support.constant.language","div"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen",">"],
|
||||||
|
["text"," "],
|
||||||
|
["string.start","'"],
|
||||||
|
["string"," Test "],
|
||||||
|
["paren.lparen.markup.italic","~["],
|
||||||
|
["identifier","name"],
|
||||||
|
["paren.rparen.markup.italic","]"],
|
||||||
|
["string.end","'"],
|
||||||
|
["paren.rparen",";"]
|
||||||
|
],[
|
||||||
|
"start"
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["keyword","define"],
|
||||||
|
["text"," :"],
|
||||||
|
["support.variable.class","userProfile"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen","{"]
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["text","\t"],
|
||||||
|
["keyword.support.constant.language","header"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen","{"]
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["text","\t\t"],
|
||||||
|
["keyword.support.constant.language","h4"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen",">"],
|
||||||
|
["text"," "],
|
||||||
|
["support.function.markup.bold","@title"],
|
||||||
|
["paren.lparen",";"]
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["text","\t\t"],
|
||||||
|
["keyword.support.constant.language","button"],
|
||||||
|
["support.variable.class",".close"],
|
||||||
|
["paren.lparen",";"]
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["text","\t"],
|
||||||
|
["paren.rparen","}"]
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["paren.rparen","}"]
|
||||||
|
],[
|
||||||
|
"start"
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["support.function.markup.bold",":userProfile"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen","{"]
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["text","\t"],
|
||||||
|
["support.function.markup.bold","@title"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen",">"],
|
||||||
|
["text"," "],
|
||||||
|
["string.start","'"],
|
||||||
|
["string"," Hello "],
|
||||||
|
["paren.lparen.markup.italic","~["],
|
||||||
|
["keyword.control.markup.italic",":"],
|
||||||
|
["text"," "],
|
||||||
|
["identifier","username"],
|
||||||
|
["punctuation.operator","."],
|
||||||
|
["support.function","toUpperCase"],
|
||||||
|
["paren.lparen","("],
|
||||||
|
["paren.rparen",")"],
|
||||||
|
["paren.rparen.markup.italic","]"],
|
||||||
|
["string.end","'"]
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["paren.rparen","}"]
|
||||||
|
],[
|
||||||
|
"start"
|
||||||
|
],[
|
||||||
|
["paren.lparen52","constant.language40"],
|
||||||
|
["constant.language","style"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen","{"]
|
||||||
|
],[
|
||||||
|
["css-block-ruleset","paren.lparen52","paren.lparen52","constant.language40"],
|
||||||
|
["text"," "],
|
||||||
|
["constant","html"],
|
||||||
|
["text",", "],
|
||||||
|
["constant","body"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen","{"]
|
||||||
|
],[
|
||||||
|
["css-block-ruleset","paren.lparen52","paren.lparen52","constant.language40"],
|
||||||
|
["text"," "],
|
||||||
|
["support.type","background"],
|
||||||
|
["text",": "],
|
||||||
|
["support.function","url("],
|
||||||
|
["string","'name.png'"],
|
||||||
|
["support.function",")"],
|
||||||
|
["text"," "],
|
||||||
|
["constant.numeric","0"],
|
||||||
|
["text"," "],
|
||||||
|
["constant.numeric","0"],
|
||||||
|
["text"," "],
|
||||||
|
["support.constant","no-repeat"],
|
||||||
|
["text",";"]
|
||||||
|
],[
|
||||||
|
["paren.lparen52","constant.language40"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.rparen","}"]
|
||||||
|
],[
|
||||||
|
["#tmp","css-block-end","paren.lparen52","constant.language40"],
|
||||||
|
["paren.rparen","}"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen52","constant.language40"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen52","constant.language40"],
|
||||||
|
["keyword.support.constant.language","button"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen","{"]
|
||||||
|
],[
|
||||||
|
["paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["text","\t"],
|
||||||
|
["constant.language","event"],
|
||||||
|
["text"," "],
|
||||||
|
["support.variable.class","click"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen","("],
|
||||||
|
["identifier","e"],
|
||||||
|
["paren.rparen",")"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen","{"]
|
||||||
|
],[
|
||||||
|
["#tmp","js-block-start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["text","\t "],
|
||||||
|
["variable.language","this"],
|
||||||
|
["punctuation.operator","."],
|
||||||
|
["identifier","textContent"],
|
||||||
|
["text"," "],
|
||||||
|
["keyword.operator","="],
|
||||||
|
["text"," "],
|
||||||
|
["string.quasi.start","`"],
|
||||||
|
["string.quasi","name "],
|
||||||
|
["paren.quasi.start","${"],
|
||||||
|
["identifier","e"],
|
||||||
|
["punctuation.operator","."],
|
||||||
|
["identifier","clientX"],
|
||||||
|
["paren.quasi.end","}"],
|
||||||
|
["string.quasi"," !"],
|
||||||
|
["string.quasi.end","`"],
|
||||||
|
["punctuation.operator",";"]
|
||||||
|
],[
|
||||||
|
["#tmp","js-block-end","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["text","\t"],
|
||||||
|
["paren.rparen","}"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["paren.rparen","}"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"]
|
||||||
|
],[
|
||||||
|
["paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["constant.language","md"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen",">"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen","\"\"\""]
|
||||||
|
],[
|
||||||
|
["#tmp","md-multiline-allowBlock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"]
|
||||||
|
],[
|
||||||
|
["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["markup.list","- "],
|
||||||
|
["list","div"]
|
||||||
|
],[
|
||||||
|
["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["markup.list","- "],
|
||||||
|
["list","span"]
|
||||||
|
],[
|
||||||
|
["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["list"," "]
|
||||||
|
],[
|
||||||
|
["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["list","Hello"]
|
||||||
|
],[
|
||||||
|
["#tmp","md-multiline-start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"]
|
||||||
|
],[
|
||||||
|
["#tmp","md-multiline-start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["text","["],
|
||||||
|
["string","one"],
|
||||||
|
["text","]("],
|
||||||
|
["markup.underline","http://google.com"],
|
||||||
|
["text",")"]
|
||||||
|
],[
|
||||||
|
["#tmp","md-multiline-allowBlock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["paren.rparen","\"\"\";"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["keyword.support.constant.language","header"],
|
||||||
|
["text"," "],
|
||||||
|
["support.variable.class",".foo"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen",">"],
|
||||||
|
["text"," "],
|
||||||
|
["string.start","'"],
|
||||||
|
["string","Heading"],
|
||||||
|
["string.end","'"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"]
|
||||||
|
],[
|
||||||
|
["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["keyword.support.constant.language","button"],
|
||||||
|
["text"," "],
|
||||||
|
["support.variable.class",".baz"],
|
||||||
|
["text"," "],
|
||||||
|
["support.variable.class.markup.bold","x-signal"],
|
||||||
|
["keyword.operator","="],
|
||||||
|
["string.start","'"],
|
||||||
|
["string","click: test"],
|
||||||
|
["string.end","'"],
|
||||||
|
["text"," "],
|
||||||
|
["support.variable.class","disabled"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen",">"],
|
||||||
|
["text"," "],
|
||||||
|
["string.start","\""]
|
||||||
|
],[
|
||||||
|
["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["string","\tHello,"]
|
||||||
|
],[
|
||||||
|
["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["string","\tworld "]
|
||||||
|
],[
|
||||||
|
["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["string","\t"],
|
||||||
|
["string.escape","\\\""],
|
||||||
|
["string","Buddy"],
|
||||||
|
["string.escape","\\\""]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["string.end","\""]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"]
|
||||||
|
],[
|
||||||
|
["#tmp","js-statement-start","start","js-statement-no_regex","constant.language53","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["constant.language","var"],
|
||||||
|
["text"," "],
|
||||||
|
["identifier","a"],
|
||||||
|
["text"," "],
|
||||||
|
["keyword.operator","="],
|
||||||
|
["text"," "],
|
||||||
|
["paren","{"]
|
||||||
|
],[
|
||||||
|
["#tmp","js-statement-no_regex","start","js-statement-no_regex","constant.language53","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["text"," "],
|
||||||
|
["identifier","name"],
|
||||||
|
["punctuation.operator",":"],
|
||||||
|
["text"," "],
|
||||||
|
["string.quasi.start","`"],
|
||||||
|
["string.quasi","name "],
|
||||||
|
["paren.quasi.start","${"],
|
||||||
|
["variable.language","window"],
|
||||||
|
["punctuation.operator","."],
|
||||||
|
["support.constant","innerWidth"],
|
||||||
|
["paren.rparen","}"],
|
||||||
|
["string.quasi.end","`"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["paren.rparen","};"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"]
|
||||||
|
],[
|
||||||
|
["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"],
|
||||||
|
["keyword.support.constant.language","span"],
|
||||||
|
["text"," "],
|
||||||
|
["support.variable.class",".foo"],
|
||||||
|
["text"," "],
|
||||||
|
["paren.lparen",">"],
|
||||||
|
["text"," "],
|
||||||
|
["string.start","\""],
|
||||||
|
["paren.lparen.markup.italic","~["],
|
||||||
|
["keyword.control.markup.italic","bind:"],
|
||||||
|
["text"," "],
|
||||||
|
["identifier","a"],
|
||||||
|
["punctuation.operator","."],
|
||||||
|
["identifier","name"],
|
||||||
|
["paren.rparen.markup.italic","]"],
|
||||||
|
["string.end","\""]
|
||||||
|
]]
|
||||||
|
|
@ -53,9 +53,6 @@ var testRanges = function(str) {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
name: "ACE multi_select.js",
|
|
||||||
|
|
||||||
"test: cstyle": function() {
|
"test: cstyle": function() {
|
||||||
function testValue(line) {
|
function testValue(line) {
|
||||||
assert.equal(editor.getValue(), Array(4).join(line + "\n"));
|
assert.equal(editor.getValue(), Array(4).join(line + "\n"));
|
||||||
|
|
@ -123,6 +120,15 @@ module.exports = {
|
||||||
assert.equal(editor.getValue(), "{")
|
assert.equal(editor.getValue(), "{")
|
||||||
exec("insertstring", 1, "\n");
|
exec("insertstring", 1, "\n");
|
||||||
assert.equal(editor.getValue(), "{\n \n}")
|
assert.equal(editor.getValue(), "{\n \n}")
|
||||||
|
|
||||||
|
editor.setValue("");
|
||||||
|
exec("insertstring", 1, "(");
|
||||||
|
exec("insertstring", 1, '"');
|
||||||
|
exec("insertstring", 1, '"');
|
||||||
|
assert.equal(editor.getValue(), '("")');
|
||||||
|
exec("backspace", 1);
|
||||||
|
exec("insertstring", 1, '"');
|
||||||
|
assert.equal(editor.getValue(), '("")');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -260,48 +260,40 @@ var CstyleBehaviour = function() {
|
||||||
var cursor = editor.getCursorPosition();
|
var cursor = editor.getCursorPosition();
|
||||||
var line = session.doc.getLine(cursor.row);
|
var line = session.doc.getLine(cursor.row);
|
||||||
var leftChar = line.substring(cursor.column-1, cursor.column);
|
var leftChar = line.substring(cursor.column-1, cursor.column);
|
||||||
|
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
||||||
|
|
||||||
|
var token = session.getTokenAt(cursor.row, cursor.column);
|
||||||
|
var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
|
||||||
// We're escaped.
|
// We're escaped.
|
||||||
if (leftChar == '\\') {
|
if (leftChar == "\\" && token && /escape/.test(token.type))
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
// Find what token we're inside.
|
var stringBefore = token && /string/.test(token.type);
|
||||||
var tokens = session.getTokens(selection.start.row);
|
var stringAfter = !rightToken || /string/.test(rightToken.type);
|
||||||
var col = 0, token;
|
|
||||||
var quotepos = -1; // Track whether we're inside an open quote.
|
|
||||||
|
|
||||||
for (var x = 0; x < tokens.length; x++) {
|
var pair;
|
||||||
token = tokens[x];
|
if (rightChar == quote) {
|
||||||
if (token.type == "string") {
|
pair = stringBefore !== stringAfter;
|
||||||
quotepos = -1;
|
} else {
|
||||||
} else if (quotepos < 0) {
|
if (stringBefore && !stringAfter)
|
||||||
quotepos = token.value.indexOf(quote);
|
return null; // wrap string with different quote
|
||||||
}
|
if (stringBefore && stringAfter)
|
||||||
if ((token.value.length + col) > selection.start.column) {
|
return null; // do not pair quotes inside strings
|
||||||
break;
|
var wordRe = session.$mode.tokenRe;
|
||||||
}
|
wordRe.lastIndex = 0;
|
||||||
col += tokens[x].value.length;
|
var isWordBefore = wordRe.test(leftChar);
|
||||||
}
|
wordRe.lastIndex = 0;
|
||||||
|
var isWordAfter = wordRe.test(leftChar);
|
||||||
// Try and be smart about when we auto insert.
|
if (isWordBefore || isWordAfter)
|
||||||
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
|
return null; // before or after alphanumeric
|
||||||
if (!CstyleBehaviour.isSaneInsertion(editor, session))
|
if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
|
||||||
return;
|
return null; // there is rightChar and it isn't closing
|
||||||
return {
|
pair = true;
|
||||||
text: quote + quote,
|
|
||||||
selection: [1,1]
|
|
||||||
};
|
|
||||||
} else if (token && token.type === "string") {
|
|
||||||
// Ignore input and move right one if we're typing over the closing quote.
|
|
||||||
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
|
||||||
if (rightChar == quote) {
|
|
||||||
return {
|
|
||||||
text: '',
|
|
||||||
selection: [1, 1]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
|
text: pair ? quote + quote : "",
|
||||||
|
selection: [1,1]
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ var DartHighlightRules = function() {
|
||||||
|
|
||||||
var constantLanguage = "true|false|null";
|
var constantLanguage = "true|false|null";
|
||||||
var variableLanguage = "this|super";
|
var variableLanguage = "this|super";
|
||||||
var keywordControl = "try|catch|finally|throw|rethrow|assert|break|case|continue|default|do|else|for|if|in|return|switch|while|new";
|
var keywordControl = "try|catch|finally|throw|rethrow|assert|break|case|continue|default|do|else|for|if|in|return|switch|while|new|deferred|async|await";
|
||||||
var keywordDeclaration = "abstract|class|extends|external|factory|implements|get|native|operator|set|typedef|with";
|
var keywordDeclaration = "abstract|class|extends|external|factory|implements|get|native|operator|set|typedef|with|enum";
|
||||||
var storageModifier = "static|final|const";
|
var storageModifier = "static|final|const";
|
||||||
var storageType = "void|bool|num|int|double|dynamic|var|String";
|
var storageType = "void|bool|num|int|double|dynamic|var|String";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,45 +58,44 @@ var EiffelHighlightRules = function() {
|
||||||
"keyword": keywords
|
"keyword": keywords
|
||||||
}, "identifier", true);
|
}, "identifier", true);
|
||||||
|
|
||||||
|
var simpleString = /(?:[^"%\b\f\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)+?/;
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
"start": [{
|
"start": [{
|
||||||
token : "comment.line.double-dash",
|
token : "string.quoted.other", // Aligned-verbatim-strings (verbatim option not supported)
|
||||||
regex : /--.*$/
|
|
||||||
}, {
|
|
||||||
token : "string.quoted.double",
|
|
||||||
regex : /"(?:%"|[^%])*?"/
|
|
||||||
}, {
|
|
||||||
token : "string.quoted.other", // "[ ]" aligned verbatim string
|
|
||||||
regex : /"\[/,
|
regex : /"\[/,
|
||||||
next: "aligned_verbatim_string"
|
next: "aligned_verbatim_string"
|
||||||
}, {
|
}, {
|
||||||
token : "string.quoted.other", // "{ }" non-aligned verbatim string
|
token : "string.quoted.other", // Non-aligned-verbatim-strings (verbatim option not supported)
|
||||||
regex : /"\{/,
|
regex : /"\{/,
|
||||||
next: "non-aligned_verbatim_string"
|
next: "non-aligned_verbatim_string"
|
||||||
|
}, {
|
||||||
|
token : "string.quoted.double",
|
||||||
|
regex : /"(?:[^%\b\f\n\r\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)*?"/
|
||||||
|
}, {
|
||||||
|
token : "comment.line.double-dash",
|
||||||
|
regex : /--.*/
|
||||||
}, {
|
}, {
|
||||||
token : "constant.character",
|
token : "constant.character",
|
||||||
regex : /'(?:%%|%T|%R|%N|%F|%'|[^%])'/
|
regex : /'(?:[^%\b\f\n\r\t\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)'/
|
||||||
}, {
|
}, {
|
||||||
token : "constant.numeric", // real
|
token : "constant.numeric", // hexa | octal | bin
|
||||||
regex : /(?:\d(?:_?\d)*\.|\.\d)(?:\d*[eE][+-]?\d+)?\b/
|
regex : /\b0(?:[xX][\da-fA-F](?:_*[\da-fA-F])*|[cC][0-7](?:_*[0-7])*|[bB][01](?:_*[01])*)\b/
|
||||||
}, {
|
}, {
|
||||||
token : "constant.numeric", // integer
|
token : "constant.numeric",
|
||||||
regex : /\d(?:_?\d)*\b/
|
regex : /(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?[eE][+-]?)?\d(?:_*\d)*|\d(?:_*\d)*\.?/
|
||||||
}, {
|
}, {
|
||||||
token : "constant.numeric", // hex
|
token : "paren.lparen",
|
||||||
regex : /0[xX][a-fA-F\d](?:_?[a-fA-F\d])*\b/
|
regex : /[\[({]|<<|\|\(/
|
||||||
}, {
|
}, {
|
||||||
token : "constant.numeric", // octal
|
token : "paren.rparen",
|
||||||
regex : /0[cC][0-7](?:_?[0-7])*\b/
|
regex : /[\])}]|>>|\|\)/
|
||||||
},{
|
|
||||||
token : "constant.numeric", // bin
|
|
||||||
regex : /0[bB][01](?:_?[01])*\b/
|
|
||||||
}, {
|
|
||||||
token : "keyword.operator",
|
|
||||||
regex : /\+|\-|\*|\/|\\\\|\/\/|\^|~|\/~|<|>|<=|>=|\/=|=|:=|\|\.\.\||\.\./
|
|
||||||
}, {
|
}, {
|
||||||
token : "keyword.operator", // punctuation
|
token : "keyword.operator", // punctuation
|
||||||
regex : /\.|:|,|;\b/
|
regex : /:=|->|\.(?=\w)|[;,:?]/
|
||||||
|
}, {
|
||||||
|
token : "keyword.operator",
|
||||||
|
regex : /\\\\|\|\.\.\||\.\.|\/[~\/]?|[><\/]=?|[-+*^=~]/
|
||||||
}, {
|
}, {
|
||||||
token : function (v) {
|
token : function (v) {
|
||||||
var result = keywordMapper (v);
|
var result = keywordMapper (v);
|
||||||
|
|
@ -106,33 +105,27 @@ var EiffelHighlightRules = function() {
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
regex : /[a-zA-Z][a-zA-Z\d_]*\b/
|
regex : /[a-zA-Z][a-zA-Z\d_]*\b/
|
||||||
}, {
|
|
||||||
token : "paren.lparen",
|
|
||||||
regex : /[\[({]/
|
|
||||||
}, {
|
|
||||||
token : "paren.rparen",
|
|
||||||
regex : /[\])}]/
|
|
||||||
}, {
|
}, {
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : /\s+/
|
regex : /\s+/
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aligned_verbatim_string" : [{
|
"aligned_verbatim_string" : [{
|
||||||
token : "string", // closing multi-line comment
|
token : "string",
|
||||||
regex : /]"/,
|
regex : /]"/,
|
||||||
next : "start"
|
next : "start"
|
||||||
}, {
|
}, {
|
||||||
token : "string", // comment spanning whole line
|
token : "string",
|
||||||
regex : /[^(?:\]")]+/
|
regex : simpleString
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"non-aligned_verbatim_string" : [{
|
"non-aligned_verbatim_string" : [{
|
||||||
token : "string.quoted.other", // closing multi-line comment
|
token : "string.quoted.other",
|
||||||
regex : /}"/,
|
regex : /}"/,
|
||||||
next : "start"
|
next : "start"
|
||||||
}, {
|
}, {
|
||||||
token : "string.quoted.other", // comment spanning whole line
|
token : "string.quoted.other",
|
||||||
regex : /[^(?:\}")]+/
|
regex : simpleString
|
||||||
}
|
}
|
||||||
]};
|
]};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,8 @@ oop.inherits(FoldMode, CFoldMode);
|
||||||
var maxRow = session.getLength();
|
var maxRow = session.getLength();
|
||||||
var startRow = row;
|
var startRow = row;
|
||||||
|
|
||||||
var re = /^\s*#(end)?region\b/
|
var re = /^\s*#(end)?region\b/;
|
||||||
var depth = 1
|
var depth = 1;
|
||||||
while (++row < maxRow) {
|
while (++row < maxRow) {
|
||||||
line = session.getLine(row);
|
line = session.getLine(row);
|
||||||
var m = re.exec(line);
|
var m = re.exec(line);
|
||||||
|
|
@ -128,8 +128,7 @@ oop.inherits(FoldMode, CFoldMode);
|
||||||
|
|
||||||
var endRow = row;
|
var endRow = row;
|
||||||
if (endRow > startRow) {
|
if (endRow > startRow) {
|
||||||
var endColumn = line.search(/\S/);
|
return new Range(startRow, startColumn, endRow, line.length);
|
||||||
return new Range(startRow, startColumn, endRow, endColumn);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,48 @@ oop.inherits(FoldMode, BaseFoldMode);
|
||||||
|
|
||||||
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
|
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
|
||||||
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
|
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
|
||||||
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||||
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||||
|
this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
|
||||||
|
|
||||||
|
//prevent naming conflict with any modes that inherit from cstyle and override this (like csharp)
|
||||||
|
this._getFoldWidgetBase = this.getFoldWidget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets fold widget with some non-standard extras:
|
||||||
|
*
|
||||||
|
* @example lineCommentRegionStart
|
||||||
|
* //#region [optional description]
|
||||||
|
*
|
||||||
|
* @example blockCommentRegionStart
|
||||||
|
* /*#region [optional description] *[/]
|
||||||
|
*
|
||||||
|
* @example tripleStarFoldingSection
|
||||||
|
* /*** this folds even though 1 line because it has 3 stars ***[/]
|
||||||
|
*/
|
||||||
|
this.getFoldWidget = function(session, foldStyle, row) {
|
||||||
|
var line = session.getLine(row);
|
||||||
|
|
||||||
|
if (this.singleLineBlockCommentRe.test(line)) {
|
||||||
|
// No widget for single line block comment unless region or triple star
|
||||||
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||||
|
|
||||||
|
if (!fw && this.startRegionRe.test(line))
|
||||||
|
return "start"; // lineCommentRegionStart
|
||||||
|
|
||||||
|
return fw;
|
||||||
|
};
|
||||||
|
|
||||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||||
var line = session.getLine(row);
|
var line = session.getLine(row);
|
||||||
|
|
||||||
|
if (this.startRegionRe.test(line))
|
||||||
|
return this.getCommentRegionBlock(session, line, row);
|
||||||
|
|
||||||
var match = line.match(this.foldingStartMarker);
|
var match = line.match(this.foldingStartMarker);
|
||||||
if (match) {
|
if (match) {
|
||||||
var i = match.index;
|
var i = match.index;
|
||||||
|
|
@ -119,6 +158,29 @@ oop.inherits(FoldMode, BaseFoldMode);
|
||||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.getCommentRegionBlock = function(session, line, row) {
|
||||||
|
var startColumn = line.search(/\s*$/);
|
||||||
|
var maxRow = session.getLength();
|
||||||
|
var startRow = row;
|
||||||
|
|
||||||
|
var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
|
||||||
|
var depth = 1;
|
||||||
|
while (++row < maxRow) {
|
||||||
|
line = session.getLine(row);
|
||||||
|
var m = re.exec(line);
|
||||||
|
if (!m) continue;
|
||||||
|
if (m[1]) depth--;
|
||||||
|
else depth++;
|
||||||
|
|
||||||
|
if (!depth) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var endRow = row;
|
||||||
|
if (endRow > startRow) {
|
||||||
|
return new Range(startRow, startColumn, endRow, line.length);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}).call(FoldMode.prototype);
|
}).call(FoldMode.prototype);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,30 @@ module.exports = {
|
||||||
|
|
||||||
assert.range(session.getFoldWidgetRange(0), 0, 5, 5, 0);
|
assert.range(session.getFoldWidgetRange(0), 0, 5, 5, 0);
|
||||||
assert.range(session.getFoldWidgetRange(5), 0, 5, 5, 0);
|
assert.range(session.getFoldWidgetRange(5), 0, 5, 5, 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test: fold multiple nested optional elements": function() {
|
||||||
|
var session = new EditSession([
|
||||||
|
'<p>',
|
||||||
|
'<li>',
|
||||||
|
'<p>juhu',
|
||||||
|
'<p>',
|
||||||
|
'kinners',
|
||||||
|
'</li>'
|
||||||
|
]);
|
||||||
|
|
||||||
|
var mode = new HtmlMode();
|
||||||
|
session.setMode(mode);
|
||||||
|
session.setFoldStyle("markbeginend");
|
||||||
|
|
||||||
|
assert.equal(session.getFoldWidget(0), "start");
|
||||||
|
assert.equal(session.getFoldWidget(1), "start");
|
||||||
|
assert.equal(session.getFoldWidget(2), "start");
|
||||||
|
assert.equal(session.getFoldWidget(3), "start");
|
||||||
|
assert.equal(session.getFoldWidget(4), "");
|
||||||
|
assert.equal(session.getFoldWidget(5), "end");
|
||||||
|
|
||||||
|
assert.range(session.getFoldWidgetRange(1), 1, 4, 5, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,9 +192,6 @@ function is(token, type) {
|
||||||
if (!tag || top.tagName == tag.tagName) {
|
if (!tag || top.tagName == tag.tagName) {
|
||||||
return stack.pop();
|
return stack.pop();
|
||||||
}
|
}
|
||||||
else if (this.optionalEndTags.hasOwnProperty(tag.tagName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
|
else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
|
||||||
stack.pop();
|
stack.pop();
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ var LatexHighlightRules = function() {
|
||||||
}, {
|
}, {
|
||||||
// A label
|
// A label
|
||||||
token : ["keyword","lparen", "variable.parameter", "rparen"],
|
token : ["keyword","lparen", "variable.parameter", "rparen"],
|
||||||
regex : "(\\\\label)(?:({)([^}]*)(}))?"
|
regex : "(\\\\(?:label|v?ref|cite(?:[^{]*)))(?:({)([^}]*)(}))?"
|
||||||
}, {
|
}, {
|
||||||
// A block
|
// A block
|
||||||
token : ["storage.type", "lparen", "variable.parameter", "rparen"],
|
token : ["storage.type", "lparen", "variable.parameter", "rparen"],
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Distributed under the BSD license:
|
* Distributed under the BSD license:
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
* Copyright (c) 2014, Ajax.org B.V.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -28,67 +28,57 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
"use strict"
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
module.exports = {
|
"use strict";
|
||||||
"x": {
|
|
||||||
operator: {
|
|
||||||
ch: "d",
|
|
||||||
count: 1
|
|
||||||
},
|
|
||||||
motion: {
|
|
||||||
ch: "l",
|
|
||||||
count: 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"X": {
|
|
||||||
operator: {
|
|
||||||
ch: "d",
|
|
||||||
count: 1
|
|
||||||
},
|
|
||||||
motion: {
|
|
||||||
ch: "h",
|
|
||||||
count: 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"D": {
|
|
||||||
operator: {
|
|
||||||
ch: "d",
|
|
||||||
count: 1
|
|
||||||
},
|
|
||||||
motion: {
|
|
||||||
ch: "$",
|
|
||||||
count: 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"C": {
|
|
||||||
operator: {
|
|
||||||
ch: "c",
|
|
||||||
count: 1
|
|
||||||
},
|
|
||||||
motion: {
|
|
||||||
ch: "$",
|
|
||||||
count: 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"s": {
|
|
||||||
operator: {
|
|
||||||
ch: "c",
|
|
||||||
count: 1
|
|
||||||
},
|
|
||||||
motion: {
|
|
||||||
ch: "l",
|
|
||||||
count: 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"S": {
|
|
||||||
operator: {
|
|
||||||
ch: "c",
|
|
||||||
count: 1
|
|
||||||
},
|
|
||||||
param: "c"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
|
var oop = require("../lib/oop");
|
||||||
|
var TextMode = require("./text").Mode;
|
||||||
|
var MaskHighlightRules = require("./mask_highlight_rules").MaskHighlightRules;
|
||||||
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||||
|
var CssBehaviour = require("./behaviour/css").CssBehaviour;
|
||||||
|
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||||
|
|
||||||
|
var Mode = function() {
|
||||||
|
this.HighlightRules = MaskHighlightRules;
|
||||||
|
this.$outdent = new MatchingBraceOutdent();
|
||||||
|
this.$behaviour = new CssBehaviour();
|
||||||
|
this.foldingRules = new CStyleFoldMode();
|
||||||
|
};
|
||||||
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = "//";
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
|
// ignore braces in comments
|
||||||
|
var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
|
||||||
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
|
return indent;
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = line.match(/^.*\{\s*$/);
|
||||||
|
if (match) {
|
||||||
|
indent += tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
return indent;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.checkOutdent = function(state, line, input) {
|
||||||
|
return this.$outdent.checkOutdent(line, input);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.autoOutdent = function(state, doc, row) {
|
||||||
|
this.$outdent.autoOutdent(doc, row);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$id = "ace/mode/mask";
|
||||||
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
exports.Mode = Mode;
|
||||||
|
|
||||||
|
});
|
||||||
309
lib/ace/mode/mask_highlight_rules.js
Normal file
309
lib/ace/mode/mask_highlight_rules.js
Normal file
|
|
@ -0,0 +1,309 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Distributed under the BSD license:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Ajax.org B.V.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of Ajax.org B.V. nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports.MaskHighlightRules = MaskHighlightRules;
|
||||||
|
|
||||||
|
var oop = require("../lib/oop");
|
||||||
|
var lang = require("../lib/lang");
|
||||||
|
var TextRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
var JSRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
||||||
|
var CssRules = require("./css_highlight_rules").CssHighlightRules;
|
||||||
|
var MDRules = require("./markdown_highlight_rules").MarkdownHighlightRules;
|
||||||
|
var HTMLRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||||
|
|
||||||
|
var token_TAG = "keyword.support.constant.language",
|
||||||
|
token_COMPO = "support.function.markup.bold",
|
||||||
|
token_KEYWORD = "keyword",
|
||||||
|
token_LANG = "constant.language",
|
||||||
|
token_UTIL = "keyword.control.markup.italic",
|
||||||
|
token_ATTR = "support.variable.class",
|
||||||
|
token_PUNKT = "keyword.operator",
|
||||||
|
token_ITALIC = "markup.italic",
|
||||||
|
token_BOLD = "markup.bold",
|
||||||
|
token_LPARE = "paren.lparen",
|
||||||
|
token_RPARE = "paren.rparen";
|
||||||
|
|
||||||
|
var const_FUNCTIONS,
|
||||||
|
const_KEYWORDS,
|
||||||
|
const_CONST,
|
||||||
|
const_TAGS;
|
||||||
|
(function(){
|
||||||
|
const_FUNCTIONS = lang.arrayToMap(
|
||||||
|
("log").split("|")
|
||||||
|
);
|
||||||
|
const_CONST = lang.arrayToMap(
|
||||||
|
(":dualbind|:bind|:import|slot|event|style|html|markdown|md").split("|")
|
||||||
|
);
|
||||||
|
const_KEYWORDS = lang.arrayToMap(
|
||||||
|
("debugger|define|var|if|each|for|of|else|switch|case|with|visible|+if|+each|+for|+switch|+with|+visible|include|import").split("|")
|
||||||
|
);
|
||||||
|
const_TAGS = lang.arrayToMap(
|
||||||
|
("a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdo|" +
|
||||||
|
"big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|" +
|
||||||
|
"command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|" +
|
||||||
|
"figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|" +
|
||||||
|
"header|hgroup|hr|html|i|iframe|img|input|ins|keygen|kbd|label|legend|li|" +
|
||||||
|
"link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|" +
|
||||||
|
"option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|" +
|
||||||
|
"small|source|span|strike|strong|style|sub|summary|sup|table|tbody|td|" +
|
||||||
|
"textarea|tfoot|th|thead|time|title|tr|tt|u|ul|var|video|wbr|xmp").split("|")
|
||||||
|
);
|
||||||
|
}());
|
||||||
|
|
||||||
|
function MaskHighlightRules () {
|
||||||
|
|
||||||
|
this.$rules = {
|
||||||
|
"start" : [
|
||||||
|
Token("comment", "\\/\\/.*$"),
|
||||||
|
Token("comment", "\\/\\*", [
|
||||||
|
Token("comment", ".*?\\*\\/", "start"),
|
||||||
|
Token("comment", ".+")
|
||||||
|
]),
|
||||||
|
|
||||||
|
Blocks.string("'''"),
|
||||||
|
Blocks.string('"""'),
|
||||||
|
Blocks.string('"'),
|
||||||
|
Blocks.string("'"),
|
||||||
|
|
||||||
|
Blocks.syntax(/(markdown|md)\b/, "md-multiline", "multiline"),
|
||||||
|
Blocks.syntax(/html\b/, "html-multiline", "multiline"),
|
||||||
|
Blocks.syntax(/(slot|event)\b/, "js-block", "block"),
|
||||||
|
Blocks.syntax(/style\b/, "css-block", "block"),
|
||||||
|
Blocks.syntax(/var\b/, "js-statement", "attr"),
|
||||||
|
|
||||||
|
Blocks.tag(),
|
||||||
|
|
||||||
|
Token(token_LPARE, "[[({>]"),
|
||||||
|
Token(token_RPARE, "[\\])};]", "start"),
|
||||||
|
{
|
||||||
|
caseInsensitive: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
var rules = this;
|
||||||
|
|
||||||
|
addJavaScript("interpolation", /\]/, token_RPARE + "." + token_ITALIC);
|
||||||
|
addJavaScript("statement", /\)|}|;/);
|
||||||
|
addJavaScript("block", /\}/);
|
||||||
|
addCss();
|
||||||
|
addMarkdown();
|
||||||
|
addHtml();
|
||||||
|
|
||||||
|
function addJavaScript(name, escape, closeType) {
|
||||||
|
var prfx = "js-" + name + "-",
|
||||||
|
rootTokens = name === "block" ? ["start"] : ["start", "no_regex"];
|
||||||
|
add(
|
||||||
|
JSRules
|
||||||
|
, prfx
|
||||||
|
, escape
|
||||||
|
, rootTokens
|
||||||
|
, closeType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function addCss() {
|
||||||
|
add(CssRules, "css-block-", /\}/);
|
||||||
|
}
|
||||||
|
function addMarkdown() {
|
||||||
|
add(MDRules, "md-multiline-", /("""|''')/, []);
|
||||||
|
}
|
||||||
|
function addHtml() {
|
||||||
|
add(HTMLRules, "html-multiline-", /("""|''')/);
|
||||||
|
}
|
||||||
|
function add(Rules, strPrfx, rgxEnd, rootTokens, closeType) {
|
||||||
|
var next = "pop";
|
||||||
|
var tokens = rootTokens || [ "start" ];
|
||||||
|
if (tokens.length === 0) {
|
||||||
|
tokens = null;
|
||||||
|
}
|
||||||
|
if (/block|multiline/.test(strPrfx)) {
|
||||||
|
next = strPrfx + "end";
|
||||||
|
rules.$rules[next] = [
|
||||||
|
Token("empty", "", "start")
|
||||||
|
];
|
||||||
|
}
|
||||||
|
rules.embedRules(
|
||||||
|
Rules
|
||||||
|
, strPrfx
|
||||||
|
, [ Token(closeType || token_RPARE, rgxEnd, next) ]
|
||||||
|
, tokens
|
||||||
|
, tokens == null ? true : false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.normalizeRules();
|
||||||
|
}
|
||||||
|
oop.inherits(MaskHighlightRules, TextRules);
|
||||||
|
|
||||||
|
var Blocks = {
|
||||||
|
string: function(str, next){
|
||||||
|
var token = Token(
|
||||||
|
"string.start"
|
||||||
|
, str
|
||||||
|
, [
|
||||||
|
Token(token_LPARE + "." + token_ITALIC, /~\[/, Blocks.interpolation()),
|
||||||
|
Token("string.end", str, "pop"),
|
||||||
|
{
|
||||||
|
defaultToken: "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
, next
|
||||||
|
);
|
||||||
|
if (str.length === 1){
|
||||||
|
var escaped = Token("string.escape", "\\\\" + str);
|
||||||
|
token.push.unshift(escaped);
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
},
|
||||||
|
interpolation: function(){
|
||||||
|
return [
|
||||||
|
Token(token_UTIL, /\s*\w*\s*:/),
|
||||||
|
"js-interpolation-start"
|
||||||
|
];
|
||||||
|
},
|
||||||
|
tagHead: function (rgx) {
|
||||||
|
return Token(token_ATTR, rgx, [
|
||||||
|
Token(token_ATTR, /[\w\-_]+/),
|
||||||
|
Token(token_LPARE + "." + token_ITALIC, /~\[/, Blocks.interpolation()),
|
||||||
|
Blocks.goUp()
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
tag: function () {
|
||||||
|
return {
|
||||||
|
token: 'tag',
|
||||||
|
onMatch : function(value) {
|
||||||
|
if (void 0 !== const_KEYWORDS[value])
|
||||||
|
return token_KEYWORD;
|
||||||
|
if (void 0 !== const_CONST[value])
|
||||||
|
return token_LANG;
|
||||||
|
if (void 0 !== const_FUNCTIONS[value])
|
||||||
|
return "support.function";
|
||||||
|
if (void 0 !== const_TAGS[value.toLowerCase()])
|
||||||
|
return token_TAG;
|
||||||
|
|
||||||
|
return token_COMPO;
|
||||||
|
},
|
||||||
|
regex : /([@\w\-_:+]+)|((^|\s)(?=\s*(\.|#)))/,
|
||||||
|
push: [
|
||||||
|
Blocks.tagHead(/\./) ,
|
||||||
|
Blocks.tagHead(/\#/) ,
|
||||||
|
Blocks.expression(),
|
||||||
|
Blocks.attribute(),
|
||||||
|
|
||||||
|
Token(token_LPARE, /[;>{]/, "pop")
|
||||||
|
]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
syntax: function(rgx, next, type){
|
||||||
|
return {
|
||||||
|
token: token_LANG,
|
||||||
|
regex : rgx,
|
||||||
|
push: ({
|
||||||
|
"attr": [
|
||||||
|
next + "-start",
|
||||||
|
Token(token_PUNKT, /;/, "start")
|
||||||
|
],
|
||||||
|
"multiline": [
|
||||||
|
Blocks.tagHead(/\./) ,
|
||||||
|
Blocks.tagHead(/\#/) ,
|
||||||
|
Blocks.attribute(),
|
||||||
|
Blocks.expression(),
|
||||||
|
Token(token_LPARE, /[>\{]/),
|
||||||
|
Token(token_PUNKT, /;/, "start"),
|
||||||
|
Token(token_LPARE, /'''|"""/, [ next + "-start" ])
|
||||||
|
],
|
||||||
|
"block": [
|
||||||
|
Blocks.tagHead(/\./) ,
|
||||||
|
Blocks.tagHead(/\#/) ,
|
||||||
|
Blocks.attribute(),
|
||||||
|
Blocks.expression(),
|
||||||
|
Token(token_LPARE, /\{/, [ next + "-start" ])
|
||||||
|
]
|
||||||
|
})[type]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
attribute: function(){
|
||||||
|
return Token(function(value){
|
||||||
|
return /^x\-/.test(value)
|
||||||
|
? token_ATTR + "." + token_BOLD
|
||||||
|
: token_ATTR;
|
||||||
|
}, /[\w_-]+/, [
|
||||||
|
Token(token_PUNKT, /\s*=\s*/, [
|
||||||
|
Blocks.string('"'),
|
||||||
|
Blocks.string("'"),
|
||||||
|
Blocks.word(),
|
||||||
|
Blocks.goUp()
|
||||||
|
]),
|
||||||
|
Blocks.goUp()
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
expression: function(){
|
||||||
|
return Token(token_LPARE, /\(/, [ "js-statement-start" ]);
|
||||||
|
},
|
||||||
|
word: function(){
|
||||||
|
return Token("string", /[\w-_]+/);
|
||||||
|
},
|
||||||
|
goUp: function(){
|
||||||
|
return Token("text", "", "pop");
|
||||||
|
},
|
||||||
|
goStart: function(){
|
||||||
|
return Token("text", "", "start");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function Token(token, rgx, mix) {
|
||||||
|
var push, next, onMatch;
|
||||||
|
if (arguments.length === 4) {
|
||||||
|
push = mix;
|
||||||
|
next = arguments[3];
|
||||||
|
}
|
||||||
|
else if (typeof mix === "string") {
|
||||||
|
next = mix;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
push = mix;
|
||||||
|
}
|
||||||
|
if (typeof token === "function") {
|
||||||
|
onMatch = token;
|
||||||
|
token = "empty";
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
token: token,
|
||||||
|
regex: rgx,
|
||||||
|
push: push,
|
||||||
|
next: next,
|
||||||
|
onMatch: onMatch
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -55,6 +55,24 @@ oop.inherits(PhpMode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.tokenRe = new RegExp("^["
|
||||||
|
+ unicode.packages.L
|
||||||
|
+ unicode.packages.Mn + unicode.packages.Mc
|
||||||
|
+ unicode.packages.Nd
|
||||||
|
+ unicode.packages.Pc + "\_]+", "g"
|
||||||
|
);
|
||||||
|
|
||||||
|
this.nonTokenRe = new RegExp("^(?:[^"
|
||||||
|
+ unicode.packages.L
|
||||||
|
+ unicode.packages.Mn + unicode.packages.Mc
|
||||||
|
+ unicode.packages.Nd
|
||||||
|
+ unicode.packages.Pc + "\_]|\s])+", "g"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
this.lineCommentStart = ["//", "#"];
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
|
|
@ -100,8 +118,10 @@ oop.inherits(PhpMode, TextMode);
|
||||||
|
|
||||||
var Mode = function(opts) {
|
var Mode = function(opts) {
|
||||||
if (opts && opts.inline) {
|
if (opts && opts.inline) {
|
||||||
PhpMode.call(this);
|
var mode = new PhpMode();
|
||||||
return;
|
mode.createWorker = this.createWorker;
|
||||||
|
mode.inlinePhp = true;
|
||||||
|
return mode;
|
||||||
}
|
}
|
||||||
HtmlMode.call(this);
|
HtmlMode.call(this);
|
||||||
this.HighlightRules = PhpHighlightRules;
|
this.HighlightRules = PhpHighlightRules;
|
||||||
|
|
@ -110,29 +130,12 @@ var Mode = function(opts) {
|
||||||
"css-": CssMode,
|
"css-": CssMode,
|
||||||
"php-": PhpMode
|
"php-": PhpMode
|
||||||
});
|
});
|
||||||
|
this.foldingRules.subModes["php-"] = new CStyleFoldMode();
|
||||||
};
|
};
|
||||||
oop.inherits(Mode, HtmlMode);
|
oop.inherits(Mode, HtmlMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.tokenRe = new RegExp("^["
|
|
||||||
+ unicode.packages.L
|
|
||||||
+ unicode.packages.Mn + unicode.packages.Mc
|
|
||||||
+ unicode.packages.Nd
|
|
||||||
+ unicode.packages.Pc + "\_]+", "g"
|
|
||||||
);
|
|
||||||
|
|
||||||
this.nonTokenRe = new RegExp("^(?:[^"
|
|
||||||
+ unicode.packages.L
|
|
||||||
+ unicode.packages.Mn + unicode.packages.Mc
|
|
||||||
+ unicode.packages.Nd
|
|
||||||
+ unicode.packages.Pc + "\_]|\s])+", "g"
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
this.lineCommentStart = ["//", "#"];
|
|
||||||
this.blockComment = {start: "/*", end: "*/"};
|
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker");
|
var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker");
|
||||||
worker.attachToDocument(session.getDocument());
|
worker.attachToDocument(session.getDocument());
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({
|
module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({
|
||||||
1:[function(_dereq_,module,exports){
|
1:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var init = function(that, code, message, pos, type){
|
var init = function(that, code, message, pos, type){
|
||||||
|
|
@ -43,11 +43,11 @@ exports.StaticWarning = StaticWarning.prototype.constructor = function(code, mes
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{}],
|
{}],
|
||||||
2:[function(_dereq_,module,exports){
|
2:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var TreeOps = _dereq_('../tree_ops').TreeOps;
|
var TreeOps = require('../tree_ops').TreeOps;
|
||||||
var Errors = _dereq_('./errors');
|
var Errors = require('./errors');
|
||||||
var StaticWarning = Errors.StaticWarning;
|
var StaticWarning = Errors.StaticWarning;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -216,7 +216,7 @@ exports.FunctionCallHandler = function(translator, sctx, node, arity){
|
||||||
*/
|
*/
|
||||||
},
|
},
|
||||||
{"../tree_ops":11,"./errors":1}],
|
{"../tree_ops":11,"./errors":1}],
|
||||||
3:[function(_dereq_,module,exports){
|
3:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -276,17 +276,17 @@ exports.getSchemaBuiltinTypes = function(){
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{}],
|
{}],
|
||||||
4:[function(_dereq_,module,exports){
|
4:[function(require,module,exports){
|
||||||
exports.StaticContext = function (parent, pos) {
|
exports.StaticContext = function (parent, pos) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var TreeOps = _dereq_('../tree_ops').TreeOps;
|
var TreeOps = require('../tree_ops').TreeOps;
|
||||||
|
|
||||||
var Errors = _dereq_('./errors');
|
var Errors = require('./errors');
|
||||||
var StaticError = Errors.StaticError;
|
var StaticError = Errors.StaticError;
|
||||||
var StaticWarning = Errors.StaticWarning;
|
var StaticWarning = Errors.StaticWarning;
|
||||||
|
|
||||||
var getSchemaBuiltinTypes = _dereq_('./schema_built-in_types').getSchemaBuiltinTypes;
|
var getSchemaBuiltinTypes = require('./schema_built-in_types').getSchemaBuiltinTypes;
|
||||||
|
|
||||||
var emptyPos = { sl:0, sc: 0, el: 0, ec: 0 };
|
var emptyPos = { sl:0, sc: 0, el: 0, ec: 0 };
|
||||||
var namespaces = {};
|
var namespaces = {};
|
||||||
|
|
@ -725,17 +725,17 @@ exports.StaticContext = function (parent, pos) {
|
||||||
|
|
||||||
},
|
},
|
||||||
{"../tree_ops":11,"./errors":1,"./schema_built-in_types":3}],
|
{"../tree_ops":11,"./errors":1,"./schema_built-in_types":3}],
|
||||||
5:[function(_dereq_,module,exports){
|
5:[function(require,module,exports){
|
||||||
exports.Translator = function(rootStcx, ast){
|
exports.Translator = function(rootStcx, ast){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Errors = _dereq_('./errors');
|
var Errors = require('./errors');
|
||||||
var StaticError = Errors.StaticError;
|
var StaticError = Errors.StaticError;
|
||||||
var StaticWarning = Errors.StaticWarning;
|
var StaticWarning = Errors.StaticWarning;
|
||||||
|
|
||||||
var TreeOps = _dereq_('../tree_ops').TreeOps;
|
var TreeOps = require('../tree_ops').TreeOps;
|
||||||
var StaticContext = _dereq_('./static_context').StaticContext;
|
var StaticContext = require('./static_context').StaticContext;
|
||||||
var Handlers = _dereq_('./handlers');
|
var Handlers = require('./handlers');
|
||||||
|
|
||||||
var get = function(node, path){
|
var get = function(node, path){
|
||||||
var result = [];
|
var result = [];
|
||||||
|
|
@ -1178,7 +1178,7 @@ exports.Translator = function(rootStcx, ast){
|
||||||
pushSctx(node.pos);
|
pushSctx(node.pos);
|
||||||
quantifiedDecls.push(0);
|
quantifiedDecls.push(0);
|
||||||
this.visitChildren(node);
|
this.visitChildren(node);
|
||||||
for(var i=1; i <= quantifiedDecls[clauses.length - 1]; i++) {
|
for(var i=1; i <= quantifiedDecls[quantifiedDecls.length - 1]; i++) {
|
||||||
popSctx(node.pos);
|
popSctx(node.pos);
|
||||||
}
|
}
|
||||||
quantifiedDecls.pop();
|
quantifiedDecls.pop();
|
||||||
|
|
@ -1305,10 +1305,10 @@ exports.Translator = function(rootStcx, ast){
|
||||||
|
|
||||||
},
|
},
|
||||||
{"../tree_ops":11,"./errors":1,"./handlers":2,"./static_context":4}],
|
{"../tree_ops":11,"./errors":1,"./handlers":2,"./static_context":4}],
|
||||||
6:[function(_dereq_,module,exports){
|
6:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var TreeOps = _dereq_('../tree_ops').TreeOps;
|
var TreeOps = require('../tree_ops').TreeOps;
|
||||||
|
|
||||||
var ID_REGEX = /[a-zA-Z_0-9\$]/;
|
var ID_REGEX = /[a-zA-Z_0-9\$]/;
|
||||||
|
|
||||||
|
|
@ -1561,7 +1561,7 @@ exports.complete = function(source, ast, rootSctx, pos){
|
||||||
|
|
||||||
},
|
},
|
||||||
{"../tree_ops":11}],
|
{"../tree_ops":11}],
|
||||||
7:[function(_dereq_,module,exports){
|
7:[function(require,module,exports){
|
||||||
exports.StyleChecker = function (ast, source) {
|
exports.StyleChecker = function (ast, source) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
@ -1690,7 +1690,7 @@ exports.StyleChecker = function (ast, source) {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{}],
|
{}],
|
||||||
8:[function(_dereq_,module,exports){
|
8:[function(require,module,exports){
|
||||||
exports.JSONParseTreeHandler = function (code) {
|
exports.JSONParseTreeHandler = function (code) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
@ -1856,7 +1856,7 @@ exports.JSONParseTreeHandler = function (code) {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{}],
|
{}],
|
||||||
9:[function(_dereq_,module,exports){
|
9:[function(require,module,exports){
|
||||||
// This file was generated on Thu Jul 24, 2014 15:00 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
|
// This file was generated on Thu Jul 24, 2014 15:00 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
|
||||||
// REx command line: JSONiqParser.ebnf -ll 2 -backtrack -tree -javascript -a xqlint
|
// REx command line: JSONiqParser.ebnf -ll 2 -backtrack -tree -javascript -a xqlint
|
||||||
|
|
||||||
|
|
@ -44140,7 +44140,7 @@ JSONiqParser.TOKEN =
|
||||||
|
|
||||||
},
|
},
|
||||||
{}],
|
{}],
|
||||||
10:[function(_dereq_,module,exports){
|
10:[function(require,module,exports){
|
||||||
// This file was generated on Thu Jul 24, 2014 15:00 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
|
// This file was generated on Thu Jul 24, 2014 15:00 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
|
||||||
// REx command line: XQueryParser.ebnf -ll 2 -backtrack -tree -javascript -a xqlint
|
// REx command line: XQueryParser.ebnf -ll 2 -backtrack -tree -javascript -a xqlint
|
||||||
|
|
||||||
|
|
@ -78693,7 +78693,7 @@ XQueryParser.TOKEN =
|
||||||
|
|
||||||
},
|
},
|
||||||
{}],
|
{}],
|
||||||
11:[function(_dereq_,module,exports){
|
11:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
exports.TreeOps = {
|
exports.TreeOps = {
|
||||||
|
|
@ -78786,18 +78786,18 @@ exports.TreeOps = {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{}],
|
{}],
|
||||||
12:[function(_dereq_,module,exports){
|
12:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var JSONiqParser = _dereq_('./parsers/JSONiqParser').JSONiqParser;
|
var JSONiqParser = require('./parsers/JSONiqParser').JSONiqParser;
|
||||||
var XQueryParser = _dereq_('./parsers/XQueryParser').XQueryParser;
|
var XQueryParser = require('./parsers/XQueryParser').XQueryParser;
|
||||||
var JSONParseTreeHandler = _dereq_('./parsers/JSONParseTreeHandler').JSONParseTreeHandler;
|
var JSONParseTreeHandler = require('./parsers/JSONParseTreeHandler').JSONParseTreeHandler;
|
||||||
var Translator = _dereq_('./compiler/translator').Translator;
|
var Translator = require('./compiler/translator').Translator;
|
||||||
var StyleChecker = _dereq_('./formatter/style_checker').StyleChecker;
|
var StyleChecker = require('./formatter/style_checker').StyleChecker;
|
||||||
var completer = _dereq_('../lib/completion/completer');
|
var completer = require('../lib/completion/completer');
|
||||||
|
|
||||||
var createStaticContext = exports.createStaticContext = function(){
|
var createStaticContext = exports.createStaticContext = function(){
|
||||||
var StaticContext = _dereq_('./compiler/static_context').StaticContext;
|
var StaticContext = require('./compiler/static_context').StaticContext;
|
||||||
return new StaticContext();
|
return new StaticContext();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -78906,7 +78906,6 @@ exports.XQLint = function (source, opts) {
|
||||||
};
|
};
|
||||||
|
|
||||||
},
|
},
|
||||||
{"../lib/completion/completer":6,"./compiler/static_context":4,"./compiler/translator":5,"./formatter/style_checker":7,"./parsers/JSONParseTreeHandler":8,"./parsers/JSONiqParser":9,"./parsers/XQueryParser":10}]},{},[12])
|
{"../lib/completion/completer":6,"./compiler/static_context":4,"./compiler/translator":5,"./formatter/style_checker":7,"./parsers/JSONParseTreeHandler":8,"./parsers/JSONiqParser":9,"./parsers/XQueryParser":10}]},{},[12])(12)
|
||||||
(12)
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -35,7 +35,6 @@ var oop = require("../lib/oop");
|
||||||
var Mirror = require("../worker/mirror").Mirror;
|
var Mirror = require("../worker/mirror").Mirror;
|
||||||
var XQLintLib = require("./xquery/xqlint");
|
var XQLintLib = require("./xquery/xqlint");
|
||||||
var XQLint = XQLintLib.XQLint;
|
var XQLint = XQLintLib.XQLint;
|
||||||
var Modules = require("./xquery/modules").Modules;
|
|
||||||
|
|
||||||
var getModuleResolverFromModules = function(modules){
|
var getModuleResolverFromModules = function(modules){
|
||||||
return function(uri){
|
return function(uri){
|
||||||
|
|
@ -68,8 +67,8 @@ var XQueryWorker = exports.XQueryWorker = function(sender) {
|
||||||
this.opts = {
|
this.opts = {
|
||||||
styleCheck: false
|
styleCheck: false
|
||||||
};
|
};
|
||||||
this.availableModuleNamespaces = Object.keys(Modules);
|
//this.availableModuleNamespaces = Object.keys(Modules);
|
||||||
this.moduleResolver = getModuleResolverFromModules(Modules);
|
//this.moduleResolver; = getModuleResolverFromModules(Modules);
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
this.sender.on("complete", function(e){
|
this.sender.on("complete", function(e){
|
||||||
|
|
@ -105,7 +104,7 @@ oop.inherits(XQueryWorker, Mirror);
|
||||||
}
|
}
|
||||||
var opts = {
|
var opts = {
|
||||||
styleCheck: this.styleCheck,
|
styleCheck: this.styleCheck,
|
||||||
staticContext: sctx,
|
staticContext: sctx
|
||||||
};
|
};
|
||||||
this.xqlint = new XQLint(value, opts);
|
this.xqlint = new XQLint(value, opts);
|
||||||
this.sender.emit("markers", this.xqlint.getMarkers());
|
this.sender.emit("markers", this.xqlint.getMarkers());
|
||||||
|
|
|
||||||
|
|
@ -70,10 +70,10 @@ function DefaultHandlers(mouseHandler) {
|
||||||
if (button !== 0) {
|
if (button !== 0) {
|
||||||
var selectionRange = editor.getSelectionRange();
|
var selectionRange = editor.getSelectionRange();
|
||||||
var selectionEmpty = selectionRange.isEmpty();
|
var selectionEmpty = selectionRange.isEmpty();
|
||||||
|
editor.$blockScrolling++;
|
||||||
if (selectionEmpty)
|
if (selectionEmpty)
|
||||||
editor.selection.moveToPosition(pos);
|
editor.selection.moveToPosition(pos);
|
||||||
|
editor.$blockScrolling--;
|
||||||
// 2: contextmenu, 1: linux paste
|
// 2: contextmenu, 1: linux paste
|
||||||
editor.textInput.onContextMenu(ev.domEvent);
|
editor.textInput.onContextMenu(ev.domEvent);
|
||||||
return; // stopping event here breaks contextmenu on ff mac
|
return; // stopping event here breaks contextmenu on ff mac
|
||||||
|
|
@ -100,7 +100,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
|
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
|
||||||
var editor = this.editor;
|
var editor = this.editor;
|
||||||
// allow double/triple click handlers to change selection
|
// allow double/triple click handlers to change selection
|
||||||
|
editor.$blockScrolling++;
|
||||||
if (this.mousedownEvent.getShiftKey())
|
if (this.mousedownEvent.getShiftKey())
|
||||||
editor.selection.selectToPosition(pos);
|
editor.selection.selectToPosition(pos);
|
||||||
else if (!waitForClickSelection)
|
else if (!waitForClickSelection)
|
||||||
|
|
@ -112,12 +112,13 @@ function DefaultHandlers(mouseHandler) {
|
||||||
}
|
}
|
||||||
editor.setStyle("ace_selecting");
|
editor.setStyle("ace_selecting");
|
||||||
this.setState("select");
|
this.setState("select");
|
||||||
|
editor.$blockScrolling--;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.select = function() {
|
this.select = function() {
|
||||||
var anchor, editor = this.editor;
|
var anchor, editor = this.editor;
|
||||||
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
|
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
|
||||||
|
editor.$blockScrolling++;
|
||||||
if (this.$clickSelection) {
|
if (this.$clickSelection) {
|
||||||
var cmp = this.$clickSelection.comparePoint(cursor);
|
var cmp = this.$clickSelection.comparePoint(cursor);
|
||||||
|
|
||||||
|
|
@ -133,7 +134,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
|
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
|
||||||
}
|
}
|
||||||
editor.selection.selectToPosition(cursor);
|
editor.selection.selectToPosition(cursor);
|
||||||
|
editor.$blockScrolling--;
|
||||||
editor.renderer.scrollCursorIntoView();
|
editor.renderer.scrollCursorIntoView();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -141,7 +142,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
var anchor, editor = this.editor;
|
var anchor, editor = this.editor;
|
||||||
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
|
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
|
||||||
var range = editor.selection[unitName](cursor.row, cursor.column);
|
var range = editor.selection[unitName](cursor.row, cursor.column);
|
||||||
|
editor.$blockScrolling++;
|
||||||
if (this.$clickSelection) {
|
if (this.$clickSelection) {
|
||||||
var cmpStart = this.$clickSelection.comparePoint(range.start);
|
var cmpStart = this.$clickSelection.comparePoint(range.start);
|
||||||
var cmpEnd = this.$clickSelection.comparePoint(range.end);
|
var cmpEnd = this.$clickSelection.comparePoint(range.end);
|
||||||
|
|
@ -165,7 +166,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
|
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
|
||||||
}
|
}
|
||||||
editor.selection.selectToPosition(cursor);
|
editor.selection.selectToPosition(cursor);
|
||||||
|
editor.$blockScrolling--;
|
||||||
editor.renderer.scrollCursorIntoView();
|
editor.renderer.scrollCursorIntoView();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,11 @@ var MouseHandler = function(editor) {
|
||||||
new DragdropHandler(this);
|
new DragdropHandler(this);
|
||||||
|
|
||||||
var focusEditor = function(e) {
|
var focusEditor = function(e) {
|
||||||
if (!editor.isFocused() && editor.textInput)
|
// because we have to call event.preventDefault() any window on ie and iframes
|
||||||
editor.textInput.moveToMouse(e);
|
// on other browsers do not get focus, so we have to call window.focus() here
|
||||||
editor.focus()
|
if (!document.hasFocus || !document.hasFocus())
|
||||||
|
window.focus();
|
||||||
|
editor.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
var mouseTarget = editor.renderer.getMouseEventTarget();
|
var mouseTarget = editor.renderer.getMouseEventTarget();
|
||||||
|
|
@ -62,7 +64,7 @@ var MouseHandler = function(editor) {
|
||||||
event.addMultiMouseDownListener(editor.renderer.scrollBarH.inner, [400, 300, 250], this, "onMouseEvent");
|
event.addMultiMouseDownListener(editor.renderer.scrollBarH.inner, [400, 300, 250], this, "onMouseEvent");
|
||||||
if (useragent.isIE) {
|
if (useragent.isIE) {
|
||||||
event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
|
event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
|
||||||
event.addListener(editor.renderer.scrollBarH.element, "mousemove", focusEditor);
|
event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
|
event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
|
||||||
|
|
@ -84,11 +86,11 @@ var MouseHandler = function(editor) {
|
||||||
if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
|
if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var char = editor.renderer.screenToTextCoordinates(e.x, e.y);
|
var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
|
||||||
var range = editor.session.selection.getRange();
|
var range = editor.session.selection.getRange();
|
||||||
var renderer = editor.renderer;
|
var renderer = editor.renderer;
|
||||||
|
|
||||||
if (!range.isEmpty() && range.insideStart(char.row, char.column)) {
|
if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
|
||||||
renderer.setCursorStyle("default");
|
renderer.setCursorStyle("default");
|
||||||
} else {
|
} else {
|
||||||
renderer.setCursorStyle("");
|
renderer.setCursorStyle("");
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ function onMouseDown(e) {
|
||||||
return;
|
return;
|
||||||
screenCursor = newCursor;
|
screenCursor = newCursor;
|
||||||
|
|
||||||
|
editor.$blockScrolling++;
|
||||||
editor.selection.moveToPosition(cursor);
|
editor.selection.moveToPosition(cursor);
|
||||||
editor.renderer.scrollCursorIntoView();
|
editor.renderer.scrollCursorIntoView();
|
||||||
|
|
||||||
|
|
@ -160,8 +161,9 @@ function onMouseDown(e) {
|
||||||
rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
|
rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
|
||||||
rectSel.forEach(editor.addSelectionMarker, editor);
|
rectSel.forEach(editor.addSelectionMarker, editor);
|
||||||
editor.updateSelectionMarkers();
|
editor.updateSelectionMarkers();
|
||||||
|
editor.$blockScrolling--;
|
||||||
};
|
};
|
||||||
|
editor.$blockScrolling++;
|
||||||
if (isMultiSelect && !accel) {
|
if (isMultiSelect && !accel) {
|
||||||
selection.toSingleRange();
|
selection.toSingleRange();
|
||||||
} else if (!isMultiSelect && accel) {
|
} else if (!isMultiSelect && accel) {
|
||||||
|
|
@ -173,6 +175,7 @@ function onMouseDown(e) {
|
||||||
screenAnchor = session.documentToScreenPosition(selection.lead);
|
screenAnchor = session.documentToScreenPosition(selection.lead);
|
||||||
else
|
else
|
||||||
selection.moveToPosition(pos);
|
selection.moveToPosition(pos);
|
||||||
|
editor.$blockScrolling--;
|
||||||
|
|
||||||
screenCursor = {row: -1, column: -1};
|
screenCursor = {row: -1, column: -1};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -552,38 +552,12 @@ var Editor = require("./editor").Editor;
|
||||||
var pos = anchor == this.multiSelect.anchor
|
var pos = anchor == this.multiSelect.anchor
|
||||||
? range.cursor == range.start ? range.end : range.start
|
? range.cursor == range.start ? range.end : range.start
|
||||||
: range.cursor;
|
: range.cursor;
|
||||||
if (!isSamePoint(pos, anchor))
|
if (pos.row != anchor.row
|
||||||
|
|| this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column)
|
||||||
this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
|
this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// todo this should change when paste becomes a command
|
|
||||||
this.onPaste = function(text) {
|
|
||||||
if (this.$readOnly)
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
var e = {text: text};
|
|
||||||
this._signal("paste", e);
|
|
||||||
text = e.text;
|
|
||||||
if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
|
|
||||||
return this.insert(text);
|
|
||||||
|
|
||||||
var lines = text.split(/\r\n|\r|\n/);
|
|
||||||
var ranges = this.selection.rangeList.ranges;
|
|
||||||
|
|
||||||
if (lines.length > ranges.length || lines.length < 2 || !lines[1])
|
|
||||||
return this.commands.exec("insertstring", this, text);
|
|
||||||
|
|
||||||
for (var i = ranges.length; i--;) {
|
|
||||||
var range = ranges[i];
|
|
||||||
if (!range.isEmpty())
|
|
||||||
this.session.remove(range);
|
|
||||||
|
|
||||||
this.session.insert(range.start, lines[i]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds and selects all the occurences of `needle`.
|
* Finds and selects all the occurences of `needle`.
|
||||||
* @param {String} The text to find
|
* @param {String} The text to find
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,45 @@ var exec = function(name, times, args) {
|
||||||
var testRanges = function(str) {
|
var testRanges = function(str) {
|
||||||
assert.equal(editor.selection.getAllRanges() + "", str + "");
|
assert.equal(editor.selection.getAllRanges() + "", str + "");
|
||||||
};
|
};
|
||||||
|
function getSelection(editor) {
|
||||||
|
var data = editor.multiSelect.toJSON();
|
||||||
|
if (!data.length) data = [data];
|
||||||
|
data = data.map(function(x) {
|
||||||
|
var a, c;
|
||||||
|
if (x.isBackwards) {
|
||||||
|
a = x.end;
|
||||||
|
c = x.start;
|
||||||
|
} else {
|
||||||
|
c = x.end;
|
||||||
|
a = x.start;
|
||||||
|
}
|
||||||
|
return Range.comparePoints(a, c)
|
||||||
|
? [a.row, a.column, c.row, c.column]
|
||||||
|
: [a.row, a.column];
|
||||||
|
});
|
||||||
|
return data.length > 1 ? data : data[0];
|
||||||
|
}
|
||||||
|
function testSelection(editor, data) {
|
||||||
|
assert.equal(getSelection(editor) + "", data + "");
|
||||||
|
}
|
||||||
|
function setSelection(editor, data) {
|
||||||
|
if (typeof data[0] == "number")
|
||||||
|
data = [data];
|
||||||
|
editor.selection.fromJSON(data.map(function(x) {
|
||||||
|
var start = {row: x[0], column: x[1]};
|
||||||
|
var end = x.length == 2 ? start : {row: x[2], column: x[3]};
|
||||||
|
var isBackwards = Range.comparePoints(start, end) > 0;
|
||||||
|
return isBackwards ? {
|
||||||
|
start: end,
|
||||||
|
end: start,
|
||||||
|
isBackwards: true
|
||||||
|
} : {
|
||||||
|
start: start,
|
||||||
|
end: end,
|
||||||
|
isBackwards: true
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
|
|
@ -170,6 +209,37 @@ module.exports = {
|
||||||
assert.equal('l1foo\nl2foo', editor.getValue());
|
assert.equal('l1foo\nl2foo', editor.getValue());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"test multiselect move lines": function() {
|
||||||
|
editor = new Editor(new MockRenderer());
|
||||||
|
|
||||||
|
editor.setValue("l1\nl2\nl3\nl4", -1);
|
||||||
|
setSelection(editor, [[0,2],[1,2],[2,2],[3,2]]);
|
||||||
|
|
||||||
|
exec("copylinesdown");
|
||||||
|
assert.equal(editor.getValue(),"l1\nl1\nl2\nl2\nl3\nl3\nl4\nl4");
|
||||||
|
testSelection(editor, [[1,2],[3,2],[5,2],[7,2]]);
|
||||||
|
exec("copylinesup");
|
||||||
|
assert.equal(editor.getValue(),"l1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4");
|
||||||
|
testSelection(editor, [[1,2],[4,2],[7,2],[10,2]]);
|
||||||
|
exec("removeline");
|
||||||
|
assert.equal(editor.getValue(),"l1\nl1\nl2\nl2\nl3\nl3\nl4\nl4");
|
||||||
|
testSelection(editor, [[1,0],[3,0],[5,0],[7,0]]);
|
||||||
|
|
||||||
|
setSelection(editor, [[1,2],[1,0,1,1],[3,0,3,1],[5,0,5,1],[7,0,7,1]]);
|
||||||
|
exec("copylinesdown");
|
||||||
|
exec("copylinesup");
|
||||||
|
assert.equal(editor.getValue(),"l1\nl1\nl1\nl1\nl2\nl2\nl2\nl2\nl3\nl3\nl3\nl3\nl4\nl4\nl4\nl4");
|
||||||
|
testSelection(editor, [[2,2],[2,0,2,1],[6,0,6,1],[10,0,10,1],[14,0,14,1]]);
|
||||||
|
|
||||||
|
exec("movelinesdown", 12);
|
||||||
|
assert.equal(editor.getValue(),"l1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4\nl1\nl2\nl3\nl4");
|
||||||
|
testSelection(editor, [[12,2],[12,0,12,1],[13,0,13,1],[14,0,14,1],[15,0,15,1]]);
|
||||||
|
|
||||||
|
exec("movelinesup", 12);
|
||||||
|
assert.equal(editor.getValue(),"l1\nl2\nl3\nl4\nl1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4");
|
||||||
|
testSelection(editor, [[0,2],[0,0,0,1],[1,0,1,1],[2,0,2,1],[3,0,3,1]]);
|
||||||
|
},
|
||||||
|
|
||||||
"test multiselect fromJSON/toJSON": function() {
|
"test multiselect fromJSON/toJSON": function() {
|
||||||
var doc = new EditSession(["l1", "l2"]);
|
var doc = new EditSession(["l1", "l2"]);
|
||||||
editor = new Editor(new MockRenderer(), doc);
|
editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ var assert = require("./test/assertions");
|
||||||
var JavaScriptMode = require("./mode/javascript").Mode;
|
var JavaScriptMode = require("./mode/javascript").Mode;
|
||||||
var PlaceHolder = require("./placeholder").PlaceHolder;
|
var PlaceHolder = require("./placeholder").PlaceHolder;
|
||||||
var UndoManager = require("./undomanager").UndoManager;
|
var UndoManager = require("./undomanager").UndoManager;
|
||||||
|
require("./multi_select")
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
|
|
@ -89,7 +90,7 @@ module.exports = {
|
||||||
editor.insert('v');
|
editor.insert('v');
|
||||||
assert.equal(session.doc.getValue(), "var v$a = 10;\nconsole.log(v$a, v$a);");
|
assert.equal(session.doc.getValue(), "var v$a = 10;\nconsole.log(v$a, v$a);");
|
||||||
next();
|
next();
|
||||||
}, 10);
|
}, 20);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: detaching placeholder" : function() {
|
"test: detaching placeholder" : function() {
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,8 @@ var Search = function() {
|
||||||
* @returns {Range}
|
* @returns {Range}
|
||||||
**/
|
**/
|
||||||
this.find = function(session) {
|
this.find = function(session) {
|
||||||
var iterator = this.$matchIterator(session, this.$options);
|
var options = this.$options;
|
||||||
|
var iterator = this.$matchIterator(session, options);
|
||||||
if (!iterator)
|
if (!iterator)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -111,7 +111,13 @@ var Search = function() {
|
||||||
iterator.forEach(function(range, row, offset) {
|
iterator.forEach(function(range, row, offset) {
|
||||||
if (!range.start) {
|
if (!range.start) {
|
||||||
var column = range.offset + (offset || 0);
|
var column = range.offset + (offset || 0);
|
||||||
firstRange = new Range(row, column, row, column+range.length);
|
firstRange = new Range(row, column, row, column + range.length);
|
||||||
|
if (!range.length && options.start && options.start.start
|
||||||
|
&& options.skipCurrent != false && firstRange.isEqual(options.start)
|
||||||
|
) {
|
||||||
|
firstRange = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
firstRange = range;
|
firstRange = range;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -240,8 +246,7 @@ var Search = function() {
|
||||||
if (!re)
|
if (!re)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var self = this, callback, backwards = options.backwards;
|
var callback;
|
||||||
|
|
||||||
if (options.$isMultiLine) {
|
if (options.$isMultiLine) {
|
||||||
var len = re.length;
|
var len = re.length;
|
||||||
var matchIterator = function(line, row, offset) {
|
var matchIterator = function(line, row, offset) {
|
||||||
|
|
@ -266,7 +271,7 @@ var Search = function() {
|
||||||
if (callback(range))
|
if (callback(range))
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
} else if (backwards) {
|
} else if (options.backwards) {
|
||||||
var matchIterator = function(line, row, startIndex) {
|
var matchIterator = function(line, row, startIndex) {
|
||||||
var matches = lang.getMatchOffsets(line, re);
|
var matches = lang.getMatchOffsets(line, re);
|
||||||
for (var i = matches.length-1; i >= 0; i--)
|
for (var i = matches.length-1; i >= 0; i--)
|
||||||
|
|
@ -282,10 +287,12 @@ var Search = function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lineIterator = this.$lineIterator(session, options);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
forEach: function(_callback) {
|
forEach: function(_callback) {
|
||||||
callback = _callback;
|
callback = _callback;
|
||||||
self.$lineIterator(session, options).forEach(matchIterator);
|
lineIterator.forEach(matchIterator);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var EditSession = require("./edit_session").EditSession;
|
var EditSession = require("./edit_session").EditSession;
|
||||||
|
var MockRenderer = require("./test/mockrenderer").MockRenderer;
|
||||||
|
var Editor = require("./editor").Editor;
|
||||||
var Search = require("./search").Search;
|
var Search = require("./search").Search;
|
||||||
var assert = require("./test/assertions");
|
var assert = require("./test/assertions");
|
||||||
|
|
||||||
|
|
@ -451,6 +453,37 @@ module.exports = {
|
||||||
assert.position(ranges[1].end, 0, 11);
|
assert.position(ranges[1].end, 0, 11);
|
||||||
assert.position(ranges[0].start, 0, 0);
|
assert.position(ranges[0].start, 0, 0);
|
||||||
assert.position(ranges[0].end, 0, 3);
|
assert.position(ranges[0].end, 0, 3);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test: find next empty range" : function() {
|
||||||
|
var session = new EditSession("foo foobar foo");
|
||||||
|
var editor = new Editor(new MockRenderer(), session);
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
needle: "o*",
|
||||||
|
wrap: true,
|
||||||
|
regExp: true,
|
||||||
|
backwards: false
|
||||||
|
};
|
||||||
|
var positions = [4, 5.2, 7, 8, 9, 10, 11, 12.2, 14, 0, 1.2, 3];
|
||||||
|
|
||||||
|
session.selection.moveCursorTo(0, 3);
|
||||||
|
for (var i = 0; i < 12; i++) {
|
||||||
|
editor.find(options)
|
||||||
|
var range = editor.selection.getRange();
|
||||||
|
var start = range.start.column;
|
||||||
|
var len = range.end.column - start;
|
||||||
|
assert.equal(start + 0.1 * len, positions[i])
|
||||||
|
}
|
||||||
|
options.backwards = true;
|
||||||
|
positions = [1.2, 1, 0, 14, 12.2, 12, 11, 10, 9, 8, 7, 5.2, 5, 4, 3];
|
||||||
|
for (var i = 0; i < 16; i++) {
|
||||||
|
editor.find(options);
|
||||||
|
var range = editor.selection.getRange();
|
||||||
|
var start = range.start.column;
|
||||||
|
var len = range.end.column - start;
|
||||||
|
console.log(start + 0.1 * len)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ var testNames = [
|
||||||
"ace/multi_select_test",
|
"ace/multi_select_test",
|
||||||
"ace/mouse/mouse_handler_test",
|
"ace/mouse/mouse_handler_test",
|
||||||
"ace/occur_test",
|
"ace/occur_test",
|
||||||
|
"ace/placeholder_test",
|
||||||
"ace/range_test",
|
"ace/range_test",
|
||||||
"ace/range_list_test",
|
"ace/range_list_test",
|
||||||
"ace/search_test",
|
"ace/search_test",
|
||||||
|
|
@ -71,6 +72,8 @@ document.body.appendChild(nav);
|
||||||
if (location.search)
|
if (location.search)
|
||||||
testNames = location.search.substr(1).split(",")
|
testNames = location.search.substr(1).split(",")
|
||||||
|
|
||||||
|
var filter = location.hash.substr(1);
|
||||||
|
|
||||||
require(testNames, function() {
|
require(testNames, function() {
|
||||||
var tests = testNames.map(function(x) {
|
var tests = testNames.map(function(x) {
|
||||||
var module = require(x);
|
var module = require(x);
|
||||||
|
|
@ -80,6 +83,12 @@ require(testNames, function() {
|
||||||
|
|
||||||
async.list(tests)
|
async.list(tests)
|
||||||
.expand(function(test) {
|
.expand(function(test) {
|
||||||
|
if (filter) {
|
||||||
|
Object.keys(test).forEach(function(method) {
|
||||||
|
if (method.match(/^>?test/) && !method.match(filter))
|
||||||
|
test[method] = undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
return AsyncTest.testcase(test)
|
return AsyncTest.testcase(test)
|
||||||
}, AsyncTest.TestGenerator)
|
}, AsyncTest.TestGenerator)
|
||||||
.run()
|
.run()
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var config = require("./config");
|
||||||
// tokenizing lines longer than this makes editor very slow
|
// tokenizing lines longer than this makes editor very slow
|
||||||
var MAX_TOKEN_COUNT = 2000;
|
var MAX_TOKEN_COUNT = 2000;
|
||||||
/**
|
/**
|
||||||
|
|
@ -353,13 +354,8 @@ var Tokenizer = function(rules) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
this.reportError = function(msg, data) {
|
this.reportError = config.reportError;
|
||||||
var e = new Error(msg);
|
|
||||||
e.data = data;
|
|
||||||
if (typeof console == "object" && console.error)
|
|
||||||
console.error(e);
|
|
||||||
setTimeout(function() { throw e; });
|
|
||||||
};
|
|
||||||
}).call(Tokenizer.prototype);
|
}).call(Tokenizer.prototype);
|
||||||
|
|
||||||
exports.Tokenizer = Tokenizer;
|
exports.Tokenizer = Tokenizer;
|
||||||
|
|
|
||||||
|
|
@ -375,6 +375,9 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
if (this.resizing)
|
if (this.resizing)
|
||||||
this.resizing = 0;
|
this.resizing = 0;
|
||||||
|
// reset cached values on scrollbars, needs to be removed when switching to non-native scrollbars
|
||||||
|
// see https://github.com/ajaxorg/ace/issues/2195
|
||||||
|
this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$updateCachedSize = function(force, gutterWidth, width, height) {
|
this.$updateCachedSize = function(force, gutterWidth, width, height) {
|
||||||
|
|
@ -634,9 +637,12 @@ var VirtualRenderer = function(container, theme) {
|
||||||
var posLeft = this.$cursorLayer.$pixelPos.left;
|
var posLeft = this.$cursorLayer.$pixelPos.left;
|
||||||
posTop -= config.offset;
|
posTop -= config.offset;
|
||||||
|
|
||||||
|
var style = this.textarea.style;
|
||||||
var h = this.lineHeight;
|
var h = this.lineHeight;
|
||||||
if (posTop < 0 || posTop > config.height - h)
|
if (posTop < 0 || posTop > config.height - h) {
|
||||||
|
style.top = style.left = "0";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var w = this.characterWidth;
|
var w = this.characterWidth;
|
||||||
if (this.$composition) {
|
if (this.$composition) {
|
||||||
|
|
@ -649,11 +655,10 @@ var VirtualRenderer = function(container, theme) {
|
||||||
posLeft = this.$size.scrollerWidth - w;
|
posLeft = this.$size.scrollerWidth - w;
|
||||||
|
|
||||||
posLeft += this.gutterWidth;
|
posLeft += this.gutterWidth;
|
||||||
|
style.height = h + "px";
|
||||||
this.textarea.style.height = h + "px";
|
style.width = w + "px";
|
||||||
this.textarea.style.width = w + "px";
|
style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
|
||||||
this.textarea.style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
|
style.top = Math.min(posTop, this.$size.height - h) + "px";
|
||||||
this.textarea.style.top = Math.min(posTop, this.$size.height - h) + "px";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -684,13 +684,14 @@ function convertTmLanguage(name, langStr) {
|
||||||
|
|
||||||
if (!module.parent) {
|
if (!module.parent) {
|
||||||
var args = process.argv.splice(2);
|
var args = process.argv.splice(2);
|
||||||
var tmLanguageFile = args[0];
|
var devMode = args[0] == "--dev";
|
||||||
var devMode = args[1];
|
if (devMode)
|
||||||
if (tmLanguageFile === undefined) {
|
args.shift();
|
||||||
console.error("Usage: node tmlanguage.js path/or/url/to/syntax.file");
|
if (args.length < 1) {
|
||||||
|
console.error("Usage: node tmlanguage.js [--dev] path/or/url/to/syntax.file ...");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
fetchAndConvert(tmLanguageFile);
|
args.forEach(fetchAndConvert);
|
||||||
} else {
|
} else {
|
||||||
exports.fetchAndConvert = fetchAndConvert;
|
exports.fetchAndConvert = fetchAndConvert;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ function extractStyles(theme) {
|
||||||
|
|
||||||
for (var i=1; i<theme.settings.length; i++) {
|
for (var i=1; i<theme.settings.length; i++) {
|
||||||
var element = theme.settings[i];
|
var element = theme.settings[i];
|
||||||
if (!element.scope)
|
if (!element.scope || !element.settings)
|
||||||
continue;
|
continue;
|
||||||
var scopes = element.scope.split(/\s*[|,]\s*/g);
|
var scopes = element.scope.split(/\s*[|,]\s*/g);
|
||||||
for (var j = 0; j < scopes.length; j++) {
|
for (var j = 0; j < scopes.length; j++) {
|
||||||
|
|
@ -282,9 +282,13 @@ var themes = {
|
||||||
"xcode": "Xcode_default"
|
"xcode": "Xcode_default"
|
||||||
};
|
};
|
||||||
|
|
||||||
function convertTheme(name) {
|
function convertBuiltinTheme(name) {
|
||||||
|
return convertTheme(name, __dirname + "/tmthemes/" + themes[name] + ".tmTheme", __dirname + "/../lib/ace/theme");
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertTheme(name, tmThemePath, outputDirectory) {
|
||||||
console.log("Converting " + name);
|
console.log("Converting " + name);
|
||||||
var tmTheme = fs.readFileSync(__dirname + "/tmthemes/" + themes[name] + ".tmTheme", "utf8");
|
var tmTheme = fs.readFileSync(tmThemePath, "utf8");
|
||||||
parseTheme(tmTheme, function(theme) {
|
parseTheme(tmTheme, function(theme) {
|
||||||
var styles = extractStyles(theme);
|
var styles = extractStyles(theme);
|
||||||
|
|
||||||
|
|
@ -305,7 +309,7 @@ function convertTheme(name) {
|
||||||
// this way, we preserve all hand-modified rules in the <theme>.css rules,
|
// this way, we preserve all hand-modified rules in the <theme>.css rules,
|
||||||
// (because some exist, for collab1 and ace_indentation_guide
|
// (because some exist, for collab1 and ace_indentation_guide
|
||||||
try {
|
try {
|
||||||
var outThemeCss = fs.readFileSync(__dirname + "/../lib/ace/theme/" + name + ".css");
|
var outThemeCss = fs.readFileSync(outputDirectory + "/" + name + ".css");
|
||||||
var oldRules = cssParse(outThemeCss).stylesheet.rules;
|
var oldRules = cssParse(outThemeCss).stylesheet.rules;
|
||||||
var newRules = cssParse(css).stylesheet.rules;
|
var newRules = cssParse(css).stylesheet.rules;
|
||||||
|
|
||||||
|
|
@ -333,6 +337,7 @@ function convertTheme(name) {
|
||||||
css = cssStringify({stylesheet: {rules: oldRules}}, { compress: false });
|
css = cssStringify({stylesheet: {rules: oldRules}}, { compress: false });
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("Creating new file: " + name + ".css")
|
console.log("Creating new file: " + name + ".css")
|
||||||
|
css = cssStringify(cssParse(css), { compress: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
var js = fillTemplate(jsTemplate, {
|
var js = fillTemplate(jsTemplate, {
|
||||||
|
|
@ -342,13 +347,25 @@ function convertTheme(name) {
|
||||||
isDark: styles.isDark
|
isDark: styles.isDark
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFileSync(__dirname + "/../lib/ace/theme/" + name + ".js", js);
|
fs.writeFileSync(outputDirectory + "/" + name + ".js", js);
|
||||||
fs.writeFileSync(__dirname + "/../lib/ace/theme/" + name + ".css", css);
|
fs.writeFileSync(outputDirectory + "/" + name + ".css", css);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var name in themes) {
|
if (process.argv.length > 1) {
|
||||||
convertTheme(name);
|
var args = process.argv.splice(2);
|
||||||
|
if (args.length < 3) {
|
||||||
|
console.error("Usage: node tmtheme.js [theme_name, path/to/theme.tmTheme path/to/output/directory]");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
var name = args[0];
|
||||||
|
var themePath = args[1];
|
||||||
|
var outputDirectory = args[2];
|
||||||
|
convertTheme(name, themePath, outputDirectory);
|
||||||
|
} else {
|
||||||
|
for (var name in themes) {
|
||||||
|
convertBuiltinTheme(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var sortedUnsupportedScopes = {};
|
var sortedUnsupportedScopes = {};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
var https = require("https")
|
var https = require("https");
|
||||||
, http = require("http")
|
var http = require("http");
|
||||||
, url = require("url")
|
var url = require("url");
|
||||||
, fs = require("fs");
|
var fs = require("fs");
|
||||||
|
|
||||||
var Path = require("path");
|
var Path = require("path");
|
||||||
var spawn = require("child_process").spawn;
|
var spawn = require("child_process").spawn;
|
||||||
|
|
@ -119,6 +119,22 @@ var deps = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
vim: {
|
||||||
|
fetch: function(){
|
||||||
|
var rootHref = "https://raw.githubusercontent.com/codemirror/CodeMirror/master/"
|
||||||
|
var fileMap = {"keymap/vim.js": "keyboard/vim.js", "test/vim_test.js": "keyboard/vim_test.js"};
|
||||||
|
async.forEach(Object.keys(fileMap), function(x, next) {
|
||||||
|
download(rootHref + x, function(e, d) {
|
||||||
|
d = d.replace(/^\(function.*{[^{}]+^}[^{}]+{/m, "define(function(require, exports, module) {");
|
||||||
|
d = d.replace(/^\s*return vimApi;\s*};/gm, " //};")
|
||||||
|
.replace("var Vim = function() {", "$& return vimApi; } //{")
|
||||||
|
fs.writeFile(rootDir + fileMap[x], d, next)
|
||||||
|
})
|
||||||
|
}, function() {
|
||||||
|
console.log("done")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
coffee: {
|
coffee: {
|
||||||
fetch: function(){
|
fetch: function(){
|
||||||
var rootHref = "https://raw.github.com/jashkenas/coffee-script/master/";
|
var rootHref = "https://raw.github.com/jashkenas/coffee-script/master/";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue