From 7a6fb27a5340d0dfdcc3c7d8b49c00fca09df50b Mon Sep 17 00:00:00 2001 From: paris Date: Mon, 24 Mar 2014 16:53:33 +0000 Subject: [PATCH] Amended some default styling/befavior - cursorBlink is not default from now on - added some custom behavior in the demo --- demo/main.js | 22 +++++++++++++++++++--- demo/style.css | 6 ++++++ src/xterm.css | 4 ++++ src/xterm.js | 2 +- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/demo/main.js b/demo/main.js index a57c680..05a7d15 100644 --- a/demo/main.js +++ b/demo/main.js @@ -1,8 +1,24 @@ var terminalContainer = document.getElementById('terminal-container'), - term = new Terminal({geometry: [60, 37]}); + term = new Terminal({geometry: [95, 37]}); + +term.prompt = function () { + term.write('> '); +} term.open(terminalContainer); +term.writeln('Welcome to xterm.js'); +term.writeln('Just type some keys in the prompt below.'); +term.writeln(''); +term.prompt(); -term.on('data', function (data) { - term.write(data); +term.on('key', function (key, ev) { + console.log(this, key, ev); + if (ev.keyIdentifier == 'Enter') { + term.writeln(''); + term.prompt(); + } if (ev.keyCode == 8) { + term.write('\b \b'); + }else { + term.write(key); + } }); \ No newline at end of file diff --git a/demo/style.css b/demo/style.css index 7ed117b..6ed5d25 100644 --- a/demo/style.css +++ b/demo/style.css @@ -12,9 +12,15 @@ h1 { width: 960px; height: 600px; margin: 0 auto; + padding: 2px; } #terminal-container .terminal { background-color: #111; color: #fafafa; + padding: 2px; +} + +#terminal-container .terminal .terminal-cursor { + background-color: #fafafa; } \ No newline at end of file diff --git a/src/xterm.css b/src/xterm.css index 41ba490..86d22b2 100644 --- a/src/xterm.css +++ b/src/xterm.css @@ -40,4 +40,8 @@ color: #fff; outline: none; font-family: courier-new, courier, monospace; +} + +.terminal .terminal-cursor { + background-color: #fff; } \ No newline at end of file diff --git a/src/xterm.js b/src/xterm.js index 9dafc1f..bec7234 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -389,7 +389,7 @@ Terminal.defaults = { convertEol: false, termName: 'xterm', geometry: [80, 24], - cursorBlink: true, + cursorBlink: false, visualBell: false, popOnBell: false, scrollback: 1000,