fix textarea cursor position.

This commit is contained in:
Christopher Jeffrey 2013-07-06 02:54:04 -05:00
parent 0db80e844b
commit 31a0a0a2e6
1 changed files with 11 additions and 4 deletions

View File

@ -2558,15 +2558,22 @@ Textarea.prototype.__proto__ = ScrollableText.prototype;
Textarea.prototype.type = 'textarea';
// TODO: Optimize this. Remember cursor coords.
// Optimize to use CUU, CUD, CUB, CUF.
Textarea.prototype.updateCursor = function() {
if (this.screen.focused !== this) return;
var _clines = this.value.split('\n');
var clen = _clines.length;
var last = _clines[_clines.length-1];
var last = this._clines[this._clines.length-1];
// Stop a situation where the textarea begins scrolling
// and the last cline appears to always be empty from the
// _typeScroll `+ '\n'` thing.
if (last === '' && this.value[this.value.length-1] !== '\n') {
last = this._clines[this._clines.length-2] || '';
}
var line = Math.min(
clen - 1 - this.childBase,
this._clines.length - 1 - this.childBase,
this.height - (this.border ? 2 : 0) - 1);
this.screen.program.cup(