-
Notifications
You must be signed in to change notification settings - Fork 72
/
class_CHotstringOptions.ahk
75 lines (56 loc) · 1.78 KB
/
class_CHotstringOptions.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class CHotstringOptions
{
static DefaultOptions := {"RequireEndChar":true, "CaseSensitive":false, "ConformToTypedCase":true, "OmitEndChar":true, "StartAnywhere":false, "DeleteHotstring":true, "Raw":true}
static optionNameString := "StartAnywhere,DeleteHotstring,OmitEndChar,ConformToTypedCase,CaseSensitive,RequireEndChar,Raw"
static StartAnywhere := 1
static DeleteHotstring := 2
static OmitEndChar := 4
static ConformToTypedCase := 8
static CaseSensitive := 16
static RequireEndChar := 32
static Raw := 64
static Default := 110
; Does x contain n: (x & n) = n
; Include n into x: x |= n
; Exclude n from x: x & n = n ? x ^= n
ToOptions(x)
{
y := 0
optionString := CHotstringOptions.optionNameString
for k, v in x
{
if k not in %optionString%
continue
if(v)
{
;~ OutputDebug, % "Append " CHotstringOptions[k]
y |= CHotstringOptions[k]
}
}
return y
}
ToHotstring(x)
{
if(x & 16 = 16 && x & 8 = 8) ; Exclude CaseSensitive if ConformToTypedCase is set
x ^= 16
if (x & 4 = 4 && x & 32 <> 32) ; Exclude OmitEndingCharacter if RequireEndingCharacter is not set
x ^= 4
y := {"RequireEndChar":false, "CaseSensitive":false, "ConformToTypedCase":false, "OmitEndChar":false, "StartAnywhere":false, "DeleteHotstring":false, "Raw":false}
if(x & 1 = 1)
y.StartAnywhere := true
if(x & 2 = 2)
y.DeleteHotstring := true
if(x & 4 = 4)
y.OmitEndChar := true
if(x & 8 = 8)
y.ConformToTypedCase := true
if(x & 16 = 16)
y.CaseSensitive := true
if(x & 32 = 32)
y.RequireEndChar := true
if(x & 64 = 64)
y.Raw := true
; OutputDebug % "HSC: OEC = " y.OmitEndChar
return y
}
}