#sub gotoitemedit function~~name str pattern="(?m)^(.+\s\:.+)"
_s.getmacro(name 0) str ss d int i ARRAY(str) a findrx(_s pattern 04 a) for i 0 a.len ,d.formata("%s[]" a[0 i]) ret d.trim
#sub FlashCodeLine function line hce if(!hce) hce=GetQmCodeEditor int indicator=9 SendMessage(hce SCI.SCI_SETINDICATORCURRENT indicator 0) SendMessage(hce SCI.SCI_INDICSETALPHA indicator 100) SendMessage(hce SCI.SCI_INDICSETFORE indicator 0x00FF00) SendMessage(hce SCI.SCI_INDICSETSTYLE indicator SCI.INDIC_STRAIGHTBOX) SendMessage(hce SCI.SCI_INDICSETUNDER indicator TRUE) int lsp=SendMessage(hce SCI.SCI_POSITIONFROMLINE line 0) int lep=SendMessage(hce SCI.SCI_GETLINEENDPOSITION line 0) rep4 ,SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp) ,0.25 ,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp) ,0.25 SendMessage(hce SCI.SCI_SETINDICATORCURRENT00)
#sub EditSubclassProc function# hWnd message wParam lParam int cid=GetDlgCtrlID(hWnd) int Phwnd=GetParent(hWnd) ;OutWinMsg message wParam lParam sel message ,caseWM_DESTROY ,caseWM_GETDLGCODE ,sel wParam ,,caseVK_RETURN ,,retDLGC_WANTALLKEYS ,caseWM_CHAR ,sel wParam ,,caseVK_RETURN ,,sel cid ,,,case [3,5] ,,,ret0 ,caseWM_KEYDOWN ,sel wParam ;;virtual key code ,,caseVK_RETURN ,,;on enter in the edit box select the item in the list box ,,sel cid ,,,case3 ,,,SendMessage Phwnd WM_COMMANDLBN_SELCHANGE<<16|GetDlgCtrlID(id(4 Phwnd))id(4 Phwnd) ,,,case5 ,,,SendMessage Phwnd WM_COMMANDLBN_DBLCLK<<16|GetDlgCtrlID(id(6 Phwnd))id(6 Phwnd) ,,ret ,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT] ,,;relay these keys to the listbox and not to the edit box ,,sel cid ,,,case3 ,,,SendMessageid(4 Phwnd) message wParam lParam ,,,case5 ,,,SendMessageid(6 Phwnd) message wParam lParam ,,ret
05-01-2019, 05:11 AM (This post was last modified: 05-01-2019, 06:01 AM by win.)
OK, now it’s successful. thanks a lot I can't all use the keyboard to open the AutoText item. Enter key is invalid
My steps are as follows
1. type t2
2. Press tab three times
3. Press the arrow keys to select an item
4. Enter (now is invalid)
Please see the picture below
In addition,I need to close the dialog box after pressing the Enter key in the fourth step.
I think the Enter key has to be handled a lot, it is a bit difficult
#sub gotoitemedit function~~name str pattern="(?m)^(.+\s\:.+)"
_s.getmacro(name 0) str ss d int i ARRAY(str) a findrx(_s pattern 04 a) for i 0 a.len ,d.formata("%s[]" a[0 i]) ret d.trim
#sub FlashCodeLine function line hce if(!hce) hce=GetQmCodeEditor int indicator=19 SendMessage(hce SCI.SCI_SETINDICATORCURRENT indicator 0) SendMessage(hce SCI.SCI_INDICSETALPHA indicator 100) SendMessage(hce SCI.SCI_INDICSETFORE indicator 0x00FF00) SendMessage(hce SCI.SCI_INDICSETSTYLE indicator SCI.INDIC_STRAIGHTBOX) SendMessage(hce SCI.SCI_INDICSETUNDER indicator TRUE) int lsp=SendMessage(hce SCI.SCI_POSITIONFROMLINE line 0) int lep=SendMessage(hce SCI.SCI_GETLINEENDPOSITION line 0) rep4 ,SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp) ,0.25 ,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp) ,0.25 SendMessage(hce SCI.SCI_SETINDICATORCURRENT00)
int Phwnd=GetParent(hwnd) ;OutWinMsg message wParam lParam sel message ,caseWM_GETDLGCODE ,sel(wParam)caseVK_RETURNret DLGC_WANTALLKEYS ;;send WM_KEYDOWN instead of closing the dialog ,caseWM_CHAR ,sel(wParam)caseVK_RETURNret0 ,caseWM_KEYDOWN ,sel wParam ;;virtual key code ,,caseVK_RETURN ,,;on enter in the edit box select the item in the list box ,,sel uIdSubclass ,,,case3 ,,,SendMessage Phwnd WM_COMMANDLBN_SELCHANGE<<16|GetDlgCtrlID(id(4 Phwnd))id(4 Phwnd) ,,,case5 ,,,SendMessage Phwnd WM_COMMANDLBN_DBLCLK<<16|GetDlgCtrlID(id(6 Phwnd))id(6 Phwnd) ,,ret ,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT] ,,;relay these keys to the listbox and not to the edit box ,,sel uIdSubclass ,,,case3 ,,,SendMessageid(4 Phwnd) message wParam lParam ,,,case5 ,,,SendMessageid(6 Phwnd) message wParam lParam ,,ret
int R=DefSubclassProc(hwnd message wParam lParam)
sel message ,caseWM_NCDESTROY ,RemoveWindowSubclass(hwnd &sub.EditSubclassProc uIdSubclass)
sel message ,caseWM_GETDLGCODE ,sel(wParam)caseVK_RETURNret DLGC_WANTALLKEYS ;;send WM_KEYDOWN instead of closing the dialog ,caseWM_KEYDOWN ,sel(wParam)caseVK_RETURNSendMessageGetParent(hwnd)WM_COMMANDLBN_DBLCLK<<16|uIdSubclass hwnd;ret
int R=DefSubclassProc(hwnd message wParam lParam)
sel message ,caseWM_NCDESTROY ,RemoveWindowSubclass(hwnd &sub.ListBoxSubclassProc uIdSubclass)
#sub gotoitemedit function~~name str pattern="(?m)^(.+\s\:.+)"
_s.getmacro(name 0) str ss d int i ARRAY(str) a findrx(_s pattern 04 a) for i 0 a.len ,d.formata("%s[]" a[0 i]) ret d.trim
#sub FlashCodeLine function line hce if(!hce) hce=GetQmCodeEditor int indicator=19 SendMessage(hce SCI.SCI_SETINDICATORCURRENT indicator 0) SendMessage(hce SCI.SCI_INDICSETALPHA indicator 100) SendMessage(hce SCI.SCI_INDICSETFORE indicator 0x00FF00) SendMessage(hce SCI.SCI_INDICSETSTYLE indicator SCI.INDIC_STRAIGHTBOX) SendMessage(hce SCI.SCI_INDICSETUNDER indicator TRUE) int lsp=SendMessage(hce SCI.SCI_POSITIONFROMLINE line 0) int lep=SendMessage(hce SCI.SCI_GETLINEENDPOSITION line 0) rep4 ,SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp) ,0.25 ,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp) ,0.25 SendMessage(hce SCI.SCI_SETINDICATORCURRENT00)
int Phwnd=GetParent(hwnd) ;OutWinMsg message wParam lParam sel message ,caseWM_GETDLGCODE ,sel(wParam)caseVK_RETURNretDLGC_WANTALLKEYS;;send WM_KEYDOWN instead of closing the dialog ,caseWM_CHAR ,sel(wParam)caseVK_RETURNret0 ,caseWM_KEYDOWN ,sel wParam ;;virtual key code ,,caseVK_RETURN ,,;on enter in the edit box select the item in the list box ,,sel uIdSubclass ,,,case3 ,,,SendMessage Phwnd WM_COMMANDLBN_SELCHANGE<<16|GetDlgCtrlID(id(4 Phwnd))id(4 Phwnd) ,,,case5 ,,,SendMessage Phwnd WM_COMMANDLBN_DBLCLK<<16|GetDlgCtrlID(id(6 Phwnd))id(6 Phwnd) ,,ret ,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT] ,,;relay these keys to the listbox and not to the edit box ,,sel uIdSubclass ,,,case3 ,,,SendMessageid(4 Phwnd) message wParam lParam ,,,case5 ,,,SendMessageid(6 Phwnd) message wParam lParam ,,ret
int R=DefSubclassProc(hwnd message wParam lParam)
sel message ,caseWM_NCDESTROY ,RemoveWindowSubclass(hwnd &sub.EditSubclassProc uIdSubclass)
sel message ,caseWM_GETDLGCODE ,sel(wParam)caseVK_RETURNretDLGC_WANTALLKEYS;;send WM_KEYDOWN instead of closing the dialog ,caseWM_KEYDOWN ,sel(wParam)caseVK_RETURNSendMessageGetParent(hwnd)WM_COMMANDLBN_DBLCLK<<16|uIdSubclass hwnd;ret
int R=DefSubclassProc(hwnd message wParam lParam)
sel message ,caseWM_NCDESTROY ,RemoveWindowSubclass(hwnd &sub.ListBoxSubclassProc uIdSubclass)
sel message ,caseWM_INITDIALOG ,SendMessageid(3 hDlg)EM_SETCUEBANNERTRUE@"Enter Text" ,SendMessageid(4 hDlg)EM_SETCUEBANNERTRUE@"Enter Statements" ,SendMessageid(12 hDlg)EM_SETCUEBANNERTRUE@"Enter Comment" ,SendMessageid(5 hDlg)CB_SETCUEBANNER0@"Select Autotext file to add text to" ,DT_SetAccelerators(hDlg "400 Az") ,caseWM_DESTROY ,caseWM_COMMANDgoto messages2 ret ;messages2 sel wParam ,caseCBN_EDITCHANGE<<16|5 ,sub.CB_AutoComplete lParam ,caseIDOK ,caseIDCANCEL ,case10;;Add ,DT_Ok hDlg ,case13;;Multiline/Singlelin Autotext ,hidid(15 hDlg) ,hidid(16 hDlg) ,hidid(17 hDlg) ,case9;;Template for KeyAutoInputDialog ,hid-id(15 hDlg) ,hid-id(16 hDlg) ,hid-id(17 hDlg) ,case [15,400];;+ inp_name ,_s.getsel(00id(4 hDlg)) ,if _s.len ,,str s.from("$inp_" _s "$") ,,s.setsel(0id(4 hDlg)) ,else ,,mes"You must first select a word in the edit box" ,case16;;+ sel_name ,str aid_sel=sub.Get_AID_sel_AID_var("sel") ,_i=ListDialog(aid_sel "Select an option from the list below""AID_sel") ,if(_i=0)ret ,aid_sel.getl(aid_sel _i-1) ,actid(4 hDlg) ,paste aid_sel ,case17;;+ var_name ,str aid_var=sub.Get_AID_sel_AID_var("var") ,_i=ListDialog(aid_var "Select an option from the list below""AID_var") ,if(_i=0)ret ,aid_var.getl(aid_var _i-1) ,actid(4 hDlg) ,paste aid_var ,case14;;Edit Existing Autotext ,0; ,sub.LaunchEditDialog ret1
#sub GetInsertedTextCaretPosition function# [flags] ;;flags: 1 go to that position int c=GetQmCodeEditor SendMessage(c SCI.SCI_UNDO00) int r=SendMessage(c SCI.SCI_GETCURRENTPOS00) SendMessage(c SCI.SCI_REDO00) if(flags&1)SendMessage(c SCI.SCI_GOTOPOS r 0) ret r
#sub CB_AutoComplete function hcb
ifk(B)ret ifk(X)ret str s ss;int i
s.getwintext(hcb) if(s.len) ,i=CB_FindItem(hcb s) ,if(i>=0) ,,CB_GetItemText(hcb i ss) ,,if(ss.len>s.len) ,,,ss.setwintext(hcb) ,,,SendMessage(hcb CB_SETEDITSEL0 ss.len<<16|s.len) #sub Get_AID_sel_AID_var function~~option str oName pattern sel option ,case"sel" ,oName="AID_sel" ,pattern="\$(?:sel)_(.+?)\$" ,case"var" ,oName="AID_var" ,pattern="\$(?:var)_(.+?)\$"
_s.getmacro(oName 0) str ss d int i ARRAY(str) aid_S foreach ss _s ,findrx(ss pattern 04 aid_S) ,for i 0 aid_S.len ,,d.formata("%s[]" aid_S[0 i]) ret d.trim
#sub check_for_comment function curPos h ~comment str s ss if(!h); h=GetQmCodeEditor int line=SendMessage(h SCI.SCI_LINEFROMPOSITION curPos 0) SendMessage(h SCI.SCI_GOTOLINE line 0) int sp=SendMessage(h SCI.SCI_POSITIONFROMLINE line 0); int ep=SendMessage(h SCI.SCI_GETLINEENDPOSITION line 0) int ll=ep-sp
s.fix(SendMessage(h SCI.SCI_GETLINE line s.all(ll+1)))
s.trim if(findrx(s ";;")<0) ,ss.from(";;" comment) ,SendMessage(h SCI.SCI_GOTOPOS ep 0) ,SendMessage(h SCI.SCI_INSERTTEXT-1 ss)
#sub FlashCodeLine function curPos hce if(!hce) hce=GetQmCodeEditor int indicator=9 int line=SendMessage(hce SCI.SCI_LINEFROMPOSITION curPos 0) SendMessage(hce SCI.SCI_SETINDICATORCURRENT indicator 0) SendMessage(hce SCI.SCI_INDICSETALPHA indicator 100) SendMessage(hce SCI.SCI_INDICSETFORE indicator 0x00FF00) SendMessage(hce SCI.SCI_INDICSETSTYLE indicator SCI.INDIC_STRAIGHTBOX) SendMessage(hce SCI.SCI_INDICSETUNDER indicator TRUE) int lsp=SendMessage(hce SCI.SCI_POSITIONFROMLINE line 0) int lep=SendMessage(hce SCI.SCI_GETLINEENDPOSITION line 0) rep4 ,SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp) ,0.25 ,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp) ,0.25 SendMessage(hce SCI.SCI_SETINDICATORCURRENT00)
sel message ,caseWM_INITDIALOG ,SendMessageid(3 hDlg)EM_SETCUEBANNERTRUE@"Enter Text" ,SendMessageid(4 hDlg)EM_SETCUEBANNERTRUE@"Enter Statements" ,SendMessageid(12 hDlg)EM_SETCUEBANNERTRUE@"Enter Comment" ,SendMessageid(5 hDlg)CB_SETCUEBANNER0@"Select Autotext file to add text to" ,DT_SetAccelerators(hDlg "400 Az") ,SetWindowSubclass(id(16 hDlg)&sub.Btn_SubclassProc160) ,SetWindowSubclass(id(17 hDlg)&sub.Btn_SubclassProc170) ,caseWM_DESTROY ,caseWM_COMMANDgoto messages2 ret ;messages2 sel wParam ,caseCBN_EDITCHANGE<<16|5 ,sub.CB_AutoComplete lParam ,caseIDOK ,caseIDCANCEL ,case10;;Add ,DT_Ok hDlg ,case13;;Multiline/Singlelin Autotext ,hidid(15 hDlg) ,hidid(16 hDlg) ,hidid(17 hDlg) ,case9;;Template for KeyAutoInputDialog ,hid-id(15 hDlg) ,hid-id(16 hDlg) ,hid-id(17 hDlg) ,case [15,400];;+ inp_name ,_s.getsel(00id(4 hDlg)) ,if _s.len ,,str s.from("$inp_" _s "$") ,,s.setsel(0id(4 hDlg)) ,else ,,mes"You must first select a word in the edit box" ,case16;;+ sel_name ,str aid_sel=sub.Get_AID_sel_AID_var("sel") ,_i=ListDialog(aid_sel "Select an option from the list below""AID_sel") ,if(_i=0)ret ,aid_sel.getl(aid_sel _i-1) ,actid(4 hDlg) ,paste aid_sel ,case17;;+ var_name ,str aid_var=sub.Get_AID_sel_AID_var("var") ,_i=ListDialog(aid_var "Select an option from the list below""AID_var") ,if(_i=0)ret ,aid_var.getl(aid_var _i-1) ,actid(4 hDlg) ,paste aid_var ,case14;;Edit Existing Autotext ,0; ,sub.LaunchEditDialog ret1
#sub GetInsertedTextCaretPosition function# [flags] ;;flags: 1 go to that position int c=GetQmCodeEditor SendMessage(c SCI.SCI_UNDO00) int r=SendMessage(c SCI.SCI_GETCURRENTPOS00) SendMessage(c SCI.SCI_REDO00) if(flags&1)SendMessage(c SCI.SCI_GOTOPOS r 0) ret r
#sub CB_AutoComplete function hcb
ifk(B)ret ifk(X)ret str s ss;int i
s.getwintext(hcb) if(s.len) ,i=CB_FindItem(hcb s) ,if(i>=0) ,,CB_GetItemText(hcb i ss) ,,if(ss.len>s.len) ,,,ss.setwintext(hcb) ,,,SendMessage(hcb CB_SETEDITSEL0 ss.len<<16|s.len) #sub Get_AID_sel_AID_var function~~option str oName pattern sel option ,case"sel" ,oName="AID_sel" ,pattern="\$(?:sel)_(.+?)\$" ,case"var" ,oName="AID_var" ,pattern="\$(?:var)_(.+?)\$"
_s.getmacro(oName 0) str ss d int i ARRAY(str) aid_S foreach ss _s ,findrx(ss pattern 04 aid_S) ,for i 0 aid_S.len ,,d.formata("%s[]" aid_S[0 i]) ret d.trim
#sub check_for_comment function curPos h ~comment str s ss if(!h); h=GetQmCodeEditor int line=SendMessage(h SCI.SCI_LINEFROMPOSITION curPos 0) SendMessage(h SCI.SCI_GOTOLINE line 0) int sp=SendMessage(h SCI.SCI_POSITIONFROMLINE line 0); int ep=SendMessage(h SCI.SCI_GETLINEENDPOSITION line 0) int ll=ep-sp
s.fix(SendMessage(h SCI.SCI_GETLINE line s.all(ll+1)))
s.trim if(findrx(s ";;")<0) ,ss.from(";;" comment) ,SendMessage(h SCI.SCI_GOTOPOS ep 0) ,SendMessage(h SCI.SCI_INSERTTEXT-1 ss)
#sub FlashCodeLine function curPos hce if(!hce) hce=GetQmCodeEditor int indicator=9 int line=SendMessage(hce SCI.SCI_LINEFROMPOSITION curPos 0) SendMessage(hce SCI.SCI_SETINDICATORCURRENT indicator 0) SendMessage(hce SCI.SCI_INDICSETALPHA indicator 100) SendMessage(hce SCI.SCI_INDICSETFORE indicator 0x00FF00) SendMessage(hce SCI.SCI_INDICSETSTYLE indicator SCI.INDIC_STRAIGHTBOX) SendMessage(hce SCI.SCI_INDICSETUNDER indicator TRUE) int lsp=SendMessage(hce SCI.SCI_POSITIONFROMLINE line 0) int lep=SendMessage(hce SCI.SCI_GETLINEENDPOSITION line 0) rep4 ,SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp) ,0.25 ,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp) ,0.25 SendMessage(hce SCI.SCI_SETINDICATORCURRENT00)
05-12-2019, 03:36 AM (This post was last modified: 05-12-2019, 03:37 AM by win.)
It is best to add the code to restart QM after the code, because sometimes the newly added item display position cannot be refreshed. and Memory cannot be released
After adding the autotext, it will be in the last position
Before the Add AutoText dialog box is opened, the memory requirement is about 4M. After the addition, the memory will increase to about 10M. I added the restart QM command. Without these problems.
05-12-2019, 09:50 PM (This post was last modified: 05-12-2019, 09:55 PM by Kevin.)
I'm sorry i do not have the same result as you. Memory on my pc is released when the dialog closes. autotext items are placed where they are coded t be placed. any newly created autotext function i can move to any place no problem.
no idea what you mean by this
"the newly added item display position cannot be refreshed"
06-20-2019, 09:26 AM (This post was last modified: 06-20-2019, 09:49 AM by win.)
@Kevin
Hello, I have been using the above features, it feels very good, I found three areas for improvement, I haven't solved them yet, can you help me? Thanks a lot. the attachment is related files
1. The newly added AutoText file will be displayed at the end, restart QM, it will be displayed at the top.
2. Cannot add phrases to the correct AutoText file (When the file prefix is the same)
3. When adding a phrase with the same acronym, I need to sort (When the phrase is added, judge it, if there is the same acronym, sort it)