Update ace to 5b6e24dd0953e4728766bd8d6c807a48e9ec61cd

This commit is contained in:
Nathan Sobo
2012-01-31 19:23:42 -07:00
parent a72dc17b87
commit 0e677b6b82
205 changed files with 4986 additions and 2570 deletions

60
vendor/ace/ace.js vendored
View File

@@ -36,40 +36,42 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
require("./lib/fixoldbrowsers");
require("./lib/fixoldbrowsers");
var Dom = require("./lib/dom");
var Event = require("./lib/event");
var Dom = require("./lib/dom");
var Event = require("./lib/event");
var Editor = require("./editor").Editor;
var EditSession = require("./edit_session").EditSession;
var UndoManager = require("./undomanager").UndoManager;
var Renderer = require("./virtual_renderer").VirtualRenderer;
var Editor = require("./editor").Editor;
var EditSession = require("./edit_session").EditSession;
var UndoManager = require("./undomanager").UndoManager;
var Renderer = require("./virtual_renderer").VirtualRenderer;
exports.edit = function(el) {
if (typeof(el) == "string") {
el = document.getElementById(el);
}
exports.edit = function(el) {
if (typeof(el) == "string") {
el = document.getElementById(el);
}
var doc = new EditSession(Dom.getInnerText(el));
doc.setUndoManager(new UndoManager());
el.innerHTML = '';
var doc = new EditSession(Dom.getInnerText(el));
doc.setUndoManager(new UndoManager());
el.innerHTML = '';
var editor = new Editor(new Renderer(el, require("ace/theme/textmate")));
editor.setSession(doc);
var editor = new Editor(new Renderer(el, require("./theme/textmate")));
editor.setSession(doc);
var env = {};
env.document = doc;
env.editor = editor;
var env = {};
env.document = doc;
env.editor = editor;
editor.resize();
Event.addListener(window, "resize", function() {
editor.resize();
Event.addListener(window, "resize", function() {
editor.resize();
});
el.env = env;
// Store env on editor such that it can be accessed later on from
// the returned object.
editor.env = env;
return editor;
};
});
});
el.env = env;
// Store env on editor such that it can be accessed later on from
// the returned object.
editor.env = env;
return editor;
};
});

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
@@ -155,7 +156,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
this.row = pos.row;
this.column = pos.column;
this._dispatchEvent("change", {
this._emit("change", {
old: old,
value: pos
});

View File

@@ -40,7 +40,8 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var Document = require("./document").Document;
var Anchor = require("./anchor").Anchor;
var Range = require("./range").Range;

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
@@ -100,7 +101,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
first: firstRow,
last: lastRow
};
this._dispatchEvent("update", {data: data});
this._emit("update", {data: data});
};
this.start = function(startRow) {
@@ -130,8 +131,8 @@ var BackgroundTokenizer = function(tokenizer, editor) {
};
this.$tokenizeRows = function(firstRow, lastRow) {
if (!this.doc)
return [];
if (!this.doc || isNaN(firstRow) || isNaN(lastRow))
return [{'state':'start','tokens':[]}];
var rows = [];

View File

@@ -1,4 +1,5 @@
define(function(require, exports, module) {
"use strict";
var keyUtil = require("../lib/keys");
@@ -146,8 +147,13 @@ var CommandManager = function(platform, commands) {
if (this.recording) {
this.macro.pop();
this.exec = this.normal_exec;
if (!this.macro.length)
this.macro = this.oldMacro;
return this.recording = false;
}
this.oldMacro = this.macro;
this.macro = [];
this.normal_exec = this.exec;
this.exec = function(command, editor, args) {
@@ -158,10 +164,10 @@ var CommandManager = function(platform, commands) {
};
this.replay = function(editor) {
if (this.$inReplay)
if (this.$inReplay || !this.macro)
return;
if (!this.macro || this.recording)
if (this.recording)
return this.toggleRecording();
try {

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var CommandManager = require("./command_manager").CommandManager;
var keys = require("../lib/keys");
@@ -56,7 +57,7 @@ module.exports = {
},
called: false,
exec: function(editor) { this.called = true; }
}
};
this.cm = new CommandManager("mac", [this.command]);
},
@@ -113,7 +114,7 @@ module.exports = {
},
called: false,
exec: function(editor) { this.called = true; }
}
};
this.cm.addCommand(command);
this.cm.exec("gotoline");
@@ -127,16 +128,16 @@ module.exports = {
var called = "";
this.cm.addCommands({
togglerecording: function(editor) {
editor.cm.toggleRecording()
editor.cm.toggleRecording();
},
replay: function(editor) {
editor.cm.replay()
editor.cm.replay();
},
cm1: function(editor, arg) {
called += "1" + (arg || "")
called += "1" + (arg || "");
},
cm2: function(editor) {
called += "2"
called += "2";
}
});
@@ -158,17 +159,17 @@ module.exports = {
var called = "";
this.cm.addCommands({
cm1: function(editor, arg) {
called += "1" + (arg || "")
called += "1" + (arg || "");
},
cm2: function(editor) {
called += "2"
called += "2";
}
});
this.cm.bindKeys({
"Ctrl-L|Command-C": "cm1",
"Ctrl-R": "cm2",
})
"Ctrl-R": "cm2"
});
var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "C");
assert.equal(command, "cm1");
@@ -178,7 +179,7 @@ module.exports = {
this.cm.bindKeys({
"Ctrl-R": null
})
});
var command = this.cm.findKeyCommand(keys.KEY_MODS.ctrl, "R");
assert.equal(command, null);
@@ -188,5 +189,5 @@ module.exports = {
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec()
require("asyncjs").test.testcase(module.exports).exec();
}

View File

@@ -39,6 +39,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var lang = require("../lib/lang");
@@ -63,7 +64,7 @@ exports.commands = [{
name: "gotoline",
bindKey: bindKey("Ctrl-L", "Command-L"),
exec: function(editor) {
var line = parseInt(prompt("Enter line number:"));
var line = parseInt(prompt("Enter line number:"), 10);
if (!isNaN(line)) {
editor.gotoLine(line);
}
@@ -262,6 +263,11 @@ exports.commands = [{
bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
exec: function(editor) { editor.commands.replay(editor); },
readOnly: true
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(); },
readOnly: true
},
// commands disabled in readOnly mode

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

View File

@@ -1,10 +1,10 @@
/*@import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono);*/
@import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono);
.ace_editor {
position: absolute;
overflow: hidden;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Courier New', monospace;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace;
font-size: 12px;
}
@@ -35,24 +35,41 @@
z-index: 4;
}
.ace_gutter .ace_layer {
position: relative;
min-width: 54px;
text-align: right;
}
.ace_gutter {
position: absolute;
overflow-x: hidden;
overflow-y: hidden;
overflow : hidden;
height: 100%;
width: auto;
cursor: default;
}
.ace_gutter-cell {
padding-left: 19px;
padding-right: 6px;
}
.ace_gutter-cell.ace_error {
background-image: url("data:image/gif,GIF89a%10%00%10%00%D5%00%00%F5or%F5%87%88%F5nr%F4ns%EBmq%F5z%7F%DDJT%DEKS%DFOW%F1Yc%F2ah%CE(7%CE)8%D18E%DD%40M%F2KZ%EBU%60%F4%60m%DCir%C8%16(%C8%19*%CE%255%F1%3FR%F1%3FS%E6%AB%B5%CA%5DI%CEn%5E%F7%A2%9A%C9G%3E%E0a%5B%F7%89%85%F5yy%F6%82%80%ED%82%80%FF%BF%BF%E3%C4%C4%FF%FF%FF%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00%25%00%2C%00%00%00%00%10%00%10%00%00%06p%C0%92pH%2C%1A%8F%C8%D2H%93%E1d4%23%E4%88%D3%09mB%1DN%B48%F5%90%40%60%92G%5B%94%20%3E%22%D2%87%24%FA%20%24%C5%06A%00%20%B1%07%02B%A38%89X.v%17%82%11%13q%10%0Fi%24%0F%8B%10%7BD%12%0Ei%09%92%09%0EpD%18%15%24%0A%9Ci%05%0C%18F%18%0B%07%04%01%04%06%A0H%18%12%0D%14%0D%12%A1I%B3%B4%B5IA%00%3B");
background-repeat: no-repeat;
background-position: 4px center;
background-position: 2px center;
}
.ace_gutter-cell.ace_warning {
background-image: url("data:image/gif,GIF89a%10%00%10%00%D5%00%00%FF%DBr%FF%DE%81%FF%E2%8D%FF%E2%8F%FF%E4%96%FF%E3%97%FF%E5%9D%FF%E6%9E%FF%EE%C1%FF%C8Z%FF%CDk%FF%D0s%FF%D4%81%FF%D5%82%FF%D5%83%FF%DC%97%FF%DE%9D%FF%E7%B8%FF%CCl%7BQ%13%80U%15%82W%16%81U%16%89%5B%18%87%5B%18%8C%5E%1A%94d%1D%C5%83-%C9%87%2F%C6%84.%C6%85.%CD%8B2%C9%871%CB%8A3%CD%8B5%DC%98%3F%DF%9BB%E0%9CC%E1%A5U%CB%871%CF%8B5%D1%8D6%DB%97%40%DF%9AB%DD%99B%E3%B0p%E7%CC%AE%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00%2F%00%2C%00%00%00%00%10%00%10%00%00%06a%C0%97pH%2C%1A%8FH%A1%ABTr%25%87%2B%04%82%F4%7C%B9X%91%08%CB%99%1C!%26%13%84*iJ9(%15G%CA%84%14%01%1A%97%0C%03%80%3A%9A%3E%81%84%3E%11%08%B1%8B%20%02%12%0F%18%1A%0F%0A%03'F%1C%04%0B%10%16%18%10%0B%05%1CF%1D-%06%07%9A%9A-%1EG%1B%A0%A1%A0U%A4%A5%A6BA%00%3B");
background-repeat: no-repeat;
background-position: 4px center;
background-position: 2px center;
}
.ace_gutter-cell.ace_info {
background-image: url("data:image/gif;base64,R0lGODlhEAAQAMQAAAAAAEFBQVJSUl5eXmRkZGtra39/f4WFhYmJiZGRkaampry8vMPDw8zMzNXV1dzc3OTk5Orq6vDw8P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABQALAAAAAAQABAAAAUuICWOZGmeaBml5XGwFCQSBGyXRSAwtqQIiRuiwIM5BoYVbEFIyGCQoeJGrVptIQA7");
background-repeat: no-repeat;
background-position: 2px center;
}
.ace_editor .ace_sb {
@@ -85,7 +102,7 @@
.ace_editor textarea {
position: fixed;
z-index: -1;
z-index: 0;
width: 10px;
height: 30px;
opacity: 0;
@@ -105,6 +122,9 @@
white-space: nowrap;
height: 100%;
width: 100%;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.ace_text-layer {
@@ -162,25 +182,100 @@
}
.ace_line .ace_fold {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
display: inline-block;
height: 11px;
margin-top: -2px;
vertical-align: middle;
background-image:
url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82"),
url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%3AIDAT8%11c%FC%FF%FF%7F%18%03%1A%60%01%F2%3F%A0%891%80%04%FF%11-%F8%17%9BJ%E2%05%B1ZD%81v%26t%E7%80%F8%A3%82h%A12%1A%20%A3%01%02%0F%01%BA%25%06%00%19%C0%0D%AEF%D5%3ES%00%00%00%00IEND%AEB%60%82");
background-repeat: no-repeat, repeat-x;
background-position: center center, top left;
color: transparent;
border: 1px solid black;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
cursor: pointer;
color: darkred;
-moz-outline-radius: 4px;
outline-radius: 4px;
border-radius: 4px;
outline: 1px solid #1C00FF;
outline-offset: -2px;
pointer-events: auto;
}
.ace_dark .ace_fold {
color: #E6E1DC;
outline-color: #FC6F09;
}
.ace_fold:hover{
background: gold!important;
background-image:
url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82"),
url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%003IDAT8%11c%FC%FF%FF%7F%3E%03%1A%60%01%F2%3F%A3%891%80%04%FFQ%26%F8w%C0%B43%A1%DB%0C%E2%8F%0A%A2%85%CAh%80%8C%06%08%3C%04%E8%96%18%00%A3S%0D%CD%CF%D8%C1%9D%00%00%00%00IEND%AEB%60%82");
background-repeat: no-repeat, repeat-x;
background-position: center center, top left;
}
.ace_dragging .ace_content {
cursor: move;
cursor: move;
}
.ace_folding-enabled .ace_gutter-cell {
padding-right: 13px;
}
.ace_fold-widget {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
margin: 0 -12px 1px 1px;
display: inline-block;
height: 14px;
width: 11px;
vertical-align: text-bottom;
background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAe%8A%B1%0D%000%0C%C2%F2%2CK%96%BC%D0%8F9%81%88H%E9%D0%0E%96%C0%10%92%3E%02%80%5E%82%E4%A9*-%EEsw%C8%CC%11%EE%96w%D8%DC%E9*Eh%0C%151(%00%00%00%00IEND%AEB%60%82");
background-repeat: no-repeat;
background-position: center 5px;
border-radius: 3px;
}
.ace_fold-widget.end {
background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAm%C7%C1%09%000%08C%D1%8C%ECE%C8E(%8E%EC%02)%1EZJ%F1%C1'%04%07I%E1%E5%EE%CAL%F5%A2%99%99%22%E2%D6%1FU%B5%FE0%D9x%A7%26Wz5%0E%D5%00%00%00%00IEND%AEB%60%82");
}
.ace_fold-widget.closed {
background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%03%00%00%00%06%08%06%00%00%00%06%E5%24%0C%00%00%009IDATx%DA5%CA%C1%09%000%08%03%C0%AC*(%3E%04%C1%0D%BA%B1%23%A4Uh%E0%20%81%C0%CC%F8%82%81%AA%A2%AArGfr%88%08%11%11%1C%DD%7D%E0%EE%5B%F6%F6%CB%B8%05Q%2F%E9tai%D9%00%00%00%00IEND%AEB%60%82");
}
.ace_fold-widget:hover {
border: 1px solid rgba(0, 0, 0, 0.3);
background-color: rgba(255, 255, 255, 0.2);
-moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
-webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
background-position: center 4px;
}
.ace_fold-widget:active {
border: 1px solid rgba(0, 0, 0, 0.4);
background-color: rgba(0, 0, 0, 0.05);
-moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255);
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
-webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
box-shadow:inset 0 1px 1px rgba(255, 255, 255);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}
.ace_fold-widget.invalid {
background-color: #FFB4B4;
border-color: #DE5555;
}

BIN
vendor/ace/css/expand-marker.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
@@ -106,7 +107,7 @@ var Document = function(text) {
case "auto":
return this.$autoNewLine;
}
},
};
this.$autoNewLine = "\n";
this.$newLineMode = "auto";
@@ -169,7 +170,7 @@ var Document = function(text) {
position.column = this.getLine(length-1).length;
}
return position;
}
};
this.insert = function(position, text) {
if (text.length == 0)
@@ -207,9 +208,9 @@ var Document = function(text) {
range: range,
lines: lines
};
this._dispatchEvent("change", { data: delta });
this._emit("change", { data: delta });
return range.end;
},
};
this.insertNewLine = function(position) {
position = this.$clipPosition(position);
@@ -228,7 +229,7 @@ var Document = function(text) {
range: Range.fromPoints(position, end),
text: this.getNewLineCharacter()
};
this._dispatchEvent("change", { data: delta });
this._emit("change", { data: delta });
return end;
};
@@ -252,7 +253,7 @@ var Document = function(text) {
range: Range.fromPoints(position, end),
text: text
};
this._dispatchEvent("change", { data: delta });
this._emit("change", { data: delta });
return end;
};
@@ -304,7 +305,7 @@ var Document = function(text) {
range: range,
text: removed
};
this._dispatchEvent("change", { data: delta });
this._emit("change", { data: delta });
return range.start;
};
@@ -325,7 +326,7 @@ var Document = function(text) {
nl: this.getNewLineCharacter(),
lines: removed
};
this._dispatchEvent("change", { data: delta });
this._emit("change", { data: delta });
return removed;
};
@@ -343,7 +344,7 @@ var Document = function(text) {
range: range,
text: this.getNewLineCharacter()
};
this._dispatchEvent("change", { data: delta });
this._emit("change", { data: delta });
};
this.replace = function(range, text) {
@@ -372,13 +373,13 @@ var Document = function(text) {
var range = Range.fromPoints(delta.range.start, delta.range.end);
if (delta.action == "insertLines")
this.insertLines(range.start.row, delta.lines)
this.insertLines(range.start.row, delta.lines);
else if (delta.action == "insertText")
this.insert(range.start, delta.text)
this.insert(range.start, delta.text);
else if (delta.action == "removeLines")
this.removeLines(range.start.row, range.end.row - 1)
this.removeLines(range.start.row, range.end.row - 1);
else if (delta.action == "removeText")
this.remove(range)
this.remove(range);
}
};
@@ -389,13 +390,13 @@ var Document = function(text) {
var range = Range.fromPoints(delta.range.start, delta.range.end);
if (delta.action == "insertLines")
this.removeLines(range.start.row, range.end.row - 1)
this.removeLines(range.start.row, range.end.row - 1);
else if (delta.action == "insertText")
this.remove(range)
this.remove(range);
else if (delta.action == "removeLines")
this.insertLines(range.start.row, delta.lines)
this.insertLines(range.start.row, delta.lines);
else if (delta.action == "removeText")
this.insert(range.start, delta.text)
this.insert(range.start, delta.text);
}
};

