Merge pull request #1952 from ajaxorg/misc

Sync with cloud9 + better demos
This commit is contained in:
Lennart Kats 2014-05-11 19:13:07 +02:00
commit 669deb54b2
24 changed files with 411 additions and 229 deletions

View file

@ -247,6 +247,46 @@ function demo(project) {
}); });
copyFileSync(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png"); copyFileSync(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png");
fs.readdirSync(ACE_HOME + "/demo/").forEach(function(x) {
if (/\s|requirejs/.test(x) || !/\.(js|html)$/.test(x))
return;
copy({
source: ACE_HOME +"/demo/" + x,
dest: BUILD_DIR + "/demo/" + x,
filter: [function(source) {
if (/\.(js)$/.test(x))
return source;
var removeRequireJS
source = source.replace(/<script src="kitchen-sink\/require.js"[\s\S]+?require\(\[([^\]]+).*/, function(e, m){
removeRequireJS = true;
var scripts = m.split(/,\s*/);
var result = [];
function comment(str) {result.push("<!-- " + str + " -->")};
function script(str) {result.push('<script src="../src/' + str + '.js"></script>')}
scripts.forEach(function(s) {
s = s.replace(/"/g, "");
if (s == "ace/ace") {
comment("load ace")
script("ace")
} else {
var extName = s.match(/[^/]*$/)[0];
comment("load ace " + extName + " extension");
script("ext-" + extName);
}
});
result.push("<script>")
return result.join("\n");
});
if (removeRequireJS)
source = source.replace(/\s*\}\);?\s*(<\/script>)/, "\n$1");
source = source.replace(/"\.\.\/build\//g, function(e) {
console.log(e); return '"../';
});
return source;
}]
});
});
} }
function jsFileList(path, filter) { function jsFileList(path, filter) {

View file

@ -35,7 +35,8 @@
// enable autocompletion and snippets // enable autocompletion and snippets
editor.setOptions({ editor.setOptions({
enableBasicAutocompletion: true, enableBasicAutocompletion: true,
enableSnippets: true enableSnippets: true,
enableLiveAutocompletion: false
}); });
</script> </script>

View file

@ -20,29 +20,37 @@
</style> </style>
</head> </head>
<body> <body>
<pre id="editor">autoresizing editor</pre> <pre id="editor1">autoresizing editor</pre>
<div class="scrollmargin"></div> <div class="scrollmargin"></div>
<pre id="editor2">minHeight = 2 lines</pre> <pre id="editor2">minHeight = 2 lines</pre>
<div class="scrollmargin"></div>
<pre id="editor"></pre>
<script src="../build/src/ace.js"></script> <script src="../build/src/ace.js"></script>
<script> <script>
// create first editor var editor1 = ace.edit("editor1");
var editor = ace.edit("editor"); editor1.setTheme("ace/theme/tomorrow_night_eighties");
editor.setTheme("ace/theme/tomorrow"); editor1.session.setMode("ace/mode/html");
editor.session.setMode("ace/mode/html"); editor1.setAutoScrollEditorIntoView(true);
editor.setAutoScrollEditorIntoView(); editor1.setOption("maxLines", 30);
editor.setOption("maxLines", 100);
var editor2 = ace.edit("editor2"); var editor2 = ace.edit("editor2");
editor2.setTheme("ace/theme/tomorrow_night_blue"); editor2.setTheme("ace/theme/tomorrow_night_blue");
editor2.session.setMode("ace/mode/html"); editor2.session.setMode("ace/mode/html");
editor2.setAutoScrollEditorIntoView(); editor2.setAutoScrollEditorIntoView(true);
editor2.setOption("maxLines", 30); editor2.setOption("maxLines", 30);
editor2.setOption("minLines", 2); editor2.setOption("minLines", 2);
var editor = ace.edit("editor");
editor.setTheme("ace/theme/tomorrow");
editor.session.setMode("ace/mode/html");
editor.setAutoScrollEditorIntoView(true);
editor.setOption("maxLines", 100);
</script> </script>
<script src="./show_own_source.js"></script>
</body> </body>
</html> </html>

View file

@ -22,19 +22,20 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<!-- load ace --> <!-- load emmet code and snippets compiled for browser -->
<script src="../build/src-noconflict/ace.js"></script>
<!-- load ace emmet extension -->
<script src="../build/src-noconflict/ext-emmet.js"></script>
<!-- load core emmet files -->
<script src="https://nightwing.github.io/emmet-core/emmet.js"></script> <script src="https://nightwing.github.io/emmet-core/emmet.js"></script>
<script src="kitchen-sink/require.js"></script>
<script> <script>
// trigger extension // setup paths
ace.require("ace/ext/emmet"); require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/emmet"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.session.setMode("ace/mode/html"); editor.session.setMode("ace/mode/html");
// enable emmet on the current editor // enable emmet on the current editor
editor.setOption("enableEmmet", true); editor.setOption("enableEmmet", true);
});
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>ACE Editor StatusBar Demo</title> <title>ACE Editor StatusBar Demo</title>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
/*!important without this top: 0; bottom: 0 doesn't work */ /*!important without this top: 0; bottom: 0 doesn't work on old ie */
body, html { body, html {
position: absolute; position: absolute;
top: 0px; bottom: 0; left: 0; right: 0; top: 0px; bottom: 0; left: 0; right: 0;

View file

@ -22,8 +22,11 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<script src="../build/src-noconflict/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
require(["ace/ace"], function(ace) {
var editor = ace.edit("editor") var editor = ace.edit("editor")
editor.setTheme("ace/theme/twilight") editor.setTheme("ace/theme/twilight")
editor.session.setMode("ace/mode/html") editor.session.setMode("ace/mode/html")
@ -39,6 +42,8 @@
}) })
} }
}) })
editor.execCommand("showKeyboardShortcuts")
})
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -23,24 +23,27 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<script src="../build/src-noconflict/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script src="../build/src-noconflict/ext-modelist.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/modelist"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
(function () { (function () {
var modelist = ace.require('ace/ext/modelist'); var modelist = ace.require("ace/ext/modelist");
// the file path could come from an xmlhttp request, a drop event, // the file path could come from an xmlhttp request, a drop event,
// or any other scriptable file loading process. // or any other scriptable file loading process.
// Extensions could consume the modelist and use it to dynamically // Extensions could consume the modelist and use it to dynamically
// set the editor mode. Webmasters could use it in their scripts // set the editor mode. Webmasters could use it in their scripts
// for site specific purposes as well. // for site specific purposes as well.
var filePath = 'blahblah/weee/some.js'; var filePath = "blahblah/weee/some.js";
var mode = modelist.getModeForPath(filePath).mode; var mode = modelist.getModeForPath(filePath).mode;
console.log(mode); console.log(mode);
editor.session.setMode(mode); editor.session.setMode(mode);
}()); }());
})
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -5,19 +5,18 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Editor</title> <title>Editor</title>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
.ace_editor {
.ace_editor { position: relative !important;
position: relative !important; border: 1px solid lightgray;
border: 1px solid lightgray; margin: auto;
margin: auto; height: 200px;
height: 200px; width: 80%;
width: 80%; }
}
.ace_editor.fullScreen { .ace_editor.fullScreen {
height: auto; height: auto;
width: auto; width: auto;
border: 0; border: 0;
margin: 0; margin: 0;
position: fixed !important; position: fixed !important;
top: 0; top: 0;
@ -25,17 +24,16 @@
left: 0; left: 0;
right: 0; right: 0;
z-index: 10; z-index: 10;
background: white;
} }
.fullScreen { .fullScreen {
overflow: hidden overflow: hidden
} }
.scrollmargin { .scrollmargin {
height: 500px; height: 500px;
text-align: center; text-align: center;
} }
.large-button { .large-button {
color: lightblue; color: lightblue;
@ -56,7 +54,7 @@
<body> <body>
<div class="scrollmargin"> <div class="scrollmargin">
<span onclick="scroll()" class="large-button"> <span onclick="scroll()" class="large-button">
scroll down &dArr; scroll down &dArr;
</span> </span>
</div> </div>
<pre id="editor">function foo(items) { <pre id="editor">function foo(items) {
@ -76,28 +74,35 @@
</div> </div>
<script src="../build/src/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script> <script>
require.config({paths: { "ace" : "../lib/ace"}});
require(["ace/ace", "ace/ext/themelist"], function(ace) {
var $ = document.getElementById.bind(document); var $ = document.getElementById.bind(document);
var dom = require("ace/lib/dom"); var dom = require("ace/lib/dom");
//add command to all new editor instaces //add command to all new editor instaces
require("ace/commands/default_commands").commands.push({ require("ace/commands/default_commands").commands.push({
name: "Toggle Fullscreen", name: "Toggle Fullscreen",
bindKey: "F11", bindKey: "F11",
exec: function(editor) { exec: function(editor) {
dom.toggleCssClass(document.body, "fullScreen") var fullScreen = dom.toggleCssClass(document.body, "fullScreen")
dom.toggleCssClass(editor.container, "fullScreen") dom.setCssClass(editor.container, "fullScreen", fullScreen)
editor.setAutoScrollEditorIntoView() editor.setAutoScrollEditorIntoView(!fullScreen)
editor.resize() editor.resize()
} }
}) })
// create first editor // create first editor
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/javascript"); editor.session.setMode("ace/mode/javascript");
editor.setAutoScrollEditorIntoView(); editor.renderer.setScrollMargin(10, 10);
editor.setOptions({
// "scrollPastEnd": 0.8,
autoScrollEditorIntoView: true
});
var count = 1; var count = 1;
function add() { function add() {
@ -110,12 +115,13 @@ function add() {
oldEl.parentNode.insertBefore(el, pad.nextSibling) oldEl.parentNode.insertBefore(el, pad.nextSibling)
count++ count++
var theme = "ace/theme/" + themes[Math.floor(themes.length * Math.random() - 1e-5)] var theme = themes[Math.floor(themes.length * Math.random() - 1e-5)]
editor = ace.edit(el) editor = ace.edit(el)
editor.setTheme(theme) editor.setOptions({
editor.session.setMode("ace/mode/javascript") mode: "ace/mode/javascript",
theme: theme,
editor.setAutoScrollEditorIntoView() autoScrollEditorIntoView: true
})
editor.setValue([ editor.setValue([
"this is editor number: ", count, "\n", "this is editor number: ", count, "\n",
@ -126,7 +132,6 @@ function add() {
scroll() scroll()
} }
function scroll(speed) { function scroll(speed) {
var top = editor.container.getBoundingClientRect().top var top = editor.container.getBoundingClientRect().top
speed = speed || 10 speed = speed || 10
@ -139,14 +144,11 @@ function scroll(speed) {
} }
} }
var themes = { var themes = require("ace/ext/themelist").themes.map(function(t){return t.theme});
bright: [ "chrome", "clouds", "crimson_editor", "dawn", "dreamweaver", "eclipse", "github",
"solarized_light", "textmate", "tomorrow"], window.add = add;
dark: [ "clouds_midnight", "cobalt", "idle_fingers", "kr_theme", "merbivore", "merbivore_soft", window.scroll = scroll;
"mono_industrial", "monokai", "pastel_on_dark", "solarized_dark", "terminal", "tomorrow_night", });
"tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night_eighties", "twilight", "vibrant_ink"]
}
themes = [].concat(themes.bright, themes.dark);
</script> </script>
</body> </body>

View file

@ -23,9 +23,12 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<script src="../build/src-noconflict/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script src="../build/src-noconflict/ext-settings_menu.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/settings_menu"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
ace.require('ace/ext/settings_menu').init(editor); ace.require('ace/ext/settings_menu').init(editor);
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
@ -38,6 +41,7 @@
}, },
readOnly: true readOnly: true
}]); }]);
})
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -1,3 +1,16 @@
ace.require("ace/lib/net").get(document.baseURI, function(t){ if (typeof ace == "undefined" && typeof require == "undefined") {
editor.setValue(t, 1); document.body.innerHTML = "<p style='padding: 20px 50px;'>couldn't find ace.js file, <br>"
}) + "to build it run <code>node Makefile.dryice.js full<code>"
} else if (typeof ace == "undefined" && typeof require != "undefined") {
require(["ace/ace"], setValue)
} else {
require = ace.require;
setValue()
}
function setValue() {
require("ace/lib/net").get(document.baseURI, function(t){
var el = document.getElementById("editor");
el.env.editor.setValue(t, 1);
})
}

