aboutsummaryrefslogtreecommitdiff
path: root/qml/StateHandler.qml
blob: 53ca3af0f1ae5c8e5b0c11d4676aab169905d289 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import QtQuick 2.0
import QtQuick.Controls 1.2

Item {
	id: item

	property Item terminalList : null

	state: "INSERT"

	function enterInsertMode() {
		insertTerminalAction.trigger();
	}

	states: [
		State {
			name: "NORMAL"

			PropertyChanges { target: escapeTerminalAction;   enabled: false }
			PropertyChanges { target: insertTerminalAction;   enabled: true  }
			PropertyChanges { target: nextTerminalAction;     enabled: true  }
			PropertyChanges { target: heightenTerminalAction; enabled: true  }
			PropertyChanges { target: shortenTerminalAction;  enabled: true  }
			PropertyChanges { target: prevTerminalAction;     enabled: true  }
			PropertyChanges { target: lastTerminalAction;     enabled: true  }
			PropertyChanges { target: firstTerminalAction;    enabled: true  }
			PropertyChanges { target: resetTerminalAction;    enabled: true  }
		},
		State {
			name: "INSERT"

			PropertyChanges { target: escapeTerminalAction;   enabled: true  }
			PropertyChanges { target: insertTerminalAction;   enabled: false }
			PropertyChanges { target: nextTerminalAction;     enabled: false }
			PropertyChanges { target: heightenTerminalAction; enabled: false }
			PropertyChanges { target: shortenTerminalAction;  enabled: false }
			PropertyChanges { target: prevTerminalAction;     enabled: false }
			PropertyChanges { target: lastTerminalAction;     enabled: false }
			PropertyChanges { target: firstTerminalAction;    enabled: false }
			PropertyChanges { target: resetTerminalAction;    enabled: false }
		}
	]

	Action {
		id: insertTerminalAction
		shortcut: "i"
		onTriggered: {
			item.state = "INSERT";

			terminalList.focusCurrent();
		}
	}

	Action {
		id: escapeTerminalAction
		shortcut: "Shift+ESC"
		onTriggered: {
			item.state = "NORMAL";

            terminalList.forceActiveFocus();
			terminalList.unfocusCurrent();
		}
	}

	Action {
		id: nextTerminalAction
		shortcut: "j"
		onTriggered: terminalList.selectNext()
	}

	Action {
		id: heightenTerminalAction
		shortcut: "Shift+J"
		onTriggered: terminalList.getCurrent().heighten()
	}

	Action {
		id: shortenTerminalAction
		shortcut: "Shift+K"
		onTriggered: terminalList.getCurrent().shorten()
	}

	Action {
		id: prevTerminalAction
		shortcut: "k"
		onTriggered: terminalList.selectPrev()
	}

	Action {
		id: lastTerminalAction
		shortcut: "Shift+G"
		onTriggered: terminalList.selectItem(terminalList.children.length - 1)
	}

	Action {
		id: firstTerminalAction
		shortcut: "g"
		onTriggered: terminalList.selectItem(0)
	}

	Action {
		id: resetTerminalAction
		shortcut: "d"
		onTriggered: terminalList.getCurrent().reset()
	}
}