local function MsgPopup(msg,title,flags,delay)
if flags and flags:find("w") then
mf.beep()
delay = delay or 1000
end
local s = far.SaveScreen()
far.Message(msg,title or nfo.name,"",flags)
far.Text()
win.Sleep(delay or 300); far.RestoreScreen(s)
end
local GET_TOP = 0
Macro { description="[Bookmarks] push cur. position to bookmarks";
area="Editor"; key="LCtrlF3";
action=function()
assert(BM.Push()~=0)
MsgPopup("Pushed")
end;
}
Macro { description="[Bookmarks] add cur. position to bookmarks and cut 'tail'";
area="Editor"; key="LCtrlF3:Hold";
action=function()
assert(BM.Add()~=0)
MsgPopup("Added")
end;
}
Macro { description="[Bookmarks] pop bookmark";
area="Editor"; key="LCtrlF4";
action=function()
local idxTop = BM.Stat(GET_TOP)
if idxTop==0 then
MsgPopup("Pop: no bookmarks")
elseif BM.Pop()==0 then
MsgPopup("Pop: already on position")
BM.Del(idxTop)
end
end;
}
Macro { description="[Bookmarks] goto top bookmark";
area="Editor"; key="LCtrlF4:Hold";
action=function()
local idxTop = BM.Stat(GET_TOP)
if idxTop==0 then
MsgPopup("Goto top: no bookmarks")
elseif BM.Goto(idxTop)==0 then
MsgPopup("Goto top: already on position")
end
end;
}
Macro { description="[Bookmarks] goto current bookmark";
area="Editor"; key="LCtrlF5:Hold";
action=function()
if BM.Stat(GET_TOP)==0 then
MsgPopup("Goto current: no bookmarks")
elseif BM.Goto()==0 then
MsgPopup("Goto current: already on position")
end
end;
}
Macro { description="[Bookmarks] next bookmark";
area="Editor"; key="LCtrlF5";
action=function()
if BM.Stat(GET_TOP)==0 then
MsgPopup("Next: no bookmarks")
elseif BM.Next()==0 then
MsgPopup("Next: already on position")
end
end;
}
Macro { description="[Bookmarks] prev bookmark";
area="Editor"; key="LCtrlF6";
action=function()
if BM.Stat(GET_TOP)==0 then
MsgPopup("Prev: no bookmarks")
elseif BM.Prev()==0 then
MsgPopup("Prev: already on position")
end
end;
}
Macro { description="[Bookmarks] back (push just added and goto prev)";
area="Editor"; key="LCtrlF6:Hold";
action=function()
local idxTop = BM.Stat(GET_TOP)
if idxTop==0 then
MsgPopup("Back: no bookmarks")
elseif BM.Back()~=1 then
MsgPopup("Back: already on position")
elseif idxTop<BM.Stat(GET_TOP) then
MsgPopup("Back: pushed")
end
end;
}
Macro { description="[Bookmarks] del current bookmark";
area="Editor"; key="LCtrlF8";
action=function()
if BM.Del()==0 then
MsgPopup("Del: no bookmarks")
else
MsgPopup("Deleted")
end
end;
}
Macro { description="[Bookmarks] clear bookmarks";
area="Editor"; key="LCtrlF8:Hold";
action=function()
assert(BM.Clear()~=0)
MsgPopup("Cleared")
end;
}
--]]