-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathreadHotkeys.ahk
28 lines (27 loc) · 982 Bytes
/
readHotkeys.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
readHotkeys(filepath,retObj:=0){
local
comment:=0,hlObj:={}
static regExN:={singleComment:"^\s{0,};",blockComment:"^\s{0,}/\*",blockCommentEnd:"^\s{0,}\*/",directive:"i)^\s{0,}#if",hotskey:"::"}
rFile:=fileOpen(filepath,"r")
while(!rFile.atEOF){
cLine:=rFile.readLine()
if(comment || cLine~=regExN.singleComment){ ; inside block comment/single-line comment
if(cLine~=regExN.blockCommentEnd) ; check for end block comment
comment:=0
continue
}else if(cLine~=regExN.blockComment){ ; check for block comment
comment:=1
continue
}else if(cLine~=regExN.directive || cLine~=regExN.hotskey){ ; get if-directive/get hotstring/hotkey (literal)
if(retObj)
hlObj[a_index]:=cLine
strOut.=a_index . a_tab . cLine
}
}
rFile.close()
if(retObj){
hlObj.str:=strOut
return hlObj
}
return strOut
}