From e0685078e5cfa687843b7a4c3b4352fb36f3d5a8 Mon Sep 17 00:00:00 2001 From: Yevgen Shevchenko Date: Tue, 11 May 2021 13:54:56 +0300 Subject: [PATCH 1/2] README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 489406f..2abb6b8 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,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 From aa2f3be1a1fbe9cd157ab73291a56e4fd802bfc6 Mon Sep 17 00:00:00 2001 From: Yevgen Shevchenko Date: Tue, 11 May 2021 15:50:52 +0300 Subject: [PATCH 2/2] 3.0.1 PS1 prompt customization --- README.md | 3 +++ terminal.js | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2abb6b8..8d4faf7 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/terminal.js b/terminal.js index 8598c6f..a85e568 100644 --- a/terminal.js +++ b/terminal.js @@ -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; @@ -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 @@ -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);