getLines and getScreenLines, handle detaching/reattaching widgets.

This commit is contained in:
Christopher Jeffrey 2014-01-13 10:25:31 -06:00
parent 445d9f4065
commit c218df7350
2 changed files with 32 additions and 4 deletions

View File

@ -403,6 +403,9 @@ parameter must be a string.
- **shiftLine(i)** - shift a line off the top of the content. - **shiftLine(i)** - shift a line off the top of the content.
- **pushLine(lines)** - push a line onto the bottom of the content. - **pushLine(lines)** - push a line onto the bottom of the content.
- **popLine(i)** - pop a line off the bottom of the content. - **popLine(i)** - pop a line off the bottom of the content.
- **getLines()** - an array containing the content lines.
- **getScreenLines()** - an array containing the lines as they are displayed on
the screen.
#### Box (from Element) #### Box (from Element)

View File

@ -3518,6 +3518,14 @@ Element.prototype.popLine = function(n) {
return this.deleteLine(this._clines.fake.length - 1, n); return this.deleteLine(this._clines.fake.length - 1, n);
}; };
Element.prototype.getLines = function() {
return this._clines.fake.slice();
};
Element.prototype.getScreenLines = function() {
return this._clines.slice();
};
/** /**
* Box * Box
*/ */
@ -3889,7 +3897,7 @@ ScrollableBox.prototype.resetScroll = function() {
return this.emit('scroll'); return this.emit('scroll');
}; };
ScrollableBox.prototype.getScrollHeight = function(s) { ScrollableBox.prototype.getScrollHeight = function() {
return Math.max(this._clines.length, this._scrollBottom()); return Math.max(this._clines.length, this._scrollBottom());
}; };
@ -4278,6 +4286,11 @@ List.prototype.pick = function(callback) {
var focused = this.screen.focused; var focused = this.screen.focused;
if (focused && focused._done) focused._done('stop'); if (focused && focused._done) focused._done('stop');
this.screen.saveFocus(); this.screen.saveFocus();
//var parent = this.parent;
//this.detach();
//parent.append(this);
this.focus(); this.focus();
this.show(); this.show();
this.screen.render(); this.screen.render();
@ -5458,6 +5471,10 @@ Prompt.prototype.type = function(text, value, callback) {
value = ''; value = '';
} }
//var parent = this.parent;
//this.detach();
//parent.append(this);
this.show(); this.show();
this.setContent(' ' + text); this.setContent(' ' + text);
@ -5540,6 +5557,10 @@ Question.prototype.ask = function(text, callback) {
var self = this; var self = this;
var press, okay, cancel; var press, okay, cancel;
//var parent = this.parent;
//this.detach();
//parent.append(this);
this.show(); this.show();
this.setContent(' ' + text); this.setContent(' ' + text);
@ -5609,9 +5630,9 @@ Message.prototype.display = function(text, time, callback) {
if (time == null) time = 3; if (time == null) time = 3;
//time = time || 3; //time = time || 3;
var parent = this.parent; //var parent = this.parent;
this.detach(); //this.detach();
parent.append(this); //parent.append(this);
if (this.scrollable) { if (this.scrollable) {
this.screen.saveFocus(); this.screen.saveFocus();
@ -5712,6 +5733,10 @@ Loading.prototype.type = 'loading';
Loading.prototype.load = function(text) { Loading.prototype.load = function(text) {
var self = this; var self = this;
//var parent = this.parent;
//this.detach();
//parent.append(this);
this.show(); this.show();
this.setContent(text); this.setContent(text);