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
lol yeah forgot about that

there ya go complete with flashing

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 0x54012009 0x0 64 120 122 10 "Template for KeyAutoInputDialog" "Check here if statement is a Template for KeyAutoInputDialog"
;13 Button 0x54012009 0x0 248 120 103 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 0x54230242 0x0 64 160 135 213 ""
;6 Static 0x54000000 0x0 8 160 44 16 "Add to:"
;7 Static 0x54000000 0x4 8 8 48 16 "Abbreviation:"
;8 Static 0x54000000 0x4 8 32 44 16 "Statement:"
;11 Static 0x54000000 0x0 8 136 44 16 "Comment:"
;15 Button 0x44030F00 0x0 6 50 48 14 "+ inp_name"
;16 Button 0x44030F00 0x4 6 71 48 14 "+ sel_name"
;17 Button 0x44032000 0x4 6 92 48 14 "+ var_name"
;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 o9Tem o13Mul e12 cb5
if s.len
,e4Sta=s
o13Mul=1
cb5=_s
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
str cbt
findrx(cb5 "\s[\x80-\xff]+|\s[a-zA-Z0-9]+" 0 1 cbt)
cbt.trim
str result=val(cb5)
if(result =-1)
,int ni=newitem(cbt "/b/i/c/m" "Autotext" "$t" "" 4)
str Abbreviation=iif((e3tex=" "or empty(e3tex)) "Text" e3tex) 
str comment=iif((e12=" "or empty(e12)) "Description" e12)
str statement=e4Sta
mac+ cbt
err
,mac+ ni
ARRAY(str) atl
if(numlines(statement) >1)
,atl=statement
,for i 0 atl.len
,,atl[i].from(" " atl[i])
,statement=atl
,statement.rtrim
,if(o13Mul=1)    
,,statement- "_s= []"
,,statement+ "[]paste _s"
,else
,,statement- "_s=[]F[]"
,,statement+ "[]PasteAutoInputDialog(_s)"        
else
,,if(o13Mul=1)
,,,statement- "''"
,,,statement+ "''"
,,else
,,,atl=statement
,,,for i 0 atl.len
,,,,atl[i].from(" " atl[i])
,,,statement=atl
,,,statement.rtrim
,,,statement- "_s=[]F[]"
,,,statement+ "[]PasteAutoInputDialog(_s)"            
int h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)
InsertStatement(statement comment "" 2)
int r
if(result != -1)
,r=sub.GetInsertedTextCaretPosition(1)
else
,SendMessage(h SCI.SCI_GOTOLINE 1 0)
,r=SendMessage(h SCI.SCI_GETCURRENTPOS 0 0)
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)
sub.check_for_comment(cp h comment)
cp+7
SendMessage(h SCI.SCI_GOTOPOS cp 0)
sub.FlashCodeLine(cp h)
#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"
,DT_SetAccelerators(hDlg "400 Az")
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case CBN_EDITCHANGE<<16|5
,sub.CB_AutoComplete lParam    
,case IDOK
,case IDCANCEL
,case 10 ;;Add
,DT_Ok hDlg
,case 13 ;;Multiline/Singlelin Autotext
,hid id(15 hDlg)
,hid id(16 hDlg)
,hid id(17 hDlg) 
,case 9 ;;Template for KeyAutoInputDialog
,hid- id(15 hDlg)
,hid- id(16 hDlg)
,hid- id(17 hDlg)
,case [15, 400];;+ inp_name
,_s.getsel(0 0 id(4 hDlg))
,if _s.len
,,str s.from("$inp_" _s "$")
,,s.setsel(0 id(4 hDlg))
,else
,,mes "You must first select  a word in the edit box"
,case 16 ;;+ sel_name
,str aid_sel=sub.Get_AID_sel_AID_var("sel")
,_i=ListDialog(aid_sel "Select an  option from the list below" "AID_sel")
,if(_i=0) ret
,aid_sel.getl(aid_sel _i-1)
,act id(4 hDlg)
,paste aid_sel
,case 17 ;;+ var_name
,str aid_var=sub.Get_AID_sel_AID_var("var")
,_i=ListDialog(aid_var "Select an  option from the list below" "AID_var")
,if(_i=0) ret
,aid_var.getl(aid_var _i-1)
,act id(4 hDlg)
,paste aid_var
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

#sub CB_AutoComplete
function hcb

ifk(B) ret
ifk(X) ret
str s ss; int i
s.getwintext(hcb)
if(s.len)
,i=CB_FindItem(hcb s)
,if(i>=0)
,,CB_GetItemText(hcb i ss)
,,if(ss.len>s.len)
,,,ss.setwintext(hcb)
,,,SendMessage(hcb CB_SETEDITSEL 0 ss.len<<16|s.len)
#sub Get_AID_sel_AID_var
function~ ~option 
str oName pattern
sel option
,case "sel"
,oName="AID_sel"
,pattern="\$(?:sel)_(.+?)\$"
,case "var"
,oName="AID_var"
,pattern="\$(?:var)_(.+?)\$"    
_s.getmacro(oName 0)
str ss d
int i
ARRAY(str) aid_S
foreach ss _s
,findrx(ss pattern 0 4 aid_S)
,for i 0 aid_S.len
,,d.formata("%s[]" aid_S[0 i])
ret d.trim

#sub check_for_comment
function curPos h ~comment 
str s ss
if(!h); h=GetQmCodeEditor
int line=SendMessage(h SCI.SCI_LINEFROMPOSITION curPos 0)
SendMessage(h SCI.SCI_GOTOLINE line 0) 
int sp=SendMessage(h SCI.SCI_POSITIONFROMLINE line 0);
int ep=SendMessage(h SCI.SCI_GETLINEENDPOSITION line 0)
int ll=ep-sp
s.fix(SendMessage(h SCI.SCI_GETLINE line s.all(ll+1)))
s.trim
if(findrx(s ";;") <0)
,ss.from(";;" comment)
,SendMessage(h SCI.SCI_GOTOPOS ep 0)
,SendMessage(h SCI.SCI_INSERTTEXT -1 ss)

#sub FlashCodeLine
function curPos hce
if(!hce) hce=GetQmCodeEditor
int indicator=9
int line=SendMessage(hce SCI.SCI_LINEFROMPOSITION curPos 0)
SendMessage(hce SCI.SCI_SETINDICATORCURRENT indicator 0)
SendMessage(hce SCI.SCI_INDICSETALPHA indicator 100)
SendMessage(hce SCI.SCI_INDICSETFORE indicator 0x00FF00)
SendMessage(hce SCI.SCI_INDICSETSTYLE indicator SCI.INDIC_STRAIGHTBOX)
SendMessage(hce SCI.SCI_INDICSETUNDER indicator TRUE)
int lsp=SendMessage(hce SCI.SCI_POSITIONFROMLINE line 0)
int lep=SendMessage(hce SCI.SCI_GETLINEENDPOSITION line 0)
rep 4
,SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp)
,0.25
,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp)
,0.25
SendMessage(hce SCI.SCI_SETINDICATORCURRENT 0 0)


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

Forum Jump:


Users browsing this thread: 2 Guest(s)