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
#52
your idea is indeed not simpler but will make it more complicated. Let qm figure out subfunction numbers it does it automatically already. We can however get rid of the text dialog.

I created a new dialog
looks like this

   

has multiline edit control for autotext statements. can be either normal or multiline autotext or can use it for making a template for keyAutoInput
still can can be launched by ctrl+shift+alt+a
will check if active window has selection and paste it into
multiline edit in dialog
template just needs the template code nothing else no leading space

Dear Mr. $inp_Customer$,

thank you for contacting us. The price is $$inp_Price$. Let's meet next $inp_Day$.

Myfile is here "$inp_Filepath$"

Thanks and best regards,
$set_CaretHere$

pcname is $var_pcname$

$var_ShortDate$

the dialog will add the remaining code needed to create the  autotext for the template


here try this out
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"
;2 Button 0x54030000 0x4 304 184 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""

str controls = "3 4 9 13 12 5"
str e3tex e4Sta c9Tem c13Mul e12 cb5
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


Messages In This Thread
RE: How to get a list of all AutoText files in the left pane - by Kevin - 04-08-2019, 05:07 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)