-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSQLiteViewer_HistoryTab.ahk
47 lines (37 loc) · 1.7 KB
/
SQLiteViewer_HistoryTab.ahk
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
class SQLiteViewer_HistoryTab {
groups := []
groupCnt := 1
sql := []
__New(gui, height, width) {
this.gui := gui
this.LV := this.gui.addListView("w" width " h" height " Section Count100 -Multi -0x80 vHistoryLV", "Query|Rows")
this.LV.ModifyCol(1, width - 100)
this.LV.ModifyCol(2, "AutoHdr")
SetExplorerTheme(this.LV.hwnd)
LV_EX_EnableGroupView(this.LV.hwnd)
this.hdrHwnd := LV_EX_GetHeader(this.LV.hwnd)
WinSetStyle(-0x80, "ahk_id " this.hdrHwnd)
this.LV.OnEvent("Click", (ctrl, row) => this.SetEditText(ctrl, row))
this.edit := new Scintilla(gui, "wp-" gui.MarginX * 3 " hp ys Border vHistoryEdit", , 0, 0)
setupSciControl(this.edit)
this.edit.SetReadOnly(1)
}
setEditText(ctrl, row) {
this.edit.SetReadOnly(0)
row ? this.edit.SetText("", this.sql[row], 1) : this.edit.ClearAll()
this.edit.SetReadOnly(1)
}
addRow(db, sql, rows) {
if (!this.groups.HasKey(db)) {
LV_EX_GroupInsert(this.LV.hwnd, this.groupCnt, db)
LV_EX_GroupSetState(this.LV.hwnd, this.groupCnt, "Collapsible")
this.groups[db] := this.groupCnt
this.groupCnt++
}
; replace any newlines and following white space with a single space for display in the ListView
noNewLinesSql := RegExReplace(sql, "\R\s*", " ")
rowNum := this.LV.Add("", noNewLinesSql, rows)
this.sql[rowNum] := sql ; store for lookup later to display in readonly Scintilla control
LV_EX_SetGroup(this.LV.hwnd, rowNum, this.groups[db])
}
}