Skip to content

Commit

Permalink
LF History 3.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed Nov 4, 2023
1 parent 95c235e commit 5a3a491
Show file tree
Hide file tree
Showing 10 changed files with 541 additions and 262 deletions.
6 changes: 3 additions & 3 deletions plugins/luafarhistory/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ T_MESSAGE = $(path_plugin)\lfh_message.lua
bootscript = $(path_plugin)\$(PROJECT).lua

scripts = \
$(path_plugin)\_globalinfo.lua \
$(path_plugin)\lfh_message.lua \
$(path_plugin)\config.lua
$(path_plugin)\_globalinfo.lua

modules = \
$(path_plugin)\lfh_message.lua \
$(path_plugin)\lfh_config.lua \
$(path_share)*shmuz\serial.lua \
$(path_share)*far2\history.lua \
$(path_share)*far2\custommenu.lua \
Expand Down
4 changes: 2 additions & 2 deletions plugins/luafarhistory/build/define.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Definitions
VER_MAJOR = "3"
VER_MINOR = "11"
VER_MICRO = "2"
VER_MINOR = "12"
VER_MICRO = "0"

MINFARVERSION = "{ 3, 0, 0, 3812 }" -- 3.0.0.4364 for non-embedded plugin build (-DRUN_LUAFAR_INIT)

Expand Down
86 changes: 0 additions & 86 deletions plugins/luafarhistory/config.lua

This file was deleted.

7 changes: 7 additions & 0 deletions plugins/luafarhistory/doc/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Legend: [+] added; [-] deleted; [*] changed; [!] fixed;
------------------------------------------------------------------

2023-11-04, v3.12.0
[+] Configuration: add exclusion lists
[+] Most operations made available via Plugin.Call
[*] The macrofile lf_history.lua uses Plugin.Call rather than Plugin.Menu
[*] Full separation between configuration and data
[-] Remove switching between history windows of different types

2023-07-11, v3.11.2
[!] Configuration dialog: fixes

Expand Down
204 changes: 204 additions & 0 deletions plugins/luafarhistory/lfh_config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
-- file created: 2010-03-16
-- luacheck: globals _Plugin

local F = far.Flags
local sd = require "far2.simpledialog"
local M = require "lfh_message"
local DlgSend = far.SendDlgMessage
local main

local function Init(data)
main = data
end

local function ConfigDialog ()
local aData = _Plugin.Cfg
local offset = 5 + math.max(M.mBtnHighTextColor:len(), M.mBtnSelHighTextColor:len()) + 10
local swid = M.mTextSample:len()
local Items = {
guid = "05d16094-0735-426c-a421-62dae2db6b1a";
help = "PluginConfig";
width = 66;
{ tp="dbox"; text=M.mPluginTitle..": "..M.mSettings; },

{ tp="text"; text=M.mMaxHistorySizes; },
{ tp="text"; text=M.mSizeCmd; x1=6; },
{ tp="fixedit"; x1=20; width=5; name="iSizeCmd"; ystep=0; },
{ tp="text"; text=M.mSizeView; x1=6; },
{ tp="fixedit"; x1=20; width=5; name="iSizeView"; ystep=0; },
{ tp="text"; text=M.mSizeFold; x1=6; },
{ tp="fixedit"; x1=20; width=5; name="iSizeFold"; ystep=0; },

{ tp="text"; text=M.mWinProperties; x1=34; ystep=-3; },
{ tp="chbox"; text=M.mDynResize; x1=35; name="bDynResize"; },
{ tp="chbox"; text=M.mAutoCenter; x1=35; name="bAutoCenter"; },

{ tp="sep"; text=M.mSepColors; centertext=1; ystep=2; },
{ tp="butt"; text=M.mBtnHighTextColor; btnnoclose=1; name="btnHighTextColor"; },
{ tp="text"; text=M.mTextSample; x1=offset; ystep=0; name="labHighTextColor"; width=swid; },
{ tp="butt"; text=M.mBtnSelHighTextColor; btnnoclose=1; name="btnSelHighTextColor"; },
{ tp="text"; text=M.mTextSample; x1=offset; ystep=0; name="labSelHighTextColor"; width=swid; },
{ tp="sep"; },

{ tp="text"; text=M.mDateFormat; },
{ tp="combobox"; name="iDateFormat"; dropdown=1; list={}; width=24; },
{ tp="chbox"; text=M.mKeepSelectedItem; name="bKeepSelectedItem"; x1=35; ystep=-1; },
{ tp="sep"; ystep=2; },

{ tp="butt"; text=M.mOk; centergroup=1; default=1; },
{ tp="butt"; text=M.mCancel; centergroup=1; cancel=1; },
}
------------------------------------------------------------------------------
local dlg = sd.New(Items)
local Pos, Elem = dlg:Indexes()

local time = os.time()
for _,fmt in ipairs(main.DateFormats) do
local t = { Text = fmt and os.date(fmt, time) or M.mDontShowDates }
table.insert(Elem.iDateFormat.list, t)
end

dlg:LoadData(aData)
Elem.iSizeCmd.val = aData.commands.iSize
Elem.iSizeView.val = aData.view.iSize
Elem.iSizeFold.val = aData.folders.iSize

local hColor0 = aData.HighTextColor
local hColor1 = aData.SelHighTextColor

Items.proc = function (hDlg, msg, param1, param2)
if msg == F.DN_BTNCLICK then
if param1 == Pos.btnHighTextColor then
local c = far.ColorDialog(hColor0)
if c then hColor0 = c; DlgSend(hDlg,F.DM_REDRAW); end
elseif param1 == Pos.btnSelHighTextColor then
local c = far.ColorDialog(hColor1)
if c then hColor1 = c; DlgSend(hDlg,F.DM_REDRAW); end
end

elseif msg == F.DN_CTLCOLORDLGITEM then
if param1 == Pos.labHighTextColor then param2[1] = hColor0; return param2; end
if param1 == Pos.labSelHighTextColor then param2[1] = hColor1; return param2; end
end
end

local out = dlg:Run()
if out then
if tonumber(out.iSizeCmd) then aData.commands.iSize = tonumber(out.iSizeCmd) end
if tonumber(out.iSizeView) then aData.view.iSize = tonumber(out.iSizeView) end
if tonumber(out.iSizeFold) then aData.folders.iSize = tonumber(out.iSizeFold) end
out.iSizeCmd, out.iSizeView, out.iSizeFold = nil,nil,nil
aData.HighTextColor = hColor0
aData.SelHighTextColor = hColor1
dlg:SaveData(out, aData)
main.SaveHistory()
end
end

local function ExclusionDialog (aStr)
local title = aStr=="" and M.mExcludeDlgTitleAdd or M.mExcludeDlgTitleEdit
local Items = {
guid = "4F55D7A5-0CAA-4533-A440-840553845DB0";
help = "ExclusionDialog";
{ tp="dbox"; text=title; },
{ tp="text"; text=M.mExcludeDlgPrompt; },
{ tp="edit"; text=aStr; name="pattern"; },
{ tp="sep"; },
{ tp="butt"; text=M.mOk; centergroup=1; default=1; },
{ tp="butt"; text=M.mCancel; centergroup=1; cancel=1; },
}

local retvalue = nil
Items.closeaction = function(_hDlg, _Par1, tOut)
if tOut.pattern ~= "" and pcall(regex.new, tOut.pattern) then
retvalue = tOut.pattern
else
far.Message(("%s: \"%s\"" ):format(M.mExcludeDlgError, tOut.pattern), M.mError, M.mOk, "w")
return 0
end
end

sd.New(Items):Run()
return retvalue
end

local function ExclusionMenu (aData, aTitle)
local exclude = aData.exclude
local Props = { Title=aTitle; Bottom="Ins, Del, F4"; HelpTopic="ExclusionMenu"; }
local Items = {}
local Bkeys = "Ins Del F4"
local modif = false

for i,v in ipairs(exclude) do Items[i] = v end

while true do
local item, pos = far.Menu(Props, Items, Bkeys)
if item then Props.SelectIndex = pos end

if not item then
if not modif then break end
local R = far.Message(M.mExcludeDlgSaveQuery, M.mPluginTitle, ";YesNoCancel", "w")
if R == 1 then
aData.exclude = Items
main.SaveHistory()
break
elseif R == 2 then
break
end

elseif item.BreakKey == "Ins" then
local txt = ExclusionDialog("")
if txt then
modif = true
table.insert(Items, Items[pos] and pos or 1, { text=txt; })
end

elseif item.BreakKey == "Del" and Items[pos] then
modif = true
table.remove(Items, pos)
if not Items[pos] then Props.SelectIndex = pos-1 end

elseif (item.BreakKey == "F4" or item.BreakKey == nil) and Items[pos] then
local txt = ExclusionDialog(Items[pos].text)
if txt then
modif = true
Items[pos].text = txt
end

end
end
end

local function ConfigMenu()
local Props = { Title=M.mPluginTitle; HelpTopic="ConfigMenu"; }
local Items = {
{ tag="general"; data=M.mGeneralSettings; },
{ separator=true; },
{ tag="commands"; data=M.mMenuCommands .. ": " ..M.mExclusions; },
{ tag="view"; data=M.mMenuView .. ": " ..M.mExclusions; },
{ tag="folders"; data=M.mMenuFolders .. ": " ..M.mExclusions; },
}
local j = 1
for i,v in ipairs(Items) do
if v.separator==nil then
v.text = ("&%d. %s"):format(j, v.data)
j = j+1
end
end

while true do
local item,pos = far.Menu(Props,Items)
if not item then break end
Props.SelectIndex = pos
if item.tag == "general" then
ConfigDialog()
else
ExclusionMenu(_Plugin.Cfg[item.tag], item.data)
end
end
end

return {
Init = Init;
ConfigMenu = ConfigMenu;
}
27 changes: 24 additions & 3 deletions plugins/luafarhistory/lfh_eng.hlf.mcr
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ title. There are 4 switchable filtering methods available:
#Ctrl-Alt-X# Apply XLat conversion on filter and also
switch the keyboard layout.
#Ctrl-I# Inverse sort order.
#Alt-F8# Switch to Commands history.
#Alt-F11# Switch to View/Edit history.
#Alt-F12# Switch to Folders history.
#Ins# Check the item (it protects from deleting by Ctrl-Del or Ctrl-F8)

\3BCommands history\-
Expand Down Expand Up @@ -94,3 +91,27 @@ $ #Plugin's Configuration Dialog#
changes.

~Contents~@Contents@

@ConfigMenu
$ #Plugin's Configuration Menu#
Here you can choose what to configure:
#-# ~Plugin's Configuration Dialog~@PluginConfig@
#-# Either of the three exclusion lists

~Contents~@Contents@

@ExclusionMenu
$ #Exclusion Menu#
#Ins# Add a new exclusion pattern to the list
#Del# Delete an exclusion pattern from the list
#F4# Edit an exclusion pattern

~Contents~@Contents@

@ExclusionDialog
$ #Edit exclusion pattern dialog#
Here you can add or edit a pattern (FAR regular expression).
If a history item will match this expression it will not be added to a history.
The history items that are already in history will not be affected.

~Contents~@Contents@
Loading

0 comments on commit 5a3a491

Please sign in to comment.