mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-17 08:07:51 +00:00
move command history to its own module
This commit is contained in:
parent
1868788342
commit
07d1631d9d
28
lib/dashboard/command_history.js
Normal file
28
lib/dashboard/command_history.js
Normal file
@ -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 */
|
/*jshint esversion: 6 */
|
||||||
|
|
||||||
var blessed = require("blessed");
|
var blessed = require("blessed");
|
||||||
|
var CommandHistory = require('./command_history.js');
|
||||||
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];
|
|
||||||
};
|
|
||||||
|
|
||||||
function Dashboard(options) {
|
function Dashboard(options) {
|
||||||
var title = (options && options.title) || "Embark 2.3.0";
|
var title = (options && options.title) || "Embark 2.3.0";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user