|pollSizeChanges| is called only on resize, not every 500ms

This commit is contained in:
Sergi Mansilla 2011-02-27 12:44:43 +01:00
commit ff7c1b5182

View file

@ -63,7 +63,7 @@ var Editor =function(renderer, session) {
this.textInput = new TextInput(renderer.getTextAreaContainer(), this); this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
this.keyBinding = new KeyBinding(this); this.keyBinding = new KeyBinding(this);
// TODO detect touch event support // TODO detect touch event support
if (useragent.isIPad) { if (useragent.isIPad) {
//this.$mouseHandler = new TouchHandler(this); //this.$mouseHandler = new TouchHandler(this);
@ -158,16 +158,16 @@ var Editor =function(renderer, session) {
this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this); this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker); this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
this.$onChangeBackMarker = this.onChangeBackMarker.bind(this); this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker); this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this); this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint); this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
this.$onChangeAnnotation = this.onChangeAnnotation.bind(this); this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation); this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
this.$onCursorChange = this.onCursorChange.bind(this); this.$onCursorChange = this.onCursorChange.bind(this);
this.session.addEventListener("changeOverwrite", this.$onCursorChange); this.session.addEventListener("changeOverwrite", this.$onCursorChange);
@ -206,6 +206,7 @@ var Editor =function(renderer, session) {
this.resize = function() { this.resize = function() {
this.renderer.onResize(); this.renderer.onResize();
this.renderer.$textLayer.$pollSizeChanges();
}; };
this.setTheme = function(theme) { this.setTheme = function(theme) {
@ -308,7 +309,7 @@ var Editor =function(renderer, session) {
this.$updateHighlightActiveLine = function() { this.$updateHighlightActiveLine = function() {
var session = this.getSession(); var session = this.getSession();
if (session.$highlightLineMarker) { if (session.$highlightLineMarker) {
session.removeMarker(session.$highlightLineMarker); session.removeMarker(session.$highlightLineMarker);
} }
@ -323,7 +324,7 @@ var Editor =function(renderer, session) {
this.onSelectionChange = function(e) { this.onSelectionChange = function(e) {
var session = this.getSession(); var session = this.getSession();
if (session.$selectionMarker) { if (session.$selectionMarker) {
session.removeMarker(session.$selectionMarker); session.removeMarker(session.$selectionMarker);
} }
@ -344,11 +345,11 @@ var Editor =function(renderer, session) {
this.onChangeFrontMarker = function() { this.onChangeFrontMarker = function() {
this.renderer.updateFrontMarkers(); this.renderer.updateFrontMarkers();
}; };
this.onChangeBackMarker = function() { this.onChangeBackMarker = function() {
this.renderer.updateBackMarkers(); this.renderer.updateBackMarkers();
}; };
this.onChangeBreakpoint = function() { this.onChangeBreakpoint = function() {
this.renderer.setBreakpoints(this.session.getBreakpoints()); this.renderer.setBreakpoints(this.session.getBreakpoints());
}; };
@ -429,18 +430,18 @@ var Editor =function(renderer, session) {
var lineIndent = this.mode.getNextLineIndent(lineState, line.slice(0, cursor.column), this.session.getTabString()); var lineIndent = this.mode.getNextLineIndent(lineState, line.slice(0, cursor.column), this.session.getTabString());
var end = this.session.insert(cursor, text); var end = this.session.insert(cursor, text);
var lineState = this.bgTokenizer.getState(cursor.row); var lineState = this.bgTokenizer.getState(cursor.row);
// TODO disabled multiline auto indent // TODO disabled multiline auto indent
// possibly doing the indent before inserting the text // possibly doing the indent before inserting the text
// if (cursor.row !== end.row) { // if (cursor.row !== end.row) {
if (this.session.getDocument().isNewLine(text)) { if (this.session.getDocument().isNewLine(text)) {
this.moveCursorTo(cursor.row+1, 0); this.moveCursorTo(cursor.row+1, 0);
var size = this.session.getTabSize(), var size = this.session.getTabSize(),
minIndent = Number.MAX_VALUE; minIndent = Number.MAX_VALUE;
for (var row = cursor.row + 1; row <= end.row; ++row) { for (var row = cursor.row + 1; row <= end.row; ++row) {
var indent = 0; var indent = 0;
@ -472,7 +473,7 @@ var Editor =function(renderer, session) {
if (shouldOutdent) { if (shouldOutdent) {
this.mode.autoOutdent(lineState, this.session, cursor.row); this.mode.autoOutdent(lineState, this.session, cursor.row);
} }
}; };
} }
this.onTextInput = function(text) { this.onTextInput = function(text) {
@ -484,7 +485,7 @@ var Editor =function(renderer, session) {
}; };
this.setOverwrite = function(overwrite) { this.setOverwrite = function(overwrite) {
this.session.setOverwrite(); this.session.setOverwrite();
}; };
this.getOverwrite = function() { this.getOverwrite = function() {
@ -601,7 +602,7 @@ var Editor =function(renderer, session) {
this.session.remove(this.getSelectionRange()); this.session.remove(this.getSelectionRange());
this.clearSelection(); this.clearSelection();
}; };
this.removeWordRight = function() { this.removeWordRight = function() {
if (this.$readOnly) if (this.$readOnly)
return; return;
@ -612,7 +613,7 @@ var Editor =function(renderer, session) {
this.session.remove(this.getSelectionRange()); this.session.remove(this.getSelectionRange());
this.clearSelection(); this.clearSelection();
}; };
this.removeWordLeft = function() { this.removeWordLeft = function() {
if (this.$readOnly) if (this.$readOnly)
return; return;
@ -623,7 +624,7 @@ var Editor =function(renderer, session) {
this.session.remove(this.getSelectionRange()); this.session.remove(this.getSelectionRange());
this.clearSelection(); this.clearSelection();
}; };
this.removeToLineStart = function() { this.removeToLineStart = function() {
if (this.$readOnly) if (this.$readOnly)
return; return;
@ -634,7 +635,7 @@ var Editor =function(renderer, session) {
this.session.remove(this.getSelectionRange()); this.session.remove(this.getSelectionRange());
this.clearSelection(); this.clearSelection();
}; };
this.removeToLineEnd = function() { this.removeToLineEnd = function() {
if (this.$readOnly) if (this.$readOnly)
return; return;
@ -649,30 +650,30 @@ var Editor =function(renderer, session) {
this.splitLine = function() { this.splitLine = function() {
if (this.$readOnly) if (this.$readOnly)
return; return;
if (!this.selection.isEmpty()) { if (!this.selection.isEmpty()) {
this.session.remove(this.getSelectionRange()); this.session.remove(this.getSelectionRange());
this.clearSelection(); this.clearSelection();
} }
var cursor = this.getCursorPosition(); var cursor = this.getCursorPosition();
this.insert("\n"); this.insert("\n");
this.moveCursorToPosition(cursor); this.moveCursorToPosition(cursor);
}; };
this.transposeLetters = function() { this.transposeLetters = function() {
if (this.$readOnly) if (this.$readOnly)
return; return;
if (!this.selection.isEmpty()) { if (!this.selection.isEmpty()) {
return; return;
} }
var cursor = this.getCursorPosition(); var cursor = this.getCursorPosition();
var column = cursor.column; var column = cursor.column;
if (column == 0) if (column == 0)
return; return;
var line = this.session.getLine(cursor.row); var line = this.session.getLine(cursor.row);
if (column < line.length) { if (column < line.length) {
var swap = line.charAt(column) + line.charAt(column-1); var swap = line.charAt(column) + line.charAt(column-1);
@ -684,7 +685,7 @@ var Editor =function(renderer, session) {
} }
this.session.replace(range, swap); this.session.replace(range, swap);
}; };
this.indent = function() { this.indent = function() {
if (this.$readOnly) if (this.$readOnly)
return; return;
@ -897,7 +898,7 @@ var Editor =function(renderer, session) {
this.scrollToLine = function(line, center) { this.scrollToLine = function(line, center) {
this.renderer.scrollToLine(line, center); this.renderer.scrollToLine(line, center);
}; };
this.centerSelection = function() { this.centerSelection = function() {
var range = this.getSelectionRange(); var range = this.getSelectionRange();
var line = Math.floor(range.start.row + (range.end.row - range.start.row) / 2); var line = Math.floor(range.start.row + (range.end.row - range.start.row) / 2);
@ -922,7 +923,7 @@ var Editor =function(renderer, session) {
this.selection.selectAll(); this.selection.selectAll();
this.$blockScrolling -= 1; this.$blockScrolling -= 1;
}; };
this.clearSelection = function() { this.clearSelection = function() {
this.selection.clearSelection(); this.selection.clearSelection();
}; };
@ -1049,7 +1050,7 @@ var Editor =function(renderer, session) {
this.$blockScrolling += 1; this.$blockScrolling += 1;
for (var i = ranges.length - 1; i >= 0; --i) for (var i = ranges.length - 1; i >= 0; --i)
this.$tryReplace(ranges[i], replacement); this.$tryReplace(ranges[i], replacement);
this.selection.setSelectionRange(selection); this.selection.setSelectionRange(selection);
this.$blockScrolling -= 1; this.$blockScrolling -= 1;
}, },