Skip to content

Commit

Permalink
Merge pull request #18 from eosterberg/3.0.1
Browse files Browse the repository at this point in the history
3.0.1 (prompt PS1)
  • Loading branch information
commanddotcom authored May 11, 2021
2 parents 0b4a5c3 + aa2f3be commit 3e59c60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ Displays a confirm message, with a " (y/n)" automatically appended at the end. T
.clear()
Clears the screen.

.setPrompt()
You can customize your PS1 for the prompt. It can be set and override at any point of time.

.sleep(milliseconds, callback)
Works exactly like the JavaScript "setTimeout" function. Waits for the number of milliseconds given, then executes the callback.

Expand All @@ -70,7 +73,7 @@ All the ".set" methods accepts any CSS-compliant value.
Set to true by default.

.html
**DEPRECATED** from v. 3.0. This is the top DOM element of the terminal instance. If you want to modify styling via CSS, all instances belong to a .Terminal class. The element will also get the ID from the constructor argument.
This is the top DOM element of the terminal instance. If you want to modify styling via CSS, all instances belong to a .Terminal class.

### License

Expand Down
9 changes: 8 additions & 1 deletion terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = (function () {

var VERSION = '3.0.0-alpha';
var VERSION = '3.0.1';

// PROMPT_TYPE
var PROMPT_INPUT = 1, PROMPT_PASSWORD = 2, PROMPT_CONFIRM = 3;
Expand Down Expand Up @@ -107,6 +107,7 @@ module.exports = (function () {

this._innerWindow = document.createElement('div');
this._output = document.createElement('p');
this._promptPS = document.createElement('span');
this._inputLine = document.createElement('span'); //the span element where the users input is put
this._cursor = document.createElement('span');
this._input = document.createElement('p'); //the full element administering the user input, including cursor
Expand Down Expand Up @@ -195,11 +196,17 @@ module.exports = (function () {
return this;
}

this.setPrompt = function (promptPS) {
this._promptPS.textContent = promptPS;
return this;
}

this.getVersion = function() {
console.info(`TerminalJS ${VERSION}`)
return VERSION;
}

this._input.appendChild(this._promptPS);
this._input.appendChild(this._inputLine);
this._input.appendChild(this._cursor);
this._innerWindow.appendChild(this._output);
Expand Down

0 comments on commit 3e59c60

Please sign in to comment.