read qm help for findrx
findrx
ARRAY(CHARRANGE)result receives start and end offsets of the match and submatches. The CHARRANGE type is used to store start and end positions of a substring in a string.
type CHARRANGE cpMin cpMax
cpMin - start of substring (match or submatch) in string. It is 0-based index of first character of substring in string.
cpMax - end of substring.
offset=cpMin
length=cpMax-cpMin
i changed some of the variable names so it hopefully makes more sense to you now
findrx
ARRAY(CHARRANGE)result receives start and end offsets of the match and submatches. The CHARRANGE type is used to store start and end positions of a substring in a string.
type CHARRANGE cpMin cpMax
cpMin - start of substring (match or submatch) in string. It is 0-based index of first character of substring in string.
cpMax - end of substring.
offset=cpMin
length=cpMax-cpMin
i changed some of the variable names so it hopefully makes more sense to you now
int SelectionEndPosition
str s=sub.getAutotextItem("At" SelectionEndPosition)
ARRAY(str) a=s
a.sort(2)
s=a
;;code: Write the sort result to the original file
mac+ "At"
int h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)
int SelectionStartPosition=SendMessage(h SCI.SCI_GETCURRENTPOS 0 0)
SendMessage(h SCI.SCI_SETSEL SelectionStartPosition SelectionEndPosition)
s.setclip
SendMessage(h SCI.SCI_PASTE 0 0)
#sub getAutotextItem
function~ ~name &EndPosition
str pattern="(?m)^(.+\s\:.+)"
_s.getmacro(name 0);
ARRAY(CHARRANGE) a; int i
findrx(_s pattern 0 4 a)
str items t
for i 0 a.len
,int StartPosition(a[0 i].cpMin) length(a[0 i].cpMax-a[0 i].cpMin)
,t.get(_s StartPosition length)
,items.formata("%s[]" t.trim)
,EndPosition=a[0 i].cpMax
ret items