View file

@ -1,5 +1,4 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" <!DOCTYPE html>
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en"> <html lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@ -34,30 +33,31 @@ function wobble (flam) {
return flam.wobbled = true; return flam.wobbled = true;
} }
// the scrollbars are from overflow auto on .ace_editor.
</pre> </pre>
<script src="../../build/src-noconflict/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script src="../../build/src-noconflict/ext-static_highlight.js"></script>
<script> <script>
var highlight = ace.require("ace/ext/static_highlight") require.config({paths: { "ace" : "../lib/ace"}});
var dom = ace.require("ace/lib/dom")
function qsa(sel) {
return [].slice.call(document.querySelectorAll(sel));
}
qsa(".code").forEach(function (codeEl) { require(["ace/ace", "ace/ext/static_highlight"], function(ace) {
highlight(codeEl, { var highlight = ace.require("ace/ext/static_highlight")
mode: codeEl.getAttribute('ace-mode'), var dom = ace.require("ace/lib/dom")
theme: codeEl.getAttribute('ace-theme'), function qsa(sel) {
startLineNumber: 1, return Array.apply(null, document.querySelectorAll(sel));
showGutter: codeEl.getAttribute("ace-gutter"), }
trim: true
}, function (highlighted) { qsa(".code").forEach(function (codeEl) {
highlight(codeEl, {
mode: codeEl.getAttribute("ace-mode"),
theme: codeEl.getAttribute("ace-theme"),
startLineNumber: 1,
showGutter: codeEl.getAttribute("ace-gutter"),
trim: true
}, function (highlighted) {
});
}); });
}); })
</script> </script>
</body> </body>

