blob: ef53b122af3f4b459199b3c43e738ccd08552cb8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
import QtQuick 2.0
import QMLTermWidget 1.0
import QtQuick.Layouts 1.1
import Qt.labs.settings 1.0
Item {
id: item
property string program
property string workingDirectory
property int lines : 20
property int frameWidth : 10
height: terminal.height
width: parent.width - frameWidth
Settings {
category: "terminal"
property alias frameWidth : item.frameWidth
property alias colorScheme : terminal.colorScheme
property alias fontFamily : terminal.font.family
property alias fontSize : terminal.font.pointSize
}
function select() { highlighter.select() }
function deselect() { highlighter.deselect() }
RowLayout {
id: container
anchors {
left: parent.left
right: parent.right
}
spacing: 0
Highlighter {
id: highlighter
width: item.frameWidth
Layout.fillHeight: true
}
QMLTermWidget {
id: terminal
font {
family: "Monospace"
pointSize: 8
}
Layout.fillWidth: true
Layout.preferredHeight: fontMetrics.height * item.lines
colorScheme: "cool-retro-term"
session: QMLTermSession {
initialWorkingDirectory: item.workingDirectory
shellProgram: {
return (item.program).split(" ")[0];
}
shellProgramArgs: {
var elements = (item.program).split(" ");
elements.shift();
return elements;
}
}
onTermGetFocus: highlighter.focus()
onTermLostFocus: highlighter.unfocus()
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
onWheel: { }
}
Component.onCompleted: {
forceActiveFocus();
highlighter.select();
session.startShellProgram();
}
}
}
}
|