Merge branch 'master' of git://github.com/ajaxorg/ace into praat
This commit is contained in:
commit
5ebcf9298b
56 changed files with 2476 additions and 1092 deletions
|
|
@ -1,3 +1,13 @@
|
|||
2014.07.01 Version 1.1.4
|
||||
|
||||
* New Features
|
||||
- Highlight matching tags (Adam Jimenez)
|
||||
- Improved jump to matching command (Adam Jimenez)
|
||||
|
||||
* new language modes
|
||||
- AppleScript (Yaogang Lian)
|
||||
- Vala
|
||||
|
||||
2014.03.08 Version 1.1.3
|
||||
|
||||
* New Features
|
||||
|
|
|
|||
1
Makefile
1
Makefile
|
|
@ -13,7 +13,6 @@ pre_build:
|
|||
build: pre_build
|
||||
./Makefile.dryice.js normal
|
||||
./Makefile.dryice.js demo
|
||||
./Makefile.dryice.js bm
|
||||
|
||||
# Minimal build: call Makefile.dryice.js only if our sources changed
|
||||
basic: build/src/ace.js
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
2
build
2
build
|
|
@ -1 +1 @@
|
|||
Subproject commit fc9d2cae9fe8e6e95e74c86a31d21caadd8f9f39
|
||||
Subproject commit b85b38c1e33e161826f4dd7774ef73aac55e0d14
|
||||
|
|
@ -20,7 +20,7 @@ function foo() {
|
|||
var bar = true;
|
||||
}</textarea><br>
|
||||
SourceUrl: <br>
|
||||
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/textarea/src/"></input><br>
|
||||
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/src-noconflict"></input><br>
|
||||
<button id="buBuild">Build Link</button> <br> <a href="#"></a>
|
||||
<a href="https://github.com/ajaxorg/ace/">
|
||||
<div class="fork_on_github" ></div>
|
||||
|
|
@ -49,63 +49,60 @@ function foo() {
|
|||
|
||||
<script>
|
||||
|
||||
function inject(callback) {
|
||||
var baseUrl = "src/";
|
||||
function inject(options, callback) {
|
||||
var baseUrl = options.baseUrl || "../../src-noconflict";
|
||||
|
||||
var load = window.__ace_loader__ = function(path, module, callback) {
|
||||
var load = function(path, callback) {
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var s = document.createElement('script');
|
||||
|
||||
s.src = baseUrl + path;
|
||||
|
||||
s.src = baseUrl + "/" + path;
|
||||
head.appendChild(s);
|
||||
|
||||
s.onload = function() {
|
||||
window.__ace_shadowed__.require([module], callback);
|
||||
|
||||
s.onload = s.onreadystatechange = function(_, isAbort) {
|
||||
if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
|
||||
s = s.onload = s.onreadystatechange = null;
|
||||
if (!isAbort)
|
||||
callback();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
load('ace-bookmarklet.js', "ace/ext/textarea", function() {
|
||||
var ace = window.__ace_shadowed__;
|
||||
|
||||
ace.options.mode = "javascript";
|
||||
var Event = ace.require("ace/lib/event");
|
||||
var areas = document.getElementsByTagName("textarea");
|
||||
for (var i = 0; i < areas.length; i++) {
|
||||
Event.addListener(areas[i], "click", function(e) {
|
||||
if (e.detail == 3) {
|
||||
ace.transformTextarea(e.target, load);
|
||||
}
|
||||
});
|
||||
}
|
||||
callback && callback();
|
||||
load("ace.js", function() {
|
||||
ace.config.loadModule("ace/ext/textarea", function() {
|
||||
var event = ace.require("ace/lib/event");
|
||||
var areas = document.getElementsByTagName("textarea");
|
||||
for (var i = 0; i < areas.length; i++) {
|
||||
event.addListener(areas[i], "click", function(e) {
|
||||
if (e.detail == 3) {
|
||||
ace.transformTextarea(e.target, options.ace);
|
||||
}
|
||||
});
|
||||
}
|
||||
callback && callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Call the inject function to load the ace files.
|
||||
var textAce;
|
||||
inject(function () {
|
||||
// Transform the textarea on the page into an ace editor.
|
||||
var ace = window.__ace_shadowed__;
|
||||
inject({}, function () {
|
||||
// Transform the textarea on the page into an ace editor.
|
||||
var t = document.querySelector("textarea");
|
||||
textAce = ace.transformTextarea(t, window.__ace_loader__);
|
||||
textAce = ace.require("ace/ext/textarea").transformTextarea(t);
|
||||
setTimeout(function(){textAce.setDisplaySettings(true)});
|
||||
});
|
||||
|
||||
|
||||
document.getElementById("buBuild").onclick = function() {
|
||||
var injectSrc = inject.toString().split("\n").join("");
|
||||
injectSrc = injectSrc.replace('baseUrl = "src/"', 'baseUrl="' + document.getElementById("srcURL").value + '"');
|
||||
|
||||
var aceOptions = textAce.getOptions();
|
||||
var opt = [];
|
||||
for (var option in aceOptions) {
|
||||
opt.push(option + ":'" + aceOptions[option] + "'");
|
||||
}
|
||||
injectSrc = injectSrc.replace('ace.options.mode = "javascript"', 'ace.options = { ' + opt.join(",") + ' }');
|
||||
injectSrc = injectSrc.replace(/\s+/g, " ");
|
||||
|
||||
var options = textAce.getOptions();
|
||||
options.baseUrl = document.getElementById("srcURL").value;
|
||||
|
||||
var a = document.querySelector("a");
|
||||
a.href = "javascript:(" + injectSrc + ")()";
|
||||
a.href = "javascript:(" + injectSrc + ")(" + JSON.stringify(options) + ")";
|
||||
a.innerHTML = "Ace Bookmarklet Link";
|
||||
}
|
||||
|
||||
|
|
@ -26,28 +26,32 @@
|
|||
<div class="scrollmargin"></div>
|
||||
<pre id="editor"></pre>
|
||||
|
||||
<script src="../build/src/ace.js"></script>
|
||||
<script src="kitchen-sink/require.js"></script>
|
||||
<script>
|
||||
// setup paths
|
||||
require.config({paths: { "ace" : "../lib/ace"}});
|
||||
// load ace and extensions
|
||||
require(["ace/ace"], function(ace) {
|
||||
|
||||
var editor1 = ace.edit("editor1");
|
||||
editor1.setTheme("ace/theme/tomorrow_night_eighties");
|
||||
editor1.session.setMode("ace/mode/html");
|
||||
editor1.setAutoScrollEditorIntoView(true);
|
||||
editor1.setOption("maxLines", 30);
|
||||
var editor1 = ace.edit("editor1");
|
||||
editor1.setTheme("ace/theme/tomorrow_night_eighties");
|
||||
editor1.session.setMode("ace/mode/html");
|
||||
editor1.setAutoScrollEditorIntoView(true);
|
||||
editor1.setOption("maxLines", 30);
|
||||
|
||||
var editor2 = ace.edit("editor2");
|
||||
editor2.setTheme("ace/theme/tomorrow_night_blue");
|
||||
editor2.session.setMode("ace/mode/html");
|
||||
editor2.setAutoScrollEditorIntoView(true);
|
||||
editor2.setOption("maxLines", 30);
|
||||
editor2.setOption("minLines", 2);
|
||||
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/tomorrow");
|
||||
editor.session.setMode("ace/mode/html");
|
||||
editor.setAutoScrollEditorIntoView(true);
|
||||
editor.setOption("maxLines", 100);
|
||||
var editor2 = ace.edit("editor2");
|
||||
editor2.setTheme("ace/theme/tomorrow_night_blue");
|
||||
editor2.session.setMode("ace/mode/html");
|
||||
editor2.setAutoScrollEditorIntoView(true);
|
||||
editor2.setOption("maxLines", 30);
|
||||
editor2.setOption("minLines", 2);
|
||||
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/tomorrow");
|
||||
editor.session.setMode("ace/mode/html");
|
||||
editor.setAutoScrollEditorIntoView(true);
|
||||
editor.setOption("maxLines", 100);
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="./show_own_source.js"></script>
|
||||
|
|
|
|||
|
|
@ -592,7 +592,7 @@ env.editSnippets = function() {
|
|||
require("ace/ext/language_tools");
|
||||
env.editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: true,
|
||||
enableLiveAutocompletion: false,
|
||||
enableSnippets: true
|
||||
});
|
||||
|
||||
|
|
|
|||
11
demo/kitchen-sink/docs/.gitignore
vendored
Normal file
11
demo/kitchen-sink/docs/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# A sample .gitignore file.
|
||||
|
||||
.buildlog
|
||||
.DS_Store
|
||||
.svn
|
||||
|
||||
# Negated patterns:
|
||||
!foo.bar
|
||||
|
||||
# Also ignore user settings...
|
||||
/.settings
|
||||
21
demo/kitchen-sink/docs/vala.vala
Normal file
21
demo/kitchen-sink/docs/vala.vala
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using Gtk;
|
||||
|
||||
int main (string[] args) {
|
||||
Gtk.init (ref args);
|
||||
var foo = new MyFoo<string[](), MyBar<string, int>>();
|
||||
|
||||
var window = new Window();
|
||||
window.title = "Hello, World!";
|
||||
window.border_width = 10;
|
||||
window.window_position = WindowPosition.CENTER;
|
||||
window.set_default_size(350, 70);
|
||||
window.destroy.connect(Gtk.main_quit);
|
||||
|
||||
var label = new Label("Hello, World!");
|
||||
|
||||
window.add(label);
|
||||
window.show_all();
|
||||
|
||||
Gtk.main();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -29,14 +29,20 @@
|
|||
}</pre>
|
||||
|
||||
<script src="../demo/kitchen-sink/require.js"></script>
|
||||
<script src="../build/src/ace.js" charset="utf-8"></script>
|
||||
<script>
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
editor.session.setMode("ace/mode/javascript");
|
||||
require(["ace/requirejs/text!src/ace"], function(e){
|
||||
editor.setValue(e);
|
||||
})
|
||||
require.config({paths: {ace: "../build/src"}})
|
||||
define('testace', ['ace/ace'],
|
||||
function(ace, langtools) {
|
||||
console.log("This is the testace module");
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
editor.session.setMode("ace/mode/javascript");
|
||||
require(["ace/requirejs/text!src/ace"], function(e){
|
||||
editor.setValue(e);
|
||||
})
|
||||
}
|
||||
);
|
||||
require(['testace'])
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -11,16 +11,10 @@
|
|||
commit %commit%
|
||||
-->
|
||||
|
||||
<!--DEVEL-->
|
||||
<link rel="stylesheet" href="demo/kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
|
||||
<script async="true" src="https://use.edgefonts.net/source-code-pro.js"></script>
|
||||
<!--DEVEL-->
|
||||
<link rel="stylesheet" href="demo/kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
|
||||
<script async="true" src="https://use.edgefonts.net/source-code-pro.js"></script>
|
||||
|
||||
<link href="./doc/site/images/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<!--PACKAGE
|
||||
<link rel="stylesheet" href="kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
|
||||
<script async="true" src="https://use.edgefonts.net/source-code-pro.js"></script>
|
||||
PACKAGE-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="optionsPanel" style="position:absolute;height:100%;width:260px">
|
||||
|
|
@ -287,7 +281,7 @@
|
|||
<script src="src/ace.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="src/keybinding-vim.js"></script>
|
||||
<script src="src/keybinding-emacs.js"></script>
|
||||
<script src="kitchen-sink/demo.js"></script>
|
||||
<script src="demo/kitchen-sink/demo.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
require("kitchen-sink/demo");
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -101,12 +101,12 @@ var Autocomplete = function() {
|
|||
this.changeTimer.cancel();
|
||||
|
||||
if (this.popup && this.popup.isOpen) {
|
||||
this.gatherCompletionsId = this.gatherCompletionsId + 1;
|
||||
}
|
||||
|
||||
if (this.popup)
|
||||
this.gatherCompletionsId += 1;
|
||||
this.popup.hide();
|
||||
|
||||
}
|
||||
|
||||
if (this.base)
|
||||
this.base.detach();
|
||||
this.activated = false;
|
||||
this.completions = this.base = null;
|
||||
};
|
||||
|
|
@ -205,8 +205,7 @@ var Autocomplete = function() {
|
|||
var line = session.getLine(pos.row);
|
||||
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
||||
|
||||
this.base = editor.getCursorPosition();
|
||||
this.base.column -= prefix.length;
|
||||
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
|
||||
|
||||
var matches = [];
|
||||
var total = editor.completers.length;
|
||||
|
|
@ -306,13 +305,7 @@ var Autocomplete = function() {
|
|||
};
|
||||
|
||||
this.cancelContextMenu = function() {
|
||||
var stop = function(e) {
|
||||
this.editor.off("nativecontextmenu", stop);
|
||||
if (e && e.domEvent)
|
||||
event.stopEvent(e.domEvent);
|
||||
}.bind(this);
|
||||
setTimeout(stop, 10);
|
||||
this.editor.on("nativecontextmenu", stop);
|
||||
this.editor.$mouseHandler.cancelContextMenu();
|
||||
};
|
||||
|
||||
}).call(Autocomplete.prototype);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ var AcePopup = function(parentNode) {
|
|||
popup.renderer.setStyle("ace_autocomplete");
|
||||
|
||||
popup.setOption("displayIndentGuides", false);
|
||||
popup.setOption("dragDelay", 150);
|
||||
|
||||
var noop = function(){};
|
||||
|
||||
|
|
@ -178,7 +179,7 @@ var AcePopup = function(parentNode) {
|
|||
if (typeof data == "string")
|
||||
data = {value: data};
|
||||
if (!data.caption)
|
||||
data.caption = data.value;
|
||||
data.caption = data.value || data.name;
|
||||
|
||||
var last = -1;
|
||||
var flag, c;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ define(function(require, exports, module) {
|
|||
var wordList = Object.keys(wordScore);
|
||||
callback(null, wordList.map(function(word) {
|
||||
return {
|
||||
name: word,
|
||||
caption: word,
|
||||
value: word,
|
||||
score: wordScore[word],
|
||||
meta: "local"
|
||||
|
|
|
|||
|
|
@ -392,17 +392,23 @@ exports.commands = [{
|
|||
readOnly: true
|
||||
}, {
|
||||
name: "jumptomatching",
|
||||
bindKey: bindKey("Ctrl-P", "Ctrl-Shift-P"),
|
||||
bindKey: bindKey("Ctrl-P", "Ctrl-P"),
|
||||
exec: function(editor) { editor.jumpToMatching(); },
|
||||
multiSelectAction: "forEach",
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "selecttomatching",
|
||||
bindKey: bindKey("Ctrl-Shift-P", null),
|
||||
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
|
||||
exec: function(editor) { editor.jumpToMatching(true); },
|
||||
multiSelectAction: "forEach",
|
||||
readOnly: true
|
||||
},
|
||||
}, {
|
||||
name: "passKeysToBrowser",
|
||||
bindKey: bindKey("null", "null"),
|
||||
exec: function() {},
|
||||
passEvent: true,
|
||||
readOnly: true
|
||||
},
|
||||
|
||||
// commands disabled in readOnly mode
|
||||
{
|
||||
|
|
|
|||
|
|
@ -153,7 +153,11 @@ function init(packaged) {
|
|||
var scriptOptions = {};
|
||||
var scriptUrl = "";
|
||||
|
||||
var scripts = document.getElementsByTagName("script");
|
||||
// Use currentScript.ownerDocument in case this file was loaded from imported document. (HTML Imports)
|
||||
var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
|
||||
var currentDocument = currentScript && currentScript.ownerDocument || document;
|
||||
|
||||
var scripts = currentDocument.getElementsByTagName("script");
|
||||
for (var i=0; i<scripts.length; i++) {
|
||||
var script = scripts[i];
|
||||
|
||||
|
|
|
|||
|
|
@ -485,15 +485,15 @@ function Folding() {
|
|||
};
|
||||
|
||||
this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
|
||||
if (startRow == null) {
|
||||
if (startRow == null)
|
||||
startRow = foldLine.start.row;
|
||||
if (startColumn == null)
|
||||
startColumn = 0;
|
||||
}
|
||||
|
||||
if (endRow == null) {
|
||||
if (endRow == null)
|
||||
endRow = foldLine.end.row;
|
||||
if (endColumn == null)
|
||||
endColumn = this.getLine(endRow).length;
|
||||
}
|
||||
|
||||
|
||||
// Build the textline using the FoldLine walker.
|
||||
var doc = this.doc;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
|||
var CommandManager = require("./commands/command_manager").CommandManager;
|
||||
var defaultCommands = require("./commands/default_commands").commands;
|
||||
var config = require("./config");
|
||||
var TokenIterator = require("./token_iterator").TokenIterator;
|
||||
|
||||
/**
|
||||
* The main entry point into the Ace functionality.
|
||||
|
|
@ -210,13 +211,14 @@ var Editor = function(renderer, session) {
|
|||
}
|
||||
};
|
||||
|
||||
// TODO use property on commands instead of this
|
||||
this.$mergeableCommands = ["backspace", "del", "insertstring"];
|
||||
this.$historyTracker = function(e) {
|
||||
if (!this.$mergeUndoDeltas)
|
||||
return;
|
||||
|
||||
|
||||
var prev = this.prevOp;
|
||||
var mergeableCommands = ["backspace", "del", "insertstring"];
|
||||
var mergeableCommands = this.$mergeableCommands;
|
||||
// previous command was the same
|
||||
var shouldMerge = prev.command && (e.command.name == prev.command.name);
|
||||
if (e.command.name == "insertstring") {
|
||||
|
|
@ -535,6 +537,89 @@ var Editor = function(renderer, session) {
|
|||
}, 50);
|
||||
};
|
||||
|
||||
// todo: move to mode.getMatching
|
||||
this.$highlightTags = function() {
|
||||
var session = this.session;
|
||||
|
||||
if (this.$highlightTagPending) {
|
||||
return;
|
||||
}
|
||||
|
||||
// perform highlight async to not block the browser during navigation
|
||||
var self = this;
|
||||
this.$highlightTagPending = true;
|
||||
setTimeout(function() {
|
||||
self.$highlightTagPending = false;
|
||||
|
||||
var pos = self.getCursorPosition();
|
||||
var iterator = new TokenIterator(self.session, pos.row, pos.column);
|
||||
var token = iterator.getCurrentToken();
|
||||
|
||||
if (!token || token.type.indexOf('tag-name') === -1) {
|
||||
session.removeMarker(session.$tagHighlight);
|
||||
session.$tagHighlight = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var tag = token.value;
|
||||
var depth = 0;
|
||||
var prevToken = iterator.stepBackward();
|
||||
|
||||
if (prevToken.value == '<'){
|
||||
//find closing tag
|
||||
do {
|
||||
prevToken = token;
|
||||
token = iterator.stepForward();
|
||||
|
||||
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
|
||||
if (prevToken.value==='<'){
|
||||
depth++;
|
||||
} else if (prevToken.value==='</'){
|
||||
depth--;
|
||||
}
|
||||
}
|
||||
|
||||
} while (token && depth>=0);
|
||||
}else{
|
||||
//find opening tag
|
||||
do {
|
||||
token = prevToken;
|
||||
prevToken = iterator.stepBackward();
|
||||
|
||||
if(token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
|
||||
if (prevToken.value==='<') {
|
||||
depth++;
|
||||
} else if( prevToken.value==='</') {
|
||||
depth--;
|
||||
}
|
||||
}
|
||||
} while (prevToken && depth<=0);
|
||||
|
||||
//select tag again
|
||||
iterator.stepForward();
|
||||
}
|
||||
|
||||
if (!token) {
|
||||
session.removeMarker(session.$tagHighlight);
|
||||
session.$tagHighlight = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var row = iterator.getCurrentTokenRow();
|
||||
var column = iterator.getCurrentTokenColumn();
|
||||
var range = new Range(row, column, row, column+token.value.length);
|
||||
|
||||
//remove range if different
|
||||
if (session.$tagHighlight && range.compareRange(session.$backMarkers[session.$tagHighlight].range)!==0) {
|
||||
session.removeMarker(session.$tagHighlight);
|
||||
session.$tagHighlight = null;
|
||||
}
|
||||
|
||||
if (range && !session.$tagHighlight)
|
||||
session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
|
||||
}, 50);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Brings the current `textInput` into focus.
|
||||
|
|
@ -651,6 +736,7 @@ var Editor = function(renderer, session) {
|
|||
}
|
||||
|
||||
this.$highlightBrackets();
|
||||
this.$highlightTags();
|
||||
this.$updateHighlightActiveLine();
|
||||
this._signal("changeSelection");
|
||||
};
|
||||
|
|
@ -1915,24 +2001,157 @@ var Editor = function(renderer, session) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Moves the cursor's row and column to the next matching bracket.
|
||||
* Moves the cursor's row and column to the next matching bracket or HTML tag.
|
||||
*
|
||||
**/
|
||||
this.jumpToMatching = function(select) {
|
||||
var cursor = this.getCursorPosition();
|
||||
var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
|
||||
var prevToken = iterator.getCurrentToken();
|
||||
var token = prevToken;
|
||||
|
||||
var range = this.session.getBracketRange(cursor);
|
||||
if (!range) {
|
||||
range = this.find({
|
||||
needle: /[{}()\[\]]/g,
|
||||
preventScroll:true,
|
||||
start: {row: cursor.row, column: cursor.column - 1}
|
||||
});
|
||||
if (!range)
|
||||
if (!token)
|
||||
token = iterator.stepForward();
|
||||
|
||||
if (!token)
|
||||
return;
|
||||
|
||||
//get next closing tag or bracket
|
||||
var matchType;
|
||||
var found = false;
|
||||
var depth = {};
|
||||
var i = cursor.column - token.start;
|
||||
var bracketType;
|
||||
var brackets = {
|
||||
")": "(",
|
||||
"(": "(",
|
||||
"]": "[",
|
||||
"[": "[",
|
||||
"{": "{",
|
||||
"}": "{"
|
||||
};
|
||||
|
||||
do {
|
||||
if (token.value.match(/[{}()\[\]]/g)) {
|
||||
for (; i<token.value.length && !found; i++) {
|
||||
if (!brackets[token.value[i]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bracketType = brackets[token.value[i]]+'.'+token.type.replace("rparen", "lparen");
|
||||
|
||||
if (isNaN(depth[bracketType])) {
|
||||
depth[bracketType] = 0;
|
||||
}
|
||||
|
||||
switch (token.value[i]) {
|
||||
case '(':
|
||||
case '[':
|
||||
case '{':
|
||||
depth[bracketType]++;
|
||||
break;
|
||||
case ')':
|
||||
case ']':
|
||||
case '}':
|
||||
depth[bracketType]--;
|
||||
|
||||
if (depth[bracketType]===-1) {
|
||||
matchType = 'bracket';
|
||||
found = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (token && token.type.indexOf('tag-name') !== -1) {
|
||||
if (isNaN(depth[token.value])) {
|
||||
depth[token.value] = 0;
|
||||
}
|
||||
|
||||
if (prevToken.value === '<') {
|
||||
depth[token.value]++;
|
||||
} else if (prevToken.value === '</') {
|
||||
depth[token.value]--;
|
||||
}
|
||||
|
||||
if (depth[token.value] === -1) {
|
||||
matchType = 'tag';
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
prevToken = token;
|
||||
token = iterator.stepForward();
|
||||
i = 0;
|
||||
}
|
||||
} while (token && !found);
|
||||
|
||||
//no match found
|
||||
if (!matchType) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range;
|
||||
if (matchType==='bracket') {
|
||||
range = this.session.getBracketRange(cursor);
|
||||
if (!range) {
|
||||
range = new Range(
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn()+i-1,
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn()+i-1
|
||||
);
|
||||
if (!range)
|
||||
return;
|
||||
var pos = range.start;
|
||||
if (pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
|
||||
range = this.session.getBracketRange(pos);
|
||||
}
|
||||
} else if(matchType==='tag') {
|
||||
if (token && token.type.indexOf('tag-name') !== -1)
|
||||
var tag = token.value;
|
||||
else
|
||||
return;
|
||||
var pos = range.start;
|
||||
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
|
||||
range = this.session.getBracketRange(pos);
|
||||
|
||||
var range = new Range(
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn()-2,
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn()-2
|
||||
);
|
||||
|
||||
//find matching tag
|
||||
if (range.compare(cursor.row, cursor.column) === 0) {
|
||||
found = false;
|
||||
do {
|
||||
token = prevToken;
|
||||
prevToken = iterator.stepBackward();
|
||||
|
||||
if (prevToken) {
|
||||
if (prevToken.type.indexOf('tag-close') !== -1) {
|
||||
range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn()+1);
|
||||
}
|
||||
|
||||
if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
|
||||
if (prevToken.value === '<') {
|
||||
depth[tag]++;
|
||||
} else if ( prevToken.value === '</') {
|
||||
depth[tag]--;
|
||||
}
|
||||
|
||||
if (depth[tag]===0)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
} while (prevToken && !found);
|
||||
}
|
||||
|
||||
//we found it
|
||||
if (token && token.type.indexOf('tag-name')) {
|
||||
var pos = range.start;
|
||||
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
|
||||
pos = range.end;
|
||||
}
|
||||
}
|
||||
|
||||
pos = range && range.cursor || pos;
|
||||
|
|
|
|||
|
|
@ -108,8 +108,9 @@ var loadSnippetFile = function(id) {
|
|||
config.loadModule(snippetFilePath, function(m) {
|
||||
if (m) {
|
||||
snippetManager.files[id] = m;
|
||||
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
|
||||
snippetManager.register(m.snippets, m.scope);
|
||||
if (!m.snippets && m.snippetText)
|
||||
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
|
||||
snippetManager.register(m.snippets || [], m.scope);
|
||||
if (m.includeScopes) {
|
||||
snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes;
|
||||
m.includeScopes.forEach(function(x) {
|
||||
|
|
@ -120,45 +121,46 @@ var loadSnippetFile = function(id) {
|
|||
});
|
||||
};
|
||||
|
||||
var doLiveAutocomplete = function(e) {
|
||||
var editor = e.editor;
|
||||
var text = e.args || "";
|
||||
function getCompletionPrefix(editor) {
|
||||
var pos = editor.getCursorPosition();
|
||||
var line = editor.session.getLine(pos.row);
|
||||
var hasCompleter = editor.completer && editor.completer.activated;
|
||||
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
||||
|
||||
//Try to find custom prefixes on the completers
|
||||
completers.forEach(function(completer) {
|
||||
// Try to find custom prefixes on the completers
|
||||
editor.completers.forEach(function(completer) {
|
||||
if (completer.identifierRegexps) {
|
||||
completer.identifierRegexps.forEach(function(identifierRegex) {
|
||||
if (!prefix) {
|
||||
if (!prefix && identifierRegex)
|
||||
prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return prefix;
|
||||
}
|
||||
|
||||
var doLiveAutocomplete = function(e) {
|
||||
var editor = e.editor;
|
||||
var text = e.args || "";
|
||||
var hasCompleter = editor.completer && editor.completer.activated;
|
||||
|
||||
|
||||
|
||||
// We don't want to autocomplete with no prefix
|
||||
if (e.command.name === "backspace" && !prefix) {
|
||||
if (hasCompleter)
|
||||
if (e.command.name === "backspace") {
|
||||
if (hasCompleter && !getCompletionPrefix(editor))
|
||||
editor.completer.detach();
|
||||
}
|
||||
else if (e.command.name === "insertstring") {
|
||||
var prefix = getCompletionPrefix(editor);
|
||||
// Only autocomplete if there's a prefix that can be matched
|
||||
if (prefix && !hasCompleter) {
|
||||
if (!editor.completer) {
|
||||
// Create new autocompleter
|
||||
editor.completer = new Autocomplete();
|
||||
// Disable autoInsert
|
||||
editor.completer.autoSelect = false;
|
||||
editor.completer.autoInsert = false;
|
||||
}
|
||||
// Disable autoInsert
|
||||
editor.completer.autoSelect = false;
|
||||
editor.completer.autoInsert = false;
|
||||
editor.completer.showPopup(editor);
|
||||
} else if (!prefix && hasCompleter) {
|
||||
// When the prefix is empty
|
||||
// close the autocomplete dialog
|
||||
editor.completer.detach();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -168,7 +170,8 @@ require("../config").defineOptions(Editor.prototype, "editor", {
|
|||
enableBasicAutocompletion: {
|
||||
set: function(val) {
|
||||
if (val) {
|
||||
this.completers = Array.isArray(val)? val: completers;
|
||||
if (!this.completers)
|
||||
this.completers = Array.isArray(val)? val: completers;
|
||||
this.commands.addCommand(Autocomplete.startCommand);
|
||||
} else {
|
||||
this.commands.removeCommand(Autocomplete.startCommand);
|
||||
|
|
@ -183,7 +186,8 @@ require("../config").defineOptions(Editor.prototype, "editor", {
|
|||
enableLiveAutocompletion: {
|
||||
set: function(val) {
|
||||
if (val) {
|
||||
this.completers = Array.isArray(val)? val: completers;
|
||||
if (!this.completers)
|
||||
this.completers = Array.isArray(val)? val: completers;
|
||||
// On each change automatically trigger the autocomplete
|
||||
this.commands.on('afterExec', doLiveAutocomplete);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -60,41 +60,47 @@ module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) {
|
|||
var modelist = require('../modelist');
|
||||
var themelist = require('../themelist');
|
||||
editor.menuOptions = {
|
||||
"setNewLineMode" : [{
|
||||
"textContent" : "unix",
|
||||
"value" : "unix"
|
||||
setNewLineMode: [{
|
||||
textContent: "unix",
|
||||
value: "unix"
|
||||
}, {
|
||||
"textContent" : "windows",
|
||||
"value" : "windows"
|
||||
textContent: "windows",
|
||||
value: "windows"
|
||||
}, {
|
||||
"textContent" : "auto",
|
||||
"value" : "auto"
|
||||
textContent: "auto",
|
||||
value: "auto"
|
||||
}],
|
||||
"setTheme" : [],
|
||||
"setMode" : [],
|
||||
"setKeyboardHandler": [{
|
||||
"textContent" : "ace",
|
||||
"value" : ""
|
||||
setTheme: [],
|
||||
setMode: [],
|
||||
setKeyboardHandler: [{
|
||||
textContent: "ace",
|
||||
value: ""
|
||||
}, {
|
||||
"textContent" : "vim",
|
||||
"value" : "ace/keyboard/vim"
|
||||
textContent: "vim",
|
||||
value: "ace/keyboard/vim"
|
||||
}, {
|
||||
"textContent" : "emacs",
|
||||
"value" : "ace/keyboard/emacs"
|
||||
textContent: "emacs",
|
||||
value: "ace/keyboard/emacs"
|
||||
}, {
|
||||
textContent: "textarea",
|
||||
value: "ace/keyboard/textarea"
|
||||
}, {
|
||||
textContent: "sublime",
|
||||
value: "ace/keyboard/sublime"
|
||||
}]
|
||||
};
|
||||
|
||||
editor.menuOptions.setTheme = themelist.themes.map(function(theme) {
|
||||
return {
|
||||
'textContent' : theme.caption,
|
||||
'value' : theme.theme
|
||||
textContent: theme.caption,
|
||||
value: theme.theme
|
||||
};
|
||||
});
|
||||
|
||||
editor.menuOptions.setMode = modelist.modes.map(function(mode) {
|
||||
return {
|
||||
'textContent' : mode.name,
|
||||
'value' : mode.mode
|
||||
textContent: mode.name,
|
||||
value: mode.mode
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ var supportedModes = {
|
|||
C9Search: ["c9search_results"],
|
||||
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
|
||||
Cirru: ["cirru|cr"],
|
||||
Clojure: ["clj"],
|
||||
Clojure: ["clj|cljs"],
|
||||
Cobol: ["CBL|COB"],
|
||||
coffee: ["coffee|cf|cson|^Cakefile"],
|
||||
ColdFusion: ["cfm"],
|
||||
|
|
@ -70,6 +70,7 @@ var supportedModes = {
|
|||
Forth: ["frt|fs|ldr"],
|
||||
FTL: ["ftl"],
|
||||
Gherkin: ["feature"],
|
||||
Gitignore: ["^.gitignore"],
|
||||
Glsl: ["glsl|frag|vert"],
|
||||
golang: ["go"],
|
||||
Groovy: ["groovy"],
|
||||
|
|
@ -144,6 +145,7 @@ var supportedModes = {
|
|||
Toml: ["toml"],
|
||||
Twig: ["twig"],
|
||||
Typescript: ["ts|typescript|str"],
|
||||
Vala: ["vala"],
|
||||
VBScript: ["vbs"],
|
||||
Velocity: ["vm"],
|
||||
Verilog: ["v|vh|sv|svh"],
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ function setupContainer(element, getValue) {
|
|||
return container;
|
||||
}
|
||||
|
||||
exports.transformTextarea = function(element, loader) {
|
||||
exports.transformTextarea = function(element, options) {
|
||||
var session;
|
||||
var container = setupContainer(element, function() {
|
||||
return session.getValue();
|
||||
|
|
@ -215,9 +215,8 @@ exports.transformTextarea = function(element, loader) {
|
|||
applyStyles(settingDiv, settingDivStyles);
|
||||
container.appendChild(settingDiv);
|
||||
|
||||
options = options || exports.defaultOptions;
|
||||
// Power up ace on the textarea:
|
||||
var options = {};
|
||||
|
||||
var editor = ace.edit(editorDiv);
|
||||
session = editor.getSession();
|
||||
|
||||
|
|
@ -228,10 +227,10 @@ exports.transformTextarea = function(element, loader) {
|
|||
container.appendChild(settingOpener);
|
||||
|
||||
// Create the API.
|
||||
setupApi(editor, editorDiv, settingDiv, ace, options, loader);
|
||||
setupApi(editor, editorDiv, settingDiv, ace, options, load);
|
||||
|
||||
// Create the setting's panel.
|
||||
setupSettingPanel(settingDiv, settingOpener, editor, options);
|
||||
setupSettingPanel(settingDiv, settingOpener, editor);
|
||||
|
||||
var state = "";
|
||||
event.addListener(settingOpener, "mousemove", function(e) {
|
||||
|
|
@ -296,37 +295,15 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
|
|||
};
|
||||
|
||||
editor.$setOption = editor.setOption;
|
||||
editor.$getOption = editor.getOption;
|
||||
editor.setOption = function(key, value) {
|
||||
if (options[key] == value) return;
|
||||
|
||||
switch (key) {
|
||||
case "mode":
|
||||
if (value != "text") {
|
||||
// Load the required mode file. Files get loaded only once.
|
||||
loader("mode-" + value + ".js", "ace/mode/" + value, function() {
|
||||
var aceMode = require("../mode/" + value).Mode;
|
||||
session.setMode(new aceMode());
|
||||
});
|
||||
} else {
|
||||
session.setMode(new (require("../mode/text").Mode));
|
||||
}
|
||||
editor.$setOption("mode", "ace/mode/" + value)
|
||||
break;
|
||||
|
||||
case "theme":
|
||||
if (value != "textmate") {
|
||||
// Load the required theme file. Files get loaded only once.
|
||||
loader("theme-" + value + ".js", "ace/theme/" + value, function() {
|
||||
editor.setTheme("ace/theme/" + value);
|
||||
});
|
||||
} else {
|
||||
editor.setTheme("ace/theme/textmate");
|
||||
}
|
||||
editor.$setOption("theme", "ace/theme/" + value)
|
||||
break;
|
||||
|
||||
case "fontSize":
|
||||
editorDiv.style.fontSize = value;
|
||||
break;
|
||||
|
||||
case "keybindings":
|
||||
switch (value) {
|
||||
case "vim":
|
||||
|
|
@ -341,58 +318,55 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
|
|||
break;
|
||||
|
||||
case "softWrap":
|
||||
switch (value) {
|
||||
case "off":
|
||||
session.setUseWrapMode(false);
|
||||
renderer.setPrintMarginColumn(80);
|
||||
break;
|
||||
case "40":
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(40, 40);
|
||||
renderer.setPrintMarginColumn(40);
|
||||
break;
|
||||
case "80":
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(80, 80);
|
||||
renderer.setPrintMarginColumn(80);
|
||||
break;
|
||||
case "free":
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(null, null);
|
||||
renderer.setPrintMarginColumn(80);
|
||||
break;
|
||||
}
|
||||
case "fontSize":
|
||||
editor.$setOption(key, value);
|
||||
break;
|
||||
|
||||
default:
|
||||
editor.$setOption(key, toBool(value));
|
||||
}
|
||||
|
||||
options[key] = value;
|
||||
};
|
||||
|
||||
editor.getOption = function(key) {
|
||||
return options[key];
|
||||
switch (key) {
|
||||
case "mode":
|
||||
return editor.$getOption("mode").substr("ace/mode/".length)
|
||||
break;
|
||||
|
||||
case "theme":
|
||||
return editor.$getOption("theme").substr("ace/theme/".length)
|
||||
break;
|
||||
|
||||
case "keybindings":
|
||||
var value = editor.getKeyboardHandler()
|
||||
switch (value && value.$id) {
|
||||
case "ace/keyboard/vim":
|
||||
return "vim";
|
||||
case "ace/keyboard/emacs":
|
||||
return "emacs";
|
||||
default:
|
||||
return "ace";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return editor.$getOption(key);
|
||||
}
|
||||
};
|
||||
|
||||
editor.getOptions = function() {
|
||||
return options;
|
||||
};
|
||||
|
||||
editor.setOptions(exports.options);
|
||||
|
||||
editor.setOptions(options);
|
||||
return editor;
|
||||
}
|
||||
|
||||
function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
||||
function setupSettingPanel(settingDiv, settingOpener, editor) {
|
||||
var BOOL = null;
|
||||
|
||||
var desc = {
|
||||
mode: "Mode:",
|
||||
gutter: "Display Gutter:",
|
||||
wrap: "Soft Wrap:",
|
||||
theme: "Theme:",
|
||||
fontSize: "Font Size:",
|
||||
softWrap: "Soft Wrap:",
|
||||
showGutter: "Display Gutter:",
|
||||
keybindings: "Keyboard",
|
||||
showPrintMargin: "Show Print Margin:",
|
||||
useSoftTabs: "Use Soft Tabs:",
|
||||
|
|
@ -445,7 +419,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
|||
twilight: "Twilight",
|
||||
vibrant_ink: "Vibrant Ink"
|
||||
},
|
||||
gutter: BOOL,
|
||||
showGutter: BOOL,
|
||||
fontSize: {
|
||||
"10px": "10px",
|
||||
"11px": "11px",
|
||||
|
|
@ -453,7 +427,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
|||
"14px": "14px",
|
||||
"16px": "16px"
|
||||
},
|
||||
softWrap: {
|
||||
wrap: {
|
||||
off: "Off",
|
||||
40: "40",
|
||||
80: "80",
|
||||
|
|
@ -476,7 +450,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
|||
if (!obj) {
|
||||
builder.push(
|
||||
"<input type='checkbox' title='", option, "' ",
|
||||
cValue == "true" ? "checked='true'" : "",
|
||||
cValue + "" == "true" ? "checked='true'" : "",
|
||||
"'></input>"
|
||||
);
|
||||
return;
|
||||
|
|
@ -496,10 +470,10 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
|||
builder.push("</select>");
|
||||
}
|
||||
|
||||
for (var option in options) {
|
||||
for (var option in exports.defaultOptions) {
|
||||
table.push("<tr><td>", desc[option], "</td>");
|
||||
table.push("<td>");
|
||||
renderOption(table, option, optionValues[option], options[option]);
|
||||
renderOption(table, option, optionValues[option], editor.getOption(option));
|
||||
table.push("</td></tr>");
|
||||
}
|
||||
table.push("</table>");
|
||||
|
|
@ -532,12 +506,12 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
|||
}
|
||||
|
||||
// Default startup options.
|
||||
exports.options = {
|
||||
mode: "text",
|
||||
exports.defaultOptions = {
|
||||
mode: "javascript",
|
||||
theme: "textmate",
|
||||
gutter: "false",
|
||||
wrap: "off",
|
||||
fontSize: "12px",
|
||||
softWrap: "off",
|
||||
showGutter: "false",
|
||||
keybindings: "ace",
|
||||
showPrintMargin: "false",
|
||||
useSoftTabs: "true",
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
if (!/^\s*[^*+\-\s]/.test(line))
|
||||
continue;
|
||||
|
||||
var tabs = line.match(/^\t*/)[0].length;
|
||||
if (line[0] == "\t")
|
||||
tabIndents++;
|
||||
|
||||
|
|
@ -65,9 +64,6 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
line = lines[i++];
|
||||
}
|
||||
|
||||
if (!stats.length)
|
||||
return;
|
||||
|
||||
function getScore(indent) {
|
||||
var score = 0;
|
||||
for (var i = indent; i < stats.length; i += indent)
|
||||
|
|
@ -82,7 +78,7 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
for (var i = 1; i < 12; i++) {
|
||||
if (i == 1) {
|
||||
spaceIndents = getScore(i);
|
||||
var score = 1;
|
||||
var score = stats.length && 1;
|
||||
} else
|
||||
var score = getScore(i) / spaceIndents;
|
||||
|
||||
|
|
@ -99,7 +95,7 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
if (tabIndents > spaceIndents + 1)
|
||||
return {ch: "\t", length: tabLength};
|
||||
|
||||
if (spaceIndents + 1 > tabIndents)
|
||||
if (spaceIndents > tabIndents + 1)
|
||||
return {ch: " ", length: tabLength};
|
||||
};
|
||||
|
||||
|
|
|
|||
116
lib/ace/ext/whitespace_test.js
Normal file
116
lib/ace/ext/whitespace_test.js
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
if (typeof process !== "undefined") {
|
||||
require("amd-loader");
|
||||
require("../test/mockdom");
|
||||
}
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var assert = require("assert");
|
||||
var EditSession = require("../edit_session").EditSession;
|
||||
var whitespace = require("./whitespace");
|
||||
|
||||
// Execution ORDER: test.setUpSuite, setUp, testFn, tearDown, test.tearDownSuite
|
||||
module.exports = {
|
||||
timeout: 10000,
|
||||
|
||||
"test tab detection": function(next) {
|
||||
var s = new EditSession([
|
||||
"define({",
|
||||
"\tfoo:1,",
|
||||
"\tbar:2,",
|
||||
"\tbaz:{,",
|
||||
"\t\tx:3",
|
||||
"\t}",
|
||||
"})"
|
||||
]);
|
||||
|
||||
var indent = whitespace.$detectIndentation(s.doc.$lines);
|
||||
assert.equal(indent.ch, "\t");
|
||||
assert.equal(indent.length, undefined);
|
||||
|
||||
s.insert({row: 0, column: 0}, " ");
|
||||
indent = whitespace.$detectIndentation(s.doc.$lines);
|
||||
assert.equal(indent.ch, "\t");
|
||||
assert.equal(indent.length, 4);
|
||||
|
||||
s.setValue("");
|
||||
indent = whitespace.$detectIndentation(s.doc.$lines);
|
||||
assert.ok(!indent);
|
||||
|
||||
next();
|
||||
},
|
||||
|
||||
"test empty session": function(next) {
|
||||
var s = new EditSession([
|
||||
"define({",
|
||||
"foo:1,",
|
||||
"})"
|
||||
]);
|
||||
var indent = whitespace.$detectIndentation(s.doc.$lines);
|
||||
assert.ok(!indent);
|
||||
s.insert({row: 1, column: 0}, " x\n ");
|
||||
|
||||
indent = whitespace.$detectIndentation(s.doc.$lines);
|
||||
assert.equal(indent.ch, " ");
|
||||
assert.equal(indent.length, 4);
|
||||
|
||||
next();
|
||||
},
|
||||
|
||||
"!test one line": function(next) {
|
||||
var s = new EditSession([
|
||||
"define({",
|
||||
" foo:1,",
|
||||
"})"
|
||||
]);
|
||||
var indent = whitespace.$detectIndentation(s.doc.$lines);
|
||||
assert.equal(indent.ch, " ");
|
||||
assert.equal(indent.length, 4);
|
||||
|
||||
next();
|
||||
},
|
||||
|
||||
"test 1 width indents": function(next) {
|
||||
var s = new EditSession([
|
||||
"define({",
|
||||
" foo:1,",
|
||||
"})",
|
||||
"define({",
|
||||
" bar:1,",
|
||||
"})",
|
||||
" t",
|
||||
" t",
|
||||
" t",
|
||||
" t",
|
||||
" t",
|
||||
" t",
|
||||
" t",
|
||||
" t"
|
||||
]);
|
||||
var indent = whitespace.$detectIndentation(s.doc.$lines);
|
||||
// assert.equal(indent.ch, " ");
|
||||
// assert.equal(indent.length, 4);
|
||||
|
||||
s = new EditSession([
|
||||
"{",
|
||||
" foo:1,",
|
||||
" bar: {",
|
||||
" baz:2",
|
||||
" }",
|
||||
"}"
|
||||
]);
|
||||
indent = whitespace.$detectIndentation(s.doc.$lines);
|
||||
assert.equal(indent.ch, " ");
|
||||
assert.equal(indent.length, 1);
|
||||
|
||||
next();
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
82
lib/ace/keyboard/textarea.js
Normal file
82
lib/ace/keyboard/textarea.js
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/* ***** 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 HashHandler = require("./hash_handler").HashHandler;
|
||||
exports.handler = new HashHandler();
|
||||
|
||||
[{
|
||||
bindKey: "Shift-Tab|Tab",
|
||||
command: "passKeysToBrowser"
|
||||
}, {
|
||||
bindKey: {win: "Ctrl-L", mac: "Cmd-L"},
|
||||
command: "passKeysToBrowser"
|
||||
}, {
|
||||
bindKey: {win: "Ctrl-G", mac: "Cmd-G"},
|
||||
command: "gotoline"
|
||||
}, {
|
||||
bindKey: {win: "Ctrl-T|Ctrl-Shift-T", mac: "Cmd-T|Cmd-Shift-T"},
|
||||
command: "passKeysToBrowser"
|
||||
}, {
|
||||
bindKey: {win: "Ctrl-G", mac: "Cmd-G"},
|
||||
command: "passKeysToBrowser"
|
||||
}, {
|
||||
bindKey: {win: "Ctrl-G", mac: "Cmd-G"},
|
||||
command: "passKeysToBrowser"
|
||||
}, {
|
||||
name: "golineup",
|
||||
bindKey: {win: null, mac: "Ctrl-P"},
|
||||
}, {
|
||||
name: "golinedown",
|
||||
bindKey: {win: null, mac: "Ctrl-N"},
|
||||
}, {
|
||||
name: "gotoleft",
|
||||
bindKey: {win: null, mac: "Ctrl-B"},
|
||||
}, {
|
||||
name: "gotoright",
|
||||
bindKey: {win: null, mac: "Ctrl-F"},
|
||||
}, {
|
||||
name: "gotolineend",
|
||||
bindKey: {win: null, mac: "Ctrl-E"},
|
||||
}, {
|
||||
name: "gotolinestart",
|
||||
bindKey: {win: null, mac: "Ctrl-A"},
|
||||
}
|
||||
].forEach(function(k) {
|
||||
var bindKey = k.bindKey;
|
||||
if (typeof bindKey == "object")
|
||||
bindKey = bindKey[exports.handler.platform];
|
||||
exports.handler.bindKey(bindKey, k.command);
|
||||
});
|
||||
exports.handler.$id = "ace/keyboard/textarea";
|
||||
|
||||
});
|
||||
|
|
@ -428,13 +428,17 @@ var TextInput = function(parentNode, host) {
|
|||
|
||||
this.onContextMenu = function(e) {
|
||||
afterContextMenu = true;
|
||||
if (!tempStyle)
|
||||
tempStyle = text.style.cssText;
|
||||
|
||||
text.style.cssText = "z-index:100000;" + (useragent.isIE ? "opacity:0.1;" : "");
|
||||
|
||||
resetSelection(host.selection.isEmpty());
|
||||
host._emit("nativecontextmenu", {target: host, domEvent: e});
|
||||
this.moveToMouse(e, true);
|
||||
};
|
||||
|
||||
this.moveToMouse = function(e, bringToFront) {
|
||||
if (!tempStyle)
|
||||
tempStyle = text.style.cssText;
|
||||
text.style.cssText = (bringToFront ? "z-index:100000;" : "")
|
||||
+ (useragent.isIE ? "opacity:0.1;" : "");
|
||||
|
||||
var rect = host.container.getBoundingClientRect();
|
||||
var style = dom.computedStyle(host.container);
|
||||
var top = rect.top + (parseInt(style.borderTopWidth) || 0);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ define(function(require, exports, module) {
|
|||
|
||||
var util = require("./util");
|
||||
var registers = require("../registers");
|
||||
var Range = require("../../../range").Range;
|
||||
|
||||
module.exports = {
|
||||
"d": {
|
||||
|
|
@ -90,15 +91,18 @@ module.exports = {
|
|||
count = count || 1;
|
||||
switch (param) {
|
||||
case "c":
|
||||
for (var i = 0; i < count; i++) {
|
||||
editor.removeLines();
|
||||
util.insertMode(editor);
|
||||
}
|
||||
|
||||
editor.$blockScrolling++;
|
||||
editor.selection.$moveSelection(function() {
|
||||
editor.selection.moveCursorBy(count - 1, 0);
|
||||
});
|
||||
var rows = editor.$getSelectedRows();
|
||||
range = new Range(rows.first, 0, rows.last, Infinity);
|
||||
editor.session.remove(range);
|
||||
editor.$blockScrolling--;
|
||||
util.insertMode(editor);
|
||||
break;
|
||||
default:
|
||||
if (range) {
|
||||
|
||||
// range.end.column ++;
|
||||
editor.session.remove(range);
|
||||
util.insertMode(editor);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ var Marker = function(parentEl) {
|
|||
this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config);
|
||||
}
|
||||
}
|
||||
this.element = dom.setInnerHtml(this.element, html.join(""));
|
||||
this.element.innerHTML = html.join("");
|
||||
};
|
||||
|
||||
this.$getTop = function(row, layerConfig) {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ var Text = function(parentEl) {
|
|||
html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
|
||||
);
|
||||
lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
|
||||
dom.setInnerHtml(lineElement, html.join(""));
|
||||
lineElement.innerHTML = html.join("");
|
||||
}
|
||||
row++;
|
||||
}
|
||||
|
|
@ -310,7 +310,7 @@ var Text = function(parentEl) {
|
|||
|
||||
row++;
|
||||
}
|
||||
this.element = dom.setInnerHtml(this.element, html.join(""));
|
||||
this.element.innerHTML = html.join("");
|
||||
};
|
||||
|
||||
this.$textToken = {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ exports.preventDefault = function(e) {
|
|||
exports.getButton = function(e) {
|
||||
if (e.type == "dblclick")
|
||||
return 0;
|
||||
if (e.type == "contextmenu" || (e.ctrlKey && useragent.isMac))
|
||||
if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
|
||||
return 2;
|
||||
|
||||
// DOM Event
|
||||
|
|
@ -183,7 +183,7 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
|
|||
if (!timer || isNewClick)
|
||||
clicks = 1;
|
||||
if (timer)
|
||||
clearTimeout(timer)
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
|
||||
|
||||
if (clicks == 1) {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ exports.isIE =
|
|||
exports.isOldIE = exports.isIE && exports.isIE < 9;
|
||||
|
||||
// Is this Firefox or related?
|
||||
exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko";
|
||||
exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
|
||||
|
||||
// oldGecko == rev < 2.0
|
||||
exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ function LineWidgets(session) {
|
|||
|
||||
editor.widgetManager = this;
|
||||
|
||||
editor.setOption("enableLineWidgets", true);
|
||||
editor.renderer.on("beforeRender", this.measureWidgets);
|
||||
editor.renderer.on("afterRender", this.renderWidgets);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ oop.inherits(Mode, TextMode);
|
|||
(function() {
|
||||
this.lineCommentStart = "--";
|
||||
this.blockComment = {start: "(*", end: "*)"};
|
||||
this.$id = "ace/mode/applescript";
|
||||
// Extra logic goes here.
|
||||
}).call(Mode.prototype);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ var DartHighlightRules = function() {
|
|||
},
|
||||
{
|
||||
token: "keyword.other.import.dart",
|
||||
regex: "(?:\\b)(?:library|import|part|of)(?:\\b)"
|
||||
regex: "(?:\\b)(?:library|import|export|part|of)(?:\\b)"
|
||||
},
|
||||
{
|
||||
token : ["keyword.other.import.dart", "text"],
|
||||
|
|
|
|||
19
lib/ace/mode/gitignore.js
Normal file
19
lib/ace/mode/gitignore.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var GitignoreHighlightRules = require("./gitignore_highlight_rules").GitignoreHighlightRules;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = GitignoreHighlightRules;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.$id = "ace/mode/gitignore";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
31
lib/ace/mode/gitignore_highlight_rules.js
Normal file
31
lib/ace/mode/gitignore_highlight_rules.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var GitignoreHighlightRules = function() {
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : /^\s*#.*$/
|
||||
}, {
|
||||
token : "keyword", // negated patterns
|
||||
regex : /^\s*!.*$/
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
GitignoreHighlightRules.metaData = {
|
||||
fileTypes: ['gitignore'],
|
||||
name: 'Gitignore'
|
||||
};
|
||||
|
||||
oop.inherits(GitignoreHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.GitignoreHighlightRules = GitignoreHighlightRules;
|
||||
});
|
||||
|
|
@ -72,9 +72,6 @@ define(function(require, exports, module) {
|
|||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\])}]"
|
||||
}, {
|
||||
token: "invalid",
|
||||
regex: "\\s+$"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -717,34 +717,52 @@ PHP.Lexer = function( src, ini ) {
|
|||
|
||||
var re;
|
||||
if ( curlyOpen > 0) {
|
||||
re = /^([^\\\$"{}\]\)]|\\.)+/g;
|
||||
re = /^([^\\\$"{}\]\(\)\->]|\\.)+/g;
|
||||
} else {
|
||||
re = /^([^\\\$"{]|\\.|{[^\$]|\$(?=[^a-zA-Z_\x7f-\uffff]))+/g;;
|
||||
}
|
||||
|
||||
var type, match2;
|
||||
while(( match = result.match( re )) !== null ) {
|
||||
|
||||
|
||||
if (result.length === 1) {
|
||||
throw new Error(match);
|
||||
}
|
||||
|
||||
type = 0;
|
||||
|
||||
|
||||
|
||||
results.push([
|
||||
parseInt(( curlyOpen > 0 ) ? PHP.Constants.T_CONSTANT_ENCAPSED_STRING : PHP.Constants.T_ENCAPSED_AND_WHITESPACE, 10),
|
||||
match[ 0 ].replace(/\n/g,"\\n").replace(/\r/g,""),
|
||||
line
|
||||
]);
|
||||
if( curlyOpen > 0 ){
|
||||
if( match2 = match[0].match(/^[\[\]\;\:\?\(\)\!\.\,\>\<\=\+\-\/\*\|\&\{\}\@\^\%\$\~]/) ){
|
||||
results.push(match2[0]);
|
||||
}else{
|
||||
type = PHP.Constants.T_STRING;
|
||||
}
|
||||
}else{
|
||||
type = PHP.Constants.T_ENCAPSED_AND_WHITESPACE;
|
||||
}
|
||||
|
||||
if( type ){
|
||||
results.push([
|
||||
parseInt(type, 10),
|
||||
match[ 0 ].replace(/\n/g,"\\n").replace(/\r/g,""),
|
||||
line
|
||||
]);
|
||||
}
|
||||
|
||||
line += match[ 0 ].split('\n').length - 1;
|
||||
|
||||
result = result.substring( match[ 0 ].length );
|
||||
}
|
||||
|
||||
if( curlyOpen > 0 && result.match(/^\->/) !== null ) {
|
||||
results.push([
|
||||
parseInt(PHP.Constants.T_OBJECT_OPERATOR, 10),
|
||||
'->',
|
||||
line
|
||||
]);
|
||||
result = result.substring( 2 );
|
||||
}
|
||||
|
||||
if( result.match(/^{\$/) !== null ) {
|
||||
|
||||
results.push([
|
||||
parseInt(PHP.Constants.T_CURLY_OPEN, 10),
|
||||
"{",
|
||||
|
|
|
|||
|
|
@ -74,14 +74,21 @@ oop.inherits(Mode, TextMode);
|
|||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return /^\s+end$/.test(line + input) || /^\s+}$/.test(line + input) || /^\s+else$/.test(line + input);
|
||||
return /^\s+(end|else)$/.test(line + input) || this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
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.autoOutdent = function(state, session, row) {
|
||||
var line = session.getLine(row);
|
||||
if (/}/.test(line))
|
||||
return this.$outdent.autoOutdent(session, row);
|
||||
var indent = this.$getIndent(line);
|
||||
var prevLine = session.getLine(row - 1);
|
||||
var prevIndent = this.$getIndent(prevLine);
|
||||
var tab = session.getTabString();
|
||||
if (prevIndent.length <= indent.length) {
|
||||
if (indent.slice(-tab.length) == tab)
|
||||
session.remove(new Range(row, indent.length-tab.length, row, indent.length));
|
||||
}
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/ruby";
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ var Mode = function() {
|
|||
|
||||
this.getTokenizer = function() {
|
||||
if (!this.$tokenizer) {
|
||||
this.$highlightRules = new this.HighlightRules();
|
||||
this.$highlightRules = this.$highlightRules || new this.HighlightRules();
|
||||
this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
|
||||
}
|
||||
return this.$tokenizer;
|
||||
|
|
|
|||
105
lib/ace/mode/vala.js
Normal file
105
lib/ace/mode/vala.js
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, 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 ***** */
|
||||
|
||||
/*
|
||||
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var ValaHighlightRules = require("./vala_highlight_rules").ValaHighlightRules;
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = ValaHighlightRules;
|
||||
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
||||
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
var endState = tokenizedLine.state;
|
||||
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
if (state == "start" || state == "no_regex") {
|
||||
var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
} else if (state == "doc-start") {
|
||||
if (endState == "start" || endState == "no_regex") {
|
||||
return "";
|
||||
}
|
||||
var match = line.match(/^\s*(\/?)\*/);
|
||||
if (match) {
|
||||
if (match[1]) {
|
||||
indent += " ";
|
||||
}
|
||||
indent += "* ";
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
// Extra logic goes here.
|
||||
this.$id = "ace/mode/vala"
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
457
lib/ace/mode/vala_highlight_rules.js
Normal file
457
lib/ace/mode/vala_highlight_rules.js
Normal file
|
|
@ -0,0 +1,457 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, 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 ***** */
|
||||
|
||||
/* This file was autogenerated from https://raw.githubusercontent.com/technosophos/Vala-TMBundle/master/Syntaxes/Vala.tmLanguage (uuid: ) */
|
||||
/****************************************************************************************
|
||||
* IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. *
|
||||
* fileTypes *
|
||||
****************************************************************************************/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var ValaHighlightRules = function() {
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules = { start:
|
||||
[ { token:
|
||||
[ 'meta.using.vala',
|
||||
'keyword.other.using.vala',
|
||||
'meta.using.vala',
|
||||
'storage.modifier.using.vala',
|
||||
'meta.using.vala',
|
||||
'punctuation.terminator.vala' ],
|
||||
regex: '^(\\s*)(using)\\b(?:(\\s*)([^ ;$]+)(\\s*)((?:;)?))?' },
|
||||
{ include: '#code' } ],
|
||||
'#all-types':
|
||||
[ { include: '#primitive-arrays' },
|
||||
{ include: '#primitive-types' },
|
||||
{ include: '#object-types' } ],
|
||||
'#annotations':
|
||||
[ { token:
|
||||
[ 'storage.type.annotation.vala',
|
||||
'punctuation.definition.annotation-arguments.begin.vala' ],
|
||||
regex: '(@[^ (]+)(\\()',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.annotation-arguments.end.vala',
|
||||
regex: '\\)',
|
||||
next: 'pop' },
|
||||
{ token:
|
||||
[ 'constant.other.key.vala',
|
||||
'text',
|
||||
'keyword.operator.assignment.vala' ],
|
||||
regex: '(\\w*)(\\s*)(=)' },
|
||||
{ include: '#code' },
|
||||
{ token: 'punctuation.seperator.property.vala', regex: ',' },
|
||||
{ defaultToken: 'meta.declaration.annotation.vala' } ] },
|
||||
{ token: 'storage.type.annotation.vala', regex: '@\\w*' } ],
|
||||
'#anonymous-classes-and-new':
|
||||
[ { token: 'keyword.control.new.vala',
|
||||
regex: '\\bnew\\b',
|
||||
push_disabled:
|
||||
[ { token: 'text',
|
||||
regex: '(?<=\\)|\\])(?!\\s*{)|(?<=})|(?=;)',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<=\\)|\\])(?!\\s*{)|(?<=})|(?=;)',
|
||||
next: 'pop' },
|
||||
{ token: [ 'storage.type.vala', 'text' ],
|
||||
regex: '(\\w+)(\\s*)(?=\\[)',
|
||||
push:
|
||||
[ { token: 'text', regex: '}|(?=;|\\))', next: 'pop' },
|
||||
{ token: 'text',
|
||||
regex: '\\[',
|
||||
push:
|
||||
[ { token: 'text', regex: '\\]', next: 'pop' },
|
||||
{ include: '#code' } ] },
|
||||
{ token: 'text',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'text', regex: '(?=})', next: 'pop' },
|
||||
{ include: '#code' } ] } ] },
|
||||
{ token: 'text',
|
||||
regex: '(?=\\w.*\\()',
|
||||
push:
|
||||
[ { token: 'text',
|
||||
regex: '(?<=\\))',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<=\\))',
|
||||
next: 'pop' },
|
||||
{ include: '#object-types' },
|
||||
{ token: 'text',
|
||||
regex: '\\(',
|
||||
push:
|
||||
[ { token: 'text', regex: '\\)', next: 'pop' },
|
||||
{ include: '#code' } ] } ] },
|
||||
{ token: 'meta.inner-class.vala',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'meta.inner-class.vala', regex: '}', next: 'pop' },
|
||||
{ include: '#class-body' },
|
||||
{ defaultToken: 'meta.inner-class.vala' } ] } ] } ],
|
||||
'#assertions':
|
||||
[ { token:
|
||||
[ 'keyword.control.assert.vala',
|
||||
'meta.declaration.assertion.vala' ],
|
||||
regex: '\\b(assert|requires|ensures)(\\s)',
|
||||
push:
|
||||
[ { token: 'meta.declaration.assertion.vala',
|
||||
regex: '$',
|
||||
next: 'pop' },
|
||||
{ token: 'keyword.operator.assert.expression-seperator.vala',
|
||||
regex: ':' },
|
||||
{ include: '#code' },
|
||||
{ defaultToken: 'meta.declaration.assertion.vala' } ] } ],
|
||||
'#class':
|
||||
[ { token: 'meta.class.vala',
|
||||
regex: '(?=\\w?[\\w\\s]*(?:class|(?:@)?interface|enum|struct|namespace)\\s+\\w+)',
|
||||
push:
|
||||
[ { token: 'punctuation.section.class.end.vala',
|
||||
regex: '}',
|
||||
next: 'pop' },
|
||||
{ include: '#storage-modifiers' },
|
||||
{ include: '#comments' },
|
||||
{ token:
|
||||
[ 'storage.modifier.vala',
|
||||
'meta.class.identifier.vala',
|
||||
'entity.name.type.class.vala' ],
|
||||
regex: '(class|(?:@)?interface|enum|struct|namespace)(\\s+)([\\w\\.]+)' },
|
||||
{ token: 'storage.modifier.extends.vala',
|
||||
regex: ':',
|
||||
push:
|
||||
[ { token: 'meta.definition.class.inherited.classes.vala',
|
||||
regex: '(?={|,)',
|
||||
next: 'pop' },
|
||||
{ include: '#object-types-inherited' },
|
||||
{ include: '#comments' },
|
||||
{ defaultToken: 'meta.definition.class.inherited.classes.vala' } ] },
|
||||
{ token:
|
||||
[ 'storage.modifier.implements.vala',
|
||||
'meta.definition.class.implemented.interfaces.vala' ],
|
||||
regex: '(,)(\\s)',
|
||||
push:
|
||||
[ { token: 'meta.definition.class.implemented.interfaces.vala',
|
||||
regex: '(?=\\{)',
|
||||
next: 'pop' },
|
||||
{ include: '#object-types-inherited' },
|
||||
{ include: '#comments' },
|
||||
{ defaultToken: 'meta.definition.class.implemented.interfaces.vala' } ] },
|
||||
{ token: 'meta.class.body.vala',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'meta.class.body.vala', regex: '(?=})', next: 'pop' },
|
||||
{ include: '#class-body' },
|
||||
{ defaultToken: 'meta.class.body.vala' } ] },
|
||||
{ defaultToken: 'meta.class.vala' } ],
|
||||
comment: 'attempting to put namespace in here.' } ],
|
||||
'#class-body':
|
||||
[ { include: '#comments' },
|
||||
{ include: '#class' },
|
||||
{ include: '#enums' },
|
||||
{ include: '#methods' },
|
||||
{ include: '#annotations' },
|
||||
{ include: '#storage-modifiers' },
|
||||
{ include: '#code' } ],
|
||||
'#code':
|
||||
[ { include: '#comments' },
|
||||
{ include: '#class' },
|
||||
{ token: 'text',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'text', regex: '}', next: 'pop' },
|
||||
{ include: '#code' } ] },
|
||||
{ include: '#assertions' },
|
||||
{ include: '#parens' },
|
||||
{ include: '#constants-and-special-vars' },
|
||||
{ include: '#anonymous-classes-and-new' },
|
||||
{ include: '#keywords' },
|
||||
{ include: '#storage-modifiers' },
|
||||
{ include: '#strings' },
|
||||
{ include: '#all-types' } ],
|
||||
'#comments':
|
||||
[ { token: 'punctuation.definition.comment.vala',
|
||||
regex: '/\\*\\*/' },
|
||||
{ include: 'text.html.javadoc' },
|
||||
{ include: '#comments-inline' } ],
|
||||
'#comments-inline':
|
||||
[ { token: 'punctuation.definition.comment.vala',
|
||||
regex: '/\\*',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.comment.vala',
|
||||
regex: '\\*/',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'comment.block.vala' } ] },
|
||||
{ token:
|
||||
[ 'text',
|
||||
'punctuation.definition.comment.vala',
|
||||
'comment.line.double-slash.vala' ],
|
||||
regex: '(\\s*)(//)(.*$)' } ],
|
||||
'#constants-and-special-vars':
|
||||
[ { token: 'constant.language.vala',
|
||||
regex: '\\b(?:true|false|null)\\b' },
|
||||
{ token: 'variable.language.vala',
|
||||
regex: '\\b(?:this|base)\\b' },
|
||||
{ token: 'constant.numeric.vala',
|
||||
regex: '\\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:[LlFfUuDd]|UL|ul)?\\b' },
|
||||
{ token: [ 'keyword.operator.dereference.vala', 'constant.other.vala' ],
|
||||
regex: '((?:\\.)?)\\b([A-Z][A-Z0-9_]+)(?!<|\\.class|\\s*\\w+\\s*=)\\b' } ],
|
||||
'#enums':
|
||||
[ { token: 'text',
|
||||
regex: '^(?=\\s*[A-Z0-9_]+\\s*(?:{|\\(|,))',
|
||||
push:
|
||||
[ { token: 'text', regex: '(?=;|})', next: 'pop' },
|
||||
{ token: 'constant.other.enum.vala',
|
||||
regex: '\\w+',
|
||||
push:
|
||||
[ { token: 'meta.enum.vala', regex: '(?=,|;|})', next: 'pop' },
|
||||
{ include: '#parens' },
|
||||
{ token: 'text',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'text', regex: '}', next: 'pop' },
|
||||
{ include: '#class-body' } ] },
|
||||
{ defaultToken: 'meta.enum.vala' } ] } ] } ],
|
||||
'#keywords':
|
||||
[ { token: 'keyword.control.catch-exception.vala',
|
||||
regex: '\\b(?:try|catch|finally|throw)\\b' },
|
||||
{ token: 'keyword.control.vala', regex: '\\?|:|\\?\\?' },
|
||||
{ token: 'keyword.control.vala',
|
||||
regex: '\\b(?:return|break|case|continue|default|do|while|for|foreach|switch|if|else|in|yield|get|set|value)\\b' },
|
||||
{ token: 'keyword.operator.vala',
|
||||
regex: '\\b(?:typeof|is|as)\\b' },
|
||||
{ token: 'keyword.operator.comparison.vala',
|
||||
regex: '==|!=|<=|>=|<>|<|>' },
|
||||
{ token: 'keyword.operator.assignment.vala', regex: '=' },
|
||||
{ token: 'keyword.operator.increment-decrement.vala',
|
||||
regex: '\\-\\-|\\+\\+' },
|
||||
{ token: 'keyword.operator.arithmetic.vala',
|
||||
regex: '\\-|\\+|\\*|\\/|%' },
|
||||
{ token: 'keyword.operator.logical.vala', regex: '!|&&|\\|\\|' },
|
||||
{ token: 'keyword.operator.dereference.vala',
|
||||
regex: '\\.(?=\\S)',
|
||||
originalRegex: '(?<=\\S)\\.(?=\\S)' },
|
||||
{ token: 'punctuation.terminator.vala', regex: ';' },
|
||||
{ token: 'keyword.operator.ownership', regex: 'owned|unowned' } ],
|
||||
'#methods':
|
||||
[ { token: 'meta.method.vala',
|
||||
regex: '(?!new)(?=\\w.*\\s+)(?=[^=]+\\()',
|
||||
push:
|
||||
[ { token: 'meta.method.vala', regex: '}|(?=;)', next: 'pop' },
|
||||
{ include: '#storage-modifiers' },
|
||||
{ token: [ 'entity.name.function.vala', 'meta.method.identifier.vala' ],
|
||||
regex: '([\\~\\w\\.]+)(\\s*\\()',
|
||||
push:
|
||||
[ { token: 'meta.method.identifier.vala',
|
||||
regex: '\\)',
|
||||
next: 'pop' },
|
||||
{ include: '#parameters' },
|
||||
{ defaultToken: 'meta.method.identifier.vala' } ] },
|
||||
{ token: 'meta.method.return-type.vala',
|
||||
regex: '(?=\\w.*\\s+\\w+\\s*\\()',
|
||||
push:
|
||||
[ { token: 'meta.method.return-type.vala',
|
||||
regex: '(?=\\w+\\s*\\()',
|
||||
next: 'pop' },
|
||||
{ include: '#all-types' },
|
||||
{ defaultToken: 'meta.method.return-type.vala' } ] },
|
||||
{ include: '#throws' },
|
||||
{ token: 'meta.method.body.vala',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'meta.method.body.vala', regex: '(?=})', next: 'pop' },
|
||||
{ include: '#code' },
|
||||
{ defaultToken: 'meta.method.body.vala' } ] },
|
||||
{ defaultToken: 'meta.method.vala' } ] } ],
|
||||
'#namespace':
|
||||
[ { token: 'text',
|
||||
regex: '^(?=\\s*[A-Z0-9_]+\\s*(?:{|\\(|,))',
|
||||
push:
|
||||
[ { token: 'text', regex: '(?=;|})', next: 'pop' },
|
||||
{ token: 'constant.other.namespace.vala',
|
||||
regex: '\\w+',
|
||||
push:
|
||||
[ { token: 'meta.namespace.vala', regex: '(?=,|;|})', next: 'pop' },
|
||||
{ include: '#parens' },
|
||||
{ token: 'text',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'text', regex: '}', next: 'pop' },
|
||||
{ include: '#code' } ] },
|
||||
{ defaultToken: 'meta.namespace.vala' } ] } ],
|
||||
comment: 'This is not quite right. See the class grammar right now' } ],
|
||||
'#object-types':
|
||||
[ { token: 'storage.type.generic.vala',
|
||||
regex: '\\b(?:[a-z]\\w*\\.)*[A-Z]+\\w*<',
|
||||
push:
|
||||
[ { token: 'storage.type.generic.vala',
|
||||
regex: '>|[^\\w\\s,\\?<\\[()\\]]',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '>|[^\\w\\s,\\?<\\[(?:[,]+)\\]]',
|
||||
next: 'pop' },
|
||||
{ include: '#object-types' },
|
||||
{ token: 'storage.type.generic.vala',
|
||||
regex: '<',
|
||||
push:
|
||||
[ { token: 'storage.type.generic.vala',
|
||||
regex: '>|[^\\w\\s,\\[\\]<]',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'storage.type.generic.vala' } ],
|
||||
comment: 'This is just to support <>\'s with no actual type prefix' },
|
||||
{ defaultToken: 'storage.type.generic.vala' } ] },
|
||||
{ token: 'storage.type.object.array.vala',
|
||||
regex: '\\b(?:[a-z]\\w*\\.)*[A-Z]+\\w*(?=\\[)',
|
||||
push:
|
||||
[ { token: 'storage.type.object.array.vala',
|
||||
regex: '(?=[^\\]\\s])',
|
||||
next: 'pop' },
|
||||
{ token: 'text',
|
||||
regex: '\\[',
|
||||
push:
|
||||
[ { token: 'text', regex: '\\]', next: 'pop' },
|
||||
{ include: '#code' } ] },
|
||||
{ defaultToken: 'storage.type.object.array.vala' } ] },
|
||||
{ token:
|
||||
[ 'storage.type.vala',
|
||||
'keyword.operator.dereference.vala',
|
||||
'storage.type.vala' ],
|
||||
regex: '\\b(?:([a-z]\\w*)(\\.))*([A-Z]+\\w*\\b)' } ],
|
||||
'#object-types-inherited':
|
||||
[ { token: 'entity.other.inherited-class.vala',
|
||||
regex: '\\b(?:[a-z]\\w*\\.)*[A-Z]+\\w*<',
|
||||
push:
|
||||
[ { token: 'entity.other.inherited-class.vala',
|
||||
regex: '>|[^\\w\\s,<]',
|
||||
next: 'pop' },
|
||||
{ include: '#object-types' },
|
||||
{ token: 'storage.type.generic.vala',
|
||||
regex: '<',
|
||||
push:
|
||||
[ { token: 'storage.type.generic.vala',
|
||||
regex: '>|[^\\w\\s,<]',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'storage.type.generic.vala' } ],
|
||||
comment: 'This is just to support <>\'s with no actual type prefix' },
|
||||
{ defaultToken: 'entity.other.inherited-class.vala' } ] },
|
||||
{ token:
|
||||
[ 'entity.other.inherited-class.vala',
|
||||
'keyword.operator.dereference.vala',
|
||||
'entity.other.inherited-class.vala' ],
|
||||
regex: '\\b(?:([a-z]\\w*)(\\.))*([A-Z]+\\w*)' } ],
|
||||
'#parameters':
|
||||
[ { token: 'storage.modifier.vala', regex: 'final' },
|
||||
{ include: '#primitive-arrays' },
|
||||
{ include: '#primitive-types' },
|
||||
{ include: '#object-types' },
|
||||
{ token: 'variable.parameter.vala', regex: '\\w+' } ],
|
||||
'#parens':
|
||||
[ { token: 'text',
|
||||
regex: '\\(',
|
||||
push:
|
||||
[ { token: 'text', regex: '\\)', next: 'pop' },
|
||||
{ include: '#code' } ] } ],
|
||||
'#primitive-arrays':
|
||||
[ { token: 'storage.type.primitive.array.vala',
|
||||
regex: '\\b(?:bool|byte|sbyte|char|decimal|double|float|int|uint|long|ulong|object|short|ushort|string|void|int8|int16|int32|int64|uint8|uint16|uint32|uint64)(?:\\[\\])*\\b' } ],
|
||||
'#primitive-types':
|
||||
[ { token: 'storage.type.primitive.vala',
|
||||
regex: '\\b(?:var|bool|byte|sbyte|char|decimal|double|float|int|uint|long|ulong|object|short|ushort|string|void|signal|int8|int16|int32|int64|uint8|uint16|uint32|uint64)\\b',
|
||||
comment: 'var is not really a primitive, but acts like one in most cases' } ],
|
||||
'#storage-modifiers':
|
||||
[ { token: 'storage.modifier.vala',
|
||||
regex: '\\b(?:public|private|protected|internal|static|final|sealed|virtual|override|abstract|readonly|volatile|dynamic|async|unsafe|out|ref|weak|owned|unowned|const)\\b',
|
||||
comment: 'Not sure about unsafe and readonly' } ],
|
||||
'#strings':
|
||||
[ { token: 'punctuation.definition.string.begin.vala',
|
||||
regex: '@"',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.vala',
|
||||
regex: '"',
|
||||
next: 'pop' },
|
||||
{ token: 'constant.character.escape.vala',
|
||||
regex: '\\\\.|%[\\w\\.\\-]+|\\$(?:\\w+|\\([\\w\\s\\+\\-\\*\\/]+\\))' },
|
||||
{ defaultToken: 'string.quoted.interpolated.vala' } ] },
|
||||
{ token: 'punctuation.definition.string.begin.vala',
|
||||
regex: '"',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.vala',
|
||||
regex: '"',
|
||||
next: 'pop' },
|
||||
{ token: 'constant.character.escape.vala', regex: '\\\\.' },
|
||||
{ token: 'constant.character.escape.vala',
|
||||
regex: '%[\\w\\.\\-]+' },
|
||||
{ defaultToken: 'string.quoted.double.vala' } ] },
|
||||
{ token: 'punctuation.definition.string.begin.vala',
|
||||
regex: '\'',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.vala',
|
||||
regex: '\'',
|
||||
next: 'pop' },
|
||||
{ token: 'constant.character.escape.vala', regex: '\\\\.' },
|
||||
{ defaultToken: 'string.quoted.single.vala' } ] },
|
||||
{ token: 'punctuation.definition.string.begin.vala',
|
||||
regex: '"""',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.vala',
|
||||
regex: '"""',
|
||||
next: 'pop' },
|
||||
{ token: 'constant.character.escape.vala',
|
||||
regex: '%[\\w\\.\\-]+' },
|
||||
{ defaultToken: 'string.quoted.triple.vala' } ] } ],
|
||||
'#throws':
|
||||
[ { token: 'storage.modifier.vala',
|
||||
regex: 'throws',
|
||||
push:
|
||||
[ { token: 'meta.throwables.vala', regex: '(?={|;)', next: 'pop' },
|
||||
{ include: '#object-types' },
|
||||
{ defaultToken: 'meta.throwables.vala' } ] } ],
|
||||
'#values':
|
||||
[ { include: '#strings' },
|
||||
{ include: '#object-types' },
|
||||
{ include: '#constants-and-special-vars' } ] }
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
ValaHighlightRules.metaData = {
|
||||
comment: 'Based heavily on the Java bundle\'s language syntax. TODO:\n* Closures\n* Delegates\n* Properties: Better support for properties.\n* Annotations\n* Error domains\n* Named arguments\n* Array slicing, negative indexes, multidimensional\n* construct blocks\n* lock blocks?\n* regex literals\n* DocBlock syntax highlighting. (Currently importing javadoc)\n* Folding rule for comments.\n',
|
||||
fileTypes: [ 'vala' ],
|
||||
foldingStartMarker: '(\\{\\s*(//.*)?$|^\\s*// \\{\\{\\{)',
|
||||
foldingStopMarker: '^\\s*(\\}|// \\}\\}\\}$)',
|
||||
name: 'Vala',
|
||||
scopeName: 'source.vala' }
|
||||
|
||||
|
||||
oop.inherits(ValaHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.ValaHighlightRules = ValaHighlightRules;
|
||||
});
|
||||
|
|
@ -109,12 +109,15 @@ function DefaultHandlers(mouseHandler) {
|
|||
var editor = this.editor;
|
||||
// allow double/triple click handlers to change selection
|
||||
var shiftPressed = this.mousedownEvent.getShiftKey();
|
||||
if (shiftPressed) {
|
||||
editor.selection.selectToPosition(pos);
|
||||
}
|
||||
else if (!this.$clickSelection) {
|
||||
editor.selection.moveToPosition(pos);
|
||||
}
|
||||
setTimeout(function(){
|
||||
if (shiftPressed) {
|
||||
editor.selection.selectToPosition(pos);
|
||||
}
|
||||
else if (!this.$clickSelection) {
|
||||
editor.selection.moveToPosition(pos);
|
||||
}
|
||||
this.select();
|
||||
}.bind(this), 0);
|
||||
if (editor.renderer.scroller.setCapture) {
|
||||
editor.renderer.scroller.setCapture();
|
||||
}
|
||||
|
|
@ -213,7 +216,6 @@ function DefaultHandlers(mouseHandler) {
|
|||
this.setState("selectByWords");
|
||||
}
|
||||
this.$clickSelection = range;
|
||||
this[this.state] && this[this.state](ev);
|
||||
};
|
||||
|
||||
this.onTripleClick = function(ev) {
|
||||
|
|
@ -221,8 +223,13 @@ function DefaultHandlers(mouseHandler) {
|
|||
var editor = this.editor;
|
||||
|
||||
this.setState("selectByLines");
|
||||
this.$clickSelection = editor.selection.getLineRange(pos.row);
|
||||
this[this.state] && this[this.state](ev);
|
||||
var range = editor.getSelectionRange();
|
||||
if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
|
||||
this.$clickSelection = editor.selection.getLineRange(range.start.row);
|
||||
this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
|
||||
} else {
|
||||
this.$clickSelection = editor.selection.getLineRange(pos.row);
|
||||
}
|
||||
};
|
||||
|
||||
this.onQuadClick = function(ev) {
|
||||
|
|
|
|||
|
|
@ -40,13 +40,18 @@ var DragdropHandler = require("./dragdrop_handler").DragdropHandler;
|
|||
var config = require("../config");
|
||||
|
||||
var MouseHandler = function(editor) {
|
||||
var _self = this;
|
||||
this.editor = editor;
|
||||
|
||||
new DefaultHandlers(this);
|
||||
new DefaultGutterHandler(this);
|
||||
new DragdropHandler(this);
|
||||
|
||||
var focusEditor = function(e) { editor.focus() };
|
||||
var focusEditor = function(e) {
|
||||
if (!editor.isFocused() && editor.textInput)
|
||||
editor.textInput.moveToMouse(e);
|
||||
editor.focus()
|
||||
};
|
||||
|
||||
var mouseTarget = editor.renderer.getMouseEventTarget();
|
||||
event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
|
||||
|
|
@ -74,6 +79,21 @@ var MouseHandler = function(editor) {
|
|||
editor.focus();
|
||||
return event.preventDefault(e);
|
||||
});
|
||||
|
||||
editor.on("mousemove", function(e){
|
||||
if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
|
||||
return;
|
||||
|
||||
var char = editor.renderer.screenToTextCoordinates(e.x, e.y);
|
||||
var range = editor.session.selection.getRange();
|
||||
var renderer = editor.renderer;
|
||||
|
||||
if (!range.isEmpty() && range.insideStart(char.row, char.column)) {
|
||||
renderer.setCursorStyle("default");
|
||||
} else {
|
||||
renderer.setCursorStyle("");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
|
@ -157,11 +177,22 @@ var MouseHandler = function(editor) {
|
|||
var timerId = setInterval(onCaptureInterval, 20);
|
||||
};
|
||||
this.releaseMouse = null;
|
||||
this.cancelContextMenu = function() {
|
||||
var stop = function(e) {
|
||||
if (e && e.domEvent && e.domEvent.type != "contextmenu")
|
||||
return;
|
||||
this.editor.off("nativecontextmenu", stop);
|
||||
if (e && e.domEvent)
|
||||
event.stopEvent(e.domEvent);
|
||||
}.bind(this);
|
||||
setTimeout(stop, 10);
|
||||
this.editor.on("nativecontextmenu", stop);
|
||||
};
|
||||
}).call(MouseHandler.prototype);
|
||||
|
||||
config.defineOptions(MouseHandler.prototype, "mouseHandler", {
|
||||
scrollSpeed: {initialValue: 2},
|
||||
dragDelay: {initialValue: 150},
|
||||
dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
|
||||
dragEnabled: {initialValue: true},
|
||||
focusTimout: {initialValue: 0},
|
||||
tooltipFollowsMouse: {initialValue: true}
|
||||
|
|
|
|||
|
|
@ -58,15 +58,17 @@ module.exports = {
|
|||
next();
|
||||
},
|
||||
|
||||
"test: double tap. issue #956" : function() {
|
||||
"test: double tap. issue #956" : function(done) {
|
||||
// mouse up fired immediately after mouse down
|
||||
var target = this.editor.renderer.getMouseEventTarget();
|
||||
target.dispatchEvent(MouseEvent("down", {x: 1, y: 1}));
|
||||
target.dispatchEvent(MouseEvent("up", {x: 1, y: 1}));
|
||||
target.dispatchEvent(MouseEvent("down", {x: 1, y: 1, detail: 2}));
|
||||
target.dispatchEvent(MouseEvent("up", {x: 1, y: 1, detail: 2}));
|
||||
|
||||
assert.equal(this.editor.getSelectedText(), "Juhu");
|
||||
setTimeout(function() {
|
||||
assert.equal(this.editor.getSelectedText(), "Juhu");
|
||||
done();
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
define(function(require, exports, module) {
|
||||
|
||||
var event = require("../lib/event");
|
||||
var useragent = require("../lib/useragent");
|
||||
|
||||
// mouse
|
||||
function isSamePoint(p1, p2) {
|
||||
|
|
@ -41,19 +42,26 @@ function onMouseDown(e) {
|
|||
var ev = e.domEvent;
|
||||
var alt = ev.altKey;
|
||||
var shift = ev.shiftKey;
|
||||
var ctrl = e.getAccelKey();
|
||||
var ctrl = ev.ctrlKey;
|
||||
var accel = e.getAccelKey();
|
||||
var button = e.getButton();
|
||||
|
||||
if (ctrl && useragent.isMac)
|
||||
button = ev.button;
|
||||
|
||||
if (e.editor.inMultiSelectMode && button == 2) {
|
||||
e.editor.textInput.onContextMenu(e.domEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ctrl && !alt) {
|
||||
if (!ctrl && !alt && !accel) {
|
||||
if (button === 0 && e.editor.inMultiSelectMode)
|
||||
e.editor.exitMultiSelectMode();
|
||||
return;
|
||||
}
|
||||
|
||||
if (button !== 0)
|
||||
return;
|
||||
|
||||
var editor = e.editor;
|
||||
var selection = editor.selection;
|
||||
|
|
@ -62,38 +70,37 @@ function onMouseDown(e) {
|
|||
var cursor = selection.getCursor();
|
||||
var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
|
||||
|
||||
|
||||
var mouseX = e.x, mouseY = e.y;
|
||||
var onMouseSelection = function(e) {
|
||||
mouseX = e.clientX;
|
||||
mouseY = e.clientY;
|
||||
};
|
||||
|
||||
var blockSelect = function() {
|
||||
var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
|
||||
var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
|
||||
|
||||
if (isSamePoint(screenCursor, newCursor)
|
||||
&& isSamePoint(cursor, selection.selectionLead))
|
||||
return;
|
||||
screenCursor = newCursor;
|
||||
|
||||
editor.selection.moveToPosition(cursor);
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
|
||||
editor.removeSelectionMarkers(rectSel);
|
||||
rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
|
||||
rectSel.forEach(editor.addSelectionMarker, editor);
|
||||
editor.updateSelectionMarkers();
|
||||
};
|
||||
|
||||
var session = editor.session;
|
||||
var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
|
||||
var screenCursor = screenAnchor;
|
||||
|
||||
|
||||
var selectionMode;
|
||||
if (editor.$mouseHandler.$enableJumpToDef) {
|
||||
if (ctrl && alt || accel && alt)
|
||||
selectionMode = "add";
|
||||
else if (alt)
|
||||
selectionMode = "block";
|
||||
} else {
|
||||
if (accel && !alt) {
|
||||
selectionMode = "add";
|
||||
if (!isMultiSelect && shift)
|
||||
return;
|
||||
} else if (alt) {
|
||||
selectionMode = "block";
|
||||
}
|
||||
}
|
||||
|
||||
if (selectionMode && useragent.isMac && ev.ctrlKey) {
|
||||
editor.$mouseHandler.cancelContextMenu();
|
||||
}
|
||||
|
||||
if (ctrl && !alt && !shift && button === 0) {
|
||||
if (selectionMode == "add") {
|
||||
if (!isMultiSelect && inSelection)
|
||||
return; // dragging
|
||||
|
||||
|
|
@ -104,44 +111,86 @@ function onMouseDown(e) {
|
|||
|
||||
var oldRange = selection.rangeList.rangeAtPoint(pos);
|
||||
|
||||
|
||||
editor.$blockScrolling++;
|
||||
editor.inVirtualSelectionMode = true;
|
||||
|
||||
if (shift) {
|
||||
oldRange = null;
|
||||
range = selection.ranges[0];
|
||||
editor.removeSelectionMarker(range);
|
||||
}
|
||||
editor.once("mouseup", function() {
|
||||
var tmpSel = selection.toOrientedRange();
|
||||
|
||||
if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
|
||||
selection.substractPoint(tmpSel.cursor);
|
||||
else {
|
||||
if (range) {
|
||||
if (shift) {
|
||||
selection.substractPoint(range.cursor);
|
||||
} else if (range) {
|
||||
editor.removeSelectionMarker(range);
|
||||
selection.addRange(range);
|
||||
}
|
||||
selection.addRange(tmpSel);
|
||||
}
|
||||
editor.$blockScrolling--;
|
||||
editor.inVirtualSelectionMode = false;
|
||||
});
|
||||
|
||||
} else if (alt && button === 0) {
|
||||
} else if (selectionMode == "block") {
|
||||
e.stop();
|
||||
|
||||
if (isMultiSelect && !ctrl)
|
||||
selection.toSingleRange();
|
||||
else if (!isMultiSelect && ctrl)
|
||||
selection.addRange();
|
||||
|
||||
editor.inVirtualSelectionMode = true;
|
||||
var initialRange;
|
||||
var rectSel = [];
|
||||
if (shift) {
|
||||
screenAnchor = session.documentToScreenPosition(selection.lead);
|
||||
blockSelect();
|
||||
} else {
|
||||
selection.moveToPosition(pos);
|
||||
}
|
||||
var blockSelect = function() {
|
||||
var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
|
||||
var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
|
||||
|
||||
if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
|
||||
return;
|
||||
screenCursor = newCursor;
|
||||
|
||||
editor.selection.moveToPosition(cursor);
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
|
||||
editor.removeSelectionMarkers(rectSel);
|
||||
rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
|
||||
if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
|
||||
rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
|
||||
rectSel.forEach(editor.addSelectionMarker, editor);
|
||||
editor.updateSelectionMarkers();
|
||||
};
|
||||
|
||||
if (isMultiSelect && !accel) {
|
||||
selection.toSingleRange();
|
||||
} else if (!isMultiSelect && accel) {
|
||||
initialRange = selection.toOrientedRange();
|
||||
editor.addSelectionMarker(initialRange);
|
||||
}
|
||||
|
||||
if (shift)
|
||||
screenAnchor = session.documentToScreenPosition(selection.lead);
|
||||
else
|
||||
selection.moveToPosition(pos);
|
||||
|
||||
screenCursor = {row: -1, column: -1};
|
||||
|
||||
var onMouseSelectionEnd = function(e) {
|
||||
clearInterval(timerId);
|
||||
editor.removeSelectionMarkers(rectSel);
|
||||
if (!rectSel.length)
|
||||
rectSel = [selection.toOrientedRange()];
|
||||
editor.$blockScrolling++;
|
||||
if (initialRange) {
|
||||
editor.removeSelectionMarker(initialRange);
|
||||
selection.toSingleRange(initialRange);
|
||||
}
|
||||
for (var i = 0; i < rectSel.length; i++)
|
||||
selection.addRange(rectSel[i]);
|
||||
editor.inVirtualSelectionMode = false;
|
||||
editor.$mouseHandler.$clickSelection = null;
|
||||
editor.$blockScrolling--;
|
||||
};
|
||||
|
||||
var onSelectionInterval = blockSelect;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ var EditSession = require("./edit_session").EditSession;
|
|||
if (!range)
|
||||
return;
|
||||
|
||||
if (!this.inMultiSelectMode && this.rangeCount == 0) {
|
||||
if (!this.inMultiSelectMode && this.rangeCount === 0) {
|
||||
var oldRange = this.toOrientedRange();
|
||||
this.rangeList.add(oldRange);
|
||||
this.rangeList.add(range);
|
||||
|
|
@ -168,7 +168,7 @@ var EditSession = require("./edit_session").EditSession;
|
|||
|
||||
this._signal("removeRange", {ranges: removed});
|
||||
|
||||
if (this.rangeCount == 0 && this.inMultiSelectMode) {
|
||||
if (this.rangeCount === 0 && this.inMultiSelectMode) {
|
||||
this.inMultiSelectMode = false;
|
||||
this._signal("singleSelect");
|
||||
this.session.$undoSelect = true;
|
||||
|
|
@ -543,6 +543,19 @@ var Editor = require("./editor").Editor;
|
|||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
this.$checkMultiselectChange = function(e, anchor) {
|
||||
if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
|
||||
var range = this.multiSelect.ranges[0];
|
||||
if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
|
||||
return;
|
||||
var pos = anchor == this.multiSelect.anchor
|
||||
? range.cursor == range.start ? range.end : range.start
|
||||
: range.cursor;
|
||||
if (!isSamePoint(pos, anchor))
|
||||
this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
|
||||
}
|
||||
};
|
||||
|
||||
// todo this should change when paste becomes a command
|
||||
this.onPaste = function(text) {
|
||||
|
|
@ -742,8 +755,15 @@ var Editor = require("./editor").Editor;
|
|||
var session = this.session;
|
||||
var sel = session.multiSelect;
|
||||
var ranges = sel.ranges;
|
||||
|
||||
if (!ranges.length) {
|
||||
// filter out ranges on same row
|
||||
var row = -1;
|
||||
var sameRowRanges = ranges.filter(function(r) {
|
||||
if (r.cursor.row == row)
|
||||
return true;
|
||||
row = r.cursor.row;
|
||||
});
|
||||
|
||||
if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
|
||||
var range = this.selection.getRange();
|
||||
var fr = range.start.row, lr = range.end.row;
|
||||
var guessRange = fr == lr;
|
||||
|
|
@ -769,14 +789,9 @@ var Editor = require("./editor").Editor;
|
|||
}
|
||||
this.selection.setRange(range);
|
||||
} else {
|
||||
// filter out ranges on same row
|
||||
var row = -1;
|
||||
var sameRowRanges = ranges.filter(function(r) {
|
||||
if (r.cursor.row == row)
|
||||
return true;
|
||||
row = r.cursor.row;
|
||||
sameRowRanges.forEach(function(r) {
|
||||
sel.substractPoint(r.cursor);
|
||||
});
|
||||
sel.$onRemoveRange(sameRowRanges);
|
||||
|
||||
var maxCol = 0;
|
||||
var minSpace = Infinity;
|
||||
|
|
@ -851,19 +866,19 @@ var Editor = require("./editor").Editor;
|
|||
function alignLeft(m) {
|
||||
return !m[2] ? m[0] : spaces(startW) + m[2]
|
||||
+ spaces(textW - m[2].length + endW)
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ")
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ");
|
||||
}
|
||||
function alignRight(m) {
|
||||
return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
|
||||
+ spaces(endW, " ")
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ")
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ");
|
||||
}
|
||||
function unAlign(m) {
|
||||
return !m[2] ? m[0] : spaces(startW) + m[2]
|
||||
+ spaces(endW)
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ")
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ");
|
||||
}
|
||||
}
|
||||
};
|
||||
}).call(Editor.prototype);
|
||||
|
||||
|
||||
|
|
@ -884,17 +899,21 @@ exports.onSessionChange = function(e) {
|
|||
|
||||
var oldSession = e.oldSession;
|
||||
if (oldSession) {
|
||||
oldSession.multiSelect.removeEventListener("addRange", this.$onAddRange);
|
||||
oldSession.multiSelect.removeEventListener("removeRange", this.$onRemoveRange);
|
||||
oldSession.multiSelect.removeEventListener("multiSelect", this.$onMultiSelect);
|
||||
oldSession.multiSelect.removeEventListener("singleSelect", this.$onSingleSelect);
|
||||
oldSession.multiSelect.off("addRange", this.$onAddRange);
|
||||
oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
|
||||
oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
|
||||
oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
|
||||
oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
|
||||
oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
|
||||
}
|
||||
|
||||
session.multiSelect.on("addRange", this.$onAddRange);
|
||||
session.multiSelect.on("removeRange", this.$onRemoveRange);
|
||||
session.multiSelect.on("multiSelect", this.$onMultiSelect);
|
||||
session.multiSelect.on("singleSelect", this.$onSingleSelect);
|
||||
|
||||
session.multiSelect.lead.on("change", this.$checkMultiselectChange);
|
||||
session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
|
||||
|
||||
// this.$onSelectionChange = this.onSelectionChange.bind(this);
|
||||
|
||||
if (this.inMultiSelectMode != session.selection.inMultiSelectMode) {
|
||||
|
|
@ -916,6 +935,7 @@ function MultiSelect(editor) {
|
|||
editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
|
||||
editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
|
||||
editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
|
||||
editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
|
||||
|
||||
editor.$multiselectOnSessionChange(editor);
|
||||
editor.on("changeSession", editor.$multiselectOnSessionChange);
|
||||
|
|
@ -969,7 +989,7 @@ require("./config").defineOptions(Editor.prototype, "editor", {
|
|||
},
|
||||
value: true
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
|||
var Range = require("./range").Range;
|
||||
|
||||
/**
|
||||
*
|
||||
* Contains the cursor position and the text selection of an edit session.
|
||||
*
|
||||
* The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding.
|
||||
|
|
@ -49,22 +48,16 @@ var Range = require("./range").Range;
|
|||
* Emitted when the cursor position changes.
|
||||
* @event changeCursor
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
/**
|
||||
* Emitted when the cursor selection changes.
|
||||
*
|
||||
* @event changeSelection
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
/**
|
||||
* Creates a new `Selection` object.
|
||||
* @param {EditSession} session The session to use
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
**/
|
||||
var Selection = function(session) {
|
||||
|
|
|
|||
7
lib/ace/snippets/gitignore.js
Normal file
7
lib/ace/snippets/gitignore.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./gitignore.snippets");
|
||||
exports.scope = "gitignore";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/gitignore.snippets
Normal file
0
lib/ace/snippets/gitignore.snippets
Normal file
195
lib/ace/snippets/vala.js
Normal file
195
lib/ace/snippets/vala.js
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
// exports.snippetText = require("../requirejs/text!./.snippets");
|
||||
exports.snippets = [
|
||||
{
|
||||
"content": "case ${1:condition}:\n\t$0\n\tbreak;\n",
|
||||
"name": "case",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "case"
|
||||
},
|
||||
{
|
||||
"content": "/**\n * ${6}\n */\n${1:public} class ${2:MethodName}${3: : GLib.Object} {\n\n\t/**\n\t * ${7}\n\t */\n\tpublic ${2}(${4}) {\n\t\t${5}\n\t}\n\n\t$0\n}",
|
||||
"name": "class",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "class"
|
||||
},
|
||||
{
|
||||
"content": "(${1}) => {\n\t${0}\n}\n",
|
||||
"name": "closure",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "=>"
|
||||
},
|
||||
{
|
||||
"content": "/*\n * $0\n */",
|
||||
"name": "Comment (multiline)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "/*"
|
||||
},
|
||||
{
|
||||
"content": "Console.WriteLine($1);\n$0",
|
||||
"name": "Console.WriteLine (writeline)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "writeline"
|
||||
},
|
||||
{
|
||||
"content": "[DBus(name = \"$0\")]",
|
||||
"name": "DBus annotation",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "[DBus"
|
||||
},
|
||||
{
|
||||
"content": "delegate ${1:void} ${2:DelegateName}($0);",
|
||||
"name": "delegate",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "delegate"
|
||||
},
|
||||
{
|
||||
"content": "do {\n\t$0\n} while ($1);\n",
|
||||
"name": "do while",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "dowhile"
|
||||
},
|
||||
{
|
||||
"content": "/**\n * $0\n */",
|
||||
"name": "DocBlock",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "/**"
|
||||
},
|
||||
{
|
||||
"content": "else if ($1) {\n\t$0\n}\n",
|
||||
"name": "else if (elseif)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "elseif"
|
||||
},
|
||||
{
|
||||
"content": "else {\n\t$0\n}",
|
||||
"name": "else",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "else"
|
||||
},
|
||||
{
|
||||
"content": "enum {$1:EnumName} {\n\t$0\n}",
|
||||
"name": "enum",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "enum"
|
||||
},
|
||||
{
|
||||
"content": "public errordomain ${1:Error} {\n\t$0\n}",
|
||||
"name": "error domain",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "errordomain"
|
||||
},
|
||||
{
|
||||
"content": "for ($1;$2;$3) {\n\t$0\n}",
|
||||
"name": "for",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "for"
|
||||
},
|
||||
{
|
||||
"content": "foreach ($1 in $2) {\n\t$0\n}",
|
||||
"name": "foreach",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "foreach"
|
||||
},
|
||||
{
|
||||
"content": "Gee.ArrayList<${1:G}>($0);",
|
||||
"name": "Gee.ArrayList",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "ArrayList"
|
||||
},
|
||||
{
|
||||
"content": "Gee.HashMap<${1:K},${2:V}>($0);",
|
||||
"name": "Gee.HashMap",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "HashMap"
|
||||
},
|
||||
{
|
||||
"content": "Gee.HashSet<${1:G}>($0);",
|
||||
"name": "Gee.HashSet",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "HashSet"
|
||||
},
|
||||
{
|
||||
"content": "if ($1) {\n\t$0\n}",
|
||||
"name": "if",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "if"
|
||||
},
|
||||
{
|
||||
"content": "interface ${1:InterfaceName}{$2: : SuperInterface} {\n\t$0\n}",
|
||||
"name": "interface",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "interface"
|
||||
},
|
||||
{
|
||||
"content": "public static int main(string [] argv) {\n\t${0}\n\treturn 0;\n}",
|
||||
"name": "Main function",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "main"
|
||||
},
|
||||
{
|
||||
"content": "namespace $1 {\n\t$0\n}\n",
|
||||
"name": "namespace (ns)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "ns"
|
||||
},
|
||||
{
|
||||
"content": "stdout.printf($0);",
|
||||
"name": "printf",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "printf"
|
||||
},
|
||||
{
|
||||
"content": "${1:public} ${2:Type} ${3:Name} {\n\tset {\n\t\t$0\n\t}\n\tget {\n\n\t}\n}",
|
||||
"name": "property (prop)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "prop"
|
||||
},
|
||||
{
|
||||
"content": "${1:public} ${2:Type} ${3:Name} {\n\tget {\n\t\t$0\n\t}\n}",
|
||||
"name": "read-only property (roprop)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "roprop"
|
||||
},
|
||||
{
|
||||
"content": "@\"${1:\\$var}\"",
|
||||
"name": "String template (@)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "@"
|
||||
},
|
||||
{
|
||||
"content": "struct ${1:StructName} {\n\t$0\n}",
|
||||
"name": "struct",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "struct"
|
||||
},
|
||||
{
|
||||
"content": "switch ($1) {\n\t$0\n}",
|
||||
"name": "switch",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "switch"
|
||||
},
|
||||
{
|
||||
"content": "try {\n\t$2\n} catch (${1:Error} e) {\n\t$0\n}",
|
||||
"name": "try/catch",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "try"
|
||||
},
|
||||
{
|
||||
"content": "\"\"\"$0\"\"\";",
|
||||
"name": "Verbatim string (\"\"\")",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "verbatim"
|
||||
},
|
||||
{
|
||||
"content": "while ($1) {\n\t$0\n}",
|
||||
"name": "while",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "while"
|
||||
}
|
||||
];
|
||||
exports.scope = "";
|
||||
|
||||
});
|
||||
|
|
@ -44,6 +44,7 @@ var testNames = [
|
|||
"ace/mode/folding/xml_test",
|
||||
"ace/mode/folding/coffee_test",
|
||||
"ace/multi_select_test",
|
||||
"ace/mouse/mouse_handler_test",
|
||||
"ace/occur_test",
|
||||
"ace/range_test",
|
||||
"ace/range_list_test",
|
||||
|
|
|
|||
|
|
@ -116,6 +116,11 @@ var Tokenizer = function(rules) {
|
|||
rule.onMatch = null;
|
||||
}
|
||||
|
||||
if (!ruleRegExps.length) {
|
||||
mapping[0] = 0;
|
||||
ruleRegExps.push("$");
|
||||
}
|
||||
|
||||
splitterRurles.forEach(function(rule) {
|
||||
rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
|
||||
}, this);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@
|
|||
"asyncjs": "0.0.x",
|
||||
"jsdom": "0.2.x",
|
||||
"amd-loader": "~0.0.4",
|
||||
"dryice": "0.4.10"
|
||||
"dryice": "0.4.11",
|
||||
"architect-build": "https://github.com/c9/architect-build/tarball/42723e152bb"
|
||||
},
|
||||
"mappings": {
|
||||
"ace": "."
|
||||
|
|
@ -30,6 +31,7 @@
|
|||
"lib": "lib/ace"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node static.js",
|
||||
"test": "node lib/ace/test/all.js"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ var deps = {
|
|||
jshint: {
|
||||
path: "mode/javascript/jshint.js",
|
||||
browserify: {
|
||||
npmModule: "git+https://github.com/nightwing/jshint.git#master",
|
||||
npmModule: "git+https://github.com/ajaxorg/jshint.git#master",
|
||||
path: "jshint/src/jshint.js",
|
||||
exports: "jshint"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue