First iteration of code folding - not much working yet.
This commit is contained in:
parent
298408b93a
commit
c010348eae
6 changed files with 198 additions and 55 deletions
|
|
@ -62,7 +62,7 @@ var Editor =function(renderer, session) {
|
|||
|
||||
this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
|
||||
this.keyBinding = new KeyBinding(this);
|
||||
|
||||
|
||||
// TODO detect touch event support
|
||||
if (useragent.isIPad) {
|
||||
//this.$mouseHandler = new TouchHandler(this);
|
||||
|
|
@ -125,6 +125,7 @@ var Editor =function(renderer, session) {
|
|||
this.session.removeEventListener("changeTabSize", this.$onChangeTabSize);
|
||||
this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit);
|
||||
this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode);
|
||||
this.session.removeEventListener("onChangeFold", this.$onChangeFold);
|
||||
this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
|
||||
this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
|
||||
this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
|
||||
|
|
@ -159,18 +160,21 @@ var Editor =function(renderer, session) {
|
|||
this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
|
||||
session.addEventListener("changeWrapMode", this.$onChangeWrapMode);
|
||||
|
||||
this.$onChangeFold = this.onChangeFold.bind(this);
|
||||
session.addEventListener("changeFold", this.$onChangeFold);
|
||||
|
||||
this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
|
||||
this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
|
||||
|
||||
|
||||
this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
|
||||
this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
|
||||
|
||||
|
||||
this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
|
||||
this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
|
||||
|
||||
this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
|
||||
this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
|
||||
|
||||
|
||||
this.$onCursorChange = this.onCursorChange.bind(this);
|
||||
this.session.addEventListener("changeOverwrite", this.$onCursorChange);
|
||||
|
||||
|
|
@ -251,7 +255,7 @@ var Editor =function(renderer, session) {
|
|||
// to be on the save side we do both
|
||||
// except for IE
|
||||
var _self = this;
|
||||
if (!useragent.isIE) {
|
||||
if (!useragent.isIE) {
|
||||
setTimeout(function() {
|
||||
_self.textInput.focus();
|
||||
});
|
||||
|
|
@ -311,7 +315,7 @@ var Editor =function(renderer, session) {
|
|||
|
||||
this.$updateHighlightActiveLine = function() {
|
||||
var session = this.getSession();
|
||||
|
||||
|
||||
if (session.$highlightLineMarker) {
|
||||
session.removeMarker(session.$highlightLineMarker);
|
||||
}
|
||||
|
|
@ -326,7 +330,7 @@ var Editor =function(renderer, session) {
|
|||
|
||||
this.onSelectionChange = function(e) {
|
||||
var session = this.getSession();
|
||||
|
||||
|
||||
if (session.$selectionMarker) {
|
||||
session.removeMarker(session.$selectionMarker);
|
||||
}
|
||||
|
|
@ -347,11 +351,11 @@ var Editor =function(renderer, session) {
|
|||
this.onChangeFrontMarker = function() {
|
||||
this.renderer.updateFrontMarkers();
|
||||
};
|
||||
|
||||
|
||||
this.onChangeBackMarker = function() {
|
||||
this.renderer.updateBackMarkers();
|
||||
};
|
||||
|
||||
|
||||
this.onChangeBreakpoint = function() {
|
||||
this.renderer.setBreakpoints(this.session.getBreakpoints());
|
||||
};
|
||||
|
|
@ -372,6 +376,11 @@ var Editor =function(renderer, session) {
|
|||
this.renderer.onResize(true);
|
||||
};
|
||||
|
||||
this.onChangeFold = function() {
|
||||
// TODO: This might be too much updating. Okay for now.
|
||||
this.render.updateFull();
|
||||
};
|
||||
|
||||
this.getCopyText = function() {
|
||||
if (!this.selection.isEmpty()) {
|
||||
return this.session.getTextRange(this.getSelectionRange());
|
||||
|
|
@ -397,7 +406,7 @@ var Editor =function(renderer, session) {
|
|||
|
||||
var session = this.session;
|
||||
var mode = session.getMode();
|
||||
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
text = text.replace("\t", this.session.getTabString());
|
||||
|
||||
|
|
@ -420,14 +429,14 @@ var Editor =function(renderer, session) {
|
|||
var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
|
||||
var end = session.insert(cursor, text);
|
||||
|
||||
|
||||
var lineState = session.getState(cursor.row);
|
||||
|
||||
// TODO disabled multiline auto indent
|
||||
// possibly doing the indent before inserting the text
|
||||
// if (cursor.row !== end.row) {
|
||||
if (session.getDocument().isNewLine(text)) {
|
||||
this.moveCursorTo(cursor.row+1, 0);
|
||||
|
||||
|
||||
var size = session.getTabSize();
|
||||
var minIndent = Number.MAX_VALUE;
|
||||
|
||||
|
|
@ -462,7 +471,7 @@ var Editor =function(renderer, session) {
|
|||
if (shouldOutdent) {
|
||||
mode.autoOutdent(lineState, session, cursor.row);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
this.onTextInput = function(text) {
|
||||
|
|
@ -591,7 +600,7 @@ var Editor =function(renderer, session) {
|
|||
this.session.remove(this.getSelectionRange());
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
|
||||
this.removeWordRight = function() {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
|
@ -602,7 +611,7 @@ var Editor =function(renderer, session) {
|
|||
this.session.remove(this.getSelectionRange());
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
|
||||
this.removeWordLeft = function() {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
|
@ -613,7 +622,7 @@ var Editor =function(renderer, session) {
|
|||
this.session.remove(this.getSelectionRange());
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
|
||||
this.removeToLineStart = function() {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
|
@ -624,7 +633,7 @@ var Editor =function(renderer, session) {
|
|||
this.session.remove(this.getSelectionRange());
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
|
||||
this.removeToLineEnd = function() {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
|
@ -639,30 +648,30 @@ var Editor =function(renderer, session) {
|
|||
this.splitLine = function() {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
|
||||
if (!this.selection.isEmpty()) {
|
||||
this.session.remove(this.getSelectionRange());
|
||||
this.clearSelection();
|
||||
}
|
||||
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
this.insert("\n");
|
||||
this.moveCursorToPosition(cursor);
|
||||
};
|
||||
|
||||
|
||||
this.transposeLetters = function() {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
|
||||
if (!this.selection.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
var column = cursor.column;
|
||||
if (column == 0)
|
||||
return;
|
||||
|
||||
|
||||
var line = this.session.getLine(cursor.row);
|
||||
if (column < line.length) {
|
||||
var swap = line.charAt(column) + line.charAt(column-1);
|
||||
|
|
@ -674,7 +683,7 @@ var Editor =function(renderer, session) {
|
|||
}
|
||||
this.session.replace(range, swap);
|
||||
};
|
||||
|
||||
|
||||
this.indent = function() {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
|
@ -887,7 +896,7 @@ var Editor =function(renderer, session) {
|
|||
this.scrollToLine = function(line, center) {
|
||||
this.renderer.scrollToLine(line, center);
|
||||
};
|
||||
|
||||
|
||||
this.centerSelection = function() {
|
||||
var range = this.getSelectionRange();
|
||||
var line = Math.floor(range.start.row + (range.end.row - range.start.row) / 2);
|
||||
|
|
@ -912,7 +921,7 @@ var Editor =function(renderer, session) {
|
|||
this.selection.selectAll();
|
||||
this.$blockScrolling -= 1;
|
||||
};
|
||||
|
||||
|
||||
this.clearSelection = function() {
|
||||
this.selection.clearSelection();
|
||||
};
|
||||
|
|
@ -1039,7 +1048,7 @@ var Editor =function(renderer, session) {
|
|||
this.$blockScrolling += 1;
|
||||
for (var i = ranges.length - 1; i >= 0; --i)
|
||||
this.$tryReplace(ranges[i], replacement);
|
||||
|
||||
|
||||
this.selection.setSelectionRange(selection);
|
||||
this.$blockScrolling -= 1;
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue