-- Автор zg, соавтор AleXH. -- Страница скрипта: http://forum.farmanager.com/viewtopic.php?f=60&t=8674 F=far.Flags editors={} Colors={ regex.new "/(\\s+)/" {Flags:bit64.bor F.FCF_FG_4BIT,F.FCF_BG_4BIT ForegroundColor:0x9 BackgroundColor:0x1} regex.new "/([а-яёА-ЯЁ]+)/" {Flags:bit64.bor F.FCF_FG_4BIT,F.FCF_BG_4BIT ForegroundColor:0xe BackgroundColor:0xc} regex.new [[/([-+*:.,;!?~@#$%^&\\\/]+)/]] {Flags:bit64.bor F.FCF_FG_4BIT,F.FCF_BG_4BIT ForegroundColor:0xf BackgroundColor:0x1} } Comment=regex.new "/^.*?\\-{2}/" colorguid=win.Uuid "F4B5E624-16F6-4243-9A3D-763097C72EAA" ffi=require "ffi" GetSubStringW=(EditorId,StringNumber,Start,Length)-> ec=ffi.cast("struct PluginStartupInfo*",far.CPluginStartupInfo!).EditorControl egs=ffi.new "struct EditorGetString" egs.StructSize=ffi.sizeof egs egs.StringNumber=StringNumber-1 ss,fLength="",0 if ec(EditorId,"ECTL_GETSTRING",0,egs)~=0 fLength=egs.StringLength if Start<=fLength Length=math.min Length,fLength-Start+1 ss=ffi.string egs.StringText+Start-1,Length*2 ss,fLength GetEditorData=(id)-> data=editors[id] if not data editors[id]= start:0 finish:0 data=editors[id] data RemoveColors=(id,data)-> for ii=data.start,data.finish editor.DelColor id,ii,0,colorguid ProcessColors=(id,update)-> data=GetEditorData id RemoveColors id,data update data Event group:"EditorEvent" condition:(id,event,param)-> return editors[id] action:(id,event,param)-> if event==F.EE_CLOSE editors[id]=nil if event==F.EE_REDRAW ei=editor.GetInfo! ProcessColors ei.EditorID,(data)-> data.start=ei.TopScreenLine data.finish=math.min ei.TopScreenLine+ei.WindowSizeY,ei.TotalLines for ii=data.start,data.finish RealLeftPos=editor.TabToReal ei.EditorID,ii,ei.LeftPos line,fLength=GetSubStringW ei.EditorID,ii,RealLeftPos,ei.WindowSizeX line2=Comment\matchW line for i=1,#Colors/2 if line2 and i>1 then line=line2 sEnd=0 while sEnd sBegin,sEnd=Colors[i*2-1]\findW line,sEnd+1 if sEnd editor.AddColor ei.EditorID,ii,RealLeftPos+sBegin-1,RealLeftPos+sEnd-1,0,Colors[i*2],190,colorguid editor.AddColor ei.EditorID,ii,fLength+1,fLength+2,0,Colors[2],190,colorguid Event group:"ExitFAR" action:-> wincount=far.AdvControl F.ACTL_GETWINDOWCOUNT,0,0 for ii=1,wincount info=far.AdvControl F.ACTL_GETWINDOWINFO,ii,0 if info and F.WTYPE_EDITOR==info.Type ProcessColors info.Id,(data)-> data.start=0 data.finish=0 Macro description:"Подсветка кириллицы и пробельных символов" area:"Editor" key:"F3" action:-> id = editor.GetInfo(-1).EditorID if not editors[id] editors[id] = start:0 finish:0 editor.Redraw! Editor.Set 20,1 else ProcessColors id,(data)-> data.start=1 data.finish=1 editors[id] = nil Editor.Set 20,0 |