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
#21
I added an input box, In the input dialog, I added two ways to display the AutoText.

One is the combo box. In this way, after selecting the item, you need to press the ok button.

One is a list box. In this way, after double-clicking the project, execute it directly.  How to achieve?  Huh

Exclamation I have an idea:

When the AutoText file is opened, the insertion point is always positioned immediately at the beginning of the second line. Please see the position of the image below.

In this way, the newly added phrase is always at the top and there will never be an unknown error. Smile

The newly added phrase is always at the top, very convenient to view. At present, I don't understand the main code. Can you help me to modify it? thank you very much
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


str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 150 210 "Dialog" "4"
;3 Edit 0x54030080 0x200 28 19 96 12 ""
;4 Edit 0x54030080 0x200 28 42 96 12 ""
;5 ComboBox 0x54230243 0x0 28 64 96 213 ""
;6 ListBox 0x54230101 0x200 28 84 96 90 ""
;1 Button 0x54030001 0x4 24 182 48 14 "OK"
;2 Button 0x54030000 0x4 80 182 48 14 "Cancel"
;7 Button 0x54020007 0x0 8 4 134 198 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 4 5 6"
str e3 e4 cb5 lb6
e3="text"
e4="description"
str s1 s2
s1=e3
s2=e4
_s=atn
cb5=_s
lb6=_s
if(!ShowDialog(dd 0 &controls)) ret

;2.code:Open selected Autotext
;int ii=ListDialog(_s); if(ii=0) ret
;SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET htvi[ii-1];; opens autotext file selected in list dialog
;_s.getl(_s ii-1)
int ii=val(cb5)
SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET htvi[ii];; opens autotext file selected in dialog
_s.getl(_s ii)
;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


Attached Files Image(s)
   


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

Forum Jump:


Users browsing this thread: 2 Guest(s)