cursor position in textarea.

This commit is contained in:
Christopher Jeffrey 2015-04-27 15:03:04 -07:00
parent 09fe097d3f
commit 46e9c52030
1 changed files with 8 additions and 1 deletions

View File

@ -5901,7 +5901,7 @@ Textarea.prototype._updateCursor = function(get) {
line = Math.max(0, line);
cy = lpos.yi + this.itop + line;
cx = lpos.xi + this.ileft + last.length;
cx = lpos.xi + this.ileft + this._strWidth(last);
// XXX Not sure, but this may still sometimes
// cause problems when leaving editor.
@ -5926,6 +5926,12 @@ Textarea.prototype._updateCursor = function(get) {
}
};
Textarea.prototype._strWidth = function(str) {
if (!this.screen.fullUnicode) return str.length;
str = str.replace(/\x03/g, '');
return unicode.strWidth(str, 0);
};
Textarea.prototype.input =
Textarea.prototype.setInput =
Textarea.prototype.readInput = function(callback) {
@ -6033,6 +6039,7 @@ Textarea.prototype._listener = function(ch, key) {
if (this.value.length) {
if (this.screen.fullUnicode) {
if (unicode.isSurrogate(this.value, this.value.length - 2)) {
// || unicode.isCombining(this.value, this.value.length - 1)) {
this.value = this.value.slice(0, -2);
} else {
this.value = this.value.slice(0, -1);