04-03-2019, 07:42 AM
try this
Macro Add autotext
Trigger CSAa
if still having issues i will get back to you after i awaken.
Macro Add autotext
Trigger CSAa
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
_s.getl(_s ii-1)
;3.code:The cursor is positioned
;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)
#sub InsertionPoint
function ~name int&h
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
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] ;;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
if still having issues i will get back to you after i awaken.