diff options
-rw-r--r-- | src/list/TerminalItem.qml | 26 | ||||
-rw-r--r-- | src/ui.qrc | 1 | ||||
-rw-r--r-- | src/widget/EmbeddedTerminal.qml | 11 | ||||
-rw-r--r-- | src/widget/HistoryViewer.qml | 33 |
4 files changed, 71 insertions, 0 deletions
diff --git a/src/list/TerminalItem.qml b/src/list/TerminalItem.qml index febd116..cfffd86 100644 --- a/src/list/TerminalItem.qml +++ b/src/list/TerminalItem.qml @@ -6,6 +6,7 @@ Item { id: item property EmbeddedTerminal terminal : null + property HistoryViewer history : null property int index : 0 signal executed (int index) @@ -96,12 +97,22 @@ Item { function createTerminal(program) { var terminalComponent = Qt.createComponent("qrc:/EmbeddedTerminal.qml"); var instantiateTerminal = function() { + if ( item.history !== null ) { + item.history.destroy(); + item.history = null; + } + item.terminal = terminalComponent.createObject(elementList, { "settings" : settings, "program" : program, "workingDirectory" : "$HOME", "focus" : true }); + item.terminal.onFinished.connect(function() { + var history = item.terminal.history; + item.reset(); + createHistoryViewer(history); + }); } if ( terminalComponent.status === Component.Ready ) { @@ -111,6 +122,21 @@ Item { } } + function createHistoryViewer(history) { + var historyComponent = Qt.createComponent("qrc:/HistoryViewer.qml"); + var instantiateHistory = function() { + item.history = historyComponent.createObject(elementList, { + "history" : history + }); + } + + if ( historyComponent.status === Component.Ready ) { + instantiateHistory(); + } else { + historyComponent.statusChanged.connect(instantiateHistory); + } + } + RowLayout { anchors { left: parent.left @@ -8,6 +8,7 @@ <file alias="CommandInput.qml">command/CommandInput.qml</file> <file alias="commands.js">command/commands.js</file> <file alias="EmbeddedTerminal.qml">widget/EmbeddedTerminal.qml</file> + <file alias="HistoryViewer.qml">widget/HistoryViewer.qml</file> <file alias="Highlighter.qml">widget/Highlighter.qml</file> </qresource> </RCC> diff --git a/src/widget/EmbeddedTerminal.qml b/src/widget/EmbeddedTerminal.qml index fa30e23..497bf49 100644 --- a/src/widget/EmbeddedTerminal.qml +++ b/src/widget/EmbeddedTerminal.qml @@ -5,11 +5,15 @@ import QtQuick.Layouts 1.1 Item { id: item + signal finished + property string program property string workingDirectory property int lines : settings.terminal.initialLines + property alias history : session.history + function select() { highlighter.select() } function deselect() { highlighter.deselect() } function displayOverlay() { overlay.displayBriefly() } @@ -48,6 +52,8 @@ Item { colorScheme: settings.terminal.colorScheme session: QMLTermSession { + id: session + initialWorkingDirectory: item.workingDirectory shellProgram: { @@ -60,6 +66,11 @@ Item { return elements; } + + onFinished: { + clearScreen(); + item.finished(); + } } Component.onCompleted: { diff --git a/src/widget/HistoryViewer.qml b/src/widget/HistoryViewer.qml new file mode 100644 index 0000000..ca042f4 --- /dev/null +++ b/src/widget/HistoryViewer.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 +import QMLTermWidget 1.0 +import QtQuick.Layouts 1.1 + +Item { + id: item + + property string history + + height: viewer.height + width: parent.width - settings.terminal.frameWidth + + Text { + id: viewer + + anchors { + left: parent.left + leftMargin: settings.terminal.frameWidth + right: parent.right + } + + color: settings.item.fontColor + + font { + family: settings.terminal.fontFamily + pointSize: settings.terminal.fontSize + } + + Layout.fillWidth: true + + text: history.trim() + } +} |