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
I have an idea, I don't know if I can achieve it,

When the dialog is open,

When I press the alt key, the checkbox is selected, press again to deselect Exclamation

Simple dialog code

Macro Add autotext
Trigger CSAa     Help - how to add the trigger to the macro
Copy      Help
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
,i=qmitem(-i 1|16 &q 1|2|4|8)
,if(i=0) break
,if q.itype=4

str dd=
;0 "" 0x90C80AC8 0x0 0 0 164 234 "Dialog" "4"
;2 Button 0x54030000 0x4 91 202 48 14 "Cancel"
;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"
;7 Button 0x54020007 0x0 8 4 148 222 ""
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 4 5 6 8"
str e3 e4 cb5 lb6 c8Ope

if(!ShowDialog(dd 0 &controls)) ret

str s1 s2
;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) ;;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: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.findreplace("text" s1)
_s+ F" ;;{s2}"
SendMessage(h SCI.SCI_PASTE 0 0)
,men 33285 _hwndqm ;;Close active item
,men 33013  _hwndqm ;;Close Qm Window

#sub InsertionPoint
function ~name int&h
;int i = qmitem(name)
;str ss
;int ii ln pos lpe
;foreach ss _s
,;if ss.beg("#sub")
,,;ln= ii-1
;mac+ name
;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
,;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
mac+ name
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

Three feature requests:

1. Edit box defaults to focus

2. The first AutoText project defaults to focus

3. Press the alt key to set the checkbox status.

Using the tree directory, I feel it may be more troublesome. I have an idea now, it might be simpler to implement.

by default,
The list box shows all AutoText items.
Combo box displays all AutoText folders

When I select an AutoText folder, the AutoText file in it is displayed in the list box.

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, 06:48 AM

Forum Jump:

Users browsing this thread: 3 Guest(s)