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
#81
I tried to add the code to the edit button  Smile

But there are three problems  Huh
1. No comments are displayed in the list
2. The row of the positioning subfunction is not at the top (How to make the line where the anchor point is displayed at the top of the editor and highlight it)
3. I can't use the list box continuously for positioning. For example, I first locate sub1 and then locate sub2. These need to close the dialog and reopen.



Macro Macro6
Trigger AV     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"
;14 Button 0x54032000 0x0 214 160 41 14 "Edit"
;2 Button 0x54030000 0x4 304 184 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

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[\u4e00-\u9fa5_a-zA-Z0-9]{1,100}" 0 1 cbt)
findrx(cb5 "\s[\x80-\xff]+|\s[a-zA-Z0-9]+" 0 1 cbt) ;;
;findrx(cb5 "\s[a-zA-Z0-9]{1,100}" 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(F"{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)
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"
,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
,
,case 14 ;;Edit
,_s.getwintext(id(5 hDlg))
,str items=sub.gotoitemedit(_s)
,_i=ListDialog(items "Which item to Edit" "Select item")-1
,if(_i<0) ret
,mac+ _s
,int c=GetQmCodeEditor
,SendMessage(c SCI.SCI_GOTOPOS a[0 _i].cpMin 0)
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 gotoitemedit
function~ ~name
str s.getmacro(name 0); if(!s.len) ret

ARRAY(CHARRANGE)+ a; int i
if(0=findrx(s "(?m)^(?:#sub +(\w+))" 0 4 a)) ret

str items t
for i 0 a.len
,int isBM=s[a[0 i].cpMin]!='#'
,CHARRANGE& r=a[1+isBM i]
,int n=r.cpMax-r.cpMin; if(n>0) t.get(s r.cpMin n); t.trim; else t=""
,items.formata("%i %s[]" isBM t)

ret items


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

Forum Jump:


Users browsing this thread: 31 Guest(s)