Merge remote branch 'upstream/master' into requirejs

This commit is contained in:
Irakli Gozalishvili 2011-01-31 12:31:35 +01:00
commit 6c5729d094
5 changed files with 66 additions and 33 deletions

View file

@ -74,7 +74,7 @@
}
.ace_editor textarea {
position: "absolute";
position: absolute;
z-index: -1;
opacity: 0;
width: 10px;

View file

@ -541,7 +541,7 @@ var EditSession = function(text, mode) {
if (firstDelta.action == "insertText" || firstDelta.action == "insertLines")
this.selection.moveCursorToPosition(firstDelta.range.start);
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) {
@ -560,7 +560,7 @@ var EditSession = function(text, mode) {
if (firstDelta.action == "insertText" || firstDelta.action == "insertLines")
this.selection.setSelectionRange(Range.fromPoints(firstDelta.range.start, lastDelta.range.end));
if (firstDelta.action == "removeText" || firstDelta.action == "removeLines")
this.selection.moveCursorToPosition(firstDelta.range.start);
this.selection.moveCursorToPosition(lastDelta.range.start);
},
this.replace = function(range, text) {
@ -918,7 +918,7 @@ var EditSession = function(text, mode) {
/**
*
* @returns array
* - array[0]: The documentRow aquivalent.
* - array[0]: The documentRow equivalent.
* - array[1]: The screenRowOffset to the first documentRow on the screen.
*/
this.$screenToDocumentRow = function(row) {
@ -949,23 +949,24 @@ var EditSession = function(text, mode) {
var docRow;
var docColumn;
var remaining = column;
var linesCount = this.getLength();
if (!this.$useWrapMode) {
docRow = row;
docRow = row >= linesCount? linesCount-1 : (row < 0 ? 0 : row);
row = 0;
docColumn = 0;
line = this.getLine(docRow);
} else {
var wrapData = this.$wrapData, linesCount = this.getLength();
var wrapData = this.$wrapData;
var rowData = this.$screenToDocumentRow(row);
row = rowData[1];
docRow = rowData[0];
var docRow = 0;
while (docRow < linesCount && row >= wrapData[docRow].length + 1) {
row -= wrapData[docRow].length + 1;
docRow ++;
}
if (docRow >= linesCount) {
return {
row: docRow,
column: 0
};
docRow = linesCount-1
row = wrapData[docRow].length;
}
docColumn = wrapData[docRow][row - 1] || 0;
line = this.getLine(docRow).substring(docColumn);
@ -1009,15 +1010,16 @@ var EditSession = function(text, mode) {
}
// Clamp docColumn.
if (docRow < linesCount && wrapData[docRow][row]) {
if (docColumn >= wrapData[docRow][row]) {
if (this.$useWrapMode) {
column = wrapData[docRow][row]
if (docColumn >= column) {
// We remove one character at the end such that the docColumn
// position returned is not associated to the next row on the
// screen.
docColumn = wrapData[docRow][row] - 1;
docColumn = column - 1;
}
} else if (this.getLine(docRow)) {
docColumn = Math.min(docColumn, this.getLine(docRow).length);
} else if (line) {
docColumn = Math.min(docColumn, line.length);
}
return {

View file

@ -264,7 +264,7 @@ var Editor =function(renderer, session) {
var range = delta.range;
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;
else
lastRow = Infinity;
@ -280,17 +280,17 @@ var Editor =function(renderer, session) {
};
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);
if (!this.$blockScrolling && (!e || !e.blockScrolling)) {
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();
};
@ -357,10 +357,16 @@ var Editor =function(renderer, session) {
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
pos.row = Math.max(0, Math.min(pos.row, this.session.getLength()-1));
if (event.getButton(e) != 0) {
if (this.selection.isEmpty()) {
var button = event.getButton(e)
if (button != 0) {
var isEmpty = this.selection.isEmpty()
if (isEmpty) {
this.moveCursorToPosition(pos);
}
if(button == 2) {
this.textInput.onContextMenu({x: pageX, y: pageY}, isEmpty);
event.capture(this.container, function(){}, this.textInput.onContextMenuClose);
}
return;
}

View file

@ -50,6 +50,7 @@ var TextInput = function(parentNode, host) {
var inCompostion = false;
var copied = false;
var tempStyle = '';
function sendText(valueToSend) {
if (!copied) {
@ -184,10 +185,32 @@ var TextInput = function(parentNode, host) {
this.blur = function() {
text.blur();
};
this.getElement = function() {
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;

View file

@ -20,7 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Fabian Jakobs <fabian@ajax.org>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
* Julian Viereck <julian.viereck@gmail.com>
*
@ -96,12 +96,13 @@ var VirtualRenderer = function(container, theme) {
column : 0
};
var self = this;
var _self = this;
this.$textLayer.addEventListener("changeCharaterSize", function() {
self.characterWidth = textLayer.getCharacterWidth();
self.lineHeight = textLayer.getLineHeight();
_self.characterWidth = textLayer.getCharacterWidth();
_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, "dblclick", this.$onGutterClick.bind(this));
@ -272,6 +273,7 @@ var VirtualRenderer = function(container, theme) {
if (!this.$showPrintMargin && !this.$printMarginEl)
return;
if (!this.$printMarginEl) {
containerEl = document.createElement("div");
containerEl.className = "ace_print_margin_layer";