Merge branch 'master' of github.com:ajaxorg/ace

This commit is contained in:
Fabian Jakobs 2011-05-18 10:47:34 +02:00
commit 98bd0eeb51
3 changed files with 31 additions and 21 deletions

View file

@ -155,6 +155,8 @@ exports.launch = function(env) {
var container = document.getElementById("editor"); var container = document.getElementById("editor");
var cockpitInput = document.getElementById("cockpitInput"); var cockpitInput = document.getElementById("cockpitInput");
env.editor = new Editor(new Renderer(container, theme)); env.editor = new Editor(new Renderer(container, theme));
window.env = env;
window.ace = env.editor;
var modes = { var modes = {
text: new TextMode(), text: new TextMode(),
@ -337,7 +339,7 @@ exports.launch = function(env) {
} }
function onResize() { function onResize() {
var width = (document.documentElement.clientWidth - 300); var width = (document.documentElement.clientWidth - 280);
container.style.width = width + "px"; container.style.width = width + "px";
cockpitInput.style.width = width + "px"; cockpitInput.style.width = width + "px";
container.style.height = (document.documentElement.clientHeight - 22) + "px"; container.style.height = (document.documentElement.clientHeight - 22) + "px";
@ -531,4 +533,4 @@ exports.launch = function(env) {
} }
}; };
}); });

View file

@ -1,6 +1,6 @@
html { html {
height: 100%; height: 100%;
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
} }
@ -24,7 +24,7 @@ body {
#editor { #editor {
position: absolute; position: absolute;
top: 0px; top: 0px;
left: 300px; left: 280px;
bottom: 0px; bottom: 0px;
right: 0px; right: 0px;
background: white; background: white;
@ -44,7 +44,7 @@ body {
#cockpitInput { #cockpitInput {
position: absolute; position: absolute;
left: 300px; left: 280px;
right: 0px; right: 0px;
bottom: 0; bottom: 0;

View file

@ -463,7 +463,7 @@ var EditSession = function(text, mode) {
this.$stopWorker(); this.$stopWorker();
if (this.$useWorker) if (this.$useWorker)
this.$startWorker(); this.$startWorker();
var tokenizer = mode.getTokenizer(); var tokenizer = mode.getTokenizer();
@ -492,10 +492,10 @@ var EditSession = function(text, mode) {
this.$stopWorker = function() { this.$stopWorker = function() {
if (this.$worker) if (this.$worker)
this.$worker.terminate(); this.$worker.terminate();
this.$worker = null; this.$worker = null;
}; };
this.$startWorker = function() { this.$startWorker = function() {
if (typeof Worker !== "undefined" && !require.noWorker) { if (typeof Worker !== "undefined" && !require.noWorker) {
try { try {
@ -503,7 +503,7 @@ var EditSession = function(text, mode) {
} catch (e) { } catch (e) {
console.log("Could not load worker"); console.log("Could not load worker");
console.log(e); console.log(e);
this.$worker = null; this.$worker = null;
} }
} }
else else
@ -1010,7 +1010,7 @@ var EditSession = function(text, mode) {
removedFolds = this.getFoldsInRange(e.data.range); removedFolds = this.getFoldsInRange(e.data.range);
this.removeFolds(removedFolds); this.removeFolds(removedFolds);
var foldLine = this.getFoldLine(lastRow); var foldLine = this.getFoldLine(end.row);
var idx = 0; var idx = 0;
if (foldLine) { if (foldLine) {
foldLine.addRemoveChars(end.row, end.column, start.column - end.column); foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
@ -1026,7 +1026,7 @@ var EditSession = function(text, mode) {
for (idx; idx < foldLines.length; idx++) { for (idx; idx < foldLines.length; idx++) {
var foldLine = foldLines[idx]; var foldLine = foldLines[idx];
if (foldLine.start.row >= lastRow) { if (foldLine.start.row >= end.row) {
foldLine.shiftRow(-len); foldLine.shiftRow(-len);
} }
} }
@ -1418,7 +1418,7 @@ var EditSession = function(text, mode) {
} }
} }
var docRowCacheLast = docRow; var docRowCacheLast = docRow;
// clamp row before clamping column, for selection on last line // clamp row before clamping column, for selection on last line
var maxRow = this.getLength() - 1; var maxRow = this.getLength() - 1;
var foldLine = this.getNextFold(docRow); var foldLine = this.getNextFold(docRow);
@ -1449,7 +1449,7 @@ var EditSession = function(text, mode) {
if (foldLine && foldLine.start.row <= docRow) if (foldLine && foldLine.start.row <= docRow)
line = this.getFoldDisplayLine(foldLine); line = this.getFoldDisplayLine(foldLine);
else { else {
line = this.getLine(docRow); line = this.getLine(docRow);
foldLine = null; foldLine = null;
} }
@ -1596,21 +1596,29 @@ var EditSession = function(text, mode) {
}; };
this.getScreenLength = function() { this.getScreenLength = function() {
var length = this.getLength();
var screenRows = 0; var screenRows = 0;
var lastFoldLine = null;
var foldLine = null;
if (!this.$useWrapMode) { if (!this.$useWrapMode) {
screenRows = length; screenRows = this.getLength();
// Remove the folded lines again.
var foldData = this.$foldData;
for (var i = 0; i < foldData.length; i++) {
foldLine = foldData[i];
screenRows -= foldLine.end.row - foldLine.start.row;
}
} else { } else {
for (var row = 0; row < this.$wrapData.length; row++) { for (var row = 0; row < this.$wrapData.length; row++) {
screenRows += this.$wrapData[row].length + 1; if (foldLine = this.getFoldLine(row, lastFoldLine)) {
row = foldLine.end.row;
screenRows += 1;
} else {
screenRows += this.$wrapData[row].length + 1;
}
} }
} }
var foldData = this.$foldData;
for (var i = 0; i < foldData.length; i++) {
var foldLine = foldData[i];
screenRows -= foldLine.end.row - foldLine.start.row;
}
return screenRows; return screenRows;
} }