View Issue Details

IDProjectCategoryView StatusLast Update
0003334Far Manager_Commonpublic2016-10-22 14:38
ReporterAleXH Assigned Tozg  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Platformx86OSWindowsOS VersionXP SP2
Summary0003334: С 4809 поломана работа скрипта по раскрашиванию пробельных символов и кириллицы.
DescriptionРепостинг с ru-board

-- Автор 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! 
         if ei 
           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 length<RightBorder 
                   editor.AddColor ei.EditorID,ii,length+1,length+2,0,Colors[1][2],190,colorguid 
                 for i=1,#Colors 
                   sEnd=RealLeftPos 
                   while sEnd<RightBorder 
                     sBegin,sEnd,_,s2=Colors[i][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

Открываем в редакторе текст, F3 (исполняем скрипт) - всё ок. CtrlTab возвращаемся в панели F4 на другом файле, запускаем скрипт - не работает. в 4807 всё работает.
TagsNo tags attached.
Build0

Activities

zg

2016-10-22 14:37

developer   bugnote:0014943

всё работает, как просили. если хочется, чтобы работало как хочется:
- ei=editor.GetInfo!
+ ei=editor.GetInfo id

Issue History

Date Modified Username Field Change
2016-10-22 12:21 AleXH New Issue
2016-10-22 14:37 zg Note Added: 0014943
2016-10-22 14:38 zg Build => 0
2016-10-22 14:38 zg Status new => closed
2016-10-22 14:38 zg Assigned To => zg
2016-10-22 14:38 zg Resolution open => no change required