View file

@ -41,15 +41,19 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<div id="statusBar">ace rocks!</div> <div id="statusBar">ace rocks!</div>
<script src="../build/src-noconflict/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script src="../build/src-noconflict/ext-statusbar.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/statusbar"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
var StatusBar = ace.require('ace/ext/statusbar').StatusBar; var StatusBar = ace.require("ace/ext/statusbar").StatusBar;
// create a simple selection status indicator // create a simple selection status indicator
var statusBar = new StatusBar(editor, document.getElementById('statusBar')); var statusBar = new StatusBar(editor, document.getElementById("statusBar"));
editor.setTheme("ace/theme/dawn"); editor.setTheme("ace/theme/dawn");
editor.session.setMode("ace/mode/html"); editor.session.setMode("ace/mode/html");
});
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -760,11 +760,6 @@ if (match) {
style="left: -5px; top: 10px;" /> style="left: -5px; top: 10px;" />
<a href="http://www.codecademy.com/">Codecademy</a> <a href="http://www.codecademy.com/">Codecademy</a>
</li> </li>
<li>
<img src="http://textor.houfeng.net/images/textor.png"
style="position: relative; left: 13px; top: -3px; width: 75px" />
<a href="http://textor.houfeng.net/">Textor</a>
</li>
<li> <li>
<img src="doc/site/images/rstudio_logo_64.png" <img src="doc/site/images/rstudio_logo_64.png"
style="left: 19px; top: 2px;" /> style="left: 19px; top: 2px;" />
@ -793,7 +788,7 @@ if (match) {
<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;
padding: 6px 4px 6px 6px; width: 100px" /> padding: 6px 4px 6px 6px; width: 100px" />
<a href="http://www.zorba-xquery.com/html/demo">Zorba XQuery</a> <a href="http://try.zorba.io/queries/xquery">Zorba XQuery</a>
</li> </li>
<li> <li>
<img src="doc/site/images/plunker.png" <img src="doc/site/images/plunker.png"
@ -879,9 +874,9 @@ if (match) {
<a href="https://drivenotepad.appspot.com/support">Drive Notepad</a> <a href="https://drivenotepad.appspot.com/support">Drive Notepad</a>
</li> </li>
<li> <li>
<img src="doc/site/images/FineCut_small_logo.png" <img src="http://textor.houfeng.net/images/textor.png"
style="left: 12px; top: -4px" /> style="position: relative; left: 13px; top: -3px; width: 75px" />
<a href="http://finecut.info/">Fine Cut Engine</a> <a href="http://textor.houfeng.net/">Textor</a>
</li> </li>
<li> <li>
<img src="http://phpassist.com/images/logo-large.png" <img src="http://phpassist.com/images/logo-large.png"
@ -915,9 +910,9 @@ if (match) {
<a href="http://orbit.bonsaijs.org/">BonsaiJS playground</a> <a href="http://orbit.bonsaijs.org/">BonsaiJS playground</a>
</li> </li>
<li> <li>
<img src="doc/site/images/acebug-logo.png" <img src="http://approximatrix.com/products/simplytext/logo-320x320.png"
style="left: 20px; top: 5px;"> style="width: 106px; left: -4px; top: -22px;">
<a href="https://addons.mozilla.org/en-US/firefox/addon/acebug/">Acebug</a> <a href="http://approximatrix.com/products/simplytext">Simply Text</a>
</li> </li>
<li> <li>
<div class="text-logo" style="font-size: 18px;">ShareLaTeX</div> <div class="text-logo" style="font-size: 18px;">ShareLaTeX</div>
@ -1117,7 +1112,7 @@ if (match) {
<a href="http://bakemycss.mypathforpython.appspot.com/">BakeMyCss</a> <a href="http://bakemycss.mypathforpython.appspot.com/">BakeMyCss</a>
</li> </li>
<li> <li>
<div class="" style=" <div style="
background: url(https://s3.amazonaws.com/spark-website/spark.png) no-repeat; background: url(https://s3.amazonaws.com/spark-website/spark.png) no-repeat;
position: absolute; height: 65px; width: 83px; background-size: 200px 65px; position: absolute; height: 65px; width: 83px; background-size: 200px 65px;
background-position: 19px;"></div> background-position: 19px;"></div>
@ -1136,7 +1131,56 @@ if (match) {
<a href=" http://www.praczone.com/editor">pracZone</a> <a href=" http://www.praczone.com/editor">pracZone</a>
</li> </li>
<li> <li>
<a href="https://github.com/Gozala/sky-edit">Sky Edit</a> <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>
<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: 86px; left: 7px; top: -11px;">
<a href="http://neutronide.com/">Neutron IDE</a>
</li>
<li>
<div style="
background: url(https://www.pythonanywhere.com/static/anywhere/images/logo-234x35.png) no-repeat;
position: absolute; height: 65px; width: 94px; background-size: 234px 35px;
background-position: 19px;"></div>
<a href="http://www.pythonanywhere.com/">PythonAnywhere</a>
</li>
<li>
<img src="http://subtexteditor.com/images/subtext-icon-4.png"
style="width: 86px; left: 7px; top: -11px;">
<a href="http://subtexteditor.com/">Subtext Editor</a>
</li>
<li>
<img src="http://climbi.com/static/img/logo.png"
style="width: 86px; left: 7px; top: -11px;">
<a href="http://climbi.com/">Climbi</a>
</li>
<li>
<div style="
background: url(http://gpupowered.org/sites/default/files/favicon.png) rgba(0, 0, 0, 0.66) no-repeat;
position: absolute;
height: 75px;
width: 99px; background-size: 27px 32px;
background-position: 37px;"></div>
<a href="http://www.gpupowered.org/sand2/launch2/#">GPUPowered</a>
</li>
<li style="width: 248px;">
<img src="http://www.codeavengers.com/image/RedLogoSmall.png" style="width: 248px; top: 30px;">
<a href="http://www.codeavengers.com/image/RedLogoSmall.png">Code Avengers</a>
</li>
<li style="width: 248px;">
<img src="http://www.codemonkey.co.il/images/logoSmallFaceTop.png" style="width: 248px; top: -3px;">
<a href="http://www.codemonkey.co.il/">CodeMonkey</a>
</li>
<li style="width: 248px;">
<img src="http://learn-angular.org/Content/Images/LearnAngular-small.png" style="width: 275px; left: -12px; top: 7px;">
<a href="http://learn-angular.org">Learn Angular</a>
</li> </li>
<li> <li>
<a href="http://www.wavemaker.com/">WaveMaker</a> <a href="http://www.wavemaker.com/">WaveMaker</a>
@ -1144,35 +1188,15 @@ if (match) {
<li> <li>
<a href="http://www.playmycode.com/">Play My Code</a> <a href="http://www.playmycode.com/">Play My Code</a>
</li> </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> <li>
<a href="http://ext.radiantcms.org/extensions/264-ace">Radiant CMS</a> <a href="http://ext.radiantcms.org/extensions/264-ace">Radiant CMS</a>
</li> </li>
<li> <li>
<a href="http://developercompanion.com/">Developer Companion</a> <a href="http://developercompanion.com/">Developer Companion</a>
</li> </li>
<li>
<a href="http://www.pythonanywhere.com/">PythonAnywhere</a>
</li>
<li>
<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> <li>
<a href="http://www.akshell.com/">Akshell</a> <a href="http://www.akshell.com/">Akshell</a>
</li> </li>
<li>
<a href="http://beanstalkapp.com/">beanstalk</a>
</li>
<li> <li>
<div class="text-logo">tmpltr</div> <div class="text-logo">tmpltr</div>

View file

@ -51,7 +51,7 @@ var Autocomplete = function() {
this.changeTimer = lang.delayedCall(function() { this.changeTimer = lang.delayedCall(function() {
this.updateCompletions(true); this.updateCompletions(true);
}.bind(this)) }.bind(this));
}; };
(function() { (function() {
@ -270,7 +270,7 @@ var Autocomplete = function() {
var _id = this.gatherCompletionsId; var _id = this.gatherCompletionsId;
this.gatherCompletions(this.editor, function(err, results) { this.gatherCompletions(this.editor, function(err, results) {
// Only detach if result gathering is finished // Only detach if result gathering is finished
var doDetach = function() { var detachIfFinished = function() {
if (!results.finished) return; if (!results.finished) return;
return this.detach(); return this.detach();
}.bind(this); }.bind(this);
@ -279,10 +279,10 @@ var Autocomplete = function() {
var matches = results && results.matches; var matches = results && results.matches;
if (!matches || !matches.length) if (!matches || !matches.length)
return doDetach(); return detachIfFinished();
// Wrong prefix or wrong session -> ignore // Wrong prefix or wrong session -> ignore
if (prefix.indexOf(results.prefix) != 0 || _id != this.gatherCompletionsId) if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId)
return; return;
this.completions = new FilteredList(matches); this.completions = new FilteredList(matches);
@ -291,11 +291,11 @@ var Autocomplete = function() {
// No results // No results
if (!filtered.length) if (!filtered.length)
return doDetach(); return detachIfFinished();
// One result equals to the prefix // One result equals to the prefix
if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet) if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet)
return doDetach(); return detachIfFinished();
// Autoinsert if one result // Autoinsert if one result
if (this.autoInsert && filtered.length == 1) if (this.autoInsert && filtered.length == 1)

View file

@ -141,11 +141,15 @@ exports.commands = [{
name: "findnext", name: "findnext",
bindKey: bindKey("Ctrl-K", "Command-G"), bindKey: bindKey("Ctrl-K", "Command-G"),
exec: function(editor) { editor.findNext(); }, exec: function(editor) { editor.findNext(); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true readOnly: true
}, { }, {
name: "findprevious", name: "findprevious",
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
exec: function(editor) { editor.findPrevious(); }, exec: function(editor) { editor.findPrevious(); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true readOnly: true
}, { }, {
name: "selectOrFindNext", name: "selectOrFindNext",

View file

@ -2363,8 +2363,9 @@ var Editor = function(renderer, session) {
var cursorLayer = this.renderer.$cursorLayer; var cursorLayer = this.renderer.$cursorLayer;
if (!cursorLayer) if (!cursorLayer)
return; return;
cursorLayer.setSmoothBlinking(style == "smooth"); cursorLayer.setSmoothBlinking(/smooth/.test(style));
cursorLayer.isBlinking = !this.$readOnly && style != "wide"; cursorLayer.isBlinking = !this.$readOnly && style != "wide";
dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
}; };
}).call(Editor.prototype); }).call(Editor.prototype);

View file

@ -86,9 +86,8 @@ exports.$detectIndentation = function(lines, fallback) {
} else } else
var score = getScore(i) / spaceIndents; var score = getScore(i) / spaceIndents;
if (changes[i]) { if (changes[i])
score += changes[i] / changesTotal; score += changes[i] / changesTotal;
}
if (score > first.score) if (score > first.score)
first = {score: score, length: i}; first = {score: score, length: i};

View file

@ -143,15 +143,6 @@ var Keys = (function() {
} }
})(); })();
(function() {
var mods = ["cmd", "ctrl", "alt", "shift"];
for (var i = Math.pow(2, mods.length); i--;) {
ret.KEY_MODS[i] = mods.filter(function(x) {
return i & ret.KEY_MODS[x];
}).join("-") + "-";
}
})();
return ret; return ret;
})(); })();
oop.mixin(exports, Keys); oop.mixin(exports, Keys);

View file

@ -464,36 +464,41 @@ var Editor = require("./editor").Editor;
/** /**
* Executes a command for each selection range. * Executes a command for each selection range.
* @param {String} cmd The command to execute * @param {Object} cmd The command to execute
* @param {String} args Any arguments for the command * @param {String} args Any arguments for the command
* @method Editor.forEachSelection * @method Editor.forEachSelection
**/ **/
this.forEachSelection = function(cmd, args, $byLines) { this.forEachSelection = function(cmd, args, options) {
if (this.inVirtualSelectionMode) if (this.inVirtualSelectionMode)
return; return;
var keepOrder = options && options.keepOrder;
var $byLines = options == true || options && options.$byLines
var session = this.session; var session = this.session;
var selection = this.selection; var selection = this.selection;
var rangeList = selection.rangeList; var rangeList = selection.rangeList;
var ranges = (keepOrder ? selection : rangeList).ranges;
var result; var result;
if (!ranges.length)
return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
var reg = selection._eventRegistry; var reg = selection._eventRegistry;
selection._eventRegistry = {}; selection._eventRegistry = {};
var tmpSel = new Selection(session); var tmpSel = new Selection(session);
this.inVirtualSelectionMode = true; this.inVirtualSelectionMode = true;
for (var i = rangeList.ranges.length; i--;) { for (var i = ranges.length; i--;) {
if ($byLines) { if ($byLines) {
while (i > 0 && rangeList.ranges[i].start.row == rangeList.ranges[i - 1].end.row) while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
i--; i--;
} }
tmpSel.fromOrientedRange(rangeList.ranges[i]); tmpSel.fromOrientedRange(ranges[i]);
tmpSel.id = rangeList.ranges[i].marker; tmpSel.index = i;
this.selection = session.selection = tmpSel; this.selection = session.selection = tmpSel;
var cmdResult = cmd.exec(this, args || {}); var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
if (result !== undefined) if (!result && cmdResult !== undefined)
result = cmdResult; result = cmdResult;
tmpSel.toOrientedRange(rangeList.ranges[i]); tmpSel.toOrientedRange(ranges[i]);
} }
tmpSel.detach(); tmpSel.detach();
@ -599,6 +604,10 @@ var Editor = require("./editor").Editor;
for (var i = ranges.length; i--; ) for (var i = ranges.length; i--; )
selection.addRange(ranges[i], true); selection.addRange(ranges[i], true);
// keep old selection as primary if possible
if (range && selection.rangeList.rangeAtPoint(range.start))
selection.addRange(range, true);
this.$blockScrolling -= 1; this.$blockScrolling -= 1;
return ranges.length; return ranges.length;

View file

@ -30,8 +30,11 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
var lang = require("./lib/lang") var oop = require("./lib/oop");
var Range = require("./range").Range var EventEmitter = require("./lib/event_emitter").EventEmitter;
var lang = require("./lib/lang");
var Range = require("./range").Range;
var Anchor = require("./anchor").Anchor;
var HashHandler = require("./keyboard/hash_handler").HashHandler; var HashHandler = require("./keyboard/hash_handler").HashHandler;
var Tokenizer = require("./tokenizer").Tokenizer; var Tokenizer = require("./tokenizer").Tokenizer;
var comparePoints = Range.comparePoints; var comparePoints = Range.comparePoints;
@ -42,12 +45,14 @@ var SnippetManager = function() {
}; };
(function() { (function() {
oop.implement(this, EventEmitter);
this.getTokenizer = function() { this.getTokenizer = function() {
function TabstopToken(str, _, stack) { function TabstopToken(str, _, stack) {
str = str.substr(1); str = str.substr(1);
if (/^\d+$/.test(str) && !stack.inFormatString) if (/^\d+$/.test(str) && !stack.inFormatString)
return [{tabstopId: parseInt(str, 10)}]; return [{tabstopId: parseInt(str, 10)}];
return [{text: str}] return [{text: str}];
} }
function escape(ch) { function escape(ch) {
return "(?:[^\\\\" + ch + "]|\\\\.)"; return "(?:[^\\\\" + ch + "]|\\\\.)";
@ -125,7 +130,7 @@ var SnippetManager = function() {
}); });
SnippetManager.prototype.getTokenizer = function() { SnippetManager.prototype.getTokenizer = function() {
return SnippetManager.$tokenizer; return SnippetManager.$tokenizer;
} };
return SnippetManager.$tokenizer; return SnippetManager.$tokenizer;
}; };
@ -151,6 +156,7 @@ var SnippetManager = function() {
switch(name) { switch(name) {
case "CURRENT_WORD": case "CURRENT_WORD":
var r = s.getWordRange(); var r = s.getWordRange();
/* falls through */
case "SELECTION": case "SELECTION":
case "SELECTED_TEXT": case "SELECTED_TEXT":
return s.getTextRange(r); return s.getTextRange(r);
@ -166,7 +172,7 @@ var SnippetManager = function() {
return s.getUseSoftTabs() ? "YES" : "NO"; return s.getUseSoftTabs() ? "YES" : "NO";
case "TAB_SIZE": case "TAB_SIZE":
return s.getTabSize(); return s.getTabSize();
// defult but can't fill :( // default but can't fill :(
case "FILENAME": case "FILENAME":
case "FILEPATH": case "FILEPATH":
return ""; return "";
@ -262,7 +268,7 @@ var SnippetManager = function() {
return result; return result;
}; };
this.insertSnippet = function(editor, snippetText) { this.insertSnippetForSelection = function(editor, snippetText) {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = editor.session.getLine(cursor.row); var line = editor.session.getLine(cursor.row);
var tabString = editor.session.getTabString(); var tabString = editor.session.getTabString();
@ -313,7 +319,7 @@ var SnippetManager = function() {
tabstops.forEach(function(ts) {ts.length = 0}); tabstops.forEach(function(ts) {ts.length = 0});
var expanding = {}; var expanding = {};
function copyValue(val) { function copyValue(val) {
var copy = [] var copy = [];
for (var i = 0; i < val.length; i++) { for (var i = 0; i < val.length; i++) {
var p = val[i]; var p = val[i];
if (typeof p == "object") { if (typeof p == "object") {
@ -349,7 +355,7 @@ var SnippetManager = function() {
if (ts.indexOf(p) === -1) if (ts.indexOf(p) === -1)
ts.push(p); ts.push(p);
}; }
// convert to plain text // convert to plain text
var row = 0, column = 0; var row = 0, column = 0;
@ -373,8 +379,21 @@ var SnippetManager = function() {
var end = editor.session.replace(range, text); var end = editor.session.replace(range, text);
var tabstopManager = new TabstopManager(editor); var tabstopManager = new TabstopManager(editor);
tabstopManager.addTabstops(tabstops, range.start, end); var selectionId = editor.inVirtualSelectionMode && editor.selection.index;
tabstopManager.tabNext(); tabstopManager.addTabstops(tabstops, range.start, end, selectionId);
};
this.insertSnippet = function(editor, snippetText) {
var self = this;
if (editor.inVirtualSelectionMode)
return self.insertSnippetForSelection(editor, snippetText);
editor.forEachSelection(function() {
self.insertSnippetForSelection(editor, snippetText);
}, null, {keepOrder: true});
if (editor.tabstopManager)
editor.tabstopManager.tabNext();
}; };
this.$getScope = function(editor) { this.$getScope = function(editor) {
@ -384,7 +403,7 @@ var SnippetManager = function() {
// PHP is actually HTML // PHP is actually HTML
if (scope === "php" && !editor.session.$mode.inlinePhp) if (scope === "php" && !editor.session.$mode.inlinePhp)
scope = "html"; scope = "html";
var c = editor.getCursorPosition() var c = editor.getCursorPosition();
var state = editor.session.getState(c.row); var state = editor.session.getState(c.row);
if (typeof state === "object") { if (typeof state === "object") {
state = state[0]; state = state[0];
@ -413,7 +432,17 @@ var SnippetManager = function() {
return scopes; return scopes;
}; };
this.expandWithTab = function(editor) { this.expandWithTab = function(editor, options) {
var self = this;
var result = editor.forEachSelection(function() {
return self.expandSnippetForSelection(editor, options);
}, null, {keepOrder: true});
if (result && editor.tabstopManager)
editor.tabstopManager.tabNext();
return result;
};
this.expandSnippetForSelection = function(editor, options) {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = editor.session.getLine(cursor.row); var line = editor.session.getLine(cursor.row);
var before = line.substring(0, cursor.column); var before = line.substring(0, cursor.column);
@ -429,7 +458,8 @@ var SnippetManager = function() {
}, this); }, this);
if (!snippet) if (!snippet)
return false; return false;
if (options && options.dryRun)
return true;
editor.session.doc.removeInLine(cursor.row, editor.session.doc.removeInLine(cursor.row,
cursor.column - snippet.replaceBefore.length, cursor.column - snippet.replaceBefore.length,
cursor.column + snippet.replaceAfter.length cursor.column + snippet.replaceAfter.length
@ -437,7 +467,7 @@ var SnippetManager = function() {
this.variables.M__ = snippet.matchBefore; this.variables.M__ = snippet.matchBefore;
this.variables.T__ = snippet.matchAfter; this.variables.T__ = snippet.matchAfter;
this.insertSnippet(editor, snippet.content); this.insertSnippetForSelection(editor, snippet.content);
this.variables.M__ = this.variables.T__ = null; this.variables.M__ = this.variables.T__ = null;
return true; return true;
@ -469,7 +499,7 @@ var SnippetManager = function() {
var self = this; var self = this;
function wrapRegexp(src) { function wrapRegexp(src) {
if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src)) if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
src = "(?:" + src + ")" src = "(?:" + src + ")";
return src || ""; return src || "";
} }
@ -491,7 +521,7 @@ var SnippetManager = function() {
function addSnippet(s) { function addSnippet(s) {
if (!s.scope) if (!s.scope)
s.scope = scope || "_"; s.scope = scope || "_";
scope = s.scope scope = s.scope;
if (!snippetMap[scope]) { if (!snippetMap[scope]) {
snippetMap[scope] = []; snippetMap[scope] = [];
snippetNameMap[scope] = {}; snippetNameMap[scope] = {};
@ -517,12 +547,14 @@ var SnippetManager = function() {
s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true); s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
s.endTriggerRe = new RegExp(s.endTrigger, "", true); s.endTriggerRe = new RegExp(s.endTrigger, "", true);
}; }
if (snippets.content) if (snippets.content)
addSnippet(snippets); addSnippet(snippets);
else if (Array.isArray(snippets)) else if (Array.isArray(snippets))
snippets.forEach(addSnippet); snippets.forEach(addSnippet);
this._signal("registerSnippets", {scope: scope});
}; };
this.unregister = function(snippets, scope) { this.unregister = function(snippets, scope) {
var snippetMap = this.snippetMap; var snippetMap = this.snippetMap;
@ -551,7 +583,7 @@ var SnippetManager = function() {
while (m = re.exec(str)) { while (m = re.exec(str)) {
if (m[1]) { if (m[1]) {
try { try {
snippet = JSON.parse(m[1]) snippet = JSON.parse(m[1]);
list.push(snippet); list.push(snippet);
} catch (e) {} } catch (e) {}
} if (m[4]) { } if (m[4]) {
@ -604,9 +636,10 @@ var TabstopManager = function(editor) {
}; };
(function() { (function() {
this.attach = function(editor) { this.attach = function(editor) {
this.index = -1; this.index = 0;
this.ranges = []; this.ranges = [];
this.tabstops = []; this.tabstops = [];
this.$openTabstops = null;
this.selectedTabstop = null; this.selectedTabstop = null;
this.editor = editor; this.editor = editor;
@ -646,7 +679,7 @@ var TabstopManager = function(editor) {
} }
if (!this.$inChange && isRemove) { if (!this.$inChange && isRemove) {
var ts = this.selectedTabstop; var ts = this.selectedTabstop;
var changedOutside = !ts.some(function(r) { var changedOutside = ts && !ts.some(function(r) {
return comparePoints(r.start, start) <= 0 && comparePoints(r.end, end) >= 0; return comparePoints(r.start, start) <= 0 && comparePoints(r.end, end) >= 0;
}); });
if (changedOutside) if (changedOutside)
@ -658,7 +691,7 @@ var TabstopManager = function(editor) {
if (r.end.row < start.row) if (r.end.row < start.row)
continue; continue;
if (comparePoints(start, r.start) < 0 && comparePoints(end, r.end) > 0) { if (isRemove && comparePoints(start, r.start) < 0 && comparePoints(end, r.end) > 0) {
this.removeRange(r); this.removeRange(r);
i--; i--;
continue; continue;
@ -681,7 +714,7 @@ var TabstopManager = function(editor) {
}; };
this.updateLinkedFields = function() { this.updateLinkedFields = function() {
var ts = this.selectedTabstop; var ts = this.selectedTabstop;
if (!ts.hasLinkedRanges) if (!ts || !ts.hasLinkedRanges)
return; return;
this.$inChange = true; this.$inChange = true;
var session = this.editor.session; var session = this.editor.session;
@ -690,7 +723,7 @@ var TabstopManager = function(editor) {
var range = ts[i]; var range = ts[i];
if (!range.linked) if (!range.linked)
continue; continue;
var fmt = exports.snippetManager.tmStrFormat(text, range.original) var fmt = exports.snippetManager.tmStrFormat(text, range.original);
session.replace(range, fmt); session.replace(range, fmt);
} }
this.$inChange = false; this.$inChange = false;
@ -701,7 +734,7 @@ var TabstopManager = function(editor) {
}; };
this.onChangeSelection = function() { this.onChangeSelection = function() {
if (!this.editor) if (!this.editor)
return return;
var lead = this.editor.selection.lead; var lead = this.editor.selection.lead;
var anchor = this.editor.selection.anchor; var anchor = this.editor.selection.anchor;
var isEmpty = this.editor.selection.isEmpty(); var isEmpty = this.editor.selection.isEmpty();
@ -719,14 +752,17 @@ var TabstopManager = function(editor) {
this.detach(); this.detach();
}; };
this.tabNext = function(dir) { this.tabNext = function(dir) {
var max = this.tabstops.length - 1; var max = this.tabstops.length;
var index = this.index + (dir || 1); var index = this.index + (dir || 1);
index = Math.min(Math.max(index, 0), max); index = Math.min(Math.max(index, 1), max);
this.selectTabstop(index);
if (index == max) if (index == max)
index = 0;
this.selectTabstop(index);
if (index === 0)
this.detach(); this.detach();
}; };
this.selectTabstop = function(index) { this.selectTabstop = function(index) {
this.$openTabstops = null;
var ts = this.tabstops[this.index]; var ts = this.tabstops[this.index];
if (ts) if (ts)
this.addTabstopMarkers(ts); this.addTabstopMarkers(ts);
@ -744,6 +780,9 @@ var TabstopManager = function(editor) {
continue; continue;
sel.addRange(ts[i].clone(), true); sel.addRange(ts[i].clone(), true);
} }
// todo investigate why is this needed
if (sel.ranges[0])
sel.addRange(sel.ranges[0].clone());
} else { } else {
this.editor.selection.setRange(ts.firstNonLinked); this.editor.selection.setRange(ts.firstNonLinked);
} }
@ -751,6 +790,8 @@ var TabstopManager = function(editor) {
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
}; };
this.addTabstops = function(tabstops, start, end) { this.addTabstops = function(tabstops, start, end) {
if (!this.$openTabstops)
this.$openTabstops = [];
// add final tabstop if missing // add final tabstop if missing
if (!tabstops[0]) { if (!tabstops[0]) {
var p = Range.fromPoints(end, end); var p = Range.fromPoints(end, end);
@ -761,33 +802,44 @@ var TabstopManager = function(editor) {
} }
var i = this.index; var i = this.index;
var arg = [i, 0]; var arg = [i + 1, 0];
var ranges = this.ranges; var ranges = this.ranges;
var editor = this.editor; tabstops.forEach(function(ts, index) {
tabstops.forEach(function(ts) { var dest = this.$openTabstops[index] || ts;
for (var i = ts.length; i--;) { for (var i = ts.length; i--;) {
var p = ts[i]; var p = ts[i];
var range = Range.fromPoints(p.start, p.end || p.start); var range = Range.fromPoints(p.start, p.end || p.start);
movePoint(range.start, start); movePoint(range.start, start);
movePoint(range.end, start); movePoint(range.end, start);
range.original = p; range.original = p;
range.tabstop = ts; range.tabstop = dest;
ranges.push(range); ranges.push(range);
ts[i] = range; if (dest != ts)
dest.unshift(range);
else
dest[i] = range;
if (p.fmtString) { if (p.fmtString) {
range.linked = true; range.linked = true;
ts.hasLinkedRanges = true; dest.hasLinkedRanges = true;
} else if (!ts.firstNonLinked) } else if (!dest.firstNonLinked)
ts.firstNonLinked = range; dest.firstNonLinked = range;
} }
if (!ts.firstNonLinked) if (!dest.firstNonLinked)
ts.hasLinkedRanges = false; dest.hasLinkedRanges = false;
arg.push(ts); if (dest === ts) {
this.addTabstopMarkers(ts); arg.push(dest);
this.$openTabstops[index] = dest;
}
this.addTabstopMarkers(dest);
}, this); }, this);
// tabstop 0 is the last one
arg.push(arg.splice(2, 1)[0]); if (arg.length > 2) {
this.tabstops.splice.apply(this.tabstops, arg); // when adding new snippet inside existing one, make sure 0 tabstop is at the end
if (this.tabstops.length)
arg.push(arg.splice(2, 1)[0]);
this.tabstops.splice.apply(this.tabstops, arg);
}
}; };
this.addTabstopMarkers = function(ts) { this.addTabstopMarkers = function(ts) {
@ -810,6 +862,13 @@ var TabstopManager = function(editor) {
i = this.ranges.indexOf(range); i = this.ranges.indexOf(range);
this.ranges.splice(i, 1); this.ranges.splice(i, 1);
this.editor.session.removeMarker(range.markerId); this.editor.session.removeMarker(range.markerId);
if (!range.tabstop.length) {
i = this.tabstops.indexOf(range.tabstop);
if (i != -1)
this.tabstops.splice(i, 1);
if (!this.tabstops.length)
this.detach();
}
}; };
this.keyboardHandler = new HashHandler(); this.keyboardHandler = new HashHandler();
@ -835,6 +894,19 @@ var TabstopManager = function(editor) {
}).call(TabstopManager.prototype); }).call(TabstopManager.prototype);
var changeTracker = {};
changeTracker.onChange = Anchor.prototype.onChange;
changeTracker.setPosition = function(row, column) {
this.pos.row = row;
this.pos.column = column;
};
changeTracker.update = function(pos, delta, $insertRight) {
this.$insertRight = $insertRight;
this.pos = pos;
this.onChange(delta);
};
var movePoint = function(point, diff) { var movePoint = function(point, diff) {
if (point.row == 0) if (point.row == 0)
point.column += diff.column; point.column += diff.column;
@ -860,4 +932,14 @@ require("./lib/dom").importCssString("\
exports.snippetManager = new SnippetManager(); exports.snippetManager = new SnippetManager();
var Editor = require("./editor").Editor;
(function() {
this.insertSnippet = function(content, options) {
return exports.snippetManager.insertSnippet(this, content, options);
};
this.expandSnippet = function(options) {
return exports.snippetManager.expandWithTab(this, options);
};
}).call(Editor.prototype);
}); });

View file

@ -337,8 +337,6 @@ var VirtualRenderer = function(container, theme) {
* *
**/ **/
this.onResize = function(force, gutterWidth, width, height) { this.onResize = function(force, gutterWidth, width, height) {
// if (force)
// console.log("force resize requested", width, height)
if (this.resizing > 2) if (this.resizing > 2)
return; return;
else if (this.resizing > 0) else if (this.resizing > 0)
@ -354,12 +352,6 @@ var VirtualRenderer = function(container, theme) {
width = el.clientWidth || el.scrollWidth; width = el.clientWidth || el.scrollWidth;
var changes = this.$updateCachedSize(force, gutterWidth, width, height); var changes = this.$updateCachedSize(force, gutterWidth, width, height);
// console.log("resizing to", width, height, JSON.stringify(this.$size))
// setTimeout(function() {
// console.log("actual size ", this.container.clientWidth, this.container.clientHeight)
// }.bind(this), 500)
if (!this.$size.scrollerHeight || (!width && !height)) if (!this.$size.scrollerHeight || (!width && !height))
return this.resizing = 0; return this.resizing = 0;
@ -757,7 +749,16 @@ var VirtualRenderer = function(container, theme) {
}; };
this.$updateScrollBarV = function() { this.$updateScrollBarV = function() {
this.scrollBarV.setScrollHeight(this.layerConfig.maxHeight + this.scrollMargin.v); var scrollHeight = this.layerConfig.maxHeight;
var scrollerHeight = this.$size.scrollerHeight;
if (!this.$maxLines && this.$scrollPastEnd) {
scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
if (this.scrollTop > scrollHeight - scrollerHeight) {
scrollHeight = this.scrollTop + scrollerHeight;
this.scrollBarV.scrollTop = null;
}
}
this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top); this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
}; };
this.$updateScrollBarH = function() { this.$updateScrollBarH = function() {
@ -934,11 +935,7 @@ var VirtualRenderer = function(container, theme) {
} }
if (!this.$maxLines && this.$scrollPastEnd) { if (!this.$maxLines && this.$scrollPastEnd) {
if (this.scrollTop > maxHeight - size.scrollerHeight) maxHeight += (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
maxHeight += Math.min(
(size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd,
this.scrollTop - maxHeight + size.scrollerHeight
);
} }
var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible || var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
@ -1373,8 +1370,7 @@ var VirtualRenderer = function(container, theme) {
if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top) if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
return true; return true;
if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
- this.layerConfig.maxHeight - (this.$size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
< -1 + this.scrollMargin.bottom)
return true; return true;
if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left) if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
return true; return true;

View file

@ -111,14 +111,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
}; };
this.$normalizePath = function(path) { this.$normalizePath = function(path) {
if (!location.host) // needed for file:// protocol return net.qualifyURL(path);
return path;
path = path.replace(/^[a-z]+:\/\/[^\/]+/, ""); // Remove domain name and rebuild it
path = location.protocol + "//" + location.host
// paths starting with a slash are relative to the root (host)
+ (path.charAt(0) == "/" ? "" : location.pathname.replace(/\/[^\/]*$/, ""))
+ "/" + path.replace(/^[\/]+/, "");
return path;
}; };
this.terminate = function() { this.terminate = function() {
@ -149,7 +142,9 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
// TODO: cleanup event // TODO: cleanup event
this.$worker.postMessage({event: event, data: {data: data.data}}); this.$worker.postMessage({event: event, data: {data: data.data}});
} }
catch(ex) {} catch(ex) {
console.error(ex.stack);
}
}; };
this.attachToDocument = function(doc) { this.attachToDocument = function(doc) {
@ -182,7 +177,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
this.$workerBlob = function(workerUrl) { this.$workerBlob = function(workerUrl) {
// workerUrl can be protocol relative // workerUrl can be protocol relative
// importScripts only takes fully qualified urls // importScripts only takes fully qualified urls
var script = "importScripts('" + net.qualifyURL( workerUrl ) + "');"; var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
try { try {
return new Blob([script], {"type": "application/javascript"}); return new Blob([script], {"type": "application/javascript"});
} catch (e) { // Backwards-compatibility } catch (e) { // Backwards-compatibility