Merge remote-tracking branch 'remotes/origin/master'

Conflicts:
	lib/ace/line_widgets.js
This commit is contained in:
nightwing 2014-01-16 00:14:34 +04:00
commit c8fca3053c
34 changed files with 1232 additions and 221 deletions

View file

@ -1,4 +1,5 @@
2013.12.02 Version 1.1.2
* New Features
- Accessibility Theme for Ace (Peter Xiao)
- use snipetManager for expanding emmet snippets
@ -21,9 +22,8 @@
- Protobuf (Zef Hemel)
- Soy
- Handlebars
-
2013.06.04 Version 1.1.01
2013.06.04 Version 1.1.1
- Improved emacs keybindings (Robert Krahn)
- Added markClean, isClean methods to UndoManager (Joonsoo Jeon)

View file

@ -297,8 +297,19 @@ function getWriteFilters(options, projectType) {
if (options.compress)
filters.push(copy.filter.uglifyjs);
copy.filter.uglifyjs.options.ascii = true;
// copy.filter.uglifyjs.options.ascii = true; doesn't work with some uglify.js versions
filters.push(function(text) {
var t1 = text.replace(/[\x80-\uffff]/g, function(c) {
c = c.charCodeAt(0).toString(16);
if (c.length == 2)
return "\\x" + c;
if (c.length == 3)
c = "0" + c;
return "\\u" + c;
});
return text;
});
if (options.exportModule && projectType == "main") {
if (options.noconflict)
filters.push(exportAce(options.ns, options.exportModule, options.ns));

View file

@ -32,25 +32,26 @@ define(function(require, exports, module) {
"use strict";
var dom = require("ace/lib/dom");
var oop = require("ace/lib/oop");
var event = require("ace/lib/event");
var Range = require("ace/range").Range;
var Tooltip = require("ace/tooltip").Tooltip;
var tooltipNode;
var TokenTooltip = function(editor) {
function TokenTooltip (editor) {
if (editor.tokenTooltip)
return;
editor.tokenTooltip = this;
Tooltip.call(this, editor.container);
editor.tokenTooltip = this;
this.editor = editor;
editor.tooltip = tooltipNode || this.$init();
this.update = this.update.bind(this);
this.onMouseMove = this.onMouseMove.bind(this);
this.onMouseOut = this.onMouseOut.bind(this);
event.addListener(editor.renderer.scroller, "mousemove", this.onMouseMove);
event.addListener(editor.renderer.content, "mouseout", this.onMouseOut);
};
}
oop.inherits(TokenTooltip, Tooltip);
(function(){
this.token = {};
@ -86,15 +87,10 @@ var TokenTooltip = function(editor) {
}
if (!token) {
session.removeMarker(this.marker);
tooltipNode.style.display = "none";
this.isOpen = false;
this.hide();
return;
}
if (!this.isOpen) {
tooltipNode.style.display = "";
this.isOpen = true;
}
var tokenText = token.type;
if (token.state)
tokenText += "|" + token.state;
@ -102,15 +98,15 @@ var TokenTooltip = function(editor) {
tokenText += "\n merge";
if (token.stateTransitions)
tokenText += "\n " + token.stateTransitions.join("\n ");
if (this.tokenText != tokenText) {
tooltipNode.textContent = tokenText;
this.tooltipWidth = tooltipNode.offsetWidth;
this.tooltipHeight = tooltipNode.offsetHeight;
this.setText(tokenText);
this.width = this.getWidth();
this.height = this.getHeight();
this.tokenText = tokenText;
}
this.updateTooltipPosition(this.x, this.y);
this.show(null, this.x, this.y);
this.token = token;
session.removeMarker(this.marker);
@ -123,56 +119,34 @@ var TokenTooltip = function(editor) {
this.y = e.clientY;
if (this.isOpen) {
this.lastT = e.timeStamp;
this.updateTooltipPosition(this.x, this.y);
this.setPosition(this.x, this.y);
}
if (!this.$timer)
this.$timer = setTimeout(this.update, 100);
};
this.onMouseOut = function(e) {
var t = e && e.relatedTarget;
var ct = e && e.currentTarget;
while(t && (t = t.parentNode)) {
if (t == ct)
return;
}
tooltipNode.style.display = "none";
if (e && e.currentTarget.contains(e.relatedTarget))
return;
this.hide();
this.editor.session.removeMarker(this.marker);
this.$timer = clearTimeout(this.$timer);
this.isOpen = false;
};
this.updateTooltipPosition = function(x, y) {
var st = tooltipNode.style;
if (x + 10 + this.tooltipWidth > this.maxWidth)
x = window.innerWidth - this.tooltipWidth - 10;
if (y > window.innerHeight * 0.75 || y + 20 + this.tooltipHeight > this.maxHeight)
y = y - this.tooltipHeight - 30;
st.left = x + 10 + "px";
st.top = y + 20 + "px";
};
this.$init = function() {
tooltipNode = document.documentElement.appendChild(dom.createElement("div"));
var st = tooltipNode.style;
st.position = "fixed";
st.display = "none";
st.background = "lightyellow";
st.borderRadius = "";
st.border = "1px solid gray";
st.padding = "1px";
st.zIndex = 1000;
st.fontFamily = "monospace";
st.whiteSpace = "pre-line";
return tooltipNode;
this.setPosition = function(x, y) {
if (x + 10 + this.width > this.maxWidth)
x = window.innerWidth - this.width - 10;
if (y > window.innerHeight * 0.75 || y + 20 + this.height > this.maxHeight)
y = y - this.height - 30;
Tooltip.prototype.setPosition.call(this, x + 10, y + 20);
};
this.destroy = function() {
this.onMouseOut();
event.removeListener(this.editor.renderer.scroller, "mousemove", this.onMouseMove);
event.removeListener(this.editor.renderer.content, "mouseout", this.onMouseOut);
delete this.editor.tokenTooltip;
delete this.editor.tokenTooltip;
};
}).call(TokenTooltip.prototype);
@ -180,4 +154,3 @@ var TokenTooltip = function(editor) {
exports.TokenTooltip = TokenTooltip;
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -6,23 +6,21 @@ $(function() {
editor.container.style.opacity = "";
embedded_editor = ace.edit("embedded_ace_code");
embedded_editor.container.style.opacity = "";
editor.session.setMode("ace/mode/javascript");
embedded_editor.session.setMode("ace/mode/html");
embedded_editor.setAutoScrollEditorIntoView(true);
embedded_editor.setOption("maxLines", 40);
editor.setOptions({
maxLines: 30
})
maxLines: 30,
mode: "ace/mode/javascript",
autoScrollEditorIntoView: true
});
ace.config.loadModule("ace/ext/emmet", function() {
ace.require("ace/lib/net").loadScript("http://nightwing.github.io/emmet-core/emmet.js", function() {
embedded_editor.setOption("enableEmmet", true);
editor.setOption("enableEmmet", true);
});
embedded_editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
});
ace.config.loadModule("ace/ext/language_tools", function() {
@ -34,19 +32,21 @@ $(function() {
enableSnippets: true,
enableBasicAutocompletion: true
});
});
$("ul.menu-list").mousedown(function(e) {
if (e.button === 1) {
e.preventDefault();
}
});
embedded_editor.setAutoScrollEditorIntoView(true);
editor.setAutoScrollEditorIntoView(true);
$("ul.menu-list li").click(function(e) {
if (e.target.tagName === "LI") {
console.log($(this).find("a"));
window.location = $(this).find("a").attr("href");
}
else if (e.target.tagName === "P" || e.target.tagName === "IMG") {
var anchor = $(e.target).siblings();
window.location = anchor.attr("href");
if (e.target.tagName !== "A") {
var href = $(this).find("a").attr("href");
if (e.button == 1)
window.open(href, "_blank");
else
window.location = href;
}
});

View file

@ -173,16 +173,14 @@ console.log(addResult);
common operations, such as setting a different language mode or
getting the contents from the editor.
</p>
<h2>Loading Ace from a Local URL</h2>
<p>The above code is all you need to embed Ace in your site (including setting language modes
and themes). Plus it's super fast because it's on Amazon's distributed content network.
</p>
<p>But, if you want to clone host Ace locally you can
<h2>Loading Ace from a Local URL</h2>
<p>If you want to clone and host Ace locally you can
use one of the <a href="https://github.com/ajaxorg/ace-builds/">pre-packaged versions</a>. Just copy
one of <code>src*</code> subdirectories somewhere into your project, or use RequireJS to load the
contents of <a href="https://github.com/ajaxorg/ace/tree/master/lib/ace">lib/ace</a> as <code>ace</code>:
contents of <a href="https://github.com/ajaxorg/ace/tree/master/lib/ace">lib/ace</a> folder as <code>ace</code>:
</p>
<p>The packaged version can also be loaded from CDN's such as <a href="http://www.jsdelivr.com/#!ace">jsDelivr</a> or <a href="http://cdnjs.com/libraries/ace/">cdnjs</a>.
</p>
<pre><code class="javascript">var ace = require("lib/ace");</code></pre>
</div>
<div class="tab-pane fade" id="howto">
<h1>Working with Ace</h1>
@ -795,9 +793,8 @@ if (match) {
<a href="http://plnkr.co/edit/">Plunker</a>
</li>
<li>
<img src="doc/site/images/KERA-med-web.png"
style="left: 3px;top: 23px;width: 97px;" />
<a href="http://kera.io/">Kera.io</a>
<img src="http://zedapp.org/content/images/2013/Nov/Icon-1.png" style="left: -1px;top: -20px;width: 103px;">
<a href="http://zedapp.org">Zed</a>
</li>
<li>
<img src="doc/site/images/sassmeister-logo.png"
@ -834,20 +831,19 @@ if (match) {
left: 19px; top: 6px;width: 60px;height: 60px;background-size: 60px;position: relative;"></div>
<a href="http://habitat.inkling.com">Inkling Habitat</a>
</li>
<li>
<img src="doc/site/images/weecod-logo.png"
style="left: 0px; top: 0px; width: 100px" />
<a href="http://www.weecod.com">Weecod</a>
<li style="width: 248px;">
<img src="http://codecombat.com/images/pages/base/logo.png" style="left: 48px; top: 10px;">
<a href="http://codecombat.com">Code Combat</a>
</li>
<li>
<!--seems to be down <li>
<img src="doc/site/images/lws-logo.png"
style="left: 0px; top: 0px; width: 100px" />
<a href="http://liveworkspace.org">Live Workspace</a>
</li>
</li>-->
<li>
<img src="doc/site/images/processwire-logo.svg"
style="left: 0px; top: 25px; width: 102px" />
<a href=" http://modules.processwire.com/modules/inputfield-ace-editor/">Process<i>Wire</i></a>
<img src="doc/site/images/repl.it-logo.png"
style="left: 0px; top: 17px; width: 100px" />
<a href="http://repl.it/">Repl.it</a>
</li>
<li>
<img src="doc/site/images/stypi-logo.png"
@ -855,9 +851,14 @@ if (match) {
<a href="https://code.stypi.com/">Stypi</a>
</li>
<li>
<img src="doc/site/images/repl.it-logo.png"
style="left: 0px; top: 17px; width: 100px" />
<a href="http://repl.it/">Repl.it</a>
<img src="doc/site/images/weecod-logo.png"
style="left: 0px; top: 0px; width: 100px" />
<a href="http://www.weecod.com">Weecod</a>
</li>
<li>
<img src="doc/site/images/processwire-logo.svg"
style="left: 0px; top: 25px; width: 102px" />
<a href=" http://modules.processwire.com/modules/inputfield-ace-editor/">Process<i>Wire</i></a>
</li>
<li>
<img src="doc/site/images/crunchapp-logo.png"
@ -877,7 +878,7 @@ if (match) {
<li>
<img src="http://phpassist.com/images/logo-large.png"
style="left: 3px; top: -10px; width: 95px">
<a href="http://phpassist.com/">PHP Assist</a>
<a href="http://phpassist.com/f8456">PHP Assist</a>
</li>
<li>
<div class="text-logo">Dillinger</div>
@ -938,11 +939,10 @@ if (match) {
<a href="http://www.debuggex.com">Debuggex</a>
</li>
<li>
<div style="width: 90px; left: 5px; top: -17px;background:rgb(23,23,23);color:rgb(181,232,83);
font-family: Monaco, 'Bitstream Vera Sans Mono', 'Lucida Console', Terminal, monospace;
<div style="width:90px; left:9px; top:-6px;background:rgb(23,23,23);color:rgb(181,232,83);
font: 90px/90px Monaco, 'Bitstream Vera Sans Mono', 'Lucida Console', Terminal, monospace;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(181, 232, 83, 0.1), 0 0 10px rgba(181, 232, 83, 0.1);
-webkit-font-smoothing: antialiased;
font-size: 90px;text-align: center;line-height: 90px;">S</div>
-webkit-font-smoothing: antialiased; text-align: center; position: absolute;">S</div>
<a href="http://slimtext.org/">Slim Text</a>
</li>
<li>
@ -952,7 +952,7 @@ if (match) {
<a href="https://www.decor-tab-creator.com">Decor</a>
</li>
<li>
<img src="https://app.divshot.com/images/logo-glyph.svg"
<img src="https://2.gravatar.com/avatar/cca33939e02e36446015d57b01868d2d?d=https%3A%2F%2Fidenticons.github.com%2F260479af5073adc51195677756073de5.png&r=x&s=100"
style="left: 12px; width: 79px;top: -18px;">
<a href="http://www.divshot.com/">Divshot</a>
</li>
@ -1050,14 +1050,13 @@ if (match) {
<a href="https://github.com/websiteduck/Run-PHP-Code">RunPHPCode</a>
</li>
<li>
<img src="http://instaedu.com/publish/static/img/20ac02f.png"
style="width: 111px; left: -3px; top: 30px;">
<div class="text-logo">InstaEDU</div>
<a href="http://instaedu.com/lesson-demo/">InstaEDU</a>
</li>
<li>
<img src="http://s7.postimg.org/tbw9lfcvb/cloudcmd.png"
style="width: 74px; left: 13px; top: -2px;">
<a href="http://coderaiser.github.io/cloudcmd">CloudCmd</a>
<a href="http://cloudcmd.io">Cloud Commander</a>
</li>
<li>
<img src="http://www.ogeditor.com/images/logo.png"
@ -1098,10 +1097,45 @@ if (match) {
<div class="text-logo">md</div>
<a href="http://thlorenz.github.io/browserify-markdown-editor/">browserify-markdown-editor</a>
</li>
<li>
<img src="http://www.siteleaf.com/images/logo.svg" style="left: 20px; top: -15px; width: 60px;">
<a href="http://www.siteleaf.com/">Siteleaf</a>
</li>
<li>
<div class="" style="
background: url(http://colorsublime.com/img/ColorSublime_logo.png);
position: absolute;height: 65px;width: 99px;
background-size: 310px 128px;background-position: 210px top;
"></div>
<a href="http://colorsublime.com/">ColorSublime</a>
</li>
<li>
<div class="text-logo">iMDone</div>
<a href="http://piascikj.github.io/imdone/">iMDone</a>
</li>
<li>
<div class="text-logo"></div>
<a href="http://bakemycss.mypathforpython.appspot.com/">BakeMyCss</a>
</li>
<li>
<div class="" style="
background: url(https://s3.amazonaws.com/spark-website/spark.png) no-repeat;
position: absolute; height: 65px; width: 83px; background-size: 200px 65px;
background-position: 19px;"></div>
<a href="http://spark.io/build">Spark Core</a>
</li>
<li>
<img src="https://2.gravatar.com/avatar/021e207e86fe81a7d81c67ef1ff38a0c" style="left: 11px; top: -5px;">
<a href="http://owncloud.org">ownCloud</a>
</li>
<li>
<img src="http://www.ezoui.com/prod/images/EZo_logo.png" style="left: 11px; top: -5px;">
<a href="http://jqmdesigner.appspot.com">JQM Designer</a>
</li>
<li>
<img src="http://www.praczone.info/images/praczone.png" style="top: 20px;width: 100px;">
<a href=" http://www.praczone.com/editor">pracZone</a>
</li>
<li>
<a href="https://github.com/Gozala/sky-edit">Sky Edit</a>
</li>
@ -1112,6 +1146,8 @@ if (match) {
<a href="http://www.playmycode.com/">Play My Code</a>
</li>
<li>
<img src="http://resources.qooxdoo.org/images/logo.gif"
style="width: 125px; left: -13px; top: 18px;">
<a href="http://demo.qooxdoo.org/devel/playground/#">Qooxdoo playground</a>
</li>
<li>
@ -1127,17 +1163,18 @@ if (match) {
<div class="text-logo">ShareJS</div>
<a href="http://sharejs.org/hello-ace.html">ShareJS</a>
</li>
<li>
<img src="https://neutron-drive.appspot.com/static/img/neutron_face_high.png"
style="width: 76px; left: 7px; top: -11px;">
<a href="http://neutronide.com/">Neutron IDE</a>
</li>
<li>
<a href="http://www.akshell.com/">Akshell</a>
</li>
<li>
<a href="http://beanstalkapp.com/">beanstalk</a>
</li>
<li>
<img src="https://neutron-drive.appspot.com/static/img/neutron_face_high.png"
style="width: 76px; left: 7px; top: -11px;">
<a href="http://neutronide.com/">Neutron IDE</a>
</li>
<li>
<div class="text-logo">tmpltr</div>
<a href="http://rocktronica.github.com/tmpltr/">tmpltr</a>
@ -1153,7 +1190,7 @@ if (match) {
</li>
<li id="add_your_site">
<p>+</p>
<a href="mailto:ace@c9.io?subject=Put%20me%20on%20the%20Ace%20site!">Your Site Here</a>
<a href="mailto:ace@c9.io?subject=Put%20me%20on%20the%20Ace%20site!&body=Please include a link to a logo hosted on your site!">Your Site Here</a>
</li>
</ul>
</div>

View file

@ -54,6 +54,7 @@ require("./keyboard/hash_handler");
require("./placeholder");
require("./mode/folding/fold_mode");
require("./theme/textmate");
require("./ext/error_marker");
exports.config = require("./config");

View file

@ -52,6 +52,26 @@ exports.commands = [{
});
},
readOnly: true
}, {
name: "goToNextError",
bindKey: bindKey("Alt-E", "Ctrl-E"),
exec: function(editor) {
config.loadModule("ace/ext/error_marker", function(module) {
module.showErrorMarker(editor, 1);
});
},
scrollIntoView: "center",
readOnly: true
}, {
name: "goToPreviousError",
bindKey: bindKey("Alt-Shift-E", "Ctrl-Shift-E"),
exec: function(editor) {
config.loadModule("ace/ext/error_marker", function(module) {
module.showErrorMarker(editor, -1);
});
},
scrollIntoView: "center",
readOnly: true
}, {
name: "selectall",
bindKey: bindKey("Ctrl-A", "Command-A"),
@ -165,6 +185,7 @@ exports.commands = [{
exec: function(editor) { editor.getSelection().selectFileStart(); },
multiSelectAction: "forEach",
readOnly: true,
scrollIntoView: "animate",
aceCommandGroup: "fileJump"
}, {
name: "gotostart",
@ -172,6 +193,7 @@ exports.commands = [{
exec: function(editor) { editor.navigateFileStart(); },
multiSelectAction: "forEach",
readOnly: true,
scrollIntoView: "animate",
aceCommandGroup: "fileJump"
}, {
name: "selectup",
@ -191,6 +213,7 @@ exports.commands = [{
exec: function(editor) { editor.getSelection().selectFileEnd(); },
multiSelectAction: "forEach",
readOnly: true,
scrollIntoView: "animate",
aceCommandGroup: "fileJump"
}, {
name: "gotoend",
@ -198,90 +221,105 @@ exports.commands = [{
exec: function(editor) { editor.navigateFileEnd(); },
multiSelectAction: "forEach",
readOnly: true,
scrollIntoView: "animate",
aceCommandGroup: "fileJump"
}, {
name: "selectdown",
bindKey: bindKey("Shift-Down", "Shift-Down"),
exec: function(editor) { editor.getSelection().selectDown(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "golinedown",
bindKey: bindKey("Down", "Down|Ctrl-N"),
exec: function(editor, args) { editor.navigateDown(args.times); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectwordleft",
bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
exec: function(editor) { editor.getSelection().selectWordLeft(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotowordleft",
bindKey: bindKey("Ctrl-Left", "Option-Left"),
exec: function(editor) { editor.navigateWordLeft(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selecttolinestart",
bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
exec: function(editor) { editor.getSelection().selectLineStart(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotolinestart",
bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
exec: function(editor) { editor.navigateLineStart(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectleft",
bindKey: bindKey("Shift-Left", "Shift-Left"),
exec: function(editor) { editor.getSelection().selectLeft(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotoleft",
bindKey: bindKey("Left", "Left|Ctrl-B"),
exec: function(editor, args) { editor.navigateLeft(args.times); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectwordright",
bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
exec: function(editor) { editor.getSelection().selectWordRight(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotowordright",
bindKey: bindKey("Ctrl-Right", "Option-Right"),
exec: function(editor) { editor.navigateWordRight(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selecttolineend",
bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
exec: function(editor) { editor.getSelection().selectLineEnd(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotolineend",
bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
exec: function(editor) { editor.navigateLineEnd(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectright",
bindKey: bindKey("Shift-Right", "Shift-Right"),
exec: function(editor) { editor.getSelection().selectRight(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotoright",
bindKey: bindKey("Right", "Right|Ctrl-F"),
exec: function(editor, args) { editor.navigateRight(args.times); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectpagedown",

View file

@ -301,7 +301,7 @@
background-position: center center, top left;
}
.ace_gutter-tooltip {
.ace_tooltip {
background-color: #FFF;
background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));
background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));
@ -309,21 +309,22 @@
border-radius: 1px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
color: black;
display: inline-block;
max-width: 500px;
padding: 4px;
display: block;
max-width: 100%;
padding: 3px 4px;
position: fixed;
z-index: 999999;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
cursor: default;
white-space: pre-line;
white-space: pre;
word-wrap: break-word;
line-height: normal;
font-style: normal;
font-weight: normal;
letter-spacing: normal;
pointer-events: none;
}
.ace_folding-enabled > .ace_gutter-cell {

View file

@ -2474,7 +2474,14 @@ config.defineOptions(EditSession.prototype, "session", {
this.$wrap = value;
},
get: function() {
return this.getUseWrapMode() ? this.getWrapLimitRange().min || "free" : "off";
if (this.getUseWrapMode()) {
if (this.$wrap == -1)
return "printMargin";
if (!this.getWrapLimitRange().min)
return "free";
return this.$wrap;
}
return "off";
},
handlesSet: true
},

View file

@ -454,13 +454,16 @@ function Folding() {
if (expandInner) {
this.removeFolds(folds);
} else {
// TODO: might need to remove and add folds in one go instead of using
var subFolds = folds;
// TODO: might be better to remove and add folds in one go instead of using
// expandFolds several times.
while (folds.length) {
this.expandFolds(folds);
folds = this.getFoldsInRangeList(range);
while (subFolds.length) {
this.expandFolds(subFolds);
subFolds = this.getFoldsInRangeList(range);
}
}
if (folds.length)
return folds;
};
/*

View file

@ -133,7 +133,6 @@ var Editor = function(renderer, session) {
if (command.aceCommandGroup == "fileJump") {
if (this.lastFileJumpPos && !this.curOp.selectionChanged) {
this.selection.fromJSON(this.lastFileJumpPos);
return;
}
}
this.endOperation(e);
@ -168,7 +167,8 @@ var Editor = function(renderer, session) {
this.$opResetTimer.schedule();
this.curOp = {
command: commadEvent.command || {},
args: commadEvent.args
args: commadEvent.args,
scrollTop: this.renderer.scrollTop
};
var command = this.curOp.command;
@ -187,16 +187,24 @@ var Editor = function(renderer, session) {
case "center":
this.renderer.scrollCursorIntoView(null, 0.5);
break;
case "animate":
case "cursor":
this.renderer.scrollCursorIntoView();
break;
case "selectionPart":
this.renderer.scrollCursorIntoView();
var range = this.selection.getRange();
var config = this.renderer.layerConfig;
if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
}
break;
default:
break;
}
if (command.scrollIntoView == "animate")
this.renderer.animateScrolling(this.curOp.scrollTop);
}
this.prevOp = this.curOp;
this.curOp = null;
}
@ -243,7 +251,6 @@ var Editor = function(renderer, session) {
* Sets a new key handler, such as "vim" or "windows".
* @param {String} keyboardHandler The new key handler
*
*
**/
this.setKeyboardHandler = function(keyboardHandler) {
if (!keyboardHandler) {
@ -277,7 +284,6 @@ var Editor = function(renderer, session) {
* @event changeSession
* @param {Object} e An object with two properties, `oldSession` and `session`, that represent the old and new [[EditSession]]s.
*
*
**/
/**
* Sets a new editsession to use. This method also emits the `'changeSession'` event.
@ -1197,7 +1203,7 @@ var Editor = function(renderer, session) {
var state = session.getState(range.start.row);
var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
if (range.end.column == 0) {
if (range.end.column === 0) {
var text = session.getTextRange(range);
if (text[text.length - 1] == "\n") {
var line = session.getLine(range.end.row);
@ -1619,7 +1625,7 @@ var Editor = function(renderer, session) {
var last = rows.end.row;
var first = rows.start.row;
while (i--) {
var rows = ranges[i].collapseRows();
rows = ranges[i].collapseRows();
if (first - rows.end.row <= 1)
first = rows.end.row;
else
@ -1723,11 +1729,11 @@ var Editor = function(renderer, session) {
var rows = dir * Math.floor(config.height / config.lineHeight);
this.$blockScrolling++;
if (select == true) {
if (select === true) {
this.selection.$moveSelection(function(){
this.moveCursorBy(rows, 0);
});
} else if (select == false) {
} else if (select === false) {
this.selection.moveCursorBy(rows, 0);
this.selection.clearSelection();
}
@ -2056,10 +2062,8 @@ var Editor = function(renderer, session) {
* Moves the cursor to the end of the current file. Note that this does de-select the current selection.
**/
this.navigateFileEnd = function() {
var scrollTop = this.renderer.scrollTop;
this.selection.moveCursorFileEnd();
this.clearSelection();
this.renderer.animateScrolling(scrollTop);
};
/**
@ -2067,10 +2071,8 @@ var Editor = function(renderer, session) {
* Moves the cursor to the start of the current file. Note that this does de-select the current selection.
**/
this.navigateFileStart = function() {
var scrollTop = this.renderer.scrollTop;
this.selection.moveCursorFileStart();
this.clearSelection();
this.renderer.animateScrolling(scrollTop);
};
/**
@ -2253,7 +2255,7 @@ var Editor = function(renderer, session) {
var scrollTop = this.renderer.scrollTop;
this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
if (animate != false)
if (animate !== false)
this.renderer.animateScrolling(scrollTop);
};

212
lib/ace/ext/error_marker.js Normal file
View file

@ -0,0 +1,212 @@
/* ***** 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 ***** */
define(function(require, exports, module) {
"use strict";
var LineWidgets = require("ace/line_widgets").LineWidgets;
var dom = require("ace/lib/dom");
var Range = require("ace/range").Range;
function binarySearch(array, needle, comparator) {
var first = 0;
var last = array.length - 1;
while (first <= last) {
var mid = (first + last) >> 1;
var c = comparator(needle, array[mid]);
if (c > 0)
first = mid + 1;
else if (c < 0)
last = mid - 1;
else
return mid;
}
// Return the nearest lesser index, "-1" means "0, "-2" means "1", etc.
return -(first + 1);
}
function findAnnotations(session, row, dir) {
var annotations = session.getAnnotations().sort(Range.comparePoints);
if (!annotations.length)
return;
var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
if (i < 0)
i = -i - 1;
if (i >= annotations.length - 1)
i = dir > 0 ? 0 : annotations.length - 1;
else if (i === 0 && dir < 0)
i = annotations.length - 1;
var annotation = annotations[i];
if (!annotation || !dir)
return;
if (annotation.row === row) {
do {
annotation = annotations[i += dir];
} while (annotation && annotation.row === row);
if (!annotation)
return annotations.slice();
}
var matched = [];
row = annotation.row;
do {
matched[dir < 0 ? "unshift" : "push"](annotation);
annotation = annotations[i += dir];
} while (annotation && annotation.row == row);
return matched.length && matched;
}
exports.showErrorMarker = function(editor, dir) {
var session = editor.session;
if (!session.widgetManager) {
session.widgetManager = new LineWidgets(session);
session.widgetManager.attach(editor);
}
var pos = editor.getCursorPosition();
var row = pos.row;
var oldWidget = session.lineWidgets && session.lineWidgets[row];
if (oldWidget) {
oldWidget.destroy();
} else {
row -= dir;
}
var annotations = findAnnotations(session, row, dir);
var gutterAnno;
if (annotations) {
var annotation = annotations[0];
if (annotation.pos && annotation.column == null)
pos.column = annotation.pos.sc;
pos.row = annotation.row;
gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
} else if (oldWidget) {
return;
} else {
gutterAnno = {
text: ["Looks good!"],
className: "ace_ok"
};
}
editor.session.unfold(pos.row);
editor.selection.moveCursorToPosition(pos);
editor.selection.clearSelection();
var w = {
row: pos.row,
fixedWidth: true,
coverGutter: true,
el: dom.createElement("div")
};
var el = w.el.appendChild(dom.createElement("div"));
var arrow = w.el.appendChild(dom.createElement("div"));
arrow.className = "error_widget_arrow " + gutterAnno.className;
var left = editor.renderer.$cursorLayer
.getPixelPosition(pos).left;
arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
w.el.className = "error_widget_wrapper";
el.className = "error_widget " + gutterAnno.className;
el.innerHTML = gutterAnno.text.join("<br>");
var kb = {
handleKeyboard:function(_,hashId, keyString) {
if (hashId === 0 && keyString === "esc") {
w.destroy();
return true;
}
}
};
w.destroy = function() {
if (editor.$mouseHandler.isMousePressed)
return;
editor.keyBinding.removeKeyboardHandler(kb);
session.widgetManager.removeLineWidget(w);
editor.off("changeSelection", w.destroy);
editor.off("changeSession", w.destroy);
editor.off("mouseup", w.destroy);
editor.off("change", w.destroy);
};
editor.keyBinding.addKeyboardHandler(kb);
editor.on("changeSelection", w.destroy);
editor.on("changeSession", w.destroy);
editor.on("mouseup", w.destroy);
editor.on("change", w.destroy);
editor.session.widgetManager.addLineWidget(w);
w.el.onmousedown = editor.focus.bind(editor);
};
dom.importCssString("\
.error_widget_wrapper {\
background: inherit;\
color: inherit;\
border:none\
}\
.error_widget {\
border-top: solid 2px;\
border-bottom: solid 2px;\
margin: 5px 0;\
padding: 10px 40px;\
white-space: pre-wrap;\
}\
.error_widget.ace_error, .error_widget_arrow.ace_error{\
border-color: #ff5a5a\
}\
.error_widget.ace_warning, .error_widget_arrow.ace_warning{\
border-color: #F1D817\
}\
.error_widget.ace_info, .error_widget_arrow.ace_info{\
border-color: #5a5a5a\
}\
.error_widget.ace_ok, .error_widget_arrow.ace_ok{\
border-color: #5aaa5a\
}\
.error_widget_arrow {\
position: absolute;\
border: solid 5px;\
border-top-color: transparent!important;\
border-right-color: transparent!important;\
border-left-color: transparent!important;\
top: -5px;\
}\
", "");
});

View file

@ -86,7 +86,7 @@ module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) {
editor.menuOptions.setTheme = themelist.themes.map(function(theme) {
return {
'textContent' : theme.desc,
'textContent' : theme.caption,
'value' : theme.theme
};
});
@ -100,4 +100,4 @@ module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) {
};
});
});

View file

@ -0,0 +1,532 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2014, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
if (typeof process !== "undefined") {
require("amd-loader");
}
define(function(require, exports, module) {
"use strict";
function repeat(str, times) {
return new Array(times + 1).join(str);
}
var EditSession = require("./../edit_session").EditSession,
Editor = require("./../editor").Editor,
UndoManager = require("./../undomanager").UndoManager,
MockRenderer = require("./../test/mockrenderer").MockRenderer,
assert = require("./../test/assertions"),
keys = require("./../lib/keys"),
vim = require("./vim"),
editor,
keyCodeByFuncKey = {},
tests = {};
//Helper functions
function initKeyCodeByFuncKey() {
for (var keyCode in keys.FUNCTION_KEYS) {
var funcKey = keys.FUNCTION_KEYS[keyCode];
keyCodeByFuncKey[funcKey] = keyCode;
}
}
function initEditor(docString) {
var session = new EditSession(docString.split("\n"));
var undoManager = new UndoManager();
session.setUndoManager(undoManager);
editor = new Editor(new MockRenderer(), session);
editor.setKeyboardHandler(vim.handler);
}
function sendKeys() {
//Vim handler needs to be sent a key at a time for undo to work
//Handle any mix of command keys and text input arguments
for (var argInt=0; argInt<arguments.length; argInt++) {
var arg = arguments[argInt];
var keyMods = arg.split(/[\-]/);
var trailingKeys = keyMods.pop();
var hashId = 0;
for (var keyModIndex in keyMods) {
var keyMod = keyMods[keyModIndex];
var lowerKeyMod = keyMod.toLowerCase();
if (keys.KEY_MODS.hasOwnProperty(lowerKeyMod)) {
hashId |= keys.KEY_MODS[lowerKeyMod];
}
}
if (hashId === 0) {
trailingKeys = arg;
}
var keyCode;
if (keyCodeByFuncKey.hasOwnProperty(trailingKeys)) {
keyCode = keyCodeByFuncKey[trailingKeys];
editor.onCommandKey({}, hashId, keyCode);
} else {
if (hashId !== 0) {
keyCode = trailingKeys.toUpperCase().charCodeAt(0);
editor.onCommandKey({}, hashId, keyCode);
} else {
for (var i=0; i<trailingKeys.length; i++) {
var key = trailingKeys.charAt(i);
editor.onTextInput(key);
editor.session.$syncInformUndoManager();
}
}
}
}
}
function assertContent(expectedText) {
var actualText = editor.session.toString();
assert.strictEqual(actualText, expectedText, "Content expected: " + expectedText + ", actual: " + actualText);
}
function assertPosition(expectedRow, expectedCol) {
var actualPosition = editor.getCursorPosition();
var actualRow = actualPosition.row;
var actualCol = actualPosition.column;
assert.strictEqual(actualRow, expectedRow, "Row expected: " + expectedRow + ", actual: " + actualRow);
assert.strictEqual(actualCol, expectedCol, "Column expected: " + expectedCol + ", actual: " + actualCol);
}
function addTest(title, chapter, section, testFunction) {
var href = "http://vimdoc.sourceforge.net/htmldoc/usr_" + chapter + ".html#" + chapter + "." + section;
var testName;
if (location.protocol === "file:") { //running in console mode
testName = "test " + title + " (See " + href + ")";
} else {
testName = "test <a href=\"" + href + "\" target=\"_blank\">" + title + "</a>";
}
tests[testName] = testFunction;
}
//Define the tests
initKeyCodeByFuncKey();
addTest("Insert text", "02", "2", function() {
var text = "A very intelligent turtle\nFound programming UNIX a hurdle";
initEditor("");
sendKeys("i", text, "Esc");
assertContent(text);
sendKeys("Esc", "Esc");
assertContent(text);
});
addTest("Moving around", "02", "3", function() {
initEditor(" k \nh l\n j ");
sendKeys("hjj");
assertPosition(2, 0);
sendKeys("jll");
assertPosition(2, 2);
sendKeys("lkk");
assertPosition(0, 2);
sendKeys("khh");
assertPosition(0, 0);
});
addTest("Deleting characters", "02", "4", function() {
var text = "A very intelligent turtle\nFound programming UNIX a hurdle";
initEditor(text);
sendKeys("xxxxxxx");
assertContent(text.substring(7));
sendKeys("iA young ", "Esc");
assertContent("A young intelligent turtle\nFound programming UNIX a hurdle");
sendKeys("dd");
assertContent("Found programming UNIX a hurdle");
sendKeys("ddiA young intelligent\nturtle", "Esc", "kJ");
assertContent("A young intelligent turtle");
});
addTest("Undo and Redo [PARTIAL]", "02", "5", function() {
var text = "A young intelligent turtle";
initEditor(text);
sendKeys("ddu");
assertContent(text);
sendKeys("0xxxxxxx");
assertContent(text.substring(7));
for (var i=6; i>=0; i--) {
sendKeys("u");
assertContent(text.substring(i));
}
sendKeys("ctrl-r", "ctrl-r");
assertContent(text.substring(2));
text = "A very intelligent turtle";
sendKeys("ddi", text, "Esc");
sendKeys("0wxxxxxwwxxxxxx");
assertContent("A intelligent ");
/* "U" fails
sendKeys("U");
assertContent(text);
sendKeys("u");
assertContent("A intelligent ");
*/
});
addTest("Other editing commands [PARTIAL]", "02", "6", function() {
var text = "and that's not saying much for the turtle.";
initEditor(text);
sendKeys("$xa!!!", "Esc");
assertContent(text.slice(0, -1) + "!!!");
var text1 = "A very intelligent turtle";
var text2 = "Found programming UNIX a hurdle";
sendKeys("ddi", text1 + "\n" + text2, "Esc");
var text3 = "That liked using Vim";
sendKeys("ko", text3, "Esc");
assertContent([text1, text3, text2].join("\n"));
sendKeys("O", "Esc");
assertContent([text1, "", text3, text2].join("\n"));
/* "3a!" fails
sendKeys("3a!", "Esc");
*/
sendKeys("a!!!", "Esc");
assertContent([text1, "!!!", text3, text2].join("\n"));
sendKeys("hhh3x");
assertContent([text1, "", text3, text2].join("\n"));
});
addTest("Getting out [PARTIAL]", "02", "7", function() {
initEditor("");
sendKeys("ZZ");
/*
sendKeys("aSome text", "Esc");
sendKeys(":q", "Return");
sendKeys(":q!", "Return");
sendKeys(":e!", "Return");
*/
});
addTest("Finding help [PARTIAL]", "02", "8", function() {
initEditor("");
sendKeys(":help", "Return");
sendKeys("F1");
});
addTest("Word movement [PARTIAL]", "03", "1", function() {
var text = "This is a line with example text";
initEditor(text);
sendKeys("www3w");
assertPosition(0, 28);
sendKeys("b2b");
assertPosition(0, 10);
sendKeys("3le");
assertPosition(0, 18);
/* "ge" fails
sendKeys("2ge");
assertPosition(0, 8);
TODO: What iskeyword behavior is assumed for Ace?
Need to test "b,w,ge,e,gE, B, W, E" behaviors
sendKeys("ddaThis is-a line, with special/separated/words (and some more).", "Esc");
sendKeys("$4b");
assertPosition(0, 21);
*/
});
addTest("Moving to the start or end of a line [PARTIAL]", "03", "2", function() {
var text = " This is a line with example text";
var textLength = text.length;
initEditor(text);
sendKeys("$");
assertPosition(0, 36);
sendKeys("0");
assertPosition(0, 0);
/* "End" and "Home" fails
sendKeys("End");
assertPosition(0, 36);
sendKeys("Home");
assertPosition(0, 0);
*/
sendKeys("^");
assertPosition(0, 5);
sendKeys("$^");
assertPosition(0, 5);
sendKeys("ddaA young intelligent turtle\nFound programming UNIX a hurdle", "Esc", "k0");
assertPosition(0, 0);
/* <count>$ fails
sendKeys("2$");
assertPosition(1, 30);
*/
});
addTest("Moving to a character [PARTIAL]", "03", "3", function() {
var text = "To err is human. To really foul up you need a computer.";
initEditor(repeat(text, 2));
sendKeys("fh");
assertPosition(0, 10);
sendKeys("3fl");
assertPosition(0, 31);
sendKeys("Fh");
assertPosition(0, 10);
sendKeys("Fh");
assertPosition(0, 10);
sendKeys("2tn");
assertPosition(0, 39);
sendKeys("Th");
assertPosition(0, 11);
sendKeys("tn");
assertPosition(0, 13);
sendKeys(";");
assertPosition(0, 39);
/* Problem with mockrenderer?
sendKeys(";");
assertPosition(0, 39);
*/
sendKeys(",");
assertPosition(0, 15);
sendKeys("0f", "Esc", "w");
assertPosition(0, 3);
});
addTest("Matching a parenthesis", "03", "4", function() {
var text = "if (a == (b * c) / d)\nif [a == [b * c] / d]\nif {a == {b * c} / d}";
initEditor(text);
sendKeys("%");
assertPosition(0, 20);
sendKeys("%");
assertPosition(0, 3);
sendKeys("0j%");
assertPosition(1, 20);
sendKeys("%");
assertPosition(1, 3);
sendKeys("0j%");
assertPosition(2, 20);
sendKeys("%");
assertPosition(2, 3);
});
addTest("Moving to a specific line [PARTIAL]", "03", "5", function() {
var text = "first line of a file\n" + repeat("text text text text\n", 8) + "last line of a file";
initEditor(text);
sendKeys("7G");
assertPosition(6, 0);
sendKeys("gg");
assertPosition(0, 0);
sendKeys("G");
assertPosition(9, 0);
/* <percent>% motion fails
sendKeys("50%");
assertPosition(4, 0);
sendKeys("90%");
assertPosition(8, 0);
"H, M, L" motion supported, but mockrenderer.js has no 'getScrollBottomRow', etc.
sendKeys("L");
assertPosition(9, 0);
sendKeys("M");
assertPosition(4, 0);
sendKeys("H");
assertPosition(0, 0);
*/
});
addTest("Telling where you are [PARTIAL]", "03", "6", function() {
// Ctrl-G, :set commands not implemented?
});
addTest("Scrolling around [PARTIAL]", "03", "7", function() {
/* Ctrl-D, Ctrl-U, Ctrl-E, Ctrl-Y, zz, zt, zb cannot be tested with mockrenderer
var text = repeat("some text\n", 4) + "\n123456\n7890\n" + repeat("\nexample", 4);
initEditor(text);
sendKeys("Ctrl-D");
*/
});
addTest("Simple searches [PARTIAL]", "03", "8", function() {
var text = repeat("To find the word #include\n", 10);
initEditor(text);
/* Search fails, (is a command line really necessary for this to work?
sendKeys("/include", "Return");
assertPosition(0, 18);
sendKeys("/#include", "Return");
assertPosition(1, 17);
sendKeys("nnn");
assertPosition(4, 17);
sendKeys("3n");
assertPosition(7, 17);
sendKeys("?word", "Return");
assertPosition(7, 12);
sendKeys("N");
assertPosition(8, 12);
sendKeys("/#include", "Return");
assertPosition(8, 17);
sendKeys("N");
assertPosition(7, 17);
//Skipping ':set ignorecase' and ':set noignorecase'
//Skipping search history
//TODO additional search tests
*" and "#" searches fail, no getPixelPosition in mockrenderer
sendKeys("gg*");
assertPosition(1, 5);
*/
});
addTest("Simple search patterns [PARTIAL]", "03", "9", function() {
});
addTest("Using marks [PARTIAL]", "03", "10", function() {
/* '', ``, Ctrl-O, Ctrl-I fail
var text1 = "example text\n"
var text2 = "line 33 text\n"
var text3 = "There you are\n"
var text = repeat(text1, 32) + text2 + repeat(text1, 2) + text3 + text1;
initEditor(text);
sendKeys("G");
sendKeys("``");
assertPosition(0, 0);
sendKeys("``");
assertPosition(37, 0);
sendKeys("10k``");
assertPosition(0, 0);
sendKeys("33G");
assertPosition(33, 0);
sendKeys("/^The");
assertPosition((36, 0);
sendKeys("Ctrl-O");
assertPosition(33, 0);
sendKeys("Ctrl-O");
assertPosition(0, 0);
sendKeys("Ctrl-I");
assertPosition(33, 0);
sendKeys("Ctrl-I");
assertPosition(36, 0);
sendKeys(":0$msG$me's");
assertPosition(0, 0);
sendKeys("`s");
assertPosition(0, 11);
sendKeys("'e");
assertPosition(36, 0);
sendKeys("`e"):
assertPosition(36, 11);
*/
});
addTest("Operators and motions [PARTIAL]", "04", "1", function() {
initEditor("To err is human. To really foul up you need a computer.");
sendKeys("5wd4w");
assertContent("To err is human. you need a computer.");
/* "d<count>e" fails
sendKeys("d2e");
assertContent("To err is human. a computer.");
sendKeys("2hd$");
assertContent("To err is human");
*/
});
addTest("Changing text [PARTIAL]", "04", "2", function() {
initEditor("To err is human");
/*
// "c<count>w" fails
// sendKeys("wc2wbe", "Esc");
// assertContent("To be human");
sendKeys("uccabc def", "Esc");
assertContent("abc def");
sendKeys("0c$123", "Esc");
assertContent("123");
sendKeys("hx");
assertContent("13");
sendKeys("X");
assertContent("3");
sendKeys("a 2 1", "Esc", "0wD");
assertContent("3 ");
sendKeys("a2 1", "Esc", "0wC4 5", "Esc");
assertContent("3 4 5");
sendKeys("0ws6", "Esc");
assertContent("3 6 5");
sendKeys("S1 3 2", "Esc");
assertContent("1 3 2");
sendKeys("$a4 6 5", "Esc", "03d2w");
assertContent("");
sendKeys("athere is somerhing grong here", "Esc", "0rTww4lrtwrw");
assertContent("There is something wrong here");
sendKeys("03w5rx");
assertContent("There is something xxxxx here");
// "r<Return>" fails - also replaces trailing space
sendKeys("r", "Return");
assertContent("There is something xxxx\n here");
//TODO - 4r<Return>
*/
});
addTest("Repeating a change [PARTIAL]", "04", "3", function() {
/*
initEditor("To <B>generate</B> a table of <B>contents");
sendKeys("f<df>f<.f<."); //strangeness after this
assertContent("To generate a table of contents");;
sendKeys("dd");
assertContent("");
sendKeys("Esc", "Esc");
sendKeys("afind");
var text = "find the first \"four\"\n" +
"change the word to \"five\"\n" +
"find the next \"four\"\n" +
"repeat the change to \"five\"\n" +
"find the next \"four\"\n" +
"repeat the change\n" +
"etc.";
sendKeys(text);
assertContent(text);
sendKeys("Esc");
sendKeys("0");
// search doesn't work with mockrenderer
sendKeys("/four", "<Return>", "cwfive", "Esc", "n.n.");
text.replace(/four/g, "five");
assertContent(text);
*/
});
addTest("Visual mode [PARTIAL]", "04", "4", function() {
});
addTest("Moving text [PARTIAL]", "04", "5", function() {
});
addTest("Copying text [PARTIAL]", "04", "6", function() {
});
addTest("Using the clipboard [PARTIAL]", "04", "7", function() {
});
addTest("Text objects [PARTIAL]", "04", "8", function() {
});
addTest("Replace mode [PARTIAL]", "04", "9", function() {
});
tests.name = "vim_test.js";
module.exports = tests;
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec();
}

View file

@ -118,8 +118,8 @@ exports.capture = function(el, eventHandler, releaseCaptureHandler) {
exports.addMouseWheelListener = function(el, callback) {
if ("onmousewheel" in el) {
var factor = 8;
exports.addListener(el, "mousewheel", function(e) {
var factor = 8;
if (e.wheelDeltaX !== undefined) {
e.wheelX = -e.wheelDeltaX / factor;
e.wheelY = -e.wheelDeltaY / factor;
@ -131,8 +131,19 @@ exports.addMouseWheelListener = function(el, callback) {
});
} else if ("onwheel" in el) {
exports.addListener(el, "wheel", function(e) {
e.wheelX = (e.deltaX || 0) * 5;
e.wheelY = (e.deltaY || 0) * 5;
var factor = 0.35;
switch (e.deltaMode) {
case e.DOM_DELTA_PIXEL:
e.wheelX = e.deltaX * factor || 0;
e.wheelY = e.deltaY * factor || 0;
break;
case e.DOM_DELTA_LINE:
case e.DOM_DELTA_PAGE:
e.wheelX = (e.deltaX || 0) * 5;
e.wheelY = (e.deltaY || 0) * 5;
break;
}
callback(e);
});
} else {

View file

@ -48,12 +48,13 @@ function LineWidgets(session) {
this.detach = this.detach.bind(this);
this.session.on("change", this.updateOnChange);
};
}
(function() {
this.getRowLength = function(row) {
var h;
if (this.lineWidgets)
var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
else
h = 0;
if (!this.$useWrapMode || !this.$wrapData[row]) {
@ -104,7 +105,8 @@ function LineWidgets(session) {
editor.renderer.off("beforeRender", this.measureWidgets);
editor.renderer.off("afterRender", this.renderWidgets);
this.session.lineWidgets.forEach(function(w) {
var lineWidgets = this.session.lineWidgets;
lineWidgets && lineWidgets.forEach(function(w) {
if (w && w.el && w.el.parentNode) {
w._inDocument = false;
w.el.parentNode.removeChild(w.el);
@ -113,8 +115,8 @@ function LineWidgets(session) {
};
this.updateOnChange = function(e) {
var cells = this.session.lineWidgets;
if (!cells) return;
var lineWidgets = this.session.lineWidgets;
if (!lineWidgets) return;
var delta = e.data;
var range = delta.range;
@ -124,24 +126,24 @@ function LineWidgets(session) {
if (len === 0) {
// return
} else if (delta.action == 'remove') {
var removed = cells.splice(startRow + 1, len);
var removed = lineWidgets.splice(startRow + 1, len);
removed.forEach(function(w) {
w && this.removeLineWidget(w);
}, this);
this.$updateRows();
} else {
var args = Array(len);
var args = new Array(len);
args.unshift(startRow, 0);
cells.splice.apply(cells, args);
lineWidgets.splice.apply(lineWidgets, args);
this.$updateRows();
}
};
this.$updateRows = function() {
var lw = this.session.lineWidgets;
if (!lw) return;
var lineWidgets = this.session.lineWidgets;
if (!lineWidgets) return;
var noWidgets = true;
lw.forEach(function(w, i) {
lineWidgets.forEach(function(w, i) {
if (w) {
noWidgets = false;
w.row = i;
@ -149,11 +151,11 @@ function LineWidgets(session) {
});
if (noWidgets)
this.session.lineWidgets = null;
}
};
this.addLineWidget = function(w) {
if (!this.session.lineWidgets)
this.session.lineWidgets = Array(this.session.getLength())
this.session.lineWidgets = new Array(this.session.getLength());
this.session.lineWidgets[w.row] = w;
@ -164,6 +166,8 @@ function LineWidgets(session) {
}
if (w.el) {
dom.addCssClass(w.el, "ace_lineWidgetContainer");
w.el.style.position = "absolute";
w.el.style.zIndex = 5;
renderer.container.appendChild(w.el);
w._inDocument = true;
}
@ -191,7 +195,8 @@ function LineWidgets(session) {
if (w.editor && w.editor.destroy) try {
w.editor.destroy();
} catch(e){}
this.session.lineWidgets[w.row] = undefined;
if (this.session.lineWidgets)
this.session.lineWidgets[w.row] = undefined;
this.session._emit("changeFold", {data:{start:{row: w.row}}});
this.$updateRows();
};
@ -202,13 +207,13 @@ function LineWidgets(session) {
};
this.measureWidgets = function(e, renderer) {
var ws = this.session._changedWidgets;
var changedWidgets = this.session._changedWidgets;
var config = renderer.layerConfig;
if (!ws || !ws.length) return;
if (!changedWidgets || !changedWidgets.length) return;
var min = Infinity;
for (var i = 0; i < ws.length; i++) {
var w = ws[i].lineWidget;
for (var i = 0; i < changedWidgets.length; i++) {
var w = changedWidgets[i];
if (!w._inDocument) {
w._inDocument = true;
renderer.container.appendChild(w.el);
@ -242,13 +247,13 @@ function LineWidgets(session) {
this.renderWidgets = function(e, renderer) {
var config = renderer.layerConfig;
var ws = this.session.lineWidgets;
if (!ws)
var lineWidgets = this.session.lineWidgets;
if (!lineWidgets)
return;
var first = Math.min(this.firstRow, config.firstRow);
var last = Math.max(this.lastRow, config.lastRow, ws.length);
var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
while (first > 0 && !ws[first])
while (first > 0 && !lineWidgets[first])
first--;
this.firstRow = config.firstRow;
@ -256,7 +261,7 @@ function LineWidgets(session) {
renderer.$cursorLayer.config = config;
for (var i = first; i <= last; i++) {
var w = ws[i];
var w = lineWidgets[i];
if (!w || !w.el) continue;
if (!w._inDocument) {

View file

@ -10,7 +10,7 @@ a/=b/c
//test tokenize reg exps
a=/b/g
a+/b/g
a = 1 + /2 + 1/b
a = 1 + /2 + 1/gimyxk
a=/a/ / /a/
case /a/.test(c)
//test tokenize multi-line comment containing a single line comment

View file

@ -96,7 +96,8 @@
["text"," "],
["string.regexp","/2 "],
["constant.language.escape","+"],
["string.regexp"," 1/b"]
["string.regexp"," 1/gimyx"],
["identifier","k"]
],[
"no_regex",
["identifier","a"],

View file

@ -132,7 +132,7 @@ var CstyleBehaviour = function () {
selection: false
};
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
if (/[\]\}\)]/.test(line[cursor.column])) {
if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
CstyleBehaviour.recordAutoInsert(editor, session, "}");
return {
text: '{}',
@ -165,19 +165,24 @@ var CstyleBehaviour = function () {
CstyleBehaviour.clearMaybeInsertedClosing();
}
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '}' || closing !== "") {
if (rightChar === '}') {
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
if (!openBracePos)
return null;
var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
var next_indent = this.$getIndent(session.getLine(openBracePos.row));
} else if (closing) {
var next_indent = this.$getIndent(line);
return {
text: '\n' + indent + '\n' + next_indent + closing,
selection: [1, indent.length, 1, indent.length]
};
} else {
return;
}
var indent = next_indent + session.getTabString();
return {
text: '\n' + indent + '\n' + next_indent + closing,
selection: [1, indent.length, 1, indent.length]
};
} else {
CstyleBehaviour.clearMaybeInsertedClosing();
}
});

View file

@ -75,6 +75,8 @@ var C9SearchHighlightRules = function() {
tokens.push({type: types[2], value: skipped});
if (m[0])
tokens.push({type: types[3], value: m[0]});
else if (!skipped)
break;
}
}
if (last < str.length)
@ -99,7 +101,7 @@ var C9SearchHighlightRules = function() {
search = lang.escapeRegExp(search);
if (/whole/.test(options))
search = "\\b" + search + "\\b";
var regex = safeCreateRegexp(
var regex = search && safeCreateRegexp(
"(" + search + ")",
/ sensitive/.test(options) ? "g" : "ig"
);

View file

@ -37,7 +37,7 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
/* All exports are for Stylus highlighter */
var supportType = exports.supportType = "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index";
var supportType = exports.supportType = "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|pointer-events|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index";
var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero";
var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";

View file

@ -13,7 +13,7 @@ var DartHighlightRules = function() {
var constantLanguage = "true|false|null";
var variableLanguage = "this|super";
var keywordControl = "try|catch|finally|throw|break|case|continue|default|do|else|for|if|in|return|switch|while|new";
var keywordDeclaration = "abstract|class|extends|external|factory|implements|get|native|operator|set|typedef";
var keywordDeclaration = "abstract|class|extends|external|factory|implements|get|native|operator|set|typedef|with";
var storageModifier = "static|final|const";
var storageType = "void|bool|num|int|double|dynamic|var|String";

View file

@ -3228,7 +3228,8 @@ var JSHINT = (function () {
if (this.id === "++" || this.id === "--") {
if (state.option.plusplus) {
warning("W016", this, this.id);
} else if ((!this.right.identifier || isReserved(this.right)) &&
} else if (this.right &&
(!this.right.identifier || isReserved(this.right)) &&
this.right.id !== "." && this.right.id !== "[") {
warning("W017", this);
}

View file

@ -242,7 +242,7 @@ var JavaScriptHighlightRules = function() {
}, {
// flag
token: "string.regexp",
regex: "/\\w*",
regex: "/[sxngimy]*",
next: "no_regex"
}, {
// invalid operators
@ -251,7 +251,7 @@ var JavaScriptHighlightRules = function() {
}, {
// operators
token : "constant.language.escape",
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?]/
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
}, {
token : "constant.language.delimiter",
regex: /\|/

View file

@ -98,7 +98,7 @@ var LogiQLHighlightRules = function() {
//All the lang system predicates
},
{ token: [ 'storage.type', 'text' ],
regex: '(export|sealed|clauses|block|alias)(\\s*\\()(?=`)',
regex: '(export|sealed|clauses|block|alias|alias_all)(\\s*\\()(?=`)',
//Module keywords
},
{ token: 'entity.name',
@ -116,4 +116,4 @@ var LogiQLHighlightRules = function() {
oop.inherits(LogiQLHighlightRules, TextHighlightRules);
exports.LogiQLHighlightRules = LogiQLHighlightRules;
});
});

View file

@ -31,11 +31,14 @@
define(function(require, exports, module) {
"use strict";
var dom = require("../lib/dom");
var oop = require("../lib/oop");
var event = require("../lib/event");
var Tooltip = require("../tooltip").Tooltip;
function GutterHandler(mouseHandler) {
var editor = mouseHandler.editor;
var gutter = editor.renderer.$gutterLayer;
var tooltip = new GutterTooltip(editor.container);
mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
if (!editor.isFocused() || e.getButton() != 0)
@ -63,18 +66,9 @@ function GutterHandler(mouseHandler) {
});
var tooltipTimeout, mouseEvent, tooltip, tooltipAnnotation;
function createTooltip() {
tooltip = dom.createElement("div");
tooltip.className = "ace_gutter-tooltip";
tooltip.style.display = "none";
editor.container.appendChild(tooltip);
}
var tooltipTimeout, mouseEvent, tooltipAnnotation;
function showTooltip() {
if (!tooltip) {
createTooltip();
}
var row = mouseEvent.getDocumentPosition().row;
var annotation = gutter.$annotations[row];
if (!annotation)
@ -92,8 +86,8 @@ function GutterHandler(mouseHandler) {
return;
tooltipAnnotation = annotation.text.join("<br/>");
tooltip.style.display = "block";
tooltip.innerHTML = tooltipAnnotation;
tooltip.setHtml(tooltipAnnotation);
tooltip.show();
editor.on("mousewheel", hideTooltip);
moveTooltip(mouseEvent);
@ -103,23 +97,14 @@ function GutterHandler(mouseHandler) {
if (tooltipTimeout)
tooltipTimeout = clearTimeout(tooltipTimeout);
if (tooltipAnnotation) {
tooltip.style.display = "none";
tooltip.hide();
tooltipAnnotation = null;
editor.removeEventListener("mousewheel", hideTooltip);
}
}
function moveTooltip(e) {
var rect = editor.renderer.$gutter.getBoundingClientRect();
tooltip.style.left = e.x + 15 + "px";
if (e.y + 3 * editor.renderer.lineHeight + 15 < rect.bottom) {
tooltip.style.bottom = "";
tooltip.style.top = e.y + 15 + "px";
} else {
tooltip.style.top = "";
var innerHeight = window.innerHeight || document.documentElement.clientHeight;
tooltip.style.bottom = innerHeight - e.y + 5 + "px";
}
tooltip.setPosition(e.x, e.y);
}
mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
@ -156,6 +141,33 @@ function GutterHandler(mouseHandler) {
editor.on("changeSession", hideTooltip);
}
function GutterTooltip(parentNode) {
Tooltip.call(this, parentNode);
}
oop.inherits(GutterTooltip, Tooltip);
(function(){
this.setPosition = function(x, y) {
var windowWidth = window.innerWidth || document.documentElement.clientWidth;
var windowHeight = window.innerHeight || document.documentElement.clientHeight;
var width = this.getWidth();
var height = this.getHeight();
x += 15;
y += 15;
if (x + width > windowWidth) {
x -= (x + width) - windowWidth;
}
if (y + height > windowHeight) {
y -= 20 + height;
}
Tooltip.prototype.setPosition.call(this, x, y);
};
}).call(GutterTooltip.prototype);
exports.GutterHandler = GutterHandler;
});

View file

@ -235,8 +235,15 @@ function DefaultHandlers(mouseHandler) {
};
this.onMouseWheel = function(ev) {
if (ev.getShiftKey() || ev.getAccelKey())
if (ev.getAccelKey())
return;
//shift wheel to horiz scroll
if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
ev.wheelX = ev.wheelY;
ev.wheelY = 0;
}
var t = ev.domEvent.timeStamp;
var dt = t - (this.$lastScrollTime||0);

View file

@ -384,6 +384,8 @@ function DragdropHandler(mouseHandler) {
var button = e.getButton();
var clickCount = e.domEvent.detail || 1;
if (clickCount === 1 && button === 0 && inSelection) {
if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
return;
this.mousedownEvent.time = Date.now();
var eventTarget = e.domEvent.target || e.domEvent.srcElement;
if ("unselectable" in eventTarget)
@ -391,7 +393,7 @@ function DragdropHandler(mouseHandler) {
if (editor.getDragDelay()) {
// https://code.google.com/p/chromium/issues/detail?id=286700
if (useragent.isWebKit) {
self.cancelDrag = true;
this.cancelDrag = true;
var mouseTarget = editor.container;
mouseTarget.draggable = true;
}

View file

@ -105,7 +105,8 @@ function onMouseDown(e) {
}
var oldRange = selection.rangeList.rangeAtPoint(pos);
editor.$blockScrolling++;
editor.once("mouseup", function() {
var tmpSel = selection.toOrientedRange();
@ -118,6 +119,7 @@ function onMouseDown(e) {
}
selection.addRange(tmpSel);
}
editor.$blockScrolling--;
});
} else if (alt && button == 0) {

View file

@ -55,7 +55,7 @@ var RenderLoop = function(onRender, win) {
//this.onRender(change);
//return;
this.changes = this.changes | change;
if (!this.pending) {
if (!this.pending && this.changes) {
this.pending = true;
var _self = this;
event.nextFrame(function() {

View file

@ -24,6 +24,7 @@ var testNames = [
"ace/incremental_search_test",
"ace/keyboard/emacs_test",
"ace/keyboard/keybinding_test",
"ace/keyboard/vim_test",
"ace/layer/text_test",
"ace/lib/event_emitter_test",
"ace/mode/coffee/parser_test",

138
lib/ace/tooltip.js Normal file
View file

@ -0,0 +1,138 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var dom = require("./lib/dom");
/**
* @class Tooltip
**/
/**
* @param {Element} parentNode
*
* @constructor
**/
function Tooltip (parentNode) {
this.isOpen = false;
this.$element = null;
this.$parentNode = parentNode;
}
(function() {
this.$init = function() {
this.$element = dom.createElement("div");
this.$element.className = "ace_tooltip";
this.$element.style.display = "none";
this.$parentNode.appendChild(this.$element);
return this.$element;
};
/**
* @returns {Element}
**/
this.getElement = function() {
return this.$element || this.$init();
};
/**
* @param {String} text
**/
this.setText = function(text) {
dom.setInnerText(this.getElement(), text);
};
/**
* @param {String} html
**/
this.setHtml = function(html) {
this.getElement().innerHTML = html;
};
/**
* @param {Number} x
* @param {Number} y
**/
this.setPosition = function(x, y) {
this.getElement().style.left = x + "px";
this.getElement().style.top = y + "px";
};
/**
* @param {String} className
**/
this.setClassName = function(className) {
dom.addCssClass(this.getElement(), className);
};
/**
* @param {String} text
* @param {Number} x
* @param {Number} y
**/
this.show = function(text, x, y) {
if (text != null)
this.setText(text);
if (x != null && y != null)
this.setPosition(x, y);
if (!this.isOpen) {
this.getElement().style.display = "block";
this.isOpen = true;
}
};
this.hide = function() {
if (this.isOpen) {
this.getElement().style.display = "none";
this.isOpen = false;
}
};
/**
* @returns {Number}
**/
this.getHeight = function() {
return this.getElement().offsetHeight;
};
/**
* @returns {Number}
**/
this.getWidth = function() {
return this.getElement().offsetWidth;
};
}).call(Tooltip.prototype);
exports.Tooltip = Tooltip;
});

View file

@ -127,7 +127,7 @@ var VirtualRenderer = function(container, theme) {
this.$textLayer.addEventListener("changeCharacterSize", function() {
_self.updateCharacterSize();
_self.onResize(true);
_self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
_self._signal("changeCharacterSize");
});
@ -1272,10 +1272,11 @@ var VirtualRenderer = function(container, theme) {
clearInterval(this.$timer);
_self.session.setScrollTop(steps.shift());
// trick session to think it's already scrolled to not loose toValue
_self.session.$scrollTop = toValue;
this.$timer = setInterval(function() {
if (steps.length) {
_self.session.setScrollTop(steps.shift());
// trick session to think it's already scrolled to not loose toValue
_self.session.$scrollTop = toValue;
} else if (toValue != null) {
_self.session.$scrollTop = -1;
@ -1494,6 +1495,11 @@ var VirtualRenderer = function(container, theme) {
if (_self.theme)
dom.removeCssClass(_self.container, _self.theme.cssClass);
var padding = "padding" in module ? module.padding
: "padding" in (_self.theme || {}) ? 4 : _self.$padding;
if (_self.$padding && padding != _self.$padding)
_self.setPadding(padding);
// this is kept only for backwards compatibility
_self.$theme = module.cssClass;
@ -1501,10 +1507,6 @@ var VirtualRenderer = function(container, theme) {
dom.addCssClass(_self.container, module.cssClass);
dom.setCssClass(_self.container, "ace_dark", module.isDark);
var padding = "padding" in module ? module.padding : 4;
if (_self.$padding && padding != _self.$padding)
_self.setPadding(padding);
// force re-measure of the gutter width
if (_self.$size) {
_self.$size.width = 0;
@ -1534,7 +1536,7 @@ var VirtualRenderer = function(container, theme) {
*
**/
this.setStyle = function(style, include) {
dom.setCssClass(this.container, style, include != false);
dom.setCssClass(this.container, style, include !== false);
};
/**
@ -1545,6 +1547,11 @@ var VirtualRenderer = function(container, theme) {
this.unsetStyle = function(style) {
dom.removeCssClass(this.container, style);
};
this.setCursorStyle = function(style) {
if (this.content.style.cursor != style)
this.content.style.cursor = style;
};
/**
* @param {String} cursorStyle A css cursor style