Merge remote-tracking branch 'origin/master' into highlighting/mixed
Conflicts: index.html
This commit is contained in:
commit
373f24849b
23 changed files with 863 additions and 381 deletions
|
|
@ -497,11 +497,13 @@ img {
|
||||||
|
|
||||||
.rotating-logo {
|
.rotating-logo {
|
||||||
-webkit-transform: rotate(0deg);
|
-webkit-transform: rotate(0deg);
|
||||||
|
transform: rotate(0deg);
|
||||||
-webkit-transition: all 0.5s ease-out;
|
-webkit-transition: all 0.5s ease-out;
|
||||||
transition: all 0.5s ease-out;
|
transition: all 0.5s ease-out;
|
||||||
}
|
}
|
||||||
.rotating-logo:hover {
|
.rotating-logo:hover {
|
||||||
-webkit-transform: rotate(360deg);
|
-webkit-transform: rotate(360deg);
|
||||||
|
transform: rotate(360deg);
|
||||||
-webkit-transition: all 0.5s ease-in-out;
|
-webkit-transition: all 0.5s ease-in-out;
|
||||||
transition: all 0.5s ease-in-out;
|
transition: all 0.5s ease-in-out;
|
||||||
}
|
}
|
||||||
51
index.html
51
index.html
|
|
@ -770,20 +770,19 @@ if (match) {
|
||||||
<a href="http://www.applicationcraft.com/">Application Craft</a>
|
<a href="http://www.applicationcraft.com/">Application Craft</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<img src="doc/site/images/wolf_3d_logo_trans.png"
|
<img src="http://benweet.github.io/stackedit/img/stackedit-128.png"
|
||||||
style="left: 10px; top: -4px; width:80px" />
|
style="width: 74px; left: 13px; top: 1px;">
|
||||||
<a href="http://www.wolfcms.org/repository/133">Wolf CMS</a>
|
<a href="http://benweet.github.io/stackedit/">StackEdit</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<img src="http://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png" style="left: -5px; top: -35px; width: 110px;">
|
||||||
|
<a href="https://en.wikipedia.org/wiki/Special:Version" style="font-family: 'Linux Libertine','Hoefler Text',Georgia,'Times New Roman',Times,serif;">W<span style="font-variant: small-caps;">ikipedi</span>A</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<img src="doc/site/images/codiad.png"
|
<img src="doc/site/images/codiad.png"
|
||||||
style="left: 10px; top: -4px; width:80px" />
|
style="left: 10px; top: -4px; width:80px" />
|
||||||
<a href="http://codiad.com/">Codiad</a>
|
<a href="http://codiad.com/">Codiad</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<img src="doc/site/images/FineCut_small_logo.png"
|
|
||||||
style="left: 12px; top: -4px" />
|
|
||||||
<a href="http://finecut.info/">Fine Cut Engine</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<img src="doc/site/images/zorba-logo.png"
|
<img src="doc/site/images/zorba-logo.png"
|
||||||
style="left: -5px; top: 16px;
|
style="left: -5px; top: 16px;
|
||||||
|
|
@ -832,7 +831,7 @@ if (match) {
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="rotating-logo" style="background:url(doc/site/images/habitat-logo.svg) center no-repeat;
|
<div class="rotating-logo" style="background:url(doc/site/images/habitat-logo.svg) center no-repeat;
|
||||||
left: 19px; top: 6px;width: 60px;height: 60px;background-size: 60px;position: relative;" ></div>
|
left: 19px; top: 6px;width: 60px;height: 60px;background-size: 60px;position: relative;"></div>
|
||||||
<a href="http://habitat.inkling.com">Inkling Habitat</a>
|
<a href="http://habitat.inkling.com">Inkling Habitat</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
@ -870,6 +869,11 @@ if (match) {
|
||||||
style="left: 9px; top: -5px; width: 84px">
|
style="left: 9px; top: -5px; width: 84px">
|
||||||
<a href="https://drivenotepad.appspot.com/support">Drive Notepad</a>
|
<a href="https://drivenotepad.appspot.com/support">Drive Notepad</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<img src="doc/site/images/FineCut_small_logo.png"
|
||||||
|
style="left: 12px; top: -4px" />
|
||||||
|
<a href="http://finecut.info/">Fine Cut Engine</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<img src="http://phpassist.com/images/logo-large.png"
|
<img src="http://phpassist.com/images/logo-large.png"
|
||||||
style="left: 3px; top: -10px; width: 95px">
|
style="left: 3px; top: -10px; width: 95px">
|
||||||
|
|
@ -952,10 +956,6 @@ if (match) {
|
||||||
style="left: 12px; width: 79px;top: -18px;">
|
style="left: 12px; width: 79px;top: -18px;">
|
||||||
<a href="http://www.divshot.com/">Divshot</a>
|
<a href="http://www.divshot.com/">Divshot</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<div class="text-logo">Codio</div>
|
|
||||||
<a href="https://codio.com/">Codio</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<script>
|
<script>
|
||||||
ace.require("ace/lib/dom").importCssStylsheet("https://fonts.googleapis.com/css?family=Henny+Penny", document);
|
ace.require("ace/lib/dom").importCssStylsheet("https://fonts.googleapis.com/css?family=Henny+Penny", document);
|
||||||
|
|
@ -1065,15 +1065,15 @@ if (match) {
|
||||||
<a href="http://www.ogeditor.com/index.aspx">ogEditor</a>
|
<a href="http://www.ogeditor.com/index.aspx">ogEditor</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="text-logo" >allong.es</div>
|
<div class="text-logo">allong.es</div>
|
||||||
<a href="http://allong.es/try/">Try allong.es</a>
|
<a href="http://allong.es/try/">Try allong.es</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="text-logo" >NapCat</div>
|
<div class="text-logo">NapCat</div>
|
||||||
<a href="http://napcatapp.tumblr.com/post/60598006734/version-1-3-is-released">NapCat</a>
|
<a href="http://napcatapp.tumblr.com/post/60598006734/version-1-3-is-released">NapCat</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="text-logo" >CorsLit</div>
|
<div class="text-logo">CorsLit</div>
|
||||||
<a href="http://www.corslit.com/new/melloWorld">CorsLit</a>
|
<a href="http://www.corslit.com/new/melloWorld">CorsLit</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
@ -1082,9 +1082,26 @@ if (match) {
|
||||||
<a href="http://ojjs.org/index.html">OJjs</a>
|
<a href="http://ojjs.org/index.html">OJjs</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="text-logo" >Codechat</div>
|
<div class="text-logo">Codechat</div>
|
||||||
<a href="http://codechat.net/">Codechat</a>
|
<a href="http://codechat.net/">Codechat</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<img src="doc/site/images/wolf_3d_logo_trans.png"
|
||||||
|
style="left: 10px; top: -4px; width:80px" />
|
||||||
|
<a href="http://www.wolfcms.org/repository/133">Wolf CMS</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<img src="http://thlorenz.github.io/scriptie-talkie/images/code.png" style="left: 20px; top: 20px; width: 60px;">
|
||||||
|
<a href="http://thlorenz.github.io/scriptie-talkie/">Scriptie-Talkie</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<div class="text-logo">md</div>
|
||||||
|
<a href="http://thlorenz.github.io/browserify-markdown-editor/">browserify-markdown-editor</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<div class="text-logo"></div>
|
||||||
|
<a href="http://bakemycss.mypathforpython.appspot.com/">BakeMyCss</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/Gozala/sky-edit">Sky Edit</a>
|
<a href="https://github.com/Gozala/sky-edit">Sky Edit</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
color: black;
|
color: black;
|
||||||
|
-ms-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace_scroller {
|
.ace_scroller {
|
||||||
|
|
@ -23,6 +27,28 @@
|
||||||
cursor: text;
|
cursor: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ace_dragging, .ace_dragging * {
|
||||||
|
cursor: move !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace_dragging .ace_scroller:before{
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
content: '';
|
||||||
|
background: rgba(250, 250, 250, 0.01);
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
.ace_dragging.ace_dark .ace_scroller:before{
|
||||||
|
background: rgba(0, 0, 0, 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace_selecting, .ace_selecting * {
|
||||||
|
cursor: text !important;
|
||||||
|
}
|
||||||
|
|
||||||
.ace_gutter {
|
.ace_gutter {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
overflow : hidden;
|
overflow : hidden;
|
||||||
|
|
@ -268,10 +294,6 @@
|
||||||
background-position: center center, top left;
|
background-position: center center, top left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace_editor.ace_dragging .ace_content {
|
|
||||||
cursor: move;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_gutter-tooltip {
|
.ace_gutter-tooltip {
|
||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));
|
background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));
|
||||||
|
|
|
||||||
|
|
@ -1327,7 +1327,7 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.insert(toRange.start, text);
|
toRange.end = this.insert(toRange.start, text);
|
||||||
if (folds.length) {
|
if (folds.length) {
|
||||||
var oldStart = fromRange.start;
|
var oldStart = fromRange.start;
|
||||||
var newStart = toRange.start;
|
var newStart = toRange.start;
|
||||||
|
|
|
||||||
|
|
@ -1559,8 +1559,8 @@ var Editor = function(renderer, session) {
|
||||||
* @returns {Range} The new range where the text was moved to.
|
* @returns {Range} The new range where the text was moved to.
|
||||||
* @related EditSession.moveText
|
* @related EditSession.moveText
|
||||||
**/
|
**/
|
||||||
this.moveText = function(range, toPosition) {
|
this.moveText = function(range, toPosition, copy) {
|
||||||
return this.session.moveText(range, toPosition);
|
return this.session.moveText(range, toPosition, copy);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2403,6 +2403,7 @@ config.defineOptions(Editor.prototype, "editor", {
|
||||||
|
|
||||||
scrollSpeed: "$mouseHandler",
|
scrollSpeed: "$mouseHandler",
|
||||||
dragDelay: "$mouseHandler",
|
dragDelay: "$mouseHandler",
|
||||||
|
dragEnabled: "$mouseHandler",
|
||||||
focusTimout: "$mouseHandler",
|
focusTimout: "$mouseHandler",
|
||||||
|
|
||||||
firstLineNumber: "session",
|
firstLineNumber: "session",
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ var TextInput = function(parentNode, host) {
|
||||||
text.autocapitalize = "off";
|
text.autocapitalize = "off";
|
||||||
text.spellcheck = false;
|
text.spellcheck = false;
|
||||||
|
|
||||||
text.style.bottom = "2000em";
|
text.style.opacity = "0";
|
||||||
parentNode.insertBefore(text, parentNode.firstChild);
|
parentNode.insertBefore(text, parentNode.firstChild);
|
||||||
|
|
||||||
var PLACEHOLDER = "\x01\x01";
|
var PLACEHOLDER = "\x01\x01";
|
||||||
|
|
@ -372,10 +372,13 @@ var TextInput = function(parentNode, host) {
|
||||||
var onCompositionUpdate = function() {
|
var onCompositionUpdate = function() {
|
||||||
// console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value))
|
// console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value))
|
||||||
if (!inComposition) return;
|
if (!inComposition) return;
|
||||||
host.onCompositionUpdate(text.value);
|
var val = text.value.replace(/\x01/g, "");
|
||||||
|
if (inComposition.lastValue === val) return;
|
||||||
|
|
||||||
|
host.onCompositionUpdate(val);
|
||||||
if (inComposition.lastValue)
|
if (inComposition.lastValue)
|
||||||
host.undo();
|
host.undo();
|
||||||
inComposition.lastValue = text.value.replace(/\x01/g, "")
|
inComposition.lastValue = val;
|
||||||
if (inComposition.lastValue) {
|
if (inComposition.lastValue) {
|
||||||
var r = host.selection.getRange();
|
var r = host.selection.getRange();
|
||||||
host.insert(inComposition.lastValue);
|
host.insert(inComposition.lastValue);
|
||||||
|
|
@ -424,7 +427,12 @@ var TextInput = function(parentNode, host) {
|
||||||
var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
|
var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
|
||||||
|
|
||||||
event.addListener(text, "compositionstart", onCompositionStart);
|
event.addListener(text, "compositionstart", onCompositionStart);
|
||||||
event.addListener(text, useragent.isGecko ? "text" : "keyup", function(){syncComposition.schedule()});
|
if (useragent.isGecko) {
|
||||||
|
event.addListener(text, "text", function(){syncComposition.schedule()});
|
||||||
|
} else {
|
||||||
|
event.addListener(text, "keyup", function(){syncComposition.schedule()});
|
||||||
|
event.addListener(text, "keydown", function(){syncComposition.schedule()});
|
||||||
|
}
|
||||||
event.addListener(text, "compositionend", onCompositionEnd);
|
event.addListener(text, "compositionend", onCompositionEnd);
|
||||||
|
|
||||||
this.getElement = function() {
|
this.getElement = function() {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ exports.addListener = function(elem, type, callback) {
|
||||||
}
|
}
|
||||||
if (elem.attachEvent) {
|
if (elem.attachEvent) {
|
||||||
var wrapper = function() {
|
var wrapper = function() {
|
||||||
callback(window.event);
|
callback.call(elem, window.event);
|
||||||
};
|
};
|
||||||
callback._wrapper = wrapper;
|
callback._wrapper = wrapper;
|
||||||
elem.attachEvent("on" + type, wrapper);
|
elem.attachEvent("on" + type, wrapper);
|
||||||
|
|
@ -99,44 +99,20 @@ exports.getButton = function(e) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (document.documentElement.setCapture) {
|
exports.capture = function(el, eventHandler, releaseCaptureHandler) {
|
||||||
exports.capture = function(el, eventHandler, releaseCaptureHandler) {
|
|
||||||
var called = false;
|
|
||||||
function onReleaseCapture(e) {
|
|
||||||
eventHandler(e);
|
|
||||||
|
|
||||||
if (!called) {
|
|
||||||
called = true;
|
|
||||||
releaseCaptureHandler(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.removeListener(el, "mousemove", eventHandler);
|
|
||||||
exports.removeListener(el, "mouseup", onReleaseCapture);
|
|
||||||
exports.removeListener(el, "losecapture", onReleaseCapture);
|
|
||||||
|
|
||||||
el.releaseCapture();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.addListener(el, "mousemove", eventHandler);
|
|
||||||
exports.addListener(el, "mouseup", onReleaseCapture);
|
|
||||||
exports.addListener(el, "losecapture", onReleaseCapture);
|
|
||||||
el.setCapture();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
exports.capture = function(el, eventHandler, releaseCaptureHandler) {
|
|
||||||
function onMouseUp(e) {
|
function onMouseUp(e) {
|
||||||
eventHandler && eventHandler(e);
|
eventHandler && eventHandler(e);
|
||||||
releaseCaptureHandler && releaseCaptureHandler(e);
|
releaseCaptureHandler && releaseCaptureHandler(e);
|
||||||
|
|
||||||
document.removeEventListener("mousemove", eventHandler, true);
|
exports.removeListener(document, "mousemove", eventHandler, true);
|
||||||
document.removeEventListener("mouseup", onMouseUp, true);
|
exports.removeListener(document, "mouseup", onMouseUp, true);
|
||||||
|
exports.removeListener(document, "dragstart", onMouseUp, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("mousemove", eventHandler, true);
|
exports.addListener(document, "mousemove", eventHandler, true);
|
||||||
document.addEventListener("mouseup", onMouseUp, true);
|
exports.addListener(document, "mouseup", onMouseUp, true);
|
||||||
};
|
exports.addListener(document, "dragstart", onMouseUp, true);
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.addMouseWheelListener = function(el, callback) {
|
exports.addMouseWheelListener = function(el, callback) {
|
||||||
if ("onmousewheel" in el) {
|
if ("onmousewheel" in el) {
|
||||||
|
|
@ -183,22 +159,23 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
|
||||||
exports.addListener(el, "mousedown", function(e) {
|
exports.addListener(el, "mousedown", function(e) {
|
||||||
if (exports.getButton(e) != 0) {
|
if (exports.getButton(e) != 0) {
|
||||||
clicks = 0;
|
clicks = 0;
|
||||||
|
} else if (e.detail > 1) {
|
||||||
|
clicks++;
|
||||||
|
if (clicks > 4)
|
||||||
|
clicks = 1;
|
||||||
} else {
|
} else {
|
||||||
|
clicks = 1;
|
||||||
|
}
|
||||||
|
if (useragent.isIE) {
|
||||||
var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
|
var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
|
||||||
|
if (isNewClick) {
|
||||||
if (!timer || isNewClick)
|
clicks = 1;
|
||||||
clicks = 0;
|
|
||||||
|
|
||||||
clicks += 1;
|
|
||||||
|
|
||||||
if (timer)
|
|
||||||
clearTimeout(timer)
|
|
||||||
timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
|
|
||||||
}
|
}
|
||||||
if (clicks == 1) {
|
if (clicks == 1) {
|
||||||
startX = e.clientX;
|
startX = e.clientX;
|
||||||
startY = e.clientY;
|
startY = e.clientY;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
eventHandler[callbackName]("mousedown", e);
|
eventHandler[callbackName]("mousedown", e);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules;
|
var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules;
|
||||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
var CStyleFoldMode = require("./folding/csharp").FoldMode;
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
this.HighlightRules = CSharpHighlightRules;
|
this.HighlightRules = CSharpHighlightRules;
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,9 @@ var CSharpHighlightRules = function() {
|
||||||
}, {
|
}, {
|
||||||
token : "keyword.operator",
|
token : "keyword.operator",
|
||||||
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
|
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
|
||||||
|
}, {
|
||||||
|
token : "keyword",
|
||||||
|
regex : "^\\s*#(if|else|elif|endif|define|undef|warning|error|line|region|endregion|pragma)"
|
||||||
}, {
|
}, {
|
||||||
token : "punctuation.operator",
|
token : "punctuation.operator",
|
||||||
regex : "\\?|\\:|\\,|\\;|\\."
|
regex : "\\?|\\:|\\,|\\;|\\."
|
||||||
|
|
|
||||||
138
lib/ace/mode/folding/csharp.js
Normal file
138
lib/ace/mode/folding/csharp.js
Normal 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 Range = require("../../range").Range;
|
||||||
|
var CFoldMode = require("./cstyle").FoldMode;
|
||||||
|
|
||||||
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||||
|
if (commentRegex) {
|
||||||
|
this.foldingStartMarker = new RegExp(
|
||||||
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||||
|
);
|
||||||
|
this.foldingStopMarker = new RegExp(
|
||||||
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
oop.inherits(FoldMode, CFoldMode);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
this.usingRe = /^\s*using \S/;
|
||||||
|
|
||||||
|
this.getFoldWidgetRangeBase = this.getFoldWidgetRange;
|
||||||
|
this.getFoldWidgetBase = this.getFoldWidget;
|
||||||
|
|
||||||
|
this.getFoldWidget = function(session, foldStyle, row) {
|
||||||
|
var fw = this.getFoldWidgetBase(session, foldStyle, row);
|
||||||
|
if (!fw) {
|
||||||
|
var line = session.getLine(row);
|
||||||
|
if (/^\s*#region\b/.test(line))
|
||||||
|
return "start";
|
||||||
|
var usingRe = this.usingRe;
|
||||||
|
if (usingRe.test(line)) {
|
||||||
|
var prev = session.getLine(row - 1);
|
||||||
|
var next = session.getLine(row + 1);
|
||||||
|
if (!usingRe.test(prev) && usingRe.test(next))
|
||||||
|
return "start"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fw;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||||
|
var range = this.getFoldWidgetRangeBase(session, foldStyle, row);
|
||||||
|
if (range)
|
||||||
|
return range;
|
||||||
|
|
||||||
|
var line = session.getLine(row);
|
||||||
|
if (this.usingRe.test(line))
|
||||||
|
return this.getUsingStatementBlock(session, line, row);
|
||||||
|
|
||||||
|
if (/^\s*#region\b/.test(line))
|
||||||
|
return this.getRegionBlock(session, line, row);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getUsingStatementBlock = function(session, line, row) {
|
||||||
|
var startColumn = line.match(this.usingRe)[0].length - 1;
|
||||||
|
var maxRow = session.getLength();
|
||||||
|
var startRow = row;
|
||||||
|
var endRow = row;
|
||||||
|
|
||||||
|
while (++row < maxRow) {
|
||||||
|
line = session.getLine(row);
|
||||||
|
if (/^\s*$/.test(line))
|
||||||
|
continue;
|
||||||
|
if (!this.usingRe.test(line))
|
||||||
|
break;
|
||||||
|
|
||||||
|
endRow = row;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endRow > startRow) {
|
||||||
|
var endColumn = session.getLine(endRow).length;
|
||||||
|
return new Range(startRow, startColumn, endRow, endColumn);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getRegionBlock = function(session, line, row) {
|
||||||
|
var startColumn = line.search(/\s*$/);
|
||||||
|
var maxRow = session.getLength();
|
||||||
|
var startRow = row;
|
||||||
|
|
||||||
|
var re = /^\s*#(end)?region\b/
|
||||||
|
var depth = 1
|
||||||
|
while (++row < maxRow) {
|
||||||
|
line = session.getLine(row);
|
||||||
|
var m = re.exec(line);
|
||||||
|
if (!m)
|
||||||
|
continue;
|
||||||
|
if (m[1])
|
||||||
|
depth--;
|
||||||
|
else
|
||||||
|
depth++;
|
||||||
|
|
||||||
|
if (!depth)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var endRow = row;
|
||||||
|
if (endRow > startRow) {
|
||||||
|
var endColumn = line.search(/\S/);
|
||||||
|
return new Range(startRow, startColumn, endRow, endColumn);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}).call(FoldMode.prototype);
|
||||||
|
|
||||||
|
});
|
||||||
80
lib/ace/mode/folding/ini.js
Normal file
80
lib/ace/mode/folding/ini.js
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
/* ***** 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 Range = require("../../range").Range;
|
||||||
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||||
|
|
||||||
|
var FoldMode = exports.FoldMode = function() {
|
||||||
|
};
|
||||||
|
oop.inherits(FoldMode, BaseFoldMode);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
this.foldingStartMarker = /^\s*\[([^\])]*)]\s*(?:$|[;#])/;
|
||||||
|
|
||||||
|
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||||
|
var re = this.foldingStartMarker;
|
||||||
|
var line = session.getLine(row);
|
||||||
|
|
||||||
|
var m = line.match(re);
|
||||||
|
|
||||||
|
if (!m) return;
|
||||||
|
|
||||||
|
var startName = m[1] + ".";
|
||||||
|
|
||||||
|
var startColumn = line.length;
|
||||||
|
var maxRow = session.getLength();
|
||||||
|
var startRow = row;
|
||||||
|
var endRow = row;
|
||||||
|
|
||||||
|
while (++row < maxRow) {
|
||||||
|
line = session.getLine(row);
|
||||||
|
if (/^\s*$/.test(line))
|
||||||
|
continue;
|
||||||
|
m = line.match(re);
|
||||||
|
if (m && m[1].lastIndexOf(startName, 0) !== 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
endRow = row;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endRow > startRow) {
|
||||||
|
var endColumn = session.getLine(endRow).length;
|
||||||
|
return new Range(startRow, startColumn, endRow, endColumn);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}).call(FoldMode.prototype);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -26,17 +26,8 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
/*
|
|
||||||
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -45,7 +36,7 @@ var TextMode = require("./text").Mode;
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var IniHighlightRules = require("./ini_highlight_rules").IniHighlightRules;
|
var IniHighlightRules = require("./ini_highlight_rules").IniHighlightRules;
|
||||||
// TODO: pick appropriate fold mode
|
// TODO: pick appropriate fold mode
|
||||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
var FoldMode = require("./folding/ini").FoldMode;
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
this.HighlightRules = IniHighlightRules;
|
this.HighlightRules = IniHighlightRules;
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,6 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
/* This file was autogenerated from tool\tm bundles\ini.tmbundle\Syntaxes\Ini.plist (uuid: ) */
|
/* This file was autogenerated from tool\tm bundles\ini.tmbundle\Syntaxes\Ini.plist (uuid: ) */
|
||||||
/****************************************************************************************
|
|
||||||
* IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. *
|
|
||||||
* fileTypes *
|
|
||||||
****************************************************************************************/
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -40,56 +36,74 @@ define(function(require, exports, module) {
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var IniHighlightRules = function() {
|
var escapeRe = "\\\\(?:[\\\\0abtrn;#=:]|x[a-fA-F\\d]{4})";
|
||||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
|
||||||
// regexps are ordered -> the first match is used
|
|
||||||
|
|
||||||
this.$rules = { start:
|
var IniHighlightRules = function() {
|
||||||
[ { token: 'punctuation.definition.comment.ini',
|
this.$rules = {
|
||||||
|
start: [{
|
||||||
|
token: 'punctuation.definition.comment.ini',
|
||||||
regex: '#.*',
|
regex: '#.*',
|
||||||
push_:
|
push_: [{
|
||||||
[ { token: 'comment.line.number-sign.ini',
|
token: 'comment.line.number-sign.ini',
|
||||||
regex: '$',
|
regex: '$|^',
|
||||||
next: 'pop' },
|
next: 'pop'
|
||||||
{ defaultToken: 'comment.line.number-sign.ini' } ] },
|
}, {
|
||||||
{ token: 'punctuation.definition.comment.ini',
|
defaultToken: 'comment.line.number-sign.ini'
|
||||||
|
}]
|
||||||
|
}, {
|
||||||
|
token: 'punctuation.definition.comment.ini',
|
||||||
regex: ';.*',
|
regex: ';.*',
|
||||||
push_:
|
push_: [{
|
||||||
[ { token: 'comment.line.semicolon.ini', regex: '$', next: 'pop' },
|
token: 'comment.line.semicolon.ini',
|
||||||
{ defaultToken: 'comment.line.semicolon.ini' } ] },
|
regex: '$|^',
|
||||||
{ token:
|
next: 'pop'
|
||||||
[ 'keyword.other.definition.ini',
|
}, {
|
||||||
'text',
|
defaultToken: 'comment.line.semicolon.ini'
|
||||||
'punctuation.separator.key-value.ini' ],
|
}]
|
||||||
regex: '\\b([a-zA-Z0-9_.-]+)\\b(\\s*)(=)' },
|
}, {
|
||||||
{ token:
|
token: ['keyword.other.definition.ini', 'text', 'punctuation.separator.key-value.ini'],
|
||||||
[ 'punctuation.definition.entity.ini',
|
regex: '\\b([a-zA-Z0-9_.-]+)\\b(\\s*)(=)'
|
||||||
'constant.section.group-title.ini',
|
}, {
|
||||||
'punctuation.definition.entity.ini' ],
|
token: ['punctuation.definition.entity.ini', 'constant.section.group-title.ini', 'punctuation.definition.entity.ini'],
|
||||||
regex: '^(\\[)(.*?)(\\])' },
|
regex: '^(\\[)(.*?)(\\])'
|
||||||
{ token: 'punctuation.definition.string.begin.ini',
|
}, {
|
||||||
regex: '\'',
|
token: 'punctuation.definition.string.begin.ini',
|
||||||
push:
|
regex: "'",
|
||||||
[ { token: 'punctuation.definition.string.end.ini',
|
push: [{
|
||||||
regex: '\'',
|
token: 'punctuation.definition.string.end.ini',
|
||||||
next: 'pop' },
|
regex: "'",
|
||||||
{ token: 'constant.character.escape.ini', regex: '\\\\.' },
|
next: 'pop'
|
||||||
{ defaultToken: 'string.quoted.single.ini' } ] },
|
}, {
|
||||||
{ token: 'punctuation.definition.string.begin.ini',
|
token: "constant.language.escape",
|
||||||
|
regex: escapeRe
|
||||||
|
}, {
|
||||||
|
defaultToken: 'string.quoted.single.ini'
|
||||||
|
}]
|
||||||
|
}, {
|
||||||
|
token: 'punctuation.definition.string.begin.ini',
|
||||||
regex: '"',
|
regex: '"',
|
||||||
push:
|
push: [{
|
||||||
[ { token: 'punctuation.definition.string.end.ini',
|
token: "constant.language.escape",
|
||||||
|
regex: escapeRe
|
||||||
|
}, {
|
||||||
|
token: 'punctuation.definition.string.end.ini',
|
||||||
regex: '"',
|
regex: '"',
|
||||||
next: 'pop' },
|
next: 'pop'
|
||||||
{ defaultToken: 'string.quoted.double.ini' } ] } ] }
|
}, {
|
||||||
|
defaultToken: 'string.quoted.double.ini'
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
this.normalizeRules();
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
|
|
||||||
IniHighlightRules.metaData = { fileTypes: [ 'ini', 'conf' ],
|
IniHighlightRules.metaData = {
|
||||||
|
fileTypes: ['ini', 'conf'],
|
||||||
keyEquivalent: '^~I',
|
keyEquivalent: '^~I',
|
||||||
name: 'Ini',
|
name: 'Ini',
|
||||||
scopeName: 'source.ini' }
|
scopeName: 'source.ini'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
oop.inherits(IniHighlightRules, TextHighlightRules);
|
oop.inherits(IniHighlightRules, TextHighlightRules);
|
||||||
|
|
|
||||||
|
|
@ -689,7 +689,7 @@ PHP.Lexer = function( src, ini ) {
|
||||||
|
|
||||||
result = result.substring( match[ 0 ].length );
|
result = result.substring( match[ 0 ].length );
|
||||||
|
|
||||||
match = result.match(/^(\-\>)([a-zA-Z0-9_\x7f-\xff]*)/);
|
match = result.match(/^(\-\>)\s*([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\s*(\()/);
|
||||||
|
|
||||||
if ( match !== null ) {
|
if ( match !== null ) {
|
||||||
|
|
||||||
|
|
@ -703,6 +703,9 @@ PHP.Lexer = function( src, ini ) {
|
||||||
match[ 2 ],
|
match[ 2 ],
|
||||||
line
|
line
|
||||||
]);
|
]);
|
||||||
|
if (match[3]) {
|
||||||
|
results.push(match[3]);
|
||||||
|
}
|
||||||
result = result.substring( match[ 0 ].length );
|
result = result.substring( match[ 0 ].length );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -714,9 +717,9 @@ PHP.Lexer = function( src, ini ) {
|
||||||
|
|
||||||
var re;
|
var re;
|
||||||
if ( curlyOpen > 0) {
|
if ( curlyOpen > 0) {
|
||||||
re = /^([^\\\$"{}\]]|\\.)+/g;
|
re = /^([^\\\$"{}\]\)]|\\.)+/g;
|
||||||
} else {
|
} else {
|
||||||
re = /^([^\\\$"{]|\\.|{[^\$])+/g;
|
re = /^([^\\\$"{]|\\.|{[^\$]|\$(?=[^a-zA-Z_\x7f-\xff]))+/g;;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(( match = result.match( re )) !== null ) {
|
while(( match = result.match( re )) !== null ) {
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,7 @@ var oop = require("../lib/oop");
|
||||||
var TextMode = require("./text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var TomlHighlightRules = require("./toml_highlight_rules").TomlHighlightRules;
|
var TomlHighlightRules = require("./toml_highlight_rules").TomlHighlightRules;
|
||||||
// TODO: pick appropriate fold mode
|
var FoldMode = require("./folding/ini").FoldMode;
|
||||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
this.HighlightRules = TomlHighlightRules;
|
this.HighlightRules = TomlHighlightRules;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,8 @@ function GutterHandler(mouseHandler) {
|
||||||
}
|
}
|
||||||
mouseHandler.$clickSelection = editor.selection.getLineRange(row);
|
mouseHandler.$clickSelection = editor.selection.getLineRange(row);
|
||||||
}
|
}
|
||||||
mouseHandler.captureMouse(e, "selectByLines");
|
mouseHandler.setState("selectByLines");
|
||||||
|
mouseHandler.captureMouse(e);
|
||||||
return e.preventDefault();
|
return e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -116,7 +117,8 @@ function GutterHandler(mouseHandler) {
|
||||||
tooltip.style.top = e.y + 15 + "px";
|
tooltip.style.top = e.y + 15 + "px";
|
||||||
} else {
|
} else {
|
||||||
tooltip.style.top = "";
|
tooltip.style.top = "";
|
||||||
tooltip.style.bottom = rect.bottom - e.y + 5 + "px";
|
var innerHeight = window.innerHeight || document.documentElement.clientHeight;
|
||||||
|
tooltip.style.bottom = innerHeight - e.y + 5 + "px";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("../lib/dom");
|
||||||
|
var event = require("../lib/event");
|
||||||
var useragent = require("../lib/useragent");
|
var useragent = require("../lib/useragent");
|
||||||
|
|
||||||
var DRAG_OFFSET = 0; // pixels
|
var DRAG_OFFSET = 0; // pixels
|
||||||
|
|
@ -46,8 +47,8 @@ function DefaultHandlers(mouseHandler) {
|
||||||
editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
|
editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
|
||||||
editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
|
editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
|
||||||
|
|
||||||
var exports = ["select", "startSelect", "drag", "dragEnd", "dragWait",
|
var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
|
||||||
"dragWaitEnd", "startDrag", "focusWait"];
|
"selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
|
||||||
|
|
||||||
exports.forEach(function(x) {
|
exports.forEach(function(x) {
|
||||||
mouseHandler[x] = this[x];
|
mouseHandler[x] = this[x];
|
||||||
|
|
@ -85,9 +86,10 @@ function DefaultHandlers(mouseHandler) {
|
||||||
if (inSelection && !editor.isFocused()) {
|
if (inSelection && !editor.isFocused()) {
|
||||||
editor.focus();
|
editor.focus();
|
||||||
if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
|
if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
|
||||||
|
this.mousedownEvent.time = (new Date()).getTime();
|
||||||
this.setState("focusWait");
|
this.setState("focusWait");
|
||||||
this.captureMouse(ev);
|
this.captureMouse(ev);
|
||||||
return ev.preventDefault();
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,22 +99,29 @@ function DefaultHandlers(mouseHandler) {
|
||||||
this.startSelect(pos);
|
this.startSelect(pos);
|
||||||
} else if (inSelection) {
|
} else if (inSelection) {
|
||||||
this.mousedownEvent.time = (new Date()).getTime();
|
this.mousedownEvent.time = (new Date()).getTime();
|
||||||
this.setState("dragWait");
|
this.startSelect(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.captureMouse(ev);
|
this.captureMouse(ev);
|
||||||
return ev.preventDefault();
|
return ev.preventDefault();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.startSelect = function(pos) {
|
this.startSelect = function(pos) {
|
||||||
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
|
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
|
||||||
|
var editor = this.editor;
|
||||||
|
// allow double/triple click handlers to change selection
|
||||||
|
setTimeout(function(){
|
||||||
if (this.mousedownEvent.getShiftKey()) {
|
if (this.mousedownEvent.getShiftKey()) {
|
||||||
this.editor.selection.selectToPosition(pos);
|
editor.selection.selectToPosition(pos);
|
||||||
}
|
}
|
||||||
else if (!this.$clickSelection) {
|
else if (!this.$clickSelection) {
|
||||||
this.editor.moveCursorToPosition(pos);
|
editor.moveCursorToPosition(pos);
|
||||||
this.editor.selection.clearSelection();
|
editor.selection.clearSelection();
|
||||||
}
|
}
|
||||||
|
}.bind(this), 0);
|
||||||
|
if (editor.container.setCapture) {
|
||||||
|
editor.container.setCapture();
|
||||||
|
}
|
||||||
|
editor.setStyle("ace_selecting");
|
||||||
this.setState("select");
|
this.setState("select");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -171,32 +180,14 @@ function DefaultHandlers(mouseHandler) {
|
||||||
editor.renderer.scrollCursorIntoView();
|
editor.renderer.scrollCursorIntoView();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.startDrag = function() {
|
this.selectEnd =
|
||||||
var editor = this.editor;
|
this.selectAllEnd =
|
||||||
this.setState("drag");
|
this.selectByWordsEnd =
|
||||||
this.dragRange = editor.getSelectionRange();
|
this.selectByLinesEnd = function() {
|
||||||
var style = editor.getSelectionStyle();
|
this.editor.unsetStyle("ace_selecting");
|
||||||
this.dragSelectionMarker = editor.session.addMarker(this.dragRange, "ace_selection", style);
|
if (this.editor.container.releaseCapture) {
|
||||||
editor.clearSelection();
|
this.editor.container.releaseCapture();
|
||||||
dom.addCssClass(editor.container, "ace_dragging");
|
|
||||||
if (!this.$dragKeybinding) {
|
|
||||||
this.$dragKeybinding = {
|
|
||||||
handleKeyboard: function(data, hashId, keyString, keyCode) {
|
|
||||||
if (keyString == "esc")
|
|
||||||
return {command: this.command};
|
|
||||||
},
|
|
||||||
command: {
|
|
||||||
exec: function(editor) {
|
|
||||||
var self = editor.$mouseHandler;
|
|
||||||
self.dragCursor = null;
|
|
||||||
self.dragEnd();
|
|
||||||
self.startSelect();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.keyBinding.addKeyboardHandler(this.$dragKeybinding);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.focusWait = function() {
|
this.focusWait = function() {
|
||||||
|
|
@ -207,59 +198,6 @@ function DefaultHandlers(mouseHandler) {
|
||||||
this.startSelect(this.mousedownEvent.getDocumentPosition());
|
this.startSelect(this.mousedownEvent.getDocumentPosition());
|
||||||
};
|
};
|
||||||
|
|
||||||
this.dragWait = function(e) {
|
|
||||||
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
|
|
||||||
var time = (new Date()).getTime();
|
|
||||||
var editor = this.editor;
|
|
||||||
|
|
||||||
if (distance > DRAG_OFFSET) {
|
|
||||||
this.startSelect(this.mousedownEvent.getDocumentPosition());
|
|
||||||
} else if (time - this.mousedownEvent.time > editor.$mouseHandler.$dragDelay) {
|
|
||||||
this.startDrag();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.dragWaitEnd = function(e) {
|
|
||||||
this.mousedownEvent.domEvent = e;
|
|
||||||
this.startSelect();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.drag = function() {
|
|
||||||
var editor = this.editor;
|
|
||||||
this.dragCursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
|
|
||||||
editor.moveCursorToPosition(this.dragCursor);
|
|
||||||
editor.renderer.scrollCursorIntoView();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.dragEnd = function(e) {
|
|
||||||
var editor = this.editor;
|
|
||||||
var dragCursor = this.dragCursor;
|
|
||||||
var dragRange = this.dragRange;
|
|
||||||
dom.removeCssClass(editor.container, "ace_dragging");
|
|
||||||
editor.session.removeMarker(this.dragSelectionMarker);
|
|
||||||
editor.keyBinding.removeKeyboardHandler(this.$dragKeybinding);
|
|
||||||
|
|
||||||
if (!dragCursor)
|
|
||||||
return;
|
|
||||||
|
|
||||||
editor.clearSelection();
|
|
||||||
if (e && (e.ctrlKey || e.altKey)) {
|
|
||||||
var session = editor.session;
|
|
||||||
var newRange = dragRange;
|
|
||||||
newRange.end = session.insert(dragCursor, session.getTextRange(dragRange));
|
|
||||||
newRange.start = dragCursor;
|
|
||||||
} else if (dragRange.contains(dragCursor.row, dragCursor.column)) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
var newRange = editor.moveText(dragRange, dragCursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!newRange)
|
|
||||||
return;
|
|
||||||
|
|
||||||
editor.selection.setSelectionRange(newRange);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.onDoubleClick = function(ev) {
|
this.onDoubleClick = function(ev) {
|
||||||
var pos = ev.getDocumentPosition();
|
var pos = ev.getDocumentPosition();
|
||||||
var editor = this.editor;
|
var editor = this.editor;
|
||||||
|
|
@ -293,7 +231,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
|
|
||||||
editor.selectAll();
|
editor.selectAll();
|
||||||
this.$clickSelection = editor.getSelectionRange();
|
this.$clickSelection = editor.getSelectionRange();
|
||||||
this.setState("null");
|
this.setState("selectAll");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onMouseWheel = function(ev) {
|
this.onMouseWheel = function(ev) {
|
||||||
|
|
|
||||||
122
lib/ace/mouse/dragdrop.js
vendored
122
lib/ace/mouse/dragdrop.js
vendored
|
|
@ -1,122 +0,0 @@
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Distributed under the BSD license:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var event = require("../lib/event");
|
|
||||||
|
|
||||||
var DragdropHandler = function(mouseHandler) {
|
|
||||||
var editor = mouseHandler.editor;
|
|
||||||
var dragSelectionMarker, x, y;
|
|
||||||
var timerId, range;
|
|
||||||
var dragCursor, counter = 0;
|
|
||||||
|
|
||||||
var mouseTarget = editor.container;
|
|
||||||
event.addListener(mouseTarget, "dragenter", function(e) {
|
|
||||||
if (editor.getReadOnly())
|
|
||||||
return;
|
|
||||||
var types = e.dataTransfer.types;
|
|
||||||
if (types && Array.prototype.indexOf.call(types, "text/plain") === -1)
|
|
||||||
return;
|
|
||||||
if (!dragSelectionMarker)
|
|
||||||
addDragMarker();
|
|
||||||
counter++;
|
|
||||||
return event.preventDefault(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
event.addListener(mouseTarget, "dragover", function(e) {
|
|
||||||
if (editor.getReadOnly())
|
|
||||||
return;
|
|
||||||
var types = e.dataTransfer.types;
|
|
||||||
if (types && Array.prototype.indexOf.call(types, "text/plain") === -1)
|
|
||||||
return;
|
|
||||||
if (onMouseMoveTimer !== null)
|
|
||||||
onMouseMoveTimer = null;
|
|
||||||
x = e.clientX;
|
|
||||||
y = e.clientY;
|
|
||||||
return event.preventDefault(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
var onDragInterval = function() {
|
|
||||||
dragCursor = editor.renderer.screenToTextCoordinates(x, y);
|
|
||||||
editor.moveCursorToPosition(dragCursor);
|
|
||||||
editor.renderer.scrollCursorIntoView();
|
|
||||||
};
|
|
||||||
|
|
||||||
event.addListener(mouseTarget, "dragleave", function(e) {
|
|
||||||
counter--;
|
|
||||||
if (counter <= 0 && dragSelectionMarker) {
|
|
||||||
clearDragMarker();
|
|
||||||
return event.preventDefault(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
event.addListener(mouseTarget, "drop", function(e) {
|
|
||||||
if (!dragSelectionMarker)
|
|
||||||
return;
|
|
||||||
range.end = editor.session.insert(dragCursor, e.dataTransfer.getData('Text'));
|
|
||||||
range.start = dragCursor;
|
|
||||||
clearDragMarker();
|
|
||||||
editor.focus();
|
|
||||||
return event.preventDefault(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
function addDragMarker() {
|
|
||||||
range = editor.selection.toOrientedRange();
|
|
||||||
dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
|
|
||||||
editor.clearSelection();
|
|
||||||
clearInterval(timerId);
|
|
||||||
timerId = setInterval(onDragInterval, 20);
|
|
||||||
counter = 0;
|
|
||||||
event.addListener(document, "mousemove", onMouseMove);
|
|
||||||
}
|
|
||||||
function clearDragMarker() {
|
|
||||||
clearInterval(timerId);
|
|
||||||
editor.session.removeMarker(dragSelectionMarker);
|
|
||||||
dragSelectionMarker = null;
|
|
||||||
editor.selection.fromOrientedRange(range);
|
|
||||||
counter = 0;
|
|
||||||
event.removeListener(document, "mousemove", onMouseMove);
|
|
||||||
}
|
|
||||||
// sometimes other code on the page can stop dragleave event leaving editor stuck in the drag state
|
|
||||||
var onMouseMoveTimer = null;
|
|
||||||
function onMouseMove() {
|
|
||||||
if (onMouseMoveTimer == null) {
|
|
||||||
onMouseMoveTimer = setTimeout(function() {
|
|
||||||
if (onMouseMoveTimer != null && dragSelectionMarker)
|
|
||||||
clearDragMarker();
|
|
||||||
}, 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.DragdropHandler = DragdropHandler;
|
|
||||||
});
|
|
||||||
413
lib/ace/mouse/dragdrop_handler.js
Normal file
413
lib/ace/mouse/dragdrop_handler.js
Normal file
|
|
@ -0,0 +1,413 @@
|
||||||
|
/* ***** 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 dom = require("../lib/dom");
|
||||||
|
var event = require("../lib/event");
|
||||||
|
var useragent = require("../lib/useragent");
|
||||||
|
|
||||||
|
var AUTOSCROLL_DELAY = 200;
|
||||||
|
var SCROLL_CURSOR_DELAY = 200;
|
||||||
|
var SCROLL_CURSOR_HYSTERESIS = 5;
|
||||||
|
|
||||||
|
function DragdropHandler(mouseHandler) {
|
||||||
|
|
||||||
|
var editor = mouseHandler.editor;
|
||||||
|
|
||||||
|
// Safari accepts either image or element (but it must present in the DOM)
|
||||||
|
var proxy = dom.createElement("img");
|
||||||
|
// Safari crashes without image data
|
||||||
|
proxy.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
|
||||||
|
|
||||||
|
if (useragent.isOpera) {
|
||||||
|
proxy.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;visibility:hidden";
|
||||||
|
editor.container.appendChild(proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
|
||||||
|
|
||||||
|
exports.forEach(function(x) {
|
||||||
|
mouseHandler[x] = this[x];
|
||||||
|
}, this);
|
||||||
|
editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
|
||||||
|
|
||||||
|
|
||||||
|
var mouseTarget = editor.container;
|
||||||
|
var dragSelectionMarker, x, y;
|
||||||
|
var timerId, range;
|
||||||
|
var dragCursor, counter = 0;
|
||||||
|
var dragOperation;
|
||||||
|
var autoScrollStartTime;
|
||||||
|
var cursorMovedTime;
|
||||||
|
var cursorPointOnCaretMoved;
|
||||||
|
|
||||||
|
this.onDragStart = function(e) {
|
||||||
|
// webkit workaround, see this.onMouseDown
|
||||||
|
if (this.cancelDrag || !mouseTarget.draggable) {
|
||||||
|
var self = this;
|
||||||
|
setTimeout(function(){
|
||||||
|
self.startSelect();
|
||||||
|
self.captureMouse(e);
|
||||||
|
}, 0);
|
||||||
|
return e.preventDefault();
|
||||||
|
}
|
||||||
|
if (useragent.isOpera) {
|
||||||
|
proxy.style.visibility = "visible";
|
||||||
|
setTimeout(function(){
|
||||||
|
proxy.style.visibility = "hidden";
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
range = editor.getSelectionRange();
|
||||||
|
|
||||||
|
var dataTransfer = e.dataTransfer;
|
||||||
|
dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
|
||||||
|
dataTransfer.setDragImage && dataTransfer.setDragImage(proxy, 0, 0);
|
||||||
|
// clear Opera garbage
|
||||||
|
dataTransfer.clearData();
|
||||||
|
dataTransfer.setData("Text", editor.session.getTextRange());
|
||||||
|
|
||||||
|
this.setState("drag");
|
||||||
|
};
|
||||||
|
|
||||||
|
this.onDragEnd = function(e) {
|
||||||
|
mouseTarget.draggable = false;
|
||||||
|
this.setState(null);
|
||||||
|
if (!editor.getReadOnly()) {
|
||||||
|
var dropEffect = e.dataTransfer.dropEffect;
|
||||||
|
if (!dragOperation && dropEffect == "move")
|
||||||
|
// text was dragged outside the editor
|
||||||
|
editor.session.remove(editor.getSelectionRange());
|
||||||
|
editor.renderer.$cursorLayer.setBlinking(true);
|
||||||
|
}
|
||||||
|
this.editor.unsetStyle("ace_dragging");
|
||||||
|
};
|
||||||
|
|
||||||
|
this.onDragEnter = function(e) {
|
||||||
|
if (editor.getReadOnly() || !canAccept(e.dataTransfer))
|
||||||
|
return;
|
||||||
|
if (!dragSelectionMarker)
|
||||||
|
addDragMarker();
|
||||||
|
counter++;
|
||||||
|
// dataTransfer object does not save dropEffect across events on IE, so we store it in dragOperation
|
||||||
|
e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
|
||||||
|
return event.preventDefault(e);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.onDragOver = function(e) {
|
||||||
|
if (editor.getReadOnly() || !canAccept(e.dataTransfer))
|
||||||
|
return;
|
||||||
|
// Opera doesn't trigger dragenter event on drag start
|
||||||
|
if (!dragSelectionMarker) {
|
||||||
|
addDragMarker();
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
if (onMouseMoveTimer !== null)
|
||||||
|
onMouseMoveTimer = null;
|
||||||
|
x = e.clientX;
|
||||||
|
y = e.clientY;
|
||||||
|
|
||||||
|
e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
|
||||||
|
return event.preventDefault(e);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.onDragLeave = function(e) {
|
||||||
|
counter--;
|
||||||
|
if (counter <= 0 && dragSelectionMarker) {
|
||||||
|
clearDragMarker();
|
||||||
|
dragOperation = null;
|
||||||
|
return event.preventDefault(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.onDrop = function(e) {
|
||||||
|
if (!dragSelectionMarker)
|
||||||
|
return;
|
||||||
|
var dataTransfer = e.dataTransfer;
|
||||||
|
var isInternal = this.state == "drag";
|
||||||
|
if (isInternal) {
|
||||||
|
switch (dragOperation) {
|
||||||
|
case "move":
|
||||||
|
if (range.contains(dragCursor.row, dragCursor.column)) {
|
||||||
|
// clear selection
|
||||||
|
range = {
|
||||||
|
start: dragCursor,
|
||||||
|
end: dragCursor
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// move text
|
||||||
|
range = editor.moveText(range, dragCursor);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "copy":
|
||||||
|
// copy text
|
||||||
|
range = editor.moveText(range, dragCursor, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var dropData = dataTransfer.getData('Text');
|
||||||
|
range = {
|
||||||
|
start: dragCursor,
|
||||||
|
end: editor.session.insert(dragCursor, dropData)
|
||||||
|
};
|
||||||
|
editor.focus();
|
||||||
|
dragOperation = null;
|
||||||
|
}
|
||||||
|
clearDragMarker();
|
||||||
|
return event.preventDefault(e);
|
||||||
|
};
|
||||||
|
|
||||||
|
event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
|
||||||
|
event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
|
||||||
|
event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
|
||||||
|
event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
|
||||||
|
event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
|
||||||
|
event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
|
||||||
|
|
||||||
|
function scrollCursorIntoView(cursor, prevCursor) {
|
||||||
|
var now = new Date().getTime();
|
||||||
|
var vMovement = !prevCursor || cursor.row != prevCursor.row;
|
||||||
|
var hMovement = !prevCursor || cursor.column != prevCursor.column;
|
||||||
|
if (!cursorMovedTime || vMovement || hMovement) {
|
||||||
|
editor.$blockScrolling += 1;
|
||||||
|
editor.moveCursorToPosition(cursor);
|
||||||
|
editor.$blockScrolling -= 1;
|
||||||
|
cursorMovedTime = now;
|
||||||
|
cursorPointOnCaretMoved = {x: x, y: y};
|
||||||
|
} else {
|
||||||
|
var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
|
||||||
|
if (distance > SCROLL_CURSOR_HYSTERESIS) {
|
||||||
|
cursorMovedTime = null;
|
||||||
|
} else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
|
||||||
|
editor.renderer.scrollCursorIntoView();
|
||||||
|
cursorMovedTime = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function autoScroll(cursor, prevCursor) {
|
||||||
|
var now = new Date().getTime();
|
||||||
|
var lineHeight = editor.renderer.layerConfig.lineHeight;
|
||||||
|
var characterWidth = editor.renderer.layerConfig.characterWidth;
|
||||||
|
var editorRect = editor.renderer.scroller.getBoundingClientRect();
|
||||||
|
var offsets = {
|
||||||
|
x: {
|
||||||
|
left: x - editorRect.left,
|
||||||
|
right: editorRect.right - x
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
top: y - editorRect.top,
|
||||||
|
bottom: editorRect.bottom - y
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
|
||||||
|
var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
|
||||||
|
var scrollCursor = {row: cursor.row, column: cursor.column};
|
||||||
|
if (nearestXOffset / characterWidth <= 2) {
|
||||||
|
scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
|
||||||
|
}
|
||||||
|
if (nearestYOffset / lineHeight <= 1) {
|
||||||
|
scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
|
||||||
|
}
|
||||||
|
var vScroll = cursor.row != scrollCursor.row;
|
||||||
|
var hScroll = cursor.column != scrollCursor.column;
|
||||||
|
var vMovement = !prevCursor || cursor.row != prevCursor.row;
|
||||||
|
if (vScroll || (hScroll && !vMovement)) {
|
||||||
|
if (!autoScrollStartTime)
|
||||||
|
autoScrollStartTime = now;
|
||||||
|
else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
|
||||||
|
editor.renderer.scrollCursorIntoView(scrollCursor);
|
||||||
|
} else {
|
||||||
|
autoScrollStartTime = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDragInterval() {
|
||||||
|
var prevCursor = dragCursor;
|
||||||
|
dragCursor = editor.renderer.screenToTextCoordinates(x, y);
|
||||||
|
scrollCursorIntoView(dragCursor, prevCursor);
|
||||||
|
autoScroll(dragCursor, prevCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addDragMarker() {
|
||||||
|
range = editor.selection.toOrientedRange();
|
||||||
|
dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
|
||||||
|
editor.clearSelection();
|
||||||
|
clearInterval(timerId);
|
||||||
|
timerId = setInterval(onDragInterval, 20);
|
||||||
|
counter = 0;
|
||||||
|
event.addListener(document, "mousemove", onMouseMove);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearDragMarker() {
|
||||||
|
clearInterval(timerId);
|
||||||
|
editor.session.removeMarker(dragSelectionMarker);
|
||||||
|
dragSelectionMarker = null;
|
||||||
|
editor.$blockScrolling += 1;
|
||||||
|
editor.selection.fromOrientedRange(range);
|
||||||
|
editor.$blockScrolling -= 1;
|
||||||
|
range = null;
|
||||||
|
counter = 0;
|
||||||
|
autoScrollStartTime = null;
|
||||||
|
cursorMovedTime = null;
|
||||||
|
event.removeListener(document, "mousemove", onMouseMove);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sometimes other code on the page can stop dragleave event leaving editor stuck in the drag state
|
||||||
|
var onMouseMoveTimer = null;
|
||||||
|
function onMouseMove() {
|
||||||
|
if (onMouseMoveTimer == null) {
|
||||||
|
onMouseMoveTimer = setTimeout(function() {
|
||||||
|
if (onMouseMoveTimer != null && dragSelectionMarker)
|
||||||
|
clearDragMarker();
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function canAccept(dataTransfer) {
|
||||||
|
var types = dataTransfer.types;
|
||||||
|
return !types || Array.prototype.some.call(types, function(type) {
|
||||||
|
return type == 'text/plain' || type == 'Text';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropEffect(e) {
|
||||||
|
var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
|
||||||
|
var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
|
||||||
|
|
||||||
|
var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
|
||||||
|
|
||||||
|
// IE throws error while dragging from another app
|
||||||
|
var effectAllowed = "uninitialized";
|
||||||
|
try {
|
||||||
|
effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
|
||||||
|
} catch (e) {}
|
||||||
|
var dropEffect = "none";
|
||||||
|
|
||||||
|
if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
|
||||||
|
dropEffect = "copy";
|
||||||
|
else if (moveAllowed.indexOf(effectAllowed) >= 0)
|
||||||
|
dropEffect = "move";
|
||||||
|
else if (copyAllowed.indexOf(effectAllowed) >= 0)
|
||||||
|
dropEffect = "copy";
|
||||||
|
|
||||||
|
return dropEffect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
this.dragWait = function() {
|
||||||
|
var interval = (new Date()).getTime() - this.mousedownEvent.time;
|
||||||
|
if (interval > this.editor.getDragDelay())
|
||||||
|
this.startDrag();
|
||||||
|
};
|
||||||
|
|
||||||
|
this.dragWaitEnd = function() {
|
||||||
|
var target = this.editor.container;
|
||||||
|
target.draggable = false;
|
||||||
|
this.startSelect(this.mousedownEvent.getDocumentPosition());
|
||||||
|
this.selectEnd();
|
||||||
|
};
|
||||||
|
|
||||||
|
this.dragReadyEnd = function(e) {
|
||||||
|
this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
|
||||||
|
this.editor.unsetStyle("ace_dragging");
|
||||||
|
this.dragWaitEnd();
|
||||||
|
};
|
||||||
|
|
||||||
|
this.startDrag = function(){
|
||||||
|
this.cancelDrag = false;
|
||||||
|
var target = this.editor.container;
|
||||||
|
target.draggable = true;
|
||||||
|
this.editor.renderer.$cursorLayer.setBlinking(false);
|
||||||
|
this.editor.setStyle("ace_dragging");
|
||||||
|
this.setState("dragReady");
|
||||||
|
};
|
||||||
|
|
||||||
|
this.onMouseDrag = function(e) {
|
||||||
|
var target = this.editor.container;
|
||||||
|
if (useragent.isIE && this.state == "dragReady") {
|
||||||
|
// IE does not handle [draggable] attribute set after mousedown
|
||||||
|
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
|
||||||
|
if (distance > 3)
|
||||||
|
target.dragDrop();
|
||||||
|
}
|
||||||
|
if (this.state === "dragWait") {
|
||||||
|
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
|
||||||
|
if (distance > 0) {
|
||||||
|
target.draggable = false;
|
||||||
|
this.startSelect(this.mousedownEvent.getDocumentPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.onMouseDown = function(e) {
|
||||||
|
if (!this.$dragEnabled)
|
||||||
|
return;
|
||||||
|
this.mousedownEvent = e;
|
||||||
|
var editor = this.editor;
|
||||||
|
|
||||||
|
var inSelection = e.inSelection();
|
||||||
|
var button = e.getButton();
|
||||||
|
var clickCount = e.domEvent.detail || 1;
|
||||||
|
if (clickCount === 1 && button === 0 && inSelection) {
|
||||||
|
this.mousedownEvent.time = (new Date()).getTime();
|
||||||
|
var eventTarget = e.domEvent.target || e.domEvent.srcElement;
|
||||||
|
if ("unselectable" in eventTarget)
|
||||||
|
eventTarget.unselectable = "on";
|
||||||
|
if (editor.getDragDelay()) {
|
||||||
|
// https://code.google.com/p/chromium/issues/detail?id=286700
|
||||||
|
if (useragent.isWebKit) {
|
||||||
|
self.cancelDrag = true;
|
||||||
|
var mouseTarget = editor.container;
|
||||||
|
mouseTarget.draggable = true;
|
||||||
|
}
|
||||||
|
this.setState("dragWait");
|
||||||
|
} else {
|
||||||
|
this.startDrag();
|
||||||
|
}
|
||||||
|
this.captureMouse(e, this.onMouseDrag.bind(this));
|
||||||
|
// TODO: a better way to prevent default handler without preventing browser default action
|
||||||
|
e.defaultPrevented = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}).call(DragdropHandler.prototype);
|
||||||
|
|
||||||
|
|
||||||
|
function calcDistance(ax, ay, bx, by) {
|
||||||
|
return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.DragdropHandler = DragdropHandler;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -92,10 +92,7 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
|
||||||
|
|
||||||
var editor = this.editor;
|
var editor = this.editor;
|
||||||
|
|
||||||
if (editor.getReadOnly()) {
|
|
||||||
this.$inSelection = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var selectionRange = editor.getSelectionRange();
|
var selectionRange = editor.getSelectionRange();
|
||||||
if (selectionRange.isEmpty())
|
if (selectionRange.isEmpty())
|
||||||
this.$inSelection = false;
|
this.$inSelection = false;
|
||||||
|
|
@ -103,7 +100,7 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
|
||||||
var pos = this.getDocumentPosition();
|
var pos = this.getDocumentPosition();
|
||||||
this.$inSelection = selectionRange.contains(pos.row, pos.column);
|
this.$inSelection = selectionRange.contains(pos.row, pos.column);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return this.$inSelection;
|
return this.$inSelection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ var useragent = require("../lib/useragent");
|
||||||
var DefaultHandlers = require("./default_handlers").DefaultHandlers;
|
var DefaultHandlers = require("./default_handlers").DefaultHandlers;
|
||||||
var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
|
var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
|
||||||
var MouseEvent = require("./mouse_event").MouseEvent;
|
var MouseEvent = require("./mouse_event").MouseEvent;
|
||||||
var DragdropHandler = require("./dragdrop").DragdropHandler;
|
var DragdropHandler = require("./dragdrop_handler").DragdropHandler;
|
||||||
var config = require("../config");
|
var config = require("../config");
|
||||||
|
|
||||||
var MouseHandler = function(editor) {
|
var MouseHandler = function(editor) {
|
||||||
|
|
@ -64,7 +64,6 @@ var MouseHandler = function(editor) {
|
||||||
|
|
||||||
event.addListener(mouseTarget, "mousedown", function(e) {
|
event.addListener(mouseTarget, "mousedown", function(e) {
|
||||||
editor.focus();
|
editor.focus();
|
||||||
return event.preventDefault(e);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
event.addListener(gutterEl, "mousedown", function(e) {
|
event.addListener(gutterEl, "mousedown", function(e) {
|
||||||
|
|
@ -100,10 +99,7 @@ var MouseHandler = function(editor) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.captureMouse = function(ev, state) {
|
this.captureMouse = function(ev, mouseMoveHandler) {
|
||||||
if (state)
|
|
||||||
this.setState(state);
|
|
||||||
|
|
||||||
this.x = ev.x;
|
this.x = ev.x;
|
||||||
this.y = ev.y;
|
this.y = ev.y;
|
||||||
|
|
||||||
|
|
@ -118,6 +114,7 @@ var MouseHandler = function(editor) {
|
||||||
var onMouseMove = function(e) {
|
var onMouseMove = function(e) {
|
||||||
self.x = e.clientX;
|
self.x = e.clientX;
|
||||||
self.y = e.clientY;
|
self.y = e.clientY;
|
||||||
|
mouseMoveHandler && mouseMoveHandler(e);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onCaptureEnd = function(e) {
|
var onCaptureEnd = function(e) {
|
||||||
|
|
@ -130,7 +127,7 @@ var MouseHandler = function(editor) {
|
||||||
renderer.$moveTextAreaToCursor();
|
renderer.$moveTextAreaToCursor();
|
||||||
}
|
}
|
||||||
self.isMousePressed = false;
|
self.isMousePressed = false;
|
||||||
self.onMouseEvent("mouseup", e)
|
self.onMouseEvent("mouseup", e);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onCaptureInterval = function() {
|
var onCaptureInterval = function() {
|
||||||
|
|
@ -149,6 +146,7 @@ var MouseHandler = function(editor) {
|
||||||
config.defineOptions(MouseHandler.prototype, "mouseHandler", {
|
config.defineOptions(MouseHandler.prototype, "mouseHandler", {
|
||||||
scrollSpeed: {initialValue: 2},
|
scrollSpeed: {initialValue: 2},
|
||||||
dragDelay: {initialValue: 150},
|
dragDelay: {initialValue: 150},
|
||||||
|
dragEnabled: {initialValue: true},
|
||||||
focusTimout: {initialValue: 0}
|
focusTimout: {initialValue: 0}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -694,8 +694,9 @@ var Editor = require("./editor").Editor;
|
||||||
var range = sel.toOrientedRange();
|
var range = sel.toOrientedRange();
|
||||||
if (range.isEmpty()) {
|
if (range.isEmpty()) {
|
||||||
var range = session.getWordRange(range.start.row, range.start.column);
|
var range = session.getWordRange(range.start.row, range.start.column);
|
||||||
range.cursor = range.end;
|
range.cursor = dir == -1 ? range.start : range.end;
|
||||||
this.multiSelect.addRange(range);
|
this.multiSelect.addRange(range);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
var needle = session.getTextRange(range);
|
var needle = session.getTextRange(range);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ module.exports = {
|
||||||
MultiSelect(editor);
|
MultiSelect(editor);
|
||||||
|
|
||||||
editor.navigateFileEnd();
|
editor.navigateFileEnd();
|
||||||
exec("selectMoreBefore", 3);
|
exec("selectMoreBefore", 4);
|
||||||
assert.ok(editor.inMultiSelectMode);
|
assert.ok(editor.inMultiSelectMode);
|
||||||
assert.equal(editor.selection.getAllRanges().length, 4);
|
assert.equal(editor.selection.getAllRanges().length, 4);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue