-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathclass_tableListMod (2).ahk
59 lines (49 loc) · 1.54 KB
/
class_tableListMod (2).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
48
49
50
51
52
53
54
55
56
57
58
59
; Modification class for parsing lists.
class TableListMod {
debugNoRecurse := true
debugName := "TableListMod"
mod := ""
bit := 1
start := 1
len := 0
text := ""
label := 0
operation := ""
__New(m, s, l, t, a, o) {
this.mod := m
this.start := s
this.len := l
this.text := t
this.label := a
this.operation := o
}
; Actually do what this mod describes to the given row.
executeMod(rowBits) {
; For 'insert' operation - insert a blank slate at the given spot, but still operate on that spot.
if(this.operation = "i")
rowBits.insert(this.bit, "")
rowBit := rowBits[this.bit]
startOffset := endOffset := 0
if(this.len > 0) {
endOffset := this.len
} else if(this.len < 0) {
startOffset := this.len
}
rowBitLen := StrLen(rowBit)
if(this.start > 0) {
startLen := this.start - 1
} else if(this.start < 0) {
startLen := rowBitLen + this.start + 1
} else {
startLen := rowBitLen // 2
}
outBit := SubStr(rowBit, 1, startLen + startOffset) . this.text . SubStr(rowBit, (startLen + 1) + endOffset)
; DEBUG.popup(rowBits, "Row to apply to", this, "Mod applied", rowBit, "On row bit", outBit, "Finished bit", startLen, "Start len", startOffset, "Start offset", startLen + 1, "Start len + 1", endOffset, "End offset")
; Put the bit back into the full row.
rowBits[this.bit] := outBit
return rowBits
}
toDebugString() {
return "Mod: " this.mod "`nBit: " this.bit "`nStart: " this.start "`nLength: " this.len "`nText: " this.text "`nLabel: " this.label "`nOperation: " this.operation
}
}