-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconstTypES.ahk
138 lines (129 loc) · 5.18 KB
/
constTypES.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#Requires AutoHotKey 2.1-alpha.4
#include <str> ; string helper functions
class lytTypES { ; Typographic layout
static __new() { ; store all layers in a Map, TypES['base']['en'] would be base qwerty labels
static k := keyConstant._map, lbl := keyConstant._labels ; various key name constants, gets vk code to avoid issues with another layout
, s := helperString
static TypES := Map() ; actual base and other symbol layers
TypES.CaseSense := 0 ;
; Define layout
; to exclude a key from the binding map:
; key : use literal space
; left-most key : (like Q in qwerty), remove LTrim, but then make sure to align everything vertically to the first non-space char in the first row (`) as AHK trims only the same amount of spaces like in the first row
; right-most key : (and avoid text editor cutting off spaces) split into multiple strings :(
; ` : might have to add all spaces manually or replace ` after setting up a layer
this._map := TypES
TypES['base'] := lbl
TypES['⎇›'] := Map('en',"
( Join ` LTrim
`¹²³$‰↑§∞←→—≠
⎋∑€®™¥ѵіѳ′[]÷
≈§°£π₽„“”‘’
Ωש↓߶−«»⁄
)"
,'ru',"
( Join ` LTrim
~¹²³$‰↑&∞←→—≠
⎋∑€®™¥ѵіѳ′[]÷
≈§°£π₽„“”‘’
Ωש↓߶−«»/
)"
)
; typographic⁄≠/ macOS / is ÷
; replaced ⸮ with ‹
TypES['‹⎈⎇›'] :=TypES['⎇›'] ; for AltGr
TypES['⇧›⎇›'] := Map('en',"
( Join ` LTrim
`¡½⅓¼‱ˆ¿·‹›–±
˘⇥⇪˚℃ѢѴІѲ˝{}⧵
⌥⇧⌀℉₴⌘✓√λ¨'
¸✗¢ˇẞ˜•<>´
)"
,'ru',"
( Join ` LTrim
`¡½⅓¼‱ˆ¿·‹›–±
˘⇥⇪˚℃ѢѴІѲ˝{}⧵
⌥⇧⌀℉₴⌘✓√λ¨'
¸✗¢ˇẞ˜•<>´
)"
; ↓ order doesn't matter since this is matched by label match, not position
,'🕱',"
( Join ` LTrim
` 6
q r
h ;
z v n /
)"
)
;‹→⸮
;🙂→⧵
;macOS '= (Apple symbol)
;macOS . are „“
;
TypES['‹⎈⇧›⎇›'] :=TypES['⇧›⎇›'] ; for AltGr
TypES['☰'] := Map('en',
"`` ="
"{☰ \"
"½ '"
"⎈ "
,'ru',
"`` ="
"{☰ \"
"½ '"
"☰ "
)
TypES['‹⎈☰'] :=TypES['☰'] ; for AltGr
; ————— Fill helper map of labels to symbols
keys_m := Map() ; map of labels to symbols for each layer
,keys_m.CaseSense := 0 ; make key matching case insensitive
,pre_layers := Map( '⇧›⎇›','' ,'⎇›','' ,'☰','&'
,'‹⎈⇧›⎇›','' ,'‹⎈⎇›','' ) ; AltGr adds ‹⎈
,keys_m['en'] := Map()
,keys_m['en'].CaseSense := 0 ; make key matching case insensitive
,keys_m['ru'] := Map()
,keys_m['ru'].CaseSense := 0 ; make key matching case insensitive
this._keys_m := keys_m
this._pre := pre_layers
bir_labels_en := TypES['base']['en']
bir_labels_ru := TypES['base']['ru']
dbgtxt := '', dbgcount := 0
for pre,is⅋ in pre_layers { ; ⇧›⎇› or ⎇›
; dbgTT(0,pre,t:=3) ;
; dbgtxt .= (pre='☰') ? pre '`tpre' '`n' : ''
keys_m['en'][pre] := Map()
keys_m['ru'][pre] := Map()
keys_m['en'][pre].CaseSense := 0 ; make key matching case insensitive
keys_m['ru'][pre].CaseSense := 0
sym_en_list := TypES[pre]['en']
sym_ru_list := TypES[pre]['ru']
sym🕱lbl_list := TypES[pre].Get('🕱','')
; dbgtxt .= 'sym🕱lbl_list ' sym🕱lbl_list '`n'
if not StrLen(bir_labels_en) = StrLen(bir_labels_ru) {
throw ValueError("TypES's labels lists should have the same length", -1)
}
loop StrLen(bir_labels_en) {
label_en := SubStr(bir_labels_en,A_Index,1)
label_ru := SubStr(bir_labels_ru,A_Index,1)
if inStr(sym🕱lbl_list, label_en) { ; skip deadkeys defined in the keyboard key list above
; dbgtxt .= '🕱' label_en
; dbgtxt .= (Mod(dbgcount, 10) = 0) ? '`n' : ' ', dbgcount += 1 ; insert a newline every X keys
continue
} else { ;
sym_en := SubStr(sym_en_list,A_Index,1) ; ˘
sym_ru := SubStr(sym_ru_list,A_Index,1) ; ˘
keys_m['en'][pre][label_en] := sym_en ; [⇧›⎇›][q] = ˘
keys_m['ru'][pre][label_ru] := sym_ru ; [⇧›⎇›][й] = ˘
if pre == '☰' {
; dbgtxt .= label_en sym_en ' '
; dbgtxt .= label_ru sym_ru ' '
; dbgtxt .= (Mod(dbgcount, 10) = 0) ? '`n' : ' ', dbgcount += 1 ; insert a newline every X keys
}
}
} ; msgbox(pre '`n' bir_labels_en '`n' sym_en_list)
}
; ar1 := keys_m['en']['⇧›⎇›']
; ar2 := keys_m['ru']['⎇›']
; dbgtxt2 := ar1['w'] '`t' ar2['б'] '`t' ar2['ю'] '`t' ar2['.'] '`n' bir_labels_en '`n' sym_en_list
; msgbox(dbgtxt2); dbgTT(0, 'constTypES`n' dbgtxt,t:=5)
}
}