View File

@@ -42,7 +42,8 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var Document = require("./document").Document;
var Range = require("./range").Range;
var assert = require("./test/assertions");

View File

@@ -39,6 +39,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var lang = require("./lib/lang");
@@ -58,6 +59,7 @@ var EditSession = function(text, mode) {
this.$rowCache = [];
this.$wrapData = [];
this.$foldData = [];
this.$undoSelect = true;
this.$foldData.toString = function() {
var str = "";
this.forEach(function(foldLine) {
@@ -141,7 +143,7 @@ var EditSession = function(text, mode) {
}
this.bgTokenizer.start(delta.range.start.row);
this._dispatchEvent("change", e);
this._emit("change", e);
};
this.setValue = function(text) {
@@ -274,7 +276,7 @@ var EditSession = function(text, mode) {
this.$modified = true;
this.$tabSize = tabSize;
this._dispatchEvent("changeTabSize");
this._emit("changeTabSize");
};
this.getTabSize = function() {
@@ -290,7 +292,7 @@ var EditSession = function(text, mode) {
if (this.$overwrite == overwrite) return;
this.$overwrite = overwrite;
this._dispatchEvent("changeOverwrite");
this._emit("changeOverwrite");
};
this.getOverwrite = function() {
@@ -310,22 +312,22 @@ var EditSession = function(text, mode) {
for (var i=0; i<rows.length; i++) {
this.$breakpoints[rows[i]] = true;
}
this._dispatchEvent("changeBreakpoint", {});
this._emit("changeBreakpoint", {});
};
this.clearBreakpoints = function() {
this.$breakpoints = [];
this._dispatchEvent("changeBreakpoint", {});
this._emit("changeBreakpoint", {});
};
this.setBreakpoint = function(row) {
this.$breakpoints[row] = true;
this._dispatchEvent("changeBreakpoint", {});
this._emit("changeBreakpoint", {});
};
this.clearBreakpoint = function(row) {
delete this.$breakpoints[row];
this._dispatchEvent("changeBreakpoint", {});
this._emit("changeBreakpoint", {});
};
this.getBreakpoints = function() {
@@ -345,10 +347,10 @@ var EditSession = function(text, mode) {
if (inFront) {
this.$frontMarkers[id] = marker;
this._dispatchEvent("changeFrontMarker")
this._emit("changeFrontMarker")
} else {
this.$backMarkers[id] = marker;
this._dispatchEvent("changeBackMarker")
this._emit("changeBackMarker")
}
return id;
@@ -362,7 +364,7 @@ var EditSession = function(text, mode) {
var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
if (marker) {
delete (markers[markerId]);
this._dispatchEvent(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
this._emit(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
}
};
@@ -389,7 +391,7 @@ var EditSession = function(text, mode) {
else
this.$annotations[row] = [annotation];
}
this._dispatchEvent("changeAnnotation", {});
this._emit("changeAnnotation", {});
};
this.getAnnotations = function() {
@@ -398,7 +400,7 @@ var EditSession = function(text, mode) {
this.clearAnnotations = function() {
this.$annotations = {};
this._dispatchEvent("changeAnnotation", {});
this._emit("changeAnnotation", {});
};
this.$detectNewLine = function(text) {
@@ -479,7 +481,7 @@ var EditSession = function(text, mode) {
this.onReloadTokenizer = function(e) {
var rows = e.data;
this.bgTokenizer.start(rows.first);
this._dispatchEvent("tokenizerUpdate", e);
this._emit("tokenizerUpdate", e);
};
this.$mode = null;
@@ -503,7 +505,7 @@ var EditSession = function(text, mode) {
this.bgTokenizer = new BackgroundTokenizer(tokenizer);
var _self = this;
this.bgTokenizer.addEventListener("update", function(e) {
_self._dispatchEvent("tokenizerUpdate", e);
_self._emit("tokenizerUpdate", e);
});
} else {
this.bgTokenizer.setTokenizer(tokenizer);
@@ -515,7 +517,9 @@ var EditSession = function(text, mode) {
this.tokenRe = mode.tokenRe;
this.nonTokenRe = mode.nonTokenRe;
this._dispatchEvent("changeMode");
this.$setFolding(mode.foldingRules);
this._emit("changeMode");
};
this.$stopWorker = function() {
@@ -542,18 +546,34 @@ var EditSession = function(text, mode) {
this.getMode = function() {
return this.$mode;
};
this.$scrollTop = 0;
this.setScrollTopRow = function(scrollTopRow) {
if (this.$scrollTop === scrollTopRow) return;
this.setScrollTop = function(scrollTop) {
scrollTop = Math.round(Math.max(0, scrollTop));
if (this.$scrollTop === scrollTop)
return;
this.$scrollTop = scrollTopRow;
this._dispatchEvent("changeScrollTop");
this.$scrollTop = scrollTop;
this._emit("changeScrollTop", scrollTop);
};
this.getScrollTopRow = function() {
this.getScrollTop = function() {
return this.$scrollTop;
};
this.$scrollLeft = 0;
this.setScrollLeft = function(scrollLeft) {
scrollLeft = Math.round(Math.max(0, scrollLeft));
if (this.$scrollLeft === scrollLeft)
return;
this.$scrollLeft = scrollLeft;
this._emit("changeScrollLeft", scrollLeft);
};
this.getScrollLeft = function() {
return this.$scrollLeft;
};
this.getWidth = function() {
this.$computeWidth();
@@ -638,7 +658,7 @@ var EditSession = function(text, mode) {
this.$fromUndo = true;
var lastUndoRange = null;
for (var i = deltas.length - 1; i != -1; i--) {
delta = deltas[i];
var delta = deltas[i];
if (delta.group == "doc") {
this.doc.revertDeltas(delta.deltas);
lastUndoRange =
@@ -651,10 +671,11 @@ var EditSession = function(text, mode) {
}
this.$fromUndo = false;
lastUndoRange &&
this.$undoSelect &&
!dontSelect &&
this.selection.setSelectionRange(lastUndoRange);
return lastUndoRange;
},
};
this.redoChanges = function(deltas, dontSelect) {
if (!deltas.length)
@@ -663,7 +684,7 @@ var EditSession = function(text, mode) {
this.$fromUndo = true;
var lastUndoRange = null;
for (var i = 0; i < deltas.length; i++) {
delta = deltas[i];
var delta = deltas[i];
if (delta.group == "doc") {
this.doc.applyDeltas(delta.deltas);
lastUndoRange =
@@ -672,10 +693,15 @@ var EditSession = function(text, mode) {
}
this.$fromUndo = false;
lastUndoRange &&
this.$undoSelect &&
!dontSelect &&
this.selection.setSelectionRange(lastUndoRange);
return lastUndoRange;
},
};
this.setUndoSelect = function(enable) {
this.$undoSelect = enable;
};
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
function isInsert(delta) {
@@ -835,6 +861,12 @@ var EditSession = function(text, mode) {
return Math.max(0, Math.min(row, this.doc.getLength()-1));
};
this.$clipColumnToRow = function(row, column) {
if (column < 0)
return 0;
return Math.min(this.doc.getLine(row).length, column);
};
this.$clipPositionToDocument = function(row, column) {
column = Math.max(0, column);
@@ -857,6 +889,30 @@ var EditSession = function(text, mode) {
};
};
this.$clipRangeToDocument = function(range) {
if (range.start.row < 0) {
range.start.row = 0;
range.start.column = 0
} else {
range.start.column = this.$clipColumnToRow(
range.start.row,
range.start.column
);
}
var len = this.doc.getLength() - 1;
if (range.end.row > len) {
range.end.row = len;
range.end.column = this.doc.getLine(len).length;
} else {
range.end.column = this.$clipColumnToRow(
range.end.row,
range.end.column
);
}
return range;
};
// WRAPMODE
this.$wrapLimit = 80;
this.$useWrapMode = false;
@@ -875,13 +931,13 @@ var EditSession = function(text, mode) {
if (useWrapMode) {
var len = this.getLength();
this.$wrapData = [];
for (i = 0; i < len; i++) {
for (var i = 0; i < len; i++) {
this.$wrapData.push([]);
}
this.$updateWrapData(0, len - 1);
}
this._dispatchEvent("changeWrapMode");
this._emit("changeWrapMode");
}
};
@@ -899,7 +955,7 @@ var EditSession = function(text, mode) {
this.$wrapLimitRange.max = max;
this.$modified = true;
// This will force a recalculation of the wrap limit
this._dispatchEvent("changeWrapMode");
this._emit("changeWrapMode");
}
};
@@ -913,7 +969,7 @@ var EditSession = function(text, mode) {
if (this.$useWrapMode) {
this.$updateWrapData(0, this.getLength() - 1);
this.$resetRowCache(0)
this._dispatchEvent("changeWrapLimit");
this._emit("changeWrapLimit");
}
return true;
}
@@ -949,10 +1005,10 @@ var EditSession = function(text, mode) {
var useWrapMode = this.$useWrapMode;
var len;
var action = e.data.action;
var firstRow = e.data.range.start.row,
lastRow = e.data.range.end.row,
start = e.data.range.start,
end = e.data.range.end;
var firstRow = e.data.range.start.row;
var lastRow = e.data.range.end.row;
var start = e.data.range.start;
var end = e.data.range.end;
var removedFolds = null;
if (action.indexOf("Lines") != -1) {
@@ -1037,7 +1093,6 @@ var EditSession = function(text, mode) {
} else {
// Realign folds. E.g. if you add some new chars before a fold, the
// fold should "move" to the right.
var column;
len = Math.abs(e.data.range.start.column - e.data.range.end.column);
if (action.indexOf("remove") != -1) {
// Get all the folds in the change range and remove them.
@@ -1120,12 +1175,11 @@ var EditSession = function(text, mode) {
TAB = 11,
TAB_SPACE = 12;
this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
this.$computeWrapSplits = function(tokens, wrapLimit) {
if (tokens.length == 0) {
return [];
}
var tabSize = this.getTabSize();
var splits = [];
var displayLength = tokens.length;
var lastSplit = 0, lastDocSplit = 0;
@@ -1138,11 +1192,11 @@ var EditSession = function(text, mode) {
var len = displayed.length;
displayed.join("").
// Get all the TAB_SPACEs.
replace(/12/g, function(m) {
replace(/12/g, function() {
len -= 1;
}).
// Get all the CHAR_EXT/multipleWidth characters.
replace(/2/g, function(m) {
replace(/2/g, function() {
len -= 1;
});
@@ -1381,7 +1435,6 @@ var EditSession = function(text, mode) {
var docRow = 0;
var docColumn = 0;
var column;
var foldLineRowLength;
var row = 0;
var rowLength = 0;
@@ -1481,8 +1534,6 @@ var EditSession = function(text, mode) {
docRow = pos.row;
docColumn = pos.column;
var LL = this.$rowCache.length;
var wrapData;
// Special case in wrapMode if the doc is at the end of the document.
if (this.$useWrapMode) {
@@ -1498,7 +1549,6 @@ var EditSession = function(text, mode) {
}
var screenRow = 0;
var screenColumn = 0;
var foldStartRow = null;
var fold = null;

View File

@@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var TokenIterator = require("../token_iterator").TokenIterator;
@@ -92,15 +93,15 @@ function BracketMatch() {
while (true) {
while (valueIndex >= 0) {
var char = value.charAt(valueIndex);
if (char == openBracket) {
var chr = value.charAt(valueIndex);
if (chr == openBracket) {
depth -= 1;
if (depth == 0) {
return {row: iterator.getCurrentTokenRow(),
column: valueIndex + iterator.getCurrentTokenColumn()};
}
}
else if (char == bracket) {
else if (chr == bracket) {
depth += 1;
}
valueIndex -= 1;
@@ -146,15 +147,15 @@ function BracketMatch() {
var value = token.value;
var valueLength = value.length;
while (valueIndex < valueLength) {
var char = value.charAt(valueIndex);
if (char == closingBracket) {
var chr = value.charAt(valueIndex);
if (chr == closingBracket) {
depth -= 1;
if (depth == 0) {
return {row: iterator.getCurrentTokenRow(),
column: valueIndex + iterator.getCurrentTokenColumn()};
}
}
else if (char == bracket) {
else if (chr == bracket) {
depth += 1;
}
valueIndex += 1;

View File

@@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
/**
* Simple fold-data struct.
@@ -74,6 +75,42 @@ var Fold = exports.Fold = function(range, placeholder) {
return fold;
};
this.addSubFold = function(fold) {
if (this.range.isEequal(fold))
return this;
if (!this.range.containsRange(fold))
throw "A fold can't intersect already existing fold" + fold.range + this.range;
var row = fold.range.start.row, column = fold.range.start.column;
for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
cmp = this.subFolds[i].range.compare(row, column);
if (cmp != 1)
break;
}
var afterStart = this.subFolds[i];
if (cmp == 0)
return afterStart.addSubFold(fold)
// cmp == -1
var row = fold.range.end.row, column = fold.range.end.column;
for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
cmp = this.subFolds[j].range.compare(row, column);
if (cmp != 1)
break;
}
var afterEnd = this.subFolds[j];
if (cmp == 0)
throw "A fold can't intersect already existing fold" + fold.range + this.range;
var consumedFolds = this.subFolds.splice(i, j - i, fold)
fold.setFoldLine(this.foldLine);
return fold;
}
}).call(Fold.prototype);
});

View File

@@ -37,11 +37,12 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var Range = require("../range").Range;
/**
* If the an array is passed in, the folds are expected to be sorted already.
* If an array is passed in, the folds are expected to be sorted already.
*/
function FoldLine(foldData, folds) {
this.foldData = foldData;

View File

@@ -37,10 +37,12 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var Range = require("../range").Range;
var FoldLine = require("./fold_line").FoldLine;
var Fold = require("./fold").Fold;
var TokenIterator = require("../token_iterator").TokenIterator;
function Folding() {
/**
@@ -111,7 +113,30 @@ function Folding() {
}
}
return foundFolds;
}
};
/**
* Returns all folds in the document
*/
this.getAllFolds = function() {
var folds = [];
var foldLines = this.$foldData;
function addFold(fold) {
folds.push(fold);
if (!fold.subFolds)
return;
for (var i = 0; i < fold.subFolds.length; i++)
addFold(fold.subFolds[i]);
}
for (var i = 0; i < foldLines.length; i++)
for (var j = 0; j < foldLines[i].folds.length; j++)
addFold(foldLines[i].folds[j]);
return folds;
};
/**
* Returns the string between folds at the given position.
@@ -131,7 +156,7 @@ function Folding() {
* fo|o<fold>bar<fold>wolrd -trim=00> "foo"
*/
this.getFoldStringAt = function(row, column, trim, foldLine) {
var foldLine = foldLine || this.getFoldLine(row);
foldLine = foldLine || this.getFoldLine(row);
if (!foldLine)
return null;
@@ -139,16 +164,17 @@ function Folding() {
end: { column: 0 }
};
// TODO: Refactor to use getNextFoldTo function.
var str, fold;
for (var i = 0; i < foldLine.folds.length; i++) {
var fold = foldLine.folds[i];
fold = foldLine.folds[i];
var cmp = fold.range.compareEnd(row, column);
if (cmp == -1) {
var str = this
str = this
.getLine(fold.start.row)
.substring(lastFold.end.column, fold.start.column);
break;
}
else if (cmp == 0) {
else if (cmp === 0) {
return null;
}
lastFold = fold;
@@ -159,10 +185,10 @@ function Folding() {
if (trim == -1)
return str.substring(0, column - lastFold.end.column);
else if (trim == 1)
return str.substring(column - lastFold.end.column)
return str.substring(column - lastFold.end.column);
else
return str;
}
};
this.getFoldLine = function(docRow, startFoldLine) {
var foldData = this.$foldData;
@@ -180,11 +206,11 @@ function Folding() {
}
}
return null;
}
};
// returns the fold which starts after or contains docRow
this.getNextFoldLine = function(docRow, startFoldLine) {
var foldData = this.$foldData, ans;
var foldData = this.$foldData;
var i = 0;
if (startFoldLine)
i = foldData.indexOf(startFoldLine);
@@ -197,7 +223,7 @@ function Folding() {
}
}
return null;
}
};
this.getFoldedRowCount = function(first, last) {
var foldData = this.$foldData, rowCount = last-first+1;
@@ -221,7 +247,7 @@ function Folding() {
}
}
return rowCount;
}
};
this.$addFoldLine = function(foldLine) {
this.$foldData.push(foldLine);
@@ -229,7 +255,7 @@ function Folding() {
return a.start.row - b.start.row;
});
return foldLine;
}
};
/**
* Adds a new fold.
@@ -241,12 +267,15 @@ function Folding() {
this.addFold = function(placeholder, range) {
var foldData = this.$foldData;
var added = false;
var fold;
if (placeholder instanceof Fold)
var fold = placeholder;
fold = placeholder;
else
fold = new Fold(range, placeholder);
this.$clipRangeToDocument(fold.range);
var startRow = fold.start.row;
var startColumn = fold.start.column;
var endRow = fold.end.row;
@@ -259,29 +288,18 @@ function Folding() {
if (startRow == endRow && endColumn - startColumn < 2)
throw "The range has to be at least 2 characters width";
var existingFold = this.getFoldAt(startRow, startColumn, 1);
var startFold = this.getFoldAt(startRow, startColumn, 1);
var endFold = this.getFoldAt(endRow, endColumn, -1);
if (startFold && endFold == startFold)
return startFold.addSubFold(fold);
if (
existingFold
&& existingFold.range.isEnd(endRow, endColumn)
&& existingFold.range.isStart(startRow, startColumn)
(startFold && !startFold.range.isStart(startRow, startColumn))
|| (endFold && !endFold.range.isEnd(endRow, endColumn))
) {
return fold;
throw "A fold can't intersect already existing fold" + fold.range + startFold.range;
}
existingFold = this.getFoldAt(startRow, startColumn, 1);
if (existingFold && !existingFold.range.isStart(startRow, startColumn))
throw "A fold can't start inside of an already existing fold";
existingFold = this.getFoldAt(endRow, endColumn, -1);
if (existingFold && !existingFold.range.isEnd(endRow, endColumn))
throw "A fold can't end inside of an already existing fold";
if (endRow >= this.doc.getLength())
throw "End of fold is outside of the document.";
if (endColumn > this.getLine(endRow).length || startColumn > this.getLine(startRow).length)
throw "End of fold is outside of the document.";
// Check if there are folds in the range we create the new fold for.
var folds = this.getFoldsInRange(fold.range);
if (folds.length > 0) {
@@ -303,7 +321,7 @@ function Folding() {
added = true;
if (!fold.sameRow) {
// Check if we might have to merge two FoldLines.
foldLineNext = foldData[i + 1];
var foldLineNext = foldData[i + 1];
if (foldLineNext && foldLineNext.start.row == endRow) {
// We need to merge!
foldLine.merge(foldLineNext);
@@ -325,7 +343,7 @@ function Folding() {
// Notify that fold data has changed.
this.$modified = true;
this._dispatchEvent("changeFold", { data: fold });
this._emit("changeFold", { data: fold });
return fold;
};
@@ -341,8 +359,8 @@ function Folding() {
var startRow = foldLine.start.row;
var endRow = foldLine.end.row;
var foldLines = this.$foldData,
folds = foldLine.folds;
var foldLines = this.$foldData;
var folds = foldLine.folds;
// Simple case where there is only one fold in the FoldLine such that
// the entire fold line can get removed directly.
if (folds.length == 1) {
@@ -383,8 +401,8 @@ function Folding() {
// Notify that fold data has changed.
this.$modified = true;
this._dispatchEvent("changeFold", { data: fold });
}
this._emit("changeFold", { data: fold });
};
this.removeFolds = function(folds) {
// We need to clone the folds array passed in as it might be the folds
@@ -399,7 +417,7 @@ function Folding() {
this.removeFold(fold);
}, this);
this.$modified = true;
}
};
this.expandFold = function(fold) {
this.removeFold(fold);
@@ -407,13 +425,13 @@ function Folding() {
this.addFold(fold);
}, this);
fold.subFolds = [];
}
};
this.expandFolds = function(folds) {
folds.forEach(function(fold) {
this.expandFold(fold);
}, this);
}
};
this.unfold = function(location, expandInner) {
var range, folds;
@@ -426,7 +444,7 @@ function Folding() {
else
range = location;
var folds = this.getFoldsInRange(range);
folds = this.getFoldsInRange(range);
if (expandInner) {
this.removeFolds(folds);
} else {
@@ -437,7 +455,7 @@ function Folding() {
folds = this.getFoldsInRange(range);
}
}
}
};
/**
* Checks if a given documentRow is folded. This is true if there are some
@@ -450,8 +468,8 @@ function Folding() {
this.getRowFoldEnd = function(docRow, startFoldRow) {
var foldLine = this.getFoldLine(docRow, startFoldRow);
return (foldLine
? foldLine.end.row
: docRow)
? foldLine.end.row
: docRow);
};
this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
@@ -466,11 +484,10 @@ function Folding() {
}
// Build the textline using the FoldLine walker.
var line = "";
var doc = this.doc;
var textLine = "";
foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
foldLine.walk(function(placeholder, row, column, lastColumn) {
if (row < startRow) {
return;
} else if (row == startRow) {
@@ -502,7 +519,6 @@ function Folding() {
};
this.$cloneFoldData = function() {
var foldData = this.$foldData;
var fd = [];
fd = this.$foldData.map(function(foldLine) {
var folds = foldLine.folds.map(function(fold) {
@@ -517,57 +533,45 @@ function Folding() {
this.toggleFold = function(tryToUnfold) {
var selection = this.selection;
var range = selection.getRange();
var fold;
var bracketPos;
if (range.isEmpty()) {
var cursor = range.start
var fold = this.getFoldAt(cursor.row, cursor.column);
var bracketPos, column;
var cursor = range.start;
fold = this.getFoldAt(cursor.row, cursor.column);
if (fold) {
this.expandFold(fold);
return;
} else if (bracketPos = this.findMatchingBracket(cursor)) {
}
else if (bracketPos = this.findMatchingBracket(cursor)) {
if (range.comparePoint(bracketPos) == 1) {
range.end = bracketPos;
} else {
}
else {
range.start = bracketPos;
range.start.column++;
range.end.column--;
}
} else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
}
else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
if (range.comparePoint(bracketPos) == 1)
range.end = bracketPos;
else
range.start = bracketPos;
range.start.column++;
} else {
var token = this.getTokenAt(cursor.row, cursor.column);
if (token && /^comment|string/.test(token.type)) {
var startRow = cursor.row;
var endRow = cursor.row;
var t = token;
while ((t = this.getTokenAt(startRow - 1)) && t.type == token.type) {
startRow --;
token = t;
}
range.start.row = startRow;
range.start.column = token.start + 2;
while ((t = this.getTokenAt(endRow + 1, 0)) && t.type == token.type) {
endRow ++;
token = t;
}
range.end.row = endRow;
range.end.column = token.start + token.value.length - 1;
}
}
else {
range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
}
} else {
var folds = this.getFoldsInRange(range);
if (tryToUnfold && folds.length) {
this.expandFolds(folds);
return;
} else if (folds.length == 1 ) {
}
else if (folds.length == 1 ) {
fold = folds[0];
}
}
@@ -575,23 +579,178 @@ function Folding() {
if (!fold)
fold = this.getFoldAt(range.start.row, range.start.column);
if (fold && fold.range.toString() == range.toString()){
if (fold && fold.range.toString() == range.toString()) {
this.expandFold(fold);
return
return;
}
var placeholder = "...";
if (!range.isMultiLine()) {
placeholder = this.getTextRange(range);
if(placeholder.length < 4)
return;
placeholder = placeholder.trim().substring(0, 2) + ".."
placeholder = placeholder.trim().substring(0, 2) + "..";
}
this.addFold(placeholder, range);
};
this.getCommentFoldRange = function(row, column) {
var iterator = new TokenIterator(this, row, column);
var token = iterator.getCurrentToken();
if (token && /^comment|string/.test(token.type)) {
var range = new Range();
var re = new RegExp(token.type.replace(/\..*/, "\\."));
do {
token = iterator.stepBackward();
} while(token && re.test(token.type));
iterator.stepForward();
range.start.row = iterator.getCurrentTokenRow();
range.start.column = iterator.getCurrentTokenColumn() + 2;
iterator = new TokenIterator(this, row, column);
do {
token = iterator.stepForward();
} while(token && re.test(token.type));
token = iterator.stepBackward();
range.end.row = iterator.getCurrentTokenRow();
range.end.column = iterator.getCurrentTokenColumn() + token.value.length;
return range;
}
};
this.foldAll = function(startRow, endRow) {
var foldWidgets = this.foldWidgets;
endRow = endRow || this.getLength();
for (var row = startRow || 0; row < endRow; row++) {
if (foldWidgets[row] == null)
foldWidgets[row] = this.getFoldWidget(row);
if (foldWidgets[row] != "start")
continue;
var range = this.getFoldWidgetRange(row);
// sometimes range can be incompatible with existing fold
// wouldn't it be better for addFold to return null istead of throwing?
if (range && range.end.row < endRow) try {
this.addFold("...", range);
} catch(e) {}
}
};
this.$foldStyles = {
"manual": 1,
"markbegin": 1,
"markbeginend": 1
};
this.$foldStyle = "markbegin";
this.setFoldStyle = function(style) {
if (!this.$foldStyles[style])
throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
if (this.$foldStyle == style)
return;
this.$foldStyle = style;
if (style == "manual")
this.unfold();
// reset folding
var mode = this.$foldMode;
this.$setFolding(null);
this.$setFolding(mode);
};
// structured folding
this.$setFolding = function(foldMode) {
if (this.$foldMode == foldMode)
return;
this.$foldMode = foldMode;
this.removeListener('change', this.$updateFoldWidgets);
this._emit("changeAnnotation");
if (!foldMode || this.$foldStyle == "manual") {
this.foldWidgets = null;
return;
}
this.foldWidgets = [];
this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
this.on('change', this.$updateFoldWidgets);
};
this.onFoldWidgetClick = function(row, e) {
var type = this.getFoldWidget(row);
var line = this.getLine(row);
var onlySubfolds = e.shiftKey;
var addSubfolds = onlySubfolds || e.ctrlKey || e.altKey || e.metaKey;
var fold;
if (type == "end")
fold = this.getFoldAt(row, 0, -1);
else
fold = this.getFoldAt(row, line.length, 1);
if (fold) {
if (addSubfolds)
this.removeFold(fold);
else
this.expandFold(fold);
return;
}
var range = this.getFoldWidgetRange(row);
if (range) {
// sometimes singleline folds can be missed by the code above
if (!range.isMultiLine()) {
fold = this.getFoldAt(range.start.row, range.start.column, 1);
if (fold && range.isEequal(fold.range)) {
this.removeFold(fold);
return;
}
}
if (!onlySubfolds)
this.addFold("...", range);
if (addSubfolds)
this.foldAll(range.start.row + 1, range.end.row);
} else {
if (addSubfolds)
this.foldAll(row + 1, this.getLength());
e.target.className += " invalid"
}
};
this.updateFoldWidgets = function(e) {
var delta = e.data;
var range = delta.range;
var firstRow = range.start.row;
var len = range.end.row - firstRow;
if (len === 0) {
this.foldWidgets[firstRow] = null;
} else if (delta.action == "removeText" || delta.action == "removeLines") {
this.foldWidgets.splice(firstRow, len + 1, null);
} else {
var args = Array(len + 1);
args.unshift(firstRow, 1);
this.foldWidgets.splice.apply(this.foldWidgets, args);
}
};
}
exports.Folding = Folding;
});
});

View File

@@ -42,6 +42,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var lang = require("./lib/lang");
var EditSession = require("./edit_session").EditSession;
@@ -109,10 +110,10 @@ module.exports = {
assert.position(session.findMatchingBracket({row: 6, column: 20}), 1, 15);
assert.position(session.findMatchingBracket({row: 1, column: 22}), 1, 20);
assert.position(session.findMatchingBracket({row: 3, column: 31}), 3, 21);
assert.position(session.findMatchingBracket({row: 4, column: 24}), 4, 19);
assert.position(session.findMatchingBracket({row: 4, column: 24}), 4, 19);
assert.equal(session.findMatchingBracket({row: 0, column: 1}), null);
},
"test: find matching closing bracket in JavaScript mode" : function() {
var lines = [
"function foo() {",
@@ -131,7 +132,7 @@ module.exports = {
assert.position(session.findMatchingBracket({row: 1, column: 16}), 6, 19);
assert.position(session.findMatchingBracket({row: 1, column: 21}), 1, 21);
assert.position(session.findMatchingBracket({row: 3, column: 22}), 3, 30);
assert.position(session.findMatchingBracket({row: 4, column: 20}), 4, 23);
assert.position(session.findMatchingBracket({row: 4, column: 20}), 4, 23);
},
"test: handle unbalanced brackets in JavaScript mode" : function() {
@@ -223,7 +224,7 @@ module.exports = {
"12\t\t34",
"ぁぁa"
]);
assert.equal(session.getScreenLastRowColumn(0), 4);
assert.equal(session.getScreenLastRowColumn(1), 10);
assert.equal(session.getScreenLastRowColumn(2), 5);
@@ -267,13 +268,13 @@ module.exports = {
"12\t\t34",
"ぁぁa"
]);
assert.position(session.documentToScreenPosition(0, 3), 0, 3);
assert.position(session.documentToScreenPosition(1, 3), 1, 4);
assert.position(session.documentToScreenPosition(1, 4), 1, 8);
assert.position(session.documentToScreenPosition(2, 2), 2, 4);
},
"test: documentToScreen with soft wrap": function() {
var session = new EditSession(["foo bar foo bar"]);
session.setUseWrapMode(true);
@@ -283,10 +284,9 @@ module.exports = {
assert.position(session.documentToScreenPosition(0, 11), 0, 11);
assert.position(session.documentToScreenPosition(0, 12), 1, 0);
},
"test: documentToScreen with soft wrap and multibyte characters": function() {
session = new EditSession(["ぁぁa"]);
"test: documentToScreen with soft wrap and multibyte characters": function() {
var session = new EditSession(["ぁぁa"]);
session.setUseWrapMode(true);
session.setWrapLimitRange(2, 2);
session.adjustWrapLimit(80);
@@ -298,7 +298,7 @@ module.exports = {
"test: documentToScreen should clip position to the document boundaries": function() {
var session = new EditSession("foo bar\njuhu kinners");
assert.position(session.documentToScreenPosition(-1, 4), 0, 0);
assert.position(session.documentToScreenPosition(3, 0), 1, 12);
},
@@ -340,9 +340,9 @@ module.exports = {
assert.position(session.screenToDocumentPosition(0, 12), 0, 11);
assert.position(session.screenToDocumentPosition(0, 20), 0, 11);
},
"test: screenToDocument with soft wrap and multi byte characters": function() {
session = new EditSession(["ぁ a"]);
var session = new EditSession(["ぁ a"]);
session.setUseWrapMode(true);
session.adjustWrapLimit(80);
@@ -352,10 +352,10 @@ module.exports = {
assert.position(session.screenToDocumentPosition(0, 4), 0, 3);
assert.position(session.screenToDocumentPosition(0, 5), 0, 3);
},
"test: screenToDocument should clip position to the document boundaries": function() {
var session = new EditSession("foo bar\njuhu kinners");
assert.position(session.screenToDocumentPosition(-1, 4), 0, 0);
assert.position(session.screenToDocumentPosition(0, -1), 0, 0);
assert.position(session.screenToDocumentPosition(0, 30), 0, 7);
@@ -374,9 +374,6 @@ module.exports = {
},
"test: wrapLine split function" : function() {
var splits;
var c = 0;
function computeAndAssert(line, assertEqual, wrapLimit, tabSize) {
wrapLimit = wrapLimit || 12;
tabSize = tabSize || 4;
@@ -618,9 +615,9 @@ module.exports = {
},
"test getFoldsInRange()": function() {
var session = createFoldTestSession(),
foldLines = session.$foldData;
folds = foldLines[0].folds.concat(foldLines[1].folds);
var session = createFoldTestSession();
var foldLines = session.$foldData;
var folds = foldLines[0].folds.concat(foldLines[1].folds);
function test(startRow, startColumn, endColumn, endRow, folds) {
var r = new Range(startRow, startColumn, endColumn, endRow);
@@ -649,7 +646,7 @@ module.exports = {
var session = createFoldTestSession();
var undoManager = session.getUndoManager();
var foldLines = session.$foldData;
function insert(row, column, text) {
session.insert({row: row, column: column}, text);
@@ -930,7 +927,7 @@ module.exports = {
}
}
tryAddFold("foo", new Range(0, 13, 0, 17), true);
tryAddFold("foo", new Range(0, 13, 0, 17), false);
tryAddFold("foo", new Range(0, 14, 0, 18), true);
tryAddFold("foo", new Range(0, 13, 0, 18), false);
assert.equal(session.$foldData[0].folds.length, 1);
@@ -940,9 +937,9 @@ module.exports = {
assert.equal(session.$foldData[0].folds.length, 2);
session.removeFold(fold);
tryAddFold("foo", new Range(0, 18, 0, 22), true);
tryAddFold("foo", new Range(0, 18, 0, 22), false);
tryAddFold("foo", new Range(0, 18, 0, 19), true);
tryAddFold("foo", new Range(0, 22, 1, 10), true);
tryAddFold("foo", new Range(0, 22, 1, 10), false);
},
"test add subfolds": function() {
@@ -972,6 +969,12 @@ module.exports = {
assert.equal(foldData[0].folds.length, 1);
assert.equal(foldData[0].folds[0], oldFold);
assert.equal(fold.subFolds.length, 0);
session.unfold(null, true);
fold = session.addFold("fold0", new Range(0, 0, 0, 21));
session.addFold("fold0", new Range(0, 1, 0, 5));
session.addFold("fold0", new Range(0, 6, 0, 8));
assert.equal(fold.subFolds.length, 2);
}
};

125
vendor/ace/editor.js vendored
View File

@@ -39,15 +39,16 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
require("./lib/fixoldbrowsers");
var oop = require("./lib/oop");
var event = require("./lib/event");
var lang = require("./lib/lang");
var useragent = require("./lib/useragent");
var TextInput = require("./keyboard/textinput").TextInput;
var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
var FoldHandler = require("./mouse/fold_handler").FoldHandler;
//var TouchHandler = require("./touch_handler").TouchHandler;
var KeyBinding = require("./keyboard/keybinding").KeyBinding;
var EditSession = require("./edit_session").EditSession;
@@ -61,7 +62,7 @@ var Editor = function(renderer, session) {
var container = renderer.getContainerElement();
this.container = container;
this.renderer = renderer;
this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
this.keyBinding = new KeyBinding(this);
@@ -70,6 +71,7 @@ var Editor = function(renderer, session) {
//this.$mouseHandler = new TouchHandler(this);
} else {
this.$mouseHandler = new MouseHandler(this);
new FoldHandler(this);
}
this.$blockScrolling = 0;
@@ -85,30 +87,6 @@ var Editor = function(renderer, session) {
oop.implement(this, EventEmitter);
this.$forwardEvents = {
gutterclick: 1,
gutterdblclick: 1
};
this.$originalAddEventListener = this.addEventListener;
this.$originalRemoveEventListener = this.removeEventListener;
this.addEventListener = function(eventName, callback) {
if (this.$forwardEvents[eventName]) {
return this.renderer.addEventListener(eventName, callback);
} else {
return this.$originalAddEventListener(eventName, callback);
}
};
this.removeEventListener = function(eventName, callback) {
if (this.$forwardEvents[eventName]) {
return this.renderer.removeEventListener(eventName, callback);
} else {
return this.$originalRemoveEventListener(eventName, callback);
}
};
this.setKeyboardHandler = function(keyboardHandler) {
this.keyBinding.setKeyboardHandler(keyboardHandler);
};
@@ -135,12 +113,12 @@ var Editor = function(renderer, session) {
this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange);
this.session.removeEventListener("changeLeftTop", this.$onScrollLeftChange);
var selection = this.session.getSelection();
selection.removeEventListener("changeCursor", this.$onCursorChange);
selection.removeEventListener("changeSelection", this.$onSelectionChange);
this.session.setScrollTopRow(this.renderer.getScrollTopRow());
}
this.session = session;
@@ -182,6 +160,12 @@ var Editor = function(renderer, session) {
this.$onCursorChange = this.onCursorChange.bind(this);
this.session.addEventListener("changeOverwrite", this.$onCursorChange);
this.$onScrollTopChange = this.onScrollTopChange.bind(this);
this.session.addEventListener("changeScrollTop", this.$onScrollTopChange);
this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange);
this.selection = session.getSelection();
this.selection.addEventListener("changeCursor", this.$onCursorChange);
@@ -190,17 +174,21 @@ var Editor = function(renderer, session) {
this.onChangeMode();
this.$blockScrolling += 1;
this.onCursorChange();
this.$blockScrolling -= 1;
this.onScrollTopChange();
this.onScrollLeftChange();
this.onSelectionChange();
this.onChangeFrontMarker();
this.onChangeBackMarker();
this.onChangeBreakpoint();
this.onChangeAnnotation();
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
this.renderer.scrollToRow(session.getScrollTopRow());
this.renderer.updateFull();
this._dispatchEvent("changeSession", {
this._emit("changeSession", {
session: session,
oldSession: oldSession
});
@@ -236,6 +224,7 @@ var Editor = function(renderer, session) {
this.setFontSize = function(size) {
this.container.style.fontSize = size;
this.renderer.updateFontSize();
};
this.$highlightBrackets = function() {
@@ -284,26 +273,27 @@ var Editor = function(renderer, session) {
this.onFocus = function() {
this.renderer.showCursor();
this.renderer.visualizeFocus();
this._dispatchEvent("focus");
this._emit("focus");
};
this.onBlur = function() {
this.renderer.hideCursor();
this.renderer.visualizeBlur();
this._dispatchEvent("blur");
this._emit("blur");
};
this.onDocumentChange = function(e) {
var delta = e.data;
var range = delta.range;
var lastRow;
if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines")
var lastRow = range.end.row;
lastRow = range.end.row;
else
lastRow = Infinity;
this.renderer.updateLines(range.start.row, lastRow);
this._dispatchEvent("change", e);
this._emit("change", e);
// update cursor because tab characters can influence the cursor position
this.onCursorChange();
@@ -314,7 +304,15 @@ var Editor = function(renderer, session) {
this.renderer.updateLines(rows.first, rows.last);
};
this.onCursorChange = function(e) {
this.onScrollTopChange = function() {
this.renderer.scrollToY(this.session.getScrollTop());
};
this.onScrollLeftChange = function() {
this.renderer.scrollToX(this.session.getScrollLeft());
};
this.onCursorChange = function() {
this.renderer.updateCursor();
if (!this.$blockScrolling) {
@@ -445,7 +443,7 @@ var Editor = function(renderer, session) {
// remove selected text
if (!this.selection.isEmpty()) {
var cursor = this.session.remove(this.getSelectionRange());
cursor = this.session.remove(this.getSelectionRange());
this.clearSelection();
}
else if (this.session.getOverwrite()) {
@@ -548,7 +546,15 @@ var Editor = function(renderer, session) {
};
this.getScrollSpeed = function() {
return this.$mouseHandler.getScrollSpeed()
return this.$mouseHandler.getScrollSpeed();
};
this.setDragDelay = function(dragDelay) {
this.$mouseHandler.setDragDelay(dragDelay);
};
this.getDragDelay = function() {
return this.$mouseHandler.getDragDelay();
};
this.$selectionStyle = "line";
@@ -557,7 +563,7 @@ var Editor = function(renderer, session) {
this.$selectionStyle = style;
this.onSelectionChange();
this._dispatchEvent("changeSelectionStyle", {data: style});
this._emit("changeSelectionStyle", {data: style});
};
this.getSelectionStyle = function() {
@@ -637,6 +643,20 @@ var Editor = function(renderer, session) {
return this.$modeBehaviours;
};
this.setShowFoldWidgets = function(show) {
var gutter = this.renderer.$gutterLayer;
if (gutter.getShowFoldWidgets() == show)
return;
this.renderer.$gutterLayer.setShowFoldWidgets(show);
this.$showFoldWidgets = show;
this.renderer.updateFull();
};
this.getShowFoldWidgets = function() {
return this.renderer.$gutterLayer.getShowFoldWidgets();
};
this.remove = function(dir) {
if (this.selection.isEmpty()){
if(dir == "left")
@@ -791,7 +811,7 @@ var Editor = function(renderer, session) {
this.removeLines = function() {
var rows = this.$getSelectedRows();
var range;
if (rows.first == 0 || rows.last+1 < this.session.getLength())
if (rows.first === 0 || rows.last+1 < this.session.getLength())
range = new Range(rows.first, 0, rows.last+1, 0);
else
range = new Range(
@@ -849,7 +869,8 @@ var Editor = function(renderer, session) {
range.start.row += linesMoved;
range.end.row += linesMoved;
selection.setSelectionRange(range, reverse);
} else {
}
else {
selection.setSelectionAnchor(rows.last+linesMoved+1, 0);
selection.$moveSelection(function() {
selection.moveCursorTo(rows.first+linesMoved, 0);
@@ -1001,10 +1022,27 @@ var Editor = function(renderer, session) {
this.selection.moveCursorToPosition(pos);
};
this.jumpToMatching = function() {
var cursor = this.getCursorPosition();
var pos = this.session.findMatchingBracket(cursor);
if (!pos) {
cursor.column += 1;
pos = this.session.findMatchingBracket(cursor);
}
if (!pos) {
cursor.column -= 2;
pos = this.session.findMatchingBracket(cursor);
}
if (pos) {
this.clearSelection();
this.moveCursorTo(pos.row, pos.column);
}
};
this.gotoLine = function(lineNumber, column) {
this.selection.clearSelection();
this.session.unfold({row: lineNumber - 1, column: column || 0})
this.session.unfold({row: lineNumber - 1, column: column || 0});
this.$blockScrolling += 1;
this.moveCursorTo(lineNumber-1, column || 0);
@@ -1171,8 +1209,7 @@ var Editor = function(renderer, session) {
var range = this.$search.find(this.session);
if (range) {
this.session.unfold(range);
this.gotoLine(range.end.row+1, range.end.column);
this.selection.setSelectionRange(range);
this.selection.setSelectionRange(range); // this scrolls selection into view
}
};

View File

@@ -41,6 +41,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var EditSession = require("./edit_session").EditSession;
var Editor = require("./editor").Editor;

View File

@@ -42,11 +42,11 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var EditSession = require("./edit_session").EditSession;
var Editor = require("./editor").Editor;
var MockRenderer = require("./test/mockrenderer").MockRenderer;
var TextMode = require("./mode/text").Mode;
var assert = require("./test/assertions");
var lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +

View File

@@ -41,6 +41,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var EditSession = require("./edit_session").EditSession;
var Editor = require("./editor").Editor;

View File

@@ -41,6 +41,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var EditSession = require("./edit_session").EditSession;
var Editor = require("./editor").Editor;

View File

@@ -12,7 +12,7 @@
margin-right: 3px;
}
.ace-row { clear: both; }
.ace_line { clear: both; }
*.ace_gutter-cell {
-moz-user-select: -moz-none;

View File

@@ -38,6 +38,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var EditSession = require("../edit_session").EditSession;
var TextLayer = require("../layer/text").Text;
@@ -51,7 +52,9 @@ var baseStyles = require("../requirejs/text!./static.css");
* @returns {object} An object containing: html, css
*/
exports.render = function(input, mode, theme) {
exports.render = function(input, mode, theme, lineStart) {
lineStart = parseInt(lineStart || 1, 10);
var session = new EditSession("");
session.setMode(mode);
session.setUseWorker(false);
@@ -71,8 +74,8 @@ exports.render = function(input, mode, theme) {
for(var ix = 0; ix < length; ix++) {
var lineTokens = tokens[ix].tokens;
stringBuilder.push("<div class='ace-row'>");
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + (ix+1) + "</span>");
stringBuilder.push("<div class='ace_line'>");
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + (ix + lineStart) + "</span>");
textLayer.$renderLine(stringBuilder, 0, lineTokens, true);
stringBuilder.push("</div>");
}

View File

@@ -4,7 +4,8 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var assert = require("assert");
var highlighter = require("./static_highlight");
var JavaScriptMode = require("../mode/javascript").Mode;

505
vendor/ace/ext/textarea.js vendored Normal file
View File

@@ -0,0 +1,505 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Skywriter.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kevin Dangoor (kdangoor@mozilla.com)
* Julian Viereck <julian.viereck@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var Event = require("../lib/event");
var UA = require("../lib/useragent");
var net = require("../lib/net");
var ace = require("../ace");
require("ace/theme/textmate");
/**
* Returns the CSS property of element.
* 1) If the CSS property is on the style object of the element, use it, OR
* 2) Compute the CSS property
*
* If the property can't get computed, is 'auto' or 'intrinsic', the former
* calculated property is uesd (this can happen in cases where the textarea
* is hidden and has no dimension styles).
*/
var getCSSProperty = function(element, container, property) {
var ret = element.style[property];
if (!ret) {
if (window.getComputedStyle) {
ret = window.getComputedStyle(element, '').getPropertyValue(property);
} else {
ret = element.currentStyle[property];
}
}
if (!ret || ret == 'auto' || ret == 'intrinsic') {
ret = container.style[property];
}
return ret;
};
function applyStyles(elm, styles) {
for (var style in styles) {
elm.style[style] = styles[style];
}
}
function setupContainer(element, getValue) {
if (element.type != 'textarea') {
throw "Textarea required!";
}
var parentNode = element.parentNode;
// This will hold the editor.
var container = document.createElement('div');
// To put Ace in the place of the textarea, we have to copy a few of the
// textarea's style attributes to the div container.
//
// The problem is that the properties have to get computed (they might be
// defined by a CSS file on the page - you can't access such rules that
// apply to an element via elm.style). Computed properties are converted to
// pixels although the dimension might be given as percentage. When the
// window resizes, the dimensions defined by percentages changes, so the
// properties have to get recomputed to get the new/true pixels.
var resizeEvent = function() {
var style = 'position:relative;';
[
'margin-top', 'margin-left', 'margin-right', 'margin-bottom'
].forEach(function(item) {
style += item + ':' +
getCSSProperty(element, container, item) + ';';
});
// Calculating the width/height of the textarea is somewhat tricky. To
// do it right, you have to include the paddings to the sides as well
// (eg. width = width + padding-left, -right). This works well, as
// long as the width of the element is not set or given in pixels. In
// this case and after the textarea is hidden, getCSSProperty(element,
// container, 'width') will still return pixel value. If the element
// has realtiv dimensions (e.g. width='95<percent>')
// getCSSProperty(...) will return pixel values only as long as the
// textarea is visible. After it is hidden getCSSProperty will return
// the relative dimensions as they are set on the element (in the case
// of width, 95<percent>).
// Making the sum of pixel vaules (e.g. padding) and realtive values
// (e.g. <percent>) is not possible. As such the padding styles are
// ignored.
// The complete width is the width of the textarea + the padding
// to the left and right.
var width = getCSSProperty(element, container, 'width') || (element.clientWidth + "px");
var height = getCSSProperty(element, container, 'height') || (element.clientHeight + "px");
style += 'height:' + height + ';width:' + width + ';';
// Set the display property to 'inline-block'.
style += 'display:inline-block;';
container.setAttribute('style', style);
};
Event.addListener(window, 'resize', resizeEvent);
// Call the resizeEvent once, so that the size of the container is
// calculated.
resizeEvent();
// Insert the div container after the element.
if (element.nextSibling) {
parentNode.insertBefore(container, element.nextSibling);
} else {
parentNode.appendChild(container);
}
// Override the forms onsubmit function. Set the innerHTML and value
// of the textarea before submitting.
while (parentNode !== document) {
if (parentNode.tagName.toUpperCase() === 'FORM') {
var oldSumit = parentNode.onsubmit;
// Override the onsubmit function of the form.
parentNode.onsubmit = function(evt) {
element.innerHTML = getValue();
element.value = getValue();
// If there is a onsubmit function already, then call
// it with the current context and pass the event.
if (oldSumit) {
oldSumit.call(this, evt);
}
};
break;
}
parentNode = parentNode.parentNode;
}
return container;
}
exports.transformTextarea = function(element, loader) {
var session;
var container = setupContainer(element, function() {
return session.getValue();
});
// Hide the element.
element.style.display = 'none';
container.style.background = 'white';
//
var editorDiv = document.createElement("div");
applyStyles(editorDiv, {
top: "0px",
left: "0px",
right: "0px",
bottom: "0px",
border: "1px solid gray"
});
container.appendChild(editorDiv);
var settingOpener = document.createElement("div");
applyStyles(settingOpener, {
position: "absolute",
width: "15px",
right: "0px",
bottom: "0px",
background: "red",
cursor: "pointer",
textAlign: "center",
fontSize: "12px"
});
settingOpener.innerHTML = "I";
var settingDiv = document.createElement("div");
var settingDivStyles = {
top: "0px",
left: "0px",
right: "0px",
bottom: "0px",
position: "absolute",
padding: "5px",
zIndex: 100,
color: "white",
display: "none",
overflow: "auto",
fontSize: "14px"
};
if (!UA.isOldIE) {
settingDivStyles.backgroundColor = "rgba(0, 0, 0, 0.6)";
} else {
settingDivStyles.backgroundColor = "#333";
}
applyStyles(settingDiv, settingDivStyles);
container.appendChild(settingDiv);
// Power up ace on the textarea:
var options = {};
var editor = ace.edit(editorDiv);
session = editor.getSession();
session.setValue(element.value || element.innerHTML);
editor.focus();
// Add the settingPanel opener to the editor's div.
editorDiv.appendChild(settingOpener);
// Create the API.
var api = setupApi(editor, editorDiv, settingDiv, ace, options, loader);
// Create the setting's panel.
setupSettingPanel(settingDiv, settingOpener, api, options);
return api;
};
function load(url, module, callback) {
net.loadScript(url, function() {
require([module], callback);
});
}
function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
var session = editor.getSession();
var renderer = editor.renderer;
loader = loader || load;
function toBool(value) {
return value == "true";
}
var ret = {
setDisplaySettings: function(display) {
settingDiv.style.display = display ? "block" : "none";
},
setOption: function(key, value) {
if (options[key] == value) return;
switch (key) {
case "gutter":
renderer.setShowGutter(toBool(value));
break;
case "mode":
if (value != "text") {
// Load the required mode file. Files get loaded only once.
loader("mode-" + value + ".js", "ace/mode/" + value, function() {
var aceMode = require("../mode/" + value).Mode;
session.setMode(new aceMode());
});
} else {
session.setMode(new (require("../mode/text").Mode));
}
break;
case "theme":
if (value != "textmate") {
// Load the required theme file. Files get loaded only once.
loader("theme-" + value + ".js", "ace/theme/" + value, function() {
editor.setTheme("ace/theme/" + value);
});
} else {
editor.setTheme("ace/theme/textmate");
}
break;
case "fontSize":
editorDiv.style.fontSize = value;
break;
case "softWrap":
switch (value) {
case "off":
session.setUseWrapMode(false);
renderer.setPrintMarginColumn(80);
break;
case "40":
session.setUseWrapMode(true);
session.setWrapLimitRange(40, 40);
renderer.setPrintMarginColumn(40);
break;
case "80":
session.setUseWrapMode(true);
session.setWrapLimitRange(80, 80);
renderer.setPrintMarginColumn(80);
break;
case "free":
session.setUseWrapMode(true);
session.setWrapLimitRange(null, null);
renderer.setPrintMarginColumn(80);
break;
}
break;
case "useSoftTabs":
session.setUseSoftTabs(toBool(value));
break;
case "showPrintMargin":
renderer.setShowPrintMargin(toBool(value));
break;
case "showInvisibles":
editor.setShowInvisibles(toBool(value));
break;
}
options[key] = value;
},
getOption: function(key) {
return options[key];
},
getOptions: function() {
return options;
}
};
for (var option in exports.options) {
ret.setOption(option, exports.options[option]);
}
return ret;
}
function setupSettingPanel(settingDiv, settingOpener, api, options) {
var BOOL = {
"true": true,
"false": false
};
var desc = {
mode: "Mode:",
gutter: "Display Gutter:",
theme: "Theme:",
fontSize: "Font Size:",
softWrap: "Soft Wrap:",
showPrintMargin: "Show Print Margin:",
useSoftTabs: "Use Soft Tabs:",
showInvisibles: "Show Invisibles"
};
var optionValues = {
mode: {
text: "Plain",
javascript: "JavaScript",
xml: "XML",
html: "HTML",
css: "CSS",
scss: "SCSS",
python: "Python",
php: "PHP",
java: "Java",
ruby: "Ruby",
c_cpp: "C/C++",
coffee: "CoffeeScript",
json: "json",
perl: "Perl",
clojure: "Clojure",
ocaml: "OCaml",
csharp: "C#",
haxe: "haXe",
svg: "SVG",
textile: "Textile",
groovy: "Groovy",
Scala: "Scala"
},
theme: {
clouds: "Clouds",
clouds_midnight: "Clouds Midnight",
cobalt: "Cobalt",
crimson_editor: "Crimson Editor",
dawn: "Dawn",
eclipse: "Eclipse",
idle_fingers: "Idle Fingers",
kr_theme: "Kr Theme",
merbivore: "Merbivore",
merbivore_soft: "Merbivore Soft",
mono_industrial: "Mono Industrial",
monokai: "Monokai",
pastel_on_dark: "Pastel On Dark",
solarized_dark: "Solarized Dark",
solarized_light: "Solarized Light",
textmate: "Textmate",
twilight: "Twilight",
vibrant_ink: "Vibrant Ink"
},
gutter: BOOL,
fontSize: {
"10px": "10px",
"11px": "11px",
"12px": "12px",
"14px": "14px",
"16px": "16px"
},
softWrap: {
off: "Off",
40: "40",
80: "80",
free: "Free"
},
showPrintMargin: BOOL,
useSoftTabs: BOOL,
showInvisibles: BOOL
};
var table = [];
table.push("<table><tr><th>Setting</th><th>Value</th></tr>");
function renderOption(builder, option, obj, cValue) {
builder.push("<select title='" + option + "'>");
for (var value in obj) {
builder.push("<option value='" + value + "' ");
if (cValue == value) {
builder.push(" selected ");
}
builder.push(">",
obj[value],
"</option>");
}
builder.push("</select>");
}
for (var option in options) {
table.push("<tr><td>", desc[option], "</td>");
table.push("<td>");
renderOption(table, option, optionValues[option], options[option]);
table.push("</td></tr>");
}
table.push("</table>");
settingDiv.innerHTML = table.join("");
var selects = settingDiv.getElementsByTagName("select");
for (var i = 0; i < selects.length; i++) {
var onChange = (function() {
var select = selects[i];
return function() {
var option = select.title;
var value = select.value;
api.setOption(option, value);
};
})();
selects[i].onchange = onChange;
}
var button = document.createElement("input");
button.type = "button";
button.value = "Hide";
button.onclick = function() {
api.setDisplaySettings(false);
};
settingDiv.appendChild(button);
settingOpener.onclick = function() {
api.setDisplaySettings(true);
};
}
// Default startup options.
exports.options = {
mode: "text",
theme: "textmate",
gutter: "false",
fontSize: "12px",
softWrap: "off",
showPrintMargin: "false",
useSoftTabs: "true",
showInvisibles: "true"
};
});

View File

@@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var keyUtil = require("../lib/keys");

View File

@@ -38,6 +38,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var keyUtil = require("../lib/keys");
var event = require("../lib/event");
@@ -71,7 +72,7 @@ var KeyBinding = function(editor) {
};
this.getKeyboardHandler = function() {
return this.$handlers[this.$handlers - 1];
return this.$handlers[this.$handlers.length - 1];
};
this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) {
@@ -86,7 +87,9 @@ var KeyBinding = function(editor) {
if (!toExecute || !toExecute.command)
return false;
var success = false, commands = this.$editor.commands;
var success = false;
var commands = this.$editor.commands;
// allow keyboardHandler to consume keys
if (toExecute.command != "null")

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var StateHandler = require("../state_handler").StateHandler;
var matchCharacterOnly = require("../state_handler").matchCharacterOnly;

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var StateHandler = require("../state_handler").StateHandler;
var matchCharacterOnly = require("../state_handler").matchCharacterOnly;

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
// If you're developing a new keymapping and want to get an idea what's going
// on, then enable debugging.
@@ -73,7 +74,7 @@ StateHandler.prototype = {
});
},
$composeBuffer: function(data, hashId, key) {
$composeBuffer: function(data, hashId, key, e) {
// Initialize the data object.
if (data.state == null || data.buffer == null) {
data.state = "start";
@@ -102,17 +103,23 @@ StateHandler.prototype = {
data.buffer = bufferToUse;
}
return {
bufferToUse: bufferToUse,
symbolicName: symbolicName
var bufferObj = {
bufferToUse: bufferToUse,
symbolicName: symbolicName,
};
if (e) {
bufferObj.keyIdentifier = e.keyIdentifier
}
return bufferObj;
},
$find: function(data, buffer, symbolicName, hashId, key) {
$find: function(data, buffer, symbolicName, hashId, key, keyIdentifier) {
// Holds the command to execute and the args if a command matched.
var result = {};
// Loop over all the bindings of the keymapp until a match is found.
// Loop over all the bindings of the keymap until a match is found.
this.keymapping[data.state].some(function(binding) {
var match;
@@ -127,7 +134,7 @@ StateHandler.prototype = {
}
// Check if the match function matches.
if (binding.match && !binding.match(buffer, hashId, key, symbolicName)) {
if (binding.match && !binding.match(buffer, hashId, key, symbolicName, keyIdentifier)) {
return false;
}
@@ -194,20 +201,21 @@ StateHandler.prototype = {
/**
* This function is called by keyBinding.
*/
handleKeyboard: function(data, hashId, key) {
handleKeyboard: function(data, hashId, key, keyCode, e) {
// If we pressed any command key but no other key, then ignore the input.
// Otherwise "shift-" is added to the buffer, and later on "shift-g"
// which results in "shift-shift-g" which doesn't make senese.
// which results in "shift-shift-g" which doesn't make sense.
if (hashId != 0 && (key == "" || key == String.fromCharCode(0))) {
return null;
}
// Compute the current value of the keyboard input buffer.
var r = this.$composeBuffer(data, hashId, key);
var r = this.$composeBuffer(data, hashId, key, e);
var buffer = r.bufferToUse;
var symbolicName = r.symbolicName;
var keyId = r.keyIdentifier;
r = this.$find(data, buffer, symbolicName, hashId, key);
r = this.$find(data, buffer, symbolicName, hashId, key, keyId);
if (DEBUG) {
console.log("KeyboardStateMapper#match", buffer, symbolicName, r);
}

View File

@@ -38,6 +38,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var event = require("../lib/event");
var useragent = require("../lib/useragent");
@@ -48,9 +49,10 @@ var TextInput = function(parentNode, host) {
var text = dom.createElement("textarea");
if (useragent.isTouchPad)
text.setAttribute("x-palm-disable-auto-cap", true);
text.style.left = "-10000px";
parentNode.appendChild(text);
text.style.position = "fixed";
parentNode.insertBefore(text, parentNode.firstChild);
var PLACEHOLDER = String.fromCharCode(0);
sendText();
@@ -97,10 +99,10 @@ var TextInput = function(parentNode, host) {
var onTextInput = function(e) {
setTimeout(function () {
if (!inCompostion)
sendText(e.data);
sendText(e.data);
}, 0);
};
var onPropertyChange = function(e) {
if (useragent.isOldIE && text.value.charCodeAt(0) > 128) return;
setTimeout(function() {
@@ -137,7 +139,7 @@ var TextInput = function(parentNode, host) {
sendText();
}, 0);
};
var onCut = function(e) {
copied = true;
var copyText = host.getCopyText();
@@ -164,12 +166,12 @@ var TextInput = function(parentNode, host) {
inCompostion ? onCompositionUpdate() : onCompositionStart();
});
}
if ("onpropertychange" in text && !("oninput" in text))
event.addListener(text, "propertychange", onPropertyChange);
else
event.addListener(text, "input", onTextInput);
event.addListener(text, "paste", function(e) {
// Mark that the next input text comes from past.
pasted = true;
@@ -178,7 +180,7 @@ var TextInput = function(parentNode, host) {
if (e.clipboardData && e.clipboardData.getData) {
sendText(e.clipboardData.getData("text/plain"));
e.preventDefault();
}
}
else {
// If a browser doesn't support any of the things above, use the regular
// method to detect the pasted input.
@@ -189,7 +191,7 @@ var TextInput = function(parentNode, host) {
if ("onbeforecopy" in text && typeof clipboardData !== "undefined") {
event.addListener(text, "beforecopy", function(e) {
var copyText = host.getCopyText();
if(copyText)
if (copyText)
clipboardData.setData("Text", copyText);
else
e.preventDefault();
@@ -251,8 +253,8 @@ var TextInput = function(parentNode, host) {
if (mousePos) {
if (!tempStyle)
tempStyle = text.style.cssText;
text.style.cssText =
text.style.cssText =
'position:fixed; z-index:1000;' +
'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;';

View File

@@ -38,6 +38,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var dom = require("../lib/dom");
@@ -92,7 +93,7 @@ var Cursor = function(parentEl) {
}, 1000);
};
this.getPixelPosition = function(onScreen) {
this.getPixelPosition = function(position, onScreen) {
if (!this.config || !this.session) {
return {
left : 0,
@@ -100,7 +101,8 @@ var Cursor = function(parentEl) {
};
}
var position = this.session.selection.getCursor();
if (!position)
position = this.session.selection.getCursor();
var pos = this.session.documentToScreenPosition(position);
var cursorLeft = Math.round(this.$padding +
pos.column * this.config.characterWidth);
@@ -116,7 +118,7 @@ var Cursor = function(parentEl) {
this.update = function(config) {
this.config = config;
this.pixelPos = this.getPixelPosition(true);
this.pixelPos = this.getPixelPosition(null, true);
this.cursor.style.left = this.pixelPos.left + "px";
this.cursor.style.top = this.pixelPos.top + "px";

View File

@@ -38,13 +38,19 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var dom = require("../lib/dom");
var oop = require("../lib/oop");
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var Gutter = function(parentEl) {
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_gutter-layer";
parentEl.appendChild(this.element);
this.setShowFoldWidgets(this.$showFoldWidgets);
this.gutterWidth = 0;
this.$breakpoints = [];
this.$annotations = [];
@@ -53,6 +59,8 @@ var Gutter = function(parentEl) {
(function() {
oop.implement(this, EventEmitter);
this.setSession = function(session) {
this.session = session;
};
@@ -61,7 +69,7 @@ var Gutter = function(parentEl) {
if (!this.$decorations[row])
this.$decorations[row] = "";
this.$decorations[row] += " ace_" + className;
}
};
this.removeGutterDecoration = function(row, className){
this.$decorations[row] = this.$decorations[row].replace(" ace_" + className, "");
@@ -84,7 +92,9 @@ var Gutter = function(parentEl) {
};
for (var i=0; i<rowAnnotations.length; i++) {
var annotation = rowAnnotations[i];
rowInfo.text.push(annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&#8217;").replace(/</, "&lt;"));
var annoText = annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&#8217;").replace(/</, "&lt;");
if (rowInfo.text.indexOf(annoText) === -1)
rowInfo.text.push(annoText);
var type = annotation.type;
if (type == "error")
rowInfo.className = "ace_error";
@@ -105,6 +115,7 @@ var Gutter = function(parentEl) {
var lastRow = config.lastRow;
var fold = this.session.getNextFoldLine(i);
var foldStart = fold ? fold.start.row : Infinity;
var foldWidgets = this.$showFoldWidgets && this.session.foldWidgets;
while (true) {
if(i > foldStart) {
@@ -123,6 +134,19 @@ var Gutter = function(parentEl) {
"' title='", annotation.text.join("\n"),
"' style='height:", config.lineHeight, "px;'>", (i+1));
if (foldWidgets) {
var c = foldWidgets[i];
// check if cached value is invalidated and we need to recompute
if (c == null)
c = foldWidgets[i] = this.session.getFoldWidget(i);
if (c)
html.push(
"<span class='ace_fold-widget ", c,
c == "start" && i == foldStart && i < fold.end.row ? " closed" : " open",
"'></span>"
);
}
var wrappedRowLength = this.session.getRowLength(i) - 1;
while (wrappedRowLength--) {
html.push("</div><div class='ace_gutter-cell' style='height:", config.lineHeight, "px'>\xA6");
@@ -134,6 +158,26 @@ var Gutter = function(parentEl) {
}
this.element = dom.setInnerHtml(this.element, html.join(""));
this.element.style.height = config.minHeight + "px";
var gutterWidth = this.element.offsetWidth;
if (gutterWidth !== this.gutterWidth) {
this.gutterWidth = gutterWidth;
this._emit("changeGutterWidth", gutterWidth);
}
};
this.$showFoldWidgets = true;
this.setShowFoldWidgets = function(show) {
if (show)
dom.addCssClass(this.element, "ace_folding-enabled");
else
dom.removeCssClass(this.element, "ace_folding-enabled");
this.$showFoldWidgets = show;
};
this.getShowFoldWidgets = function() {
return this.$showFoldWidgets;
};
}).call(Gutter.prototype);

View File

@@ -38,6 +38,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var Range = require("../range").Range;
var dom = require("../lib/dom");
@@ -140,10 +141,11 @@ var Marker = function(parentEl) {
* Draws a multi line marker, where lines span the full width
*/
this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig, type) {
// from selection start to the end of the line
var padding = type === "background" ? 0 : this.$padding;
var layerWidth = layerConfig.width + 2 * this.$padding - padding;
// from selection start to the end of the line
var height = layerConfig.lineHeight;
var width = Math.round(layerConfig.width - (range.start.column * layerConfig.characterWidth));
var width = Math.round(layerWidth - (range.start.column * layerConfig.characterWidth));
var top = this.$getTop(range.start.row, layerConfig);
var left = Math.round(
padding + range.start.column * layerConfig.characterWidth
@@ -174,12 +176,11 @@ var Marker = function(parentEl) {
if (height < 0)
return;
top = this.$getTop(range.start.row + 1, layerConfig);
width = layerConfig.width;
stringBuilder.push(
"<div class='", clazz, "' style='",
"height:", height, "px;",
"width:", width, "px;",
"width:", layerWidth, "px;",
"top:", top, "px;",
"left:", padding, "px;'></div>"
);

View File

@@ -40,6 +40,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var dom = require("../lib/dom");
@@ -50,7 +51,6 @@ var EventEmitter = require("../lib/event_emitter").EventEmitter;
var Text = function(parentEl) {
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_text-layer";
this.element.style.width = "auto";
parentEl.appendChild(this.element);
this.$characterSize = this.$measureSizes() || {width: 0, height: 0};
@@ -84,7 +84,7 @@ var Text = function(parentEl) {
var size = this.$measureSizes();
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
this.$characterSize = size;
this._dispatchEvent("changeCharaterSize", {data: size});
this._emit("changeCharacterSize", {data: size});
}
};
@@ -389,7 +389,10 @@ var Text = function(parentEl) {
if (!this.$textToken[token.type]) {
var classes = "ace_" + token.type.replace(/\./g, " ace_");
stringBuilder.push("<span class='", classes, "'>", output, "</span>");
var style = "";
if (token.type == "fold")
style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
}
else {
stringBuilder.push(output);
@@ -401,7 +404,6 @@ var Text = function(parentEl) {
var chars = 0;
var split = 0;
var splitChars;
var characterWidth = this.config.characterWidth;
var screenColumn = 0;
var self = this;

View File

@@ -41,7 +41,8 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var assert = require("../test/assertions");
var EditSession = require("../edit_session").EditSession;
var TextLayer = require("./text").Text;

View File

@@ -39,6 +39,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("./oop");
var event = require("./event");

157
vendor/ace/lib/dom.js vendored
View File

@@ -39,6 +39,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var XHTML_NS = "http://www.w3.org/1999/xhtml";
@@ -57,69 +58,51 @@ exports.setText = function(elem, text) {
}
};
if (!document.documentElement.classList) {
exports.hasCssClass = function(el, name) {
var classes = el.className.split(/\s+/g);
return classes.indexOf(name) !== -1;
};
exports.hasCssClass = function(el, name) {
var classes = el.className.split(/\s+/g);
return classes.indexOf(name) !== -1;
};
/**
* Add a CSS class to the list of classes on the given node
*/
exports.addCssClass = function(el, name) {
if (!exports.hasCssClass(el, name)) {
el.className += " " + name;
/**
* Add a CSS class to the list of classes on the given node
*/
exports.addCssClass = function(el, name) {
if (!exports.hasCssClass(el, name)) {
el.className += " " + name;
}
};
/**
* Remove a CSS class from the list of classes on the given node
*/
exports.removeCssClass = function(el, name) {
var classes = el.className.split(/\s+/g);
while (true) {
var index = classes.indexOf(name);
if (index == -1) {
break;
}
};
classes.splice(index, 1);
}
el.className = classes.join(" ");
};
/**
* Remove a CSS class from the list of classes on the given node
*/
exports.removeCssClass = function(el, name) {
var classes = el.className.split(/\s+/g);
while (true) {
var index = classes.indexOf(name);
if (index == -1) {
break;
}
classes.splice(index, 1);
exports.toggleCssClass = function(el, name) {
var classes = el.className.split(/\s+/g), add = true;
while (true) {
var index = classes.indexOf(name);
if (index == -1) {
break;
}
el.className = classes.join(" ");
};
add = false;
classes.splice(index, 1);
}
if(add)
classes.push(name);
exports.toggleCssClass = function(el, name) {
var classes = el.className.split(/\s+/g), add = true;
while (true) {
var index = classes.indexOf(name);
if (index == -1) {
break;
}
add = false;
classes.splice(index, 1);
}
if(add)
classes.push(name);
el.className = classes.join(" ");
return add;
};
} else {
exports.hasCssClass = function(el, name) {
return el.classList.contains(name);
};
exports.addCssClass = function(el, name) {
el.classList.add(name);
};
exports.removeCssClass = function(el, name) {
el.classList.remove(name);
};
exports.toggleCssClass = function(el, name) {
return el.classList.toggle(name);
};
}
el.className = classes.join(" ");
return add;
};
/**
* Add or remove a CSS class from the list of classes on the given node
@@ -162,9 +145,9 @@ exports.importCssString = function importCssString(cssText, id, doc) {
if (id)
style.title = id;
} else {
style = doc.createElementNS ?
doc.createElementNS(XHTML_NS, "style") :
doc.createElement("style");
style = doc.createElementNS
? doc.createElementNS(XHTML_NS, "style")
: doc.createElement("style");
style.appendChild(doc.createTextNode(cssText));
if (id)
@@ -177,7 +160,7 @@ exports.importCssString = function importCssString(cssText, id, doc) {
exports.importCssStylsheet = function(uri, doc) {
if (doc.createStyleSheet) {
var sheet = doc.createStyleSheet(uri);
doc.createStyleSheet(uri);
} else {
var link = exports.createElement('link');
link.rel = 'stylesheet';
@@ -189,13 +172,19 @@ exports.importCssStylsheet = function(uri, doc) {
};
exports.getInnerWidth = function(element) {
return (parseInt(exports.computedStyle(element, "paddingLeft"))
+ parseInt(exports.computedStyle(element, "paddingRight")) + element.clientWidth);
return (
parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
parseInt(exports.computedStyle(element, "paddingRight"), 10) +
element.clientWidth
);
};
exports.getInnerHeight = function(element) {
return (parseInt(exports.computedStyle(element, "paddingTop"))
+ parseInt(exports.computedStyle(element, "paddingBottom")) + element.clientHeight);
return (
parseInt(exports.computedStyle(element, "paddingTop"), 10) +
parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
element.clientHeight
);
};
if (window.pageYOffset !== undefined) {
@@ -221,13 +210,13 @@ if (window.getComputedStyle)
exports.computedStyle = function(element, style) {
if (style)
return (window.getComputedStyle(element, "") || {})[style] || "";
return window.getComputedStyle(element, "") || {}
return window.getComputedStyle(element, "") || {};
};
else
exports.computedStyle = function(element, style) {
if (style)
return element.currentStyle[style];
return element.currentStyle
return element.currentStyle;
};
exports.scrollbarWidth = function(document) {
@@ -300,36 +289,4 @@ exports.getParentWindow = function(document) {
return document.defaultView || document.parentWindow;
};
exports.getSelectionStart = function(textarea) {
// TODO IE
var start;
try {
start = textarea.selectionStart || 0;
} catch (e) {
start = 0;
}
return start;
};
exports.setSelectionStart = function(textarea, start) {
// TODO IE
return textarea.selectionStart = start;
};
exports.getSelectionEnd = function(textarea) {
// TODO IE
var end;
try {
end = textarea.selectionEnd || 0;
} catch (e) {
end = 0;
}
return end;
};
exports.setSelectionEnd = function(textarea, end) {
// TODO IE
return textarea.selectionEnd = end;
};
});

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var keys = require("./keys");
var useragent = require("./useragent");
@@ -285,7 +286,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
exports.addCommandKeyListener = function(el, callback) {
var addListener = exports.addListener;
if (useragent.isOldGecko) {
if (useragent.isOldGecko || useragent.isOpera) {
// Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown
// event if the user pressed the key for a longer time. Instead, the
// keydown event was fired once and later on only the keypress event.
@@ -306,18 +307,6 @@ exports.addCommandKeyListener = function(el, callback) {
lastDown = e.keyIdentifier || e.keyCode;
return normalizeCommandKeys(callback, e, e.keyCode);
});
// repeated keys are fired as keypress and not keydown events
if (useragent.isMac && useragent.isOpera) {
addListener(el, "keypress", function(e) {
var keyId = e.keyIdentifier || e.keyCode;
if (lastDown !== keyId) {
return normalizeCommandKeys(callback, e, lastDown);
} else {
lastDown = null;
}
});
}
}
};

View File

@@ -39,6 +39,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var EventEmitter = {};

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var EventEmitter = require("./event_emitter").EventEmitter;
@@ -59,7 +60,7 @@ module.exports = {
assert.equal(e.type, "juhu");
});
emitter._dispatchEvent("juhu");
emitter._emit("juhu");
assert.ok(called);
}
};

View File

@@ -11,6 +11,7 @@
*/
define(function(require, exports, module) {
"use strict";
require("./regexp");
require("./es5-shim");

View File

@@ -32,6 +32,7 @@ For more information about SproutCore, visit http://www.sproutcore.com
// Most of the following code is taken from SproutCore with a few changes.
define(function(require, exports, module) {
"use strict";
var oop = require("./oop");

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
exports.stringReverse = function(string) {
return string.split("").reverse().join("");
@@ -49,7 +50,7 @@ var trimBeginRegexp = /^\s\s*/;
var trimEndRegexp = /\s\s*$/;
exports.stringTrimLeft = function (string) {
return string.replace(trimBeginRegexp, '')
return string.replace(trimBeginRegexp, '');
};
exports.stringTrimRight = function (string) {
@@ -66,11 +67,11 @@ exports.copyObject = function(obj) {
exports.copyArray = function(array){
var copy = [];
for (i=0, l=array.length; i<l; i++) {
for (var i=0, l=array.length; i<l; i++) {
if (array[i] && typeof array[i] == "object")
copy[i] = this.copyObject( array[i] );
else
copy[i] = array[i]
copy[i] = array[i];
}
return copy;
};
@@ -89,7 +90,7 @@ exports.deepCopy = function (obj) {
}
}
return copy;
}
};
exports.arrayToMap = function(arr) {
var map = {};
@@ -127,7 +128,7 @@ exports.deferredCall = function(fcn) {
deferred.cancel();
timer = setTimeout(callback, timeout || 0);
return deferred;
}
};
deferred.schedule = deferred;

View File

@@ -1,4 +1,3 @@
/**
* based on code from:
*
@@ -7,7 +6,8 @@
* see: http://github.com/jrburke/requirejs for details
*/
define(function(require, exports, module) {
"use strict";
exports.get = function (url, callback) {
var xhr = exports.createXhr();
xhr.open('GET', url, true);
@@ -23,7 +23,7 @@ exports.get = function (url, callback) {
var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
exports.createXhr = function () {
exports.createXhr = function() {
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
var xhr, i, progId;
if (typeof XMLHttpRequest !== "undefined") {

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
exports.inherits = (function() {
var tempCtor = function() {};
@@ -44,7 +45,7 @@ exports.inherits = (function() {
ctor.super_ = superCtor.prototype;
ctor.prototype = new tempCtor();
ctor.prototype.constructor = ctor;
}
};
}());
exports.mixin = function(obj, mixin) {

View File

@@ -1,13 +1,16 @@
/**
* Based on code from:
*
* XRegExp 1.5.0
* (c) 2007-2010 Steven Levithan
* MIT License
* <http://xregexp.com>
* Provides an augmented, extensible, cross-browser implementation of regular expressions,
* including support for additional syntax, flags, and methods
*/
define(function(require, exports, module) {
// Based on code from:
//
// XRegExp 1.5.0
// (c) 2007-2010 Steven Levithan
// MIT License
// <http://xregexp.com>
// Provides an augmented, extensible, cross-browser implementation of regular expressions,
// including support for additional syntax, flags, and methods
"use strict";
//---------------------------------
// Private variables

View File

@@ -36,10 +36,10 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
var ua = navigator.userAgent;
var av = navigator.appVersion;
/** Is the user using a browser that identifies itself as Windows */
exports.isWin = (os == "win");
@@ -60,7 +60,7 @@ exports.isOldIE = exports.isIE && exports.isIE < 9;
exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko";
/** oldGecko == rev < 2.0 **/
exports.isOldGecko = exports.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1]) < 4;
exports.isOldGecko = exports.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1], 10) < 4;
/** Is this Opera */
exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
@@ -84,9 +84,9 @@ exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
* Windows folks expect to use CTRL + C
*/
exports.OS = {
LINUX: 'LINUX',
MAC: 'MAC',
WINDOWS: 'WINDOWS'
LINUX: "LINUX",
MAC: "MAC",
WINDOWS: "WINDOWS"
};
/**
@@ -94,11 +94,11 @@ exports.OS = {
*/
exports.getOS = function() {
if (exports.isMac) {
return exports.OS['MAC'];
return exports.OS.MAC;
} else if (exports.isLinux) {
return exports.OS['LINUX'];
return exports.OS.LINUX;
} else {
return exports.OS['WINDOWS'];
return exports.OS.WINDOWS;
}
};

View File

@@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var Behaviour = function() {
this.$behaviours = {};

View File

@@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var Behaviour = require('../behaviour').Behaviour;

View File

@@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var Behaviour = require("../behaviour").Behaviour;

View File

@@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
@@ -45,11 +46,13 @@ var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Range = require("../range").Range;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
this.foldingRules = new CStyleFoldMode();
};
oop.inherits(Mode, TextMode);
@@ -57,7 +60,6 @@ oop.inherits(Mode, TextMode);
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var outdent = true;
var outentedRows = [];
var re = /^(\s*)\/\//;
for (var i=startRow; i<= endRow; i++) {

View File

@@ -39,6 +39,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var lang = require("../lib/lang");

View File

@@ -38,6 +38,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
@@ -56,7 +57,6 @@ oop.inherits(Mode, TextMode);
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var outdent = true;
var outentedRows = [];
var re = /^(\s*)#/;
for (var i=startRow; i<= endRow; i++) {
@@ -85,11 +85,9 @@ oop.inherits(Mode, TextMode);
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var startingIndent = indent;
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;

View File

@@ -38,6 +38,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var lang = require("../lib/lang");

View File

@@ -36,10 +36,12 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var Tokenizer = require("../tokenizer").Tokenizer;
var Rules = require("./coffee_highlight_rules").CoffeeHighlightRules;
var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var PythonFoldMode = require("./folding/pythonic").FoldMode;
var Range = require("../range").Range;
var TextMode = require("./text").Mode;
var WorkerClient = require("../worker/worker_client").WorkerClient;
@@ -48,6 +50,7 @@ var oop = require("../lib/oop");
function Mode() {
this.$tokenizer = new Tokenizer(new Rules().getRules());
this.$outdent = new Outdent();
this.foldingRules = new PythonFoldMode("=|=>|->|\\s*class [^#]*");
}
oop.inherits(Mode, TextMode);

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var assert = require("../../test/assertions");
var coffee = require("../coffee/coffee-script");

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var lang = require("../lib/lang");
var oop = require("../lib/oop");

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var Mode = require("./coffee").Mode;
var assert = require("../test/assertions");
@@ -55,7 +56,8 @@ module.exports = {
assert.equal(tokens[0].type, "keyword");
},
"test tokenize string with interpolation": function() {
// TODO: disable. not yet implemented
"!test tokenize string with interpolation": function() {
var tokens = this.tokenizer.getLineTokens('"#{ 22 / 7 } is a decent approximation of π"', "start").tokens;
console.log(tokens);
assert.equal(tokens.length, 12);
@@ -66,5 +68,5 @@ module.exports = {
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec()
require("asyncjs").test.testcase(module.exports).exec();
}

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var Mirror = require("../worker/mirror").Mirror;

View File

@@ -36,19 +36,20 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var XmlMode = require("./xml").Mode;
var JavaScriptMode = require("./javascript").Mode;
var CssMode = require("./css").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var ColdfusionHighlightRules = require("./coldfusion_highlight_rules").ColdfusionHighlightRules;
var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
var Mode = function() {
XmlMode.call(this);
var highlighter = new ColdfusionHighlightRules();
this.$tokenizer = new Tokenizer(highlighter.getRules());
this.$behaviour = new XmlBehaviour();
this.$embeds = highlighter.getEmbeds();
this.createModeDelegates({
@@ -56,22 +57,14 @@ var Mode = function() {
"css-": CssMode
});
};
oop.inherits(Mode, TextMode);
oop.inherits(Mode, XmlMode);
(function() {
this.toggleCommentLines = function(state, doc, startRow, endRow) {
return 0;
};
this.getNextLineIndent = function(state, line, tab) {
return this.$getIndent(line);
};
this.checkOutdent = function(state, line, input) {
return false;
};
}).call(Mode.prototype);
exports.Mode = Mode;

View File

@@ -36,81 +36,18 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var xml_util = require("./xml_util");
var ColdfusionHighlightRules = function() {
// regexp must not have capturing parentheses
// regexps are ordered -> the first match is used
function string(state) {
return [{
token : "string",
regex : '".*?"'
}, {
token : "string", // multi line string start
merge : true,
regex : '["].*$',
next : state + "-qqstring"
}, {
token : "string",
regex : "'.*?'"
}, {
token : "string", // multi line string start
merge : true,
regex : "['].*$",
next : state + "-qstring"
}]
}
function multiLineString(quote, state) {
return [{
token : "string",
merge : true,
regex : ".*" + quote,
next : state
}, {
token : "string",
merge : true,
regex : '.+'
}]
}
function tag(states, name, nextState) {
states[name] = [{
token : "text",
regex : "\\s+"
}, {
token : "meta.tag",
regex : "[-_a-zA-Z0-9:]+",
next : name + "-attribute-list"
}, {
token: "empty",
regex: "",
next : name + "-attribute-list"
}];
states[name + "-qstring"] = multiLineString("'", name);
states[name + "-qqstring"] = multiLineString("\"", name);
states[name + "-attribute-list"] = [{
token : "text",
regex : ">",
next : nextState
}, {
token : "entity.other.attribute-name",
regex : "[-_a-zA-Z0-9:]+"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "text",
regex : "\\s+"
}].concat(string(name));
};
this.$rules = {
start : [ {
@@ -127,15 +64,15 @@ var ColdfusionHighlightRules = function() {
regex : "<\\!--",
next : "comment"
}, {
token : "text",
token : "meta.tag",
regex : "<(?=\s*script)",
next : "script"
}, {
token : "text",
token : "meta.tag",
regex : "<(?=\s*style)",
next : "css"
next : "style"
}, {
token : "text", // opening tag
token : "meta.tag", // opening tag
regex : "<\\/?",
next : "tag"
}, {
@@ -171,22 +108,22 @@ var ColdfusionHighlightRules = function() {
} ]
};
tag(this.$rules, "tag", "start");
tag(this.$rules, "css", "css-start");
tag(this.$rules, "script", "js-start");
xml_util.tag(this.$rules, "tag", "start");
xml_util.tag(this.$rules, "style", "css-start");
xml_util.tag(this.$rules, "script", "js-start");
this.embedRules(JavaScriptHighlightRules, "js-", [{
token: "comment",
regex: "\\/\\/.*(?=<\\/script>)",
next: "tag"
}, {
token: "text",
token: "meta.tag",
regex: "<\\/(?=script)",
next: "tag"
}]);
this.embedRules(CssHighlightRules, "css-", [{
token: "text",
token: "meta.tag",
regex: "<\\/(?=style)",
next: "tag"
}]);

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var EditSession = require("../edit_session").EditSession;
var Range = require("../range").Range;

View File

@@ -1,4 +1,5 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
@@ -6,44 +7,45 @@ var Tokenizer = require("../tokenizer").Tokenizer;
var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.$tokenizer = new Tokenizer(new CSharpHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
this.foldingRules = new CStyleFoldMode();
};
oop.inherits(Mode, TextMode);
(function() {
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
if (state == "start") {
var match = line.match(/^.*[\{\(\[]\s*$/);
if (match) {
indent += tab;
}
}
return indent;
};
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
if (state == "start") {
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.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
this.createWorker = function(session) {

View File

@@ -1,4 +1,5 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var lang = require("../lib/lang");

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
@@ -43,15 +44,19 @@ var Tokenizer = require("../tokenizer").Tokenizer;
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var WorkerClient = require("../worker/worker_client").WorkerClient;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules());
this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i");
this.$outdent = new MatchingBraceOutdent();
this.foldingRules = new CStyleFoldMode();
};
oop.inherits(Mode, TextMode);
(function() {
this.foldingRules = "cStyle";
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var lang = require("../lib/lang");
@@ -44,8 +45,9 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var CssHighlightRules = function() {
var properties = lang.arrayToMap(
("-moz-box-sizing|-webkit-box-sizing|appearance|azimuth|background-attachment|background-color|background-image|" +
"background-position|background-repeat|background|border-bottom-color|" +
("-moz-appearance|-moz-box-sizing|-webkit-box-sizing|-moz-outline-radius|-moz-transform|-webkit-transform|" +
"appearance|azimuth|background-attachment|background-color|background-image|" +
"background-origin|background-position|background-repeat|background|border-bottom-color|" +
"border-bottom-style|border-bottom-width|border-bottom|border-collapse|" +
"border-color|border-left-color|border-left-style|border-left-width|" +
"border-left|border-right-color|border-right-style|border-right-width|" +
@@ -58,14 +60,14 @@ var CssHighlightRules = function() {
"letter-spacing|line-height|list-style-image|list-style-position|" +
"list-style-type|list-style|margin-bottom|margin-left|margin-right|" +
"margin-top|marker-offset|margin|marks|max-height|max-width|min-height|" +
"min-width|-moz-border-radius|opacity|orphans|outline-color|" +
"min-width|-moz-border-radius|opacity|orphans|outline-color|outline-offset|outline-radius|" +
"outline-style|outline-width|outline|overflow|overflow-x|overflow-y|padding-bottom|" +
"padding-left|padding-right|padding-top|padding|page-break-after|" +
"page-break-before|page-break-inside|page|pause-after|pause-before|" +
"pause|pitch-range|pitch|play-during|position|quotes|richness|right|" +
"pause|pitch-range|pitch|play-during|pointer-events|position|quotes|resize|richness|right|" +
"size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|" +
"stress|table-layout|text-align|text-decoration|text-indent|" +
"text-shadow|text-transform|top|unicode-bidi|vertical-align|" +
"text-shadow|text-transform|top|transform|unicode-bidi|vertical-align|" +
"visibility|voice-family|volume|white-space|widows|width|word-spacing|" +
"z-index").split("|")
);
@@ -108,20 +110,6 @@ var CssHighlightRules = function() {
var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
function ic(str) {
var re = [];
var chars = str.split("");
for (var i=0; i<chars.length; i++) {
re.push(
"[",
chars[i].toLowerCase(),
chars[i].toUpperCase(),
"]"
);
}
return re.join("");
}
var base_ruleset = [
{
token : "comment", // multi line comment
@@ -136,61 +124,13 @@ var CssHighlightRules = function() {
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric",
regex : numRe + ic("em")
}, {
token : "constant.numeric",
regex : numRe + ic("ex")
}, {
token : "constant.numeric",
regex : numRe + ic("px")
}, {
token : "constant.numeric",
regex : numRe + ic("cm")
}, {
token : "constant.numeric",
regex : numRe + ic("mm")
}, {
token : "constant.numeric",
regex : numRe + ic("in")
}, {
token : "constant.numeric",
regex : numRe + ic("pt")
}, {
token : "constant.numeric",
regex : numRe + ic("pc")
}, {
token : "constant.numeric",
regex : numRe + ic("deg")
}, {
token : "constant.numeric",
regex : numRe + ic("rad")
}, {
token : "constant.numeric",
regex : numRe + ic("grad")
}, {
token : "constant.numeric",
regex : numRe + ic("ms")
}, {
token : "constant.numeric",
regex : numRe + ic("s")
}, {
token : "constant.numeric",
regex : numRe + ic("hz")
}, {
token : "constant.numeric",
regex : numRe + ic("khz")
}, {
token : "constant.numeric",
regex : numRe + "%"
}, {
token : "constant.numeric",
regex : numRe
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)"
}, {
token : "constant.numeric", // hex6 color
regex : "#[a-fA-F0-9]{6}"
regex : "#[a-f0-9]{6}"
}, {
token : "constant.numeric", // hex3 color
regex : "#[a-fA-F0-9]{3}"
regex : "#[a-f0-9]{3}"
}, {
token : function(value) {
if (properties.hasOwnProperty(value.toLowerCase())) {
@@ -266,20 +206,20 @@ var CssHighlightRules = function() {
next: "ruleset"
}, {
token: "string",
regex: "@media.*?{",
regex: "@.*?{",
next: "media"
},{
token: "keyword",
regex: "#[a-zA-Z0-9-_]+"
regex: "#[a-z0-9-_]+"
},{
token: "variable",
regex: "\\.[a-zA-Z0-9-_]+"
regex: "\\.[a-z0-9-_]+"
},{
token: "string",
regex: ":[a-zA-Z0-9-_]+"
regex: ":[a-z0-9-_]+"
},{
token: "constant",
regex: "[a-zA-Z0-9-_]+"
regex: "[a-z0-9-_]+"
}],
"media" : [ {
@@ -297,16 +237,16 @@ var CssHighlightRules = function() {
next: "start"
},{
token: "keyword",
regex: "#[a-zA-Z0-9-_]+"
regex: "#[a-z0-9-_]+"
},{
token: "variable",
regex: "\\.[a-zA-Z0-9-_]+"
regex: "\\.[a-z0-9-_]+"
},{
token: "string",
regex: ":[a-zA-Z0-9-_]+"
regex: ":[a-z0-9-_]+"
},{
token: "constant",
regex: "[a-zA-Z0-9-_]+"
regex: "[a-z0-9-_]+"
}],
"comment" : comment,

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var EditSession = require("../edit_session").EditSession;
var CssMode = require("./css").Mode;

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var CssMode = require("./css").Mode;
var assert = require("../test/assertions");

View File

@@ -36,7 +36,8 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var Mirror = require("../worker/mirror").Mirror;
var CSSLint = require("./css/csslint").CSSLint;
@@ -53,7 +54,7 @@ oop.inherits(Worker, Mirror);
this.onUpdate = function() {
var value = this.doc.getValue();
result = CSSLint.verify(value);
var result = CSSLint.verify(value);
this.sender.emit("csslint", result.messages.map(function(msg) {
delete msg.rule;
return msg;

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var assert = require("../test/assertions");
var Worker = require("./css_worker").Worker;

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;

95
vendor/ace/mode/folding/cstyle.js vendored Normal file
View File

@@ -0,0 +1,95 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var Range = require("../../range").Range;
var BaseFoldMode = require("./fold_mode").FoldMode;
var FoldMode = exports.FoldMode = function() {};
oop.inherits(FoldMode, BaseFoldMode);
(function() {
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
this.getFoldWidgetRange = function(session, foldStyle, row) {
var line = session.getLine(row);
var match = line.match(this.foldingStartMarker);
if (match) {
var i = match.index;
if (match[1])
return this.openingBracketBlock(session, match[1], row, i);
var range = session.getCommentFoldRange(row, i + match[0].length);
range.end.column -= 2;
return range;
}
if (foldStyle !== "markbeginend")
return;
var match = line.match(this.foldingStopMarker);
if (match) {
var i = match.index + match[0].length;
if (match[2]) {
var range = session.getCommentFoldRange(row, i);
range.end.column -= 2;
return range;
}
var end = {row: row, column: i};
var start = session.$findOpeningBracket(match[1], end);
if (!start)
return;
start.column++;
end.column--;
return Range.fromPoints(start, end);
}
};
}).call(FoldMode.prototype);
});

92
vendor/ace/mode/folding/cstyle_test.js vendored Normal file
View File

@@ -0,0 +1,92 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
if (typeof process !== "undefined")
require("amd-loader");
define(function(require, exports, module) {
"use strict";
var JavaScriptMode = require("../javascript").Mode;
var EditSession = require("../../edit_session").EditSession;
var assert = require("../../test/assertions");
module.exports = {
"test: fold comments": function() {
var session = new EditSession([
'/*',
'stuff',
'*/'
]);
var mode = new JavaScriptMode();
session.setFoldStyle("markbeginend");
session.setMode(mode);
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(2), "end");
assert.range(session.getFoldWidgetRange(0), 0, 2, 2, 0);
assert.range(session.getFoldWidgetRange(2), 0, 2, 2, 0);
},
"test: fold doc style comments": function() {
var session = new EditSession([
'/**',
' * stuff',
' * *** */'
]);
var mode = new JavaScriptMode();
session.setFoldStyle("markbeginend");
session.setMode(mode);
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(2), "end");
assert.range(session.getFoldWidgetRange(0), 0, 2, 2, 7);
assert.range(session.getFoldWidgetRange(2), 0, 2, 2, 7);
}
};
});
if (typeof module !== "undefined" && module === require.main)
require("asyncjs").test.testcase(module.exports).exec();

113
vendor/ace/mode/folding/fold_mode.js vendored Normal file
View File

@@ -0,0 +1,113 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var Range = require("../../range").Range;
var FoldMode = exports.FoldMode = function() {};
(function() {
this.foldingStartMarker = null;
this.foldingStopMarker = null;
// must return "" if there's no fold, to enable caching
this.getFoldWidget = function(session, foldStyle, row) {
var line = session.getLine(row);
if (this.foldingStartMarker.test(line))
return "start";
if (foldStyle == "markbeginend"
&& this.foldingStopMarker
&& this.foldingStopMarker.test(line))
return "end";
return "";
};
this.getFoldWidgetRange = function(session, foldStyle, row) {
return null;
};
this.indentationBlock = function(session, row, column) {
var re = /^\s*/;
var startRow = row;
var endRow = row;
var line = session.getLine(row);
var startColumn = column || line.length;
var startLevel = line.match(re)[0].length;
var maxRow = session.getLength()
while (++row < maxRow) {
line = session.getLine(row);
var level = line.match(re)[0].length;
if (level == line.length)
continue;
if (level <= startLevel)
break;
endRow = row;
}
if (endRow > startRow) {
var endColumn = session.getLine(endRow).length;
return new Range(startRow, startColumn, endRow, endColumn);
}
};
this.openingBracketBlock = function(session, bracket, row, column) {
var start = {row: row, column: column + 1};
var end = session.$findClosingBracket(bracket, start);
if (!end)
return;
var fw = session.foldWidgets[end.row];
if (fw == null)
fw = this.getFoldWidget(session, end.row);
if (fw == "start") {
end.row --;
end.column = session.getLine(end.row).length;
}
return Range.fromPoints(start, end);
};
}).call(FoldMode.prototype);
});

86
vendor/ace/mode/folding/html.js vendored Normal file
View File

@@ -0,0 +1,86 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var MixedFoldMode = require("./mixed").FoldMode;
var XmlFoldMode = require("./xml").FoldMode;
var CStyleFoldMode = require("./cstyle").FoldMode;
var FoldMode = exports.FoldMode = function() {
MixedFoldMode.call(this, new XmlFoldMode({
// void elements
"area": 1,
"base": 1,
"br": 1,
"col": 1,
"command": 1,
"embed": 1,
"hr": 1,
"img": 1,
"input": 1,
"keygen": 1,
"link": 1,
"meta": 1,
"param": 1,
"source": 1,
"track": 1,
"wbr": 1,
// optional tags
"li": 1,
"dt": 1,
"dd": 1,
"p": 1,
"rt": 1,
"rp": 1,
"optgroup": 1,
"option": 1,
"colgroup": 1,
"td": 1,
"th": 1
}), {
"js-": new CStyleFoldMode(),
"css-": new CStyleFoldMode()
});
};
oop.inherits(FoldMode, MixedFoldMode);
});

169
vendor/ace/mode/folding/html_test.js vendored Normal file
View File

@@ -0,0 +1,169 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
if (typeof process !== "undefined")
require("amd-loader");
define(function(require, exports, module) {
"use strict";
var HtmlMode = require("../html").Mode;
var EditSession = require("../../edit_session").EditSession;
var assert = require("../../test/assertions");
module.exports = {
"test: fold mixed html and javascript": function() {
var session = new EditSession([
'<script type="text/javascript"> ',
'function() foo {',
' var bar = 1;',
'}',
'</script>'
]);
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), "");
assert.equal(session.getFoldWidget(3), "end");
assert.equal(session.getFoldWidget(4), "end");
assert.range(session.getFoldWidgetRange(0), 0, 8, 4, 0);
assert.range(session.getFoldWidgetRange(4), 0, 8, 4, 0);
assert.range(session.getFoldWidgetRange(1), 1, 16, 3, 0);
assert.range(session.getFoldWidgetRange(3), 1, 16, 3, 0);
},
"test: fold mixed html and css": function() {
var session = new EditSession([
'<style type="text/css">',
' .text-layer {',
' font-family: Monaco, "Courier New", monospace;',
' }',
'</style>'
]);
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), "");
assert.equal(session.getFoldWidget(3), "end");
assert.equal(session.getFoldWidget(4), "end");
assert.range(session.getFoldWidgetRange(0), 0, 7, 4, 0);
assert.range(session.getFoldWidgetRange(4), 0, 7, 4, 0);
assert.range(session.getFoldWidgetRange(1), 1, 17, 3, 4);
assert.range(session.getFoldWidgetRange(3), 1, 17, 3, 4);
},
"test: fold should skip self closing elements": function() {
var session = new EditSession([
'<body>',
'<br />',
'</body>'
]);
var mode = new HtmlMode();
session.setMode(mode);
session.setFoldStyle("markbeginend");
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(2), "end");
assert.range(session.getFoldWidgetRange(0), 0, 6, 2, 0);
assert.range(session.getFoldWidgetRange(2), 0, 6, 2, 0);
},
"test: fold should skip void elements": function() {
var session = new EditSession([
'<body>',
'<br>',
'</body>'
]);
var mode = new HtmlMode();
session.setMode(mode);
session.setFoldStyle("markbeginend");
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(2), "end");
assert.range(session.getFoldWidgetRange(0), 0, 6, 2, 0);
assert.range(session.getFoldWidgetRange(2), 0, 6, 2, 0);
},
"test: fold multiple unclosed elements": function() {
var session = new EditSession([
'<div>',
'<p>',
'juhu',
'<p>',
'kinners',
'</div>'
]);
var mode = new HtmlMode();
session.setMode(mode);
session.setFoldStyle("markbeginend");
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(2), "");
assert.equal(session.getFoldWidget(3), "");
assert.equal(session.getFoldWidget(4), "");
assert.equal(session.getFoldWidget(5), "end");
assert.range(session.getFoldWidgetRange(0), 0, 5, 5, 0);
assert.range(session.getFoldWidgetRange(5), 0, 5, 5, 0);
}
};
});
if (typeof module !== "undefined" && module === require.main)
require("asyncjs").test.testcase(module.exports).exec();

88
vendor/ace/mode/folding/mixed.js vendored Normal file
View File

@@ -0,0 +1,88 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var BaseFoldMode = require("./fold_mode").FoldMode;
var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
this.defaultMode = defaultMode;
this.subModes = subModes;
};
oop.inherits(FoldMode, BaseFoldMode);
(function() {
this.$getMode = function(state) {
for (var key in this.subModes) {
if (state.indexOf(key) === 0)
return this.subModes[key];
}
return null;
};
this.$tryMode = function(state, session, foldStyle, row) {
var mode = this.$getMode(state);
return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
};
this.getFoldWidget = function(session, foldStyle, row) {
return (
this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
this.$tryMode(session.getState(row), session, foldStyle, row) ||
this.defaultMode.getFoldWidget(session, foldStyle, row)
);
};
this.getFoldWidgetRange = function(session, foldStyle, row) {
var mode = this.$getMode(session.getState(row-1));
if (!mode || !mode.getFoldWidget(session, foldStyle, row))
mode = this.$getMode(session.getState(row));
if (!mode || !mode.getFoldWidget(session, foldStyle, row))
mode = this.defaultMode;
return mode.getFoldWidgetRange(session, foldStyle, row);
};
}).call(FoldMode.prototype);
});

65
vendor/ace/mode/folding/pythonic.js vendored Normal file
View File

@@ -0,0 +1,65 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var BaseFoldMode = require("./fold_mode").FoldMode;
var FoldMode = exports.FoldMode = function(markers) {
this.foldingStartMarker = new RegExp("(?:([\\[{])|(" + markers + "))(?:\\s*)(?:#.*)?$");
};
oop.inherits(FoldMode, BaseFoldMode);
(function() {
this.getFoldWidgetRange = function(session, foldStyle, row) {
var line = session.getLine(row);
var match = line.match(this.foldingStartMarker);
if (match) {
if (match[1])
return this.openingBracketBlock(session, match[1], row, match.index);
if (match[2])
return this.indentationBlock(session, row, match.index + match[2].length);
return this.indentationBlock(session, row);
}
}
}).call(FoldMode.prototype);
});

102
vendor/ace/mode/folding/pythonic_test.js vendored Normal file
View File

@@ -0,0 +1,102 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
if (typeof process !== "undefined")
require("amd-loader");
define(function(require, exports, module) {
"use strict";
var PythonMode = require("../python").Mode;
var EditSession = require("../../edit_session").EditSession;
var assert = require("../../test/assertions");
module.exports = {
"test: bracket folding": function() {
var session = new EditSession([
'[ #-',
'stuff',
']',
'[ ',
'{ '
]);
var mode = new PythonMode();
session.setFoldStyle("markbeginend");
session.setMode(mode);
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(2), "");
assert.equal(session.getFoldWidget(3), "start");
assert.equal(session.getFoldWidget(4), "start");
assert.range(session.getFoldWidgetRange(0), 0, 1, 2, 0);
assert.equal(session.getFoldWidgetRange(3), null);
},
"test: indentation folding": function() {
var session = new EditSession([
'def a: #',
'',
' b:',
' c',
' ',
' c',
'',
' ',
''
]);
var mode = new PythonMode();
session.setFoldStyle("markbeginend");
session.setMode(mode);
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(2), "start");
assert.range(session.getFoldWidgetRange(0), 0, 6, 5, 3);
assert.range(session.getFoldWidgetRange(2), 2, 3, 5, 3);
}
};
});
if (typeof module !== "undefined" && module === require.main)
require("asyncjs").test.testcase(module.exports).exec();

262
vendor/ace/mode/folding/xml.js vendored Normal file
View File

@@ -0,0 +1,262 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var lang = require("../../lib/lang");
var Range = require("../../range").Range;
var BaseFoldMode = require("./fold_mode").FoldMode;
var TokenIterator = require("../../token_iterator").TokenIterator;
var FoldMode = exports.FoldMode = function(voidElements) {
BaseFoldMode.call(this);
this.voidElements = voidElements || {};
};
oop.inherits(FoldMode, BaseFoldMode);
(function() {
this.getFoldWidget = function(session, foldStyle, row) {
var tag = this._getFirstTagInLine(session, row);
if (tag.closing)
return foldStyle == "markbeginend" ? "end" : "";
if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()])
return "";
if (tag.selfClosing)
return "";
if (tag.value.indexOf("/" + tag.tagName) !== -1)
return "";
return "start";
};
this._getFirstTagInLine = function(session, row) {
var tokens = session.getTokens(row, row)[0].tokens;
var value = "";
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (token.type.indexOf("meta.tag") === 0)
value += token.value;
else
value += lang.stringRepeat(" ", token.value.length);
}
return this._parseTag(value);
};
this.tagRe = /^(\s*)(<?(\/?)([-_a-zA-Z0-9:!]*)\s*(\/?)>?)/;
this._parseTag = function(tag) {
var match = this.tagRe.exec(tag);
var column = this.tagRe.lastIndex || 0;
this.tagRe.lastIndex = 0;
return {
value: tag,
match: match ? match[2] : "",
closing: match ? !!match[3] : false,
selfClosing: match ? !!match[5] || match[2] == "/>" : false,
tagName: match ? match[4] : "",
column: match[1] ? column + match[1].length : column
};
};
/**
* reads a full tag and places the iterator after the tag
*/
this._readTagForward = function(iterator) {
var token = iterator.getCurrentToken();
if (!token)
return null;
var value = "";
var start;
do {
if (token.type.indexOf("meta.tag") === 0) {
if (!start) {
var start = {
row: iterator.getCurrentTokenRow(),
column: iterator.getCurrentTokenColumn()
};
}
value += token.value;
if (value.indexOf(">") !== -1) {
var tag = this._parseTag(value);
tag.start = start;
tag.end = {
row: iterator.getCurrentTokenRow(),
column: iterator.getCurrentTokenColumn() + token.value.length
};
iterator.stepForward();
return tag;
}
}
} while(token = iterator.stepForward());
return null;
};
this._readTagBackward = function(iterator) {
var token = iterator.getCurrentToken();
if (!token)
return null;
var value = "";
var end;
do {
if (token.type.indexOf("meta.tag") === 0) {
if (!end) {
end = {
row: iterator.getCurrentTokenRow(),
column: iterator.getCurrentTokenColumn() + token.value.length
};
}
value = token.value + value;
if (value.indexOf("<") !== -1) {
var tag = this._parseTag(value);
tag.end = end;
tag.start = {
row: iterator.getCurrentTokenRow(),
column: iterator.getCurrentTokenColumn()
};
iterator.stepBackward();
return tag;
}
}
} while(token = iterator.stepBackward());
return null;
};
this._pop = function(stack, tag) {
while (stack.length) {
var top = stack[stack.length-1];
if (!tag || top.tagName == tag.tagName) {
return stack.pop();
}
else if (this.voidElements[tag.tagName]) {
return;
}
else if (this.voidElements[top.tagName]) {
stack.pop();
continue;
} else {
return null;
}
}
};
this.getFoldWidgetRange = function(session, foldStyle, row) {
var firstTag = this._getFirstTagInLine(session, row);
if (!firstTag.match)
return null;
var isBackward = firstTag.closing || firstTag.selfClosing;
var stack = [];
var tag;
if (!isBackward) {
var iterator = new TokenIterator(session, row, firstTag.column);
var start = {
row: row,
column: firstTag.column + firstTag.tagName.length + 2
};
while (tag = this._readTagForward(iterator)) {
if (tag.selfClosing) {
if (!stack.length) {
tag.start.column += tag.tagName.length + 2;
tag.end.column -= 2;
return Range.fromPoints(tag.start, tag.end);
} else
continue;
}
if (tag.closing) {
this._pop(stack, tag);
if (stack.length == 0)
return Range.fromPoints(start, tag.start);
}
else {
stack.push(tag)
}
}
}
else {
var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length);
var end = {
row: row,
column: firstTag.column
};
while (tag = this._readTagBackward(iterator)) {
if (tag.selfClosing) {
if (!stack.length) {
tag.start.column += tag.tagName.length + 2;
tag.end.column -= 2;
return Range.fromPoints(tag.start, tag.end);
} else
continue;
}
if (!tag.closing) {
this._pop(stack, tag);
if (stack.length == 0) {
tag.start.column += tag.tagName.length + 2;
return Range.fromPoints(tag.start, end);
}
}
else {
stack.push(tag)
}
}
}
};
}).call(FoldMode.prototype);
});

117
vendor/ace/mode/folding/xml_test.js vendored Normal file
View File

@@ -0,0 +1,117 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
if (typeof process !== "undefined")
require("amd-loader");
define(function(require, exports, module) {
"use strict";
var XmlMode = require("../xml").Mode;
var EditSession = require("../../edit_session").EditSession;
var assert = require("../../test/assertions");
module.exports = {
"test: fold multi line self closing element": function() {
var session = new EditSession([
'<person',
' firstname="fabian"',
' lastname="jakobs"/>'
]);
var mode = new XmlMode();
session.setFoldStyle("markbeginend");
session.setMode(mode);
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(2), "end");
assert.range(session.getFoldWidgetRange(0), 0, 8, 2, 19);
assert.range(session.getFoldWidgetRange(2), 0, 8, 2, 19);
},
"test: fold should skip self closing elements": function() {
var session = new EditSession([
'<person>',
' <attrib value="fabian"/>',
'</person>'
]);
var mode = new XmlMode();
session.setFoldStyle("markbeginend");
session.setMode(mode);
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(2), "end");
assert.range(session.getFoldWidgetRange(0), 0, 8, 2, 0);
assert.range(session.getFoldWidgetRange(2), 0, 8, 2, 0);
},
"test: fold should skip multi line self closing elements": function() {
var session = new EditSession([
'<person>',
' <attib',
' key="name"',
' value="fabian"/>',
'</person>'
]);
var mode = new XmlMode();
session.setMode(mode);
session.setFoldStyle("markbeginend");
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "start");
assert.equal(session.getFoldWidget(2), "");
assert.equal(session.getFoldWidget(3), "end");
assert.equal(session.getFoldWidget(4), "end");
assert.range(session.getFoldWidgetRange(0), 0, 8, 4, 0);
assert.range(session.getFoldWidgetRange(1), 1, 9, 3, 19);
assert.range(session.getFoldWidgetRange(3), 1, 9, 3, 19);
assert.range(session.getFoldWidgetRange(4), 0, 8, 4, 0);
}
};
});
if (typeof module !== "undefined" && module === require.main)
require("asyncjs").test.testcase(module.exports).exec();

View File

@@ -1,21 +1,19 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var JavaScriptMode = require("./javascript").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var GroovyHighlightRules = require("./groovy_highlight_rules").GroovyHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var Mode = function() {
JavaScriptMode.call(this);
this.$tokenizer = new Tokenizer(new GroovyHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
};
oop.inherits(Mode, JavaScriptMode);
(function() {
this.createWorker = function(session) {
return null;
};

View File

@@ -1,4 +1,5 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var lang = require("../lib/lang");

View File

@@ -1,4 +1,5 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
@@ -6,11 +7,13 @@ var Tokenizer = require("../tokenizer").Tokenizer;
var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.$tokenizer = new Tokenizer(new HaxeHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
this.foldingRules = new CStyleFoldMode();
};
oop.inherits(Mode, TextMode);
@@ -21,7 +24,6 @@ oop.inherits(Mode, TextMode);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;

View File

@@ -1,4 +1,5 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var lang = require("../lib/lang");

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
@@ -44,6 +45,7 @@ var CssMode = require("./css").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
var HtmlFoldMode = require("./folding/html").FoldMode;
var Mode = function() {
var highlighter = new HtmlHighlightRules();
@@ -52,14 +54,17 @@ var Mode = function() {
this.$embeds = highlighter.getEmbeds();
this.createModeDelegates({
"js-": JavaScriptMode,
"css-": CssMode
"js-": JavaScriptMode,
"css-": CssMode
});
this.foldingRules = new HtmlFoldMode();
};
oop.inherits(Mode, TextMode);
(function() {
this.toggleCommentLines = function(state, doc, startRow, endRow) {
return 0;
};

View File

@@ -36,84 +36,20 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
var xmlUtil = require("./xml_util");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var HtmlHighlightRules = function() {
// regexp must not have capturing parentheses
// regexps are ordered -> the first match is used
function string(state) {
return [{
token : "string",
regex : '".*?"'
}, {
token : "string", // multi line string start
merge : true,
regex : '["].*$',
next : state + "-qqstring"
}, {
token : "string",
regex : "'.*?'"
}, {
token : "string", // multi line string start
merge : true,
regex : "['].*$",
next : state + "-qstring"
}]
}
function multiLineString(quote, state) {
return [{
token : "string",
merge : true,
regex : ".*" + quote,
next : state
}, {
token : "string",
merge : true,
regex : '.+'
}]
}
function tag(states, name, nextState) {
states[name] = [{
token : "text",
regex : "\\s+"
}, {
token : "meta.tag",
regex : "[-_a-zA-Z0-9:]+",
next : name + "embed-attribute-list"
}, {
token: "empty",
regex: "",
next : name + "embed-attribute-list"
}];
states[name + "-qstring"] = multiLineString("'", name);
states[name + "-qqstring"] = multiLineString("\"", name);
states[name + "embed-attribute-list"] = [{
token : "text",
regex : ">",
next : nextState
}, {
token : "entity.other.attribute-name",
regex : "[-_a-zA-Z0-9:]+"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "text",
regex : "\\s+"
}].concat(string(name));
};
this.$rules = {
start : [ {
start : [{
token : "text",
merge : true,
regex : "<\\!\\[CDATA\\[",
@@ -127,15 +63,15 @@ var HtmlHighlightRules = function() {
regex : "<\\!--",
next : "comment"
}, {
token : "text",
regex : "<(?=\s*script)",
token : "meta.tag",
regex : "<(?=\s*script\\b)",
next : "script"
}, {
token : "text",
regex : "<(?=\s*style)",
next : "css"
token : "meta.tag",
regex : "<(?=\s*style\\b)",
next : "style"
}, {
token : "text", // opening tag
token : "meta.tag", // opening tag
regex : "<\\/?",
next : "tag"
}, {
@@ -171,22 +107,22 @@ var HtmlHighlightRules = function() {
} ]
};
tag(this.$rules, "tag", "start");
tag(this.$rules, "css", "css-start");
tag(this.$rules, "script", "js-start");
xmlUtil.tag(this.$rules, "tag", "start");
xmlUtil.tag(this.$rules, "style", "css-start");
xmlUtil.tag(this.$rules, "script", "js-start");
this.embedRules(JavaScriptHighlightRules, "js-", [{
token: "comment",
regex: "\\/\\/.*(?=<\\/script>)",
next: "tag"
}, {
token: "text",
token: "meta.tag",
regex: "<\\/(?=script)",
next: "tag"
}]);
this.embedRules(CssHighlightRules, "css-", [{
token: "text",
token: "meta.tag",
regex: "<\\/(?=style)",
next: "tag"
}]);

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var EditSession = require("../edit_session").EditSession;
var Range = require("../range").Range;

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var HtmlMode = require("./html").Mode;
var assert = require("../test/assertions");
@@ -50,22 +51,22 @@ module.exports = {
},
"test: tokenize embedded script" : function() {
var line = "<script a='a'>var</script>'123'";
var tokens = this.tokenizer.getLineTokens(line, "start").tokens;
//assert.equal(10, tokens.length);
assert.equal("text", tokens[0].type);
assert.equal("meta.tag", tokens[1].type);
assert.equal(12, tokens.length);
assert.equal("meta.tag", tokens[0].type);
assert.equal("meta.tag.script", tokens[1].type);
assert.equal("text", tokens[2].type);
assert.equal("entity.other.attribute-name", tokens[3].type);
assert.equal("text", tokens[4].type);
assert.equal("keyword.operator", tokens[4].type);
assert.equal("string", tokens[5].type);
assert.equal("text", tokens[6].type);
assert.equal("meta.tag", tokens[6].type);
assert.equal("keyword.definition", tokens[7].type);
assert.equal("text", tokens[8].type);
assert.equal("meta.tag", tokens[9].type);
assert.equal("text", tokens[10].type);
assert.equal("meta.tag", tokens[8].type);
assert.equal("meta.tag.script", tokens[9].type);
assert.equal("meta.tag", tokens[10].type);
assert.equal("text", tokens[11].type);
},
"test: tokenize multiline attribute value with double quotes": function() {
@@ -88,5 +89,5 @@ module.exports = {
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec()
require("asyncjs").test.testcase(module.exports).exec();
}

View File

@@ -1,16 +1,15 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var JavaScriptMode = require("./javascript").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var JavaHighlightRules = require("./java_highlight_rules").JavaHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var Mode = function() {
JavaScriptMode.call(this);
this.$tokenizer = new Tokenizer(new JavaHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
};
oop.inherits(Mode, JavaScriptMode);

View File

@@ -1,4 +1,5 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var lang = require("../lib/lang");

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
@@ -45,16 +46,19 @@ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutd
var Range = require("../range").Range;
var WorkerClient = require("../worker/worker_client").WorkerClient;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
this.foldingRules = new CStyleFoldMode();
};
oop.inherits(Mode, TextMode);
(function() {
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var outdent = true;
var re = /^(\s*)\/\//;

View File

@@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var lang = require("../lib/lang");
@@ -205,10 +206,9 @@ var JavaScriptHighlightRules = function() {
regex : "\\/\\/.*$"
}, {
token: "string.regexp",
regex: "\\/(?:(?:\\[(?:\\\\]|[^\\]])+\\])"
+ "|(?:\\\\/|[^\\]/]))*"
+ "[/]\\w*",
next: "start"
regex: "\\/",
next: "regex",
merge: true
}, {
token : "text",
regex : "\\s+"
@@ -220,6 +220,54 @@ var JavaScriptHighlightRules = function() {
next: "start"
}
],
"regex": [
{
token: "regexp.keyword.operator",
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
next: "regex"
}, {
// flag
token: "string.regexp",
regex: "/\\w*",
next: "start",
merge: true
}, {
token: "string.regexp",
regex: "[^\\\\/\\[]+",
next: "regex",
merge: true
}, {
token: "string.regexp.charachterclass",
regex: "\\[",
next: "regex_character_class",
merge: true
}, {
token: "empty",
regex: "",
next: "start"
}
],
"regex_character_class": [
{
token: "regexp.keyword.operator",
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
next: "regex_character_class"
}, {
token: "string.regexp.charachterclass",
regex: "]",
next: "regex",
merge: true
}, {
token: "string.regexp.charachterclass",
regex: "[^\\\\\\]]+",
next: "regex_character_class",
merge: true
}, {
token: "empty",
regex: "",
next: "start"
}
],
"comment_regex_allowed" : [
{
token : "comment", // closing comment

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var EditSession = require("../edit_session").EditSession;
var Tokenizer = require("../tokenizer").Tokenizer;

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var JavaScriptMode = require("./javascript").Mode;
var assert = require("../test/assertions");

View File

@@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var Mirror = require("../worker/mirror").Mirror;

View File

@@ -40,6 +40,7 @@ if (typeof process !== "undefined") {
}
define(function(require, exports, module) {
"use strict";
var assert = require("../test/assertions");
var JavaScriptWorker = require("./javascript_worker").JavaScriptWorker;

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