Skip to content

Commit

Permalink
Добавлен новый вид события: group="MacrosLoaded". Обработчики вызываю…
Browse files Browse the repository at this point in the history
…тся по завершению загрузки макрофайлов.
  • Loading branch information
shmuz committed Oct 31, 2015
1 parent 522a6ef commit ba8c663
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 19 deletions.
10 changes: 6 additions & 4 deletions enc/enc_lua/macroapi_manual.en.tsi
Expand Up @@ -1762,7 +1762,7 @@ lv=2
dt=Text
nm=Event handlers
ctime=3580139337
mtime=3655200145
mtime=3655482501
<article>
#_<markdown>
#_
Expand All @@ -1782,16 +1782,18 @@ mtime=3655200145
#_```
#_
#_The field `group` can have one of the following values:<br>
#_`"DialogEvent", "EditorEvent", "EditorInput", "ExitFAR", "ViewerEvent", "ConsoleInput"`.<br>
#_These names are derived from names of the corresponding functions, exported by the plugin, e.g.:<br>
#_`"DialogEvent", "EditorEvent", "EditorInput", "ExitFAR", "ViewerEvent", "ConsoleInput", "MacrosLoaded"`.<br>
#_These names (except `MacrosLoaded`) are derived from names of the corresponding functions, exported by the plugin, e.g.:<br>
#_ export.ProcessDialogEvent -> DialogEvent
#_The functions `condition` and `action` are called with the same parameters as the corresponding exported functions are called (see LuaFAR manual).
#_
#_When there are multiple event handlers for the same event (i.e. handlers with the same `group` value), these handlers will be called one after one: a handler having higher priority is called first. Priorities are evaluated dynamically accounting for `condition()` results if any, the same way it is done for macros.
#_
#_The `ExitFAR` handler is called in the following cases: (a) exit from Far Manager,
#_The `ExitFAR` handlers are called in the following cases: (a) exit from Far Manager,
#_(b) unloading LuaMacro plugin, \(c) unloading or reloading macros.
#_
#_The `MacrosLoaded` handlers are called after loading/reloading of macrofiles is finished. Their `condition` and `action` functions get no arguments.
#_
#_[1]: 75.html
#_
#_@@@
Expand Down
11 changes: 6 additions & 5 deletions enc/enc_lua/macroapi_manual.ru.tsi
Expand Up @@ -1756,7 +1756,7 @@ lv=2
dt=Text
nm=����������� �������
ctime=3580139337
mtime=3655200078
mtime=3655482883
<article>
#_<markdown>
#_
Expand All @@ -1776,15 +1776,16 @@ mtime=3655200078
#_```
#_
#_���� `group` ����� ����� ���� �� ��������� ��������:<br>
#_`"DialogEvent", "EditorEvent", "EditorInput", "ExitFAR", "ViewerEvent", "ConsoleInput"`.<br>
#_������ ����� �������� ������������ �� ��� ��������������� �������, �������������� ��������, ��������:<br>
#_`"DialogEvent", "EditorEvent", "EditorInput", "ExitFAR", "ViewerEvent", "ConsoleInput", "MacrosLoaded"`.<br>
#_������ ����� (����� `MacrosLoaded`) �������� ������������ �� ��� ��������������� �������, �������������� ��������, ��������:<br>
#_ export.ProcessDialogEvent -> DialogEvent
#_������� `condition` � `action` ����������� ���������� � ���� �� �����������, � �������� ���������� ��������������� �������������� ������� (��. ������ LuaFAR).
#_
#_��� ������� ���������� ������������ ������ � ���� �� ������� (�.�. ������������ � ���������� ����� `group`), ��� ����������� ����� ������� �� �������: ���������� � ����� ������� ����������� ���������� ������. ��������� ������������ ����������� � ������ ������� `condition`, ���� ������� �������, ��� � ��� ��������.
#_
#_������� `"ExitFAR"` ���������� � ��������� �������: (a) ����� �� Far Manager,
#_(b) �������� ������� LuaMacro, \(c) �������� ���� ������������ ��������.
#_����������� `ExitFAR` ���������� � ��������� �������: (a) ����� �� Far Manager, (b) �������� ������� LuaMacro, \(c) �������� ���� ������������ ��������.
#_
#_����������� `MacrosLoaded` ���������� �� ���������� ��������/������������ �����������. �� ������� `condition` � `action` ���������� ��� ����������.
#_
#_[1]: 75.html
#_
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 1, 0, 0, 539 },
Version = { 1, 0, 0, 540 },
MinFarVersion = { 3, 0, 0, 4450 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
Expand Down
6 changes: 5 additions & 1 deletion plugins/luamacro/changelog
@@ -1,4 +1,8 @@
shmuel 28.10.2015 19:17:43 +0200 - build 539
shmuel 31.10.2015 19:33:22 +0200 - build 540

1. Добавлен новый вид события: group="MacrosLoaded". Обработчики вызываются по завершению загрузки макрофайлов.

shmuel 28.10.2015 19:17:43 +0200 - build 539

1. Рефакторинг (синхронный с рефакторингом в Far build 4450).

Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luamacro.rc
@@ -1,6 +1,6 @@
#include <farversion.hpp>

#define PLUGIN_BUILD 539
#define PLUGIN_BUILD 540
#define PLUGIN_DESC "Lua Macros for Far Manager"
#define PLUGIN_NAME "LuaMacro"
#define PLUGIN_FILENAME "luamacro.dll"
Expand Down
22 changes: 15 additions & 7 deletions plugins/luamacro/utils.lua
Expand Up @@ -57,7 +57,8 @@ local LoadMacrosDone
local LoadingInProgress
local EnumState = {}
local Events
local EventGroups = {"dialogevent","editorevent","editorinput","exitfar","viewerevent", "consoleinput"}
local EventGroups = {"dialogevent","editorevent","editorinput","exitfar","viewerevent", "consoleinput",
"macrosloaded"}
local AddedMenuItems
local AddedPrefixes

Expand Down Expand Up @@ -610,6 +611,12 @@ local function LoadMacros (unload, paths)
LoadMacrosDone = false
end

export.ExitFAR = nil
export.ProcessDialogEvent = nil
export.ProcessEditorInput = nil
export.ProcessViewerEvent = nil
export.ProcessConsoleInput = nil

local allAreas = band(MacroCallFar(MCODE_F_GETOPTIONS),0x3) == 0
local numerrors=0
local newAreas = {}
Expand Down Expand Up @@ -753,15 +760,16 @@ local function LoadMacros (unload, paths)

far.RecursiveSearch (DirMacros.."\\internal", "*.lua", LoadRecordedFile, 0)

export.ExitFAR = Events.exitfar[1] and export_ExitFAR
export.ProcessDialogEvent = Events.dialogevent[1] and export_ProcessDialogEvent
export.ProcessEditorInput = Events.editorinput[1] and export_ProcessEditorInput
export.ProcessViewerEvent = Events.viewerevent[1] and export_ProcessViewerEvent
export.ProcessConsoleInput = Events.consoleinput[1] and export_ProcessConsoleInput

EV_Handler(Events.macrosloaded)
LoadMacrosDone = true
end

export.ExitFAR = Events.exitfar[1] and export_ExitFAR
export.ProcessDialogEvent = Events.dialogevent[1] and export_ProcessDialogEvent
export.ProcessEditorInput = Events.editorinput[1] and export_ProcessEditorInput
export.ProcessViewerEvent = Events.viewerevent[1] and export_ProcessViewerEvent
export.ProcessConsoleInput = Events.consoleinput[1] and export_ProcessConsoleInput

LoadingInProgress = nil
return numerrors==0
end
Expand Down

0 comments on commit ba8c663

Please sign in to comment.