mirror of https://github.com/embarklabs/embark.git
move command history to its own module
This commit is contained in:
parent
1868788342
commit
07d1631d9d
|
@ -0,0 +1,28 @@
|
|||
|
||||
var CommandHistory = function() {
|
||||
this.history = [];
|
||||
this.pointer = -1;
|
||||
};
|
||||
|
||||
CommandHistory.prototype.addCommand = function(cmd) {
|
||||
this.history.push(cmd);
|
||||
this.pointer = this.history.length;
|
||||
};
|
||||
|
||||
CommandHistory.prototype.getPreviousCommand = function(cmd) {
|
||||
if (this.pointer >= 0) {
|
||||
this.pointer--;
|
||||
}
|
||||
return this.history[this.pointer];
|
||||
};
|
||||
|
||||
CommandHistory.prototype.getNextCommand = function(cmd) {
|
||||
if (this.pointer >= this.history.length) {
|
||||
this.pointer = this.history.length - 1;
|
||||
return '';
|
||||
}
|
||||
this.pointer++;
|
||||
return this.history[this.pointer];
|
||||
};
|
||||
|
||||
module.exports = CommandHistory;
|
|
@ -1,32 +1,7 @@
|
|||
/*jshint esversion: 6 */
|
||||
|
||||
var blessed = require("blessed");
|
||||
|
||||
var CommandHistory = function() {
|
||||
this.history = [];
|
||||
this.pointer = -1;
|
||||
};
|
||||
|
||||
CommandHistory.prototype.addCommand = function(cmd) {
|
||||
this.history.push(cmd);
|
||||
this.pointer = this.history.length;
|
||||
};
|
||||
|
||||
CommandHistory.prototype.getPreviousCommand = function(cmd) {
|
||||
if (this.pointer >= 0) {
|
||||
this.pointer--;
|
||||
}
|
||||
return this.history[this.pointer];
|
||||
};
|
||||
|
||||
CommandHistory.prototype.getNextCommand = function(cmd) {
|
||||
if (this.pointer >= this.history.length) {
|
||||
this.pointer = this.history.length - 1;
|
||||
return '';
|
||||
}
|
||||
this.pointer++;
|
||||
return this.history[this.pointer];
|
||||
};
|
||||
var CommandHistory = require('./command_history.js');
|
||||
|
||||
function Dashboard(options) {
|
||||
var title = (options && options.title) || "Embark 2.3.0";
|
||||
|
|
Loading…
Reference in New Issue