Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get a list of all AutoText files in the left pane
@kevin
The following code for Autotext item management. It is useful when there are many items in the Autotext.

I can filters Autotext . I can use Arrow key selection , Enter key or double-click to open the AutoText.

But I don't know how to add filtering to AutoText items.  The items is always changing

In addition, if I Enter some acronyms for AutoText in the edit box of the AutoText item, a menu will pop up, how to disable it.



Macro AT item mg
Code:
Copy      Help
out
QMITEM q; int i
ARRAY(str) aaut
rep
,i=qmitem(-i 2 &q 1)
,if(i=0) break
,sel q.itype
,,case 4
,,aaut[]=q.name
str asaut=aaut

str dd=
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 212 178 "AT item mg"
;8 Edit 0x54030080 0x204 7 22 96 14 ""
;9 Edit 0x54030080 0x204 108 22 96 14 ""
;11 ListBox 0x54230101 0x204 7 37 96 120 ""
;12 ListBox 0x54230101 0x204 108 37 96 120 ""
;14 Static 0x54000000 0x0 38 8 48 12 "AutoText"
;15 Static 0x54000000 0x0 133 8 48 12 "AutoText item"
;16 Static 0x54000000 0x0 27 163 168 12 "AutoText And item: Enter or Double click to Open"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "8 9 11 12"
str e8 e9 lb11 lb12
lb11=asaut ;;autotext list

if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc v
function# hDlg message wParam lParam

;messages
sel message
,case WM_INITDIALOG
,SetProp id(8 hDlg) "wndproc" SubclassWindow((id(8 hDlg)) &sub.EditSubclassProc) ;;E8 Use arrow keys
,
,case WM_DESTROY
,RemoveProp id(8 hDlg) "wndproc" ;;remove prop on dialog close
,
,case WM_COMMAND goto messages2
,case WM_TIMER
,sel wParam
,,case 1 ;;e8 autotext filter to lb11
,,KillTimer hDlg wParam
,,int hlb11=id(11 hDlg)
,,SendMessage hlb11 LB_RESETCONTENT 0 0
,,str s8 se8.getwintext(id(8 hDlg)) 
,,foreach s8 lb11
,,,if(se8.len and find(s8 se8 0 1)<0) continue
,,,LB_Add hlb11 s8
ret

;messages2
sel wParam
,case EN_CHANGE<<16|8 ;;e8 autotext
,SetTimer hDlg 1 100 0
,
,case LBN_DBLCLK<<16|11 ;;lb11 autotext open
,hlb11=id(11 hDlg)
,LB_SelectedItem(hlb11 _s)
,mac+ _s
,
,case LBN_SELCHANGE<<16|11 ;;lb11 autotext item show
,str slb11
,LB_SelectedItem(lParam slb11)
,str slb12 aslb12=sub.gotoitemedit(slb11)
,;mes aslb12
,int hlb12=id(12 hDlg) 
,SendMessage(hlb12 LB_RESETCONTENT 0 0)
,aslb12.findreplace(":sub.Sub" "   ")
,aslb12.findreplace(";;" "   ")
,;mes aslb12
,foreach slb12 aslb12
,,LB_Add(hlb12 slb12)
,
,case LBN_DBLCLK<<16|12 ;;lb12 autotext item open
,str _slb12 _slb11
,_i=LB_SelectedItem(lParam _slb12)
,LB_SelectedItem id(11 hDlg) _slb11 
,mac+ _slb11
,int hQCE=GetQmCodeEditor
,SendMessage(hQCE SCI.SCI_GOTOLINE _i+1 0)
,int i=findrx(_slb12 "\d" 0 1)
,int cp=SendMessage(hQCE SCI.SCI_GETCURRENTPOS 0 0)
,cp+i+2
,SendMessage(hQCE SCI.SCI_GOTOPOS cp 0)
,
,case IDOK
,case IDCANCEL
ret 1

#sub EditSubclassProc
function# hWnd message wParam lParam
int cid=GetDlgCtrlID(hWnd)
int Phwnd= GetParent(hWnd)
;OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,
,case WM_GETDLGCODE
,sel wParam
,,case VK_RETURN
,,ret DLGC_WANTALLKEYS
,
,case [WM_KEYDOWN,WM_KEYUP]
,sel wParam ;;virtual key code
,,case VK_RETURN
,,;on enter in the edit box select the item in the list box
,,sel cid
,,,case 8
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(11 Phwnd)) id(11 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
,,,case 8
,,,SendMessage id(11 Phwnd) message wParam lParam
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)

#sub gotoitemedit
function~ ~name

str pattern="(?:.*\:sub\..*)"

_s.getmacro(name 0)
str ss d
int i
ARRAY(str) a
findrx(_s pattern 0 4 a)
for i 0 a.len
,d.formata("%s[]" a[0 i])

ret d.trim


Messages In This Thread
RE: How to get a list of all AutoText files in the left pane - by win - 04-28-2019, 02:17 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)