Merge remote branch 'upstream/master' into requirejs
This commit is contained in:
commit
6c5729d094
5 changed files with 66 additions and 33 deletions
|
|
@ -74,7 +74,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace_editor textarea {
|
.ace_editor textarea {
|
||||||
position: "absolute";
|
position: absolute;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
width: 10px;
|
width: 10px;
|
||||||
|
|
|
||||||
|
|
@ -541,7 +541,7 @@ var EditSession = function(text, mode) {
|
||||||
if (firstDelta.action == "insertText" || firstDelta.action == "insertLines")
|
if (firstDelta.action == "insertText" || firstDelta.action == "insertLines")
|
||||||
this.selection.moveCursorToPosition(firstDelta.range.start);
|
this.selection.moveCursorToPosition(firstDelta.range.start);
|
||||||
if (firstDelta.action == "removeText" || firstDelta.action == "removeLines")
|
if (firstDelta.action == "removeText" || firstDelta.action == "removeLines")
|
||||||
this.selection.setSelectionRange(Range.fromPoints(firstDelta.range.start, lastDelta.range.end));
|
this.selection.setSelectionRange(Range.fromPoints(lastDelta.range.start, firstDelta.range.end));
|
||||||
},
|
},
|
||||||
|
|
||||||
this.redoChanges = function(deltas) {
|
this.redoChanges = function(deltas) {
|
||||||
|
|
@ -560,7 +560,7 @@ var EditSession = function(text, mode) {
|
||||||
if (firstDelta.action == "insertText" || firstDelta.action == "insertLines")
|
if (firstDelta.action == "insertText" || firstDelta.action == "insertLines")
|
||||||
this.selection.setSelectionRange(Range.fromPoints(firstDelta.range.start, lastDelta.range.end));
|
this.selection.setSelectionRange(Range.fromPoints(firstDelta.range.start, lastDelta.range.end));
|
||||||
if (firstDelta.action == "removeText" || firstDelta.action == "removeLines")
|
if (firstDelta.action == "removeText" || firstDelta.action == "removeLines")
|
||||||
this.selection.moveCursorToPosition(firstDelta.range.start);
|
this.selection.moveCursorToPosition(lastDelta.range.start);
|
||||||
},
|
},
|
||||||
|
|
||||||
this.replace = function(range, text) {
|
this.replace = function(range, text) {
|
||||||
|
|
@ -918,7 +918,7 @@ var EditSession = function(text, mode) {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @returns array
|
* @returns array
|
||||||
* - array[0]: The documentRow aquivalent.
|
* - array[0]: The documentRow equivalent.
|
||||||
* - array[1]: The screenRowOffset to the first documentRow on the screen.
|
* - array[1]: The screenRowOffset to the first documentRow on the screen.
|
||||||
*/
|
*/
|
||||||
this.$screenToDocumentRow = function(row) {
|
this.$screenToDocumentRow = function(row) {
|
||||||
|
|
@ -949,23 +949,24 @@ var EditSession = function(text, mode) {
|
||||||
var docRow;
|
var docRow;
|
||||||
var docColumn;
|
var docColumn;
|
||||||
var remaining = column;
|
var remaining = column;
|
||||||
|
var linesCount = this.getLength();
|
||||||
if (!this.$useWrapMode) {
|
if (!this.$useWrapMode) {
|
||||||
docRow = row;
|
docRow = row >= linesCount? linesCount-1 : (row < 0 ? 0 : row);
|
||||||
row = 0;
|
row = 0;
|
||||||
docColumn = 0;
|
docColumn = 0;
|
||||||
line = this.getLine(docRow);
|
line = this.getLine(docRow);
|
||||||
} else {
|
} else {
|
||||||
var wrapData = this.$wrapData, linesCount = this.getLength();
|
var wrapData = this.$wrapData;
|
||||||
|
|
||||||
var rowData = this.$screenToDocumentRow(row);
|
var docRow = 0;
|
||||||
row = rowData[1];
|
while (docRow < linesCount && row >= wrapData[docRow].length + 1) {
|
||||||
docRow = rowData[0];
|
row -= wrapData[docRow].length + 1;
|
||||||
|
docRow ++;
|
||||||
|
}
|
||||||
|
|
||||||
if (docRow >= linesCount) {
|
if (docRow >= linesCount) {
|
||||||
return {
|
docRow = linesCount-1
|
||||||
row: docRow,
|
row = wrapData[docRow].length;
|
||||||
column: 0
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
docColumn = wrapData[docRow][row - 1] || 0;
|
docColumn = wrapData[docRow][row - 1] || 0;
|
||||||
line = this.getLine(docRow).substring(docColumn);
|
line = this.getLine(docRow).substring(docColumn);
|
||||||
|
|
@ -1009,15 +1010,16 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clamp docColumn.
|
// Clamp docColumn.
|
||||||
if (docRow < linesCount && wrapData[docRow][row]) {
|
if (this.$useWrapMode) {
|
||||||
if (docColumn >= wrapData[docRow][row]) {
|
column = wrapData[docRow][row]
|
||||||
|
if (docColumn >= column) {
|
||||||
// We remove one character at the end such that the docColumn
|
// We remove one character at the end such that the docColumn
|
||||||
// position returned is not associated to the next row on the
|
// position returned is not associated to the next row on the
|
||||||
// screen.
|
// screen.
|
||||||
docColumn = wrapData[docRow][row] - 1;
|
docColumn = column - 1;
|
||||||
}
|
}
|
||||||
} else if (this.getLine(docRow)) {
|
} else if (line) {
|
||||||
docColumn = Math.min(docColumn, this.getLine(docRow).length);
|
docColumn = Math.min(docColumn, line.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ var Editor =function(renderer, session) {
|
||||||
var range = delta.range;
|
var range = delta.range;
|
||||||
|
|
||||||
this.bgTokenizer.start(range.start.row);
|
this.bgTokenizer.start(range.start.row);
|
||||||
if (range.start.row == range.end.row)
|
if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines")
|
||||||
var lastRow = range.end.row;
|
var lastRow = range.end.row;
|
||||||
else
|
else
|
||||||
lastRow = Infinity;
|
lastRow = Infinity;
|
||||||
|
|
@ -280,17 +280,17 @@ var Editor =function(renderer, session) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onCursorChange = function(e) {
|
this.onCursorChange = function(e) {
|
||||||
this.$highlightBrackets();
|
|
||||||
|
|
||||||
// move text input over the cursor
|
|
||||||
// this is required for iOS and IME
|
|
||||||
this.renderer.moveTextAreaToCursor(this.textInput.getElement());
|
|
||||||
|
|
||||||
this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite);
|
this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite);
|
||||||
|
|
||||||
if (!this.$blockScrolling && (!e || !e.blockScrolling)) {
|
if (!this.$blockScrolling && (!e || !e.blockScrolling)) {
|
||||||
this.renderer.scrollCursorIntoView();
|
this.renderer.scrollCursorIntoView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// move text input over the cursor
|
||||||
|
// this is required for iOS and IME
|
||||||
|
this.renderer.moveTextAreaToCursor(this.textInput.getElement());
|
||||||
|
|
||||||
|
this.$highlightBrackets();
|
||||||
this.$updateHighlightActiveLine();
|
this.$updateHighlightActiveLine();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -357,10 +357,16 @@ var Editor =function(renderer, session) {
|
||||||
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
|
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
|
||||||
pos.row = Math.max(0, Math.min(pos.row, this.session.getLength()-1));
|
pos.row = Math.max(0, Math.min(pos.row, this.session.getLength()-1));
|
||||||
|
|
||||||
if (event.getButton(e) != 0) {
|
var button = event.getButton(e)
|
||||||
if (this.selection.isEmpty()) {
|
if (button != 0) {
|
||||||
|
var isEmpty = this.selection.isEmpty()
|
||||||
|
if (isEmpty) {
|
||||||
this.moveCursorToPosition(pos);
|
this.moveCursorToPosition(pos);
|
||||||
}
|
}
|
||||||
|
if(button == 2) {
|
||||||
|
this.textInput.onContextMenu({x: pageX, y: pageY}, isEmpty);
|
||||||
|
event.capture(this.container, function(){}, this.textInput.onContextMenuClose);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ var TextInput = function(parentNode, host) {
|
||||||
|
|
||||||
var inCompostion = false;
|
var inCompostion = false;
|
||||||
var copied = false;
|
var copied = false;
|
||||||
|
var tempStyle = '';
|
||||||
|
|
||||||
function sendText(valueToSend) {
|
function sendText(valueToSend) {
|
||||||
if (!copied) {
|
if (!copied) {
|
||||||
|
|
@ -184,10 +185,32 @@ var TextInput = function(parentNode, host) {
|
||||||
this.blur = function() {
|
this.blur = function() {
|
||||||
text.blur();
|
text.blur();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getElement = function() {
|
this.getElement = function() {
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.onContextMenu = function(mousePos, isEmpty){
|
||||||
|
if (mousePos) {
|
||||||
|
if(!tempStyle)
|
||||||
|
tempStyle = text.style.cssText;
|
||||||
|
text.style.cssText = 'position:fixed; z-index:1000;' +
|
||||||
|
'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;'
|
||||||
|
|
||||||
|
}
|
||||||
|
if (isEmpty)
|
||||||
|
text.value='';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.onContextMenuClose = function(){
|
||||||
|
setTimeout(function () {
|
||||||
|
if (tempStyle) {
|
||||||
|
text.style.cssText = tempStyle;
|
||||||
|
tempStyle = '';
|
||||||
|
}
|
||||||
|
sendText();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.TextInput = TextInput;
|
exports.TextInput = TextInput;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* the Initial Developer. All Rights Reserved.
|
* the Initial Developer. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
* Fabian Jakobs <fabian@ajax.org>
|
||||||
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
||||||
* Julian Viereck <julian.viereck@gmail.com>
|
* Julian Viereck <julian.viereck@gmail.com>
|
||||||
*
|
*
|
||||||
|
|
@ -96,12 +96,13 @@ var VirtualRenderer = function(container, theme) {
|
||||||
column : 0
|
column : 0
|
||||||
};
|
};
|
||||||
|
|
||||||
var self = this;
|
var _self = this;
|
||||||
this.$textLayer.addEventListener("changeCharaterSize", function() {
|
this.$textLayer.addEventListener("changeCharaterSize", function() {
|
||||||
self.characterWidth = textLayer.getCharacterWidth();
|
_self.characterWidth = textLayer.getCharacterWidth();
|
||||||
self.lineHeight = textLayer.getLineHeight();
|
_self.lineHeight = textLayer.getLineHeight();
|
||||||
|
_self.$updatePrintMargin();
|
||||||
|
|
||||||
self.$loop.schedule(self.CHANGE_FULL);
|
_self.$loop.schedule(_self.CHANGE_FULL);
|
||||||
});
|
});
|
||||||
event.addListener(this.$gutter, "click", this.$onGutterClick.bind(this));
|
event.addListener(this.$gutter, "click", this.$onGutterClick.bind(this));
|
||||||
event.addListener(this.$gutter, "dblclick", this.$onGutterClick.bind(this));
|
event.addListener(this.$gutter, "dblclick", this.$onGutterClick.bind(this));
|
||||||
|
|
@ -272,6 +273,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
if (!this.$showPrintMargin && !this.$printMarginEl)
|
if (!this.$showPrintMargin && !this.$printMarginEl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!this.$printMarginEl) {
|
if (!this.$printMarginEl) {
|
||||||
containerEl = document.createElement("div");
|
containerEl = document.createElement("div");
|
||||||
containerEl.className = "ace_print_margin_layer";
|
containerEl.className = "ace_print_margin_layer";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue