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.
Crest replacement
-
- Posts: 6840
- Joined: Thu 23 Mar, 2006 21:36
- Location: Israel
- Has thanked: 41 times
- Been thanked: 530 times
Crest replacement
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.
2. There is a Lua script by zg for LF4Ed plugin. It must be easy to convert it for LuaMacro.
Crest replacement
You're right.Shmuel wrote:1. I'm not using plugin Colorer but I vaguely recall it had one. Check its options.
But its like with the one from Visualizer - its always on.
I will have a look at it.Shmuel wrote:2. There is a Lua script by zg for LF4Ed plugin. It must be easy to convert it for LuaMacro.
Thanks.
Crest replacement
I use it.
- Attachments
-
- ScrollLock_cross_modGrey_(zg)editor.lua
- (5.18 KiB) Downloaded 248 times
Crest replacement
Thank you guys!
I managed to replicate my old CRest behaviour with LUA macro - it works exactly the same.
I managed to replicate my old CRest behaviour with LUA macro - it works exactly the same.
- HaRT
- Moderator
- Posts: 10869
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Crest replacement
kamil, can you please publish your macro here for others to be able to use it too?
Фар есть инструмент, а не нянька. © 2009 DrKnS
Crest replacement
Sure.
Sorry that I stripped all the comments, but I like my code clean:
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.
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; }
-
- Posts: 1
- Joined: Tue 25 Oct, 2016 00:45
Crest replacement
I messed with this script is there any other way to do so?kamil wrote: ure.
Sorry that I stripped all the comments, but I like my code clean: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.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; }
Last edited by jazz albert on Thu 01 Jan, 1970 01:00, edited 0 times in total.
Reason: [code]
Reason: [code]