12-08-2022, 12:21 PM (This post was last modified: 12-08-2022, 12:22 PM by Davider.)
Hi,
In the following example, some subfunctions have "one" or "two" in their comments
I want to find them by searching and then execute the subfunction of the selected item
I wrote the following code, but there are still three features that are not implemented
For better expression, I recorded the demo in the picture below
;Note: ;When Notepad window opens, pressing hotkey Alt+W will popping up this dialog, Because it uses a filter function Notepad_FF
;Todo1: ;There are also two AutoText files use filter function Notepad_FF, Notepad_1 and Notepad_2, get all the items inside them ;Tip: In actual use, need to get all items in AutoText files that uses the same filtering function as the dialog ;The following code only gets the items in the Notepad_1 file, How to get another?(uses same filtering function as the dialog)
sel message ,caseWM_INITDIALOG ,;Todo2: ,;How to temporarily disable AutoText files except AT1 (because AT1 use global trigger $t) ,;to prevent others AutoText list popping up when typing ,;In this example, the files that should be disabled are: AT2, Notepad_1, Notepad_2 (They not use global trigger $t) , ,__Font-- f.Create("Consolas"140) ,f.SetDialogFont(hDlg "3") ,caseWM_DESTROY ,caseWM_COMMANDgoto messages2 ret ;messages2 sel wParam ,caseIDOK ,;Todo3 ,;How to execute the selected item's subfunction when the dialog box is closed , ,caseIDCANCEL , ,caseEN_CHANGE<<16|3sub.OnTextChanged lParam ret1
#sub atList function~str'name
str pattern="(?m)(^.+) :sub.Sub\d+ ;;(.+)"
_s.getmacro(name 0) str d int i ARRAY(str) a findrx(_s pattern 04 a) for i 0 a.len ,d.formata("%s - %s[]" a[1 i].trim a[2 i].trim) ret d
#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 01)<0)continue ,x.AddRow1(-1 aList[i]) if(!x.RowCount)ret
if(ShowDropdownList(x i 01 hEdit 000 ddl)&QMDDRET_SELOK=0)ret
s=x.Cell(i+10)
str pattern="(?m)(^.+) :sub.Sub\d+ ;;(.+)" str d ss int i ARRAY(str) a foreach ss name ,_s.getmacro(ss 0) ,findrx(_s pattern 04 a) ,for i 0 a.len ,,d.formata("%s - %s[]" a[1 i].trim a[2 i].trim) ret d.rtrim
for Todo3
you cannot call autotext code from other macros or functions
_s= ;/b/i/c/m ;aa :sub.Sub1 ;;1 one a ;bb :sub.Sub2 ;;2 one b ;cc :sub.Sub3 ;;3 two c ;dd :sub.Sub4 ;;4 two d ; ;#sub Sub1 m ;"one a" ; ;#sub Sub2 m ;"one b" ; ;#sub Sub3 m ;"two c" ; ;#sub Sub4 m ;"two d"
ARRAY(str) a findrx(_s "(?s)#sub Sub1 m(.+?)#sub Sub"01 a)
12-09-2022, 09:17 AM (This post was last modified: 12-09-2022, 09:24 AM by Davider.)
This is a very useful feature, Because, sometimes abbreviations can get forgotten,
After pressing the space bar, all the items can be displayed, and search items by abbreviations and comments are supported
But executing the code in the subfunctions is a challenge
str pattern="(?m)(^.+) :sub.Sub\d+ ;;(.+)" str d ss int i ARRAY(str) a foreach ss name ,_s.getmacro(ss 0) ,findrx(_s pattern 04 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 01)<0)continue ,x.AddRow1(-1 aList[i]) if(!x.RowCount)ret if(ShowDropdownList(x i 01 hEdit 000 ddl)&QMDDRET_SELOK=0)ret
s=x.Cell(i+10)
inERS=1 EditReplaceSel hEdit 0 s 1|2|4
inERS=0
12-10-2022, 04:19 AM (This post was last modified: 12-10-2022, 04:24 AM by Davider.)
@Kevin
thank you so much, Your programming level is fantastic!
I want to continue refining the subfunction OnTextChanged
1.How to make the first item always selected?(Same as AutoText list)
2.After selecting the item, press enter, directly execute(Automatically closes the dialog), no need to press enter key again
3.Press the right mouse button on the item to locate the position of the subfunction and flash it
#sub LvSelect function hlv item [flags] ;;flags: 1 don't deselect previous, 2 don't set focus, 4 ensure visible, 8 deselect
;Selects listview item. ;To select none, use item -1. ;To select all, use item -1 and flag 8. ;Note that listview controls with LVS_SINGLESEL style can have max 1 item selected.