-- Автор zg, соавтор AleXH. -- Страница скрипта: http://forum.ru-board.com/topic.cgi?forum=5&topic=48136&start=960#17 -- прототип: http://forum.farmanager.com/viewtopic.php?f=60&t=8674 F=far.Flags editors={} Colors={ regex.new "/(\\s+?)(\\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} } colorguid=win.Uuid "F4B5E624-16F6-4243-9A3D-763097C72EAA" 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 count,ttime0,ttime1=0,0,0 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 ttime=far.FarClock! count=count+1 if ttime-ttime1>8000 --block other redraw events 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)-1 gsw=editor.GetStringW(ei.EditorID,ii) line=gsw.StringText length=gsw.StringLength if RealLeftPos<=length RightBorder=RealLeftPos+ei.WindowSizeX if RightBorder>length editor.AddColor ei.EditorID,ii,length+1,length+2,0,Colors[2],190,colorguid for i=1,#Colors/2 sEnd=RealLeftPos while sEnd<RightBorder sBegin,sEnd,_,s2=Colors[i*2-1]\findW line,sEnd+1 if sEnd if s2~="" sEnd=sEnd-1 sEnd=math.min sEnd,RightBorder editor.AddColor ei.EditorID,ii,sBegin,sEnd,0,Colors[i*2],190,colorguid else break ttime0=ttime0+far.FarClock!-ttime ttime1=far.FarClock! 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] count,ttime0=0,0 editors[id]= start:0 finish:0 -- editor.Redraw! Editor.Set 20,1 msgbox "count: "..count,"time: "..ttime0 else ProcessColors id,(data)-> data.start=1 data.finish=1 editors[id]=nil -- editor.Redraw! Editor.Set 20,0 msgbox "count: "..count,"time: "..ttime0 |