From e70782091508415448bde15c8e55396bf8271c58 Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Wed, 15 Jan 2025 23:03:57 +0100 Subject: [PATCH] better linebreaks for javascript console --- com/isoterminal/feat/jsconsole.js | 2 +- com/isoterminal/feat/term.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/com/isoterminal/feat/jsconsole.js b/com/isoterminal/feat/jsconsole.js index d9511a7..cc393a0 100644 --- a/com/isoterminal/feat/jsconsole.js +++ b/com/isoterminal/feat/jsconsole.js @@ -34,7 +34,7 @@ ISOTerminal.prototype.enableConsole = function(opts){ opts = opts || {stdout:false} this.redirectConsole( (str,prefix) => { - let finalStr = opts.stdout ? "\n\r" : "" + let finalStr = ""; prefix = prefix ? prefix+' ' : '' str.trim().split("\n").map( (line) => { finalStr += `${opts.stdout ? '' : "\x1b[38;5;165m/dev/browser: \x1b[0m"}`+prefix+line+'\n' diff --git a/com/isoterminal/feat/term.js b/com/isoterminal/feat/term.js index 8122667..a07dcbd 100644 --- a/com/isoterminal/feat/term.js +++ b/com/isoterminal/feat/term.js @@ -103,10 +103,11 @@ ISOTerminal.prototype.TermInit = function(){ this.term.write(ch) const reset = () => { this.console = "" - setTimeout( () => this.term.write( this.term.prompt),100) + setTimeout( () => "\n\r"+this.term.write( this.term.prompt),100) } if( (ch == "\n" || ch == "\r") ){ try{ + this.term.write("\n\r") if( this.console ) eval(this.console) reset() }catch(e){