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
#47
this should cover everything
Function Add_AutoText_dialog
Trigger CSAa     Help - how to add the trigger to the macro
Code:
Copy      Help
out
str s.getsel
;1.code:Get a list of all AutoText files
QMITEM q; int i
ARRAY(str) atn
ARRAY(int) htvi
rep
,i=qmitem(-i 1|16 &q 1|2|4|8)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
,,htvi[]=q.htvi
_s=atn

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 164 234 "Add AutoText" "4"
;3 Edit 0x54030080 0x200 26 19 112 12 ""
;4 Edit 0x54030080 0x200 26 42 112 12 ""
;5 ComboBox 0x54230243 0x0 26 64 112 213 ""
;6 ListBox 0x54230101 0x200 26 84 112 94 ""
;8 Button 0x54012003 0x0 45 186 72 8 "Open after adding"
;1 Button 0x54030001 0x4 26 202 48 14 "OK"
;2 Button 0x54030000 0x4 91 202 48 14 "Cancel"
;7 Button 0x54020007 0x0 8 4 148 222 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""

str controls = "3 4 5 6 8"
str e3 e4 cb5 lb6 c8Ope
e3="Text"
e4="Description"
cb5=_s
lb6=_s
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
str s1 s2
s1=e3
s2=e4
;2.code:Open selected Autotext
;int ii=val(cb5) ;;use cb5
int ii=val(lb6) ;;use lb6
SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET htvi[ii];; opens autotext file selected in dialog
_s.getl(_s ii)
;3.code: find insertion point
int h
sub.InsertionPoint(_s h)
;insert autotext
TO_Fav "TO_Text" 0 0
int w=wait(0 WA win("Text" "#32770"))
but id(6 w) ;;check box 'Multiline'
s.setwintext(id(3 w))
but id(1 w);; close to text window and insert code into autotext function
;4.code:Replace the default Abbreviation with the variable s1, Add a description with the variable s2
wait(0 WD win("Text" "#32770"))
int r=sub.GetInsertedTextCaretPosition(1)
int line=SendMessage(h SCI.SCI_LINEFROMPOSITION r 0)
int lpe=SendMessage(h SCI.SCI_GETLINEENDPOSITION line 0)
SendMessage(h SCI.SCI_SETSEL r lpe)
SendMessage(h SCI.SCI_COPY 0 0)
_s.getclip()
_s.findreplace("text" s1)
_s+ F" ;;{s2}"
_s.setclip
SendMessage(h SCI.SCI_PASTE 0 0)
if(c8Ope=0)
,men 33285 _hwndqm ;;Close active item
,men 33013  _hwndqm ;;Close Qm Window
OnScreenDisplay F"Acronym: {s1} has been added successfully" 2 

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,DT_SetAccelerators(hDlg "400 Ay");; alt+y change to something else if you dont like (alt cannot be used by itself)
,SendMessage id(6 hDlg) LB_SETCURSEL 0 0
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 400
,but* id(8 hDlg);;toggle checkbox
,case LBN_DBLCLK<<16|6
,DT_Ok hDlg
ret 1
#sub InsertionPoint
function ~name int&h
mac+ name
h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)

#sub GetInsertedTextCaretPosition
function# [flags] ;;flags: 1 go to that position
int c=GetQmCodeEditor
SendMessage(c SCI.SCI_UNDO 0 0)
int r=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
SendMessage(c SCI.SCI_REDO 0 0)
if(flags&1) SendMessage(c SCI.SCI_GOTOPOS r 0)
ret r


Messages In This Thread
RE: How to get a list of all AutoText files in the left pane - by Kevin - 04-04-2019, 02:21 PM

Forum Jump:


Users browsing this thread: 4 Guest(s)