Crest replacement

Here you can discuss about your favorite plug-in.
Post Reply
kamil
Posts: 44
Joined: Fri 13 Apr, 2012 19:19
Has thanked: 8 times

Crest replacement

Post by kamil »

I have this old simple plugin called "crest".

When I am in Editor and hold down Shift+Ctrl, it highlights for me the line and column that the cursor is currently at.
I got used to this feature so much that this plugin (it's binary I have) is the only reason I use 32 bit Far with 64 bit Windows.

Is there any other plugin which can do that?
Or perhaps some simple lua code could implement that functionality for me?

I know Visualiser can highlight the cursor's line and column, but I need to it be done only while I'm holding Shift+Ctrl, not all the time.
Shmuel
Posts: 6815
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 526 times

Crest replacement

Post by Shmuel »

1. I'm not using plugin Colorer but I vaguely recall it had one. Check its options.
2. There is a Lua script by zg for LF4Ed plugin. It must be easy to convert it for LuaMacro.
kamil
Posts: 44
Joined: Fri 13 Apr, 2012 19:19
Has thanked: 8 times

Crest replacement

Post by kamil »

Shmuel wrote:1. I'm not using plugin Colorer but I vaguely recall it had one. Check its options.
You're right.
But its like with the one from Visualizer - its always on.
Shmuel wrote:2. There is a Lua script by zg for LF4Ed plugin. It must be easy to convert it for LuaMacro.
I will have a look at it.

Thanks.
User avatar
sToLp
Posts: 938
Joined: Thu 23 Jul, 2009 10:16
Has thanked: 114 times
Been thanked: 12 times

Crest replacement

Post by sToLp »

I use it.
Attachments
ScrollLock_cross_modGrey_(zg)editor.lua
(5.18 KiB) Downloaded 240 times
kamil
Posts: 44
Joined: Fri 13 Apr, 2012 19:19
Has thanked: 8 times

Crest replacement

Post by kamil »

Thank you guys!
I managed to replicate my old CRest behaviour with LUA macro - it works exactly the same.
User avatar
HaRT
Moderator
Posts: 10806
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 220 times
Been thanked: 357 times

Crest replacement

Post by HaRT »

kamil, can you please publish your macro here for others to be able to use it too?
Фар есть инструмент, а не нянька. © 2009 DrKnS
kamil
Posts: 44
Joined: Fri 13 Apr, 2012 19:19
Has thanked: 8 times

Crest replacement

Post by kamil »

Sure.
Sorry that I stripped all the comments, but I like my code clean:

Code: Select all

local F=far.Flags
local editors={}

local color = 0x5e
local color1 = 0x5e

local scrolllock=false

function GetData(id)
  local data=editors[id]
  if not data then
    editors[id]={start=1,finish=1}
    data=editors[id]
  end
  return data
end

function RemoveCrest(id,data)
  for ii=data.start,data.finish do
    editor.DelColor(id,ii,nil)
  end
end

function ProcessCrest(id,update)
  local data=GetData(id)
  RemoveCrest(id,data)
  update(data)
end

function ProcessEditorInput(rec)
  if F.KEY_EVENT==rec.EventType and 0~=rec.VirtualKeyCode then
    if 0==bit64.band(rec.ControlKeyState,F.LEFT_CTRL_PRESSED) or 0==bit64.band(rec.ControlKeyState,F.SHIFT_PRESSED) then
      if scrolllock then
        ProcessCrest(editor.GetInfo(-1).EditorID,
          function(data)
            data.start=1
            data.finish=1
          end
        )
        scrolllock=false
        editor.Redraw(-1)
      end
    else
      if not scrolllock then
        scrolllock=true
        editor.Redraw(-1)
      end
    end
  end
  return false
end

function ProcessEditorEvent(id,event,param)
  if event==F.EE_READ then
    editors[id]={start=1,finish=1}
  end
  if event==F.EE_CLOSE then
    editors[id]=nil
  end
  if event==F.EE_REDRAW then
    if scrolllock then
      local ei=editor.GetInfo(id) --- вместо 'local ei=editor.GetInfo(-1)' - zg Fri 09 Jan, 2015 18:04 http://forum.farmanager.com/viewtopic.php?p=127200#p127200
      ProcessCrest(ei.EditorID,
        function(data)
          data.start=ei.TopScreenLine
          data.finish=math.min(ei.TopScreenLine+ei.WindowSizeY,ei.TotalLines)
          for ii=data.start,data.finish do
            local toreal=function(pos) return editor.TabToReal(ei.EditorID,ii,pos) end
            if ei.CurLine==ii then
              editor.AddColor(ei.EditorID,ii,toreal(ei.LeftPos),toreal(ei.LeftPos+ei.WindowSizeX),F.ECF_TABMARKCURRENT,color,200)
            end
            local column=toreal(ei.CurTabPos)
            editor.AddColor(ei.EditorID,ii,column,column,F.ECF_TABMARKCURRENT,ii==ei.CurLine and color1 or color,201)
          end
        end
      )
    end
  end
end

function ExitScript()
  local wincount=far.AdvControl(F.ACTL_GETWINDOWCOUNT,0,0)
  for ii=1,wincount do
    local info=far.AdvControl(F.ACTL_GETWINDOWINFO,ii,0)
    if info and F.WTYPE_EDITOR==info.Type then
      ProcessCrest(info.Id,
        function(data)
          data.start=1
          data.finish=1
        end
      )
    end
  end
end

Event { group="EditorEvent"; flags="EnableOutput"; description=""; action=ProcessEditorEvent; }
Event { group="EditorInput"; flags="EnableOutput"; description=""; action=ProcessEditorInput; }
Event { group="ExitFAR"; description=""; action=ExitScript; }
Place the above code in a .lua file (inside your far's macros folder) and then every time you hold SHIFT+LCTRL inside the editor, it will paint a cross where the cursor is.
jazz albert
Posts: 1
Joined: Tue 25 Oct, 2016 00:45

Crest replacement

Post by jazz albert »

kamil wrote: ure.
Sorry that I stripped all the comments, but I like my code clean:

Code: Select all

local F=far.Flags
local editors={}

local color = 0x5e
local color1 = 0x5e

local scrolllock=false

function GetData(id)
  local data=editors[id]
  if not data then
    editors[id]={start=1,finish=1}
    data=editors[id]
  end
  return data
end

function RemoveCrest(id,data)
  for ii=data.start,data.finish do
    editor.DelColor(id,ii,nil)
  end
end

function ProcessCrest(id,update)
  local data=GetData(id)
  RemoveCrest(id,data)
  update(data)
end

function ProcessEditorInput(rec)
  if F.KEY_EVENT==rec.EventType and 0~=rec.VirtualKeyCode then
    if 0==bit64.band(rec.ControlKeyState,F.LEFT_CTRL_PRESSED) or 0==bit64.band(rec.ControlKeyState,F.SHIFT_PRESSED) then
      if scrolllock then
        ProcessCrest(editor.GetInfo(-1).EditorID,
          function(data)
            data.start=1
            data.finish=1
          end
        )
        scrolllock=false
        editor.Redraw(-1)
      end
    else
      if not scrolllock then
        scrolllock=true
        editor.Redraw(-1)
      end
    end
  end
  return false
end

function ProcessEditorEvent(id,event,param)
  if event==F.EE_READ then
    editors[id]={start=1,finish=1}
  end
  if event==F.EE_CLOSE then
    editors[id]=nil
  end
  if event==F.EE_REDRAW then
    if scrolllock then
      local ei=editor.GetInfo(id) --- вместо 'local ei=editor.GetInfo(-1)' - zg Fri 09 Jan, 2015 18:04 http://forum.farmanager.com/viewtopic.php?p=127200#p127200
      ProcessCrest(ei.EditorID,
        function(data)
          data.start=ei.TopScreenLine
          data.finish=math.min(ei.TopScreenLine+ei.WindowSizeY,ei.TotalLines)
          for ii=data.start,data.finish do
            local toreal=function(pos) return editor.TabToReal(ei.EditorID,ii,pos) end
            if ei.CurLine==ii then
              editor.AddColor(ei.EditorID,ii,toreal(ei.LeftPos),toreal(ei.LeftPos+ei.WindowSizeX),F.ECF_TABMARKCURRENT,color,200)
            end
            local column=toreal(ei.CurTabPos)
            editor.AddColor(ei.EditorID,ii,column,column,F.ECF_TABMARKCURRENT,ii==ei.CurLine and color1 or color,201)
          end
        end
      )
    end
  end
end

function ExitScript()
  local wincount=far.AdvControl(F.ACTL_GETWINDOWCOUNT,0,0)
  for ii=1,wincount do
    local info=far.AdvControl(F.ACTL_GETWINDOWINFO,ii,0)
    if info and F.WTYPE_EDITOR==info.Type then
      ProcessCrest(info.Id,
        function(data)
          data.start=1
          data.finish=1
        end
      )
    end
  end
end

Event { group="EditorEvent"; flags="EnableOutput"; description=""; action=ProcessEditorEvent; }
Event { group="EditorInput"; flags="EnableOutput"; description=""; action=ProcessEditorInput; }
Event { group="ExitFAR"; description=""; action=ExitScript; }
Place the above code in a .lua file (inside your far's macros folder) and then every time you hold SHIFT+LCTRL inside the editor, it will paint a cross where the cursor is.
I messed with this script is there any other way to do so?
Last edited by jazz albert on Thu 01 Jan, 1970 01:00, edited 0 times in total.
Reason: [code]
Post Reply

Return to “General Plug-In Discussions”