diff --git a/commands/login.js b/commands/login.js index 65902b5..574ca4e 100644 --- a/commands/login.js +++ b/commands/login.js @@ -3,8 +3,6 @@ var unirest = require('unirest'); async function login(key, conns, MYKEY, USERNAME) { getUSERNAME(key) .then((data) => { - process.stdout.write("\033[2J") - process.stdout.write("\033[0f") console.log("Hello, " + data + "\nYou are now logged in.\n\n\n") USERNAME[0] = data MYKEY.push(key) diff --git a/sshChat.js b/sshChat.js index 41c65a3..5727bab 100644 --- a/sshChat.js +++ b/sshChat.js @@ -124,14 +124,14 @@ sidebarBox.setLabel("Connected Peers: (Currently None)") const originalLog = console.log; console.log = (...args) => { - mainBox.setContent(mainBox.getContent() + `\n${args.join(' ')}`); - updateScroll() - stdinBox.clearValue(); - - screen.render() + mainBox.setContent(mainBox.getContent() + `\n${args.join(' ')}`); + updateScroll() + stdinBox.clearValue(); + screen.render() } + // Generate a random public key const publicKey = crypto.randomBytes(32) @@ -262,7 +262,7 @@ setTimeout(() => { // The flushed promise will resolve when the topic has been fully announced to the DHT discovery.flushed().then(() => { mainBox.setLabel("Topic: " + b4a.toString(topic, 'hex') + " (Share to connect)") - stdinBox.setLabel("To login: >login [TOKEN]") + stdinBox.setLabel("To login: >login [TOKEN] | To quit: >exit") screen.render() }) }, 1000); @@ -293,4 +293,9 @@ stdinBox.on('submit', (input) => { stdinBox.focus(); // Render the screen -screen.render() \ No newline at end of file +screen.render() + +// Quit on Escape, q, or Control-C. +screen.key(['escape', 'q', 'C-c'], function(ch, key) { + return process.exit(0); +}); \ No newline at end of file