From 0dde6e134fdfbd54a2d148875e58ef1355578c8c Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 19 Aug 2015 11:40:23 +0200 Subject: Add `set` command to ease configuration changes --- src/command/commands.js | 28 ++++++++++++++++++++++++++-- src/widget/EmbeddedTerminal.qml | 4 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/command/commands.js b/src/command/commands.js index f76af01..8fa369a 100644 --- a/src/command/commands.js +++ b/src/command/commands.js @@ -18,9 +18,9 @@ function execute(output, command) { } } -function exec(output, args) { +function safeEval(output, code) { try { - var result = eval(args.join(' ')); + var result = eval(code); if ( typeof result !== 'undefined' ) { output.log(result); @@ -30,6 +30,10 @@ function exec(output, args) { } } +function exec(output, args) { + safeEval(output, args.join(' ')); +} + function jump(output, index) { terminalList.selectItem(index); } @@ -53,3 +57,23 @@ function ls(output) { } }); } + +function set(output, args) { + switch ( args.length ) { + case 2: { + safeEval(output, 'settings.' + args[0] + '.' + args[1]); + break; + } + case 3: { + safeEval( + output, + 'settings.' + args[0] + '.' + args[1] + ' = "' + args[2] + '"' + ); + break; + } + default: { + output.error('Wrong count of arguments.'); + break; + } + } +} diff --git a/src/widget/EmbeddedTerminal.qml b/src/widget/EmbeddedTerminal.qml index 54dad75..7b3cf10 100644 --- a/src/widget/EmbeddedTerminal.qml +++ b/src/widget/EmbeddedTerminal.qml @@ -123,8 +123,8 @@ Item { text: { return item.lines - + 'x' - + Math.floor(terminal.width / terminal.fontMetrics.width); + + 'x' + + Math.floor(terminal.width / terminal.fontMetrics.width); } } } -- cgit v1.2.3