Compare commits
88 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca8da0a3f3 | ||
|
|
f10da4cdb0 | ||
|
|
d953740339 | ||
|
|
6cec0b28b2 | ||
|
|
3f31ca57ed | ||
|
|
fb7144b622 | ||
|
|
2249d06337 | ||
|
|
1514d5f374 | ||
|
|
446e3e1bf9 | ||
|
|
652dd7009c | ||
|
|
3d23e1e98f | ||
|
|
cafc7e7ce1 | ||
|
|
abdc4c7510 | ||
|
|
8c1d0ab7cf | ||
|
|
9f57989043 | ||
|
|
2a089863e2 | ||
|
|
386c508042 | ||
|
|
dc7643db8d | ||
|
|
5705a7c2c1 | ||
|
|
2e2d9bcdc9 | ||
|
|
a799a4086f | ||
|
|
af5c7a9c3b | ||
|
|
fe96eef206 | ||
|
|
0a3b002e28 | ||
|
|
60439d927f | ||
|
|
95bb17d04b | ||
|
|
2c1b565591 | ||
|
|
53ea1a8665 | ||
|
|
9534e4ea92 | ||
|
|
fa86327b3d | ||
|
|
a68e8bea01 | ||
|
|
88d8cf3447 | ||
|
|
9e9aa8f328 | ||
|
|
93c39ca5b0 | ||
|
|
0db985a3d7 | ||
|
|
ad5802be06 | ||
|
|
0abd9ec30e | ||
|
|
6d205a8f7e | ||
|
|
d2dc26f5a5 | ||
|
|
ef4537a099 | ||
|
|
46f76b4b06 | ||
|
|
71d1ca9d20 | ||
|
|
263a45db02 | ||
|
|
9323a2616b | ||
|
|
ad22b71cfe | ||
|
|
cd8099b0ad | ||
|
|
a61d304cbb | ||
|
|
e72f1d8337 | ||
|
|
d080fe51d4 | ||
|
|
32cb8c6b0e | ||
|
|
3ce8d76c89 | ||
|
|
a842dcdee3 | ||
|
|
0dcb1281cd | ||
|
|
65ad04082f | ||
|
|
b6f7e5d6a1 | ||
|
|
5a3bf2570f | ||
|
|
2d7ebc34b6 | ||
|
|
87044e8816 | ||
|
|
82453d884b | ||
|
|
636ace5178 | ||
|
|
3673aabe2a | ||
|
|
694d7431b7 | ||
|
|
89b9a8ac72 | ||
|
|
67c7da75b6 | ||
|
|
662cd11975 | ||
|
|
68d531ecb2 | ||
|
|
e58fa3e6d7 | ||
|
|
e610365e67 | ||
|
|
65b2cf2855 | ||
|
|
2008ab813f | ||
|
|
ecb699aa11 | ||
|
|
63687f693b | ||
|
|
685ba18451 | ||
|
|
1ec6eb7b5d | ||
|
|
1027dcea7c | ||
|
|
961f8c4893 | ||
|
|
27284cd29f | ||
|
|
04f4292fbc | ||
|
|
4e6d48bf2e | ||
|
|
80f43beb73 | ||
|
|
cf0c81a25f | ||
|
|
ee90854917 | ||
|
|
ff4429dd5a | ||
|
|
487408e84d | ||
|
|
2713d0a8db | ||
|
|
b0ce5630c9 | ||
|
|
d89311e596 | ||
|
|
5482db1c4d |
92 changed files with 1524 additions and 398 deletions
|
|
@ -1,5 +1,16 @@
|
||||||
|
Version 1.2.0-pre
|
||||||
|
|
||||||
|
* New Features
|
||||||
|
- Indented soft wrap (danyaPostfactum)
|
||||||
|
|
||||||
|
* API Changes
|
||||||
|
- unified delta types `{start, end, action, lines}` (Alden Daniels https://github.com/ajaxorg/ace/pull/1745)
|
||||||
|
- "change" event listeners on session and editor get delta objects directly
|
||||||
|
|
||||||
2015.04.03 Version 1.1.9
|
2015.04.03 Version 1.1.9
|
||||||
|
|
||||||
|
- Small Enhancements and Bugfixes
|
||||||
|
|
||||||
2014.11.08 Version 1.1.8
|
2014.11.08 Version 1.1.8
|
||||||
|
|
||||||
* API Changes
|
* API Changes
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,13 @@
|
||||||
<style type="text/css" media="screen">
|
<style type="text/css" media="screen">
|
||||||
|
|
||||||
.ace_editor {
|
.ace_editor {
|
||||||
position: relative !important;
|
|
||||||
border: 1px solid lightgray;
|
border: 1px solid lightgray;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
height: 200px;
|
height: 200px;
|
||||||
width: 80%;
|
width: 80%;
|
||||||
}
|
}
|
||||||
.scrollmargin {
|
.scrollmargin {
|
||||||
height: 100px;
|
height: 80px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -24,6 +23,8 @@
|
||||||
<div class="scrollmargin"></div>
|
<div class="scrollmargin"></div>
|
||||||
<pre id="editor2">minHeight = 2 lines</pre>
|
<pre id="editor2">minHeight = 2 lines</pre>
|
||||||
<div class="scrollmargin"></div>
|
<div class="scrollmargin"></div>
|
||||||
|
<pre id="editor3" style="width: 40%;"></pre>
|
||||||
|
<div class="scrollmargin"></div>
|
||||||
<pre id="editor"></pre>
|
<pre id="editor"></pre>
|
||||||
|
|
||||||
<script src="kitchen-sink/require.js"></script>
|
<script src="kitchen-sink/require.js"></script>
|
||||||
|
|
@ -46,6 +47,13 @@ require(["ace/ace"], function(ace) {
|
||||||
editor2.setOption("maxLines", 30);
|
editor2.setOption("maxLines", 30);
|
||||||
editor2.setOption("minLines", 2);
|
editor2.setOption("minLines", 2);
|
||||||
|
|
||||||
|
var editor = ace.edit("editor3");
|
||||||
|
editor.setOptions({
|
||||||
|
autoScrollEditorIntoView: true,
|
||||||
|
maxLines: 8
|
||||||
|
});
|
||||||
|
editor.renderer.setScrollMargin(10, 10, 10, 10);
|
||||||
|
|
||||||
var editor = ace.edit("editor");
|
var editor = ace.edit("editor");
|
||||||
editor.setTheme("ace/theme/tomorrow");
|
editor.setTheme("ace/theme/tomorrow");
|
||||||
editor.session.setMode("ace/mode/html");
|
editor.session.setMode("ace/mode/html");
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ function warn() {
|
||||||
s.shift(); // remove the getter
|
s.shift(); // remove the getter
|
||||||
s = s.join("\n");
|
s = s.join("\n");
|
||||||
// allow easy access to ace in console, but not in ace code
|
// allow easy access to ace in console, but not in ace code
|
||||||
if (!/at Object.InjectedScript.|@debugger eval|snippets:\/{3}/.test(s)) {
|
if (!/at Object.InjectedScript.|@debugger eval|snippets:\/{3}|\(<anonymous>:\d+:\d+\)/.test(s)) {
|
||||||
console.error("trying to access to global variable");
|
console.error("trying to access to global variable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
-- =============================================
|
-- =============================================
|
||||||
-- Author: Morgan Yarbrough
|
-- Author: Morgan Yarbrough
|
||||||
-- Create date: 4/27/2015
|
-- Create date: 4/27/2015
|
||||||
-- Description: Test Procedure that shows off language features.
|
-- Description: Test procedure that shows off language features.
|
||||||
-- Includes non-standard folding using region comments using either
|
-- Includes non-standard folding with region comments using either
|
||||||
-- line comments or block comments (both are demonstrated below)
|
-- line comments or block comments (both are demonstrated below).
|
||||||
-- This mode imitates SSMS and it designed to be used with SQL Server theme.
|
-- This mode imitates SSMS and it designed to be used with SQL Server theme.
|
||||||
-- =============================================
|
-- =============================================
|
||||||
CREATE PROCEDURE dbo.TestProcedure
|
CREATE PROCEDURE dbo.TestProcedure
|
||||||
|
|
@ -11,7 +11,7 @@ CREATE PROCEDURE dbo.TestProcedure
|
||||||
--#region parameters
|
--#region parameters
|
||||||
@vint INT = 1
|
@vint INT = 1
|
||||||
,@vdate DATE = NULL
|
,@vdate DATE = NULL
|
||||||
,@vdatetime DATETIME = DATEADD (dd, 1, GETDATE())
|
,@vdatetime DATETIME = DATEADD(dd, 1, GETDATE())
|
||||||
,@vvarchar VARCHAR(MAX) = ''
|
,@vvarchar VARCHAR(MAX) = ''
|
||||||
--#endregion
|
--#endregion
|
||||||
|
|
||||||
|
|
@ -38,8 +38,8 @@ BEGIN
|
||||||
-- another folding demonstration
|
-- another folding demonstration
|
||||||
IF @vint = 1
|
IF @vint = 1
|
||||||
BEGIN
|
BEGIN
|
||||||
SET @vvarchar='one'
|
SET @vvarchar = 'one'
|
||||||
SET @vint = DATEDIFFT(dd, @vdate, @vdatetime)
|
SET @vint = DATEDIFF(dd, @vdate, @vdatetime)
|
||||||
END
|
END
|
||||||
|
|
||||||
-- this mode handles strings properly
|
-- this mode handles strings properly
|
||||||
|
|
@ -47,7 +47,7 @@ BEGIN
|
||||||
FROM Orders
|
FROM Orders
|
||||||
WHERE @OrderDate > GETDATE()'
|
WHERE @OrderDate > GETDATE()'
|
||||||
|
|
||||||
-- this mode is aware of build in stored procedures
|
-- this mode is aware of built in stored procedures
|
||||||
EXECUTE sp_executesql @sql
|
EXECUTE sp_executesql @sql
|
||||||
|
|
||||||
-- demonstrating some syntax highlighting
|
-- demonstrating some syntax highlighting
|
||||||
|
|
@ -60,4 +60,13 @@ BEGIN
|
||||||
WHERE CompanyName NOT LIKE '%something'
|
WHERE CompanyName NOT LIKE '%something'
|
||||||
OR CompanyName IS NULL
|
OR CompanyName IS NULL
|
||||||
OR CompanyName IN ('bla', 'nothing')
|
OR CompanyName IN ('bla', 'nothing')
|
||||||
|
|
||||||
|
-- this mode includes snippets
|
||||||
|
-- place your cusor at the end of the line below and trigger auto complete (Ctrl+Space)
|
||||||
|
createpr
|
||||||
|
|
||||||
|
-- SQL Server allows using keywords as object names (not recommended) as long as they are wrapped in brackets
|
||||||
|
DATABASE -- keyword
|
||||||
|
[DATABASE] -- not a keyword
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,13 @@
|
||||||
* Simple node.js server, which generates the synax highlighted version of itself
|
* Simple node.js server, which generates the synax highlighted version of itself
|
||||||
* using the Ace modes and themes on the server and serving a static web page.
|
* using the Ace modes and themes on the server and serving a static web page.
|
||||||
*/
|
*/
|
||||||
// $'
|
|
||||||
// include ace search path and modules
|
// include ace search path and modules
|
||||||
require("amd-loader");
|
require("amd-loader");
|
||||||
|
|
||||||
// load jsdom, which is required by Ace
|
|
||||||
require("../../lib/ace/test/mockdom");
|
|
||||||
|
|
||||||
var http = require("http");
|
var http = require("http");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
var resolve = require("path").resolve;
|
||||||
|
|
||||||
// load the highlighter and the desired mode and theme
|
// load the highlighter and the desired mode and theme
|
||||||
var highlighter = require("../../lib/ace/ext/static_highlight");
|
var highlighter = require("../../lib/ace/ext/static_highlight");
|
||||||
|
|
@ -20,8 +18,15 @@ var theme = require("../../lib/ace/theme/twilight");
|
||||||
var port = process.env.PORT || 2222;
|
var port = process.env.PORT || 2222;
|
||||||
|
|
||||||
http.createServer(function(req, res) {
|
http.createServer(function(req, res) {
|
||||||
|
var url = req.url;
|
||||||
|
var path = /[^#?\x00]*/.exec(url)[0];
|
||||||
|
var root = resolve(__dirname + "/../../").replace(/\\/g, "/");
|
||||||
|
path = resolve(root + "/" + path).replace(/\\/g, "/");
|
||||||
|
if (path.indexOf(root + "/") != 0)
|
||||||
|
path = __filename;
|
||||||
res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"});
|
res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"});
|
||||||
fs.readFile(__dirname + "/../../build/src/ace.js", "utf8", function(err, data) {
|
fs.readFile(path, "utf8", function(err, data) {
|
||||||
|
if (err) data = err.message;
|
||||||
var highlighted = highlighter.render(data, new JavaScriptMode(), theme);
|
var highlighted = highlighter.render(data, new JavaScriptMode(), theme);
|
||||||
res.end(
|
res.end(
|
||||||
'<html><body>\n' +
|
'<html><body>\n' +
|
||||||
|
|
|
||||||
59
experiments/debug_mem_leak.html
Normal file
59
experiments/debug_mem_leak.html
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<script src="../demo/kitchen-sink/require.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
require.config({
|
||||||
|
paths: { ace: "../lib/ace" },
|
||||||
|
waitSeconds: 0
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p><button onclick="toggleEditor()">Toggle editor</button></p>
|
||||||
|
|
||||||
|
<div id="container"></div>
|
||||||
|
<script>
|
||||||
|
var editor;
|
||||||
|
var counter = 0
|
||||||
|
|
||||||
|
function toggleEditor() {
|
||||||
|
if (!editor) {
|
||||||
|
var root = document.createElement("div");
|
||||||
|
root.style.height = "100px";
|
||||||
|
root.setAttribute("id", "editor");
|
||||||
|
root.textContent = "function foo(items) {\nvar x = 'All this is syntax highlighted';\nreturn x;\n}";
|
||||||
|
|
||||||
|
document.getElementById("container").appendChild(root);
|
||||||
|
|
||||||
|
editor = ace.edit(root);
|
||||||
|
|
||||||
|
if (counter++ % 2)
|
||||||
|
editor.setTheme("ace/theme/monokai");
|
||||||
|
else
|
||||||
|
editor.setTheme("ace/theme/clouds");
|
||||||
|
|
||||||
|
editor.session.setMode("ace/mode/javascript");
|
||||||
|
} else {
|
||||||
|
editor.destroy();
|
||||||
|
var el = editor.container;
|
||||||
|
el.parentNode.removeChild(el);
|
||||||
|
|
||||||
|
editor.container = null
|
||||||
|
editor.renderer = null
|
||||||
|
|
||||||
|
editor = null;
|
||||||
|
|
||||||
|
var root = document.getElementById("editor")
|
||||||
|
if (root)
|
||||||
|
root.parentNode.removeChild(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require(["ace/ace"], function(ace) {
|
||||||
|
window.ace = ace;
|
||||||
|
toggleEditor();
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -100,7 +100,7 @@ var Autocomplete = function() {
|
||||||
var rect = editor.container.getBoundingClientRect();
|
var rect = editor.container.getBoundingClientRect();
|
||||||
pos.top += rect.top - renderer.layerConfig.offset;
|
pos.top += rect.top - renderer.layerConfig.offset;
|
||||||
pos.left += rect.left - editor.renderer.scrollLeft;
|
pos.left += rect.left - editor.renderer.scrollLeft;
|
||||||
pos.left += renderer.$gutterLayer.gutterWidth;
|
pos.left += renderer.gutterWidth;
|
||||||
|
|
||||||
this.popup.show(pos, lineHeight);
|
this.popup.show(pos, lineHeight);
|
||||||
} else if (keepPopupPosition && !prefix) {
|
} else if (keepPopupPosition && !prefix) {
|
||||||
|
|
@ -142,10 +142,11 @@ var Autocomplete = function() {
|
||||||
// we have to check if activeElement is a child of popup because
|
// we have to check if activeElement is a child of popup because
|
||||||
// on IE preventDefault doesn't stop scrollbar from being focussed
|
// on IE preventDefault doesn't stop scrollbar from being focussed
|
||||||
var el = document.activeElement;
|
var el = document.activeElement;
|
||||||
var text = this.editor.textInput.getElement()
|
var text = this.editor.textInput.getElement();
|
||||||
if (el != text && ( !this.popup || el.parentNode != this.popup.container )
|
var fromTooltip = e.relatedTarget && e.relatedTarget == this.tooltipNode;
|
||||||
&& el != this.tooltipNode && e.relatedTarget != this.tooltipNode
|
var container = this.popup && this.popup.container;
|
||||||
&& e.relatedTarget != text
|
if (el != text && el.parentNode != container && !fromTooltip
|
||||||
|
&& el != this.tooltipNode && e.relatedTarget != text
|
||||||
) {
|
) {
|
||||||
this.detach();
|
this.detach();
|
||||||
}
|
}
|
||||||
|
|
@ -349,7 +350,7 @@ var Autocomplete = function() {
|
||||||
doc = selected;
|
doc = selected;
|
||||||
|
|
||||||
if (typeof doc == "string")
|
if (typeof doc == "string")
|
||||||
doc = {docText: doc}
|
doc = {docText: doc};
|
||||||
if (!doc || !(doc.docHTML || doc.docText))
|
if (!doc || !(doc.docHTML || doc.docText))
|
||||||
return this.hideDocTooltip();
|
return this.hideDocTooltip();
|
||||||
this.showDocTooltip(doc);
|
this.showDocTooltip(doc);
|
||||||
|
|
@ -416,7 +417,7 @@ Autocomplete.startCommand = {
|
||||||
bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
|
bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
|
||||||
};
|
};
|
||||||
|
|
||||||
var FilteredList = function(array, filterText, mutateData) {
|
var FilteredList = function(array, filterText) {
|
||||||
this.all = array;
|
this.all = array;
|
||||||
this.filtered = array;
|
this.filtered = array;
|
||||||
this.filterText = filterText || "";
|
this.filterText = filterText || "";
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var EditSession = require("../edit_session").EditSession;
|
|
||||||
var Renderer = require("../virtual_renderer").VirtualRenderer;
|
var Renderer = require("../virtual_renderer").VirtualRenderer;
|
||||||
var Editor = require("../editor").Editor;
|
var Editor = require("../editor").Editor;
|
||||||
var Range = require("../range").Range;
|
var Range = require("../range").Range;
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,10 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
var endLine = -1;
|
var endLine = -1;
|
||||||
var doc = self.doc;
|
var doc = self.doc;
|
||||||
|
|
||||||
|
var startLine = currentLine;
|
||||||
while (self.lines[currentLine])
|
while (self.lines[currentLine])
|
||||||
currentLine++;
|
currentLine++;
|
||||||
|
|
||||||
var startLine = currentLine;
|
|
||||||
|
|
||||||
var len = doc.getLength();
|
var len = doc.getLength();
|
||||||
var processedLines = 0;
|
var processedLines = 0;
|
||||||
self.running = false;
|
self.running = false;
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,49 @@ module.exports = {
|
||||||
|
|
||||||
forceTokenize(doc)
|
forceTokenize(doc)
|
||||||
testStates(doc, ["comment_regex_allowed", "start", "no_regex"])
|
testStates(doc, ["comment_regex_allowed", "start", "no_regex"])
|
||||||
|
},
|
||||||
|
"test background tokenizer sends update event" : function() {
|
||||||
|
var doc = new EditSession([
|
||||||
|
"/*",
|
||||||
|
"var",
|
||||||
|
"juhu",
|
||||||
|
"*/"
|
||||||
|
]);
|
||||||
|
doc.setMode("./mode/javascript");
|
||||||
|
|
||||||
|
var updateEvent = null;
|
||||||
|
doc.bgTokenizer.on("update", function(e) {
|
||||||
|
updateEvent = e.data;
|
||||||
|
});
|
||||||
|
function checkEvent(first, last) {
|
||||||
|
assert.ok(!updateEvent, "unneccessary update event");
|
||||||
|
doc.bgTokenizer.running = 1;
|
||||||
|
doc.bgTokenizer.$worker();
|
||||||
|
assert.ok(updateEvent);
|
||||||
|
assert.equal([first, last] + "",
|
||||||
|
[updateEvent.first, updateEvent.last] + "")
|
||||||
|
updateEvent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
forceTokenize(doc);
|
||||||
|
var comment = "comment_regex_allowed";
|
||||||
|
testStates(doc, [comment, comment, comment, "start"]);
|
||||||
|
|
||||||
|
doc.remove(new Range(0,0,0,2));
|
||||||
|
testStates(doc, [comment, comment, comment, "start"]);
|
||||||
|
|
||||||
|
checkEvent(0, 3);
|
||||||
|
testStates(doc, ["start", "no_regex", "no_regex", "regex"]);
|
||||||
|
|
||||||
|
// insert /* and and press down several times quickly
|
||||||
|
doc.insert({row:0, column:0}, "/*");
|
||||||
|
doc.getTokens(0);
|
||||||
|
doc.getTokens(1);
|
||||||
|
doc.getTokens(2);
|
||||||
|
checkEvent(0, 3);
|
||||||
|
|
||||||
|
forceTokenize(doc);
|
||||||
|
testStates(doc, [comment, comment, comment, "start"]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -423,6 +423,12 @@ exports.commands = [{
|
||||||
exec: function() {},
|
exec: function() {},
|
||||||
passEvent: true,
|
passEvent: true,
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
}, {
|
||||||
|
name: "copy",
|
||||||
|
exec: function(editor) {
|
||||||
|
// placeholder for replay macro
|
||||||
|
},
|
||||||
|
readOnly: true
|
||||||
},
|
},
|
||||||
|
|
||||||
// commands disabled in readOnly mode
|
// commands disabled in readOnly mode
|
||||||
|
|
@ -439,6 +445,12 @@ exports.commands = [{
|
||||||
},
|
},
|
||||||
scrollIntoView: "cursor",
|
scrollIntoView: "cursor",
|
||||||
multiSelectAction: "forEach"
|
multiSelectAction: "forEach"
|
||||||
|
}, {
|
||||||
|
name: "paste",
|
||||||
|
exec: function(editor, args) {
|
||||||
|
editor.$handlePaste(args);
|
||||||
|
},
|
||||||
|
scrollIntoView: "cursor"
|
||||||
}, {
|
}, {
|
||||||
name: "removeline",
|
name: "removeline",
|
||||||
bindKey: bindKey("Ctrl-D", "Command-D"),
|
bindKey: bindKey("Ctrl-D", "Command-D"),
|
||||||
|
|
|
||||||
|
|
@ -69,18 +69,14 @@ exports.iSearchCommands = [{
|
||||||
bindKey: {win: "Ctrl-F", mac: "Command-F"},
|
bindKey: {win: "Ctrl-F", mac: "Command-F"},
|
||||||
exec: function(iSearch) {
|
exec: function(iSearch) {
|
||||||
iSearch.cancelSearch(true);
|
iSearch.cancelSearch(true);
|
||||||
},
|
}
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: "searchForward",
|
name: "searchForward",
|
||||||
bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"},
|
bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"},
|
||||||
exec: function(iSearch, options) {
|
exec: function(iSearch, options) {
|
||||||
options.useCurrentOrPrevSearch = true;
|
options.useCurrentOrPrevSearch = true;
|
||||||
iSearch.next(options);
|
iSearch.next(options);
|
||||||
},
|
}
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: "searchBackward",
|
name: "searchBackward",
|
||||||
bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"},
|
bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"},
|
||||||
|
|
@ -88,42 +84,30 @@ exports.iSearchCommands = [{
|
||||||
options.useCurrentOrPrevSearch = true;
|
options.useCurrentOrPrevSearch = true;
|
||||||
options.backwards = true;
|
options.backwards = true;
|
||||||
iSearch.next(options);
|
iSearch.next(options);
|
||||||
},
|
}
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: "extendSearchTerm",
|
name: "extendSearchTerm",
|
||||||
exec: function(iSearch, string) {
|
exec: function(iSearch, string) {
|
||||||
iSearch.addString(string);
|
iSearch.addString(string);
|
||||||
},
|
}
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: "extendSearchTermSpace",
|
name: "extendSearchTermSpace",
|
||||||
bindKey: "space",
|
bindKey: "space",
|
||||||
exec: function(iSearch) { iSearch.addString(' '); },
|
exec: function(iSearch) { iSearch.addString(' '); }
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: "shrinkSearchTerm",
|
name: "shrinkSearchTerm",
|
||||||
bindKey: "backspace",
|
bindKey: "backspace",
|
||||||
exec: function(iSearch) {
|
exec: function(iSearch) {
|
||||||
iSearch.removeChar();
|
iSearch.removeChar();
|
||||||
},
|
}
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: 'confirmSearch',
|
name: 'confirmSearch',
|
||||||
bindKey: 'return',
|
bindKey: 'return',
|
||||||
exec: function(iSearch) { iSearch.deactivate(); },
|
exec: function(iSearch) { iSearch.deactivate(); }
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: 'cancelSearch',
|
name: 'cancelSearch',
|
||||||
bindKey: 'esc|Ctrl-G',
|
bindKey: 'esc|Ctrl-G',
|
||||||
exec: function(iSearch) { iSearch.deactivate(true); },
|
exec: function(iSearch) { iSearch.deactivate(true); }
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: 'occurisearch',
|
name: 'occurisearch',
|
||||||
bindKey: 'Ctrl-O',
|
bindKey: 'Ctrl-O',
|
||||||
|
|
@ -131,9 +115,7 @@ exports.iSearchCommands = [{
|
||||||
var options = oop.mixin({}, iSearch.$options);
|
var options = oop.mixin({}, iSearch.$options);
|
||||||
iSearch.deactivate();
|
iSearch.deactivate();
|
||||||
occurStartCommand.exec(iSearch.$editor, options);
|
occurStartCommand.exec(iSearch.$editor, options);
|
||||||
},
|
}
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: "yankNextWord",
|
name: "yankNextWord",
|
||||||
bindKey: "Ctrl-w",
|
bindKey: "Ctrl-w",
|
||||||
|
|
@ -142,9 +124,7 @@ exports.iSearchCommands = [{
|
||||||
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }),
|
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }),
|
||||||
string = ed.session.getTextRange(range);
|
string = ed.session.getTextRange(range);
|
||||||
iSearch.addString(string);
|
iSearch.addString(string);
|
||||||
},
|
}
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: "yankNextChar",
|
name: "yankNextChar",
|
||||||
bindKey: "Ctrl-Alt-y",
|
bindKey: "Ctrl-Alt-y",
|
||||||
|
|
@ -153,15 +133,11 @@ exports.iSearchCommands = [{
|
||||||
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }),
|
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }),
|
||||||
string = ed.session.getTextRange(range);
|
string = ed.session.getTextRange(range);
|
||||||
iSearch.addString(string);
|
iSearch.addString(string);
|
||||||
},
|
}
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: 'recenterTopBottom',
|
name: 'recenterTopBottom',
|
||||||
bindKey: 'Ctrl-l',
|
bindKey: 'Ctrl-l',
|
||||||
exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); },
|
exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); }
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: 'selectAllMatches',
|
name: 'selectAllMatches',
|
||||||
bindKey: 'Ctrl-space',
|
bindKey: 'Ctrl-space',
|
||||||
|
|
@ -173,18 +149,19 @@ exports.iSearchCommands = [{
|
||||||
return ranges.concat(ea ? ea : []); }, []) : [];
|
return ranges.concat(ea ? ea : []); }, []) : [];
|
||||||
iSearch.deactivate(false);
|
iSearch.deactivate(false);
|
||||||
ranges.forEach(ed.selection.addRange.bind(ed.selection));
|
ranges.forEach(ed.selection.addRange.bind(ed.selection));
|
||||||
},
|
}
|
||||||
readOnly: true,
|
|
||||||
isIncrementalSearchCommand: true
|
|
||||||
}, {
|
}, {
|
||||||
name: 'searchAsRegExp',
|
name: 'searchAsRegExp',
|
||||||
bindKey: 'Alt-r',
|
bindKey: 'Alt-r',
|
||||||
exec: function(iSearch) {
|
exec: function(iSearch) {
|
||||||
iSearch.convertNeedleToRegExp();
|
iSearch.convertNeedleToRegExp();
|
||||||
},
|
}
|
||||||
readOnly: true,
|
}].map(function(cmd) {
|
||||||
isIncrementalSearchCommand: true
|
cmd.readOnly = true;
|
||||||
}];
|
cmd.isIncrementalSearchCommand = true;
|
||||||
|
cmd.scrollIntoView = "animate-cursor";
|
||||||
|
return cmd;
|
||||||
|
});
|
||||||
|
|
||||||
function IncrementalSearchKeyboardHandler(iSearch) {
|
function IncrementalSearchKeyboardHandler(iSearch) {
|
||||||
this.$iSearch = iSearch;
|
this.$iSearch = iSearch;
|
||||||
|
|
@ -192,7 +169,7 @@ function IncrementalSearchKeyboardHandler(iSearch) {
|
||||||
|
|
||||||
oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
|
oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
|
||||||
|
|
||||||
;(function() {
|
(function() {
|
||||||
|
|
||||||
this.attach = function(editor) {
|
this.attach = function(editor) {
|
||||||
var iSearch = this.$iSearch;
|
var iSearch = this.$iSearch;
|
||||||
|
|
@ -201,15 +178,19 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
|
||||||
if (!e.command.isIncrementalSearchCommand) return undefined;
|
if (!e.command.isIncrementalSearchCommand) return undefined;
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return e.command.exec(iSearch, e.args || {});
|
var scrollTop = editor.session.getScrollTop();
|
||||||
|
var result = e.command.exec(iSearch, e.args || {});
|
||||||
|
editor.renderer.scrollCursorIntoView(null, 0.5);
|
||||||
|
editor.renderer.animateScrolling(scrollTop);
|
||||||
|
return result;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
this.detach = function(editor) {
|
this.detach = function(editor) {
|
||||||
if (!this.$commandExecHandler) return;
|
if (!this.$commandExecHandler) return;
|
||||||
editor.commands.removeEventListener('exec', this.$commandExecHandler);
|
editor.commands.removeEventListener('exec', this.$commandExecHandler);
|
||||||
delete this.$commandExecHandler;
|
delete this.$commandExecHandler;
|
||||||
}
|
};
|
||||||
|
|
||||||
var handleKeyboard$super = this.handleKeyboard;
|
var handleKeyboard$super = this.handleKeyboard;
|
||||||
this.handleKeyboard = function(data, hashId, key, keyCode) {
|
this.handleKeyboard = function(data, hashId, key, keyCode) {
|
||||||
|
|
@ -222,7 +203,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
|
||||||
if (extendCmd) { return {command: extendCmd, args: key}; }
|
if (extendCmd) { return {command: extendCmd, args: key}; }
|
||||||
}
|
}
|
||||||
return {command: "null", passEvent: hashId == 0 || hashId == 4};
|
return {command: "null", passEvent: hashId == 0 || hashId == 4};
|
||||||
}
|
};
|
||||||
|
|
||||||
}).call(IncrementalSearchKeyboardHandler.prototype);
|
}).call(IncrementalSearchKeyboardHandler.prototype);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ var AppConfig = require("./lib/app_config").AppConfig;
|
||||||
module.exports = exports = new AppConfig();
|
module.exports = exports = new AppConfig();
|
||||||
|
|
||||||
var global = (function() {
|
var global = (function() {
|
||||||
return this;
|
return this || typeof window != "undefined" && window;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
|
|
|
||||||
|
|
@ -422,3 +422,30 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 8;
|
z-index: 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
styles = []
|
||||||
|
for (var i = 1; i < 16; i++) {
|
||||||
|
styles.push(".ace_br" + i + "{" + (
|
||||||
|
["top-left", "top-right", "bottom-right", "bottom-left"]
|
||||||
|
).map(function(x, j) {
|
||||||
|
return i & (1<<j) ? "border-" + x + "-radius: 3px;" : ""
|
||||||
|
}).filter(Boolean).join(" ") + "}")
|
||||||
|
}
|
||||||
|
styles.join("\n")
|
||||||
|
*/
|
||||||
|
.ace_br1 {border-top-left-radius : 3px;}
|
||||||
|
.ace_br2 {border-top-right-radius : 3px;}
|
||||||
|
.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}
|
||||||
|
.ace_br4 {border-bottom-right-radius: 3px;}
|
||||||
|
.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}
|
||||||
|
.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}
|
||||||
|
.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}
|
||||||
|
.ace_br8 {border-bottom-left-radius : 3px;}
|
||||||
|
.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}
|
||||||
|
.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}
|
||||||
|
.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}
|
||||||
|
.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
|
||||||
|
.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
|
||||||
|
.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
|
||||||
|
.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ var EditSession = function(text, mode) {
|
||||||
this.$foldData = [];
|
this.$foldData = [];
|
||||||
this.$foldData.toString = function() {
|
this.$foldData.toString = function() {
|
||||||
return this.join("\n");
|
return this.join("\n");
|
||||||
}
|
};
|
||||||
this.on("changeFold", this.onChangeFold.bind(this));
|
this.on("changeFold", this.onChangeFold.bind(this));
|
||||||
this.$onChange = this.onChange.bind(this);
|
this.$onChange = this.onChange.bind(this);
|
||||||
|
|
||||||
|
|
@ -678,10 +678,10 @@ var EditSession = function(text, mode) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array containing the IDs of all the markers, either front or back.
|
* Returns an object containing all of the markers, either front or back.
|
||||||
* @param {Boolean} inFront If `true`, indicates you only want front markers; `false` indicates only back markers
|
* @param {Boolean} inFront If `true`, indicates you only want front markers; `false` indicates only back markers
|
||||||
*
|
*
|
||||||
* @returns {Array}
|
* @returns {Object}
|
||||||
**/
|
**/
|
||||||
this.getMarkers = function(inFront) {
|
this.getMarkers = function(inFront) {
|
||||||
return inFront ? this.$frontMarkers : this.$backMarkers;
|
return inFront ? this.$frontMarkers : this.$backMarkers;
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ function BracketMatch() {
|
||||||
typeRe = new RegExp(
|
typeRe = new RegExp(
|
||||||
"(\\.?" +
|
"(\\.?" +
|
||||||
token.type.replace(".", "\\.").replace("rparen", ".paren")
|
token.type.replace(".", "\\.").replace("rparen", ".paren")
|
||||||
.replace(/\b(?:end|start|begin)\b/, "")
|
.replace(/\b(?:end)\b/, "(?:start|begin|end)")
|
||||||
+ ")+"
|
+ ")+"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +174,7 @@ function BracketMatch() {
|
||||||
typeRe = new RegExp(
|
typeRe = new RegExp(
|
||||||
"(\\.?" +
|
"(\\.?" +
|
||||||
token.type.replace(".", "\\.").replace("lparen", ".paren")
|
token.type.replace(".", "\\.").replace("lparen", ".paren")
|
||||||
.replace(/\b(?:end|start|begin)\b/, "")
|
.replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
|
||||||
+ ")+"
|
+ ")+"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,8 +162,12 @@ var Editor = function(renderer, session) {
|
||||||
var command = this.curOp.command;
|
var command = this.curOp.command;
|
||||||
if (command.name && this.$blockScrolling > 0)
|
if (command.name && this.$blockScrolling > 0)
|
||||||
this.$blockScrolling--;
|
this.$blockScrolling--;
|
||||||
if (command && command.scrollIntoView) {
|
var scrollIntoView = command && command.scrollIntoView;
|
||||||
switch (command.scrollIntoView) {
|
if (scrollIntoView) {
|
||||||
|
switch (scrollIntoView) {
|
||||||
|
case "center-animate":
|
||||||
|
scrollIntoView = "animate";
|
||||||
|
/* fall through */
|
||||||
case "center":
|
case "center":
|
||||||
this.renderer.scrollCursorIntoView(null, 0.5);
|
this.renderer.scrollCursorIntoView(null, 0.5);
|
||||||
break;
|
break;
|
||||||
|
|
@ -181,7 +185,7 @@ var Editor = function(renderer, session) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (command.scrollIntoView == "animate")
|
if (scrollIntoView == "animate")
|
||||||
this.renderer.animateScrolling(this.curOp.scrollTop);
|
this.renderer.animateScrolling(this.curOp.scrollTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -275,6 +279,10 @@ var Editor = function(renderer, session) {
|
||||||
if (this.session == session)
|
if (this.session == session)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// make sure operationEnd events are not emitted to wrong session
|
||||||
|
if (this.curOp) this.endOperation();
|
||||||
|
this.curOp = {};
|
||||||
|
|
||||||
var oldSession = this.session;
|
var oldSession = this.session;
|
||||||
if (oldSession) {
|
if (oldSession) {
|
||||||
this.session.removeEventListener("change", this.$onDocumentChange);
|
this.session.removeEventListener("change", this.$onDocumentChange);
|
||||||
|
|
@ -373,6 +381,8 @@ var Editor = function(renderer, session) {
|
||||||
oldSession: oldSession
|
oldSession: oldSession
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.curOp = null;
|
||||||
|
|
||||||
oldSession && oldSession._signal("changeEditor", {oldEditor: this});
|
oldSession && oldSession._signal("changeEditor", {oldEditor: this});
|
||||||
session && session._signal("changeEditor", {editor: this});
|
session && session._signal("changeEditor", {editor: this});
|
||||||
};
|
};
|
||||||
|
|
@ -905,14 +915,16 @@ var Editor = function(renderer, session) {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.onPaste = function(text) {
|
this.onPaste = function(text, event) {
|
||||||
// todo this should change when paste becomes a command
|
var e = {text: text, event: event};
|
||||||
if (this.$readOnly)
|
this.commands.exec("paste", this, e);
|
||||||
return;
|
};
|
||||||
|
|
||||||
var e = {text: text};
|
this.$handlePaste = function(e) {
|
||||||
|
if (typeof e == "string")
|
||||||
|
e = {text: e};
|
||||||
this._signal("paste", e);
|
this._signal("paste", e);
|
||||||
text = e.text;
|
var text = e.text;
|
||||||
if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
|
if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
|
||||||
this.insert(text);
|
this.insert(text);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -930,7 +942,6 @@ var Editor = function(renderer, session) {
|
||||||
this.session.insert(range.start, lines[i]);
|
this.session.insert(range.start, lines[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.renderer.scrollCursorIntoView();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.execCommand = function(command, args) {
|
this.execCommand = function(command, args) {
|
||||||
|
|
|
||||||
|
|
@ -393,7 +393,7 @@ exports.updateCommands = function(editor, enabled) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.isSupportedMode = function(modeId) {
|
exports.isSupportedMode = function(modeId) {
|
||||||
return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs/.test(modeId);
|
return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(modeId);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onChangeMode = function(e, target) {
|
var onChangeMode = function(e, target) {
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,6 @@ function getCompletionPrefix(editor) {
|
||||||
|
|
||||||
var doLiveAutocomplete = function(e) {
|
var doLiveAutocomplete = function(e) {
|
||||||
var editor = e.editor;
|
var editor = e.editor;
|
||||||
var text = e.args || "";
|
|
||||||
var hasCompleter = editor.completer && editor.completer.activated;
|
var hasCompleter = editor.completer && editor.completer.activated;
|
||||||
|
|
||||||
// We don't want to autocomplete with no prefix
|
// We don't want to autocomplete with no prefix
|
||||||
|
|
|
||||||
|
|
@ -117,12 +117,13 @@ var supportedModes = {
|
||||||
MUSHCode: ["mc|mush"],
|
MUSHCode: ["mc|mush"],
|
||||||
MySQL: ["mysql"],
|
MySQL: ["mysql"],
|
||||||
Nix: ["nix"],
|
Nix: ["nix"],
|
||||||
|
Nim: ["nim"],
|
||||||
ObjectiveC: ["m|mm"],
|
ObjectiveC: ["m|mm"],
|
||||||
OCaml: ["ml|mli"],
|
OCaml: ["ml|mli"],
|
||||||
Pascal: ["pas|p"],
|
Pascal: ["pas|p"],
|
||||||
Perl: ["pl|pm"],
|
Perl: ["pl|pm"],
|
||||||
pgSQL: ["pgsql"],
|
pgSQL: ["pgsql"],
|
||||||
PHP: ["php|phtml"],
|
PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp"],
|
||||||
Powershell: ["ps1"],
|
Powershell: ["ps1"],
|
||||||
Praat: ["praat|praatscript|psc|proc"],
|
Praat: ["praat|praatscript|psc|proc"],
|
||||||
Prolog: ["plg|prolog"],
|
Prolog: ["plg|prolog"],
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ var baseStyles = require("../requirejs/text!./static.css");
|
||||||
var config = require("../config");
|
var config = require("../config");
|
||||||
var dom = require("../lib/dom");
|
var dom = require("../lib/dom");
|
||||||
|
|
||||||
|
var SimpleTextLayer = function() {
|
||||||
|
this.config = {};
|
||||||
|
};
|
||||||
|
SimpleTextLayer.prototype = TextLayer.prototype;
|
||||||
|
|
||||||
var highlight = function(el, opts, callback) {
|
var highlight = function(el, opts, callback) {
|
||||||
var m = el.className.match(/lang-(\w+)/);
|
var m = el.className.match(/lang-(\w+)/);
|
||||||
|
|
@ -149,12 +153,8 @@ highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
|
||||||
session.setUseWorker(false);
|
session.setUseWorker(false);
|
||||||
session.setMode(mode);
|
session.setMode(mode);
|
||||||
|
|
||||||
var textLayer = new TextLayer(document.createElement("div"));
|
var textLayer = new SimpleTextLayer();
|
||||||
textLayer.setSession(session);
|
textLayer.setSession(session);
|
||||||
textLayer.config = {
|
|
||||||
characterWidth: 10,
|
|
||||||
lineHeight: 20
|
|
||||||
};
|
|
||||||
|
|
||||||
session.setValue(input);
|
session.setValue(input);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ var themeData = [
|
||||||
["Solarized Dark" ,"solarized_dark" , "dark"],
|
["Solarized Dark" ,"solarized_dark" , "dark"],
|
||||||
["Terminal" ,"terminal" , "dark"],
|
["Terminal" ,"terminal" , "dark"],
|
||||||
["Tomorrow Night" ,"tomorrow_night" , "dark"],
|
["Tomorrow Night" ,"tomorrow_night" , "dark"],
|
||||||
|
["The Night After Tomorrow" ,"the_night_after_tomorrow" , "dark"],
|
||||||
["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
|
["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
|
||||||
["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
|
["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
|
||||||
["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],
|
["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ function objectToRegExp(obj) {
|
||||||
this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this));
|
this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this));
|
||||||
this.selectionFix(ed);
|
this.selectionFix(ed);
|
||||||
this.statusMessage(true);
|
this.statusMessage(true);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.deactivate = function(reset) {
|
this.deactivate = function(reset) {
|
||||||
this.cancelSearch(reset);
|
this.cancelSearch(reset);
|
||||||
|
|
@ -117,7 +117,7 @@ function objectToRegExp(obj) {
|
||||||
}
|
}
|
||||||
ed.onPaste = this.$originalEditorOnPaste;
|
ed.onPaste = this.$originalEditorOnPaste;
|
||||||
this.message('');
|
this.message('');
|
||||||
}
|
};
|
||||||
|
|
||||||
this.selectionFix = function(editor) {
|
this.selectionFix = function(editor) {
|
||||||
// Fix selection bug: When clicked inside the editor
|
// Fix selection bug: When clicked inside the editor
|
||||||
|
|
@ -128,7 +128,7 @@ function objectToRegExp(obj) {
|
||||||
if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
|
if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
|
||||||
editor.clearSelection();
|
editor.clearSelection();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
this.highlight = function(regexp) {
|
this.highlight = function(regexp) {
|
||||||
var sess = this.$editor.session,
|
var sess = this.$editor.session,
|
||||||
|
|
@ -136,7 +136,7 @@ function objectToRegExp(obj) {
|
||||||
new SearchHighlight(null, "ace_isearch-result", "text"));
|
new SearchHighlight(null, "ace_isearch-result", "text"));
|
||||||
hl.setRegexp(regexp);
|
hl.setRegexp(regexp);
|
||||||
sess._emit("changeBackMarker"); // force highlight layer redraw
|
sess._emit("changeBackMarker"); // force highlight layer redraw
|
||||||
}
|
};
|
||||||
|
|
||||||
this.cancelSearch = function(reset) {
|
this.cancelSearch = function(reset) {
|
||||||
var e = this.$editor;
|
var e = this.$editor;
|
||||||
|
|
@ -150,7 +150,7 @@ function objectToRegExp(obj) {
|
||||||
}
|
}
|
||||||
this.highlight(null);
|
this.highlight(null);
|
||||||
return Range.fromPoints(this.$currentPos, this.$currentPos);
|
return Range.fromPoints(this.$currentPos, this.$currentPos);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) {
|
this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) {
|
||||||
if (!this.$editor) return null;
|
if (!this.$editor) return null;
|
||||||
|
|
@ -163,7 +163,7 @@ function objectToRegExp(obj) {
|
||||||
if (options.needle.length === 0) {
|
if (options.needle.length === 0) {
|
||||||
this.statusMessage(true);
|
this.statusMessage(true);
|
||||||
return this.cancelSearch(true);
|
return this.cancelSearch(true);
|
||||||
};
|
}
|
||||||
|
|
||||||
// try to find the next occurence and enable highlighting marker
|
// try to find the next occurence and enable highlighting marker
|
||||||
options.start = this.$currentPos;
|
options.start = this.$currentPos;
|
||||||
|
|
@ -176,13 +176,13 @@ function objectToRegExp(obj) {
|
||||||
this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end));
|
this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end));
|
||||||
if (moveToNext) this.$currentPos = found.end;
|
if (moveToNext) this.$currentPos = found.end;
|
||||||
// highlight after cursor move, so selection works properly
|
// highlight after cursor move, so selection works properly
|
||||||
this.highlight(options.re)
|
this.highlight(options.re);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.statusMessage(found);
|
this.statusMessage(found);
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.addString = function(s) {
|
this.addString = function(s) {
|
||||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||||
|
|
@ -192,7 +192,7 @@ function objectToRegExp(obj) {
|
||||||
reObj.expression += s;
|
reObj.expression += s;
|
||||||
return objectToRegExp(reObj);
|
return objectToRegExp(reObj);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
this.removeChar = function(c) {
|
this.removeChar = function(c) {
|
||||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||||
|
|
@ -202,7 +202,7 @@ function objectToRegExp(obj) {
|
||||||
reObj.expression = reObj.expression.substring(0, reObj.expression.length-1);
|
reObj.expression = reObj.expression.substring(0, reObj.expression.length-1);
|
||||||
return objectToRegExp(reObj);
|
return objectToRegExp(reObj);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
this.next = function(options) {
|
this.next = function(options) {
|
||||||
// try to find the next occurence of whatever we have searched for
|
// try to find the next occurence of whatever we have searched for
|
||||||
|
|
@ -215,29 +215,29 @@ function objectToRegExp(obj) {
|
||||||
return options.useCurrentOrPrevSearch && needle.length === 0 ?
|
return options.useCurrentOrPrevSearch && needle.length === 0 ?
|
||||||
this.$prevNeedle || '' : needle;
|
this.$prevNeedle || '' : needle;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
this.onMouseDown = function(evt) {
|
this.onMouseDown = function(evt) {
|
||||||
// when mouse interaction happens then we quit incremental search
|
// when mouse interaction happens then we quit incremental search
|
||||||
this.deactivate();
|
this.deactivate();
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.onPaste = function(text) {
|
this.onPaste = function(text) {
|
||||||
this.addString(text);
|
this.addString(text);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.convertNeedleToRegExp = function() {
|
this.convertNeedleToRegExp = function() {
|
||||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||||
return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig');
|
return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig');
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
this.convertNeedleToString = function() {
|
this.convertNeedleToString = function() {
|
||||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||||
return isRegExp(needle) ? regExpToObject(needle).expression : needle;
|
return isRegExp(needle) ? regExpToObject(needle).expression : needle;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
this.statusMessage = function(found) {
|
this.statusMessage = function(found) {
|
||||||
var options = this.$options, msg = '';
|
var options = this.$options, msg = '';
|
||||||
|
|
@ -245,7 +245,7 @@ function objectToRegExp(obj) {
|
||||||
msg += 'isearch: ' + options.needle;
|
msg += 'isearch: ' + options.needle;
|
||||||
msg += found ? '' : ' (not found)';
|
msg += found ? '' : ' (not found)';
|
||||||
this.message(msg);
|
this.message(msg);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.message = function(msg) {
|
this.message = function(msg) {
|
||||||
if (this.$editor.showCommandLine) {
|
if (this.$editor.showCommandLine) {
|
||||||
|
|
@ -254,7 +254,7 @@ function objectToRegExp(obj) {
|
||||||
} else {
|
} else {
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
}).call(IncrementalSearch.prototype);
|
}).call(IncrementalSearch.prototype);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -428,7 +428,7 @@ exports.emacsKeys = {
|
||||||
"M-;": "togglecomment",
|
"M-;": "togglecomment",
|
||||||
|
|
||||||
"C-/|C-x u|S-C--|C-z": "undo",
|
"C-/|C-x u|S-C--|C-z": "undo",
|
||||||
"S-C-/|S-C-x u|C--|S-C-z": "redo", //infinite undo?
|
"S-C-/|S-C-x u|C--|S-C-z": "redo", // infinite undo?
|
||||||
// vertical editing
|
// vertical editing
|
||||||
"C-x r": "selectRectangularRegion",
|
"C-x r": "selectRectangularRegion",
|
||||||
"M-x": {command: "focusCommandLine", args: "M-x "}
|
"M-x": {command: "focusCommandLine", args: "M-x "}
|
||||||
|
|
@ -483,7 +483,7 @@ exports.handler.addCommands({
|
||||||
// different. Deactivate the mark when setMark is run with active
|
// different. Deactivate the mark when setMark is run with active
|
||||||
// mark
|
// mark
|
||||||
if (transientMarkModeActive && (mark || !hasNoSelection)) {
|
if (transientMarkModeActive && (mark || !hasNoSelection)) {
|
||||||
if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)})
|
if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)});
|
||||||
else editor.clearSelection();
|
else editor.clearSelection();
|
||||||
if (mark) editor.pushEmacsMark(null);
|
if (mark) editor.pushEmacsMark(null);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,12 @@ MultiHashHandler.prototype = HashHandler.prototype;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.bindKey = function(key, command, asDefault) {
|
this.bindKey = function(key, command, position) {
|
||||||
if (typeof key == "object")
|
if (typeof key == "object") {
|
||||||
|
if (position == undefined)
|
||||||
|
position = key.position;
|
||||||
key = key[this.platform];
|
key = key[this.platform];
|
||||||
|
}
|
||||||
if (!key)
|
if (!key)
|
||||||
return;
|
return;
|
||||||
if (typeof command == "function")
|
if (typeof command == "function")
|
||||||
|
|
@ -110,11 +113,15 @@ MultiHashHandler.prototype = HashHandler.prototype;
|
||||||
}
|
}
|
||||||
var binding = this.parseKeys(keyPart);
|
var binding = this.parseKeys(keyPart);
|
||||||
var id = KEY_MODS[binding.hashId] + binding.key;
|
var id = KEY_MODS[binding.hashId] + binding.key;
|
||||||
this._addCommandToBinding(chain + id, command, asDefault);
|
this._addCommandToBinding(chain + id, command, position);
|
||||||
}, this);
|
}, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
this._addCommandToBinding = function(keyId, command, asDefault) {
|
function getPosition(command) {
|
||||||
|
return typeof command == "object" && command.bindKey
|
||||||
|
&& command.bindKey.position || 0;
|
||||||
|
}
|
||||||
|
this._addCommandToBinding = function(keyId, command, position) {
|
||||||
var ckb = this.commandKeyBinding, i;
|
var ckb = this.commandKeyBinding, i;
|
||||||
if (!command) {
|
if (!command) {
|
||||||
delete ckb[keyId];
|
delete ckb[keyId];
|
||||||
|
|
@ -127,10 +134,20 @@ MultiHashHandler.prototype = HashHandler.prototype;
|
||||||
ckb[keyId].splice(i, 1);
|
ckb[keyId].splice(i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asDefault || command.isDefault)
|
if (typeof position != "number") {
|
||||||
ckb[keyId].unshift(command);
|
if (position || command.isDefault)
|
||||||
else
|
position = -100;
|
||||||
ckb[keyId].push(command);
|
else
|
||||||
|
position = getPosition(command);
|
||||||
|
}
|
||||||
|
var commands = ckb[keyId];
|
||||||
|
for (i = 0; i < commands.length; i++) {
|
||||||
|
var other = commands[i];
|
||||||
|
var otherPos = getPosition(other);
|
||||||
|
if (otherPos > position)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
commands.splice(i, 0, command);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -219,11 +236,19 @@ MultiHashHandler.prototype = HashHandler.prototype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.$keyChain && keyCode > 0)
|
if (data.$keyChain) {
|
||||||
data.$keyChain = "";
|
if ((!hashId || hashId == 4) && keyString.length == 1)
|
||||||
|
data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
|
||||||
|
else if (hashId == -1 || keyCode > 0)
|
||||||
|
data.$keyChain = ""; // reset keyChain
|
||||||
|
}
|
||||||
return {command: command};
|
return {command: command};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.getStatusText = function(editor, data) {
|
||||||
|
return data.$keyChain || "";
|
||||||
|
};
|
||||||
|
|
||||||
}).call(HashHandler.prototype);
|
}).call(HashHandler.prototype);
|
||||||
|
|
||||||
exports.HashHandler = HashHandler;
|
exports.HashHandler = HashHandler;
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ var TextInput = function(parentNode, host) {
|
||||||
var data = handleClipboardData(e);
|
var data = handleClipboardData(e);
|
||||||
if (typeof data == "string") {
|
if (typeof data == "string") {
|
||||||
if (data)
|
if (data)
|
||||||
host.onPaste(data);
|
host.onPaste(data, e);
|
||||||
if (useragent.isIE)
|
if (useragent.isIE)
|
||||||
setTimeout(resetSelection);
|
setTimeout(resetSelection);
|
||||||
event.preventDefault(e);
|
event.preventDefault(e);
|
||||||
|
|
|
||||||
|
|
@ -257,6 +257,7 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
if (!this.ace.inVirtualSelectionMode)
|
if (!this.ace.inVirtualSelectionMode)
|
||||||
this.ace.exitMultiSelectMode();
|
this.ace.exitMultiSelectMode();
|
||||||
|
this.ace.session.unfold({row: line, column: ch});
|
||||||
this.ace.selection.moveTo(line, ch);
|
this.ace.selection.moveTo(line, ch);
|
||||||
};
|
};
|
||||||
this.getCursor = function(p) {
|
this.getCursor = function(p) {
|
||||||
|
|
@ -729,10 +730,14 @@ CodeMirror.defineExtension = function(name, fn) {
|
||||||
CodeMirror.prototype[name] = fn;
|
CodeMirror.prototype[name] = fn;
|
||||||
};
|
};
|
||||||
dom.importCssString(".normal-mode .ace_cursor{\
|
dom.importCssString(".normal-mode .ace_cursor{\
|
||||||
border: 0!important;\
|
border: 1px solid red;\
|
||||||
background-color: red;\
|
background-color: red;\
|
||||||
opacity: 0.5;\
|
opacity: 0.5;\
|
||||||
}.ace_dialog {\
|
}\
|
||||||
|
.normal-mode .ace_hidden-cursors .ace_cursor{\
|
||||||
|
background-color: transparent;\
|
||||||
|
}\
|
||||||
|
.ace_dialog {\
|
||||||
position: absolute;\
|
position: absolute;\
|
||||||
left: 0; right: 0;\
|
left: 0; right: 0;\
|
||||||
background: white;\
|
background: white;\
|
||||||
|
|
@ -758,23 +763,6 @@ dom.importCssString(".normal-mode .ace_cursor{\
|
||||||
font-family: monospace;\
|
font-family: monospace;\
|
||||||
}", "vimMode");
|
}", "vimMode");
|
||||||
(function() {
|
(function() {
|
||||||
function dialogDiv(cm, template, bottom) {
|
|
||||||
var wrap = cm.ace.container;
|
|
||||||
var dialog;
|
|
||||||
dialog = wrap.appendChild(document.createElement("div"));
|
|
||||||
if (bottom)
|
|
||||||
dialog.className = "ace_dialog ace_dialog-bottom";
|
|
||||||
else
|
|
||||||
dialog.className = "ace_dialog ace_dialog-top";
|
|
||||||
|
|
||||||
if (typeof template == "string") {
|
|
||||||
dialog.innerHTML = template;
|
|
||||||
} else { // Assuming it's a detached DOM element.
|
|
||||||
dialog.appendChild(template);
|
|
||||||
}
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeNotification(cm, newVal) {
|
function closeNotification(cm, newVal) {
|
||||||
if (cm.state.currentNotificationClose)
|
if (cm.state.currentNotificationClose)
|
||||||
cm.state.currentNotificationClose();
|
cm.state.currentNotificationClose();
|
||||||
|
|
@ -2196,6 +2184,8 @@ dom.importCssString(".normal-mode .ace_cursor{\
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (motionArgs.toJumplist) {
|
if (motionArgs.toJumplist) {
|
||||||
|
if (!operator)
|
||||||
|
cm.ace.curOp.command.scrollIntoView = "center-animate"; // ace patch
|
||||||
var jumpList = vimGlobalState.jumpList;
|
var jumpList = vimGlobalState.jumpList;
|
||||||
// if the current motion is # or *, use cachedCursor
|
// if the current motion is # or *, use cachedCursor
|
||||||
var cachedCursor = jumpList.cachedCursor;
|
var cachedCursor = jumpList.cachedCursor;
|
||||||
|
|
@ -2882,6 +2872,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
|
||||||
var markPos = mark ? mark.find() : undefined;
|
var markPos = mark ? mark.find() : undefined;
|
||||||
markPos = markPos ? markPos : cm.getCursor();
|
markPos = markPos ? markPos : cm.getCursor();
|
||||||
cm.setCursor(markPos);
|
cm.setCursor(markPos);
|
||||||
|
cm.ace.curOp.command.scrollIntoView = "center-animate"; // ace patch
|
||||||
},
|
},
|
||||||
scroll: function(cm, actionArgs, vim) {
|
scroll: function(cm, actionArgs, vim) {
|
||||||
if (vim.visualMode) {
|
if (vim.visualMode) {
|
||||||
|
|
@ -5932,7 +5923,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
return isHandled;
|
return isHandled;
|
||||||
};
|
}
|
||||||
exports.CodeMirror = CodeMirror;
|
exports.CodeMirror = CodeMirror;
|
||||||
var getVim = Vim.maybeInitVimState_;
|
var getVim = Vim.maybeInitVimState_;
|
||||||
exports.handler = {
|
exports.handler = {
|
||||||
|
|
@ -5946,9 +5937,9 @@ dom.importCssString(".normal-mode .ace_cursor{\
|
||||||
if (!vim.insertMode) {
|
if (!vim.insertMode) {
|
||||||
var isbackwards = !sel.cursor
|
var isbackwards = !sel.cursor
|
||||||
? session.selection.isBackwards() || session.selection.isEmpty()
|
? session.selection.isBackwards() || session.selection.isEmpty()
|
||||||
: Range.comparePoints(sel.cursor, sel.start) <= 0
|
: Range.comparePoints(sel.cursor, sel.start) <= 0;
|
||||||
if (!isbackwards && left > w)
|
if (!isbackwards && left > w)
|
||||||
left -= w
|
left -= w;
|
||||||
}
|
}
|
||||||
if (!vim.insertMode && vim.status) {
|
if (!vim.insertMode && vim.status) {
|
||||||
h = h / 2;
|
h = h / 2;
|
||||||
|
|
@ -6112,13 +6103,13 @@ dom.importCssString(".normal-mode .ace_cursor{\
|
||||||
};
|
};
|
||||||
var renderVirtualNumbers = {
|
var renderVirtualNumbers = {
|
||||||
getText: function(session, row) {
|
getText: function(session, row) {
|
||||||
return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9? "\xb7" : "" ))) + ""
|
return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9? "\xb7" : "" ))) + "";
|
||||||
},
|
},
|
||||||
getWidth: function(session, lastLineNumber, config) {
|
getWidth: function(session, lastLineNumber, config) {
|
||||||
return session.getLength().toString().length * config.characterWidth;
|
return session.getLength().toString().length * config.characterWidth;
|
||||||
},
|
},
|
||||||
update: function(e, editor) {
|
update: function(e, editor) {
|
||||||
editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER)
|
editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER);
|
||||||
},
|
},
|
||||||
attach: function(editor) {
|
attach: function(editor) {
|
||||||
editor.renderer.$gutterLayer.$renderer = this;
|
editor.renderer.$gutterLayer.$renderer = this;
|
||||||
|
|
@ -6163,7 +6154,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
|
||||||
if (cm.ace.inVirtualSelectionMode)
|
if (cm.ace.inVirtualSelectionMode)
|
||||||
cm.ace.on("beforeEndOperation", delayedExecAceCommand);
|
cm.ace.on("beforeEndOperation", delayedExecAceCommand);
|
||||||
else
|
else
|
||||||
delayedExecAceCommand(null, cm.ace)
|
delayedExecAceCommand(null, cm.ace);
|
||||||
};
|
};
|
||||||
function delayedExecAceCommand(op, ace) {
|
function delayedExecAceCommand(op, ace) {
|
||||||
ace.off("beforeEndOperation", delayedExecAceCommand);
|
ace.off("beforeEndOperation", delayedExecAceCommand);
|
||||||
|
|
@ -6182,5 +6173,5 @@ dom.importCssString(".normal-mode .ace_cursor{\
|
||||||
exports.handler.actions = actions;
|
exports.handler.actions = actions;
|
||||||
exports.Vim = Vim;
|
exports.Vim = Vim;
|
||||||
|
|
||||||
Vim.map("Y", "yy");
|
Vim.map("Y", "yy", "normal");
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -120,9 +120,9 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
|
||||||
this.setPolling = function(val) {
|
this.setPolling = function(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
this.$pollSizeChanges();
|
this.$pollSizeChanges();
|
||||||
} else {
|
} else if (this.$pollSizeChangesTimer) {
|
||||||
if (this.$pollSizeChangesTimer)
|
clearInterval(this.$pollSizeChangesTimer);
|
||||||
this.$pollSizeChangesTimer;
|
this.$pollSizeChangesTimer = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ var Marker = function(parentEl) {
|
||||||
else
|
else
|
||||||
this.drawMultiLineMarker(html, range, marker.clazz, config);
|
this.drawMultiLineMarker(html, range, marker.clazz, config);
|
||||||
} else {
|
} else {
|
||||||
this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config);
|
this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.element.innerHTML = html.join("");
|
this.element.innerHTML = html.join("");
|
||||||
|
|
@ -100,29 +100,30 @@ var Marker = function(parentEl) {
|
||||||
return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
|
return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getBorderClass(tl, tr, br, bl) {
|
||||||
|
return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0);
|
||||||
|
}
|
||||||
// Draws a marker, which spans a range of text on multiple lines
|
// Draws a marker, which spans a range of text on multiple lines
|
||||||
this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
|
this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
|
||||||
// selection start
|
|
||||||
var row = range.start.row;
|
|
||||||
var session = this.session;
|
var session = this.session;
|
||||||
|
var start = range.start.row;
|
||||||
var lineRange = new Range(
|
var end = range.end.row;
|
||||||
row, range.start.column,
|
var row = start;
|
||||||
row, session.getScreenLastRowColumn(row)
|
var prev = 0;
|
||||||
);
|
var curr = 0;
|
||||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, extraStyle);
|
var next = session.getScreenLastRowColumn(row);
|
||||||
|
var lineRange = new Range(row, range.start.column, row, curr);
|
||||||
// selection end
|
for (; row <= end; row++) {
|
||||||
row = range.end.row;
|
lineRange.start.row = lineRange.end.row = row;
|
||||||
lineRange = new Range(row, session.getRowWrapIndent(row), row, range.end.column);
|
lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row);
|
||||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, extraStyle);
|
lineRange.end.column = next;
|
||||||
|
prev = curr;
|
||||||
for (row = range.start.row + 1; row < range.end.row; row++) {
|
curr = next;
|
||||||
lineRange.start.row = row;
|
next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column;
|
||||||
lineRange.start.column = session.getRowWrapIndent(row);
|
this.drawSingleLineMarker(stringBuilder, lineRange,
|
||||||
lineRange.end.row = row;
|
clazz + (row == start ? " ace_start" : "") + " ace_br"
|
||||||
lineRange.end.column = session.getScreenLastRowColumn(row);
|
+ getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end),
|
||||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, extraStyle);
|
layerConfig, row == end ? 0 : 1, extraStyle);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -136,7 +137,7 @@ var Marker = function(parentEl) {
|
||||||
extraStyle = extraStyle || "";
|
extraStyle = extraStyle || "";
|
||||||
|
|
||||||
stringBuilder.push(
|
stringBuilder.push(
|
||||||
"<div class='", clazz, " ace_start' style='",
|
"<div class='", clazz, " ace_br1 ace_start' style='",
|
||||||
"height:", height, "px;",
|
"height:", height, "px;",
|
||||||
"right:0;",
|
"right:0;",
|
||||||
"top:", top, "px;",
|
"top:", top, "px;",
|
||||||
|
|
@ -148,7 +149,7 @@ var Marker = function(parentEl) {
|
||||||
var width = range.end.column * config.characterWidth;
|
var width = range.end.column * config.characterWidth;
|
||||||
|
|
||||||
stringBuilder.push(
|
stringBuilder.push(
|
||||||
"<div class='", clazz, "' style='",
|
"<div class='", clazz, " ace_br12' style='",
|
||||||
"height:", height, "px;",
|
"height:", height, "px;",
|
||||||
"width:", width, "px;",
|
"width:", width, "px;",
|
||||||
"top:", top, "px;",
|
"top:", top, "px;",
|
||||||
|
|
@ -161,8 +162,10 @@ var Marker = function(parentEl) {
|
||||||
return;
|
return;
|
||||||
top = this.$getTop(range.start.row + 1, config);
|
top = this.$getTop(range.start.row + 1, config);
|
||||||
|
|
||||||
|
var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8);
|
||||||
|
|
||||||
stringBuilder.push(
|
stringBuilder.push(
|
||||||
"<div class='", clazz, "' style='",
|
"<div class='", clazz, (radiusClass ? " ace_br" + radiusClass : ""), "' style='",
|
||||||
"height:", height, "px;",
|
"height:", height, "px;",
|
||||||
"right:0;",
|
"right:0;",
|
||||||
"top:", top, "px;",
|
"top:", top, "px;",
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ var Text = function(parentEl) {
|
||||||
this.EOL_CHAR_LF = "\xAC";
|
this.EOL_CHAR_LF = "\xAC";
|
||||||
this.EOL_CHAR_CRLF = "\xa4";
|
this.EOL_CHAR_CRLF = "\xa4";
|
||||||
this.EOL_CHAR = this.EOL_CHAR_LF;
|
this.EOL_CHAR = this.EOL_CHAR_LF;
|
||||||
this.TAB_CHAR = "\u2192"; //"\u21E5";
|
this.TAB_CHAR = "\u2014"; //"\u21E5";
|
||||||
this.SPACE_CHAR = "\xB7";
|
this.SPACE_CHAR = "\xB7";
|
||||||
this.$padding = 0;
|
this.$padding = 0;
|
||||||
|
|
||||||
|
|
@ -128,8 +128,7 @@ var Text = function(parentEl) {
|
||||||
for (var i = 1; i < tabSize + 1; i++) {
|
for (var i = 1; i < tabSize + 1; i++) {
|
||||||
if (this.showInvisibles) {
|
if (this.showInvisibles) {
|
||||||
tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
|
tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
|
||||||
+ this.TAB_CHAR
|
+ lang.stringRepeat(this.TAB_CHAR, i)
|
||||||
+ lang.stringRepeat(" ", i - 1)
|
|
||||||
+ "</span>");
|
+ "</span>");
|
||||||
} else {
|
} else {
|
||||||
tabStr.push(lang.stringRepeat(" ", i));
|
tabStr.push(lang.stringRepeat(" ", i));
|
||||||
|
|
@ -145,7 +144,7 @@ var Text = function(parentEl) {
|
||||||
spaceClass = " ace_invisible_space";
|
spaceClass = " ace_invisible_space";
|
||||||
tabClass = " ace_invisible_tab";
|
tabClass = " ace_invisible_tab";
|
||||||
var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
|
var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
|
||||||
var tabContent = this.TAB_CHAR + lang.stringRepeat(" ", this.tabSize - 1);
|
var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
|
||||||
} else{
|
} else{
|
||||||
var spaceContent = lang.stringRepeat(" ", this.tabSize);
|
var spaceContent = lang.stringRepeat(" ", this.tabSize);
|
||||||
var tabContent = spaceContent;
|
var tabContent = spaceContent;
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ module.exports = {
|
||||||
var EOL = "<span class='ace_invisible ace_invisible_eol'>" + textLayer.EOL_CHAR + "</span>";
|
var EOL = "<span class='ace_invisible ace_invisible_eol'>" + textLayer.EOL_CHAR + "</span>";
|
||||||
var SPACE = function(i) {return Array(i+1).join(" ")}
|
var SPACE = function(i) {return Array(i+1).join(" ")}
|
||||||
var DOT = function(i) {return Array(i+1).join(textLayer.SPACE_CHAR)}
|
var DOT = function(i) {return Array(i+1).join(textLayer.SPACE_CHAR)}
|
||||||
var TAB = function(i) {return textLayer.TAB_CHAR + SPACE(i-1)}
|
var TAB = function(i) {return Array(i+1).join(textLayer.TAB_CHAR)}
|
||||||
function testRender(results) {
|
function testRender(results) {
|
||||||
for (var i = results.length; i--; ) {
|
for (var i = results.length; i--; ) {
|
||||||
var stringBuilder = [];
|
var stringBuilder = [];
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,11 @@ exports.toggleCssClass = function(el, name) {
|
||||||
return add;
|
return add;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (typeof document == "undefined") {
|
||||||
|
exports.importCssString = function() {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add or remove a CSS class from the list of classes on the given node
|
* Add or remove a CSS class from the list of classes on the given node
|
||||||
* depending on the value of <tt>include</tt>
|
* depending on the value of <tt>include</tt>
|
||||||
|
|
@ -173,9 +178,6 @@ exports.getInnerHeight = function(element) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (typeof document == "undefined")
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (window.pageYOffset !== undefined) {
|
if (window.pageYOffset !== undefined) {
|
||||||
exports.getPageScrollTop = function() {
|
exports.getPageScrollTop = function() {
|
||||||
return window.pageYOffset;
|
return window.pageYOffset;
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
|
||||||
if (pressedKeys[keyCode] == 1)
|
if (pressedKeys[keyCode] == 1)
|
||||||
ts = e.timeStamp;
|
ts = e.timeStamp;
|
||||||
} else if (keyCode === 18 && hashId === 3 && location === 2) {
|
} else if (keyCode === 18 && hashId === 3 && location === 2) {
|
||||||
var dt = e.timestamp - ts;
|
var dt = e.timeStamp - ts;
|
||||||
if (dt < 50)
|
if (dt < 50)
|
||||||
pressedKeys.altGr = true;
|
pressedKeys.altGr = true;
|
||||||
}
|
}
|
||||||
|
|
@ -326,13 +326,14 @@ exports.addCommandKeyListener = function(el, callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!pressedKeys) {
|
if (!pressedKeys) {
|
||||||
pressedKeys = Object.create(null);
|
resetPressedKeys();
|
||||||
addListener(window, "focus", function(e) {
|
addListener(window, "focus", resetPressedKeys);
|
||||||
pressedKeys = Object.create(null);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
function resetPressedKeys(e) {
|
||||||
|
pressedKeys = Object.create(null);
|
||||||
|
}
|
||||||
|
|
||||||
if (window.postMessage && !useragent.isOldIE) {
|
if (window.postMessage && !useragent.isOldIE) {
|
||||||
var postMessageId = 1;
|
var postMessageId = 1;
|
||||||
|
|
|
||||||
|
|
@ -56,34 +56,34 @@
|
||||||
],[
|
],[
|
||||||
"start",
|
"start",
|
||||||
["text"," "],
|
["text"," "],
|
||||||
["comment","| "],
|
["comment","|"],
|
||||||
["string","start "],
|
["string"," start "],
|
||||||
["comment","| "],
|
["comment","|"],
|
||||||
["string","eat "],
|
["string"," eat "],
|
||||||
["comment","| "],
|
["comment","|"],
|
||||||
["string","left "],
|
["string"," left "],
|
||||||
["comment","|"]
|
["comment","|"]
|
||||||
],[
|
],[
|
||||||
"start",
|
"start",
|
||||||
["text"," "],
|
["text"," "],
|
||||||
["comment","| "],
|
["comment","|"],
|
||||||
["string"," 12 "],
|
["string"," 12 "],
|
||||||
["comment","| "],
|
["comment","|"],
|
||||||
["string"," 5 "],
|
["string"," 5 "],
|
||||||
["comment","| "],
|
["comment","|"],
|
||||||
["string"," 7 "],
|
["string"," 7 "],
|
||||||
["comment","|"]
|
["comment","|"]
|
||||||
],[
|
],[
|
||||||
"start",
|
"start",
|
||||||
["text"," "],
|
["text"," "],
|
||||||
["comment","| "],
|
["comment","|"],
|
||||||
["string"," 20 "],
|
["string"," 20 "],
|
||||||
["comment","| "],
|
["comment","|"],
|
||||||
["string"," 5 "],
|
["string"," 5 "],
|
||||||
["comment","| "],
|
["comment","|"],
|
||||||
["string"," 15 "],
|
["string"," 15 "],
|
||||||
["comment","| "],
|
["comment","|"],
|
||||||
["string"," "]
|
["string"," "]
|
||||||
],[
|
],[
|
||||||
"start"
|
"start"
|
||||||
],[
|
],[
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,9 @@
|
||||||
],[
|
],[
|
||||||
"start",
|
"start",
|
||||||
["keyword.source.rust","fn"],
|
["keyword.source.rust","fn"],
|
||||||
["meta.function.source.rust"," "],
|
["text"," "],
|
||||||
["entity.name.function.source.rust","main"],
|
["entity.name.function.source.rust","main"],
|
||||||
["meta.function.source.rust","("],
|
["text","() {"]
|
||||||
["text",") {"]
|
|
||||||
],[
|
],[
|
||||||
"start",
|
"start",
|
||||||
["text"," "],
|
["text"," "],
|
||||||
|
|
@ -88,10 +87,14 @@
|
||||||
],[
|
],[
|
||||||
"start",
|
"start",
|
||||||
["keyword.source.rust","fn"],
|
["keyword.source.rust","fn"],
|
||||||
["meta.function.source.rust"," "],
|
["text"," "],
|
||||||
["entity.name.function.source.rust","map<T, U>"],
|
["entity.name.function.source.rust","map"],
|
||||||
["meta.function.source.rust","("],
|
["keyword.operator","<"],
|
||||||
["text","vector: &[T]"],
|
["text","T"],
|
||||||
|
["keyword.operator",","],
|
||||||
|
["text"," U"],
|
||||||
|
["keyword.operator",">"],
|
||||||
|
["text","(vector: &[T]"],
|
||||||
["keyword.operator",","],
|
["keyword.operator",","],
|
||||||
["text"," function: &fn(v: &T) "],
|
["text"," function: &fn(v: &T) "],
|
||||||
["keyword.operator","->"],
|
["keyword.operator","->"],
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,16 @@ module.exports = {
|
||||||
exec("selectleft", 1);
|
exec("selectleft", 1);
|
||||||
exec("insertstring", 1, '"');
|
exec("insertstring", 1, '"');
|
||||||
assert.equal(editor.getValue(), '("foo")');
|
assert.equal(editor.getValue(), '("foo")');
|
||||||
|
|
||||||
|
editor.setValue("", 1);
|
||||||
|
exec("selectleft", 1);
|
||||||
|
exec("insertstring", 1, '"');
|
||||||
|
assert.equal(editor.getValue(), '""');
|
||||||
|
exec("insertstring", 1, '\\');
|
||||||
|
exec("insertstring", 1, 'n');
|
||||||
|
exec("insertstring", 1, '"');
|
||||||
|
assert.equal(editor.getValue(), '"\\n"');
|
||||||
|
|
||||||
},
|
},
|
||||||
"test: xml": function() {
|
"test: xml": function() {
|
||||||
editor = new Editor(new MockRenderer());
|
editor = new Editor(new MockRenderer());
|
||||||
|
|
|
||||||
|
|
@ -269,8 +269,8 @@ var CstyleBehaviour = function() {
|
||||||
if (leftChar == "\\" && token && /escape/.test(token.type))
|
if (leftChar == "\\" && token && /escape/.test(token.type))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var stringBefore = token && /string/.test(token.type);
|
var stringBefore = token && /string|escape/.test(token.type);
|
||||||
var stringAfter = !rightToken || /string/.test(rightToken.type);
|
var stringAfter = !rightToken || /string|escape/.test(rightToken.type);
|
||||||
|
|
||||||
var pair;
|
var pair;
|
||||||
if (rightChar == quote) {
|
if (rightChar == quote) {
|
||||||
|
|
|
||||||
|
|
@ -36,18 +36,18 @@ var stringEscape = "\\\\(x[0-9A-Fa-f]{2}|[0-7]{3}|[\\\\abfnrtv'\"]|U[0-9A-Fa-f]
|
||||||
|
|
||||||
var GherkinHighlightRules = function() {
|
var GherkinHighlightRules = function() {
|
||||||
|
|
||||||
// need to include constant ints
|
// need to include constant ints
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
start : [{
|
start : [{
|
||||||
token: 'constant.numeric',
|
token: 'constant.numeric',
|
||||||
regex: "(?:(?:[1-9]\\d*)|(?:0))"
|
regex: "(?:(?:[1-9]\\d*)|(?:0))"
|
||||||
}, {
|
}, {
|
||||||
token : "comment",
|
token : "comment",
|
||||||
regex : "#.*$"
|
regex : "#.*$"
|
||||||
}, {
|
}, {
|
||||||
token : "keyword",
|
token : "keyword",
|
||||||
regex : "Feature:|Background:|Scenario:|Scenario\ Outline:|Examples:|Given|When|Then|And|But|\\*",
|
regex : "Feature:|Background:|Scenario:|Scenario\ Outline:|Examples:|Given|When|Then|And|But|\\*",
|
||||||
}, {
|
}, {
|
||||||
token : "string", // multi line """ string start
|
token : "string", // multi line """ string start
|
||||||
regex : '"{3}',
|
regex : '"{3}',
|
||||||
next : "qqstring3"
|
next : "qqstring3"
|
||||||
|
|
@ -56,22 +56,22 @@ var GherkinHighlightRules = function() {
|
||||||
regex : '"',
|
regex : '"',
|
||||||
next : "qqstring"
|
next : "qqstring"
|
||||||
}, {
|
}, {
|
||||||
token : "comment",
|
token : "comment",
|
||||||
regex : "@[A-Za-z0-9]+",
|
regex : "@[A-Za-z0-9]+",
|
||||||
next : "start"
|
next : "start"
|
||||||
}, {
|
}, {
|
||||||
token : "comment",
|
token : "comment",
|
||||||
regex : "<.+>"
|
regex : "<.+>"
|
||||||
}, {
|
}, {
|
||||||
token : "comment",
|
token : "comment",
|
||||||
regex : "\\| ",
|
regex : "\\|(?=.)",
|
||||||
next : "table-item"
|
next : "table-item"
|
||||||
}, {
|
}, {
|
||||||
token : "comment",
|
token : "comment",
|
||||||
regex : "\\|$",
|
regex : "\\|$",
|
||||||
next : "start"
|
next : "start"
|
||||||
}],
|
}],
|
||||||
"qqstring3" : [ {
|
"qqstring3" : [ {
|
||||||
token : "constant.language.escape",
|
token : "constant.language.escape",
|
||||||
regex : stringEscape
|
regex : stringEscape
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -81,7 +81,7 @@ var GherkinHighlightRules = function() {
|
||||||
}, {
|
}, {
|
||||||
defaultToken : "string"
|
defaultToken : "string"
|
||||||
}],
|
}],
|
||||||
"qqstring" : [{
|
"qqstring" : [{
|
||||||
token : "constant.language.escape",
|
token : "constant.language.escape",
|
||||||
regex : stringEscape
|
regex : stringEscape
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -96,15 +96,19 @@ var GherkinHighlightRules = function() {
|
||||||
defaultToken: "string"
|
defaultToken: "string"
|
||||||
}],
|
}],
|
||||||
"table-item" : [{
|
"table-item" : [{
|
||||||
|
token : "comment",
|
||||||
|
regex : /$/,
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
token : "comment",
|
||||||
|
regex : /\|/
|
||||||
|
}, {
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : "[A-Za-z0-9 ]*",
|
regex : /\\./
|
||||||
next : "start"
|
}, {
|
||||||
}],
|
defaultToken : "string"
|
||||||
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//new TextHighlightRules().getRules();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oop.inherits(GherkinHighlightRules, TextHighlightRules);
|
oop.inherits(GherkinHighlightRules, TextHighlightRules);
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,13 @@ var Mode = function() {
|
||||||
this.HighlightRules = HandlebarsHighlightRules;
|
this.HighlightRules = HandlebarsHighlightRules;
|
||||||
this.$behaviour = new HtmlBehaviour();
|
this.$behaviour = new HtmlBehaviour();
|
||||||
|
|
||||||
|
|
||||||
this.foldingRules = new HtmlFoldMode();
|
this.foldingRules = new HtmlFoldMode();
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(Mode, HtmlMode);
|
oop.inherits(Mode, HtmlMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
this.blockComment = {start: "{!--", end: "--}"};
|
this.blockComment = {start: "{{!--", end: "--}}"};
|
||||||
this.$id = "ace/mode/handlebars";
|
this.$id = "ace/mode/handlebars";
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ var HtmlHighlightRules = function() {
|
||||||
include : "tag_whitespace"
|
include : "tag_whitespace"
|
||||||
}, {
|
}, {
|
||||||
token : "entity.other.attribute-name.xml",
|
token : "entity.other.attribute-name.xml",
|
||||||
regex : "[-_a-zA-Z0-9:]+"
|
regex : "[-_a-zA-Z0-9:.]+"
|
||||||
}, {
|
}, {
|
||||||
token : "keyword.operator.attribute-equals.xml",
|
token : "keyword.operator.attribute-equals.xml",
|
||||||
regex : "=",
|
regex : "=",
|
||||||
|
|
@ -89,7 +89,7 @@ var HtmlHighlightRules = function() {
|
||||||
return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
|
return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
|
||||||
"meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
|
"meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
|
||||||
},
|
},
|
||||||
regex : "(</?)([-_a-zA-Z0-9:]+)",
|
regex : "(</?)([-_a-zA-Z0-9:.]+)",
|
||||||
next: "tag_stuff"
|
next: "tag_stuff"
|
||||||
}],
|
}],
|
||||||
tag_stuff: [
|
tag_stuff: [
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,7 @@ var LessHighlightRules = function() {
|
||||||
regex: "\\.[a-z0-9-_]+"
|
regex: "\\.[a-z0-9-_]+"
|
||||||
}, {
|
}, {
|
||||||
token: "variable.language",
|
token: "variable.language",
|
||||||
regex: ":[a-z0-9-_]+"
|
regex: ":[a-z_][a-z0-9-_]*"
|
||||||
}, {
|
}, {
|
||||||
token: "constant",
|
token: "constant",
|
||||||
regex: "[a-z0-9-_]+"
|
regex: "[a-z0-9-_]+"
|
||||||
|
|
|
||||||
113
lib/ace/mode/nim.js
Normal file
113
lib/ace/mode/nim.js
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Distributed under the BSD license:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010, Ajax.org B.V.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of Ajax.org B.V. nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var oop = require("../lib/oop");
|
||||||
|
var TextMode = require("./text").Mode;
|
||||||
|
var NimHighlightRules = require("./nim_highlight_rules").NimHighlightRules;
|
||||||
|
var NimFoldMode = require("./folding/pythonic").FoldMode;
|
||||||
|
var Range = require("../range").Range;
|
||||||
|
|
||||||
|
var Mode = function() {
|
||||||
|
this.HighlightRules = NimHighlightRules;
|
||||||
|
this.foldingRules = new NimFoldMode("\\:|=");
|
||||||
|
};
|
||||||
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = "#";
|
||||||
|
|
||||||
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
|
var tokenizedLine = this.getTokenizer().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 outdents = {
|
||||||
|
"discard": 1,
|
||||||
|
"return": 1,
|
||||||
|
"raise": 1,
|
||||||
|
"break": 1,
|
||||||
|
"continue": 1
|
||||||
|
};
|
||||||
|
|
||||||
|
this.checkOutdent = function(state, line, input) {
|
||||||
|
if (input !== "\r\n" && input !== "\r" && input !== "\n")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var tokens = this.getTokenizer().getLineTokens(line.trim(), state).tokens;
|
||||||
|
|
||||||
|
if (!tokens)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// ignore trailing comments
|
||||||
|
do {
|
||||||
|
var last = tokens.pop();
|
||||||
|
} while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/))));
|
||||||
|
|
||||||
|
if (!last)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (last.type == "keyword" && outdents[last.value]);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.autoOutdent = function(state, doc, row) {
|
||||||
|
// outdenting in python is slightly different because it always applies
|
||||||
|
// to the next line and only of a new line is inserted
|
||||||
|
|
||||||
|
row += 1;
|
||||||
|
var indent = this.$getIndent(doc.getLine(row));
|
||||||
|
var tab = doc.getTabString();
|
||||||
|
if (indent.slice(-tab.length) == tab)
|
||||||
|
doc.remove(new Range(row, indent.length-tab.length, row, indent.length));
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$id = "ace/mode/nim";
|
||||||
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
exports.Mode = Mode;
|
||||||
|
});
|
||||||
238
lib/ace/mode/nim_highlight_rules.js
Normal file
238
lib/ace/mode/nim_highlight_rules.js
Normal file
|
|
@ -0,0 +1,238 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Distributed under the BSD license:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010, Ajax.org B.V.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of Ajax.org B.V. nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
/*
|
||||||
|
* TODO: nim delimiters
|
||||||
|
*/
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var oop = require("../lib/oop");
|
||||||
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
var num_suffix = "(\'[Ff]32|\'[Ff]64|\'[IiUu]8|\'[IiUu]16|\'[IiUu]32|\'[IiUu]64)";
|
||||||
|
|
||||||
|
var NimHighlightRules = function() {
|
||||||
|
|
||||||
|
var keywords = (
|
||||||
|
"addr|and|as|asm|atomic|bind|block|break|case|cast|const|continue|" +
|
||||||
|
"converter|defer|discard|distinct|div|do|elif|else|end|enum|except|" +
|
||||||
|
"export|finally|for|from|func|generic|if|import|in|include|interface|" +
|
||||||
|
"is|isnot|iterator|let|macro|method|mixin|mod|nil|not|notin|object|of|" +
|
||||||
|
"or|out|proc|ptr|raise|ref|return|shl|shr|static|template|try|tuple|" +
|
||||||
|
"type|using|var|when|while|with|without|xor|yield"
|
||||||
|
);
|
||||||
|
|
||||||
|
var builtinConstants = (
|
||||||
|
"true|false|nil|NotImplemented|Ellipsis"
|
||||||
|
);
|
||||||
|
|
||||||
|
var storageType = (
|
||||||
|
"string|seq|array|expr|stmt|typed|untyped|any|auto|bool|cdouble|cfloat|"+
|
||||||
|
"cchar|clongdouble|clong|clonglong|cshort|csize|cstring|cstringarray|"+
|
||||||
|
"culong|culonglong|cushort|guarded|natural|openarray|ordinal|pointer|"+
|
||||||
|
"range|set|shared|static|typedesc|varargs|void"
|
||||||
|
);
|
||||||
|
|
||||||
|
var builtinFunctions = (
|
||||||
|
"defined|declared|declaredInScope|echo|$"
|
||||||
|
);
|
||||||
|
|
||||||
|
//var futureReserved = "";
|
||||||
|
var keywordMapper = this.createKeywordMapper({
|
||||||
|
"invalid.deprecated": "debugger",
|
||||||
|
"support.function": builtinFunctions,
|
||||||
|
//"invalid.illegal": futureReserved,
|
||||||
|
"constant.language": builtinConstants,
|
||||||
|
"storage.type" : storageType,
|
||||||
|
"keyword": keywords
|
||||||
|
}, "identifier");
|
||||||
|
|
||||||
|
var strPre = "(?:r|R)?";
|
||||||
|
|
||||||
|
var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
|
||||||
|
var octInteger = "(?:0[o]?[0-7]+)";
|
||||||
|
var hexInteger = "(?:0[xX][\\dA-Fa-f]+)";
|
||||||
|
var binInteger = "(?:0[bB][01]+)";
|
||||||
|
var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")";
|
||||||
|
|
||||||
|
var exponent = "(?:[eE][+-]?\\d+)";
|
||||||
|
var fraction = "(?:\\.\\d+)";
|
||||||
|
var intPart = "(?:\\d+)";
|
||||||
|
var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
|
||||||
|
var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")";
|
||||||
|
var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
|
||||||
|
|
||||||
|
var stringEscape = "\\\\(x[0-9A-Fa-f]{2}|[0-7]{3}|[\\\\abfnrtv'\"]|U[0-9A-Fa-f]{8}|u[0-9A-Fa-f]{4})";
|
||||||
|
|
||||||
|
this.$rules = {
|
||||||
|
"start" : [ {
|
||||||
|
token : "comment",
|
||||||
|
regex : "#.*$"
|
||||||
|
}, {
|
||||||
|
token : "keyword",
|
||||||
|
regex : "(proc|method|temdplate|macro|macromethod|converter|func|iterator) ",
|
||||||
|
next : "qproc_name"
|
||||||
|
}, {
|
||||||
|
token : "storage.type",
|
||||||
|
regex : "(c|cu|u)?int(8|16|32|64)?",
|
||||||
|
}, {
|
||||||
|
token : "storage.type",
|
||||||
|
regex : "(c|cu|u|cs)?char",
|
||||||
|
}, {
|
||||||
|
token : "storage.type",
|
||||||
|
regex : "float(32|64)?",
|
||||||
|
}, {
|
||||||
|
token : "docstring",
|
||||||
|
regex : "##.*$"
|
||||||
|
}, {
|
||||||
|
token : "string", // multi line """ string start
|
||||||
|
regex : strPre + '"{3}',
|
||||||
|
next : "qqstring3"
|
||||||
|
}, {
|
||||||
|
token : "string", // " string
|
||||||
|
regex : strPre + '"(?=.)',
|
||||||
|
next : "qqstring"
|
||||||
|
}, {
|
||||||
|
token : "string", // multi line ''' string start
|
||||||
|
regex : strPre + "'{3}",
|
||||||
|
next : "qstring3"
|
||||||
|
}, {
|
||||||
|
token : "backtick", // ` string
|
||||||
|
regex : strPre + "`(?=.)",
|
||||||
|
next : "qxstring"
|
||||||
|
}, {
|
||||||
|
token : "string", // ' string
|
||||||
|
regex : strPre + "'(?=.)",
|
||||||
|
next : "qstring"
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // imaginary
|
||||||
|
regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b"
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // float
|
||||||
|
regex : floatNumber
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // long integer
|
||||||
|
regex : integer + "[lL]\\b"
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // integer
|
||||||
|
regex : integer + "\\b"
|
||||||
|
}, {
|
||||||
|
token : keywordMapper,
|
||||||
|
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||||
|
}, {
|
||||||
|
token : "keyword.operator",
|
||||||
|
regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|="
|
||||||
|
}, {
|
||||||
|
token : "paren.lparen",
|
||||||
|
regex : "[\\[\\(\\{]"
|
||||||
|
}, {
|
||||||
|
token : "paren.rparen",
|
||||||
|
regex : "[\\]\\)\\}]"
|
||||||
|
}, {
|
||||||
|
token : "text",
|
||||||
|
regex : "\\s+"
|
||||||
|
} ],
|
||||||
|
"qqstring3" : [ {
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex : stringEscape
|
||||||
|
}, {
|
||||||
|
token : "string", // multi line """ string end
|
||||||
|
regex : '"{3}',
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
defaultToken : "string"
|
||||||
|
} ],
|
||||||
|
"qstring3" : [ {
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex : stringEscape
|
||||||
|
}, {
|
||||||
|
token : "string", // multi line ''' string end
|
||||||
|
regex : "'{3}",
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
defaultToken : "string"
|
||||||
|
} ],
|
||||||
|
"qqstring" : [{
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex : stringEscape
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : "\\\\$",
|
||||||
|
next : "qqstring"
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : '"|$',
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string"
|
||||||
|
}],
|
||||||
|
"qstring" : [{
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex : stringEscape
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : "\\\\$",
|
||||||
|
next : "qstring"
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : "'|$",
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string"
|
||||||
|
}],
|
||||||
|
"qxstring" : [{
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex : stringEscape
|
||||||
|
}, {
|
||||||
|
token : "backtick",
|
||||||
|
regex : "\\\\$",
|
||||||
|
next : "qxstring"
|
||||||
|
}, {
|
||||||
|
token : "backtick",
|
||||||
|
regex : "`|$",
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
defaultToken: "backtick"
|
||||||
|
}],
|
||||||
|
"qproc_name":[{
|
||||||
|
token : "proc_name",
|
||||||
|
regex : "\\w+",
|
||||||
|
},{
|
||||||
|
token : "start_bracket",
|
||||||
|
regex : "(\\(|=|$)",
|
||||||
|
next : "start"
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
oop.inherits(NimHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
|
exports.NimHighlightRules = NimHighlightRules;
|
||||||
|
});
|
||||||
|
|
@ -84,9 +84,8 @@ var RustHighlightRules = function() {
|
||||||
{ token: 'constant.character.escape.source.rust',
|
{ token: 'constant.character.escape.source.rust',
|
||||||
regex: stringEscape },
|
regex: stringEscape },
|
||||||
{ defaultToken: 'string.quoted.double.source.rust' } ] },
|
{ defaultToken: 'string.quoted.double.source.rust' } ] },
|
||||||
{ token: [ 'keyword.source.rust', 'meta.function.source.rust',
|
{ token: [ 'keyword.source.rust', 'text', 'entity.name.function.source.rust' ],
|
||||||
'entity.name.function.source.rust', 'meta.function.source.rust' ],
|
regex: '\\b(fn)(\\s+)([a-zA-Z_][a-zA-Z0-9_]*)' },
|
||||||
regex: '\\b(fn)(\\s+)([a-zA-Z_][a-zA-Z0-9_][\\w\\:,+ \\\'<>]*)(\\s*\\()' },
|
|
||||||
{ token: 'support.constant', regex: '\\b[a-zA-Z_][\\w\\d]*::' },
|
{ token: 'support.constant', regex: '\\b[a-zA-Z_][\\w\\d]*::' },
|
||||||
{ token: 'keyword.source.rust',
|
{ token: 'keyword.source.rust',
|
||||||
regex: '\\b(?:as|assert|break|claim|const|do|drop|else|extern|fail|for|if|impl|in|let|log|loop|match|mod|module|move|mut|Owned|priv|pub|pure|ref|return|unchecked|unsafe|use|while|mod|Send|static|trait|class|struct|enum|type)\\b' },
|
regex: '\\b(?:as|assert|break|claim|const|do|drop|else|extern|fail|for|if|impl|in|let|log|loop|match|mod|module|move|mut|Owned|priv|pub|pure|ref|return|unchecked|unsafe|use|while|mod|Send|static|trait|class|struct|enum|type)\\b' },
|
||||||
|
|
|
||||||
|
|
@ -39,15 +39,92 @@ define(function(require, exports, module) {
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextMode = require("./text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var SchemeHighlightRules = require("./scheme_highlight_rules").SchemeHighlightRules;
|
var SchemeHighlightRules = require("./scheme_highlight_rules").SchemeHighlightRules;
|
||||||
|
var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent;
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
this.HighlightRules = SchemeHighlightRules;
|
this.HighlightRules = SchemeHighlightRules;
|
||||||
|
this.$outdent = new MatchingParensOutdent();
|
||||||
};
|
};
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.lineCommentStart = ";";
|
this.lineCommentStart = ";";
|
||||||
|
this.minorIndentFunctions = ["define", "lambda", "define-macro", "define-syntax", "syntax-rules", "define-record-type", "define-structure"];
|
||||||
|
|
||||||
|
this.$toIndent = function(str) {
|
||||||
|
return str.split('').map(function(ch) {
|
||||||
|
if (/\s/.exec(ch)) {
|
||||||
|
return ch;
|
||||||
|
} else {
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
|
}).join('');
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$calculateIndent = function(line, tab) {
|
||||||
|
var baseIndent = this.$getIndent(line);
|
||||||
|
var delta = 0;
|
||||||
|
var isParen, ch;
|
||||||
|
// Walk back from end of line, find matching braces
|
||||||
|
for (var i = line.length - 1; i >= 0; i--) {
|
||||||
|
ch = line[i];
|
||||||
|
if (ch === '(') {
|
||||||
|
delta--;
|
||||||
|
isParen = true;
|
||||||
|
} else if (ch === '(' || ch === '[' || ch === '{') {
|
||||||
|
delta--;
|
||||||
|
isParen = false;
|
||||||
|
} else if (ch === ')' || ch === ']' || ch === '}') {
|
||||||
|
delta++;
|
||||||
|
}
|
||||||
|
if (delta < 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (delta < 0 && isParen) {
|
||||||
|
// Were more brackets opened than closed and was a ( left open?
|
||||||
|
i += 1;
|
||||||
|
var iBefore = i;
|
||||||
|
var fn = '';
|
||||||
|
while (true) {
|
||||||
|
ch = line[i];
|
||||||
|
if (ch === ' ' || ch === '\t') {
|
||||||
|
if(this.minorIndentFunctions.indexOf(fn) !== -1) {
|
||||||
|
return this.$toIndent(line.substring(0, iBefore - 1) + tab);
|
||||||
|
} else {
|
||||||
|
return this.$toIndent(line.substring(0, i + 1));
|
||||||
|
}
|
||||||
|
} else if (ch === undefined) {
|
||||||
|
return this.$toIndent(line.substring(0, iBefore - 1) + tab);
|
||||||
|
}
|
||||||
|
fn += line[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else if(delta < 0 && !isParen) {
|
||||||
|
// Were more brackets openend than closed and was it not a (?
|
||||||
|
return this.$toIndent(line.substring(0, i+1));
|
||||||
|
} else if(delta > 0) {
|
||||||
|
// Mere more brackets closed than opened? Outdent.
|
||||||
|
baseIndent = baseIndent.substring(0, baseIndent.length - tab.length);
|
||||||
|
return baseIndent;
|
||||||
|
} else {
|
||||||
|
// Were they nicely matched? Just indent like line before.
|
||||||
|
return baseIndent;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
|
return this.$calculateIndent(line, tab);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.checkOutdent = function(state, line, input) {
|
||||||
|
return this.$outdent.checkOutdent(line, input);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.autoOutdent = function(state, doc, row) {
|
||||||
|
this.$outdent.autoOutdent(doc, row);
|
||||||
|
};
|
||||||
|
|
||||||
this.$id = "ace/mode/scheme";
|
this.$id = "ace/mode/scheme";
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,13 @@ oop.inherits(Mode, TextMode);
|
||||||
this.lineCommentStart = "--";
|
this.lineCommentStart = "--";
|
||||||
this.blockComment = {start: "/*", end: "*/"};
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override keyword completions using list created in highlight rules
|
||||||
|
*/
|
||||||
|
this.getCompletions = function(state, session, pos, prefix) {
|
||||||
|
return session.$mode.$highlightRules.completions;
|
||||||
|
};
|
||||||
|
|
||||||
this.$id = "ace/mode/sql";
|
this.$id = "ace/mode/sql";
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,9 @@ var SqlServerHighlightRules = function() {
|
||||||
/* https://msdn.microsoft.com/en-us/library/ms177520.aspx */
|
/* https://msdn.microsoft.com/en-us/library/ms177520.aspx */
|
||||||
"@@CONNECTIONS|@@CPU_BUSY|@@IDLE|@@IO_BUSY|@@PACKET_ERRORS|@@PACK_RECEIVED|@@PACK_SENT|@@TIMETICKS|@@TOTAL_ERRORS|@@TOTAL_READ|@@TOTAL_WRITE|FN_VIRTUALFILESTATS|" +
|
"@@CONNECTIONS|@@CPU_BUSY|@@IDLE|@@IO_BUSY|@@PACKET_ERRORS|@@PACK_RECEIVED|@@PACK_SENT|@@TIMETICKS|@@TOTAL_ERRORS|@@TOTAL_READ|@@TOTAL_WRITE|FN_VIRTUALFILESTATS|" +
|
||||||
/* https://msdn.microsoft.com/en-us/library/ms188353.aspx */
|
/* https://msdn.microsoft.com/en-us/library/ms188353.aspx */
|
||||||
"PATINDEX|TEXTPTR|TEXTVALID"
|
"PATINDEX|TEXTPTR|TEXTVALID|" +
|
||||||
|
/* other */
|
||||||
|
"COALESCE|NULLIF"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -104,12 +106,14 @@ var SqlServerHighlightRules = function() {
|
||||||
keywords += "|TYPE";
|
keywords += "|TYPE";
|
||||||
|
|
||||||
|
|
||||||
//remove any other built in things from key word list
|
//remove specific built in types from keyword list
|
||||||
keywords = keywords.split('|');
|
keywords = keywords.split('|');
|
||||||
keywords = keywords.filter(function(value, index, self) {
|
keywords = keywords.filter(function(value, index, self) {
|
||||||
return logicalOperators.split('|').indexOf(value) === -1 && builtinFunctions.split('|').indexOf(value) === -1 && dataTypes.split('|').indexOf(value) === -1;
|
return logicalOperators.split('|').indexOf(value) === -1 && builtinFunctions.split('|').indexOf(value) === -1 && dataTypes.split('|').indexOf(value) === -1;
|
||||||
});
|
});
|
||||||
keywords = keywords.sort().join('|');
|
keywords = keywords.sort().join('|');
|
||||||
|
|
||||||
|
|
||||||
var keywordMapper = this.createKeywordMapper({
|
var keywordMapper = this.createKeywordMapper({
|
||||||
"constant.language": logicalOperators,
|
"constant.language": logicalOperators,
|
||||||
"storage.type": dataTypes,
|
"storage.type": dataTypes,
|
||||||
|
|
@ -119,26 +123,12 @@ var SqlServerHighlightRules = function() {
|
||||||
}, "identifier", true);
|
}, "identifier", true);
|
||||||
|
|
||||||
|
|
||||||
// createKeywordMapper ignores case which we want because SqlServer keywords are not case sensitive which causes our keywords to get changed to lowercase.
|
|
||||||
// However, the preferred standard for keywords is uppercase, so this transforms them back to uppercase for code completion
|
|
||||||
// EXCEPTION: build in stored procedures are lower case
|
|
||||||
for (var i = 0; i < this.$keywordList.length; i++) {
|
|
||||||
var keyword = this.$keywordList[i];
|
|
||||||
if (builtInStoredProcedures.indexOf(keyword) !== -1) continue;
|
|
||||||
this.$keywordList[i] = keyword.toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//https://msdn.microsoft.com/en-us/library/ms190356.aspx
|
//https://msdn.microsoft.com/en-us/library/ms190356.aspx
|
||||||
var setStatements = "SET ANSI_DEFAULTS|SET ANSI_NULLS|SET ANSI_NULL_DFLT_OFF|SET ANSI_NULL_DFLT_ON|SET ANSI_PADDING|SET ANSI_WARNINGS|SET ARITHABORT|SET ARITHIGNORE|SET CONCAT_NULL_YIELDS_NULL|SET CURSOR_CLOSE_ON_COMMIT|SET DATEFIRST|SET DATEFORMAT|SET DEADLOCK_PRIORITY|SET FIPS_FLAGGER|SET FMTONLY|SET FORCEPLAN|SET IDENTITY_INSERT|SET IMPLICIT_TRANSACTIONS|SET LANGUAGE|SET LOCK_TIMEOUT|SET NOCOUNT|SET NOEXEC|SET NUMERIC_ROUNDABORT|SET OFFSETS|SET PARSEONLY|SET QUERY_GOVERNOR_COST_LIMIT|SET QUOTED_IDENTIFIER|SET REMOTE_PROC_TRANSACTIONS|SET ROWCOUNT|SET SHOWPLAN_ALL|SET SHOWPLAN_TEXT|SET SHOWPLAN_XML|SET STATISTICS IO|SET STATISTICS PROFILE|SET STATISTICS TIME|SET STATISTICS XML|SET TEXTSIZE|SET XACT_ABORT".split('|');
|
var setStatements = "SET ANSI_DEFAULTS|SET ANSI_NULLS|SET ANSI_NULL_DFLT_OFF|SET ANSI_NULL_DFLT_ON|SET ANSI_PADDING|SET ANSI_WARNINGS|SET ARITHABORT|SET ARITHIGNORE|SET CONCAT_NULL_YIELDS_NULL|SET CURSOR_CLOSE_ON_COMMIT|SET DATEFIRST|SET DATEFORMAT|SET DEADLOCK_PRIORITY|SET FIPS_FLAGGER|SET FMTONLY|SET FORCEPLAN|SET IDENTITY_INSERT|SET IMPLICIT_TRANSACTIONS|SET LANGUAGE|SET LOCK_TIMEOUT|SET NOCOUNT|SET NOEXEC|SET NUMERIC_ROUNDABORT|SET OFFSETS|SET PARSEONLY|SET QUERY_GOVERNOR_COST_LIMIT|SET QUOTED_IDENTIFIER|SET REMOTE_PROC_TRANSACTIONS|SET ROWCOUNT|SET SHOWPLAN_ALL|SET SHOWPLAN_TEXT|SET SHOWPLAN_XML|SET STATISTICS IO|SET STATISTICS PROFILE|SET STATISTICS TIME|SET STATISTICS XML|SET TEXTSIZE|SET XACT_ABORT".split('|');
|
||||||
var isolationLevels = "READ UNCOMMITTED|READ COMMITTED|REPEATABLE READ|SNAPSHOP|SERIALIZABLE".split('|');
|
var isolationLevels = "READ UNCOMMITTED|READ COMMITTED|REPEATABLE READ|SNAPSHOP|SERIALIZABLE".split('|');
|
||||||
for (var i = 0; i < isolationLevels.length; i++) {
|
for (var i = 0; i < isolationLevels.length; i++) {
|
||||||
setStatements.push('SET TRANSACTION ISOLATION LEVEL ' + isolationLevels[i]);
|
setStatements.push('SET TRANSACTION ISOLATION LEVEL ' + isolationLevels[i]);
|
||||||
}
|
}
|
||||||
//add set statements to keywordList for completions
|
|
||||||
for (var i = 0; i < setStatements.length; i++) {
|
|
||||||
this.$keywordList.push(setStatements[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
|
|
@ -147,7 +137,7 @@ var SqlServerHighlightRules = function() {
|
||||||
regex: "'",
|
regex: "'",
|
||||||
next: [{
|
next: [{
|
||||||
token: "constant.language.escape",
|
token: "constant.language.escape",
|
||||||
regex: /\\'/
|
regex: /''/
|
||||||
}, {
|
}, {
|
||||||
token: "string.end",
|
token: "string.end",
|
||||||
next: "start",
|
next: "start",
|
||||||
|
|
@ -163,15 +153,12 @@ var SqlServerHighlightRules = function() {
|
||||||
token: "comment",
|
token: "comment",
|
||||||
start: "/\\*",
|
start: "/\\*",
|
||||||
end: "\\*/"
|
end: "\\*/"
|
||||||
}, {
|
|
||||||
token: "string", // ' string
|
|
||||||
regex: "'.*?'"
|
|
||||||
}, {
|
}, {
|
||||||
token: "constant.numeric", // float
|
token: "constant.numeric", // float
|
||||||
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||||
}, {
|
}, {
|
||||||
token: keywordMapper,
|
token: keywordMapper,
|
||||||
regex: "@{0,2}[a-zA-Z_$][a-zA-Z0-9_$]*\\b" //up to 2 @symbols for some build in functions
|
regex: "@{0,2}[a-zA-Z_$][a-zA-Z0-9_$]*\\b(?!])" //up to 2 @symbols for some built in functions
|
||||||
}, {
|
}, {
|
||||||
token: "constant.class",
|
token: "constant.class",
|
||||||
regex: "@@?[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
regex: "@@?[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||||
|
|
@ -204,18 +191,39 @@ var SqlServerHighlightRules = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
//add each set statment as regex at top of rules so that they are processed first because they require multiple words
|
//add each set statment as regex at top of rules so that they are processed first because they require multiple words
|
||||||
//note, this makes the statements not match if they are not upper case.. which is not ideal but I don't know of an easy way to fix this
|
//note: this makes the statements not match if they are not upper case.. which is not ideal but I don't know of an easy way to fix this
|
||||||
for (var i = 0; i < setStatements.length; i++) {
|
for (var i = 0; i < setStatements.length; i++) {
|
||||||
var statement = setStatements[i];
|
|
||||||
this.$rules.start.unshift({
|
this.$rules.start.unshift({
|
||||||
token: "set.statement",
|
token: "set.statement",
|
||||||
regex: statement
|
regex: setStatements[i]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
|
this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
|
||||||
|
|
||||||
this.normalizeRules();
|
this.normalizeRules();
|
||||||
|
|
||||||
|
|
||||||
|
//prepare custom keyword completions used by mode to override default completor
|
||||||
|
//this allows for custom 'meta' and proper case of completions
|
||||||
|
var completions = [];
|
||||||
|
var addCompletions = function(arr, meta) {
|
||||||
|
arr.forEach(function(v) {
|
||||||
|
completions.push({
|
||||||
|
name: v,
|
||||||
|
value: v,
|
||||||
|
score: 0,
|
||||||
|
meta: meta,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
addCompletions(builtInStoredProcedures.split('|'), 'procedure');
|
||||||
|
addCompletions(logicalOperators.split('|'), 'operator');
|
||||||
|
addCompletions(builtinFunctions.split('|'), 'function');
|
||||||
|
addCompletions(dataTypes.split('|'), 'type');
|
||||||
|
addCompletions(setStatements, 'statement');
|
||||||
|
addCompletions(keywords.split('|'), 'keyword');
|
||||||
|
|
||||||
|
this.completions = completions;
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(SqlServerHighlightRules, TextHighlightRules);
|
oop.inherits(SqlServerHighlightRules, TextHighlightRules);
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ var TomlHighlightRules = function() {
|
||||||
regex : '"(?=.)',
|
regex : '"(?=.)',
|
||||||
next : "qqstring"
|
next : "qqstring"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
token: ["variable.keygroup.toml"],
|
||||||
|
regex: "(?:^\\s*)(\\[\\[([^\\]]+)\\]\\])"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
token: ["variable.keygroup.toml"],
|
token: ["variable.keygroup.toml"],
|
||||||
regex: "(?:^\\s*)(\\[([^\\]]+)\\])"
|
regex: "(?:^\\s*)(\\[([^\\]]+)\\])"
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
this.blockComment = {start: "<!--", end: "-->"};
|
this.blockComment = {start: "<!--", end: "-->"};
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
|
var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
|
||||||
worker.attachToDocument(session.getDocument());
|
worker.attachToDocument(session.getDocument());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,10 @@ var oop = require("../lib/oop");
|
||||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var XmlHighlightRules = function(normalize) {
|
var XmlHighlightRules = function(normalize) {
|
||||||
|
// http://www.w3.org/TR/REC-xml/#NT-NameChar
|
||||||
var tagRegex = "[a-zA-Z][-_a-zA-Z0-9]*";
|
// NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
||||||
|
// NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
||||||
|
var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
start : [
|
start : [
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ function onMouseDown(e) {
|
||||||
var selectionMode;
|
var selectionMode;
|
||||||
if (editor.$mouseHandler.$enableJumpToDef) {
|
if (editor.$mouseHandler.$enableJumpToDef) {
|
||||||
if (ctrl && alt || accel && alt)
|
if (ctrl && alt || accel && alt)
|
||||||
selectionMode = "add";
|
selectionMode = shift ? "block" : "add";
|
||||||
else if (alt && editor.$blockSelectEnabled)
|
else if (alt && editor.$blockSelectEnabled)
|
||||||
selectionMode = "block";
|
selectionMode = "block";
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -117,7 +117,7 @@ function onMouseDown(e) {
|
||||||
|
|
||||||
if (shift) {
|
if (shift) {
|
||||||
oldRange = null;
|
oldRange = null;
|
||||||
range = selection.ranges[0];
|
range = selection.ranges[0] || range;
|
||||||
editor.removeSelectionMarker(range);
|
editor.removeSelectionMarker(range);
|
||||||
}
|
}
|
||||||
editor.once("mouseup", function() {
|
editor.once("mouseup", function() {
|
||||||
|
|
|
||||||
|
|
@ -84,11 +84,11 @@ function setSelection(editor, data) {
|
||||||
return isBackwards ? {
|
return isBackwards ? {
|
||||||
start: end,
|
start: end,
|
||||||
end: start,
|
end: start,
|
||||||
isBackwards: true
|
isBackwards: isBackwards
|
||||||
} : {
|
} : {
|
||||||
start: start,
|
start: start,
|
||||||
end: end,
|
end: end,
|
||||||
isBackwards: true
|
isBackwards: isBackwards
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
@ -225,19 +225,19 @@ module.exports = {
|
||||||
assert.equal(editor.getValue(),"l1\nl1\nl2\nl2\nl3\nl3\nl4\nl4");
|
assert.equal(editor.getValue(),"l1\nl1\nl2\nl2\nl3\nl3\nl4\nl4");
|
||||||
testSelection(editor, [[1,0],[3,0],[5,0],[7,0]]);
|
testSelection(editor, [[1,0],[3,0],[5,0],[7,0]]);
|
||||||
|
|
||||||
setSelection(editor, [[1,2],[1,0,1,1],[3,0,3,1],[5,0,5,1],[7,0,7,1]]);
|
setSelection(editor, [[1,2],[1,1,1,0],[3,0,3,1],[5,0,5,1],[7,0,7,1]]);
|
||||||
exec("copylinesdown");
|
exec("copylinesdown");
|
||||||
exec("copylinesup");
|
exec("copylinesup");
|
||||||
assert.equal(editor.getValue(),"l1\nl1\nl1\nl1\nl2\nl2\nl2\nl2\nl3\nl3\nl3\nl3\nl4\nl4\nl4\nl4");
|
assert.equal(editor.getValue(),"l1\nl1\nl1\nl1\nl2\nl2\nl2\nl2\nl3\nl3\nl3\nl3\nl4\nl4\nl4\nl4");
|
||||||
testSelection(editor, [[2,2],[2,0,2,1],[6,0,6,1],[10,0,10,1],[14,0,14,1]]);
|
testSelection(editor, [[2,2],[2,1,2,0],[6,0,6,1],[10,0,10,1],[14,0,14,1]]);
|
||||||
|
|
||||||
exec("movelinesdown", 12);
|
exec("movelinesdown", 12);
|
||||||
assert.equal(editor.getValue(),"l1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4\nl1\nl2\nl3\nl4");
|
assert.equal(editor.getValue(),"l1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4\nl1\nl2\nl3\nl4");
|
||||||
testSelection(editor, [[12,2],[12,0,12,1],[13,0,13,1],[14,0,14,1],[15,0,15,1]]);
|
testSelection(editor, [[12,2],[12,1,12,0],[13,0,13,1],[14,0,14,1],[15,0,15,1]]);
|
||||||
|
|
||||||
exec("movelinesup", 12);
|
exec("movelinesup", 12);
|
||||||
assert.equal(editor.getValue(),"l1\nl2\nl3\nl4\nl1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4");
|
assert.equal(editor.getValue(),"l1\nl2\nl3\nl4\nl1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4");
|
||||||
testSelection(editor, [[0,2],[0,0,0,1],[1,0,1,1],[2,0,2,1],[3,0,3,1]]);
|
testSelection(editor, [[0,2],[0,1,0,0],[1,0,1,1],[2,0,2,1],[3,0,3,1]]);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test multiselect fromJSON/toJSON": function() {
|
"test multiselect fromJSON/toJSON": function() {
|
||||||
|
|
|
||||||
|
|
@ -923,7 +923,7 @@ var Selection = function(session) {
|
||||||
this.toSingleRange(data[0]);
|
this.toSingleRange(data[0]);
|
||||||
for (var i = data.length; i--; ) {
|
for (var i = data.length; i--; ) {
|
||||||
var r = Range.fromPoints(data[i].start, data[i].end);
|
var r = Range.fromPoints(data[i].start, data[i].end);
|
||||||
if (data.isBackwards)
|
if (data[i].isBackwards)
|
||||||
r.cursor = r.start;
|
r.cursor = r.start;
|
||||||
this.addRange(r, true);
|
this.addRange(r, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
7
lib/ace/snippets/mask.js
Normal file
7
lib/ace/snippets/mask.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports.snippetText = require("../requirejs/text!./mask.snippets");
|
||||||
|
exports.scope = "mask";
|
||||||
|
|
||||||
|
});
|
||||||
0
lib/ace/snippets/mask.snippets
Normal file
0
lib/ace/snippets/mask.snippets
Normal file
7
lib/ace/snippets/nim.js
Normal file
7
lib/ace/snippets/nim.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports.snippetText = require("../requirejs/text!./nim.snippets");
|
||||||
|
exports.scope = "nim";
|
||||||
|
|
||||||
|
});
|
||||||
130
lib/ace/snippets/nim.snippets
Normal file
130
lib/ace/snippets/nim.snippets
Normal file
|
|
@ -0,0 +1,130 @@
|
||||||
|
snippet #!
|
||||||
|
#!/usr/bin/env nim
|
||||||
|
snippet imp
|
||||||
|
import ${1:module}
|
||||||
|
snippet from
|
||||||
|
from ${1:package} import ${2:module}
|
||||||
|
# Module Docstring
|
||||||
|
snippet docs
|
||||||
|
## File: ${1:FILENAME:file_name}
|
||||||
|
## Author: ${2:author}
|
||||||
|
## Description: ${3}
|
||||||
|
snippet wh
|
||||||
|
while ${1:condition}:
|
||||||
|
${2:# TODO: write code...}
|
||||||
|
# dowh - does the same as do...while in other languages
|
||||||
|
snippet dowh
|
||||||
|
while true:
|
||||||
|
${1:# TODO: write code...}
|
||||||
|
if ${2:condition}:
|
||||||
|
break
|
||||||
|
snippet with
|
||||||
|
with ${1:expr} as ${2:var}:
|
||||||
|
${3:# TODO: write code...}
|
||||||
|
# New Function
|
||||||
|
snippet proc
|
||||||
|
proc ${1:fname}(${2:`indent('.') ? 'self' : ''`}): ${3: return type} =
|
||||||
|
##${4:docstring for $1}
|
||||||
|
${5:# TODO: write code...}
|
||||||
|
snippet deff
|
||||||
|
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||||
|
${3:# TODO: write code...}
|
||||||
|
# New Method
|
||||||
|
snippet defs
|
||||||
|
def ${1:mname}(self, ${2:arg}):
|
||||||
|
${3:# TODO: write code...}
|
||||||
|
# New Property
|
||||||
|
snippet property
|
||||||
|
def ${1:foo}():
|
||||||
|
doc = "${2:The $1 property.}"
|
||||||
|
def fget(self):
|
||||||
|
${3:return self._$1}
|
||||||
|
def fset(self, value):
|
||||||
|
${4:self._$1 = value}
|
||||||
|
# Ifs
|
||||||
|
snippet if
|
||||||
|
if ${1:condition}:
|
||||||
|
${2:# TODO: write code...}
|
||||||
|
snippet el
|
||||||
|
else:
|
||||||
|
${1:# TODO: write code...}
|
||||||
|
snippet ei
|
||||||
|
elif ${1:condition}:
|
||||||
|
${2:# TODO: write code...}
|
||||||
|
# For
|
||||||
|
snippet for
|
||||||
|
for ${1:item} in ${2:items}:
|
||||||
|
${3:# TODO: write code...}
|
||||||
|
# Encodes
|
||||||
|
snippet cutf8
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
snippet clatin1
|
||||||
|
# -*- coding: latin-1 -*-
|
||||||
|
snippet cascii
|
||||||
|
# -*- coding: ascii -*-
|
||||||
|
# Lambda
|
||||||
|
snippet ld
|
||||||
|
${1:var} = lambda ${2:vars} : ${3:action}
|
||||||
|
snippet .
|
||||||
|
self.
|
||||||
|
snippet try Try/Except
|
||||||
|
try:
|
||||||
|
${1:# TODO: write code...}
|
||||||
|
except ${2:Exception}, ${3:e}:
|
||||||
|
${4:raise $3}
|
||||||
|
snippet try Try/Except/Else
|
||||||
|
try:
|
||||||
|
${1:# TODO: write code...}
|
||||||
|
except ${2:Exception}, ${3:e}:
|
||||||
|
${4:raise $3}
|
||||||
|
else:
|
||||||
|
${5:# TODO: write code...}
|
||||||
|
snippet try Try/Except/Finally
|
||||||
|
try:
|
||||||
|
${1:# TODO: write code...}
|
||||||
|
except ${2:Exception}, ${3:e}:
|
||||||
|
${4:raise $3}
|
||||||
|
finally:
|
||||||
|
${5:# TODO: write code...}
|
||||||
|
snippet try Try/Except/Else/Finally
|
||||||
|
try:
|
||||||
|
${1:# TODO: write code...}
|
||||||
|
except ${2:Exception}, ${3:e}:
|
||||||
|
${4:raise $3}
|
||||||
|
else:
|
||||||
|
${5:# TODO: write code...}
|
||||||
|
finally:
|
||||||
|
${6:# TODO: write code...}
|
||||||
|
# if __name__ == '__main__':
|
||||||
|
snippet ifmain
|
||||||
|
if isMainModule:
|
||||||
|
${1:main()}
|
||||||
|
snippet "
|
||||||
|
## ${1:doc}
|
||||||
|
# test function/method
|
||||||
|
snippet test
|
||||||
|
def test_${1:description}(${2:self}):
|
||||||
|
${3:# TODO: write code...}
|
||||||
|
# test case
|
||||||
|
snippet testcase
|
||||||
|
class ${1:ExampleCase}(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_${2:description}(self):
|
||||||
|
${3:# TODO: write code...}
|
||||||
|
#getopt
|
||||||
|
snippet getopt
|
||||||
|
try:
|
||||||
|
# Short option syntax: "hv:"
|
||||||
|
# Long option syntax: "help" or "verbose="
|
||||||
|
opts, args = getopt.getopt(sys.argv[1:], "${1:short_options}", [${2:long_options}])
|
||||||
|
|
||||||
|
except getopt.GetoptError, err:
|
||||||
|
# Print debug info
|
||||||
|
print str(err)
|
||||||
|
${3:error_action}
|
||||||
|
|
||||||
|
for option, argument in opts:
|
||||||
|
if option in ("-h", "--help"):
|
||||||
|
${4}
|
||||||
|
elif option in ("-v", "--verbose"):
|
||||||
|
verbose = argument
|
||||||
|
|
@ -22,6 +22,16 @@ snippet dateadd
|
||||||
# DATEFROMPARTS
|
# DATEFROMPARTS
|
||||||
snippet datefromparts
|
snippet datefromparts
|
||||||
DATEFROMPARTS(${1:year}, ${2:month}, ${3:day})
|
DATEFROMPARTS(${1:year}, ${2:month}, ${3:day})
|
||||||
|
# OBJECT_DEFINITION
|
||||||
|
snippet objectdef
|
||||||
|
SELECT OBJECT_DEFINITION(OBJECT_ID('${1:sys.server_permissions /*object name*/}'))
|
||||||
|
# STUFF XML
|
||||||
|
snippet stuffxml
|
||||||
|
STUFF((SELECT ', ' + ${1:ColumnName}
|
||||||
|
FROM ${2:TableName}
|
||||||
|
WHERE ${3:WhereClause}
|
||||||
|
FOR XML PATH('')), 1, 1, '') AS ${4:Alias}
|
||||||
|
${5:/*https://msdn.microsoft.com/en-us/library/ms188043.aspx*/}
|
||||||
# Create Procedure
|
# Create Procedure
|
||||||
snippet createproc
|
snippet createproc
|
||||||
-- =============================================
|
-- =============================================
|
||||||
|
|
@ -30,12 +40,14 @@ snippet createproc
|
||||||
-- Description: ${3:Description}
|
-- Description: ${3:Description}
|
||||||
-- =============================================
|
-- =============================================
|
||||||
CREATE PROCEDURE ${4:Procedure_Name}
|
CREATE PROCEDURE ${4:Procedure_Name}
|
||||||
-- Add the parameters for the stored procedure here
|
${5:/*Add the parameters for the stored procedure here*/}
|
||||||
AS
|
AS
|
||||||
BEGIN
|
BEGIN
|
||||||
-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
|
-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
|
||||||
SET NOCOUNT ON;
|
SET NOCOUNT ON;
|
||||||
|
|
||||||
|
${6:/*Add the T-SQL statements to compute the return value here*/}
|
||||||
|
|
||||||
END
|
END
|
||||||
GO
|
GO
|
||||||
# Create Scalar Function
|
# Create Scalar Function
|
||||||
|
|
@ -52,5 +64,7 @@ snippet createfn
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE @Result ${5:Function_Data_Type}
|
DECLARE @Result ${5:Function_Data_Type}
|
||||||
|
|
||||||
|
${6:/*Add the T-SQL statements to compute the return value here*/}
|
||||||
|
|
||||||
END
|
END
|
||||||
GO
|
GO
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-clouds.ace_multiselect .ace_selection.ace_start {
|
.ace-clouds.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #FFFFFF;
|
box-shadow: 0 0 3px 0px #FFFFFF;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-clouds .ace_marker-layer .ace_step {
|
.ace-clouds .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-clouds-midnight.ace_multiselect .ace_selection.ace_start {
|
.ace-clouds-midnight.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #191919;
|
box-shadow: 0 0 3px 0px #191919;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-clouds-midnight .ace_marker-layer .ace_step {
|
.ace-clouds-midnight .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-cobalt.ace_multiselect .ace_selection.ace_start {
|
.ace-cobalt.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #002240;
|
box-shadow: 0 0 3px 0px #002240;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-cobalt .ace_marker-layer .ace_step {
|
.ace-cobalt .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-dawn.ace_multiselect .ace_selection.ace_start {
|
.ace-dawn.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #F9F9F9;
|
box-shadow: 0 0 3px 0px #F9F9F9;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-dawn .ace_marker-layer .ace_step {
|
.ace-dawn .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-idle-fingers.ace_multiselect .ace_selection.ace_start {
|
.ace-idle-fingers.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #323232;
|
box-shadow: 0 0 3px 0px #323232;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-idle-fingers .ace_marker-layer .ace_step {
|
.ace-idle-fingers .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
.ace-katzenmilch.ace_multiselect .ace_selection.ace_start {
|
.ace-katzenmilch.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #f3f2f3;
|
box-shadow: 0 0 3px 0px #f3f2f3;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-katzenmilch .ace_marker-layer .ace_step {
|
.ace-katzenmilch .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-kr-theme.ace_multiselect .ace_selection.ace_start {
|
.ace-kr-theme.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #0B0A09;
|
box-shadow: 0 0 3px 0px #0B0A09;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-kr-theme .ace_marker-layer .ace_step {
|
.ace-kr-theme .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-merbivore.ace_multiselect .ace_selection.ace_start {
|
.ace-merbivore.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #161616;
|
box-shadow: 0 0 3px 0px #161616;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-merbivore .ace_marker-layer .ace_step {
|
.ace-merbivore .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-merbivore-soft.ace_multiselect .ace_selection.ace_start {
|
.ace-merbivore-soft.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #1C1C1C;
|
box-shadow: 0 0 3px 0px #1C1C1C;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-merbivore-soft .ace_marker-layer .ace_step {
|
.ace-merbivore-soft .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-mono-industrial.ace_multiselect .ace_selection.ace_start {
|
.ace-mono-industrial.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #222C28;
|
box-shadow: 0 0 3px 0px #222C28;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-mono-industrial .ace_marker-layer .ace_step {
|
.ace-mono-industrial .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-monokai.ace_multiselect .ace_selection.ace_start {
|
.ace-monokai.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #272822;
|
box-shadow: 0 0 3px 0px #272822;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-monokai .ace_marker-layer .ace_step {
|
.ace-monokai .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-pastel-on-dark.ace_multiselect .ace_selection.ace_start {
|
.ace-pastel-on-dark.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #2C2828;
|
box-shadow: 0 0 3px 0px #2C2828;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-pastel-on-dark .ace_marker-layer .ace_step {
|
.ace-pastel-on-dark .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
|
|
||||||
.ace-solarized-dark.ace_multiselect .ace_selection.ace_start {
|
.ace-solarized-dark.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #002B36;
|
box-shadow: 0 0 3px 0px #002B36;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-solarized-dark .ace_marker-layer .ace_step {
|
.ace-solarized-dark .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-solarized-light.ace_multiselect .ace_selection.ace_start {
|
.ace-solarized-light.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #FDF6E3;
|
box-shadow: 0 0 3px 0px #FDF6E3;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-solarized-light .ace_marker-layer .ace_step {
|
.ace-solarized-light .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-terminal-theme.ace_multiselect .ace_selection.ace_start {
|
.ace-terminal-theme.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px black;
|
box-shadow: 0 0 3px 0px black;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-terminal-theme .ace_marker-layer .ace_step {
|
.ace-terminal-theme .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,6 @@
|
||||||
}
|
}
|
||||||
.ace-tm.ace_multiselect .ace_selection.ace_start {
|
.ace-tm.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px white;
|
box-shadow: 0 0 3px 0px white;
|
||||||
border-radius: 2px;
|
|
||||||
}
|
}
|
||||||
.ace-tm .ace_marker-layer .ace_step {
|
.ace-tm .ace_marker-layer .ace_step {
|
||||||
background: rgb(252, 255, 0);
|
background: rgb(252, 255, 0);
|
||||||
|
|
|
||||||
139
lib/ace/theme/the_night_after_tomorrow.css
Normal file
139
lib/ace/theme/the_night_after_tomorrow.css
Normal file
|
|
@ -0,0 +1,139 @@
|
||||||
|
.ace-tomorrow-night .ace_gutter {
|
||||||
|
background: #25282c;
|
||||||
|
color: #C5C8C6
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_print-margin {
|
||||||
|
width: 1px;
|
||||||
|
background: #25282c
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night {
|
||||||
|
background-color: #1D1F21;
|
||||||
|
color: #C5C8C6
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_cursor {
|
||||||
|
color: #FFFFFF
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_marker-layer .ace_selection {
|
||||||
|
background: #373B41
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night.ace_multiselect .ace_selection.ace_start {
|
||||||
|
box-shadow: 0 0 3px 0px #1D1F21;
|
||||||
|
border-radius: 2px
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_marker-layer .ace_step {
|
||||||
|
background: rgb(102, 82, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_marker-layer .ace_bracket {
|
||||||
|
margin: -1px 0 0 -1px;
|
||||||
|
border: 1px solid #4B4E55
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_marker-layer .ace_active-line {
|
||||||
|
background: #282A2E
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_gutter-active-line {
|
||||||
|
background-color: #282A2E
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_marker-layer .ace_selected-word {
|
||||||
|
border: 1px solid #373B41
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_invisible {
|
||||||
|
color: #4B4E55
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_keyword,
|
||||||
|
.ace-tomorrow-night .ace_meta,
|
||||||
|
.ace-tomorrow-night .ace_support.ace_type {
|
||||||
|
color: #C4A400
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_storage,
|
||||||
|
.ace-tomorrow-night .ace_storage.ace_type {
|
||||||
|
color: #327FD7
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_keyword.ace_operator {
|
||||||
|
color: #8ABEB7
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_constant.ace_language{
|
||||||
|
color: #934B9F
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_constant.ace_character,
|
||||||
|
.ace-tomorrow-night .ace_constant.ace_numeric,
|
||||||
|
.ace-tomorrow-night .ace_keyword.ace_other.ace_unit,
|
||||||
|
.ace-tomorrow-night .ace_support.ace_constant,
|
||||||
|
.ace-tomorrow-night .ace_variable.ace_parameter {
|
||||||
|
color: #37BC9B
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_constant.ace_other {
|
||||||
|
color: #CED1CF
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_invalid {
|
||||||
|
color: #CED2CF;
|
||||||
|
background-color: #DF5F5F
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_invalid.ace_deprecated {
|
||||||
|
color: #CED2CF;
|
||||||
|
background-color: #B798BF
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_fold {
|
||||||
|
background-color: #62A5D6;
|
||||||
|
border-color: #C5C8C6
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_entity.ace_name.ace_function,
|
||||||
|
.ace-tomorrow-night .ace_support.ace_function,
|
||||||
|
.ace-tomorrow-night .ace_variable {
|
||||||
|
color: #62A5D6
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_support.ace_class,
|
||||||
|
.ace-tomorrow-night .ace_support.ace_type {
|
||||||
|
color: #F0C674
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_heading,
|
||||||
|
.ace-tomorrow-night .ace_markup.ace_heading,
|
||||||
|
.ace-tomorrow-night .ace_string {
|
||||||
|
color: #CD0000
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_proc_name {
|
||||||
|
color: #04939A
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_backtick {
|
||||||
|
color: #1DAA49
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_entity.ace_name.ace_tag,
|
||||||
|
.ace-tomorrow-night .ace_entity.ace_other.ace_attribute-name,
|
||||||
|
.ace-tomorrow-night .ace_meta.ace_tag,
|
||||||
|
.ace-tomorrow-night .ace_string.ace_regexp,
|
||||||
|
.ace-tomorrow-night .ace_variable {
|
||||||
|
color: #FFFFFF
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_comment {
|
||||||
|
color: #3465A4
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tomorrow-night .ace_indent-guide {
|
||||||
|
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNgYGBgYHB3d/8PAAOIAdULw8qMAAAAAElFTkSuQmCC) right repeat-y
|
||||||
|
}
|
||||||
39
lib/ace/theme/the_night_after_tomorrow.js
Normal file
39
lib/ace/theme/the_night_after_tomorrow.js
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Distributed under the BSD license:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010, Ajax.org B.V.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of Ajax.org B.V. nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
exports.isDark = true;
|
||||||
|
exports.cssClass = "ace-tomorrow-night";
|
||||||
|
exports.cssText = require("../requirejs/text!./the_night_after_tomorrow.css");
|
||||||
|
|
||||||
|
var dom = require("../lib/dom");
|
||||||
|
dom.importCssString(exports.cssText, exports.cssClass);
|
||||||
|
});
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-tomorrow.ace_multiselect .ace_selection.ace_start {
|
.ace-tomorrow.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #FFFFFF;
|
box-shadow: 0 0 3px 0px #FFFFFF;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-tomorrow .ace_marker-layer .ace_step {
|
.ace-tomorrow .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-tomorrow-night.ace_multiselect .ace_selection.ace_start {
|
.ace-tomorrow-night.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #1D1F21;
|
box-shadow: 0 0 3px 0px #1D1F21;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-tomorrow-night .ace_marker-layer .ace_step {
|
.ace-tomorrow-night .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
.ace-tomorrow-night-blue.ace_multiselect .ace_selection.ace_start {
|
.ace-tomorrow-night-blue.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #002451;
|
box-shadow: 0 0 3px 0px #002451;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-tomorrow-night-blue .ace_marker-layer .ace_step {
|
.ace-tomorrow-night-blue .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-tomorrow-night-bright.ace_multiselect .ace_selection.ace_start {
|
.ace-tomorrow-night-bright.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #000000;
|
box-shadow: 0 0 3px 0px #000000;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-tomorrow-night-bright .ace_marker-layer .ace_step {
|
.ace-tomorrow-night-bright .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
.ace-tomorrow-night-eighties.ace_multiselect .ace_selection.ace_start {
|
.ace-tomorrow-night-eighties.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #2D2D2D;
|
box-shadow: 0 0 3px 0px #2D2D2D;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-tomorrow-night-eighties .ace_marker-layer .ace_step {
|
.ace-tomorrow-night-eighties .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-twilight.ace_multiselect .ace_selection.ace_start {
|
.ace-twilight.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #141414;
|
box-shadow: 0 0 3px 0px #141414;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-twilight .ace_marker-layer .ace_step {
|
.ace-twilight .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
.ace-vibrant-ink.ace_multiselect .ace_selection.ace_start {
|
.ace-vibrant-ink.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #0F0F0F;
|
box-shadow: 0 0 3px 0px #0F0F0F;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-vibrant-ink .ace_marker-layer .ace_step {
|
.ace-vibrant-ink .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
.ace-xcode.ace_multiselect .ace_selection.ace_start {
|
.ace-xcode.ace_multiselect .ace_selection.ace_start {
|
||||||
box-shadow: 0 0 3px 0px #FFFFFF;
|
box-shadow: 0 0 3px 0px #FFFFFF;
|
||||||
border-radius: 2px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-xcode .ace_marker-layer .ace_step {
|
.ace-xcode .ace_marker-layer .ace_step {
|
||||||
|
|
|
||||||
|
|
@ -615,7 +615,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* @returns {DOMElement}
|
* @returns {DOMElement}
|
||||||
**/
|
**/
|
||||||
this.getMouseEventTarget = function() {
|
this.getMouseEventTarget = function() {
|
||||||
return this.content;
|
return this.scroller;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -919,6 +919,8 @@ var VirtualRenderer = function(container, theme) {
|
||||||
(this.$minLines||1) * this.lineHeight,
|
(this.$minLines||1) * this.lineHeight,
|
||||||
Math.min(maxHeight, height)
|
Math.min(maxHeight, height)
|
||||||
) + this.scrollMargin.v + (this.$extraHeight || 0);
|
) + this.scrollMargin.v + (this.$extraHeight || 0);
|
||||||
|
if (this.$horizScroll)
|
||||||
|
desiredHeight += this.scrollBarH.getHeight();
|
||||||
var vScroll = height > maxHeight;
|
var vScroll = height > maxHeight;
|
||||||
|
|
||||||
if (desiredHeight != this.desiredHeight ||
|
if (desiredHeight != this.desiredHeight ||
|
||||||
|
|
@ -939,9 +941,6 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$computeLayerConfig = function() {
|
this.$computeLayerConfig = function() {
|
||||||
if (this.$maxLines && this.lineHeight > 1)
|
|
||||||
this.$autosize();
|
|
||||||
|
|
||||||
var session = this.session;
|
var session = this.session;
|
||||||
var size = this.$size;
|
var size = this.$size;
|
||||||
|
|
||||||
|
|
@ -949,9 +948,6 @@ var VirtualRenderer = function(container, theme) {
|
||||||
var screenLines = this.session.getScreenLength();
|
var screenLines = this.session.getScreenLength();
|
||||||
var maxHeight = screenLines * this.lineHeight;
|
var maxHeight = screenLines * this.lineHeight;
|
||||||
|
|
||||||
var offset = this.scrollTop % this.lineHeight;
|
|
||||||
var minHeight = size.scrollerHeight + this.lineHeight;
|
|
||||||
|
|
||||||
var longestLine = this.$getLongestLine();
|
var longestLine = this.$getLongestLine();
|
||||||
|
|
||||||
var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
|
var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
|
||||||
|
|
@ -962,20 +958,27 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.$horizScroll = horizScroll;
|
this.$horizScroll = horizScroll;
|
||||||
this.scrollBarH.setVisible(horizScroll);
|
this.scrollBarH.setVisible(horizScroll);
|
||||||
}
|
}
|
||||||
|
// autoresize only after updating hscroll to include scrollbar height in desired height
|
||||||
|
if (this.$maxLines && this.lineHeight > 1)
|
||||||
|
this.$autosize();
|
||||||
|
|
||||||
|
var offset = this.scrollTop % this.lineHeight;
|
||||||
|
var minHeight = size.scrollerHeight + this.lineHeight;
|
||||||
|
|
||||||
var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
|
var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
|
||||||
? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
|
? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
|
||||||
: 0;
|
: 0;
|
||||||
maxHeight += scrollPastEnd;
|
maxHeight += scrollPastEnd;
|
||||||
|
|
||||||
this.session.setScrollTop(Math.max(-this.scrollMargin.top,
|
var sm = this.scrollMargin;
|
||||||
Math.min(this.scrollTop, maxHeight - size.scrollerHeight + this.scrollMargin.bottom)));
|
this.session.setScrollTop(Math.max(-sm.top,
|
||||||
|
Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom)));
|
||||||
|
|
||||||
this.session.setScrollLeft(Math.max(-this.scrollMargin.left, Math.min(this.scrollLeft,
|
this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft,
|
||||||
longestLine + 2 * this.$padding - size.scrollerWidth + this.scrollMargin.right)));
|
longestLine + 2 * this.$padding - size.scrollerWidth + sm.right)));
|
||||||
|
|
||||||
var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
|
var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
|
||||||
size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop);
|
size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top);
|
||||||
var vScrollChanged = this.$vScroll !== vScroll;
|
var vScrollChanged = this.$vScroll !== vScroll;
|
||||||
if (vScrollChanged) {
|
if (vScrollChanged) {
|
||||||
this.$vScroll = vScroll;
|
this.$vScroll = vScroll;
|
||||||
|
|
|
||||||
|
|
@ -36,26 +36,40 @@ if (typeof process !== "undefined") {
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var Editor = require("./edit_session").Editor;
|
||||||
var EditSession = require("./edit_session").EditSession;
|
var EditSession = require("./edit_session").EditSession;
|
||||||
var VirtualRenderer = require("./virtual_renderer").VirtualRenderer;
|
var VirtualRenderer = require("./virtual_renderer").VirtualRenderer;
|
||||||
var assert = require("./test/assertions");
|
var assert = require("./test/assertions");
|
||||||
|
|
||||||
|
var editor = null;
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"test: screen2text the column should be rounded to the next character edge" : function() {
|
setUp: function() {
|
||||||
|
if (editor)
|
||||||
|
editor.destroy()
|
||||||
var el = document.createElement("div");
|
var el = document.createElement("div");
|
||||||
|
|
||||||
if (!el.getBoundingClientRect) {
|
if (!el.getBoundingClientRect) {
|
||||||
console.log("Skipping test: This test only runs in the browser");
|
console.log("Skipping test: This test only runs in the browser");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
el.style.left = "20px";
|
el.style.left = "20px";
|
||||||
el.style.top = "30px";
|
el.style.top = "30px";
|
||||||
el.style.width = "300px";
|
el.style.width = "300px";
|
||||||
el.style.height = "100px";
|
el.style.height = "100px";
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
|
|
||||||
var renderer = new VirtualRenderer(el);
|
var renderer = new VirtualRenderer(el);
|
||||||
|
var editor = new Editor(renderer);
|
||||||
|
editor.on("destroy", function() {
|
||||||
|
document.body.removeChild(el);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
tearDown: function() {
|
||||||
|
editor && editor.destroy();
|
||||||
|
editor = null;
|
||||||
|
},
|
||||||
|
"test: screen2text the column should be rounded to the next character edge" : function(done) {
|
||||||
|
if (!editor) return done();
|
||||||
|
var renderer = editor.renderer;
|
||||||
|
|
||||||
renderer.setPadding(0);
|
renderer.setPadding(0);
|
||||||
renderer.setSession(new EditSession("1234"));
|
renderer.setSession(new EditSession("1234"));
|
||||||
|
|
||||||
|
|
@ -73,7 +87,23 @@ module.exports = {
|
||||||
testPixelToText(10, 0, 0, 1);
|
testPixelToText(10, 0, 0, 1);
|
||||||
testPixelToText(14, 0, 0, 1);
|
testPixelToText(14, 0, 0, 1);
|
||||||
testPixelToText(15, 0, 0, 2);
|
testPixelToText(15, 0, 0, 2);
|
||||||
document.body.removeChild(el);
|
done();
|
||||||
|
},
|
||||||
|
|
||||||
|
"test scrollmargin + autosize": function(done) {
|
||||||
|
if (!editor) return done();
|
||||||
|
editor.setOptions({
|
||||||
|
maxLines: 100,
|
||||||
|
useWrapMode: true
|
||||||
|
});
|
||||||
|
editor.renderer.setScrollMargin(10, 10);
|
||||||
|
editor.setValue("\n\n");
|
||||||
|
editor.setValue("\n\n\n\n");
|
||||||
|
editor.renderer.once("afterRender", function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
done();
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// change tab size after setDocument (for text layer)
|
// change tab size after setDocument (for text layer)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
"no use strict";
|
"no use strict";
|
||||||
;(function(window) {
|
;(function(window) {
|
||||||
if (typeof window.window != "undefined" && window.document) {
|
if (typeof window.window != "undefined" && window.document)
|
||||||
|
return;
|
||||||
|
if (window.require && window.define)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
window.console = function() {
|
window.console = function() {
|
||||||
var msgs = Array.prototype.slice.call(arguments, 0);
|
var msgs = Array.prototype.slice.call(arguments, 0);
|
||||||
|
|
@ -19,6 +20,7 @@ window.ace = window;
|
||||||
window.onerror = function(message, file, line, col, err) {
|
window.onerror = function(message, file, line, col, err) {
|
||||||
postMessage({type: "error", data: {
|
postMessage({type: "error", data: {
|
||||||
message: message,
|
message: message,
|
||||||
|
data: err.data,
|
||||||
file: file,
|
file: file,
|
||||||
line: line,
|
line: line,
|
||||||
col: col,
|
col: col,
|
||||||
|
|
@ -37,7 +39,7 @@ window.normalizeModule = function(parentId, moduleName) {
|
||||||
var base = parentId.split("/").slice(0, -1).join("/");
|
var base = parentId.split("/").slice(0, -1).join("/");
|
||||||
moduleName = (base ? base + "/" : "") + moduleName;
|
moduleName = (base ? base + "/" : "") + moduleName;
|
||||||
|
|
||||||
while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
|
while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
|
||||||
var previous = moduleName;
|
var previous = moduleName;
|
||||||
moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
|
moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +48,7 @@ window.normalizeModule = function(parentId, moduleName) {
|
||||||
return moduleName;
|
return moduleName;
|
||||||
};
|
};
|
||||||
|
|
||||||
window.require = function(parentId, id) {
|
window.require = function require(parentId, id) {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
id = parentId;
|
id = parentId;
|
||||||
parentId = null;
|
parentId = null;
|
||||||
|
|
@ -65,16 +67,35 @@ window.require = function(parentId, id) {
|
||||||
return module.exports;
|
return module.exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
var chunks = id.split("/");
|
|
||||||
if (!window.require.tlns)
|
if (!window.require.tlns)
|
||||||
return console.log("unable to load " + id);
|
return console.log("unable to load " + id);
|
||||||
chunks[0] = window.require.tlns[chunks[0]] || chunks[0];
|
|
||||||
var path = chunks.join("/") + ".js";
|
var path = resolveModuleId(id, window.require.tlns);
|
||||||
|
if (path.slice(-3) != ".js") path += ".js";
|
||||||
|
|
||||||
window.require.id = id;
|
window.require.id = id;
|
||||||
|
window.require.modules[id] = {}; // prevent infinite loop on broken modules
|
||||||
importScripts(path);
|
importScripts(path);
|
||||||
return window.require(parentId, id);
|
return window.require(parentId, id);
|
||||||
};
|
};
|
||||||
|
function resolveModuleId(id, paths) {
|
||||||
|
var testPath = id, tail = "";
|
||||||
|
while (testPath) {
|
||||||
|
var alias = paths[testPath];
|
||||||
|
if (typeof alias == "string") {
|
||||||
|
return alias + tail;
|
||||||
|
} else if (alias) {
|
||||||
|
return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
|
||||||
|
} else if (alias === false) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
var i = testPath.lastIndexOf("/");
|
||||||
|
if (i === -1) break;
|
||||||
|
tail = testPath.substr(i) + tail;
|
||||||
|
testPath = testPath.slice(0, i);
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
window.require.modules = {};
|
window.require.modules = {};
|
||||||
window.require.tlns = {};
|
window.require.tlns = {};
|
||||||
|
|
||||||
|
|
@ -100,9 +121,9 @@ window.define = function(id, deps, factory) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deps.length)
|
if (!deps.length)
|
||||||
// If there is no dependencies, we inject 'require', 'exports' and
|
// If there is no dependencies, we inject "require", "exports" and
|
||||||
// 'module' as dependencies, to provide CommonJS compatibility.
|
// "module" as dependencies, to provide CommonJS compatibility.
|
||||||
deps = ['require', 'exports', 'module'];
|
deps = ["require", "exports", "module"];
|
||||||
|
|
||||||
var req = function(childId) {
|
var req = function(childId) {
|
||||||
return window.require(id, childId);
|
return window.require(id, childId);
|
||||||
|
|
@ -113,16 +134,16 @@ window.define = function(id, deps, factory) {
|
||||||
factory: function() {
|
factory: function() {
|
||||||
var module = this;
|
var module = this;
|
||||||
var returnExports = factory.apply(this, deps.map(function(dep) {
|
var returnExports = factory.apply(this, deps.map(function(dep) {
|
||||||
switch(dep) {
|
switch (dep) {
|
||||||
// Because 'require', 'exports' and 'module' aren't actual
|
// Because "require", "exports" and "module" aren't actual
|
||||||
// dependencies, we must handle them seperately.
|
// dependencies, we must handle them seperately.
|
||||||
case 'require': return req;
|
case "require": return req;
|
||||||
case 'exports': return module.exports;
|
case "exports": return module.exports;
|
||||||
case 'module': return module;
|
case "module": return module;
|
||||||
// But for all other dependencies, we can just go ahead and
|
// But for all other dependencies, we can just go ahead and
|
||||||
// require them.
|
// require them.
|
||||||
default: return req(dep);
|
default: return req(dep);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
if (returnExports)
|
if (returnExports)
|
||||||
module.exports = returnExports;
|
module.exports = returnExports;
|
||||||
|
|
@ -131,9 +152,10 @@ window.define = function(id, deps, factory) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
window.define.amd = {};
|
window.define.amd = {};
|
||||||
|
require.tlns = {};
|
||||||
window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
|
window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
|
||||||
require.tlns = topLevelNamespaces;
|
for (var i in topLevelNamespaces)
|
||||||
|
require.tlns[i] = topLevelNamespaces[i];
|
||||||
};
|
};
|
||||||
|
|
||||||
window.initSender = function initSender() {
|
window.initSender = function initSender() {
|
||||||
|
|
@ -173,21 +195,23 @@ var sender = window.sender = null;
|
||||||
|
|
||||||
window.onmessage = function(e) {
|
window.onmessage = function(e) {
|
||||||
var msg = e.data;
|
var msg = e.data;
|
||||||
if (msg.command) {
|
if (msg.event && sender) {
|
||||||
|
sender._signal(msg.event, msg.data);
|
||||||
|
}
|
||||||
|
else if (msg.command) {
|
||||||
if (main[msg.command])
|
if (main[msg.command])
|
||||||
main[msg.command].apply(main, msg.args);
|
main[msg.command].apply(main, msg.args);
|
||||||
|
else if (window[msg.command])
|
||||||
|
window[msg.command].apply(window, msg.args);
|
||||||
else
|
else
|
||||||
throw new Error("Unknown command:" + msg.command);
|
throw new Error("Unknown command:" + msg.command);
|
||||||
}
|
}
|
||||||
else if (msg.init) {
|
else if (msg.init) {
|
||||||
initBaseUrls(msg.tlns);
|
window.initBaseUrls(msg.tlns);
|
||||||
require("ace/lib/es5-shim");
|
require("ace/lib/es5-shim");
|
||||||
sender = window.sender = initSender();
|
sender = window.sender = window.initSender();
|
||||||
var clazz = require(msg.module)[msg.classname];
|
var clazz = require(msg.module)[msg.classname];
|
||||||
main = window.main = new clazz(sender);
|
main = window.main = new clazz(sender);
|
||||||
}
|
}
|
||||||
else if (msg.event && sender) {
|
|
||||||
sender._signal(msg.event, msg.data);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
})(this);
|
})(this);
|
||||||
|
|
@ -21,7 +21,7 @@ http.createServer(function(req, res) {
|
||||||
if (req.method == "PUT") {
|
if (req.method == "PUT") {
|
||||||
if (!allowSave)
|
if (!allowSave)
|
||||||
return error(res, 404, "Saving not allowed pass --allow-save to enable");
|
return error(res, 404, "Saving not allowed pass --allow-save to enable");
|
||||||
save(req, res, filename);
|
return save(req, res, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.exists(filename, function(exists) {
|
fs.exists(filename, function(exists) {
|
||||||
|
|
@ -86,6 +86,7 @@ function save(req, res, filePath) {
|
||||||
}
|
}
|
||||||
res.statusCode = 200;
|
res.statusCode = 200;
|
||||||
res.end("OK");
|
res.end("OK");
|
||||||
|
console.log("saved ", filePath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
110
tool/lib.js
110
tool/lib.js
|
|
@ -1,6 +1,7 @@
|
||||||
var plist = require("plist");
|
var plist = require("plist");
|
||||||
var util = require("util");
|
var util = require("util");
|
||||||
var url = require("url");
|
var url = require("url");
|
||||||
|
var cson = require("cson");
|
||||||
|
|
||||||
var https = require("https");
|
var https = require("https");
|
||||||
var http = require("http");
|
var http = require("http");
|
||||||
|
|
@ -12,17 +13,120 @@ exports.parsePlist = function(xmlOrJSON, callback) {
|
||||||
json = result[0];
|
json = result[0];
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
xmlOrJSON = xmlOrJSON.replace(/^\s*\/\/.*/gm, "");
|
try {
|
||||||
json = JSON.parse(xmlOrJSON)
|
xmlOrJSON = xmlOrJSON.replace(
|
||||||
|
/("(?:\\.|[^"])*")|(?:,\s*)+([\]\}])|(\w+)\s*:|([\]\}]\s*[\[\{])|(\/\/.*|\/\*(?:[^\*]|\*(?=[^\/]))*?\*\/)/g,
|
||||||
|
function(_, str, extraComma, noQuote, missingComma, comment) {
|
||||||
|
if (comment)
|
||||||
|
return "";
|
||||||
|
if (missingComma)
|
||||||
|
return missingComma[0] + "," + missingComma.slice(1);
|
||||||
|
return str || extraComma || '"' + noQuote + '":';
|
||||||
|
});
|
||||||
|
json = JSON.parse(xmlOrJSON);
|
||||||
|
} catch(e) {
|
||||||
|
json = cson.parse(xmlOrJSON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
callback && callback(json);
|
callback && callback(json);
|
||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
exports.formatJSON = function(object, initialIndent) {
|
exports.formatJSON = function(object, initialIndent) {
|
||||||
return util.inspect(object, false, 40).replace(/^/gm, initialIndent||"");
|
return JSON.stringify(object, null, 4).replace(/^/gm, initialIndent||"");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.formatJS = function(object, initialIndent) {
|
||||||
|
return formatJS(object, 4, initialIndent);
|
||||||
|
};
|
||||||
|
|
||||||
|
function formatJS(object, indent, initialIndent) {
|
||||||
|
if (typeof indent == "number")
|
||||||
|
indent = Array(indent + 1).join(" ");
|
||||||
|
|
||||||
|
function $format(buffer, totalIndent, state, o) {
|
||||||
|
if (typeof o != "object" || !o) {
|
||||||
|
if (typeof o == "string")
|
||||||
|
buffer.push(JSON.stringify(o));
|
||||||
|
else
|
||||||
|
buffer.push("" + o);
|
||||||
|
}
|
||||||
|
else if (Array.isArray(o)) {
|
||||||
|
buffer.push("[")
|
||||||
|
|
||||||
|
var len = totalIndent.length
|
||||||
|
var oneLine = true;
|
||||||
|
for (var i = 0; i < o.length; i++) {
|
||||||
|
if (typeof o[i] == "string") {
|
||||||
|
len += o[i].length + 2
|
||||||
|
} else if (!o[i]) {
|
||||||
|
len += (o[i] + "").length
|
||||||
|
} else {
|
||||||
|
oneLine = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
len += 2;
|
||||||
|
if (len > 60) {
|
||||||
|
oneLine = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < o.length; i++) {
|
||||||
|
if (o[i] && typeof o[i] == "object") {
|
||||||
|
$format(buffer, totalIndent, state, o[i]);
|
||||||
|
if (i < o.length - 1)
|
||||||
|
buffer.push(", ");
|
||||||
|
} else {
|
||||||
|
if (oneLine)
|
||||||
|
i && buffer.push(" ");
|
||||||
|
else
|
||||||
|
buffer.push("\n", totalIndent + indent)
|
||||||
|
$format(buffer, totalIndent + indent, state, o[i]);
|
||||||
|
if (i < o.length - 1)
|
||||||
|
buffer.push(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!oneLine && buffer[buffer.length - 1] != "}")
|
||||||
|
buffer.push("\n" + totalIndent)
|
||||||
|
buffer.push("]")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var keys = Object.keys(o);
|
||||||
|
buffer.push("{", "\n");
|
||||||
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
buffer.push(totalIndent + indent);
|
||||||
|
if (/^\w+$/.test(keys[i]))
|
||||||
|
buffer.push(keys[i]);
|
||||||
|
else
|
||||||
|
buffer.push(JSON.stringify(keys[i]));
|
||||||
|
buffer.push(": ")
|
||||||
|
|
||||||
|
if (keys[i] == "regex" && typeof o[keys[i]] == "string") {
|
||||||
|
try {
|
||||||
|
var re = new RegExp(o[keys[i]]);
|
||||||
|
buffer.push("/" + re.source.replace(/\\.|\//g, function(f) {
|
||||||
|
return f.length == 1 ? "\\" + f : f;
|
||||||
|
}) + "/");
|
||||||
|
} catch(e) {
|
||||||
|
$format(buffer, totalIndent + indent, state, o[keys[i]]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$format(buffer, totalIndent + indent, state, o[keys[i]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < keys.length - 1)
|
||||||
|
buffer.push(",", "\n");
|
||||||
|
}
|
||||||
|
buffer.push("\n", totalIndent, "}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var buffer = [];
|
||||||
|
$format(buffer, initialIndent || "", {}, object);
|
||||||
|
return buffer.join("");
|
||||||
|
}
|
||||||
|
|
||||||
exports.fillTemplate = function(template, replacements) {
|
exports.fillTemplate = function(template, replacements) {
|
||||||
return template.replace(/%(.+?)%/g, function(str, m) {
|
return template.replace(/%(.+?)%/g, function(str, m) {
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,8 @@ function handleSaveResult(err, editor) {
|
||||||
return log(
|
return log(
|
||||||
"Write access to this file is disabled.\n"+
|
"Write access to this file is disabled.\n"+
|
||||||
"To enable saving your changes to disk, clone the Ace repository\n"+
|
"To enable saving your changes to disk, clone the Ace repository\n"+
|
||||||
"and run the included web server with the --allow-write option\n"+
|
"and run the included web server with the --allow-save option\n"+
|
||||||
"`node static.js --allow-write` or `static.py --puttable=*`"
|
"`node static.js --allow-save` or `static.py --puttable=*`"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
editor.session.getUndoManager().markClean();
|
editor.session.getUndoManager().markClean();
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "ace-tools",
|
"name": "ace-tools",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"plist": "",
|
"cson": "^3.0.1",
|
||||||
"css-parse": "1.0.3",
|
"css-parse": "1.0.3",
|
||||||
"css-stringify": "1.0.3"
|
"css-stringify": "1.0.3",
|
||||||
}
|
"plist": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -662,10 +662,10 @@ function convertTmLanguage(name, langStr) {
|
||||||
|
|
||||||
var languageHighlightRules = lib.fillTemplate(modeHighlightTemplate, {
|
var languageHighlightRules = lib.fillTemplate(modeHighlightTemplate, {
|
||||||
language: languageNameSanitized,
|
language: languageNameSanitized,
|
||||||
languageTokens: lib.formatJSON(patterns, " ").trim(),
|
languageTokens: lib.formatJS(patterns, " ").trim(),
|
||||||
uuid: language.uuid,
|
uuid: language.uuid,
|
||||||
name: name,
|
name: name,
|
||||||
metaData: lib.formatJSON(language, " ").trim()
|
metaData: lib.formatJS(language, "").trim()
|
||||||
});
|
});
|
||||||
|
|
||||||
if (devMode) {
|
if (devMode) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue