Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » FAR Manager (часть 4)

Модерирует : gyra, Maz

Maz (23-11-2017 18:57): FAR Manager (часть 5)  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

Alexyz21



Silver Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
-- Автор 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
 

Всего записей: 3471 | Зарегистр. 16-06-2007 | Отправлено: 19:28 09-02-2016 | Исправлено: Alexyz21, 19:30 09-02-2016
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » FAR Manager (часть 4)
Maz (23-11-2017 18:57): FAR Manager (часть 5)


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru