local Code=[[ local patt=regex.new("<\\/?\\w+","ix") local s=editor.GetStringW() if not s then return end local pos,pEnd = editor.GetInfo().CurPos,s.StringLength+1 if pos>pEnd then return elseif pos==pEnd then pos=pos-1 end local text,start = s.StringText.."\0",1 while true do local b,e = patt:findW(text,start) if b==nil or b>pos then break elseif e>=pos then _G.LFSTag={Num=1} _G.LFSTag.Txt=win.Utf16ToUtf8(win.subW(text,b+1,e)) _G.LFSTag.Tag=_G.LFSTag.Txt:match("%w+$") break end start=e+1 end local Data={ sSearchPat="<(/?".._G.LFSTag.Tag..")[ >]", sReplacePat="if T[1]==_G.LFSTag.Txt then _G.LFSTag.Num=_G.LFSTag.Num+1 elseif T[1]:match('%w+$')==_G.LFSTag.Tag then _G.LFSTag.Num=LFSTag.Num-1 end if _G.LFSTag.Num==0 then return true,true end", sRegexLib="pcre", bRegExpr=true, bSearchBack=_G.LFSTag.Txt~=_G.LFSTag.Tag, bRepIsFunc=true, bConfirmReplace=true, fUserChoiceFunc=function() return "cancel" end } lfsearch.EditorAction("test:replace",Data) return Data.bSearchBack ]] --<div><div><div><table><tr><td></td><td><p></p></td></tr></table></div></div></div> local LFS_Guid="8E11EA75-0303-4374-AC60-D1E38F865449" Macro { description="Goto Begin<=>End of Html Tags"; area="Editor"; key="AltM"; action=function() local bSearchBack=Plugin.Call(LFS_Guid,"code",Code) if bSearchBack then Keys("Right") else Keys("2*Left") end end } |