Function Notepad_Dialog
Trigger Aw //Notepad_FF
Trigger Aw //Notepad_FF
str- sItems
str- sdItems
sub.DisableEnableAutoText(1 "" sItems sdItems)
QMITEM q q1
int ii i=qmitem(getopt(itemname 0) 1 &q 1|32)
str filterName= q.filter
ARRAY(str) atn
rep
,ii=qmitem(-ii 1|16 &q1 1|32)
,if(ii=0) break
,if q1.itype=4
,,if q1.filter=filterName
,,,atn[]=q1.name
str names=atn; names.rtrim
str at=sub.atList(names)
ARRAY(str) aList=at
IQmDropdown ddl
int inERS
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x8 0 0 184 16 "Notepad_AutoText" "4"
;3 Edit 0x54030080 0x200 0 0 184 16 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""
str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
str textEnd subNum a ss
findrx(e3 "\-\s\d+\s(.*)$" 0 1 textEnd 1)
findrx(e3 "\-\s(\d+)" 0 1 subNum 1)
int subn=val(subNum)
foreach ss names
,_s.getmacro(ss)
,findrx(_s F"(?s)#sub Sub{subn} m(.+?)#sub Sub" 0 1 a 1)
,if !a.len
,,findrx(_s F"(?s)#sub Sub{subn} m(.*)$" 0 1 a 1)
,if a=textEnd
,,break
if(a.len)
,RunTextAsMacro a.trim
else
,out "not Found"
#sub DlgProc
function# hDlg message wParam lParam
str- sItems
str- sdItems
sel message
,case WM_INITDIALOG
,__Font-- f.Create("Consolas" 14 0)
,f.SetDialogFont(hDlg "3")
,str- selected
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,sub.DisableEnableAutoText(2 sdItems)
,case IDCANCEL
,sub.DisableEnableAutoText(3 sdItems)
,case EN_CHANGE<<16|3 sub.OnTextChanged lParam
ret 1
#sub atList
function~ str'name
str pattern="(?m)(^.+) :sub.Sub\d+ ;;(.+)"
str d ss
int i
ARRAY(str) a
foreach ss name
,_s.getmacro(ss 0)
,findrx(_s pattern 0 4 a)
,for i 0 a.len
,,d.formata("%s - %s[]" a[1 i].trim a[2 i].trim)
ret d.rtrim
#sub OnTextChanged v
function hEdit
if(inERS) ret
if(ddl) ddl.Close; ddl=0
str s.getwintext(hEdit)
if(!s.len) ret
ICsv x._create
x.AddRow1(0 "")
int i
for i 0 aList.len
,if(find(aList[i] s 0 1)<0) continue
,x.AddRow1(-1 aList[i])
if(!x.RowCount) ret
if(ShowDropdownList(x i 0 1 hEdit 0 0 0 ddl)&QMDDRET_SELOK=0) ret
s=x.Cell(i+1 0)
inERS=1
EditReplaceSel hEdit 0 s 1|2|4
inERS=0
#sub DisableEnableAutoText
function mode [str'dati] [str&atItems] [str&atditems]
QMITEM q; int i j k
ARRAY(str) atn atd
rep
,i=qmitem(-i 1|16 &q 1|4|32)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
,,sel mode
,,,case 1
,,,if(dis(q.name))
,,,,atd[]=q.name
,,,else
,,,,if(q.programs or q.filter)
,,,,,dis+ q.name
,,,case else
,,,int fdat=findw(dati q.name 0 "[]")
,,,if fdat = -1
,,,,dis- q.name