Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » FAR Manager (часть 5)

Модерирует : gyra, Maz

Maz (15-01-2020 17:38): FAR Manager (часть 6)  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

Alexyz21



Silver Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
local Code=[[
_G.LFSTag=nil
local patt=regex.new("<\\/?(?:\\w+?|xsl:\\w+?-?\\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={}
    --_G.LFSTag={Num=win.subW(text,pos,pos)=='\60\0' and 0 or 1}
    --far.Message("b="..b.."\npos="..pos)
    _G.LFSTag.Txt=win.Utf16ToUtf8(win.subW(text,b,e-1))
    _G.LFSTag.Rev=_G.LFSTag.Txt:sub(2,2)=='/'
    _G.LFSTag.Num=b==pos and not _G.LFSTag.Rev and 0 or 1
    _G.LFSTag.Tag=_G.LFSTag.Rev and '<'.._G.LFSTag.Txt:sub(3,-1) or _G.LFSTag.Txt
    break
  end
  start=e+1
end
if not _G.LFSTag then return end
--far.Message("Txt=".._G.LFSTag.Txt.."\nTag=".._G.LFSTag.Tag)
 
local Data={
  sSearchPat="(</?(?:\\w+?|xsl:\\w+?-?\\w+?))[ >]",
  sReplacePat="if T[1]==_G.LFSTag.Txt then _G.LFSTag.Num=_G.LFSTag.Num+1 elseif (T[1]:sub(2,2)=='/' and '<'..T[1]:sub(3,-1) or T[1])==_G.LFSTag.Tag then _G.LFSTag.Num=LFSTag.Num-1 end if _G.LFSTag.Num==0 then return true,true end",
  sRegexLib="oniguruma", --"far" (default), "oniguruma", "pcre" or "pcre2"
  bRegExpr=true,
  bSearchBack=_G.LFSTag.Rev,
  bRepIsFunc=true,
  bConfirmReplace=true,
  fUserChoiceFunc=function() return "cancel" end
}
 
local nFound,nReps = lfsearch.EditorAction("test:replace",Data)
return _G.LFSTag.Num,_G.LFSTag.Rev,nFound,nReps
]]
 
--<div><div><font><p></p></font></div></div>
--<xsl:when test=""><xsl:apply-templates select=""><xsl:sort select="" /></xsl:apply-templates></xsl:when>
 
local LFS_Guid="8E11EA75-0303-4374-AC60-D1E38F865449"
Macro {
  description="Goto Begin<=>End of Tags";
  area="Editor"; key="AltM";
  action=function()
    --local ttime=far.FarClock()
    local Num,Rev,nFound,nReps = Plugin.SyncCall(LFS_Guid,"code",Code)
    --ttime = far.FarClock()-ttime
    --far.Message("Num="..tostring(Num).."\nRev="..tostring(Rev).."\nnFound="..tostring(nFound).."\nnReps"..tostring(nReps))
    if Num==0 and not Rev then Keys("Left") end
    --local report="Time: "..ttime.." mcs"
    --far.Message(report,"Report",nil,"l")
  end
}

Всего записей: 3485 | Зарегистр. 16-06-2007 | Отправлено: 12:25 22-09-2019 | Исправлено: Alexyz21, 14:48 22-09-2019
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » FAR Manager (часть 5)
Maz (15-01-2020 17:38): FAR Manager (часть 6)


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru