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
#53
very good!!!

Your dialog box is very refined. I just found out that I found the error. Please see Figure 1 below.

In addition:

1. I still want to increase the Open AutoText checkbox, but use the hotkey to achieve, Press ctrl+Enter to perform the addition and open the AutoText

2. By default, the first AutoText file is selected,

3. When no acronym is entered, the default output is Text. When no comment is entered, the default output: Description

4. When Template for keyAutoInputDialog is selected, the +inp name button will appear on the left, click on it to generate a field, for example: $inp_***$

see Figure 2 below.


Function Add_AutoText_Dialog_New
Trigger CSAa     Help - how to add the trigger to the macro
Code:
Copy      Help
out
str s.getsel
QMITEM q; int i
ARRAY(str) atn
rep
,i=qmitem(-i 1|16 &q 1)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
_s=atn
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 360 208 "Add AutoText"
;3 Edit 0x54030080 0x200 64 8 287 16 "text" "• text that you must type to execute statements.[]• Can be used any characters, including spaces, tabs and line breaks.[]• Can be used escapesequences.[]"
;4 Edit 0x54231044 0x200 64 32 287 80 "Statements" "statements - []• Full text[]• any commands that you can use in macros.[]• To separate multiple statements, use semicolons.[]"
;9 Button 0x54012003 0x0 64 120 122 10 "Template for KeyAutoInputDialog" "Check here if statement is a Template for KeyAutoInputDialog"
;13 Button 0x54012003 0x0 252 120 99 10 "Multiline/Singleline Autotext" "Click here if statement is for multiline or singleline Autotext(default)"
;12 Edit 0x54030080 0x200 64 136 287 16 "" "A brief explanantion for a popup list when autotext has multiple items of the same Abbreviation[]or when Autotext confirmation option is set"
;5 ComboBox 0x54230243 0x0 64 160 135 213 ""
;6 Static 0x54000000 0x0 8 160 44 16 "Add to:"
;7 Static 0x54000000 0x4 8 8 44 16 "Abbreviation:"
;8 Static 0x54000000 0x4 8 32 44 16 "Statement:"
;11 Static 0x54000000 0x0 8 136 44 16 "Comment:"
;10 Button 0x54030000 0x4 240 184 48 14 "Add"
;14 Button 0x54012003 0x4 224 161 106 10 "Open Autotext (Ctrl+Enter)" "After adding, open the AutoText, or press the hotkey directly: Ctrl+Enter"
;15 Button 0x54032000 0x0 6 68 48 14 "+ inp name"
;2 Button 0x54030000 0x4 304 184 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 4 9 13 12 5 14"
str e3tex e4Sta c9Tem c13Mul e12 cb5 c14Ope
if s.len
,e4Sta=s
c13Mul=1
cb5=_s
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
str cbt
findrx(cb5 "\s[a-zA-Z0-9]{1,100}" 0 1 cbt)
cbt.trim
str Abbreviation=e3tex
str statement=e4Sta
str comment=e12
mac+ cbt
ARRAY(str) atl
if(numlines(statement) >1)
,atl=statement
,for i 0 atl.len
,,atl[i].from(" " atl[i])
,statement=atl
,statement.rtrim
,if(c13Mul=1)
,,statement- "_s= []"
,,statement+ "[]paste _s"
,else
,,atl=statement
,,for i 0 atl.len
,,,atl[i].from(" " atl[i])
,,statement=atl
,,statement.rtrim
,,statement- "_s= [] _s=[] F[]"
,,statement+ "[] KeyAutoInputDialog(_s)[]paste _s"
else
,,statement- "''"
,,statement+ "''"
int h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)
InsertStatement(F"{statement}" comment "" 2)
int r=sub.GetInsertedTextCaretPosition(1)
SendMessage(h SCI.SCI_SETSEL r r+4)
Abbreviation.setclip
SendMessage(h SCI.SCI_PASTE 0 0)
int cp=SendMessage(h SCI.SCI_GETCURRENTPOS 0 0)
cp+7
SendMessage(h SCI.SCI_GOTOPOS cp 0)
#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SendMessage id(3 hDlg) EM_SETCUEBANNER TRUE @"Enter Text"
,SendMessage id(4 hDlg) EM_SETCUEBANNER TRUE @"Enter Statements"
,SendMessage id(12 hDlg) EM_SETCUEBANNER TRUE @"Enter Comment"
,SendMessage id(5 hDlg) CB_SETCUEBANNER 0 @"Select Autotext file to add text to"
,;SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET|TVGN_FIRSTVISIBLE q.htvi
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 10 ;;Add
,DT_Ok hDlg
,case 13 ;;Multiline/Singlelin Autotext
,if but(id(13 hDlg))
,,but- id(9 hDlg)
,case 9 ;;Template for KeyAutoInputDialog
,if but(id(9 hDlg))
,,but- id(13 hDlg)
ret 1

#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-08-2019, 06:59 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)