как-то так.AleXH wrote:Так, так , так... Пожалуйста, развейте тему - подсветить в смешанном тексте всю кириллицу. Без колорера, а скриптом.
- F=far.Flags
- editors={}
- color=
- Flags:bit64.bor F.FCF_FG_4BIT,F.FCF_BG_4BIT
- ForegroundColor:0x1
- BackgroundColor:0xe
- colorguid=win.Uuid "1687B745-233F-4c33-AA46-3A39E67B0170"
- word=regex.new "/\\b(\\i+)\\b/"
- rus=
- match:regex.new "/[а-яёА-ЯЁ]*([a-zA-Z]+[а-яёА-ЯЁ]+)+[a-zA-Z]*/"
- find:regex.new "/([а-яёА-ЯЁ]+)/"
- 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"
- action:(id,event,param)->
- if event==F.EE_READ
- editors[id]=
- start:0
- finish:0
- if event==F.EE_CLOSE
- editors[id]=nil
- if event==F.EE_REDRAW then
- 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
- line=editor.GetString(-1,ii).StringText
- posl=1
- while true
- lbegin,lend,curr=word\find line,posl
- if lbegin==nil then break
- if rus.match\match(curr)
- posw=1
- while true
- wbegin,wend=rus.find\find curr,posw
- if not wbegin then break
- editor.AddColor ei.EditorID,ii,lbegin+wbegin-1,lbegin+wend-1,0,color,190,colorguid
- posw=wend+1
- posl=lend+1
- 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
GeSHi © Codebox Plus Extension