aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-08-19 11:40:23 +0200
committerAdrian Kummerlaender2015-08-19 11:40:23 +0200
commit0dde6e134fdfbd54a2d148875e58ef1355578c8c (patch)
tree8b1fec9a2d08a823ad6f4d8321f7d7398e8b3360
parent4cb435f2a7bbeafb53f067d95ec83e0b3a1a17f8 (diff)
downloadMetaTerm-0dde6e134fdfbd54a2d148875e58ef1355578c8c.tar
MetaTerm-0dde6e134fdfbd54a2d148875e58ef1355578c8c.tar.gz
MetaTerm-0dde6e134fdfbd54a2d148875e58ef1355578c8c.tar.bz2
MetaTerm-0dde6e134fdfbd54a2d148875e58ef1355578c8c.tar.lz
MetaTerm-0dde6e134fdfbd54a2d148875e58ef1355578c8c.tar.xz
MetaTerm-0dde6e134fdfbd54a2d148875e58ef1355578c8c.tar.zst
MetaTerm-0dde6e134fdfbd54a2d148875e58ef1355578c8c.zip
Add `set` command to ease configuration changes
-rw-r--r--src/command/commands.js28
-rw-r--r--src/widget/EmbeddedTerminal.qml4
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);
}
}
}