From 610cc9d77f89ab106fdbfbc006934c9d192a55a8 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 11 Aug 2015 21:28:46 +0200 Subject: Add command output log to UI `output` text item reference is passed to all command implementations. --- qml/commands.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'qml/commands.js') diff --git a/qml/commands.js b/qml/commands.js index 7d4bdcf..b116b23 100644 --- a/qml/commands.js +++ b/qml/commands.js @@ -1,6 +1,6 @@ -function execute(command) { +function execute(output, command) { var msg = function(name) { - console.log('"' + name + '"' + " is not implemented."); + output.log('"' + name + '"' + " is not implemented."); }; var args = command.split(' '); @@ -9,7 +9,7 @@ function execute(command) { if ( typeof closure === "function" ) { args.shift(); - closure(args); + closure(output, args); } else { msg(args[0]); } @@ -18,8 +18,18 @@ function execute(command) { } } -function exec(args) { - eval(args.join(' ')); +function exec(output, args) { + var result = eval(args.join(' ')); + + if ( typeof result !== "undefined" ) { + output.log(result); + } else { + output.log(''); + } +} + +function jump(output, index) { + terminalList.selectItem(index); } function next() { @@ -30,6 +40,3 @@ function prev() { terminalList.selectPrev(); } -function jump(index) { - terminalList.selectItem(index); -} -- cgit v1.2.3