aboutsummaryrefslogtreecommitdiff
path: root/qml
diff options
context:
space:
mode:
Diffstat (limited to 'qml')
-rw-r--r--qml/CommandInput.qml91
-rw-r--r--qml/commands.js23
-rw-r--r--qml/main.qml1
3 files changed, 84 insertions, 31 deletions
diff --git a/qml/CommandInput.qml b/qml/CommandInput.qml
index ae48a7a..6add27a 100644
--- a/qml/CommandInput.qml
+++ b/qml/CommandInput.qml
@@ -11,6 +11,8 @@ Item {
visible: false
+ Layout.preferredHeight: container.height
+
Settings {
id: settings
category: "command"
@@ -21,6 +23,8 @@ Item {
property color fontColor : "white"
}
+ onVisibleChanged: container.reset()
+
function focus(prefix) {
visible = true;
command.text = prefix;
@@ -32,40 +36,83 @@ Item {
}
Rectangle {
- anchors.fill: parent
+ anchors {
+ top: parent.top
+ left: parent.left
+ right: parent.right
+ }
+
+ height: container.height
+
color: settings.background
- TextInput {
- id: command
+ ColumnLayout {
+ id: container
- font {
- family: settings.fontFamily
- pointSize: settings.fontSize
+ function reset() {
+ command.text = '';
+ output.text = '';
}
- color: settings.fontColor
- selectionColor: settings.fontColor
- selectedTextColor: settings.background
- selectByMouse: true
+ TextInput {
+ id: command
- function reset() { text = '' }
+ Layout.fillWidth: true
- onAccepted: {
- const prefix = String(text).charAt(0);
- const cmd = String(text).substring(1, String(text).length);
+ font {
+ family: settings.fontFamily
+ pointSize: settings.fontSize
+ }
- switch ( prefix ) {
- case ':': {
- Commands.execute(cmd);
- reset();
- break;
+ color: settings.fontColor
+ selectionColor: settings.fontColor
+ selectedTextColor: settings.background
+ selectByMouse: true
+
+ onAccepted: {
+ const prefix = String(text).charAt(0);
+ const cmd = String(text).substring(1, String(text).length);
+
+ switch ( prefix ) {
+ case ':': {
+ Commands.execute(output, cmd);
+ break;
+ }
+ default: {
+ output.log('"' + prefix + '"' + " is not a command prefix.");
+ }
}
- default: {
- console.log('"' + prefix + '"' + " is not a command prefix.");
+
+ if ( output.text === '' ) {
+ item.executed();
}
}
+ }
+
+ Text {
+ id: output
- item.executed();
+ Layout.fillWidth: true
+ Layout.preferredHeight: 0
+
+ font {
+ family: settings.fontFamily
+ pointSize: settings.fontSize
+ }
+
+ color: settings.fontColor
+
+ function log(msg) {
+ text = msg;
+ }
+
+ onTextChanged: {
+ if ( text === '' ) {
+ Layout.preferredHeight = 0;
+ } else {
+ Layout.preferredHeight = contentHeight;
+ }
+ }
}
}
}
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);
-}
diff --git a/qml/main.qml b/qml/main.qml
index c04e6dd..f455120 100644
--- a/qml/main.qml
+++ b/qml/main.qml
@@ -39,7 +39,6 @@ ApplicationWindow {
id: command
Layout.fillWidth: true
- height: 20
onExecuted: state.enterNormalMode()
}