local Code=[[ local F=far.Flags local LFSTag={} local patt=regex.new("<\\/?\\w+","ix") local GetTag=function() 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 local txt while true do local b,e = patt:findW(text,start) if b==nil or b>pos then break elseif e>=pos then LFSTag.Num=1 LFSTag.Txt=win.Utf16ToUtf8(win.subW(text,b+1,e)) LFSTag.Tag=LFSTag.Txt:match("%w+$") break end start=e+1 end end local Data={ sSearchPat="<(/?\\w+)[ >]", sReplacePat="if T[1]==LFSTag.Txt then LFSTag.Num=LFSTag.Num+1 elseif T[1]:match('%w+$')==LFSTag.Tag then LFSTag.Num=LFSTag.Num-1 end if LFSTag.Num==0 then return true,true end", sRegexLib="pcre", bRegExpr=true, bRepIsFunc=true, bConfirmReplace=true, fUserChoiceFunc=function() return "cancel" end } GetTag() far.Message("Txt="..LFSTag.Txt.."\nTag="..LFSTag.Tag,"") Data.bSearchBack=LFSTag.Txt~=LFSTag.Tag lfsearch.EditorAction("test:replace",Data) --local EGI=editor.GetInfo() --local PosData={ -- CurLine =EGI.CurLine, -- CurPos =EGI.CurPos, -- CurTabPos =EGI.CurTabPos, -- TopScreenLine =EGI.TopScreenLine, -- LeftPos =EGI.LeftPos, -- Overtype =EGI.Overtype --} -- --if Data.bSearchBack --then PosData.CurPos=PosData.CurPos-0 --else PosData.CurPos=PosData.CurPos+0 --end --editor.SetPosition(nil,PosData) ]] --<div><div><p></p></div></div> Macro { description="Goto begin-end of Html Tags"; area="Editor"; key="AltM"; action=function() local LFS_Guid="8E11EA75-0303-4374-AC60-D1E38F865449" Plugin.Call(LFS_Guid,"code",Code) end } |