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
#17
this should do what ya need . Finds insertion position so no need to open the AutoText file and position cursor

Macro Add autotext
Trigger CSAa     Help - how to add the trigger to the macro
Code:
Copy      Help
out
str s.getsel
str s1 ;;string variable. If need numeric, replace str with int or double.
if(!inp(s1 "Enter AutoText Abbreviation" "" "text")) ret
str s2 ;;string variable. If need numeric, replace str with int or double.
if(!inp(s2 "Enter a phrase description" "" "description")) ret

;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
int ii=ListDialog(_s); if(ii=0) ret
;2.code:Open selected Autotext
SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET htvi[ii-1];; opens autotext file selected in list dialog
;3.code:The cursor is positioned at the end of the last AutoText field
_s.getl(_s ii-1)
;find insertion point
sub.InsertionPoint(_s)
;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 h
int r=sub.GetInsertedTextCaretPosition(1 h)
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)

#sub InsertionPoint 
function ~name
int i = qmitem(name)
_s.getmacro(i)
str ss
int ii ln pos lpe
foreach ss _s
,if ss.beg("#sub")
,,ln= ii-1
,,break
,ii+1
mac+ name
int h=GetQmCodeEditor
if ln>0
,pos=SendMessage(h SCI.SCI_POSITIONFROMLINE ln 0)
,lpe=SendMessage(h SCI.SCI_GETLINEENDPOSITION ln 0)
,SendMessage(h SCI.SCI_GOTOPOS lpe 0)
,act h
else
,pos=SendMessage(h SCI.SCI_POSITIONFROMLINE ii 0)
,lpe=SendMessage(h SCI.SCI_GETLINEENDPOSITION ii 0)
,SendMessage(h SCI.SCI_GOTOPOS lpe 0)    
,act h
,key Y           ;; Enter

#sub GetInsertedTextCaretPosition
function# [flags][&c];;flags: 1 go to that position
if(!c)
,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-03-2019, 05:23 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)