mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-01-11 03:25:45 +00:00
fix textarea cursor position.
This commit is contained in:
parent
0db80e844b
commit
31a0a0a2e6
@ -2558,15 +2558,22 @@ Textarea.prototype.__proto__ = ScrollableText.prototype;
|
|||||||
|
|
||||||
Textarea.prototype.type = 'textarea';
|
Textarea.prototype.type = 'textarea';
|
||||||
|
|
||||||
|
// TODO: Optimize this. Remember cursor coords.
|
||||||
|
// Optimize to use CUU, CUD, CUB, CUF.
|
||||||
Textarea.prototype.updateCursor = function() {
|
Textarea.prototype.updateCursor = function() {
|
||||||
if (this.screen.focused !== this) return;
|
if (this.screen.focused !== this) return;
|
||||||
|
|
||||||
var _clines = this.value.split('\n');
|
var last = this._clines[this._clines.length-1];
|
||||||
var clen = _clines.length;
|
|
||||||
var last = _clines[_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(
|
var line = Math.min(
|
||||||
clen - 1 - this.childBase,
|
this._clines.length - 1 - this.childBase,
|
||||||
this.height - (this.border ? 2 : 0) - 1);
|
this.height - (this.border ? 2 : 0) - 1);
|
||||||
|
|
||||||
this.screen.program.cup(
|
this.screen.program.cup(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user