Code: Select all
F=far.Flags
editors={}
ruColor=
Flags:bit64.bor F.FCF_FG_4BIT,F.FCF_BG_4BIT
ForegroundColor:0xe
BackgroundColor:0xc
spColor=
Flags:bit64.bor F.FCF_FG_4BIT,F.FCF_BG_4BIT
ForegroundColor:0x9
BackgroundColor:0x1
colorguid=win.Uuid "1687B745-233F-4c33-AA46-3A39E67B0170"
ruSymbols=regex.new "/([а-яёА-ЯЁ]+)/"
spSymbols=regex.new "/(\\s+)/"
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
line=editor.GetString(-1,ii).StringText
ruEnd,spEnd=0,0
while ruEnd
ruBegin,ruEnd=ruSymbols\find line,ruEnd+1
if ruEnd
editor.AddColor ei.EditorID,ii,ruBegin,ruEnd,0,ruColor,190,colorguid
while spEnd
spBegin,spEnd=spSymbols\find line,spEnd+1
if spEnd
editor.AddColor ei.EditorID,ii,spBegin,spEnd,0,spColor,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)