├── .gitignore ├── .luacheckrc ├── CMakeLists.txt ├── LICENSE ├── Macros ├── .luacheckrc ├── reserve │ ├── SimSU │ │ └── Shell_SelectingEx.lua │ ├── jd │ │ └── MacroEx │ │ │ ├── README │ │ │ ├── macroEx.lua │ │ │ └── macroEx_test.lua │ ├── shmuel │ │ ├── RemoveBracketsFromButtons.lua │ │ ├── paragraph.lua │ │ └── same_size.lua │ ├── z0hm │ │ ├── FarExit.lua │ │ └── MessageX.lua │ └── zg │ │ └── Dialog.Maximize.moon ├── scripts │ ├── Common │ │ ├── ToggleScreens.lua │ │ ├── misc.lua │ │ ├── plugins.lua │ │ ├── postmacro.lua │ │ └── test_regex.lua │ ├── Editor │ │ ├── InsertMacro.lua │ │ ├── bracket.lua │ │ ├── calc.lua │ │ ├── dup_line.lua │ │ ├── dupfighter │ │ │ ├── dupfighter.lua │ │ │ ├── dupfighter_eng.hlf │ │ │ └── dupfighter_rus.hlf │ │ ├── editor.lua │ │ ├── editor_luacheck.lua │ │ ├── editor_shellcheck.lua │ │ ├── events │ │ │ ├── Editor.ColorWord.moon │ │ │ ├── coding.lua │ │ │ ├── editor_events.lua │ │ │ ├── scite_like.lua │ │ │ └── session_bookmarks.lua │ │ ├── multiline_sort.lua │ │ ├── pick_text.lua │ │ ├── scroll.lua │ │ └── smart_home_end.lua │ ├── Misc │ │ ├── help_lang.lua │ │ ├── lf_fin.lua │ │ ├── menupos.lua │ │ └── show_guid.lua │ ├── Panel modules │ │ ├── MacroPanel │ │ │ ├── macropanel.lua │ │ │ └── macropanel_en.hlf │ │ ├── panel.abcd │ │ ├── pmodule1.lua │ │ └── xx-uu-module.lua │ ├── Plugins │ │ ├── highlight.lua │ │ ├── lf_history.lua │ │ └── lf_search.lua │ ├── Shell │ │ ├── bin2text_mf.lua │ │ ├── compare_by_hash.lua │ │ ├── custom_sorts.lua │ │ ├── hashes.lua │ │ ├── macrotest.lua │ │ ├── misc.lua │ │ ├── misc2.lua │ │ ├── mkdir │ │ │ ├── mkdir.example.alias │ │ │ ├── mkdir.grammar │ │ │ ├── mkdir.lua │ │ │ ├── mkdir.test │ │ │ ├── mkdireng.hlf │ │ │ └── mkdirrus.hlf │ │ ├── panelfilter.lua │ │ ├── py-hash.lua │ │ ├── search_plugin_panel.lua │ │ ├── sort_by_regex.lua │ │ ├── symlink.lua │ │ ├── time.lua │ │ ├── view_folder_under_cursor.lua │ │ └── visual_compare.lua │ ├── Third_party │ │ ├── BatchRen.lua │ │ ├── Common_Calendar.lua │ │ ├── Editor_MouseSelect.lua │ │ ├── Editor_Remarks_mod.lua │ │ ├── Hexed │ │ │ ├── hexed.moon │ │ │ ├── hexed_eng.hlf │ │ │ └── hexed_rus.hlf │ │ ├── RESearch.Grep.lua │ │ ├── bito.lua │ │ ├── farcall.lua │ │ ├── impenv.lua │ │ └── namedfold.lua │ └── _macroinit.lua └── util │ └── moon2lua.lua ├── Plugins ├── _common │ ├── lsqlite3.c │ └── minilua.c ├── filegen │ ├── CMakeLists.txt │ └── src │ │ ├── GlobalInfo.c │ │ ├── filegen.lua │ │ └── filegen_eng.hlf ├── highlight │ ├── CMakeLists.txt │ ├── doc │ │ ├── changelog.txt │ │ └── license.txt │ └── src │ │ ├── GlobalInfo.c │ │ ├── highlight.lua │ │ ├── highlight_eng.hlf │ │ └── syntaxes │ │ ├── syntax_batch.lua │ │ ├── syntax_cmake.lua │ │ ├── syntax_cpp.lua │ │ ├── syntax_diff.lua │ │ ├── syntax_grep.lua │ │ ├── syntax_hlf.lua │ │ ├── syntax_ini.lua │ │ ├── syntax_intel_hex.lua │ │ ├── syntax_java.lua │ │ ├── syntax_lng.lua │ │ ├── syntax_lua.lua │ │ ├── syntax_makefile.lua │ │ ├── syntax_moonscript.lua │ │ ├── syntax_pascal.lua │ │ ├── syntax_python.lua │ │ ├── syntax_shell.lua │ │ ├── syntax_srecord.lua │ │ ├── syntax_tcl.lua │ │ └── syntax_text.lua ├── lf4ed │ ├── CMakeLists.txt │ ├── doc │ │ ├── changelog.txt │ │ ├── lf4ed_manual.chm │ │ └── license.txt │ └── src │ │ ├── GlobalInfo.c │ │ ├── _usermenu.lua │ │ ├── config.lua │ │ ├── expression.lua │ │ ├── lf4ed.lua │ │ ├── lf4ed_eng.hlf │ │ ├── lf4ed_lang.templ │ │ ├── lf4ed_rus.hlf │ │ ├── scripts │ │ ├── Editor.ColorWord.moon │ │ ├── bracket.lua │ │ ├── calc.lua │ │ ├── coding.lua │ │ ├── compare_by_hash.lua │ │ ├── dup_line.lua │ │ ├── editor_events.lua │ │ ├── editor_luacheck.lua │ │ ├── file2hex.lua │ │ ├── hashes.lua │ │ ├── lf_fin.lua │ │ ├── misc.lua │ │ ├── run_code.lua │ │ ├── scite_like.lua │ │ ├── test_sortlines.lua │ │ └── visual_compare.lua │ │ ├── sortdialog.lua │ │ ├── sortlines.lua │ │ └── wrap.lua ├── lfhistory │ ├── CMakeLists.txt │ └── src │ │ ├── GlobalInfo.c │ │ ├── lfh_config.lua │ │ ├── lfh_eng.hlf │ │ ├── lfh_lang.templ │ │ ├── lfh_rus.hlf │ │ └── lfhistory.lua ├── lfsearch │ ├── CMakeLists.txt │ └── src │ │ ├── GlobalInfo.c │ │ ├── _usermenu.lua │ │ ├── doc │ │ ├── 3rd_party.txt │ │ ├── changelog.txt │ │ └── license.txt │ │ ├── lfs_common.lua │ │ ├── lfs_editengine.lua │ │ ├── lfs_editmain.lua │ │ ├── lfs_editors.lua │ │ ├── lfs_eng.hlf │ │ ├── lfs_lang.templ │ │ ├── lfs_mreplace.lua │ │ ├── lfs_panels.lua │ │ ├── lfs_rename.lua │ │ ├── lfs_replib.lua │ │ ├── lfs_rus.hlf │ │ ├── lfsearch.lua │ │ ├── reader.c │ │ └── scripts │ │ └── test_lfsearch.lua ├── lftmp │ ├── CMakeLists.txt │ └── src │ │ ├── GlobalInfo.c │ │ ├── LuaTmpEng.hlf │ │ ├── LuaTmpRus.hlf │ │ ├── lftmp.lua │ │ └── tmpp_lang.templ ├── luapanel │ ├── CMakeLists.txt │ └── src │ │ ├── GlobalInfo.c │ │ ├── luapanel.lua │ │ └── luapanel_eng.hlf ├── macro2lua │ ├── CMakeLists.txt │ └── src │ │ ├── GlobalInfo.c │ │ ├── changelog │ │ ├── m2l_test.lua │ │ ├── macro2lua.lua │ │ ├── macrosyn.lua │ │ └── readme.txt ├── polygon │ ├── CMakeLists.txt │ └── src │ │ ├── GlobalInfo.c │ │ ├── doc │ │ ├── License-Polygon │ │ ├── License-SQLiteDB │ │ ├── changelog.txt │ │ └── readme.txt │ │ ├── modules │ │ ├── config.lua │ │ ├── editor.lua │ │ ├── exporter.lua │ │ ├── panel.lua │ │ ├── progress.lua │ │ ├── sqlite.lua │ │ └── utils.lua │ │ ├── polygon.c │ │ ├── polygon.example.ini │ │ ├── polygon.ini │ │ ├── polygon.lua │ │ ├── polygon_eng.hlf │ │ ├── polygon_lang.templ │ │ └── polygon_rus.hlf ├── sqlarc │ ├── CMakeLists.txt │ └── src │ │ ├── GlobalInfo.c │ │ ├── sqlarc.c │ │ └── sqlarc.lua └── text_c0 │ ├── build │ └── Makefile │ └── src │ └── text_c0.lua ├── README.md ├── SciTEDirectory.properties └── cmake └── modules ├── FindLibLua.cmake └── FindSqlite3.cmake /.gitignore: -------------------------------------------------------------------------------- 1 | ### 2 | _build 3 | misc 4 | Macros/scripts/_keyreplace.cfg 5 | -------------------------------------------------------------------------------- /.luacheckrc: -------------------------------------------------------------------------------- 1 | -- Luacheck configuration file 2 | 3 | if (...)=="far" then -- running from Far environment 4 | luafar = true 5 | 6 | else 7 | --local cfg = require "far2.luacheck_config" 8 | local cfg = dofile(os.getenv("HOME").."/luacheck_config.lua") 9 | stds.luafar = cfg.luafar 10 | std = "max+luafar" 11 | 12 | end 13 | 14 | --- ignore = { 15 | --- "212", -- unused argument 16 | --- "421", -- shadowing a local variable 17 | --- } 18 | 19 | -- quiet = nil -- Integer in range 0..3 0 20 | -- color = nil -- Boolean true 21 | -- codes = nil -- Boolean false 22 | -- ranges = nil -- Boolean false 23 | -- formatter = nil -- String or function "default" 24 | -- cache = nil -- Boolean or string false 25 | -- jobs = nil -- Positive integer 1 26 | -- exclude_files = nil -- Array of strings {} 27 | -- include_files = nil -- Array of strings (Include all files) 28 | -- global = nil -- Boolean true 29 | -- unused = nil -- Boolean true 30 | -- redefined = nil -- Boolean true 31 | -- unused_args = nil -- Boolean true 32 | -- unused_secondaries = nil -- Boolean true 33 | -- self = nil -- Boolean true 34 | -- std = nil -- String or set of standard globals "max" 35 | -- globals = nil -- Array of strings or field definition map {} 36 | -- new_globals = nil -- Array of strings or field definition map (Do not overwrite) 37 | -- read_globals = nil -- Array of strings or field definition map {} 38 | -- new_read_globals = nil -- Array of strings or field definition map (Do not overwrite) 39 | -- not_globals = nil -- Array of strings {} 40 | -- compat = nil -- Boolean false 41 | -- allow_defined = nil -- Boolean false 42 | -- allow_defined_top = nil -- Boolean false 43 | -- module = nil -- Boolean false 44 | -- max_line_length = nil -- Number or false 120 45 | -- max_code_line_length = nil -- Number or false 120 46 | -- max_string_line_length = nil -- Number or false 120 47 | -- max_comment_line_length = nil -- Number or false 120 48 | -- max_cyclomatic_complexity = nil -- Number or false false 49 | -- ignore = nil -- Array of patterns (see Patterns) {} 50 | -- enable = nil -- Array of patterns {} 51 | -- only = nil -- Array of patterns (Do not filter) 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2007-2023 Shmuel Zeigerman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Macros/.luacheckrc: -------------------------------------------------------------------------------- 1 | -- Luacheck configuration file 2 | 3 | if (...)=="far" then -- running from Far environment 4 | luafar = true 5 | luamacro = true 6 | 7 | else 8 | --local cfg = require "far2.luacheck_config" 9 | local cfg = dofile(os.getenv("HOME").."/luacheck_config.lua") 10 | stds.luafar = cfg.luafar 11 | stds.luamacro = cfg.luamacro 12 | std = "max+luafar+luamacro" 13 | 14 | end 15 | 16 | ignore = { 17 | "212", -- unused argument 18 | "421", -- shadowing a local variable 19 | } 20 | 21 | -- quiet = nil -- Integer in range 0..3 0 22 | -- color = nil -- Boolean true 23 | -- codes = nil -- Boolean false 24 | -- ranges = nil -- Boolean false 25 | -- formatter = nil -- String or function "default" 26 | -- cache = nil -- Boolean or string false 27 | -- jobs = nil -- Positive integer 1 28 | -- exclude_files = nil -- Array of strings {} 29 | -- include_files = nil -- Array of strings (Include all files) 30 | -- global = nil -- Boolean true 31 | -- unused = nil -- Boolean true 32 | -- redefined = nil -- Boolean true 33 | -- unused_args = nil -- Boolean true 34 | -- unused_secondaries = nil -- Boolean true 35 | -- self = nil -- Boolean true 36 | -- std = nil -- String or set of standard globals "max" 37 | -- globals = nil -- Array of strings or field definition map {} 38 | -- new_globals = nil -- Array of strings or field definition map (Do not overwrite) 39 | -- read_globals = nil -- Array of strings or field definition map {} 40 | -- new_read_globals = nil -- Array of strings or field definition map (Do not overwrite) 41 | -- not_globals = nil -- Array of strings {} 42 | -- compat = nil -- Boolean false 43 | -- allow_defined = nil -- Boolean false 44 | -- allow_defined_top = nil -- Boolean false 45 | -- module = nil -- Boolean false 46 | -- max_line_length = nil -- Number or false 120 47 | -- max_code_line_length = nil -- Number or false 120 48 | -- max_string_line_length = nil -- Number or false 120 49 | -- max_comment_line_length = nil -- Number or false 120 50 | -- max_cyclomatic_complexity = nil -- Number or false false 51 | -- ignore = nil -- Array of patterns (see Patterns) {} 52 | -- enable = nil -- Array of patterns {} 53 | -- only = nil -- Array of patterns (Do not filter) 54 | -------------------------------------------------------------------------------- /Macros/reserve/jd/MacroEx/README: -------------------------------------------------------------------------------- 1 | https://forum.farmanager.com/viewtopic.php?f=15&t=8764 2 | 3 | Есть полезнейшая возможность в [MacroLib] — запуск макросов удержанием, двойным нажатием, и др. 4 | Хорошо бы подобное и в родные макросы (тикет на мантисе [есть](https://bugs.farmanager.com/view.php?id=2392)). 5 | 6 | А пока попробуем приблизится к решению задачи имеющимися средствами. 7 | 8 | Предлагаю скрипт **MacroEx**, расширяющий возможности запуска макросов следующим образом: 9 | 10 | 1. В имени клавиши через двоеточие теперь можно указывать дополнительные модификаторы *Hold* и *Double*: 11 | * **_key_:Double** — макрос будет выполнен при двукратном нажатии клавиши (в течении 300 мс, не отпуская клавиши-модификаторы) 12 | * **_key_:Hold** — макрос будет выполнен при удержании (>300 мс) 13 | **Пример:** [spoiler] 14 | 15 | ```lua 16 | Macro { 17 | description="test"; 18 | area="Editor"; key="CtrlF9"; 19 | action=function() 20 | far.Message"plain macro" 21 | end 22 | } 23 | 24 | Macro { 25 | description="hold test"; 26 | area="Editor"; key="CtrlF9:Hold"; 27 | action=function() 28 | far.Message"hold" 29 | end; 30 | } 31 | 32 | Macro { 33 | description="doubletap test"; 34 | area="Common"; key="CtrlF9:Double";-- priority=50; 35 | action=function() 36 | far.Message"doubletap 1" 37 | end; 38 | } 39 | 40 | Macro { 41 | description="doubletap test"; 42 | area="Editor"; key="CtrlF9:Double"; 43 | action=function() 44 | far.Message"doubletap 2" 45 | end; 46 | } 47 | ``` 48 | [/spoiler] 49 | 50 | 2. Поддерживаются последовательности из двух нажатий, перечисленные через "`-`": 51 | * **_key_-key2** — макрос будет выполнен при нажатии последовательности клавиш. 52 | Последовательность следует нажимать так: [spoiler]— нажать первую клавишу (с модификатором) 53 | — сразу отпустить саму клавишу, но продолжать удерживать модификатор 54 | — нажать вторую клавишу и отпустить вместе с модификатором[/spoiler]. 55 | Если вторая клавиша последовательности в течении секунды не будет нажата, то появится подсказка: из описаний возможных макросов. 56 | **Пример:** [spoiler] 57 | 58 | ```lua 59 | Macro { 60 | description="F8: sequence test 1"; 61 | area="Editor"; key="ShiftF8-F8"; 62 | action=function() 63 | far.Message"sequence 1" 64 | end; 65 | } 66 | 67 | Macro { 68 | description="F9: sequence test 2"; 69 | area="Editor"; key="CtrlF8-F9"; 70 | action=function() 71 | far.Message"sequence 2" 72 | end; 73 | } 74 | ``` 75 | [/spoiler] 76 | 77 | На один и тот же **_key_** можно назначить произвольное число макросов, конфликты разрешаются по правилам, принятым в LuaMacro. 78 | Макросы с модификаторами не лишают указанную комбинацию исходного значения: короткое нажатие выполнит исходное действие (или макрос, если назначен). 79 | 80 | **Ограничения:** 81 | - В качестве `key` поддерживаются только комбинации клавиш с модификаторами **Ctrl**/**Alt**/**Shift**. 82 | 83 | **Установка:** достаточно расположить прилагаемый **macroEx.lua** где-либо в **scripts**. 84 | 85 | [MacroLib]: http://forum.farmanager.com/viewtopic.php?f=11&t=6041 86 | -------------------------------------------------------------------------------- /Macros/reserve/jd/MacroEx/macroEx_test.lua: -------------------------------------------------------------------------------- 1 | local Info = Info or package.loaded.regscript or function(...) return ... end --luacheck: ignore 113/Info 2 | local nfo = Info { _filename or ..., 3 | name = "macroEx test"; 4 | description = "sample macros to test MacroEx"; 5 | version = "3"; --http://semver.org/lang/ru/ 6 | author = "jd"; 7 | url = "http://forum.farmanager.com/viewtopic.php?f=15&t=8764"; 8 | id = "931E8931-11D0-4FD9-B493-657898578F1B"; 9 | parent_id = "115C9534-8273-4F5A-94EB-E321D6DC8618"; 10 | --disabled = true; 11 | } 12 | if not nfo or nfo.disabled then return end 13 | 14 | Macro { 15 | description="test"; 16 | area="Editor"; key="CtrlF9"; 17 | action=function() 18 | far.Message"plain macro" 19 | end 20 | } 21 | 22 | for _,k in ipairs { 23 | "CtrlF9:Hold","CtrlF9:Double", 24 | "ShiftF8-F8", 25 | "CtrlF8-F9", 26 | "AltF1:Hold", 27 | "CtrlAltF1:Hold", 28 | "RCtrlRAltF2:Hold", 29 | "LCtrlLAltF2:Hold", 30 | "ShiftF1:Hold", 31 | "^:Hold","::Double", 32 | --"qwerty-0",--error 33 | "CtrlAlt:Hold","CtrlAlt:Double", 34 | "CtrlAlt-F8","CtrlF8-Alt", 35 | 36 | } do 37 | 38 | Macro { 39 | area="Editor"; 40 | key=k; 41 | description=k; 42 | action=function() 43 | far.Message(k) 44 | end 45 | } 46 | end 47 | 48 | Macro { 49 | description="CtrlF9:Double (Common)"; 50 | area="Common"; key="CtrlF9:Double"; priority=40; 51 | action=function() 52 | far.Message"CtrlF9:Double (Common)" 53 | end; 54 | } 55 | -------------------------------------------------------------------------------- /Macros/reserve/shmuel/RemoveBracketsFromButtons.lua: -------------------------------------------------------------------------------- 1 | -- Remove brackets from dialog buttons. 2 | -- http://forum.farmanager.com/viewtopic.php?p=128625#p128625 3 | -- http://forum.farmanager.com/viewtopic.php?p=128653#p128653 4 | 5 | local RemoveLevel = 0 -- 0:remove nothing; 1:remove only spaces; 6 | -- 2:remove only brackets; 3:remove brackets and spaces; 7 | local F = far.Flags 8 | 9 | local function Work (Event, FarDialogEvent) 10 | if Event == F.DE_DLGPROCINIT and FarDialogEvent.Msg == F.DN_INITDIALOG then 11 | local hDlg = FarDialogEvent.hDlg 12 | for k=1,1000 do 13 | local Item = hDlg:send("DM_GETDLGITEM", k) 14 | if not Item then break end 15 | if Item[1]==F.DI_BUTTON and 0==bit64.band(Item[9], F.DIF_NOBRACKETS) then 16 | Item[9] = bit64.bor(Item[9], F.DIF_NOBRACKETS) 17 | if RemoveLevel==1 then 18 | Item[10] = Item[10]:sub(1,1)..Item[10]:sub(3,-3)..Item[10]:sub(-1) 19 | elseif RemoveLevel==2 then 20 | Item[10] = Item[10]:sub(2,-2) 21 | else 22 | Item[10] = Item[10]:sub(3,-3) 23 | end 24 | hDlg:send("DM_SETDLGITEM", k, Item) 25 | end 26 | end 27 | end 28 | end 29 | 30 | Event { 31 | description="Remove brackets from dialog buttons"; 32 | group="DialogEvent"; condition = function() return RemoveLevel==1 or RemoveLevel==2 or RemoveLevel==3 end; 33 | action=Work; 34 | } 35 | -------------------------------------------------------------------------------- /Macros/reserve/shmuel/paragraph.lua: -------------------------------------------------------------------------------- 1 | -- Author: Shmuel Zeigerman 2 | -- Started: 2023-01-12 3 | -- Published in: Telegram messenger 4 | -- https://t.me/FarManager/1/6068 5 | -- https://t.me/FarManager/1/6071 6 | -- https://t.me/FarManager/1/6075 7 | 8 | Macro { 9 | description="Jump to next paragraph"; 10 | area="Editor"; key="F1"; 11 | action=function() 12 | local found 13 | local info=editor.GetInfo() 14 | for k=info.CurLine,info.TotalLines do 15 | local str = editor.GetString(nil,k,3) 16 | if found then 17 | if str:find("%S") then 18 | editor.SetPosition(nil,k,1); break 19 | end 20 | else 21 | if str:find("^%s*$") then found=true end 22 | end 23 | end 24 | end; 25 | } 26 | 27 | Macro { 28 | description="Jump to previous paragraph"; 29 | area="Editor"; key="F12"; 30 | action=function() 31 | local found 32 | local info=editor.GetInfo() 33 | for k=info.CurLine,1,-1 do 34 | local str = editor.GetString(nil,k,3) 35 | if found then 36 | if str:find("%S") then found=nil end 37 | else 38 | if str:find("^%s*$") then 39 | if k+1 < info.CurLine then 40 | editor.SetPosition(nil,k+1,1); return 41 | end 42 | found=true 43 | end 44 | end 45 | end 46 | editor.SetPosition(nil,1,1) 47 | end; 48 | } 49 | 50 | Macro { 51 | description="Select current paragraph"; 52 | area="Editor"; key="CtrlShiftU"; 53 | action=function() 54 | local info=editor.GetInfo() 55 | local str=editor.GetString(nil,info.CurLine,3) 56 | if not str:find("%S") then return end 57 | local line1,line2 = 1,info.TotalLines 58 | for k=info.CurLine-1,1,-1 do 59 | str=editor.GetString(nil,k,3) 60 | if not str:find("%S") then line1=k+1 break end 61 | end 62 | for k=info.CurLine+1,info.TotalLines do 63 | str=editor.GetString(nil,k,3) 64 | if not str:find("%S") then line2=k-1 break end 65 | end 66 | editor.Select(nil,"BTYPE_STREAM",line1,1,-1,line2-line1+1) 67 | end; 68 | } 69 | 70 | -------------------------------------------------------------------------------- /Macros/reserve/shmuel/same_size.lua: -------------------------------------------------------------------------------- 1 | -- Started: 2025-04-11, by Shmuel Zeigerman 2 | -- Published: 2025-04-11, at https://t.me/FarManager/19406 3 | -- Goal: Select all files whose size is not unique within the panel 4 | -- Language: Lua 5.1 5 | -- Category: Far Manager macro 6 | -- Works on: Windows: Far Manager >= "3.0.3008" 7 | -- Works on: Linux: far2m >= "2024-02-08" 8 | 9 | Macro { 10 | area="Shell"; key="F1"; 11 | action=function() 12 | local cache, list = {}, {} 13 | local inf = panel.GetPanelInfo(nil,1) 14 | for i=1, inf.ItemsNumber do 15 | local it = panel.GetPanelItem(nil,1,i) 16 | if not it.FileAttributes:find("d") then 17 | if cache[it.FileSize] then 18 | if cache[it.FileSize] > 0 then 19 | list[#list+1] = cache[it.FileSize] 20 | cache[it.FileSize] = -1 21 | end 22 | list[#list+1] = i 23 | else 24 | cache[it.FileSize] = i 25 | end 26 | end 27 | end 28 | panel.SetSelection(nil,1,list,true) 29 | panel.RedrawPanel(nil,1) 30 | end; 31 | } 32 | -------------------------------------------------------------------------------- /Macros/scripts/Common/ToggleScreens.lua: -------------------------------------------------------------------------------- 1 | -- Started: 2024-05-24 2 | -- This utility makes possible to switch back and forth between 2 screens. 3 | -- 1. Envoke the macro. 4 | -- 2. The Settings dialog appears. Select the desired screens and press "Enable" button. 5 | -- 3. Toggle between 2 screens with CtrlTab. 6 | 7 | local Enable 8 | local Screen1, Screen2 9 | 10 | local Title = "Toggle between 2 screens" 11 | 12 | local function Settings() 13 | local sd = require "far2.simpledialog" 14 | local items = { 15 | width=Far.Width; -- maximal width to avoid scrolling file names 16 | {tp="dbox"; text=Title; }, 17 | {tp="text"; text="Screen 1:" }, 18 | {tp="combobox"; dropdown=1; y1=""; x1=15; name="scr1"; list={}; val=Screen1 or 1; }, 19 | {tp="text"; text="Screen 2:" }, 20 | {tp="combobox"; dropdown=1; y1=""; x1=15; name="scr2"; list={}; val=Screen2 or 1; }, 21 | {tp="sep"; }, 22 | {tp="butt"; centergroup=1; text="&Enable"; name="enable"; default=1; }, 23 | {tp="butt"; centergroup=1; text="&Disable"; name="disable"; }, 24 | {tp="butt"; centergroup=1; text="&Cancel"; cancel=1; }, 25 | } 26 | 27 | local Dlg = sd.New(items) 28 | local Pos, Elem = Dlg:Indexes() 29 | 30 | local wcount = actl.GetWindowCount() 31 | if Elem.scr1.val > wcount then Elem.scr1.val = 1 end -- avoid combobox showing empty line 32 | if Elem.scr2.val > wcount then Elem.scr2.val = 1 end -- ditto 33 | 34 | for k=1,wcount do -- fill comboboxes 35 | local inf = actl.GetWindowInfo(k) 36 | local t = { Text = ("%-10s%s"):format(inf.TypeName, inf.Name) } 37 | table.insert(Elem.scr1.list, t) 38 | table.insert(Elem.scr2.list, t) 39 | end 40 | 41 | local out, pos = Dlg:Run() 42 | if out then 43 | Screen1 = out.scr1 44 | Screen2 = out.scr2 45 | Enable = (pos == Pos.enable) 46 | if Enable then actl.SetCurrentWindow(Screen1) end 47 | end 48 | end 49 | 50 | Macro { 51 | id="D5F2D8C5-1B68-43ED-9376-A49ABB21E76F"; 52 | description="Turn ON/OFF toggle 2 selected screens"; 53 | area="Common"; key="CtrlAltJ"; 54 | action=function() Settings() end; 55 | } 56 | 57 | Macro { 58 | id="E04D0104-D54F-4804-AD13-B9EF2B5DD99E"; 59 | description=Title; 60 | area="Common"; key="CtrlTab"; 61 | condition=function(key) 62 | return Enable and Screen1 and Screen2 63 | end; 64 | action=function() 65 | local pos = actl.GetWindowInfo().Pos 66 | pos = pos==Screen1 and Screen2 or Screen1 67 | if 0 == actl.SetCurrentWindow(pos) then 68 | Settings() 69 | end 70 | end; 71 | } 72 | -------------------------------------------------------------------------------- /Macros/scripts/Common/misc.lua: -------------------------------------------------------------------------------- 1 | Macro { 2 | id="F44159F4-556B-4593-A28B-EF3FD0B34FBE"; 3 | description="Reload macros"; 4 | area="Common"; key="CtrlShiftR"; 5 | action=function() 6 | local msg = win.GetEnv("FARLANG")=="Russian" and "Перезагрузка макросов" or "Reload macros" 7 | far.Message(msg,"","") 8 | far.MacroLoadAll() 9 | win.Sleep(400) 10 | far.AdvControl("ACTL_REDRAWALL") 11 | end; 12 | } 13 | 14 | Macro { 15 | id="BFC9624A-51AA-475C-B30E-3ECB8A73D22B"; 16 | description="Macro Browser"; 17 | area="Common"; key="AltShiftF1"; 18 | action=function() Plugin.Call(0x4EBBEFC8, "browser") end; 19 | } 20 | 21 | Macro { 22 | id="71A8298A-0237-429D-83F3-FC8EB5630979"; 23 | description="Insert Timestamp"; 24 | area="Shell Dialog Editor"; key="CtrlShiftT"; 25 | action=function() 26 | local items = { 27 | { Pat="%Y-%m-%d" }, 28 | { Pat="%Y-%m-%d, %a" }, 29 | { Pat="%Y-%m-%d %H:%M" }, 30 | { Pat="%Y-%m-%d %H:%M:%S" }, 31 | { Pat="[%Y-%m-%d]" }, 32 | { Pat="[%Y-%m-%d, %a]" }, 33 | { Pat="[%Y-%m-%d %H:%M]" }, 34 | { Pat="[%Y-%m-%d %H:%M:%S]" }, 35 | } 36 | for i,v in ipairs(items) do v.text="&"..i..". "..os.date(v.Pat) end 37 | local item = far.Menu({Title="Insert Timestamp"}, items) 38 | if not item then return end 39 | local guid = "FAD00DBE-3FFF-4095-9232-E1CC70C67737" --far.Guids.MakeFolderId 40 | if Area.Dialog and Dlg.Id==guid then item.Pat = item.Pat:gsub(":","-") end 41 | print(os.date(item.Pat)) 42 | end; 43 | } 44 | 45 | Macro { 46 | id="D4CFCC5C-ABD3-4C25-8245-621990382224"; 47 | description="Lua Calculator"; 48 | area="Common"; key="CtrlShiftF4"; 49 | action=function() mf.acall(require("far2.calc")); end; 50 | } 51 | 52 | Macro { 53 | id="00B425EF-B832-426A-BC8C-04F22E5FA3AC"; 54 | area="Common"; key="Ctrl/"; description="Получение названия клавиши. © SimSU"; 55 | action = function() 56 | local rus = win.GetEnv("farlang")=="Russian" 57 | far.Message(rus and " Нажмите клавишу... " or " Press key... ","","") 58 | local VK=mf.waitkey(0,1) 59 | VK = far.InputBox(nil, rus and "Название клавиши" or "Key name", 60 | (rus and "Код клавиши: %d (0x%X)" or "Key code: %d (0x%X)"): 61 | format(VK,VK), nil, mf.key(VK)) 62 | if VK then print(VK) end 63 | end; 64 | } 65 | 66 | Macro { 67 | id="4244A0FA-CFD6-4905-B266-D5235AD81990"; 68 | -- original: "Макросы для редактора Журко" 69 | key='ShiftBS'; area='Common'; 70 | description='XLat: QWERTY-ЙЦУКЕН выделения или слова и смена языка ввода ОС'; 71 | action=function() 72 | if not Object.Selected then Keys('SelWord') end 73 | Keys('XLat') 74 | mf.xlat('', 1) 75 | end; 76 | } 77 | 78 | NoMacro { 79 | description="Key logger"; 80 | area="Common"; key="/.+/"; 81 | condition=function(key) far.Log(key) end; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /Macros/scripts/Common/test_regex.lua: -------------------------------------------------------------------------------- 1 | -- Started : 2023-07-01 2 | 3 | local F = far.Flags 4 | 5 | local function DoTest() 6 | local sd = require "far2.simpledialog" 7 | local Width = 76 8 | local W1 = 3 + Width/2 9 | local Items = { 10 | width = Width; 11 | help = ":RegExp"; 12 | 13 | {tp="dbox"; text="Regular expressions"; }, 14 | {tp="text"; text="&Regex:"; width=W1; }, 15 | {tp="edit"; name="expr"; width=W1; hist="RegexTestRegex"; }, 16 | {tp="text"; text="&Test string:"; width=W1; ystep=2; }, 17 | {tp="edit"; name="subj"; width=W1; hist="RegexTestTest"; }, 18 | {tp="text"; text="&Substitution:"; width=W1; }, 19 | {tp="edit"; name="subst"; width=W1; hist="RegexTestSubstitution"; }, 20 | {tp="text"; text="Result:"; width=W1; }, 21 | {tp="edit"; name="result"; width=W1; readonly=1; }, 22 | 23 | {tp="listbox"; name="groups"; x1=W1+6; y1=2; width=24; height=10; text="Matches"; list={}; 24 | listnoclose=1; }, 25 | 26 | {tp="text"; text="Status:"; width=W1; y1=11; }, 27 | {tp="edit"; name="status"; readonly=1; }, 28 | {tp="sep"; }, 29 | {tp="butt"; text="OK"; default=1; centergroup=1; }, 30 | } 31 | 32 | local Dlg = sd.New(Items) 33 | local Pos = Dlg:Indexes() 34 | local Status 35 | 36 | function Items.proc(hDlg, Msg, Par1, Par2) 37 | if Msg == F.DN_EDITCHANGE and (Par1==Pos.expr or Par1==Pos.subj or Par1==Pos.subst) then 38 | hDlg:EnableRedraw(0) 39 | hDlg:ListDelete(Pos.groups) 40 | local expr = hDlg:GetText(Pos.expr) 41 | local ok, rex = pcall(regex.new, expr) 42 | if not ok then 43 | Status = "error" 44 | hDlg:SetText(Pos.result, "") 45 | hDlg:SetText(Pos.status, rex) 46 | else 47 | Status = "warning" 48 | local subj = hDlg:GetText(Pos.subj) 49 | local fr,to,offs = rex:exec(subj) 50 | if fr then 51 | Status = "normal" 52 | local txt = ("$0: %d-%d %s"):format(fr, to, subj:sub(fr,to)) 53 | hDlg:ListAdd(Pos.groups, {{Text=txt}}) 54 | for k=1,#offs,2 do 55 | txt = ("$%d: %d-%d %s"):format((k+1)/2, offs[k], offs[k+1], subj:sub(offs[k],offs[k+1])) 56 | hDlg:ListAdd(Pos.groups, {{Text=txt}}) 57 | end 58 | end 59 | 60 | local subst = hDlg:GetText(Pos.subst) 61 | -- convert replace pattern to LuaFAR syntax ($3 -> %3, \$ -> $, \\ -> \) 62 | subst = subst:gsub("%%", "%%%%") 63 | subst = regex.gsub(subst, [[ \$([0-9a-zA-Z]) | \\([$\\]) ]], 64 | function(a,b) return a and "%"..a or b end, nil, "x") 65 | -- get replace result 66 | local result = rex:gsub(subj, subst) 67 | hDlg:SetText(Pos.result, result) 68 | hDlg:SetText(Pos.status, fr and "Found" or "Not found") 69 | end 70 | hDlg:EnableRedraw(1) 71 | 72 | elseif Msg==F.DN_CTLCOLORDLGITEM and Par1==Pos.status then 73 | local color = 74 | Status == "normal" and 0x0B or 75 | Status == "warning" and 0x0E or 76 | Status == "error" and 0x0C or 0x00 77 | Par2[1],Par2[3] = color,color 78 | return Par2 79 | end 80 | end 81 | 82 | Dlg:Run() 83 | end 84 | 85 | if not Macro then DoTest() return end 86 | Macro { 87 | id="8F55C426-C0B4-4974-8FC8-FF5A26F8A26E"; 88 | description="Test regular expressions"; 89 | area="Common"; key="AltShiftF2"; 90 | flags="NoPluginPanels"; 91 | action=function() DoTest() end; 92 | } 93 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/bracket.lua: -------------------------------------------------------------------------------- 1 | -- bracket.lua 2 | 3 | local function FastGetString (num) 4 | return editor.GetString(nil, num, 2) 5 | end 6 | 7 | local function FindBracket (aSelect) 8 | local ei = editor.GetInfo() 9 | local line = FastGetString(ei.CurLine) 10 | 11 | local CurPos, CurLine = ei.CurPos, ei.CurLine 12 | local Bracket, Match, Direction, Increment 13 | 14 | local tForward = { ["("]=")", ["{"]="}", ["["]="]", ["<"]=">", } 15 | local tBackward = { [")"]="(", ["}"]="{", ["]"]="[", [">"]="<", } 16 | for k=0,1 do -- test cursor position and left-to-cursor position 17 | Increment = 1-k 18 | Bracket = line:sub (CurPos-k, CurPos-k) 19 | if tForward[Bracket] then 20 | Direction, Match = 1, tForward[Bracket] 21 | break 22 | elseif tBackward[Bracket] then 23 | Direction, Match = -1, tBackward[Bracket]; 24 | CurPos = CurPos - k 25 | break 26 | elseif k==1 or CurPos==1 then 27 | return 28 | end 29 | end 30 | 31 | local MatchCount = 1 32 | while true do 33 | CurPos = CurPos + Direction 34 | if CurPos > line:len() then 35 | CurLine = CurLine + 1 36 | if CurLine > ei.TotalLines then 37 | break 38 | end 39 | line = FastGetString(CurLine) 40 | CurPos = 1 41 | end 42 | if CurPos < 1 then 43 | CurLine = CurLine - 1 44 | if CurLine < 1 then 45 | break 46 | end 47 | line = FastGetString(CurLine) 48 | CurPos = line:len() 49 | end 50 | if CurPos >= 1 and CurPos <= line:len() then 51 | local Ch = line:sub (CurPos, CurPos) 52 | if Ch == Bracket then 53 | MatchCount = MatchCount + 1 54 | elseif Ch == Match then 55 | MatchCount = MatchCount - 1 56 | if MatchCount == 0 then 57 | local esp = { CurLine=CurLine, CurPos=CurPos+Increment } 58 | if (CurLine < ei.TopScreenLine or CurLine >= ei.TopScreenLine + ei.WindowSizeY) then 59 | esp.TopScreenLine = CurLine - ei.WindowSizeY/2; 60 | if esp.TopScreenLine < 1 then 61 | esp.TopScreenLine = 1 62 | end 63 | end 64 | editor.SetPosition(nil,esp) -- match found: set the new position 65 | if aSelect then 66 | local from,to = ei,esp 67 | if Direction < 0 then 68 | from,to = to,from 69 | end 70 | local width = to.CurPos-from.CurPos 71 | local height = to.CurLine-from.CurLine+1 72 | editor.Select(nil, "BTYPE_STREAM", from.CurLine, from.CurPos, width, height) 73 | end 74 | return 75 | end 76 | end 77 | end 78 | end 79 | editor.SetPosition(nil,ei) -- match not found: restore the initial position 80 | end 81 | 82 | Macro { 83 | id="9A1A2860-E6E7-4C6A-A98E-1417269740CE"; 84 | description="Go to matching bracket"; 85 | area="Editor"; key="CtrlE"; 86 | action=function() FindBracket(false) end; 87 | } 88 | Macro { 89 | id="733D4957-610C-4E05-B742-7D8A9FC81AB5"; 90 | description="Select to matching bracket"; 91 | area="Editor"; key="CtrlShiftE"; 92 | action=function() FindBracket(true) end; 93 | } 94 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/calc.lua: -------------------------------------------------------------------------------- 1 | local function GetText() 2 | local text = Editor.SelValue 3 | return (text ~= "") and text or Editor.GetStr() 4 | end 5 | 6 | local function EvalExpression() 7 | local f,err = loadstring("return "..GetText()) 8 | if f then 9 | local env = setmetatable({},{__index=function(t,c) return math[c] or _G[c] end}) 10 | local res = setfenv(f,env)() 11 | return tostring(res) 12 | else 13 | far.Message(err,"Compilation error", nil, "wl") 14 | return nil 15 | end 16 | end 17 | 18 | Macro { 19 | id="895DDA20-A5AC-4FE5-A562-F4A130F3B385"; 20 | description="Calculate Sum and Average"; 21 | area="Editor"; key="CtrlF9"; sortpriority=60; 22 | action=function() 23 | local sum = 0 24 | local min, max 25 | local n = 0 26 | local t = {} 27 | 28 | for num in regex.gmatch(GetText(), [[ \-? \b \d+ (?: \.\d+ )? \b ]], "x") do 29 | num = tonumber(num) 30 | n = n + 1 31 | t[n] = num 32 | sum = sum + num 33 | if n == 1 then 34 | min, max = num, num 35 | else 36 | if min > num then min = num end 37 | if max < num then max = num end 38 | end 39 | end 40 | 41 | local avr, std_dev, abs_dev 42 | if n > 0 then 43 | avr = sum / n 44 | std_dev, abs_dev = 0, 0 45 | for _,v in ipairs(t) do 46 | v = v - avr 47 | std_dev = std_dev + v*v 48 | abs_dev = abs_dev + (v>=0 and v or -v) 49 | end 50 | std_dev = math.sqrt(std_dev / n) 51 | abs_dev = abs_dev / n 52 | end 53 | 54 | local s = [[ 55 | Quantity: %d 56 | Sum: %s 57 | Average: %s 58 | Minimum: %s 59 | Maximum: %s 60 | Standard deviation: %s 61 | Aver. abs. deviation: %s]] 62 | 63 | local choice = far.Message( 64 | s:format(n, sum, avr or "n/a", min or "n/a", max or "n/a", std_dev or "n/a", abs_dev or "n/a"), 65 | "Sum and Average", n==0 and "OK" or "OK;Copy ∑Copy &average", "l") 66 | if choice==2 then far.CopyToClipboard(sum) 67 | elseif choice==3 then far.CopyToClipboard(avr) 68 | end 69 | end; 70 | } 71 | 72 | Macro { 73 | id="3D8D0D37-347B-4261-A826-C56FE02AAF5D"; 74 | description="Calculate Lua Expression"; 75 | area="Editor"; key="CtrlF9"; 76 | action=function() 77 | local res = EvalExpression() 78 | if res then 79 | local choice = far.Message(res, "Lua expression", "OK;&Insert;&Copy") 80 | if choice==2 then print("="..res..";") 81 | elseif choice==3 then far.CopyToClipboard(res) 82 | end 83 | end 84 | end; 85 | } 86 | 87 | Macro { 88 | id="2DEB1F1C-03DC-4D38-A2A7-9B4996F4E456"; 89 | description="Insert Lua Expression"; 90 | area="Editor"; key="CtrlF9"; 91 | action=function() 92 | local res = EvalExpression() 93 | if res then print("="..res..";") end 94 | end; 95 | } 96 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/dup_line.lua: -------------------------------------------------------------------------------- 1 | -- shmuel 14.06.2014 08:31:00 +0200 - build 1 2 | -- http://forum.farmanager.com/viewtopic.php?p=119751#p119751 3 | --------------------------------------------------------------------------------------- 4 | -- NOTE: for SciTE-like functionality of blocks duplication use CtrlP (built-in in Far) 5 | --------------------------------------------------------------------------------------- 6 | 7 | Macro { 8 | id="4A83A35D-0508-4ED3-A077-087C4DD9215D"; 9 | description="Duplicate current line"; 10 | area="Editor"; key="CtrlD"; 11 | action=function() 12 | local info = editor.GetInfo() 13 | local line = editor.GetString() 14 | local eol = line.StringEOL ~= "" and line.StringEOL or nil 15 | editor.UndoRedo(nil,"EUR_BEGIN") 16 | editor.SetPosition(nil,nil,1) 17 | editor.InsertString() 18 | editor.SetPosition(nil, info.CurLine, info.CurPos) 19 | editor.SetString(nil, nil, line.StringText, eol) 20 | editor.UndoRedo(nil,"EUR_END") 21 | info.CurLine = info.CurLine + 1 22 | editor.SetPosition(nil,info) 23 | editor.Redraw() 24 | end; 25 | } 26 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/dupfighter/dupfighter_eng.hlf: -------------------------------------------------------------------------------- 1 | .Language=English,English 2 | .PluginContents=Duplicate Fighter 3 | 4 | @Contents 5 | 6 | #Scope of processing:# 7 | Either range of lines containing selection or the entire editor 8 | contents (if there is no selection). 9 | 10 | #Stream blocks:# 11 | The entire line is processed if any part of it is selected. 12 | 13 | #Vertical blocks:# 14 | Only selected part of the line is processed. The action (if any) will be applied to the entire line. 15 | 16 | #A definition of "duplicate":# 17 | Two lines are considered "duplicate" with regards to each other if they are identical (or become identical 18 | after some conversion specified by the user). 19 | 20 | #Examples:# 21 | a) two lines are identical. 22 | b) two lines become identical after stripping white spaces from both their ends. 23 | c) two lines begin with the same 20 character sequence. 24 | 25 | ^ #The dialog# 26 | 27 | #Actions:# 28 | #(•) Remove duplicates# : remove all duplicate lines except one in each group of duplicates 29 | #(•) Clear duplicates# : clear all duplicate lines except one in each group of duplicates 30 | 31 | #[x] Keep last duplicate# 32 | On removing or clearing duplicates keep the last one rather than the first 33 | 34 | #[x] Keep empty lines# 35 | If checked then empty lines are skipped (not considered duplicate). The lines consisting entirely 36 | of whitespace characters are also skipped. 37 | 38 | #[x] Show statistics# 39 | If checked then some statistical data is shown after the work is done. 40 | 41 | #[x] Use Expression# 42 | If unchecked then two lines are considered duplicate only when they are identical. 43 | If checked then the #Expression# edit box should contain a #Lua expression# that will be applied to each 44 | selected line (or part of it in the case of a vertical block) and the results of the expression will be 45 | compared rather than the lines themselves. 46 | 47 | #*# Expressions can use the variable #L# that is the text of the line. 48 | #*# If the expression evaluates to a string or a number then this is the value to be used in comparisons. 49 | #*# If the expression evaluates to false/nil/nothing then the line is considered a NON-DUPLICATE. 50 | #*# Otherwise the value of line used in comparisons is true. 51 | 52 | #Examples of expressions resulting in either string or number:# 53 | #L:lower()# 54 | Two lines are considered duplicates if they only differ by case. 55 | #L:sub(10,20)# 56 | Two lines are considered duplicates if their [10,20] substrings are equal. 57 | #L:len()# 58 | Two lines are considered duplicates if they have the same length. 59 | #L:match("foobar")# 60 | Two lines are considered duplicates if they both contain "foobar". 61 | 62 | #[x] Convert to boolean# 63 | If checked then the result of expression is converted to boolean that is: not not X. 64 | In this case: 65 | - a line with value of false is NOT a duplicate, it does not participate in comparisons. 66 | - a line with value of true participates in comparisons. 67 | 68 | #Examples of expressions resulting in a boolean:# 69 | #L:match("foobar")# 70 | This line is considered duplicate if it contains "foobar". 71 | #not L:match("foobar")# 72 | This line is considered duplicate if it does not contain "foobar". 73 | #L:match("foo") and L:match("bar")# 74 | This line is considered duplicate if it contains both "foo" and "bar". 75 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/dupfighter/dupfighter_rus.hlf: -------------------------------------------------------------------------------- 1 | .Language=Russian,Russian (Русский) 2 | .PluginContents=Анти-дубликатор 3 | 4 | @Contents 5 | 6 | #Область обработки:# 7 | Диапазон строк, содержащих выделение, или содержимое всего файла (если нет выделения). 8 | 9 | #Поточный блок:# 10 | Вся строка обрабатывается, если какая-либо часть её выделена. 11 | 12 | #Вертикальный блок:# 13 | Обрабатывается только выделенная часть строки. Действие (если таковое имеется) 14 | будет применяться ко всей строке. 15 | 16 | #Понятие "дубликат":# 17 | Две строки считаются "дубликатами" по отношению друг к другу, если они идентичны 18 | (или становятся таковыми после некоторого преобразования, заданного пользователем). 19 | 20 | #Примеры:# 21 | a) две строки идентичны. 22 | b) две строки становятся идентичными после удаления пробелов на обоих их концах. 23 | c) две строки начинаются с одной и той же 20-символьной последовательности. 24 | 25 | ^ #Диалог# 26 | 27 | #Опции:# 28 | #(•) 1 Удалить дубликаты# : удалить все строки, кроме одной, в каждой группе дубликатов 29 | #(•) 2 Очистить дубликаты# : очистить все строки, кроме одной, в каждой группе дубликатов 30 | 31 | #[x] Сохранять последний дубликат# 32 | При удалении или очистке дубликатов сохранять последний, а не первый 33 | 34 | #[x] Сохранять пустые строки# 35 | Пустые строки пропускаются (не считаются дубликатами). 36 | Строки, состоящие целиком из пробельных символов, также пропускаются. 37 | 38 | #[x] Показывать статистику# 39 | По окончанию обработки будут показаны некоторые статистические данные. 40 | 41 | #[x] Использовать выражение# 42 | Если опция не установлена, то две строки считаются дубликатами только если они идентичны. 43 | Если опция установлена, то поле #Выражение# должно содержать #Lua-выражение#, которое будет применено 44 | к каждой выделенной строке (или ее части в случае вертикального блока) и сравниваться будут результаты вычислений 45 | выражения, а не сами строки. 46 | 47 | #*# Выражения могут использовать переменную #L#, которая содержит текст обрабатываемой строки. 48 | #*# Если результат вычисления имеет тип string или number, то данное значение и будет использоваться при сравнении. 49 | #*# Если результат вычисления равен false/nil/nothing, то строка считается НЕ-ДУБЛИКАТОМ. 50 | #*# В прочих случаях для сравнения используется содержимое строки. 51 | 52 | #Примеры выражений, дающих результат типа string или number:# 53 | #L:lower()# 54 | Две строки считаются дубликатами, если они отличаются только регистром. 55 | #L:sub(10,20)# 56 | Две строки считаются дубликатами, если их подстроки [10,20] равны. 57 | #L:len()# 58 | Две строки считаются дубликатами, если они имеют одинаковую длину. 59 | #L:match("foobar")# 60 | Две строки считаются дубликатами, если они обе содержат подстроку "foobar". 61 | 62 | #[x] Преобразовать в булевое# 63 | Результат выражения преобразуется в булевое значение применением "not not X". 64 | При этом: 65 | - строка со значением false считается не-дубликатом и не участвует в сравнениях. 66 | - строка со значением true участвует в сравнениях. 67 | 68 | #Примеры выражений, преобразовываемые в булевое:# 69 | #L:match("foobar")# 70 | Строка считается дубликатом, если она содержит подстроку "foobar". 71 | #not L:match("foobar")# 72 | Строка считается дубликатом, если она не содержит подстроку "foobar". 73 | #L:match("foo") and L:match("bar")# 74 | Строка считается дубликатом, если она содержит как "foo" так и "bar". 75 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/editor.lua: -------------------------------------------------------------------------------- 1 | local F = far.Flags 2 | 3 | Macro { 4 | id="064E3824-0517-4E07-88CD-32334D3EB490"; 5 | description="Use CtrlS for saving files instead of F2"; 6 | area="Editor"; key="CtrlS F2"; 7 | action = function() 8 | if akey(1,1)=="CtrlS" then Keys("F2") 9 | elseif akey(1,1)=="F2" then mf.usermenu() 10 | end 11 | end; 12 | } 13 | 14 | Macro { 15 | id="4210FF9C-A661-42B8-9D9A-FF9373B5FA9E"; 16 | description="Insert new GUID"; 17 | area="Editor"; key="CtrlF11"; 18 | action=function() 19 | print('"'..win.Uuid(win.Uuid()):upper()..'"') 20 | end; 21 | } 22 | 23 | Macro { 24 | id="D36B2FE9-93A9-4105-965D-FAC25C1733C5"; 25 | description="Save and run script from editor"; 26 | area="Editor"; key="CtrlF12"; 27 | action=function() 28 | for k=1,2 do 29 | local info=editor.GetInfo() 30 | if bit64.band(info.CurState, F.ECSTATE_SAVED)~=0 then 31 | local Flags = info.FileName:sub(-5):lower()==".moon" and "KMFLAGS_MOONSCRIPT" 32 | or "KMFLAGS_LUA" 33 | far.MacroPost('@"' .. info.FileName .. '"', Flags) 34 | break 35 | end 36 | if k==1 then editor.SaveFile(); end 37 | end 38 | end; 39 | } 40 | 41 | Macro { 42 | id="FFB9DBC9-B1C6-41DF-B755-21BDD5270A3C"; 43 | description="Insert Internet Shortcut"; 44 | area="Editor"; key="CtrlF11"; 45 | action=function() 46 | print[[ 47 | [InternetShortCut] 48 | Url=]] 49 | end; 50 | } 51 | 52 | Macro { 53 | id="94A59D13-A484-44CA-A192-31DC6096BC3D"; 54 | description="Insert C-file template"; 55 | area="Editor"; key="CtrlF11"; 56 | action=function() 57 | print[[ 58 | #include 59 | 60 | int main(int argc, const char* argv[]) 61 | { 62 | return 0; 63 | } 64 | ]] 65 | end; 66 | } 67 | 68 | Macro { 69 | id="32B5235E-35C8-4665-B254-9895C26B71D1"; 70 | description="Insert a simple dialog template"; 71 | area="Editor"; key="CtrlF11"; 72 | action=function() 73 | print[[ 74 | local F = far.Flags 75 | local sd = require "far2.simpledialog" 76 | local Items = { 77 | -- guid = xxx; 78 | -- help = "Contents"; 79 | -- width = 76; 80 | { tp="dbox"; text="Title"; }, 81 | { tp="text"; text="Enter the text:"; }, 82 | { tp="edit"; name="edit1"; }, 83 | { tp="sep"; }, 84 | { tp="butt"; centergroup=1; default=1; text="OK"; }, 85 | { tp="butt"; centergroup=1; cancel=1; text="Cancel"; }, 86 | } 87 | 88 | local Dlg = sd.New(Items) 89 | local Pos, Elem = Dlg:Indexes() 90 | 91 | Items.proc = function(hDlg, msg, param1, param2) 92 | if msg == F.DN_INITDIALOG then 93 | elseif msg == F.DN_BTNCLICK then 94 | elseif msg == F.DN_EDITCHANGE then 95 | elseif msg == F.DN_CLOSE then 96 | elseif msg == "EVENT_KEY" then 97 | elseif msg == "EVENT_MOUSE" then 98 | end 99 | end 100 | 101 | local out = Dlg:Run() 102 | if out then 103 | end 104 | ]] 105 | end; 106 | } 107 | 108 | Macro { 109 | id="C4571286-977C-437E-B631-8176E3A8448D"; 110 | description="Goto in the editor"; 111 | area="Editor"; key="CtrlG"; 112 | action=function() Keys("AltF8") end; 113 | } 114 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/events/Editor.ColorWord.moon: -------------------------------------------------------------------------------- 1 | -- Original author: Vadim Yegorov (aka zg) 2 | -- https://forum.farmanager.com/viewtopic.php?p=134436#p134436 3 | 4 | -- Options 5 | OptCaseSensitive=false 6 | -- End of options 7 | 8 | F=far.Flags 9 | band,bor,lshift,rshift = bit64.band, bit64.bor, bit64.lshift, bit64.rshift 10 | color = actl.GetColor "COL_EDITORTEXT" 11 | color = bor lshift(band(color,0xF),4), rshift(color,4) 12 | words={} 13 | 14 | Macro 15 | id:"FE36E158-6B89-4CB2-AEEE-AC7329E41222" 16 | area:"Editor" 17 | key:"F5" 18 | description:"Highlight Word Under Cursor" 19 | action:-> 20 | ei=editor.GetInfo! 21 | id=ei.EditorID 22 | if words[id] then words[id]=nil 23 | else 24 | pos=ei.CurPos 25 | line=editor.GetString!.StringText 26 | if pos<=line\len()+1 27 | slab=pos>1 and line\sub(1,pos-1)\match('[%w_]+$') or "" 28 | tail=line\sub(pos)\match('^[%w_]+') or "" 29 | if slab~="" or tail~="" then words[id]=OptCaseSensitive and slab..tail or (slab..tail)\lower! 30 | 31 | Event 32 | description:"Highlight Word Under Cursor" 33 | group:"EditorEvent" 34 | action:(id,event,param)-> 35 | if event==F.EE_REDRAW 36 | if words[id] 37 | ei=editor.GetInfo id 38 | start,finish=ei.TopScreenLine,math.min ei.TopScreenLine+ei.WindowSizeY,ei.TotalLines 39 | for ii=start,finish 40 | line,pos=editor.GetString(nil,ii).StringText,1 41 | while true 42 | jj,kk,curr=line\find("([%w_]+)",pos) 43 | if not jj then break 44 | if not OptCaseSensitive then curr=curr\lower! 45 | if curr==words[id] then editor.AddColor nil,ii,jj,kk,"ECF_AUTODELETE",color 46 | pos=kk+1 47 | elseif event==F.EE_CLOSE then words[id]=nil 48 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/events/editor_events.lua: -------------------------------------------------------------------------------- 1 | -- EE_SAVE: delete trailing spaces 2 | 3 | local F = far.Flags 4 | 5 | local function RemoveTrailingSpaces(Id, Event, Param) 6 | if Event==F.EE_SAVE then 7 | local info = editor.GetInfo() 8 | if info then 9 | for k=1,info.TotalLines do 10 | local ln = editor.GetString(nil,k,1) 11 | local from = ln.StringText:find("%s+$") 12 | if from then 13 | local str = ln.StringText:sub(1,from-1) 14 | editor.SetString(nil,k,str,ln.StringEOL) 15 | end 16 | end 17 | editor.SetPosition(nil,info) 18 | end 19 | end 20 | end 21 | 22 | Event { -- for text files 23 | description="EE_SAVE: delete trailing spaces"; 24 | group="EditorEvent"; 25 | filemask = ([[ bat c cmd cpp da_ h hex hlf hpp htm html lua luacheckrc mak moon pas py txt ]]) 26 | : gsub("%s*(%S+)%s*", "*.%1,") .. "changelog,makefile,readme"; 27 | action=RemoveTrailingSpaces; 28 | } 29 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/events/session_bookmarks.lua: -------------------------------------------------------------------------------- 1 | -- http://forum.farmanager.com/viewtopic.php?p=141574#p141574 2 | 3 | -------- Settings -------- 4 | local Color = 0xCF 5 | -------------------------- 6 | 7 | local F = far.Flags 8 | local colorFlags = F.ECF_AUTODELETE 9 | 10 | Event { 11 | description="EE_REDRAW: session Bookmarks"; 12 | group="EditorEvent"; 13 | action=function(EditorId, Event, Param) 14 | if Event==F.EE_REDRAW then 15 | local Arr = editor.GetSessionBookmarks() 16 | if Arr and Arr[1] then 17 | local Info = editor.GetInfo() 18 | for _,v in ipairs(Arr) do 19 | editor.AddColor(nil,v.Line,Info.LeftPos,Info.LeftPos,colorFlags,Color) 20 | end 21 | end 22 | end 23 | end 24 | } 25 | 26 | local function SetPosition(bm, info) -- info is currently not used 27 | editor.SetPosition(nil, bm.Line, bm.Cursor, nil, bm.Line-bm.ScreenLine+1, bm.LeftPos) 28 | end 29 | 30 | local function Goto(forward) 31 | local Info = editor.GetInfo() 32 | local Arr = editor.GetSessionBookmarks() 33 | if not (Info and Arr and Arr[1]) then return end 34 | for i,v in ipairs(Arr) do v.index=i end 35 | table.insert(Arr, {Line=Info.CurLine + (forward and 0.5 or -0.5)}) 36 | table.sort(Arr, function(a,b) return a.Line < b.Line end) 37 | for i,v in ipairs(Arr) do 38 | if not v.index then 39 | local bm = Arr[ forward and (i<#Arr and i+1 or 1) or (i>1 and i-1 or #Arr) ] 40 | SetPosition(bm, Info) 41 | break 42 | end 43 | end 44 | end 45 | 46 | local function BookmarksMenu() 47 | local Info = editor.GetInfo() 48 | local properties = {Title="Bookmarks", Bottom="Keys: Enter Del Esc", Flags=F.FMENU_AUTOHIGHLIGHT+F.FMENU_WRAPMODE} 49 | local bkeys = {{BreakKey="DELETE"}} 50 | while Info do 51 | local Arr = editor.GetSessionBookmarks() or {} 52 | for i,v in ipairs(Arr) do v.index=i end 53 | table.sort(Arr, function(a,b) return a.Line < b.Line end) 54 | local items = {} 55 | for i,v in ipairs(Arr) do 56 | local ch = i<10 and i or i<36 and string.char(i+55) 57 | ch = (ch and ch..". " or "") .. editor.GetString(nil,v.Line,2) 58 | items[i] = { text=ch; bm=v } 59 | end 60 | local v,pos = far.Menu(properties, items, bkeys) 61 | if not v then break end 62 | if v.BreakKey=="DELETE" then 63 | if items[pos] then editor.DeleteSessionBookmark(nil,items[pos].bm.index) end 64 | else 65 | SetPosition(v.bm, Info); break 66 | end 67 | end 68 | end 69 | 70 | Macro { 71 | id="DF2550D0-D97B-4209-ADCC-66545A65B4F9"; 72 | description="Session Bookmarks: add or delete a bookmark"; 73 | area="Editor"; key="ShiftF9"; 74 | action=function() 75 | local Info = editor.GetInfo() 76 | local Arr = editor.GetSessionBookmarks() or {} 77 | local deleted 78 | for i,v in ipairs(Arr) do 79 | if v.Line == Info.CurLine then editor.DeleteSessionBookmark(nil,i); deleted=true; end 80 | end 81 | if not deleted then editor.AddSessionBookmark() end 82 | end; 83 | } 84 | Macro { 85 | id="028A8FB3-4566-4666-931B-793DB697A13D"; 86 | description="Session Bookmarks: clear all bookmarks"; 87 | area="Editor"; key="CtrlShiftF9"; 88 | action=function() editor.ClearSessionBookmarks() end; 89 | } 90 | Macro { 91 | id="AA75EA37-72A3-43E9-B7CE-DC3249789E61"; 92 | description="Session Bookmarks: next bookmark"; 93 | area="Editor"; key="ShiftF6"; 94 | action=function() Goto(true) end; 95 | } 96 | Macro { 97 | id="383239DE-C327-4477-A6FD-85761F422473"; 98 | description="Session Bookmarks: previous bookmark"; 99 | area="Editor"; key="CtrlF6"; 100 | action=function() Goto(false) end; 101 | } 102 | Macro { 103 | id="AD2F4DC2-F059-4462-80B0-090303429152"; 104 | description="Session Bookmarks: menu"; 105 | area="Editor"; key="F9"; 106 | action=BookmarksMenu; 107 | } 108 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/pick_text.lua: -------------------------------------------------------------------------------- 1 | -- Started: 2016-02-28 2 | -- Goal: pick some text from current editor line into dialog input field 3 | -- What is picked: 4 | -- (a) if some text in the line is selected - that text is picked 5 | -- (b) else the word under cursor, 6 | -- else the nearest word in the forward direction, 7 | -- else the nearest word in the backward direction. 8 | -- If the text in the input field is equal to (a) then (b) is picked and vice versa. 9 | 10 | -- SETTINGS 11 | local pattern = regex.new("(\\w+)") 12 | -- END OF SETTINGS 13 | 14 | local function GetTextFromEditor (curtext) 15 | local line = editor.GetString() 16 | if line then 17 | local sel = line.SelStart>=1 and 18 | line.SelStart<=line.StringLength and 19 | line.StringText:sub(line.SelStart,line.SelEnd) 20 | if sel=="" then sel=nil end 21 | 22 | local word 23 | local pos = editor.GetInfo().CurPos 24 | local offset,last = pattern:find(line.StringText, pos==1 and 1 or pos-1) 25 | if offset then 26 | word = pattern:match(line.StringText:reverse(), line.StringLength-last+1):reverse() 27 | else 28 | local rword = pattern:match(line.StringText:reverse()) 29 | word = rword and rword:reverse() 30 | end 31 | if word=="" then word=nil end 32 | 33 | return (curtext==sel and word) or (curtext==word and sel) or sel or word 34 | end 35 | end 36 | 37 | Macro { 38 | id="BD8E52B8-D85A-4EE3-BE69-BCC0C72CCED3"; 39 | description="Pick word under editor cursor"; 40 | area="Dialog"; key="CtrlShiftW"; 41 | action=function() 42 | local tp = Dlg.ItemType 43 | if tp==4 or tp==6 or tp==10 then -- edit/fixedit/combobox 44 | local text = GetTextFromEditor(Dlg.GetValue(-1,0)) 45 | if text then Keys("CtrlY"); print(text); end 46 | end 47 | end; 48 | } 49 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/scroll.lua: -------------------------------------------------------------------------------- 1 | -- http://forum.farmanager.com/viewtopic.php?t=9239&p=135906#p126786 2 | 3 | local function BottomScreenLine(EI) 4 | return EI.TopScreenLine + EI.WindowSizeY - 1 5 | end 6 | 7 | Macro { 8 | id="A1F46DC8-D3CC-46C9-8A81-D03C16E92395"; 9 | description="Editor: Scroll Up"; 10 | area="Editor"; key="CtrlUp MsWheelUp"; 11 | action=function() 12 | local EI = editor.GetInfo() 13 | if EI.TopScreenLine > 1 then 14 | Keys("CtrlUp") 15 | if EI.CurLine < BottomScreenLine(EI) then Keys("Down") end 16 | end 17 | end; 18 | } 19 | 20 | Macro { 21 | id="66116298-EBCC-4BA3-ACE4-82D6CE68C991"; 22 | description="Editor: Scroll Down"; 23 | area="Editor"; key="CtrlDown MsWheelDown"; 24 | action=function() 25 | local EI = editor.GetInfo() 26 | if EI.TotalLines > BottomScreenLine(EI) then 27 | Keys("CtrlDown") 28 | if EI.CurLine > EI.TopScreenLine then Keys("Up") end 29 | end 30 | end; 31 | } 32 | 33 | Macro { 34 | id="3EE94338-2F2F-430D-9092-EACD31E4A53C"; 35 | description="Editor: Scroll Right"; 36 | area="Editor"; key="Ctrl'"; 37 | action=function() 38 | local EI = editor.GetInfo() 39 | EI.LeftPos = EI.LeftPos + 1 40 | if EI.CurTabPos < EI.LeftPos then 41 | EI.CurPos = EI.CurPos + 1 42 | end 43 | EI.CurTabPos = nil 44 | editor.SetPosition(nil, EI) 45 | end; 46 | } 47 | 48 | Macro { 49 | id="8B43B142-AF05-4C22-BB57-6D8273EE6CFE"; 50 | description="Editor: Scroll Left"; 51 | area="Editor"; key="Ctrl;"; 52 | action=function() 53 | local EI = editor.GetInfo() 54 | if EI.LeftPos > 1 then 55 | local ScrBar = Editor.Set(15,-1)~=0 and EI.TotalLines>EI.WindowSizeY 56 | local ClientSizeX = EI.WindowSizeX - (ScrBar and 1 or 0) 57 | if EI.CurTabPos-EI.LeftPos+1 == ClientSizeX then EI.CurTabPos = EI.CurTabPos-1 end 58 | EI.LeftPos, EI.CurPos = EI.LeftPos-1, nil 59 | editor.SetPosition(nil,EI) 60 | end 61 | end; 62 | } 63 | -------------------------------------------------------------------------------- /Macros/scripts/Editor/smart_home_end.lua: -------------------------------------------------------------------------------- 1 | Macro { 2 | id="CAD5CC2C-2BE8-47C4-8308-6F4D6C03194F"; 3 | description="Smart ShiftHome/ShiftEnd"; 4 | area="Editor"; key="ShiftHome ShiftEnd"; 5 | action=function() 6 | local info, str = editor.GetInfo(), editor.GetString() 7 | local to 8 | if akey(1) == "ShiftHome" then 9 | to = str.StringText:find("%S") or 1 10 | if to == info.CurPos then to = 1 end 11 | else 12 | to = str.StringLength + 1 13 | end 14 | editor.SetPosition(nil,nil,to) 15 | local fr = info.CurPos 16 | if fr > to then fr,to = to,fr end 17 | local a1, a2 = str.SelStart, str.SelEnd 18 | if a1>0 and a2>0 then -- if selection only on this line 19 | if a1==to then to=a2+1 -- merge the two parts 20 | elseif a2==fr-1 then fr=a1 -- ditto 21 | elseif a1>=fr and a1= 1 then 26 | local hDlg = FarDialogEvent.hDlg 27 | local DialogInfo = hDlg:GetDialogInfo() 28 | if DialogInfo and GUIDs[DialogInfo.Id] then 29 | for item = 1, 1e6 do 30 | local FarDialogItem = hDlg:GetDlgItem(item) 31 | if not FarDialogItem then break end 32 | if FarDialogItem[1] == F.DI_EDIT then 33 | local str, n = FarDialogItem[10]:gsub(Pattern, "") 34 | if n > 0 then 35 | hDlg:SetText(item, str) 36 | end 37 | break 38 | end 39 | end 40 | end 41 | end 42 | end 43 | 44 | Event { 45 | description="Fix Incorrect Names"; 46 | group="DialogEvent"; 47 | action=FIN; 48 | } 49 | -------------------------------------------------------------------------------- /Macros/scripts/Misc/menupos.lua: -------------------------------------------------------------------------------- 1 | -- started: 2023-09-19 2 | -- far2m only 3 | 4 | local F = far.Flags 5 | 6 | local data = mf.mload("shmuz", "FarMenuPositions") or {} 7 | 8 | local PlugMenuArea = "Shell" 9 | 10 | Macro { 11 | id="E5958B2C-B2AD-4526-9745-CCD9A428F847"; 12 | description="Plugin Menu Remember Pos"; 13 | area="Menu"; key="Enter NumEnter"; 14 | condition=function(key) return Menu.Id == far.Guids.PluginsMenuId end; 15 | action=function() 16 | data[PlugMenuArea] = Menu.Value 17 | Keys(akey(1)) 18 | end; 19 | } 20 | 21 | Macro { 22 | id="41832CDA-195F-40DE-845B-53111627EE19"; 23 | description="Config Menu Remember Pos"; 24 | area="Menu"; key="Enter NumEnter"; 25 | condition=function(key) return Menu.Id == far.Guids.PluginsConfigMenuId end; 26 | action=function() 27 | data.Config = Menu.Value 28 | Keys(akey(1)) 29 | end; 30 | } 31 | 32 | Macro { 33 | id="592C27DF-1812-4789-9880-7CAC0EF670B5"; 34 | description="Plugin Menu Select Pos"; 35 | area="Shell Editor Viewer"; key="F11"; 36 | action=function() 37 | PlugMenuArea = Area.Current 38 | local V = data[Area.Current] 39 | Keys("F11") 40 | if V then Menu.Select(V, 0) end 41 | end; 42 | } 43 | 44 | Macro { 45 | id="D10F0D17-5073-4F09-AC62-71125F43994D"; 46 | description="Config Menu Select Pos"; 47 | area="Shell"; key="AltShiftF9"; 48 | action=function() 49 | local V = data.Config 50 | Keys("AltShiftF9") 51 | if V then Menu.Select(V, 0) end 52 | end; 53 | } 54 | 55 | Event { 56 | description="Save menu positions"; 57 | group="ExitFAR"; 58 | action=function() mf.msave("shmuz", "FarMenuPositions", data) end; 59 | } 60 | -------------------------------------------------------------------------------- /Macros/scripts/Misc/show_guid.lua: -------------------------------------------------------------------------------- 1 | Macro { 2 | id="A4956445-6F20-48A0-956E-E6BAA86F6646"; 3 | description="Show dialog/menu ID"; 4 | area="Dialog Menu Disks UserMenu"; key="CtrlG"; 5 | action=function() 6 | local Id = Area.Dialog and Dlg.Id or Menu.Id 7 | local quotId = '"' .. Id .. '"' 8 | local fullname, text 9 | for name,guid in pairs(far.Guids or {}) do 10 | if guid == Id then 11 | fullname = "far.Guids." .. name 12 | break 13 | end 14 | end 15 | if fullname then 16 | local res = far.Message(fullname.."\n"..Id, "", "Copy &Name;Copy &GUID;Cancel") 17 | text = res==1 and fullname or res==2 and quotId 18 | else 19 | local res = far.Message(Id, "", "Copy &GUID;Cancel") 20 | text = res==1 and quotId 21 | end 22 | if text then far.CopyToClipboard(text) end 23 | end; 24 | } 25 | -------------------------------------------------------------------------------- /Macros/scripts/Panel modules/MacroPanel/macropanel_en.hlf: -------------------------------------------------------------------------------- 1 | .Language=English,English (English) 2 | .PluginContents=Macro Panel 3 | 4 | @Contents 5 | $ #Introduction# 6 | This plugin shows currently installed macros and events in Far Manager panels. 7 | 8 | The plugin can be activated from either: plugins menu, command line 9 | or folder shortcuts. 10 | 11 | ~Key combinations in the panel~@KeyCombinations@ 12 | ~Activation from the command line~@CommandLine@ 13 | 14 | @KeyCombinations 15 | $ #Key combinations in the panel# 16 | 17 | #Ctrl-F3# sort macros/events by description 18 | #Ctrl-F4# sort macros by area, sort events by group 19 | #Ctrl-F5# sort macros by key 20 | #LCtrl-0...9# set panel mode 0...9 21 | #F3#, #NumPad5# open macrofile containing current item in viewer 22 | #F4# open macrofile containing current item in editor 23 | #F5# toggle mode between "macros" and "events" 24 | #F6# toggle filter ON and OFF 25 | #Ctrl-Q# quick view (works only with items whose descriptions 26 | are valid file names) 27 | #Alt-Shift-F3# locate macrofile in passive panel 28 | #Ctrl-PgUp# locate macrofile in active panel 29 | 30 | @CommandLine 31 | $ #Command line# 32 | (1) #mp:macros [ [ []]]#, 33 | where - Far regular expression for description 34 | - Far regular expression for area 35 | - Far regular expression for key 36 | 37 | (2) #mp:events [ []]#, 38 | where - Far regular expression for description 39 | - Far regular expression for group 40 | 41 | These optional regular expressions are case insensitive and work 42 | in "find" mode. They make possible to display the desired set of 43 | macros or events while filtering out the rest. 44 | 45 | #Note:# 46 | Commands "macros" and "events" can be abbreviated to "m" and "e" 47 | correspondingly, e.g. instead of #mp:macros# one can write #mp:m#. 48 | 49 | #Example:# 50 | #mp:macros . ed|vi f[35]# 51 | will display only those macros whose area contains "ed" or "vi" 52 | and whose key contains "f3" or "f5". 53 | 54 | ~Useful area abbreviations~@AreaAbbreviations@ 55 | 56 | @AreaAbbreviations 57 | $ #Useful area abbreviations# 58 | #l$# Shell 59 | #ll#, #sh# Shell, ShellAutoCompletion 60 | #g$# Dialog 61 | #lo#, #ia# Dialog, DialogAutoCompletion 62 | #we# Viewer 63 | #ew#, #vi# Viewer, QView 64 | #ed# Editor 65 | #ea#, #ch# Search 66 | #sk#, #ks# Disks 67 | #nm#, #ma# MainMenu 68 | #nu#, #me# Menu, MainMenu, UserMenu 69 | #lp# Help 70 | #nf# Info 71 | #in# Info, FindFolder 72 | #qv# QView 73 | #ee#, #tr# Tree 74 | #nd#, #ld# FindFolder 75 | #rm#, #us# UserMenu 76 | #la# ShellAutoCompletion 77 | #ga# DialogAutoCompletion 78 | #pl#, #au# ShellAutoCompletion, DialogAutoCompletion 79 | -------------------------------------------------------------------------------- /Macros/scripts/Panel modules/panel.abcd: -------------------------------------------------------------------------------- 1 | C:\Shmuel_Home\BB\F\Today\1 2 | C:\Shmuel_Home\BB\F\Today\ACTL_SETARRAYCOLOR.lua 3 | C:\Shmuel_Home\BB\F\Today\Far 4 | C:\Shmuel_Home\BB\F\Today\Hours report, Shmuel, 2018-03.xls 5 | C:\Shmuel_Home\BB\F\Today\Issues 6 | C:\Shmuel_Home\BB\F\Today\LFH_BACKUP 7 | C:\Shmuel_Home\BB\F\Today\Last 8 | C:\Shmuel_Home\BB\F\Today\Lua 9 | C:\Shmuel_Home\BB\F\Today\Matras 10 | C:\Shmuel_Home\BB\F\Today\PCRE-UTF8-Quadratic 11 | C:\Shmuel_Home\BB\F\Today\Pro-Sam-instruct.pdf 12 | C:\Shmuel_Home\BB\F\Today\Programming 13 | C:\Shmuel_Home\BB\F\Today\Projects 14 | C:\Shmuel_Home\BB\F\Today\Relatives 15 | C:\Shmuel_Home\BB\F\Today\SQLiteDB-source 16 | C:\Shmuel_Home\BB\F\Today\Softlog 17 | C:\Shmuel_Home\BB\F\Today\ZTree CRASH.jpg 18 | C:\Shmuel_Home\BB\F\Today\ZeroBraneStudio 19 | C:\Shmuel_Home\BB\F\Today\lizip-0.2 20 | C:\Shmuel_Home\BB\F\Today\local_links.js 21 | C:\Shmuel_Home\BB\F\Today\lsqlite 22 | C:\Shmuel_Home\BB\F\Today\luajit-bug.lua 23 | C:\Shmuel_Home\BB\F\Today\luautf8-master 24 | C:\Shmuel_Home\BB\F\Today\mingw-w64-install.exe 25 | C:\Shmuel_Home\BB\F\Today\newprinter.txt 26 | C:\Shmuel_Home\BB\F\Today\panasonic-kx-tg68xx.pdf 27 | C:\Shmuel_Home\BB\F\Today\set_output.txt 28 | C:\Shmuel_Home\BB\F\Today\sqlite_tutorial.pdf 29 | C:\Shmuel_Home\BB\F\Today\test-jit_compile.lua 30 | C:\Shmuel_Home\BB\F\Today\test-sqlite3.lua 31 | C:\Shmuel_Home\BB\F\Today\water.txt 32 | C:\Shmuel_Home\BB\F\Today\Зхуйот Социалиот (листок принесла Света Пазюк).jpg 33 | C:\Shmuel_Home\BB\F\Today\коробки.txt 34 | -------------------------------------------------------------------------------- /Macros/scripts/Panel modules/pmodule1.lua: -------------------------------------------------------------------------------- 1 | local F = far.Flags 2 | local Title ="Demo panel in LuaMacro" 3 | local mod = {} 4 | 5 | mod.Info = { 6 | Guid = win.Uuid("715E5E90-DEB9-470A-84CE-7CF8D92A7B05"); -- mandatory field 7 | Author = "Shmuel Zeigerman"; 8 | StartDate = "2018-03-13"; 9 | } 10 | 11 | local function FileToObject(FileName) 12 | FileName = far.ConvertPath(FileName, "CPM_FULL") 13 | local attr = win.GetFileAttr(FileName) 14 | if not attr or attr:find("d") then return end -- in Linux fopen may "open" a directory 15 | local fp = io.open(FileName) 16 | if fp then 17 | local obj = { HostFile=FileName; List={} } 18 | for line in fp:lines() do 19 | line = line:gsub("\r", "") 20 | table.insert(obj.List, {FileName=line}) 21 | end 22 | fp:close() 23 | return obj 24 | end 25 | end 26 | 27 | function mod.OpenFilePlugin (Name, Data, OpMode) 28 | if Name and Name:sub(-5):lower() == ".abcd" then 29 | return FileToObject(Name) 30 | end 31 | end 32 | 33 | function mod.Open(OpenFrom, _Id, Item) 34 | if OpenFrom == F.OPEN_SHORTCUT then 35 | return FileToObject(Item.HostFile) 36 | 37 | elseif OpenFrom == F.OPEN_FINDLIST then -- luacheck: ignore 38 | -- If we uncomment the line "return true", then this module will be 39 | -- used instead of TmpPanel for displaying search results. 40 | ---- return true 41 | end 42 | end 43 | 44 | function mod.GetFindData(object, handle, OpMode) 45 | return object.List 46 | end 47 | 48 | function mod.GetOpenPanelInfo(object, handle) 49 | return { 50 | HostFile = object.HostFile; 51 | PanelTitle = Title; 52 | ShortcutData = ""; 53 | StartSortMode = F.SM_UNSORTED; 54 | StartSortOrder = 0; 55 | Flags = bit64.bor(0, F.OPIF_ADDDOTS); 56 | } 57 | end 58 | 59 | function mod.SetFindList (object, handle, Items) 60 | object.List = Items 61 | return true 62 | end 63 | 64 | if false then 65 | function mod.ProcessPanelInput (object, handle, Rec) 66 | if not (Rec.EventType==F.KEY_EVENT and Rec.KeyDown) then return; end 67 | local vcode = Rec.VirtualKeyCode 68 | local cstate = Rec.ControlKeyState 69 | local nomods = cstate == 0 -- luacheck: no unused 70 | --local alt = cstate == F.LEFT_ALT_PRESSED or cstate == F.RIGHT_ALT_PRESSED 71 | local ctrl = cstate == F.LEFT_CTRL_PRESSED or cstate == F.RIGHT_CTRL_PRESSED 72 | local shift = cstate == F.SHIFT_PRESSED 73 | 74 | local Name = far.InputRecordToName(Rec) 75 | --if Name == "ShiftF2" then return true; end 76 | --if Name == "F11" then return true; end 77 | 78 | far.Show(vcode,cstate,ctrl,shift,Name) 79 | end 80 | end 81 | 82 | MenuItem { 83 | description = Title; 84 | menu = "Plugins"; 85 | area = "Shell"; 86 | guid = "5E1ECBD6-F6E1-4A02-AC90-DB49DB6E350C"; 87 | text = Title; 88 | action = function(OpenFrom, Item) 89 | return mod, FileToObject(APanel.Current) 90 | end; 91 | } 92 | 93 | CommandLine { 94 | description = Title; 95 | prefixes = "abcd"; 96 | action = function(prefix,text) 97 | if text then return mod, FileToObject(text); end 98 | end; 99 | } 100 | 101 | PanelModule(mod) 102 | -------------------------------------------------------------------------------- /Macros/scripts/Plugins/highlight.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- Highlight -- 3 | ------------------------------------------------------------------------------ 4 | local Guid = 0xF6138DC9 5 | 6 | Macro { 7 | id="565500E7-F890-4D85-9A00-A9E0E10FA1C8"; 8 | description="Highlight: Select Syntax menu"; 9 | area="Editor"; key="CtrlShift8"; 10 | condition=function() return Plugin.Exist(Guid) end; 11 | action = function() Plugin.Call(Guid, "own", "SelectSyntax") end; 12 | } 13 | 14 | Macro { 15 | id="CFFA7850-C6FC-484F-BEE5-072D3DBD01B9"; 16 | description="Highlight: Highlight Extra"; 17 | area="Editor"; key="CtrlShift9"; 18 | condition=function() return Plugin.Exist(Guid) end; 19 | action = function() Plugin.Call(Guid, "own", "HighlightExtra") end; 20 | } 21 | 22 | Macro { 23 | id="215ECCC1-1E5B-4FB7-B6F4-D4A8AE124B67"; 24 | description="Highlight: Settings dialog"; 25 | area="Editor"; key="CtrlShift-"; 26 | condition=function() return Plugin.Exist(Guid) end; 27 | action = function() Plugin.Call(Guid, "own", "Settings") end; 28 | } 29 | -------------------------------------------------------------------------------- /Macros/scripts/Plugins/lf_history.lua: -------------------------------------------------------------------------------- 1 | local LFHistory = 0xA745761D 2 | 3 | local function condition() return Plugin.Exist(LFHistory) end 4 | 5 | local function LFH_run(cmd) Plugin.Call(LFHistory, "own", cmd) end 6 | 7 | Macro { 8 | id="B2C498EE-37D2-4162-86B0-ECB1C9B16CA4"; 9 | description="LuaFAR History: commands"; 10 | area="Shell Info QView Tree"; key="AltF8"; 11 | condition=condition; 12 | action=function() LFH_run"commands" end; 13 | } 14 | 15 | Macro { 16 | id="A15B55FC-A36B-41EA-9110-96B441F74185"; 17 | description="LuaFAR History: view/edit"; 18 | area="Shell Editor Viewer"; key="AltF11"; 19 | condition=condition; 20 | action=function() LFH_run"view" end; 21 | } 22 | 23 | Macro { 24 | id="C8CE32F4-48CF-45DA-91CA-07B521951516"; 25 | description="LuaFAR History: folders"; 26 | area="Shell"; key="AltF12"; 27 | condition=condition; 28 | action=function() LFH_run"folders" end; 29 | } 30 | 31 | Macro { 32 | id="97F6E9E5-CD17-431D-826F-79EFC51F4ED3"; 33 | description="LuaFAR History: locate file"; 34 | area="Shell"; key="ShiftSpace"; 35 | condition=condition; 36 | action=function() LFH_run"locate" end; 37 | } 38 | -------------------------------------------------------------------------------- /Macros/scripts/Plugins/lf_search.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- LuaFAR Search -- 3 | ------------------------------------------------------------------------------ 4 | 5 | local Guid = 0x8E11EA75 6 | 7 | local function LFS_Editor(...) Plugin.Call(Guid, "own", "editor", ...) end 8 | local function LFS_Panels(...) Plugin.Call(Guid, "own", "panels", ...) end 9 | local function LFS_Exist() return Plugin.Exist(Guid) end 10 | 11 | Macro { 12 | id="252A4DE0-1FFB-4409-9691-15A874BF7ADD"; 13 | description="LF Search: Editor Find"; 14 | area="Editor"; key="F3"; 15 | condition=LFS_Exist; 16 | action = function() LFS_Editor "search" end; 17 | } 18 | 19 | Macro { 20 | id="F2176F24-61A1-4180-A3E9-7D93957DF991"; 21 | description="LF Search: Editor Replace"; 22 | area="Editor"; key="CtrlF3"; 23 | condition=LFS_Exist; 24 | action = function() LFS_Editor "replace" end; 25 | } 26 | 27 | Macro { 28 | id="70DEB965-DB0F-40C7-B3AC-0BE52AD06BE6"; 29 | description="LF Search: Editor Repeat"; 30 | area="Editor"; key="ShiftF3"; 31 | condition=LFS_Exist; 32 | action = function() LFS_Editor "repeat" end; 33 | } 34 | 35 | Macro { 36 | id="2EA68553-569E-434B-8294-94A8451EA6FB"; 37 | description="LF Search: Editor Repeat reverse"; 38 | area="Editor"; key="AltF3"; 39 | condition=LFS_Exist; 40 | action = function() LFS_Editor "repeat_rev" end; 41 | } 42 | 43 | Macro { 44 | id="3973E1B8-A5DE-479D-910C-12997C7E129F"; 45 | description="LF Search: Editor search word"; 46 | area="Editor"; key="Alt6"; 47 | condition=LFS_Exist; 48 | action = function() LFS_Editor "searchword" end 49 | } 50 | 51 | Macro { 52 | id="43F80CC7-7496-4815-8714-A9FF73A2DA78"; 53 | description="LF Search: Editor search word reverse"; 54 | area="Editor"; key="Alt5"; 55 | condition=LFS_Exist; 56 | action = function() LFS_Editor "searchword_rev" end; 57 | } 58 | 59 | Macro { 60 | id="FC4DED58-C741-46FF-9070-F3A0CB6C9EC7"; 61 | description="LF Search: Editor Multi-line replace"; 62 | area="Editor"; key="CtrlShiftF3"; 63 | condition=LFS_Exist; 64 | action = function() LFS_Editor "mreplace" end; 65 | } 66 | 67 | Macro { 68 | id="2CA8B91D-C2EB-4387-8AC9-79BDC7C70763"; 69 | description="LF Search: Panel Find"; 70 | area="Shell QView Tree Info"; key="CtrlShiftF"; 71 | condition=LFS_Exist; 72 | action = function() LFS_Panels "search" end; 73 | } 74 | 75 | Macro { 76 | id="01E5738F-1250-4080-8A32-E1C9F2FC67F8"; 77 | description="LF Search: Panel Replace"; 78 | area="Shell QView Tree Info"; key="CtrlShiftG"; 79 | condition=LFS_Exist; 80 | action = function() LFS_Panels "replace" end; 81 | } 82 | 83 | Macro { 84 | id="C309794F-D629-4B8C-90CE-ED3804FEE2A2"; 85 | description="LF Search: Panel Grep"; 86 | area="Shell QView Tree Info"; key="CtrlShiftH"; 87 | condition=LFS_Exist; 88 | action = function() LFS_Panels "grep" end; 89 | } 90 | 91 | Macro { 92 | id="AFCCCC5A-177B-4A8B-BC34-7FC74F8ABEB3"; 93 | description="LF Search: Panel Rename"; 94 | area="Shell QView Tree Info"; key="CtrlShiftJ"; 95 | condition=LFS_Exist; 96 | action = function() LFS_Panels "rename" end 97 | } 98 | 99 | Macro { 100 | id="658B6513-DD1B-409F-886B-6C9BDAECCBC0"; 101 | description="LF Search: Show Panel"; 102 | area="Shell QView Tree Info"; key="CtrlShiftK"; 103 | condition=LFS_Exist; 104 | action = function() LFS_Panels "panel" end 105 | } 106 | 107 | -- This macro works best when "Show line numbers" Grep option is used. 108 | -- When this option is off the jump occurs to the beginning of the file. 109 | Macro { 110 | id="69BF96AF-F09E-43C0-BDB3-4A38B7BE156A"; 111 | description="Jump from Grep results to file and position under cursor"; 112 | area="Editor"; key="CtrlShiftG"; 113 | condition=LFS_Exist; 114 | action=function() 115 | local lnum = editor.GetString(nil,nil,3):match("^(%d+)[:%-]") 116 | local EI = editor.GetInfo() 117 | for n = EI.CurLine,1,-1 do 118 | local fname = editor.GetString(nil,n,3):match("^%[%d+%]%s+(.-) : %d+$") 119 | if fname then 120 | editor.Editor(fname,nil,nil,nil,nil,nil, 121 | {EF_NONMODAL=1,EF_IMMEDIATERETURN=1,EF_ENABLE_F6=1}, 122 | lnum or 1, lnum and math.max(1, EI.CurPos-lnum:len()-1) or 1) 123 | break 124 | end 125 | end 126 | end; 127 | } 128 | -------------------------------------------------------------------------------- /Macros/scripts/Shell/misc2.lua: -------------------------------------------------------------------------------- 1 | local SharedKey = "CtrlAltE" 2 | local SharedId = "F2199E52-FE6D-45C0-B39B-8C06984EBBE1" 3 | 4 | local function ShowDiff (aName) 5 | local dir = panel.GetPanelDirectory(nil, 1).Name 6 | panel.SetPanelDirectory(nil, 1, win.JoinPath(far.GetMyHome(), "repos", aName)) 7 | local file = far.InMyTemp(aName) .. ".diff" 8 | local fp = io.popen("git diff >"..file) 9 | if fp then 10 | fp:close() 11 | Plugin.Command(far.GetPluginId(), "edit:[1,1]"..file) 12 | end 13 | panel.SetPanelDirectory(nil, 1, dir); 14 | end 15 | 16 | local Repos = { 17 | { dir="far2m"; spr=49; }, 18 | { dir="luafar2m"; spr=48; }, 19 | { dir="luafar-far2l"; spr=47; }, 20 | { dir="scite-config"; spr=46; }, 21 | { dir="mactest"; spr=45; }, 22 | } 23 | 24 | for _,repo in ipairs(Repos) do 25 | Macro { 26 | id=SharedId; key=SharedKey; sortpriority=repo.spr; 27 | description = "git diff: " .. repo.dir; 28 | area="Shell"; 29 | action=function() ShowDiff(repo.dir) end; 30 | } 31 | end 32 | 33 | Macro { 34 | id=SharedId; key=SharedKey; sortpriority=44; 35 | description = "Generate luacheck_config.lua"; 36 | area="Shell"; 37 | action=function() 38 | local trg = far.GetMyHome().."/luacheck_config.lua" 39 | require("far2.luacheck_generate")(trg) 40 | far.Message("Done") 41 | end 42 | } 43 | 44 | Macro { 45 | id="6F4A2EBD-FE21-4417-8AA7-451FDFB3B8F4"; 46 | description="Quick search"; 47 | area="Shell"; key="/LAlt\\S/"; 48 | action=function() 49 | local ch = akey(1):sub(-1) 50 | Keys("Alt*", ch) 51 | end; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Macros/scripts/Shell/mkdir/mkdir.example.alias: -------------------------------------------------------------------------------- 1 | # Rename "mkdir.example.alias" to "mkdir.alias" 2 | # The lines starting with # are ignored 3 | # The lines' format is: alias name followed by space(s) followed by alias value 4 | # Alias names may not contain spaces 5 | # Alias names are case insensitive (foo and FOO is the same alias) 6 | # In the input dialog aliases must be within angle brackets, e.g. 7 | 8 | # If alias name has a "lua:" prefix then the alias is Lua code that will be 9 | # executed producing the final alias value. 10 | # The "lua:" prefix must be omitted in the input dialog, e.g. alias name 11 | # lua:date corresponds to just in the dialog. 12 | 13 | # Examples 14 | journey {Documents;Photo;Video;Music} 15 | months {January;February;March;April;May;June;July;August;September;October;November;December} 16 | lua:date os.date("%Y-%m-%d__%H-%M-%S") 17 | -------------------------------------------------------------------------------- /Macros/scripts/Shell/mkdir/mkdir.grammar: -------------------------------------------------------------------------------- 1 | -- highlight: lua 2 | -- started: 2025-06-01 3 | 4 | local lpeg = require "lpeg" 5 | 6 | local delim = lpeg.P(";") 7 | local open = lpeg.P("{") 8 | local close = lpeg.P("}") 9 | local dash = lpeg.P("-") 10 | local quote = lpeg.P("\"") 11 | local decnum = lpeg.R("09") ^ 1 12 | local hexnum = lpeg.R("09","af","AF") ^ 1 13 | local symbol = lpeg.utfR(1, 0x10FFFF) 14 | 15 | local special = delim + open + close + quote + lpeg.S("<>") -- special character 16 | 17 | local decrange = (open * lpeg.C(decnum) * dash * lpeg.C(decnum) * close) / 18 | function(fr,to) 19 | local fmt = fr:sub(1,1)=="0" and ("%0"..#fr.."d") or "%d" 20 | fr, to = tonumber(fr), tonumber(to) 21 | return { fr=fr; to=to; cur=fr; fmt=fmt; } 22 | end 23 | 24 | local hexrange = open * lpeg.C(hexnum) * dash * lpeg.C(hexnum) * close / 25 | function(fr,to) 26 | local fmt = fr:sub(1,1)=="0" and ("%0"..#fr.."X") or "%X" 27 | if fr:find("[a-f]") or to:find("[a-f]") then fmt = fmt:lower() end 28 | fr, to = tonumber(fr,16), tonumber(to,16) 29 | return { fr=fr; to=to; cur=fr; fmt=fmt; } 30 | end 31 | 32 | local symrange = open * lpeg.C(symbol) * dash * lpeg.C(symbol) * close / 33 | function(fr,to) 34 | fr, to = fr:byte(), to:byte() 35 | return { fr=fr; to=to; cur=fr; sym=true; } 36 | end 37 | 38 | local range = decrange + hexrange + symrange -- any range 39 | local unquoted = lpeg.C((symbol - special) ^ 1) -- unquoted char sequence 40 | local quoted = quote * lpeg.C((symbol - quote) ^ 1) * quote -- quoted char sequence 41 | local literal = quoted + unquoted -- literal string 42 | 43 | local List = lpeg.V("List") 44 | local Concat = lpeg.V("Concat") 45 | local Enum = lpeg.V("Enum") 46 | 47 | local Grammar = lpeg.P { 48 | "All", 49 | All = List * (-1); 50 | List = delim^0 * lpeg.Ct( Concat * (delim^1 * Concat)^0 ) * delim^0 51 | / function(t) t.idx=1; return t; end; 52 | Concat = lpeg.Ct( (range + Enum + literal) ^ 1 ) / function(t) t.concat=true; return t; end; 53 | Enum = open * List * close; 54 | } 55 | 56 | local function IncIndex(item) 57 | if type(item) == "string" then 58 | return false 59 | 60 | elseif item.idx then 61 | if IncIndex(item[item.idx]) then 62 | return true 63 | elseif item.idx < #item then 64 | item.idx = item.idx + 1 65 | return true 66 | else 67 | item.idx = 1 68 | end 69 | 70 | elseif item.concat then 71 | for k=#item, 1, -1 do 72 | if IncIndex(item[k]) then 73 | return true 74 | end 75 | end 76 | 77 | elseif item.cur then 78 | if item.cur < item.to then 79 | item.cur = item.cur + 1 80 | return true 81 | else 82 | item.cur = item.fr 83 | end 84 | 85 | else 86 | error("IncIndex") 87 | end 88 | 89 | end 90 | 91 | local function GetValue(item) 92 | if type(item) == "string" then 93 | return item 94 | 95 | elseif item.idx then 96 | return GetValue(item[item.idx]) 97 | 98 | elseif item.concat then 99 | local t = {} 100 | for _,v in ipairs(item) do 101 | local out 102 | if type(v) == "string" then 103 | out = v 104 | elseif type(v) == "table" then 105 | if v.idx or v.concat then 106 | out = GetValue(v) 107 | elseif v.sym then 108 | out = utf8.char(v.cur) 109 | elseif v.fmt then 110 | out = v.fmt:format(v.cur) 111 | else 112 | error("GetValue - 1") 113 | end 114 | else 115 | error("GetValue - 2") 116 | end 117 | t[#t+1] = out 118 | end 119 | return table.concat(t) 120 | 121 | else 122 | error("GetValue - 2") 123 | 124 | end 125 | end 126 | 127 | local function DoConcat(acc, concat) 128 | repeat 129 | table.insert(acc, GetValue(concat)) 130 | until not IncIndex(concat) 131 | end 132 | 133 | local function GetList(subj) 134 | local list = Grammar:match(subj) 135 | if list then 136 | local acc = {} 137 | for _,v in ipairs(list) do 138 | DoConcat(acc, v) 139 | end 140 | return acc 141 | end 142 | return nil 143 | end 144 | 145 | return { 146 | GetList = GetList; 147 | } 148 | -------------------------------------------------------------------------------- /Macros/scripts/Shell/mkdir/mkdir.test: -------------------------------------------------------------------------------- 1 | -- highlight: lua 2 | 3 | local testdata = { 4 | { "DISK{1;2;3}.DSK", {"DISK1.DSK", "DISK2.DSK", "DISK3.DSK"} }, 5 | 6 | { [[{Beta;Release}\{Disk1;Disk2;Disk3}]], { 7 | [[Beta\Disk1]], [[Beta\Disk2]], [[Beta\Disk3]], 8 | [[Release\Disk1]], [[Release\Disk2]], [[Release\Disk3]] } }, 9 | 10 | { [[{Beta;Release}\Disk{1-3}]], { 11 | [[Beta\Disk1]], [[Beta\Disk2]], [[Beta\Disk3]], 12 | [[Release\Disk1]], [[Release\Disk2]], [[Release\Disk3]] } }, 13 | 14 | { "{1-10}", {"1","2","3","4","5","6","7","8","9","10" } }, 15 | 16 | { "{01-10}", {"01","02","03","04","05","06","07","08","09","10" } }, 17 | 18 | { "{1-5;9;12;15-20}", {"1-5","9","12","15-20" } }, 19 | 20 | { "{1-5};9;12;{15-20}", {"1","2","3","4","5","9","12","15","16","17","18","19","20" } }, 21 | 22 | { "{1-1F}", {"1","10","11","12","13","14","15","16","17","18","19","1A","1B","1C","1D","1E","1F", 23 | "2","3","4","5","6","7","8","9","A","B","C","D","E","F", } }, 24 | 25 | { "{00-aa}", {"00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12", 26 | "13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25", 27 | "26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38", 28 | "39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b", 29 | "4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e", 30 | "5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71", 31 | "72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84", 32 | "85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97", 33 | "98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa"} }, 34 | 35 | { "{a-z}", {"a","b","c","d","e","f","g","h","i","j","k","l","m", 36 | "n","o","p","q","r","s","t","u","v","w","x","y","z"} }, 37 | 38 | { "{A-L;m-z}", {"A-L","m-z"} }, 39 | 40 | { "{A-L};{m-z}", {"A","B","C","D","E","F","G","H","I","J","K","L", 41 | "m","n","o","p","q","r","s","t","u","v","w","x","y","z"} }, 42 | 43 | { "base;base{01-10}", { "base","base01","base02","base03","base04","base05", 44 | "base06","base07","base08","base09","base10"} }, 45 | 46 | } 47 | 48 | local filename = far.ConvertPath("mkdir.lua") 49 | local chunk = assert(loadfile(filename)) 50 | local md = chunk(filename, "require") 51 | 52 | for i,v in ipairs(testdata) do 53 | local ref = v[2] 54 | local out = assert( md.GetDirs(v[1]), v[1] ) 55 | if #out == #ref then 56 | table.sort(ref) 57 | table.sort(out) 58 | for k=1,#ref do 59 | if out[k] ~= ref[k] then 60 | far.Show(v[1], out[k], ref[k]) 61 | return 62 | end 63 | end 64 | else 65 | far.Message("wrong number of directories\n"..v[1], "MkDir test", nil, "l") 66 | --require("far2.lua_explorer")(out) 67 | return 68 | end 69 | end 70 | 71 | far.Message("Success", "MkDir test") 72 | 73 | -------------------------------------------------------------------------------- /Macros/scripts/Shell/symlink.lua: -------------------------------------------------------------------------------- 1 | -- Started: 2023-04-12 2 | -- FAR version: far2m 3 | 4 | local F = far.Flags 5 | 6 | local function CheckSymlink(_,data) 7 | data.SymlinkTarget = far.GetReparsePointInfo(APanel.Current) 8 | return data.SymlinkTarget 9 | end 10 | 11 | local function Goto(data) 12 | Plugin.Command(far.GetPluginId(), "goto:"..data.SymlinkTarget) 13 | end 14 | 15 | Macro { 16 | id="42E5CEE2-0A93-44B9-981C-C1C580558A32"; 17 | description="Show symlink target"; 18 | area="Shell"; key="CtrlShiftL"; 19 | condition=CheckSymlink; 20 | action=function(data) 21 | local Items = { 22 | {"DI_DOUBLEBOX",3,1,60,4, 0,0,0, 0, "Symlink Target"}, 23 | {"DI_EDIT", 5,2,58,2, 0,0,0, F.DIF_READONLY, data.SymlinkTarget}, 24 | {"DI_BUTTON", 5,3, 0,3, 0,0,0, F.DIF_CENTERGROUP+F.DIF_DEFAULTBUTTON, "&Goto"}, 25 | {"DI_BUTTON", 5,3, 0,3, 0,0,0, F.DIF_CENTERGROUP, "Cancel"}, 26 | } 27 | if 3 == far.Dialog(nil,-1,-1,64,6,nil,Items) then Goto(data) end 28 | end; 29 | } 30 | 31 | Macro { 32 | id="71FE4598-4B1C-41DD-A1A0-B02B6DFE6BF6"; 33 | description="Go to symlink target"; 34 | area="Shell"; key="CtrlPgDn"; 35 | condition=CheckSymlink; 36 | action=Goto; 37 | } 38 | -------------------------------------------------------------------------------- /Macros/scripts/Shell/time.lua: -------------------------------------------------------------------------------- 1 | -- started: 2020-06-15 2 | -- url: https://forum.ru-board.com/topic.cgi?forum=5&topic=50439&start=980#19 3 | -- url: https://forum.farmanager.com/viewtopic.php?p=161334#p161334 4 | 5 | CommandLine { 6 | description = "Time"; 7 | prefixes = "time"; 8 | action = function(prefix,text) 9 | local t1 = win.Clock() 10 | far.Execute(text) 11 | t1 = win.Clock() - t1 12 | local str1 = ("%.6f"):format(t1) 13 | local ret = far.Message(str1.." sec.", "Time", "&OK;&Copy;&Fullcopy") 14 | if ret == 2 then 15 | far.CopyToClipboard(str1) 16 | elseif ret == 3 then 17 | far.CopyToClipboard(("time=%s, command=%s"):format(str1, text)) 18 | end 19 | actl.RedrawAll() 20 | end; 21 | } 22 | -------------------------------------------------------------------------------- /Macros/scripts/Shell/view_folder_under_cursor.lua: -------------------------------------------------------------------------------- 1 | -- started: 2021-09-25 2 | -- https://forum.ru-board.com/topic.cgi?forum=5&topic=50439&start=3180#17 3 | -- https://forum.farmanager.com/viewtopic.php?t=12619 4 | 5 | -- Settings ------------------------------------------------------- 6 | local Key_manual = "AltShiftF3" 7 | local Key_toggle = "CtrlShiftQ" 8 | local Key_navigate = "Down Up PgDn PgUp Left Right Home End Enter" 9 | local Key_off = "Tab" 10 | ------------------------------------------------------------------- 11 | 12 | local JoinPath = win.JoinPath 13 | local Qmode = false -- Quick folder view mode 14 | 15 | local function is_active_dir() 16 | return APanel.Folder or APanel.Current:find("/") 17 | end 18 | 19 | local function set_passive_path() 20 | Far.DisableHistory(0x02) 21 | local path, file = APanel.Current:match("(.+/)(.*)") 22 | if APanel.Folder then 23 | if path then ---- directory on TmpPanel 24 | Panel.SetPath(1, APanel.Current) 25 | elseif APanel.Path ~= "" then ---- directory on a regular panel 26 | Panel.SetPath(1, JoinPath(APanel.Path, APanel.Current)) 27 | end 28 | elseif path then ---- file on TmpPanel 29 | Panel.SetPath(1, path, file) 30 | elseif APanel.Path ~= "" then ---- file on a regular panel 31 | Panel.SetPath(1, JoinPath(APanel.Path, APanel.Current)) 32 | end 33 | end 34 | 35 | Macro { 36 | id="6C01D019-6C7E-4AB8-8F7D-E1D5ACC3CE9D"; 37 | description="Quick folder view: manual"; 38 | area="Shell"; key=Key_manual; 39 | flags="NoPluginPanels NoFiles"; 40 | action=function() set_passive_path() end; 41 | } 42 | 43 | Macro { 44 | id="BB357E70-621E-410B-BA42-74228F70F1E6"; 45 | description="Quick folder view: toggle ON/OFF"; 46 | area="Shell"; key=Key_toggle; 47 | action=function() 48 | Qmode = not Qmode 49 | if Qmode and is_active_dir() then 50 | set_passive_path() 51 | panel.RedrawPanel(nil, 0) 52 | end 53 | far.Message("Quick view mode is "..(Qmode and "ON" or "OFF"), "", "") 54 | win.Sleep(600) 55 | far.AdvControl("ACTL_REDRAWALL") 56 | end; 57 | } 58 | 59 | Macro { 60 | id="5397310D-BB80-467C-9B0A-CF5D41455521"; 61 | description="Quick folder view: navigate"; 62 | area="Shell"; key=Key_navigate; 63 | condition=function() 64 | return Qmode and CmdLine.Empty 65 | end; 66 | action=function() 67 | Keys(akey(1)) 68 | if is_active_dir() then set_passive_path() end 69 | end; 70 | } 71 | 72 | Macro { 73 | id="1D1EF06D-C58B-4705-9EB8-0C30C5F948A7"; 74 | description="Quick folder view: turn off"; 75 | area="Shell"; key=Key_off; 76 | condition=function() return Qmode end; 77 | action=function() 78 | Qmode = false 79 | Keys(akey(1)) 80 | end; 81 | } 82 | -------------------------------------------------------------------------------- /Macros/scripts/Third_party/Hexed/hexed_eng.hlf: -------------------------------------------------------------------------------- 1 | .Language=English,English 2 | .PluginContents=Hex Editor 3 | .Options CtrlStartPosChar=¦ 4 | 5 | @Contents 6 | $ #Hex Editor# 7 | ^#Keyboard reference# 8 | 9 | #F3# Toggle view/edit mode 10 | #F8# Toggle ANSI/OEM text area 11 | #F9# Save 12 | #BS# Restore the changed cell value 13 | #Tab# Toggle Hex/Text editing area 14 | #AltF8# "Go to" dialog 15 | #AltShiftF9# Edit colors 16 | #CtrlF10# Synchronize viewer position 17 | -------------------------------------------------------------------------------- /Macros/scripts/Third_party/Hexed/hexed_rus.hlf: -------------------------------------------------------------------------------- 1 | .Language=Russian,Russian (Русский) 2 | .PluginContents=Hex Editor 3 | .Options CtrlStartPosChar=¦ 4 | 5 | @Contents 6 | $ #Hex Editor# 7 | 8 | ^#Клавиатурные команды# 9 | 10 | #F3# Переключение режима просмотр/редактирование 11 | #F8# Переключение ANSI/OEM в текстовой области 12 | #F9# Сохранить файл 13 | #BS# Восстановить значение изменённого байта 14 | #Tab# Переключение областей редактирования Hex/Текст 15 | #AltF8# Диалог "Перейти" 16 | #AltShiftF9# Настройка цвета 17 | #CtrlF10# Синхронизировать позицию просмотрщика 18 | -------------------------------------------------------------------------------- /Macros/scripts/Third_party/farcall.lua: -------------------------------------------------------------------------------- 1 | -- Original author: Sergey Oblomov (aka hoopoe) 2 | -- https://forum.farmanager.com/viewtopic.php?t=10204 3 | -- Ported to far2m: Shmuel Zeigerman 4 | 5 | local action = function(text) 6 | local batpath = far.InMyTemp("__farcall") 7 | local envpath = far.InMyTemp("__farenv") 8 | local bat = assert(io.open(batpath, "w")) 9 | bat:write('cd "', far.GetCurrentDirectory(), '" || exit 1\n') 10 | bat:write(". ", text, ' || exit 2\n') -- 'source' didn't work while '.' did 11 | bat:write('env > ', envpath, '\n') 12 | bat:close() 13 | win.chmod(batpath, tonumber("0774", 8)) 14 | 15 | panel.GetUserScreen() 16 | if 0 == win.system(batpath) then 17 | for line in io.lines(envpath) do 18 | local name, value = line:match('^([^=]+)=(.*)') 19 | if name then 20 | win.SetEnv(name, value) 21 | end 22 | end 23 | end 24 | win.DeleteFile(batpath) 25 | win.DeleteFile(envpath) 26 | panel.SetUserScreen() 27 | end 28 | 29 | CommandLine { 30 | description = "Far Call Lua Edition"; 31 | prefixes = "call"; 32 | action = function(prefix, text) action(text); end; 33 | } 34 | -------------------------------------------------------------------------------- /Macros/scripts/_macroinit.lua: -------------------------------------------------------------------------------- 1 | local run = select(2, ...) 2 | if run ~= 1 then return end 3 | 4 | local repos = far.GetMyHome().."/repos" 5 | local plugins = repos.."/luafar2m/_build/install" 6 | 7 | -- load plugins 8 | if os.getenv("FARHOME") == repos.."/far2m/_build/install" then 9 | far.RecursiveSearch(plugins, "*.far-plug-wide", 10 | function(_, fullpath) 11 | far.LoadPlugin("PLT_PATH", fullpath) 12 | end, "FRS_RECUR") 13 | end 14 | -------------------------------------------------------------------------------- /Macros/util/moon2lua.lua: -------------------------------------------------------------------------------- 1 | -- moon2lua.lua 2 | 3 | local fullpath = ... 4 | local to_lua = (require"moonscript.base").to_lua 5 | 6 | local fp = assert(io.open(fullpath)) 7 | local str = fp:read("*all") 8 | fp:close() 9 | str = assert(to_lua(str)) 10 | 11 | local newpath = (fullpath:match("(.+)%.[^./]+$") or fullpath) .. ".lua" 12 | if win.GetFileAttr(newpath) then 13 | if 1 ~= far.Message(newpath.." exists. Overwrite?","Confirm","Yes;No","w") then return end 14 | end 15 | fp = assert(io.open(newpath,"w")) 16 | fp:write("-- luacheck: ignore 612 (trailing space)\n") 17 | fp:write("-- luacheck: ignore 631 (line is too long)\n") 18 | fp:write(str,"\n") 19 | fp:close() 20 | 21 | panel.UpdatePanel(nil,1) 22 | panel.RedrawPanel(nil,1) 23 | -------------------------------------------------------------------------------- /Plugins/_common/minilua.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char **argv) 8 | { 9 | lua_State *L; 10 | int status = 0; 11 | 12 | if (argc >= 2 && (L = lua_open())) 13 | { 14 | int i, j=-1, execute=0; 15 | 16 | luaL_openlibs(L); 17 | 18 | for (i=1,status=0; i= 0) 48 | status = lua_pcall(L, j, 0, 0); 49 | 50 | if (status) 51 | fprintf(stderr, "%s\n", lua_tostring(L,-1)); 52 | 53 | lua_close(L); 54 | } 55 | 56 | return status; 57 | } 58 | -------------------------------------------------------------------------------- /Plugins/filegen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(filegen) 2 | 3 | set(SOURCES 4 | src/GlobalInfo.c 5 | ${FARSOURCE}/luafar/src/luaplug.c 6 | ) 7 | 8 | add_library (${PROJECT_NAME} MODULE ${SOURCES}) 9 | set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) 10 | 11 | set(EXPNAMES 12 | GETFINDDATA 13 | GETOPENPLUGININFO 14 | OPENPLUGIN 15 | PROCESSEVENT 16 | ) 17 | 18 | set(EXPORTS "") 19 | foreach(f ${EXPNAMES}) 20 | list(APPEND EXPORTS "-DEXPORT_${f}") 21 | endforeach() 22 | 23 | target_compile_definitions(${PROJECT_NAME} 24 | PRIVATE ${EXPORTS} 25 | ) 26 | 27 | target_include_directories(${PROJECT_NAME} PRIVATE ${FARSOURCE}/far/far2sdk) 28 | 29 | if(${CMAKE_SYSTEM_NAME} MATCHES "Android") 30 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/luafar.so) 31 | endif() 32 | 33 | set(INSTALL_DIR "${INSTALL_DIR}/${PROJECT_NAME}") 34 | 35 | set_target_properties(${PROJECT_NAME} 36 | PROPERTIES 37 | LIBRARY_OUTPUT_DIRECTORY "${INSTALL_DIR}/plug" 38 | PREFIX "" 39 | SUFFIX ".far-plug-wide") 40 | 41 | set(MY_LIST 42 | filegen.lua 43 | filegen_eng.hlf 44 | ) 45 | 46 | foreach(elem ${MY_LIST}) 47 | configure_file("src/${elem}" "${INSTALL_DIR}/plug/${elem}" COPYONLY) 48 | endforeach() 49 | -------------------------------------------------------------------------------- /Plugins/filegen/src/GlobalInfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SHAREDSYMBOL void WINAPI GetGlobalInfoW(struct GlobalInfo *aInfo) 4 | { 5 | struct VersionInfo Version = { 0,2,0,0 }; 6 | aInfo->StructSize = sizeof(*aInfo); 7 | aInfo->SysID = 0x907CBCBA; 8 | aInfo->Version = Version; 9 | aInfo->Title = L"Pseudo file generator"; 10 | aInfo->Description = L"Pseudo file generator"; 11 | aInfo->Author = L"Shmuel Zeigerman"; 12 | } 13 | //--------------------------------------------------------------------------- 14 | 15 | SHAREDSYMBOL int WINAPI GetMinFarVersionW(void) 16 | { 17 | return MAKEFARVERSION(2,4); 18 | } 19 | //--------------------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /Plugins/filegen/src/filegen.lua: -------------------------------------------------------------------------------- 1 | -- started: 2014-01-07 2 | -------------------------------------------------------------------------------- 3 | far.ReloadDefaultScript = true 4 | 5 | local F = far.Flags 6 | local Title = "File generator" 7 | 8 | local OpenPanelInfoFlags = bit64.bor(F.OPIF_ADDDOTS) 9 | 10 | local PluginMenuGuid1 = win.Uuid("8DEBE183-0BD7-4223-BDF3-41325A7E24C8") 11 | local PluginConfigGuid1 = win.Uuid("CF6F0F3B-0814-4CB9-B8D2-E5CAD986B4F2") 12 | 13 | function export.GetPluginInfo() 14 | return { 15 | CommandPrefix = "fgen", 16 | Flags = 0, 17 | } 18 | end 19 | 20 | function export.Open(OpenFrom, Guid, text) 21 | if OpenFrom == F.OPEN_COMMANDLINE then 22 | local out = {} 23 | local args = { far.SplitCmdLine(text) } 24 | for k,v in ipairs(args) do 25 | local key, val = v:match("^%s*(%w+)%s*=(.+)$") 26 | if key == "fnum" or key == "dnum" then out[key] = tonumber(val) 27 | elseif key == "fname" or key == "dname" then out[key] = val 28 | end 29 | end 30 | return out 31 | end 32 | end 33 | 34 | function export.GetFindData (obj, handle, OpMode) 35 | --if band(OpMode, F.OPM_FIND) ~= 0 then return end 36 | 37 | local fname = obj.fname or "File-{1}" 38 | local dname = obj.dname or "Dir-{1}" 39 | local fnum = obj.fnum or 0 40 | local dnum = obj.dnum or 0 41 | 42 | local data = {} 43 | for k=1,fnum do 44 | data[k] = { 45 | FileName = fname:reformat(k); 46 | } 47 | end 48 | for k=1,dnum do 49 | data[k+fnum] = { 50 | FileName = dname:reformat(k); 51 | FileAttributes="d"; 52 | } 53 | end 54 | return data 55 | end 56 | 57 | function export.GetOpenPanelInfo (object, handle) 58 | return { 59 | Flags = OpenPanelInfoFlags, 60 | PanelTitle = Title, 61 | } 62 | end 63 | 64 | function export.ProcessPanelEvent (object, handle, Event, Param) 65 | if Event == F.FE_IDLE then 66 | ---- Don't call UpdatePanel here as with huge number of files it 67 | ---- causes big processor load and delayed response to keystrokes. 68 | -- panel.UpdatePanel(handle,nil,true) 69 | -- panel.RedrawPanel(handle) 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /Plugins/filegen/src/filegen_eng.hlf: -------------------------------------------------------------------------------- 1 | .Language=English,English 2 | .PluginContents=Pseudo File Generator 3 | .Options CtrlColorChar=\ 4 | 5 | @Contents 6 | $ #Pseudo File Generator# 7 | This plugin creates a panel with a given number of files and directories. 8 | Those are just panel items rather than real files and directories. 9 | 10 | #Command line# 11 | 12 | #fgen:# 13 | #fnum=#num_files 14 | #dnum=#num_dirs 15 | #fname=#file_name 16 | #dname=#dir_name 17 | 18 | #fname# and #dname# may contain placeholders for a number part 19 | in the form that utf8.reformat recognizes as a first argument, 20 | e.g. {1} or {1:d} or {1:03d} or {1:04X} etc. 21 | 22 | #Example# 23 | fgen: fnum=10 dnum=5 fname=file-{1} dname=dir-{1} -------------------------------------------------------------------------------- /Plugins/highlight/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(highlight) 2 | 3 | set(SOURCES 4 | src/GlobalInfo.c 5 | ${FARSOURCE}/luafar/src/luaplug.c 6 | ) 7 | 8 | add_library (${PROJECT_NAME} MODULE ${SOURCES}) 9 | set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) 10 | 11 | set(EXPNAMES 12 | OPENPLUGIN PROCESSEDITOREVENT PROCESSEDITORINPUT 13 | ) 14 | 15 | set(EXPORTS "") 16 | foreach(f ${EXPNAMES}) 17 | list(APPEND EXPORTS "-DEXPORT_${f}") 18 | endforeach() 19 | 20 | target_compile_definitions(${PROJECT_NAME} 21 | PRIVATE ${EXPORTS} 22 | ) 23 | 24 | target_include_directories(${PROJECT_NAME} PRIVATE 25 | ${FARSOURCE}/far/far2sdk) 26 | 27 | if(${CMAKE_SYSTEM_NAME} MATCHES "Android") 28 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/luafar.so) 29 | endif() 30 | 31 | set(INSTALL_DIR "${INSTALL_DIR}/${PROJECT_NAME}") 32 | 33 | set_target_properties(${PROJECT_NAME} 34 | PROPERTIES 35 | LIBRARY_OUTPUT_DIRECTORY "${INSTALL_DIR}/plug" 36 | PREFIX "" 37 | SUFFIX ".far-plug-wide") 38 | 39 | set(MY_LIST 40 | highlight.lua 41 | highlight_eng.hlf 42 | ) 43 | 44 | foreach(elem ${MY_LIST}) 45 | configure_file("src/${elem}" "${INSTALL_DIR}/plug/${elem}" COPYONLY) 46 | endforeach() 47 | 48 | add_custom_target(${PROJECT_NAME}_files ALL 49 | COMMAND cp -rf "${CMAKE_CURRENT_SOURCE_DIR}/src/syntaxes" "${INSTALL_DIR}/plug/" 50 | ) 51 | -------------------------------------------------------------------------------- /Plugins/highlight/doc/changelog.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------ 2 | Legend: [+] added; [-] deleted; [*] changed; [!] fixed; 3 | ------------------------------------------------------------------ 4 | 5 | 2021-06-18, v0.5.1 6 | [+] Syntax files: the table-parameter of the Class function can have the field "firstline", 7 | e.g. firstline="lua". When a file is opened in the Far editor, the plugin reads its first 8 | line and if that line contains highlight: (e.g. highlight:lua) then this file is 9 | highlighted according to this "Class". If this is the case the file extension is ignored. 10 | [*] Menu "Select syntax": added shortcuts 1...9, 0, A...Z for ease of selecting a syntax. 11 | 12 | 2020-10-31, v0.5.0 13 | [+] Syntax files: colors may be specified by names, e.g. "red" or "yellow on blue". 14 | Numeric color values also work. 15 | 16 | 2016-04-20, v0.4.5 17 | [+] Syntax Menu: add the item "Highlight OFF" and a separator. 18 | [*] Choosing a syntax from Syntax Menu acts as if the file was just open in the editor 19 | (discards all changes that might be made to current file settings). 20 | [+] Syntax files: the table-parameter to Class() may contain a (number) 'fastlines' parameter 21 | that overrides the configuration setting for the given class. 22 | [+] Syntax files: add syntax_intel_hex.lua. 23 | 24 | 2015-05-02, v0.4.4 25 | [!] Fix "attempt to index a nil value" error when a highlighted editor was 26 | open but not active and ACTL_REDRAWALL was called by another plugin. 27 | 28 | 2015-04-29, v0.4.3 29 | [!] Fix application hanging when the syntax is empty. 30 | [!] Lrexlib: fix crash bug in Oniguruma binding. 31 | 32 | 2015-04-26, v0.4.2 33 | "Highlight Extra" dialog: 34 | [+] Not closed on invalid regular expression. 35 | [+] Settings made persistent (stored in database). 36 | [+] Configurable color. 37 | 38 | 2015-04-25, v0.4.1 39 | [!] "Highlight Extra" dialog: help (F1) did not work. 40 | 41 | 2015-04-25, v0.4 42 | [*] Syntax change: bcolor->bgcolor, fcolor->fgcolor. 43 | [+] Highlighting of matching brackets: (), [] and {}. 44 | Syntax settings: bracketmatch (default=false), bracketcolor (default=0x1C). 45 | [+] "Highlight extra" functionality. 46 | [+] Syntax file: syntax_batch.lua. 47 | 48 | 2015-04-21, v0.3 49 | [*] Changed regex engine from Far Manager regex to Oniguruma. 50 | The former does not allow to specify flags for subexpressions, e.g. "(?i)". 51 | [!] In a macro call, if the macro had the "EnableOutput" flag, after selecting syntax via 52 | Plugin.Call(Guid,"own","SelectSyntax"), the editor was not redrawn. 53 | [!] Multi-line comments of kind {...} were treated incorrectly. 54 | [+] Syntax files: syntax_ini.lua, syntax_lng.lua, syntax_pascal.lua. 55 | 56 | 2014-11-11, v0.2.1 57 | [+] Menu "Select syntax". 58 | [+] Macro functions "Settings" and "SelectSyntax". 59 | [+] Syntax file : syntax_makefile.lua. 60 | [+] Macro file : highlight.lua. 61 | 62 | 2014-11-04, v0.2 63 | [*] Renames in the syntax files: 'Syntax'->'Class', 'elements'->'syntax'. 64 | [+] New fields in the syntaxes: 'bcolor', 'fcolor'. 65 | [+] Dialog: "Benchmark" button and benchmark result field. 66 | [+] Dialog: "Lines" edit controls. 67 | [+] Doc files : changelog.txt, license.txt. 68 | [+] Help file : highlight_eng.hlf. 69 | [+] Syntax files : syntax_moonscript.lua, syntax_hlf.lua. 70 | 71 | 2014-10-23, v0.1.2 72 | [*] Rebuild DLL's using embedding source code processed by LuaSrcDiet, instead of LuaJIT 2.0 byte 73 | codes (there was a complaint from a user that the plugin would not work with LuaJIT 2.1). 74 | 75 | 2014-10-22, v0.1.1 76 | [!] Two libraries ('serial' and 'far2.history') were not included in v0.1; as the result, 77 | the plugin did not work on other people systems. 78 | 79 | 2014-10-22, v0.1 80 | [+] First public release. 81 | -------------------------------------------------------------------------------- /Plugins/highlight/doc/license.txt: -------------------------------------------------------------------------------- 1 | License of Highlight v0.x 2 | -------------------------- 3 | 4 | Copyright (C) Shmuel Zeigerman 2014-2021 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated 8 | documentation files (the "Software"), to deal in the 9 | Software without restriction, including without limitation 10 | the rights to use, copy, modify, merge, publish, distribute, 11 | sublicense, and/or sell copies of the Software, and to 12 | permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall 16 | be included in all copies or substantial portions of the 17 | Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 20 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 21 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 22 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 23 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 24 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 25 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | -------------------------------------------------------------------------------- /Plugins/highlight/src/GlobalInfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SHAREDSYMBOL void WINAPI GetGlobalInfoW(struct GlobalInfo *aInfo) 4 | { 5 | struct VersionInfo Version = { 0,6,0,0 }; 6 | aInfo->StructSize = sizeof(*aInfo); 7 | aInfo->SysID = 0xF6138DC9; 8 | aInfo->Version = Version; 9 | aInfo->Title = L"Highlight"; 10 | aInfo->Description = L"Syntax highlighter for editor"; 11 | aInfo->Author = L"Shmuel Zeigerman"; 12 | } 13 | //--------------------------------------------------------------------------- 14 | 15 | SHAREDSYMBOL int WINAPI GetMinFarVersionW(void) 16 | { 17 | return MAKEFARVERSION(2,4); 18 | } 19 | //--------------------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /Plugins/highlight/src/syntaxes/syntax_batch.lua: -------------------------------------------------------------------------------- 1 | local syntax_batch = 2 | { 3 | bgcolor = "darkblue"; 4 | { 5 | name = "Comment1"; fgcolor = "gray7"; 6 | pattern = [[ (?i) ^ \s* @? \s* REM (?: \s+ .*)? $ ]]; 7 | }, 8 | { 9 | name = "Comment2"; fgcolor = "gray7"; 10 | pattern = [[ ^ :: .* ]]; 11 | }, 12 | { 13 | name = "Label"; color = "white on gray8"; 14 | pattern = [[ ^ : \w+ \s* $ ]]; 15 | }, 16 | { 17 | name = "Echo"; fgcolor = "purple"; 18 | pattern = [[ (?i) @? \s* \b ECHO \.? (?: \s+ .*)? $ ]]; 19 | }, 20 | { 21 | name = "EnvVar"; fgcolor = "green"; 22 | pattern = [[ % \w+ % ]]; 23 | }, 24 | { 25 | name = "Keyword"; fgcolor = "yellow"; 26 | --color = { ForegroundColor=0x00FF00; BackgroundColor=0x000080; Flags={FCF_FG_BOLD=1} }; 27 | pattern = [[ (?i) (?= | ~= | < | > ]]; 18 | -- }, 19 | { 20 | name = "String1"; fgcolor = "green"; color_unfinished= "darkblue on purple"; 21 | pat_open = [[ " ]]; 22 | pat_skip = [[ (?: \\. | [^\\"] )* ]]; 23 | pat_close = [[ " ]]; 24 | pat_continue = [[ \\$ ]]; 25 | }, 26 | { 27 | name = "Command"; fgcolor = "yellow"; 28 | --color = { ForegroundColor=0x00FF00; BackgroundColor=0x000080; Flags={FCF_FG_BOLD=1} }; 29 | pattern = [[ (?i) (?= | ~= | < | > ]]; 29 | }, 30 | { 31 | name = "String1"; fgcolor = "green"; color_unfinished= "darkblue on purple"; 32 | pat_open = [[ " ]]; 33 | pat_skip = [[ (?: \\. | [^\\"] )* ]]; 34 | pat_close = [[ " ]]; 35 | pat_continue = [[ \\$ ]]; 36 | }, 37 | { 38 | name = "String2"; fgcolor = "green"; color_unfinished= "darkblue on purple"; 39 | pat_open = [[ ' ]]; 40 | pat_skip = [[ (?: \\. | [^\\'] )* ]]; 41 | pat_close = [[ ' ]]; 42 | pat_continue = [[ \\$ ]]; 43 | }, 44 | { 45 | name = "Keyword"; fgcolor = "yellow"; 46 | --color = { ForegroundColor=0x00FF00; BackgroundColor=0x000080; Flags={FCF_FG_BOLD=1} }; 47 | pattern = [[ \b(?: 48 | and|break|do|else|elseif|end|for|function|if|in|local|not|or|repeat|return|then|until|while 49 | )\b ]]; 50 | }, 51 | { 52 | name = "Function"; fgcolor = "purple"; 53 | pattern = [[ \b(?: 54 | _G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|loadstring|module|next| 55 | pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall| 56 | coroutine\.create|coroutine\.resume|coroutine\.running|coroutine\.status|coroutine\.wrap|coroutine\.yield| 57 | debug\.debug|debug\.getfenv|debug\.gethook|debug\.getinfo|debug\.getlocal|debug\.getmetatable|debug\.getregistry| 58 | debug\.getupvalue|debug\.setfenv|debug\.sethook|debug\.setlocal|debug\.setmetatable|debug\.setupvalue| 59 | debug\.traceback|io\.close|io\.flush|io\.input|io\.lines|io\.open|io\.output|io\.popen|io\.read|io\.stderr| 60 | io\.stdin|io\.stdout|io\.tmpfile|io\.type|io\.write|math\.abs|math\.acos|math\.asin|math\.atan|math\.atan2| 61 | math\.ceil|math\.cos|math\.cosh|math\.deg|math\.exp|math\.floor|math\.fmod|math\.frexp|math\.huge|math\.ldexp| 62 | math\.log|math\.log10|math\.max|math\.min|math\.modf|math\.pi|math\.pow|math\.rad|math\.random|math\.randomseed| 63 | math\.sin|math\.sinh|math\.sqrt|math\.tan|math\.tanh|os\.clock|os\.date|os\.difftime|os\.execute|os\.exit| 64 | os\.getenv|os\.remove|os\.rename|os\.setlocale|os\.time|os\.tmpname|package\.config|package\.cpath|package\.loaded| 65 | package\.loaders|package\.loadlib|package\.path|package\.preload|package\.seeall|string\.byte|string\.char| 66 | string\.dump|string\.find|string\.format|string\.gmatch|string\.gsub|string\.len|string\.lower|string\.match| 67 | string\.rep|string\.reverse|string\.sub|string\.upper|table\.concat|table\.insert|table\.maxn|table\.remove| 68 | table\.sort 69 | )\b ]]; 70 | }, 71 | { 72 | name = "Library"; color="darkred on white"; 73 | pattern = [[ (?= | ~= | != | < | > ]]; 23 | }, 24 | { 25 | name = "String1"; fgcolor = "green"; color_unfinished= "darkblue on purple"; 26 | pat_open = [[ " ]]; 27 | pat_skip = [[ (?: \\. | [^\\"] )* ]]; 28 | pat_close = [[ " ]]; 29 | pat_continue = [[ \\?$ ]]; 30 | }, 31 | { 32 | name = "String2"; fgcolor = "green"; color_unfinished= "darkblue on purple"; 33 | pat_open = [[ ' ]]; 34 | pat_skip = [[ (?: \\. | [^\\'] )* ]]; 35 | pat_close = [[ ' ]]; 36 | pat_continue = [[ \\?$ ]]; 37 | }, 38 | { 39 | -- https://github.com/leafo/moonscript-site/blob/master/highlight.coffee 40 | name = "Keyword"; fgcolor = "yellow"; 41 | pattern = [[ \b(?: 42 | class|extends|if|then|super|do|with|import|export|while|elseif|return|for|in|from|when|using| 43 | else|and|or|not|switch|break|continue 44 | )\b ]]; 45 | }, 46 | { 47 | name = "Function"; fgcolor = "purple"; 48 | pattern = [[ \b(?: 49 | _G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|loadstring|module|next| 50 | pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall| 51 | coroutine\.create|coroutine\.resume|coroutine\.running|coroutine\.status|coroutine\.wrap|coroutine\.yield| 52 | debug\.debug|debug\.getfenv|debug\.gethook|debug\.getinfo|debug\.getlocal|debug\.getmetatable|debug\.getregistry| 53 | debug\.getupvalue|debug\.setfenv|debug\.sethook|debug\.setlocal|debug\.setmetatable|debug\.setupvalue| 54 | debug\.traceback|io\.close|io\.flush|io\.input|io\.lines|io\.open|io\.output|io\.popen|io\.read|io\.stderr| 55 | io\.stdin|io\.stdout|io\.tmpfile|io\.type|io\.write|math\.abs|math\.acos|math\.asin|math\.atan|math\.atan2| 56 | math\.ceil|math\.cos|math\.cosh|math\.deg|math\.exp|math\.floor|math\.fmod|math\.frexp|math\.huge|math\.ldexp| 57 | math\.log|math\.log10|math\.max|math\.min|math\.modf|math\.pi|math\.pow|math\.rad|math\.random|math\.randomseed| 58 | math\.sin|math\.sinh|math\.sqrt|math\.tan|math\.tanh|os\.clock|os\.date|os\.difftime|os\.execute|os\.exit| 59 | os\.getenv|os\.remove|os\.rename|os\.setlocale|os\.time|os\.tmpname|package\.config|package\.cpath|package\.loaded| 60 | package\.loaders|package\.loadlib|package\.path|package\.preload|package\.seeall|string\.byte|string\.char| 61 | string\.dump|string\.find|string\.format|string\.gmatch|string\.gsub|string\.len|string\.lower|string\.match| 62 | string\.rep|string\.reverse|string\.sub|string\.upper|table\.concat|table\.insert|table\.maxn|table\.remove| 63 | table\.sort 64 | )\b ]]; 65 | }, 66 | { 67 | name = "Library"; color="darkred on white"; 68 | pattern = [[ (? (?: [^"]+ | "" | "(?: \#\d+)+" )* ) " ]]; -- important: atomic group used 35 | }, 36 | { 37 | name = "String2"; fgcolor = "purple"; 38 | pattern = [[ ' (?> (?: [^']+ | '' | '(?: \#\d+)+' )* ) ' ]]; -- important: atomic group used 39 | }, 40 | { 41 | name = "Char"; fgcolor = "purple"; color_unfinished= "darkblue on purple"; 42 | pattern = [[ ' (?: \\. | [^\\'] ) ' ]]; 43 | }, 44 | { 45 | name = "Keyword"; fgcolor = "yellow"; 46 | pattern = [[ \b(?: (?i) 47 | Absolute|Abstract|All|And|And_then|Array|Asm|Begin|Bindable|Case|Class|Const|Constructor| 48 | Destructor|Div|Do|Downto|Else|End|Export|File|For|Function|Goto|If|Import|Implementation| 49 | Inherited|In|Inline|Interface|Is|Label|Mod|Module|Nil|Not|Object|Of|Only|Operator|Or|Or_else| 50 | Otherwise|Packed|Pow|Private|Procedure|Program|Property|Protected|Public|Qualified|Record| 51 | Repeat|Restricted|Set|Shl|Shr|Then|To|Type|Unit|Until|Uses|Value|Var|View|Virtual|While|With| 52 | Xor 53 | )\b ]]; 54 | }, 55 | { 56 | name = "Type"; fgcolor = "white"; 57 | pattern = [[ \b(?: (?i) 58 | Boolean|Byte|ByteBool|Cardinal|Char|Comp|Currency|Double|Extended|Int64|Integer|LongBool| 59 | Longint|Longword|PChar|QWord|Real|Shortint|Single|SmallInt|String|WideString|Word|WordBool 60 | )\b ]]; 61 | }, 62 | { 63 | name = "Word"; fgcolor = "aqua"; 64 | pattern = [[ \b\w+\b ]]; 65 | }, 66 | { 67 | name = "MathOp"; fgcolor = "white"; 68 | pattern = [[ [^\w\s] ]]; 69 | }, 70 | } 71 | 72 | Class { 73 | name = "Pascal"; 74 | filemask = "*.pas,*.dpr"; 75 | syntax = syntax_pascal; 76 | } 77 | -------------------------------------------------------------------------------- /Plugins/highlight/src/syntaxes/syntax_python.lua: -------------------------------------------------------------------------------- 1 | local syntax_python = 2 | { 3 | bgcolor = "darkblue"; 4 | bracketmatch = true; 5 | --bracketcolor = 0xE3; 6 | { 7 | name = "LongString1"; fgcolor = "green"; color_unfinished= "darkblue on purple"; 8 | pat_open = [[ (\b[Rr])? """\\? ]]; 9 | pat_skip = [[ (?: \\. | [^\\"] | "{1,2} (?! ") )* ]]; 10 | pat_close = [[ """ ]]; 11 | pat_continue = [[ $ ]]; 12 | }, 13 | { 14 | name = "LongString2"; fgcolor = "green"; color_unfinished= "darkblue on purple"; 15 | pat_open = [[ (\b[Rr])? '''\\? ]]; 16 | pat_skip = [[ (?: \\. | [^\\'] | '{1,2} (?! ') )* ]]; 17 | pat_close = [[ ''' ]]; 18 | pat_continue = [[ $ ]]; 19 | }, 20 | { 21 | name = "Comment"; fgcolor = "gray7"; 22 | pattern = [[ \# .* ]]; 23 | }, 24 | { 25 | name = "Literal"; fgcolor = "white"; 26 | pattern = [[ 27 | \b (?: 0[xX][\da-fA-F]+ | (?:\d+\.\d*|\.?\d+)(?:[eE][+-]?\d+)? ) \b ]]; 28 | }, 29 | { 30 | name = "String1"; fgcolor = "purple"; 31 | pattern = [[ (\b[Rr])? " (?: \\. | [^\\"] )* " ]]; 32 | }, 33 | { 34 | name = "String2"; fgcolor = "purple"; 35 | pattern = [[ (\b[Rr])? ' (?: \\. | [^\\'] )* ' ]]; 36 | }, 37 | { 38 | name = "Keyword"; fgcolor = "yellow"; 39 | pattern = [[ \b(?: 40 | False|class|finally|is|return|None|continue|for|lambda|try|True|def|from|nonlocal|while| 41 | and|del|global|not|with|as|elif|if|or|yield|assert|else|import|pass|break|except|in|raise 42 | )\b ]]; 43 | }, 44 | { 45 | name = "Word"; fgcolor = "aqua"; 46 | pattern = [[ \b\w+\b ]]; 47 | }, 48 | { 49 | name = "MathOp"; fgcolor = "white"; 50 | pattern = [[ [^\w\s] ]]; 51 | }, 52 | } 53 | 54 | Class { 55 | name = "Python"; 56 | filemask = "*.py"; 57 | syntax = syntax_python; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /Plugins/highlight/src/syntaxes/syntax_shell.lua: -------------------------------------------------------------------------------- 1 | -- Note: false, nil, true - placed in the group of "literals" rather than "keywords". 2 | local syntax_shell = 3 | { 4 | bgcolor = "darkblue"; 5 | bracketmatch = true; 6 | --bracketcolor = 0xE3; 7 | { 8 | name = "Comment"; fgcolor = "gray7"; 9 | pattern = [[ (?= | ~= | < | > ]]; 19 | }, 20 | { 21 | name = "String1"; fgcolor = "green"; color_unfinished= "darkblue on purple"; 22 | pat_open = [[ " ]]; 23 | pat_skip = [[ (?: \\. | [^\\"] )* ]]; 24 | pat_close = [[ " ]]; 25 | pat_continue = [[ \\$ ]]; 26 | }, 27 | { 28 | name = "String2"; fgcolor = "green"; color_unfinished= "darkblue on purple"; 29 | pat_open = [[ ' ]]; 30 | pat_skip = [[ (?: \\. | [^\\'] )* ]]; 31 | pat_close = [[ ' ]]; 32 | pat_continue = [[ \\$ ]]; 33 | }, 34 | { 35 | name = "Keyword"; fgcolor = "yellow"; 36 | --color = { ForegroundColor=0x00FF00; BackgroundColor=0x000080; Flags={FCF_FG_BOLD=1} }; 37 | pattern = [[ \b(?: 38 | case|cd|do|done|echo|elif|else|esac|exec|exit|expr|fi|for|if|in|kill|rm|sleep|start|then|while 39 | )\b ]]; 40 | }, 41 | { 42 | name = "Word"; fgcolor = "aqua"; 43 | pattern = [[ \b\w+\b ]]; 44 | }, 45 | { 46 | name = "MathOp"; fgcolor = "white"; 47 | pattern = [[ [^\w\s] ]]; 48 | }, 49 | } 50 | 51 | Class { 52 | name = "Shell script"; 53 | filemask = "*.sh"; 54 | syntax = syntax_shell; 55 | } 56 | -------------------------------------------------------------------------------- /Plugins/highlight/src/syntaxes/syntax_srecord.lua: -------------------------------------------------------------------------------- 1 | local syntax_srec = 2 | { 3 | bgcolor = "darkblue"; 4 | { 5 | name = "RecordType"; fgcolor = "white"; 6 | pattern = [[ ^ S [0-9] ]]; 7 | }, 8 | { 9 | name = "Byte count"; fgcolor = "purple"; 10 | pattern = [[ (?<= S[0-9]) [0-9a-fA-F]{2} ]]; 11 | }, 12 | { 13 | name = "Address"; fgcolor = "yellow"; 14 | pattern = [[ (?<= S[0159] [0-9a-fA-F]{2}) [0-9a-fA-F]{4} | 15 | (?<= S[268] [0-9a-fA-F]{2}) [0-9a-fA-F]{6} | 16 | (?<= S[37] [0-9a-fA-F]{2}) [0-9a-fA-F]{8} ]]; 17 | }, 18 | { 19 | name = "Checksum"; fgcolor = "red"; 20 | pattern = [[ [0-9a-fA-F]{2} \s* $ ]]; 21 | }, 22 | } 23 | 24 | Class { 25 | name = "Motorola S-record file"; 26 | filemask = "*.s19,*.s28,*.s37"; 27 | syntax = syntax_srec; 28 | fastlines = 0; 29 | } 30 | -------------------------------------------------------------------------------- /Plugins/highlight/src/syntaxes/syntax_tcl.lua: -------------------------------------------------------------------------------- 1 | local syntax_tcl = 2 | { 3 | bgcolor = "darkblue"; 4 | bracketmatch = true; 5 | { 6 | name = "Comment"; fgcolor = "gray7"; 7 | pattern = [[ \#.* ]]; 8 | }, 9 | { 10 | name = "Literal"; fgcolor = "white"; 11 | pattern = [[ (?i) \b 12 | (?: 0x[\dA-F]+ | 13 | \d+ | 14 | (?:\d+\.\d*|\.?\d+) (?:E[+-]?\d+)? 15 | ) 16 | \b ]]; 17 | }, 18 | { 19 | name = "String"; fgcolor = "purple"; color_unfinished= "darkblue on purple"; 20 | pat_open = [[ " ]]; 21 | pat_skip = [[ (?: \\. | [^\\"] )* ]]; 22 | pat_close = [[ " ]]; 23 | pat_continue = [[ \\$ ]]; 24 | }, 25 | { 26 | name = "Char"; fgcolor = "purple"; color_unfinished= "darkblue on purple"; 27 | pattern = [[ ' (?: \\. | [^\\'] ) ' ]]; 28 | }, 29 | { 30 | name = "Depoint"; fgcolor = "purple"; 31 | pattern = [[\$\w+]]; 32 | }, 33 | { 34 | name = "Keyword"; fgcolor = "yellow"; 35 | pattern = [[ \b(?: 36 | after|aio|alarm|alias|append|apply|array|binary|break|case|catch|cd|class|clock|close|collect| 37 | concat|continue|curry|dict|elseif|else|env|eof|error|eval|eventloop|exec|exists|exit|expr|fconfigure| 38 | file|finalize|flush|for|foreach|format|getref|gets|glob|global|history|if|incr|info|interp|join|kill| 39 | lambda|lappend|lassign|lindex|linsert|list|llength|lmap|load|local|loop|lrange|lrepeat|lreplace| 40 | lreverse|lsearch|lset|lsort|namespace|oo|open|os.fork|os.gethostname|os.getids|os.uptime|os.wait| 41 | pack|package|pid|posix|proc|puts|pwd|rand|range|read|ref|regexp|regsub|rename|return|scan|seek| 42 | set|setref|signal|sleep|socket|source|split|stackdump|stacktrace|string|subst|super|switch|syslog| 43 | tailcall|tcl::prefix|tell|then|throw|time|tree|try|unknown|unpack|unset|upcall|update|uplevel|upvar| 44 | vwait|while|zlib 45 | )\b ]]; 46 | }, 47 | { 48 | name = "Word"; fgcolor = "aqua"; 49 | pattern = [[ \b\w+\b ]]; 50 | }, 51 | { 52 | name = "MathOp"; fgcolor = "white"; 53 | pattern = [[ [^\w\s] ]]; 54 | }, 55 | } 56 | 57 | Class { 58 | name = "TCL"; 59 | filemask = "*.tcl"; 60 | syntax = syntax_tcl; 61 | } 62 | -------------------------------------------------------------------------------- /Plugins/highlight/src/syntaxes/syntax_text.lua: -------------------------------------------------------------------------------- 1 | local syntax_text = 2 | { 3 | bgcolor = "darkblue"; 4 | bracketmatch = true; 5 | { 6 | name = "Emphasize1"; fgcolor = "green"; 7 | pattern = [[ ^\s*__.* | \b_.*?_\b ]]; 8 | }, 9 | { 10 | name = "Emphasize2"; color = "yellow on gold"; 11 | pattern = [[ \*\*.*?\*{2,} ]]; 12 | }, 13 | { 14 | name = "Important"; fgcolor = "red"; 15 | pattern = [[ ^\s*\\\\.* ]]; 16 | }, 17 | { 18 | name = "RusLetter"; fgcolor = "yellow"; 19 | pattern = [[ [а-яёА-ЯЁ]+ ]]; 20 | }, 21 | { 22 | name = "Comment"; fgcolor = "gray7"; 23 | pattern = [[ ^\s*\/\/.* ]]; 24 | }, 25 | { 26 | name = "Digit"; fgcolor = "white"; 27 | pattern = [[ [\d\W]+? ]]; 28 | }, 29 | } 30 | 31 | Class { 32 | name = "My editor"; 33 | filemask = "*.txt;readme|CMakeLists.txt"; 34 | syntax = syntax_text; 35 | fastlines = 0; 36 | firstline = "text"; 37 | } 38 | -------------------------------------------------------------------------------- /Plugins/lf4ed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(lf4ed) 2 | 3 | set(SOURCES 4 | src/GlobalInfo.c 5 | ${FARSOURCE}/luafar/src/luaplug.c 6 | ) 7 | 8 | add_library (${PROJECT_NAME} MODULE ${SOURCES}) 9 | set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) 10 | 11 | set(EXPNAMES 12 | CONFIGURE MAYEXITFAR OPENPLUGIN PROCESSEDITOREVENT 13 | PROCESSEDITORINPUT PROCESSVIEWEREVENT PROCESSDIALOGEVENT 14 | ) 15 | 16 | set(EXPORTS "") 17 | foreach(f ${EXPNAMES}) 18 | list(APPEND EXPORTS "-DEXPORT_${f}") 19 | endforeach() 20 | 21 | target_compile_definitions(${PROJECT_NAME} 22 | PRIVATE ${EXPORTS} 23 | ) 24 | 25 | target_include_directories(${PROJECT_NAME} PRIVATE ${FARSOURCE}/far/far2sdk) 26 | 27 | if(${CMAKE_SYSTEM_NAME} MATCHES "Android") 28 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/luafar.so) 29 | endif() 30 | 31 | set(INSTALL_DIR "${INSTALL_DIR}/${PROJECT_NAME}") 32 | 33 | set_target_properties(${PROJECT_NAME} 34 | PROPERTIES 35 | LIBRARY_OUTPUT_DIRECTORY "${INSTALL_DIR}/plug" 36 | PREFIX "" 37 | SUFFIX ".far-plug-wide") 38 | 39 | set(MY_LIST 40 | config.lua 41 | expression.lua 42 | lf4ed.lua 43 | sortdialog.lua 44 | sortlines.lua 45 | wrap.lua 46 | _usermenu.lua 47 | lf4ed_eng.hlf 48 | lf4ed_rus.hlf 49 | ) 50 | 51 | foreach(elem ${MY_LIST}) 52 | configure_file("src/${elem}" "${INSTALL_DIR}/plug/${elem}" COPYONLY) 53 | endforeach() 54 | 55 | add_custom_target(${PROJECT_NAME}_lang ALL 56 | minilua ${LUA_SHARE}/makelang.lua ${CMAKE_CURRENT_SOURCE_DIR}/src/lf4ed_lang.templ ${INSTALL_DIR}/plug 57 | ) 58 | 59 | add_custom_target(${PROJECT_NAME}_files ALL 60 | COMMAND cp -rf "${CMAKE_CURRENT_SOURCE_DIR}/src/scripts" "${INSTALL_DIR}/plug/" 61 | ) 62 | -------------------------------------------------------------------------------- /Plugins/lf4ed/doc/lf4ed_manual.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shmuz/luafar2m/d7fb765fec989e20ea641977a9cb54b99c7db304/Plugins/lf4ed/doc/lf4ed_manual.chm -------------------------------------------------------------------------------- /Plugins/lf4ed/doc/license.txt: -------------------------------------------------------------------------------- 1 | License of LuaFAR for Editor v2.x.x 2 | ------------------------------------ 3 | 4 | Copyright (C) Shmuel Zeigerman 2007-2022 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated 8 | documentation files (the "Software"), to deal in the 9 | Software without restriction, including without limitation 10 | the rights to use, copy, modify, merge, publish, distribute, 11 | sublicense, and/or sell copies of the Software, and to 12 | permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall 16 | be included in all copies or substantial portions of the 17 | Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 20 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 21 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 22 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 23 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 24 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 25 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/GlobalInfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SHAREDSYMBOL void WINAPI GetGlobalInfoW(struct GlobalInfo *aInfo) 4 | { 5 | struct VersionInfo Version = { 3,9,4,0 }; 6 | aInfo->StructSize = sizeof(*aInfo); 7 | aInfo->SysID = 0x6F332978; 8 | aInfo->Version = Version; 9 | aInfo->Title = L"LuaFAR for Editor"; 10 | aInfo->Description = L"A host for scripts and script packets"; 11 | aInfo->Author = L"Shmuel Zeigerman"; 12 | } 13 | //--------------------------------------------------------------------------- 14 | 15 | SHAREDSYMBOL int WINAPI GetMinFarVersionW(void) 16 | { 17 | return MAKEFARVERSION(2,4); 18 | } 19 | //--------------------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/_usermenu.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: globals lf4ed AddCommand AddToMenu AddUserFile AutoInstall 2 | 3 | local function ReloadUserFile() 4 | lf4ed.reload() 5 | far.Message("User file reloaded","LF4Ed","") 6 | win.Sleep(600) 7 | actl.RedrawAll() 8 | end 9 | AddCommand("reload", ReloadUserFile, "Reload user file") 10 | 11 | -- main user menu file 12 | AddToMenu ("e", nil, "Ctrl+1", 1) 13 | AddToMenu ("e", nil, "Ctrl+2", 2) 14 | AddToMenu ("e", nil, "Ctrl+3", 3) 15 | AddToMenu ("e", nil, "Ctrl+4", 4) 16 | AddToMenu ("e", nil, "Ctrl+5", 5) 17 | AddToMenu ("e", nil, "Ctrl+6", 6) 18 | AddToMenu ("e", ":sep:") 19 | AddUserFile("scripts/test_sortlines.lua") 20 | 21 | -- AutoInstall("scripts") 22 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/config.lua: -------------------------------------------------------------------------------- 1 | -- file created: 2008-12-18 2 | 3 | local sd = require "far2.simpledialog" 4 | local M = require "lf4ed_message" 5 | local F = far.Flags 6 | 7 | local function ExecuteDialog (aData) 8 | local Items = { 9 | width=54; 10 | help="PluginConfig"; 11 | guid="0F5573D7-FD25-408D-8A8A-E917C0CA14DE"; 12 | 13 | {tp="dbox"; text=M.MPluginSettings;}, 14 | {tp="chbox"; text=M.MReloadDefaultScript; name="ReloadDefaultScript"; }, 15 | {tp="chbox"; text=M.MRequireWithReload; name="RequireWithReload"; }, 16 | {tp="text"; text=M.MExcludeFromReload; x1=9; name="txtExclude"; }, 17 | {tp="edit"; x1=9; name="ExcludeFromReload"; }, 18 | {tp="chbox"; text=M.MReturnToMainMenu; name="ReturnToMainMenu"; }, 19 | {tp="sep"; }, 20 | {tp="butt"; text=M.MOk; default=1; centergroup=1; }, 21 | {tp="butt"; text=M.MCancel; cancel=1; centergroup=1; }, 22 | } 23 | ------------------------------------------------------------------------------ 24 | local dlg = sd.New(Items) 25 | local Pos = dlg:Indexes() 26 | function Items.proc(hDlg, Msg, Par1, Par2) 27 | if Msg==F.DN_INITDIALOG or (Msg==F.DN_BTNCLICK and Par1==Pos.RequireWithReload) then 28 | local enb = hDlg:GetCheck(Pos.RequireWithReload) == 1 29 | hDlg:Enable(Pos.txtExclude, enb) 30 | hDlg:Enable(Pos.ExcludeFromReload, enb) 31 | end 32 | end 33 | ------------------------------------------------------------------------------ 34 | dlg:LoadData(aData) 35 | local out = dlg:Run() 36 | if out then 37 | dlg:SaveData(out, aData) 38 | return true 39 | end 40 | end 41 | 42 | local data = (...) 43 | return ExecuteDialog(data) 44 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/lf4ed_lang.templ: -------------------------------------------------------------------------------- 1 | 2 | [Languages] 3 | .Language=English,English 4 | .Language=Russian,Russian (Русский) 5 | 6 | [Settings] 7 | msgfile = lf4ed_message.lua 8 | lngfile = lf4ed 9 | 10 | [Messages] 11 | 12 | // Common 13 | MOk 14 | "OK" 15 | "OK" 16 | 17 | MCancel 18 | "Cancel" 19 | "Отмена" 20 | 21 | MError 22 | "Error" 23 | "Ошибка" 24 | 25 | // Menu 26 | MPluginName 27 | "LuaFAR for Editor" 28 | "LuaFAR для редактора" 29 | 30 | MSort 31 | "Sort Lines" 32 | "Сортировка строк" 33 | 34 | MWrap 35 | "Reformat Block" 36 | "Формат блока" 37 | 38 | MBlockSum 39 | "Block Sum" 40 | "Сумма в блоке" 41 | 42 | MExpr 43 | "Lua Expression" 44 | "Lua-выражение" 45 | 46 | MScript 47 | "Lua Script" 48 | "Lua-скрипт" 49 | 50 | MScriptParams 51 | "Script Parameters" 52 | "Параметры скрипта" 53 | 54 | MPluginNameCfg 55 | "LuaFAR for Editor (settings)" 56 | "LuaFAR для Редактора (настройки)" 57 | 58 | MReloadUserFile 59 | "Reload User File" 60 | "Перезагрузить файл пользователя" 61 | 62 | MPluginSettings 63 | "Plugin settings" 64 | "Настройки плагина" 65 | 66 | // Sort Lines 67 | MSortLines 68 | "Sort Lines" 69 | "Сортировать строки" 70 | 71 | MEnable1 72 | "&Enable" 73 | "Р&азрешить" 74 | 75 | MEnable2 76 | "E&nable" 77 | "Ра&зрешить" 78 | 79 | MEnable3 80 | "En&able" 81 | "Разре&шить" 82 | 83 | MReverse1 84 | "&Reverse" 85 | "&Реверс" 86 | 87 | MReverse2 88 | "Re&verse" 89 | "Р&еверс" 90 | 91 | MReverse3 92 | "Rever&se" 93 | "Ре&верс" 94 | 95 | MExpr1 96 | "Expr.&1" 97 | "Выраж.&1" 98 | 99 | MExpr2 100 | "Expr.&2" 101 | "Выраж.&2" 102 | 103 | MExpr3 104 | "Expr.&3" 105 | "Выраж.&3" 106 | 107 | MColPat 108 | "Col&umn Pattern" 109 | "Ша&блон колонки" 110 | 111 | MDefault 112 | "&Default" 113 | "&Сброс" 114 | 115 | MFileName 116 | "&Load File" 117 | "За&грузить файл" 118 | 119 | MEnable4 120 | "Ena&ble" 121 | "Разреш&ить" 122 | 123 | MOnlySel 124 | "&Only selected" 125 | "Т&олько выделение" 126 | 127 | MCase1 128 | "&Case sensitive" 129 | "&Учитывать регистр" 130 | 131 | MCase2 132 | "Case sens&itive" 133 | "У&читывать регистр" 134 | 135 | MCase3 136 | "Case sensi&tive" 137 | "Учи&тывать регистр" 138 | 139 | // Lua Expression; Block sum 140 | MNoTextSelected 141 | "No text is selected" 142 | "Нет выделенного текста" 143 | 144 | MResult 145 | "&Result:" 146 | "&Результат:" 147 | 148 | MInsertText 149 | "&Insert" 150 | "&Вставить" 151 | 152 | MCopyToClipboard 153 | "&Copy" 154 | "&Скопировать" 155 | 156 | // Reformat Block 157 | MReformatBlock 158 | "Reformat Block" 159 | "Форматировать Блок" 160 | 161 | MReformatBlock2 162 | "&Reformat Block" 163 | "&Форматировать блок" 164 | 165 | MStartColumn 166 | "&Start column" 167 | "&Левый край" 168 | 169 | MEndColumn 170 | "&End column" 171 | "&Правый край" 172 | 173 | MJustifyBorder 174 | "&Justify right border" 175 | "Вы&ровнять правый край" 176 | 177 | MProcessLines 178 | "&Process Lines" 179 | "&Обработать строки" 180 | 181 | MLineExpr 182 | "&Expression:" 183 | "&Выражение:" 184 | 185 | // Script parameters dialog 186 | MExternalScript 187 | "&External script:" 188 | "&Внешний скрипт:" 189 | 190 | MParamsSeparator 191 | " Parameters " 192 | " Параметры " 193 | 194 | MScriptParamsEnable 195 | "&Pass parameters to the script" 196 | "&Передавать параметры скрипту" 197 | 198 | MStoreParams 199 | "&Store" 200 | "&Сохранить" 201 | 202 | MRunScript 203 | "&Run" 204 | "&Исполнить" 205 | 206 | // Config. dialog 207 | MReloadDefaultScript 208 | "&Always reload default script" 209 | "&Перезагружать главный скрипт" 210 | 211 | MRequireWithReload 212 | "A&lways reload on 'require'" 213 | "П&ерезагружать по 'require'" 214 | 215 | MExcludeFromReload 216 | "&Except:" 217 | "&За исключением:" 218 | 219 | MReturnToMainMenu 220 | "&Return to Main menu" 221 | "&Возвращаться в главное меню" 222 | 223 | // Command line syntax message box 224 | MCommandSyntaxTitle 225 | "command line/call from macro" 226 | "командная строка/вызов из макроса" 227 | 228 | // End file // 229 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/scripts/Editor.ColorWord.moon: -------------------------------------------------------------------------------- 1 | -- Original author: Vadim Yegorov (aka zg) 2 | -- https://forum.farmanager.com/viewtopic.php?p=134436#p134436 3 | 4 | -- Options 5 | OptCaseSensitive=false 6 | -- End of options 7 | 8 | F=far.Flags 9 | band,bor,lshift,rshift = bit64.band, bit64.bor, bit64.lshift, bit64.rshift 10 | color = actl.GetColor "COL_EDITORTEXT" 11 | color = bor lshift(band(color,0xF),4), rshift(color,4) 12 | words={} 13 | 14 | -- Highlight Word Under Cursor 15 | AddToMenu "e", nil, "F5", -> 16 | ei=editor.GetInfo! 17 | id=ei.EditorID 18 | if words[id] then words[id]=nil 19 | else 20 | pos=ei.CurPos 21 | line=editor.GetString!.StringText 22 | if pos<=line\len()+1 23 | slab=pos>1 and line\sub(1,pos-1)\match('[%w_]+$') or "" 24 | tail=line\sub(pos)\match('^[%w_]+') or "" 25 | if slab~="" or tail~="" then words[id]=OptCaseSensitive and slab..tail or (slab..tail)\lower! 26 | editor.Redraw! 27 | 28 | AddEvent "EditorEvent", (id, event,param) -> 29 | if event==F.EE_REDRAW 30 | if words[id] 31 | ei=editor.GetInfo id 32 | start,finish=ei.TopScreenLine,math.min ei.TopScreenLine+ei.WindowSizeY,ei.TotalLines 33 | for ii=start,finish 34 | line,pos=editor.GetString(nil,ii).StringText,1 35 | while true 36 | jj,kk,curr=line\find("([%w_]+)",pos) 37 | if not jj then break 38 | if not OptCaseSensitive then curr=curr\lower! 39 | if curr==words[id] then editor.AddColor nil,ii,jj,kk,"ECF_AUTODELETE",color 40 | pos=kk+1 41 | elseif event==F.EE_CLOSE then words[id]=nil 42 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/scripts/bracket.lua: -------------------------------------------------------------------------------- 1 | -- bracket.lua 2 | 3 | local function FastGetString (num) 4 | return editor.GetString(nil,num, 2) 5 | end 6 | 7 | local function FindBracket() 8 | local ei = editor.GetInfo() 9 | local line = FastGetString(ei.CurLine) 10 | if ei.CurPos > line:len() then 11 | return 12 | end 13 | 14 | local Bracket = line:sub (ei.CurPos, ei.CurPos) 15 | local Direction, Match 16 | do 17 | local tForward = { ["("]=")", ["{"]="}", ["["]="]", ["<"]=">", } 18 | local tBackward = { [")"]="(", ["}"]="{", ["]"]="[", [">"]="<", } 19 | if tForward[Bracket] then 20 | Direction, Match = 1, tForward[Bracket] 21 | elseif tBackward[Bracket] then 22 | Direction, Match = -1, tBackward[Bracket] 23 | else 24 | return 25 | end 26 | end 27 | 28 | local CurPos, CurLine = ei.CurPos, ei.CurLine 29 | local MatchCount = 1 30 | while true do 31 | CurPos = CurPos + Direction 32 | if CurPos > line:len() then 33 | CurLine = CurLine + 1 34 | if CurLine > ei.TotalLines then 35 | break 36 | end 37 | line = FastGetString(CurLine) 38 | CurPos = 1 39 | end 40 | if CurPos < 1 then 41 | CurLine = CurLine - 1 42 | if CurLine < 1 then 43 | break 44 | end 45 | line = FastGetString(CurLine) 46 | CurPos = line:len() 47 | end 48 | if CurPos >= 1 and CurPos <= line:len() then 49 | local Ch = line:sub (CurPos, CurPos) 50 | if Ch == Bracket then 51 | MatchCount = MatchCount + 1 52 | elseif Ch == Match then 53 | MatchCount = MatchCount - 1 54 | if MatchCount == 0 then 55 | local esp = { CurLine = CurLine, CurPos = CurPos } 56 | if (CurLine < ei.TopScreenLine or 57 | CurLine >= ei.TopScreenLine + ei.WindowSizeY) 58 | then 59 | esp.TopScreenLine = CurLine - ei.WindowSizeY/2; 60 | if esp.TopScreenLine < 1 then 61 | esp.TopScreenLine = 1 62 | end 63 | end 64 | editor.SetPosition(nil,esp) -- match found: set the new position 65 | editor.Redraw() 66 | return 67 | end 68 | end 69 | end 70 | end 71 | editor.SetPosition(nil,ei) -- match not found: restore the initial position 72 | editor.Redraw() 73 | end 74 | 75 | AddToMenu ("e", nil, "Ctrl+E", FindBracket) 76 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/scripts/calc.lua: -------------------------------------------------------------------------------- 1 | local F = far.Flags 2 | 3 | local function GetSelectedText() 4 | local ei = editor.GetInfo() 5 | if ei and ei.BlockType ~= F.BTYPE_NONE then 6 | local t = {} 7 | local n = ei.BlockStartLine 8 | while true do 9 | local s = editor.GetString(nil,n, 1) 10 | if not s or s.SelStart == 0 then 11 | break 12 | end 13 | local sel = s.StringText:sub (s.SelStart, s.SelEnd) 14 | table.insert(t, sel) 15 | n = n + 1 16 | end 17 | editor.SetPosition(nil,ei) 18 | return table.concat(t, "\n"), n-1 19 | end 20 | end 21 | 22 | local function GetText() 23 | local text = GetSelectedText() 24 | return (text ~= "") and text or editor.GetString(nil,nil,2) 25 | end 26 | 27 | local function ShowSumAndAverage() 28 | local sum = 0 29 | local min, max 30 | local n = 0 31 | local t = {} 32 | 33 | for num in regex.gmatch(GetText(), [[ \-? \b \d+ (?: \.\d+ )? \b ]], "x") do 34 | num = tonumber(num) 35 | n = n + 1 36 | t[n] = num 37 | sum = sum + num 38 | if n == 1 then 39 | min, max = num, num 40 | else 41 | if min > num then min = num end 42 | if max < num then max = num end 43 | end 44 | end 45 | 46 | local avr, std_dev, abs_dev 47 | if n > 0 then 48 | avr = sum / n 49 | std_dev, abs_dev = 0, 0 50 | for _,v in ipairs(t) do 51 | v = v - avr 52 | std_dev = std_dev + v*v 53 | abs_dev = abs_dev + (v>=0 and v or -v) 54 | end 55 | std_dev = math.sqrt(std_dev / n) 56 | abs_dev = abs_dev / n 57 | end 58 | 59 | local s = [[ 60 | Quantity: %d 61 | Sum: %s 62 | Average: %s 63 | Minimum: %s 64 | Maximum: %s 65 | Standard deviation: %s 66 | Aver. abs. deviation: %s]] 67 | 68 | local choice = far.Message( 69 | s:format(n, sum, avr or "n/a", min or "n/a", max or "n/a", std_dev or "n/a", abs_dev or "n/a"), 70 | "Sum and Average", n==0 and "OK" or "OK;Copy ∑Copy &average", "l") 71 | if choice==2 then far.CopyToClipboard(sum) 72 | elseif choice==3 then far.CopyToClipboard(avr) 73 | end 74 | end 75 | 76 | AddToMenu ("e", nil, "Ctrl+F9", ShowSumAndAverage) 77 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/scripts/coding.lua: -------------------------------------------------------------------------------- 1 | -- Started : 2021-03-06 2 | -- Minimal Far version : 3.0.3300 3 | -- Far plugin : Either LuaMacro or LF4Ed 4 | -- Description : Customize the following operations in the Far Editor: 5 | -- (1) indent on Enter press (configurable per file extension) 6 | -- (2) dedent on Backspace press 7 | 8 | local F = far.Flags 9 | -------------------------------------------------------------------------------- 10 | -- IMPORTANT: all keys (file extensions) in Config table must be in lower case 11 | local Config = { 12 | lua = { pat= [[ \b(then|else|do)\b \s* (\-\-.*)? $ ]], indent= " "; }, 13 | c = { pat= [[ \{ \s* (\/\/.*)? $ ]]; indent= " "; }, 14 | py = { pat= [[ \: \s* (\# .*)? $ ]]; indent= " "; }, 15 | } 16 | for _,v in pairs(Config) do v.pat = regex.new(v.pat,"x") end -- compile 17 | 18 | Config.cpp = Config.c 19 | Config.cxx = Config.c 20 | Config.h = Config.c 21 | Config.hpp = Config.c 22 | Config.pyw = Config.py 23 | -------------------------------------------------------------------------------- 24 | 25 | local function GetConfig() 26 | local ext = editor.GetFileName():match("%.([^.\\]+)$") or "" 27 | return Config[ext:lower()] 28 | end 29 | 30 | local function OnEnter() 31 | local conf = GetConfig() 32 | if conf then 33 | local info = editor.GetInfo() 34 | local curline = editor.GetString(nil,info.CurLine, 2) 35 | local line1, line2 = curline:sub(1,info.CurPos-1), curline:sub(info.CurPos) 36 | local indent = curline:match("^%s*") 37 | if conf.pat:find(line1) then 38 | indent = conf.indent .. indent 39 | end 40 | editor.UndoRedo(nil,"EUR_BEGIN") 41 | editor.InsertString() 42 | editor.SetString(nil,info.CurLine, line1:match("(.-)%s*$")) 43 | editor.SetString(nil,info.CurLine+1, indent..line2:match("%s*(.-)%s*$")) 44 | editor.SetPosition(nil,info.CurLine+1, #indent+1) 45 | editor.Redraw() 46 | editor.UndoRedo(nil,"EUR_END") 47 | return true 48 | end 49 | end 50 | 51 | local function OnBackSpace() 52 | local conf = GetConfig() 53 | if conf then 54 | local info = editor.GetInfo() 55 | if info.CurPos > 2 then 56 | local line = editor.GetString(nil,info.CurLine, 2) 57 | local pos = line:find("%S") 58 | if not (pos and pos < info.CurPos) then 59 | local stop = math.max(1, info.CurLine-1000) -- limit search at 1000 lines above the current 60 | for k=info.CurLine-1,stop,-1 do 61 | local ln = editor.GetString(nil,k, 2) 62 | pos = ln:find("%S") 63 | if pos and pos < info.CurPos then 64 | editor.SetString(nil,info.CurLine, ln:sub(1,pos-1)..line:sub(info.CurPos)) 65 | editor.SetPosition(nil,info.CurLine, pos) 66 | editor.Redraw() 67 | return true 68 | end 69 | end 70 | end 71 | end 72 | end 73 | end 74 | 75 | local function OnEditorInput(Rec) 76 | if Rec.EventType == F.KEY_EVENT then 77 | local key = far.InputRecordToName(Rec) 78 | if key == "Enter" or key == "NumEnter" then 79 | return OnEnter() 80 | elseif key == "BS" then 81 | return OnBackSpace() 82 | end 83 | end 84 | end 85 | 86 | -- description = "Auto-indent/dedent"; 87 | AddEvent("EditorInput", OnEditorInput) 88 | 89 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/scripts/dup_line.lua: -------------------------------------------------------------------------------- 1 | -- shmuel 14.06.2014 08:31:00 +0200 - build 1 2 | -- http://forum.farmanager.com/viewtopic.php?p=119751#p119751 3 | --------------------------------------------------------------------------------------- 4 | -- NOTE: for SciTE-like functionality of blocks duplication use CtrlP (built-in in Far) 5 | --------------------------------------------------------------------------------------- 6 | 7 | -- description="Duplicate current line"; 8 | -- area="Editor"; key="CtrlD"; 9 | AddToMenu("e", nil, "Ctrl+D", function() 10 | local info = editor.GetInfo() 11 | local line = editor.GetString() 12 | local eol = line.StringEOL ~= "" and line.StringEOL or nil 13 | editor.UndoRedo(nil,"EUR_BEGIN") 14 | editor.SetPosition(nil,nil,1) 15 | editor.InsertString() 16 | editor.SetPosition(nil,info) 17 | editor.SetString(nil,nil, line.StringText, eol) 18 | editor.UndoRedo(nil,"EUR_END") 19 | info.CurLine = info.CurLine + 1 20 | editor.SetPosition(nil,info) 21 | editor.Redraw() 22 | end) 23 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/scripts/editor_events.lua: -------------------------------------------------------------------------------- 1 | -- EE_SAVE: delete trailing spaces 2 | 3 | local filemask = 4 | ([[ bat c cmd cpp da_ h hex hlf hpp htm html lua luacheckrc mak moon pas py txt ]]) 5 | : gsub("%s*(%S+)%s*", "*.%1,") .. "changelog,makefile,readme" 6 | 7 | local F = far.Flags 8 | 9 | local function RemoveTrailingSpaces(Id, Event, Param) 10 | if Event==F.EE_SAVE then 11 | local info = editor.GetInfo() 12 | if info and far.ProcessName(F.PN_CMPNAMELIST, filemask, info.FileName, F.PN_SKIPPATH) then 13 | for k=1,info.TotalLines do 14 | local ln = editor.GetString(nil,k,1) 15 | local from = ln.StringText:find("%s+$") 16 | if from then 17 | local str = ln.StringText:sub(1,from-1) 18 | editor.SetString(nil,k,str,ln.StringEOL) 19 | end 20 | end 21 | editor.SetPosition(nil,info) 22 | end 23 | end 24 | end 25 | 26 | AddEvent("EditorEvent", RemoveTrailingSpaces) 27 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/scripts/file2hex.lua: -------------------------------------------------------------------------------- 1 | -- Goal : Convert file contents to HEX 2 | -- Started : 2018-08-19 (by Shmuel Zeigerman) 3 | -- Tested : x86; x64; unicode file names; 4 | -- See also : 0003638: LuaFAR: проверить имплементацию file:rawhandle (https://bugs.farmanager.com/view.php?id=3638) 5 | 6 | if not jit then return end -- LuaJIT required 7 | 8 | -- Begin settings 9 | ---- local Shortcut = "CtrlShiftF2" 10 | -- End settings 11 | 12 | local ffi=require 'ffi' 13 | local C=ffi.C 14 | ffi.cdef[[ 15 | typedef struct { int a; } FILE; 16 | size_t fread(void*,size_t,size_t,FILE*); 17 | size_t fwrite(const void*,size_t,size_t,FILE*); 18 | FILE* fopen(const char*, const char*); 19 | int fclose(FILE*); 20 | ]] 21 | 22 | local F = far.Flags 23 | local band, rshift = bit64.band, bit64.rshift 24 | 25 | local function ShowProgress(Title, Size) 26 | if Size then 27 | if win.ExtractKey()=="ESCAPE" and 1==far.Message("Break the operation?",Title,"&Yes;&No","w") then 28 | return true 29 | end 30 | far.Message(math.floor(Size/0x100000).." MB", Title, "") 31 | else 32 | far.Message("Working, please wait...", Title, "") 33 | far.AdvControl("ACTL_REDRAWALL") 34 | end 35 | end 36 | 37 | -- description="Convert file contents to HEX"; 38 | -- area="Shell"; key=Shortcut; 39 | -- flags="NoPluginPanels NoFolders"; 40 | local function File2Hex() 41 | local info = panel.GetPanelInfo(nil, 1) 42 | if band(info.Flags, F.PFLAGS_PLUGIN) ~= 0 then return end 43 | 44 | local item = panel.GetCurrentPanelItem(nil, 1) 45 | if item.FileAttributes:find("d") then return end 46 | 47 | local Title = "Convert file contents to HEX"; 48 | local dir = panel.GetPanelDirectory(nil, 1).Name 49 | local name_in = dir.."/"..item.FileName 50 | local name_out = name_in..".hex" 51 | local f_in =assert(C.fopen(name_in, "rb")) 52 | local f_out=assert(C.fopen(name_out, "wb")) 53 | local ibufsize = 0x10000 54 | local ibuf=ffi.new("unsigned char[?]", ibufsize) 55 | local obuf=ffi.new("unsigned char[?]", 2*ibufsize) 56 | for cnt=0,math.huge do 57 | if ShowProgress(Title, cnt*ibufsize) then 58 | break 59 | end 60 | local n = C.fread(ibuf, 1, ibufsize, f_in) 61 | if n == 0 then break end 62 | for i=0,tonumber(n-1) do 63 | local low = band(ibuf[i],0xf) 64 | local high = rshift(ibuf[i],4) 65 | obuf[i+i] = high<10 and high+48 or high+55 66 | obuf[i+i+1] = low<10 and low+48 or low+55 67 | end 68 | C.fwrite(obuf, 1, n+n, f_out) 69 | end 70 | C.fclose(f_out) 71 | C.fclose(f_in) 72 | panel.UpdatePanel(nil, 1) 73 | far.AdvControl("ACTL_REDRAWALL") 74 | end 75 | 76 | AddCommand("file2hex", File2Hex) 77 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/scripts/lf_fin.lua: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------- 2 | -- Name: FIN == "Fix Incorrect Names" 3 | -- Started: 2010-08-26 4 | -- Author: Shmuel Zeigerman 5 | -- Original author of plugin in Pascal: Андрей Подлазов aka Тигрёнок. 6 | ----------------------------------------------------------------------------- 7 | 8 | local Pattern = "%s+$" 9 | local F = far.Flags 10 | 11 | local GUIDs = { 12 | [win.Uuid("fcef11c4-5490-451d-8b4a-62fa03f52759")] = "CopyFilesId", 13 | [win.Uuid("431a2f37-ac01-4ecd-bb6f-8cde584e5a03")] = "MoveFilesId", 14 | [win.Uuid("1d07cee2-8f4f-480a-be93-069b4ff59a2b")] = "FileOpenCreateId", 15 | [win.Uuid("9162f965-78b8-4476-98ac-d699e5b6afe7")] = "FileSaveAsId", 16 | [win.Uuid("5eb266f4-980d-46af-b3d2-2c50e64bca81")] = "HardSymLinkId", 17 | [win.Uuid("fad00dbe-3fff-4095-9232-e1cc70c67737")] = "MakeFolderId", 18 | [win.Uuid("d2750b57-d3e6-42f4-8137-231c50ddc6e4")] = "UserMenuUserInputId", 19 | [win.Uuid("502d00df-ee31-41cf-9028-442d2e352990")] = "CopyCurrentOnlyFileId", 20 | [win.Uuid("89664ef4-bb8c-4932-a8c0-59cafd937aba")] = "MoveCurrentOnlyFileId", 21 | } 22 | 23 | local function FIN (Event, FarDialogEvent) 24 | if Event == F.DE_DLGPROCINIT and FarDialogEvent.Msg == F.DN_CLOSE 25 | and FarDialogEvent.Param1 >= 1 then 26 | local hDlg = FarDialogEvent.hDlg 27 | local DialogInfo = hDlg:GetDialogInfo() 28 | if DialogInfo and GUIDs[DialogInfo.Id] then 29 | for item = 1, 1e6 do 30 | local FarDialogItem = hDlg:GetDlgItem(item) 31 | if not FarDialogItem then break end 32 | if FarDialogItem[1] == F.DI_EDIT then 33 | local str, n = FarDialogItem[10]:gsub(Pattern, "") 34 | if n > 0 then 35 | hDlg:SetText(item, str) 36 | end 37 | break 38 | end 39 | end 40 | end 41 | end 42 | end 43 | 44 | AddEvent("DialogEvent", FIN) 45 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/scripts/misc.lua: -------------------------------------------------------------------------------- 1 | -- assuming "Show directories first" option is set 2 | -- description="Find an upper non-directory item"; 3 | -- area="Shell"; key="CtrlShiftHome"; 4 | local function JumpToNonDir() 5 | local pInfo = panel.GetPanelInfo(nil, 1) 6 | if pInfo then 7 | local lower, upper = 1, pInfo.ItemsNumber 8 | while upper-lower >= 2 do -- binary search 9 | local curr = math.floor((lower+upper)/2) 10 | local item = panel.GetPanelItem(nil,1,curr) 11 | if item.FileAttributes:find("d") then lower = curr 12 | else upper = curr 13 | end 14 | end 15 | panel.RedrawPanel(nil,1,{ CurrentItem=upper; TopPanelItem=upper-8; }) 16 | end 17 | end 18 | 19 | local function SmartHome() 20 | local info, str = editor.GetInfo(), editor.GetString() 21 | local pos = str.StringText:find("%S") or 1 22 | editor.SetPosition(nil,nil, pos==info.CurPos and 1 or pos) 23 | editor.Redraw() 24 | end 25 | 26 | local function InsertNewGuid() 27 | editor.InsertText(nil, '"'..win.Uuid(win.Uuid()):upper()..'"', true) 28 | end 29 | 30 | local function Calc() require("far2.calc")() end 31 | 32 | AddCommand ("luacalc", Calc) 33 | AddCommand ("JumpToNonDir", JumpToNonDir) 34 | 35 | AddToMenu ("e", nil, "Home", SmartHome) 36 | AddToMenu ("e", nil, "Ctrl+F11", InsertNewGuid) 37 | AddToMenu ("depv", "Lua Calc", nil, Calc) 38 | -------------------------------------------------------------------------------- /Plugins/lf4ed/src/scripts/visual_compare.lua: -------------------------------------------------------------------------------- 1 | -- Started: 2017-08-02 2 | 3 | -- The algorithm for choosing a file pair for visual comparison: 4 | -- 1. Active panel: either 1 selected or valid current file --> file1 5 | -- Passive panel: either 1 selected or having the same name --> file2 6 | -- 2. Active panel: 2 selected --> file1, file2 7 | -- 3. Active panel: >2 selected and valid current file --> file1 8 | -- Passive panel: either 1 selected or having the same name --> file2 9 | 10 | local F = far.Flags 11 | local function GetCurrentItem(pan) return panel.GetCurrentPanelItem(nil,pan) end 12 | local function GetSelectedItem(pan,index) return panel.GetSelectedPanelItem(nil,pan,index) end 13 | local function isfile(item) return not item.FileAttributes:find("d") end 14 | local function extract_name(s) return s:match("[^/]+$") end 15 | 16 | local function fexist(file) 17 | return not (win.GetFileAttr(file) or "d"):find("d") 18 | end 19 | 20 | local function join(s1, s2) 21 | return s1=="" and s2 or s1:find("/$") and s1..s2 or s1.."/"..s2 22 | end 23 | 24 | local function Run() 25 | local ACT,PSV = 1,0 -- active and passive panels 26 | local aInfo = panel.GetPanelInfo(nil,ACT) 27 | local pInfo = panel.GetPanelInfo(nil,PSV) 28 | local dirActive = panel.GetPanelDirectory(nil,ACT).Name 29 | local dirPassive = panel.GetPanelDirectory(nil,PSV).Name 30 | local trgActive, trgPassive 31 | 32 | if aInfo.SelectedItemsNumber == 1 or aInfo.SelectedItemsNumber > 2 then 33 | local aItem = aInfo.SelectedItemsNumber == 1 and GetSelectedItem(ACT,1) or GetCurrentItem(ACT) 34 | if isfile(aItem) then 35 | trgActive = join(dirActive, aItem.FileName) 36 | if pInfo.SelectedItemsNumber == 1 then 37 | local pItem = GetSelectedItem(PSV,1) 38 | if bit64.band(pItem.Flags, F.PPIF_SELECTED) ~= 0 then 39 | trgPassive = join(dirPassive, pItem.FileName) 40 | end 41 | end 42 | if not trgPassive then 43 | local trg2 = join(dirPassive, extract_name(aItem.FileName)) 44 | if fexist(trg2) then trgPassive = trg2 end 45 | end 46 | end 47 | elseif aInfo.SelectedItemsNumber == 2 then 48 | local item1, item2 = GetSelectedItem(ACT,1), GetSelectedItem(ACT,2) 49 | if isfile(item1) and isfile(item2) then 50 | trgActive = join(dirActive, item1.FileName) 51 | trgPassive = join(dirActive, item2.FileName) 52 | end 53 | end 54 | 55 | if trgActive and trgPassive then 56 | os.execute(("meld %q %q &"):format(trgActive,trgPassive)) 57 | else 58 | far.Message("No suitable file pair found", "Visual compare", nil, "w") 59 | end 60 | end 61 | 62 | AddCommand("viscompare", Run) 63 | -------------------------------------------------------------------------------- /Plugins/lfhistory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(lfhistory) 2 | 3 | set(SOURCES 4 | src/GlobalInfo.c 5 | ${FARSOURCE}/luafar/src/luaplug.c 6 | ) 7 | 8 | add_library (${PROJECT_NAME} MODULE ${SOURCES}) 9 | set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) 10 | 11 | set(EXPNAMES 12 | CONFIGURE OPENPLUGIN 13 | ) 14 | 15 | set(EXPORTS "") 16 | foreach(f ${EXPNAMES}) 17 | list(APPEND EXPORTS "-DEXPORT_${f}") 18 | endforeach() 19 | 20 | target_compile_definitions(${PROJECT_NAME} 21 | PRIVATE ${EXPORTS} 22 | ) 23 | 24 | target_include_directories(${PROJECT_NAME} PRIVATE ${FARSOURCE}/far/far2sdk) 25 | 26 | if(${CMAKE_SYSTEM_NAME} MATCHES "Android") 27 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/luafar.so) 28 | endif() 29 | 30 | set(INSTALL_DIR "${INSTALL_DIR}/${PROJECT_NAME}") 31 | 32 | set_target_properties(${PROJECT_NAME} 33 | PROPERTIES 34 | LIBRARY_OUTPUT_DIRECTORY "${INSTALL_DIR}/plug" 35 | PREFIX "" 36 | SUFFIX ".far-plug-wide") 37 | 38 | set(MY_LIST 39 | lfhistory.lua 40 | lfh_config.lua 41 | lfh_eng.hlf 42 | lfh_rus.hlf 43 | ) 44 | 45 | foreach(elem ${MY_LIST}) 46 | configure_file("src/${elem}" "${INSTALL_DIR}/plug/${elem}" COPYONLY) 47 | endforeach() 48 | 49 | add_custom_target(${PROJECT_NAME}_lang ALL 50 | minilua ${LUA_SHARE}/makelang.lua ${CMAKE_CURRENT_SOURCE_DIR}/src/lfh_lang.templ ${INSTALL_DIR}/plug 51 | ) 52 | -------------------------------------------------------------------------------- /Plugins/lfhistory/src/GlobalInfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SHAREDSYMBOL void WINAPI GetGlobalInfoW(struct GlobalInfo *aInfo) 4 | { 5 | struct VersionInfo Version = { 3,12,4,0 }; 6 | aInfo->StructSize = sizeof(*aInfo); 7 | aInfo->SysID = 0xA745761D; 8 | aInfo->Version = Version; 9 | aInfo->Title = L"LuaFAR History"; 10 | aInfo->Description = L"History of commands, files and folders"; 11 | aInfo->Author = L"Shmuel Zeigerman"; 12 | } 13 | //--------------------------------------------------------------------------- 14 | 15 | SHAREDSYMBOL int WINAPI GetMinFarVersionW(void) 16 | { 17 | return MAKEFARVERSION(2,4); 18 | } 19 | //--------------------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /Plugins/lfsearch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(lfsearch) 2 | 3 | set(SOURCES 4 | src/GlobalInfo.c 5 | src/reader.c 6 | ${FARSOURCE}/luafar/src/luaplug.c 7 | ) 8 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFUNC_OPENLIBS=luaopen_reader") 9 | 10 | add_library (${PROJECT_NAME} MODULE ${SOURCES}) 11 | set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) 12 | 13 | set(EXPNAMES 14 | CLOSEPLUGIN CONFIGURE GETFINDDATA GETOPENPLUGININFO OPENFILEPLUGIN 15 | OPENPLUGIN PROCESSEDITOREVENT PROCESSEVENT PROCESSKEY PUTFILES SETDIRECTORY 16 | SETFINDLIST 17 | ) 18 | 19 | set(EXPORTS "") 20 | foreach(f ${EXPNAMES}) 21 | list(APPEND EXPORTS "-DEXPORT_${f}") 22 | endforeach() 23 | 24 | target_compile_definitions(${PROJECT_NAME} 25 | PRIVATE ${EXPORTS} 26 | ) 27 | 28 | target_include_directories(${PROJECT_NAME} PRIVATE 29 | ${FARSOURCE}/far/far2sdk) 30 | 31 | if(${CMAKE_SYSTEM_NAME} MATCHES "Android") 32 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/luafar.so) 33 | endif() 34 | 35 | set(INSTALL_DIR "${INSTALL_DIR}/${PROJECT_NAME}") 36 | 37 | set_target_properties(${PROJECT_NAME} 38 | PROPERTIES 39 | LIBRARY_OUTPUT_DIRECTORY "${INSTALL_DIR}/plug" 40 | PREFIX "" 41 | SUFFIX ".far-plug-wide") 42 | 43 | set(MY_LIST 44 | lfsearch.lua 45 | lfs_common.lua 46 | lfs_editengine.lua 47 | lfs_editmain.lua 48 | lfs_editors.lua 49 | lfs_mreplace.lua 50 | lfs_panels.lua 51 | lfs_rename.lua 52 | lfs_replib.lua 53 | _usermenu.lua 54 | lfs_eng.hlf 55 | lfs_rus.hlf 56 | ) 57 | 58 | foreach(elem ${MY_LIST}) 59 | configure_file("src/${elem}" "${INSTALL_DIR}/plug/${elem}" COPYONLY) 60 | endforeach() 61 | 62 | add_custom_target(${PROJECT_NAME}_lang ALL 63 | minilua ${LUA_SHARE}/makelang.lua ${CMAKE_CURRENT_SOURCE_DIR}/src/lfs_lang.templ ${INSTALL_DIR}/plug 64 | ) 65 | 66 | add_custom_target(${PROJECT_NAME}_files ALL 67 | COMMAND cp -rf "${CMAKE_CURRENT_SOURCE_DIR}/src/scripts" "${INSTALL_DIR}/plug/" 68 | COMMAND cp -rf "${CMAKE_CURRENT_SOURCE_DIR}/src/doc" "${INSTALL_DIR}/plug/" 69 | ) 70 | -------------------------------------------------------------------------------- /Plugins/lfsearch/src/GlobalInfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SHAREDSYMBOL void WINAPI GetGlobalInfoW(struct GlobalInfo *aInfo) 4 | { 5 | struct VersionInfo Version = { 3,49,0,0 }; 6 | aInfo->StructSize = sizeof(*aInfo); 7 | aInfo->SysID = 0x8E11EA75; 8 | aInfo->Version = Version; 9 | aInfo->Title = L"LuaFAR Search"; 10 | aInfo->Description = L"Plugin for search and replace"; 11 | aInfo->Author = L"Shmuel Zeigerman"; 12 | } 13 | //--------------------------------------------------------------------------- 14 | 15 | SHAREDSYMBOL int WINAPI GetMinFarVersionW(void) 16 | { 17 | return MAKEFARVERSION(2,4); 18 | } 19 | //--------------------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /Plugins/lfsearch/src/_usermenu.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: globals AddToMenu AddCommand 2 | 3 | AddCommand("test", "scripts/test_lfsearch") 4 | -------------------------------------------------------------------------------- /Plugins/lfsearch/src/doc/license.txt: -------------------------------------------------------------------------------- 1 | License of LuaFAR Search v2.x 2 | ----------------------------------- 3 | 4 | Copyright (C) Shmuel Zeigerman 2009-2011 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated 8 | documentation files (the "Software"), to deal in the 9 | Software without restriction, including without limitation 10 | the rights to use, copy, modify, merge, publish, distribute, 11 | sublicense, and/or sell copies of the Software, and to 12 | permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall 16 | be included in all copies or substantial portions of the 17 | Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 20 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 21 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 22 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 23 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 24 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 25 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | -------------------------------------------------------------------------------- /Plugins/lftmp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(lftmp) 2 | 3 | set(SOURCES 4 | src/GlobalInfo.c 5 | ${FARSOURCE}/luafar/src/luaplug.c 6 | ) 7 | 8 | add_library (${PROJECT_NAME} MODULE ${SOURCES}) 9 | set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) 10 | 11 | set(EXPNAMES 12 | CLOSEPLUGIN CONFIGURE GETFINDDATA GETOPENPLUGININFO 13 | OPENFILEPLUGIN OPENPLUGIN PROCESSEVENT PROCESSKEY PUTFILES 14 | SETDIRECTORY SETFINDLIST 15 | ) 16 | 17 | set(EXPORTS "") 18 | foreach(f ${EXPNAMES}) 19 | list(APPEND EXPORTS "-DEXPORT_${f}") 20 | endforeach() 21 | 22 | target_compile_definitions(${PROJECT_NAME} 23 | PRIVATE ${EXPORTS} 24 | ) 25 | 26 | target_include_directories(${PROJECT_NAME} PRIVATE 27 | ${FARSOURCE}/far/far2sdk) 28 | 29 | if(${CMAKE_SYSTEM_NAME} MATCHES "Android") 30 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/luafar.so) 31 | endif() 32 | 33 | set(INSTALL_DIR "${INSTALL_DIR}/${PROJECT_NAME}") 34 | 35 | set_target_properties(${PROJECT_NAME} 36 | PROPERTIES 37 | LIBRARY_OUTPUT_DIRECTORY "${INSTALL_DIR}/plug" 38 | PREFIX "" 39 | SUFFIX ".far-plug-wide") 40 | 41 | set(MY_LIST 42 | lftmp.lua 43 | LuaTmpEng.hlf 44 | LuaTmpRus.hlf 45 | ) 46 | 47 | foreach(elem ${MY_LIST}) 48 | configure_file("src/${elem}" "${INSTALL_DIR}/plug/${elem}" COPYONLY) 49 | endforeach() 50 | 51 | add_custom_target(${PROJECT_NAME}_lang ALL 52 | minilua ${LUA_SHARE}/makelang.lua ${CMAKE_CURRENT_SOURCE_DIR}/src/tmpp_lang.templ ${INSTALL_DIR}/plug 53 | ) 54 | -------------------------------------------------------------------------------- /Plugins/lftmp/src/GlobalInfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SHAREDSYMBOL void WINAPI GetGlobalInfoW(struct GlobalInfo *aInfo) 4 | { 5 | struct VersionInfo Version = { 3,1,2,0 }; 6 | aInfo->StructSize = sizeof(*aInfo); 7 | aInfo->SysID = 0xE2500D1C; 8 | aInfo->Version = Version; 9 | aInfo->Title = L"LuaFAR Temp. Panel"; 10 | aInfo->Description = L"A Lua clone of TmpPanel plugin"; 11 | aInfo->Author = L"Far Group, Shmuel Zeigerman"; 12 | } 13 | //--------------------------------------------------------------------------- 14 | 15 | SHAREDSYMBOL int WINAPI GetMinFarVersionW(void) 16 | { 17 | return MAKEFARVERSION(2,4); 18 | } 19 | //--------------------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /Plugins/lftmp/src/lftmp.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- luacheck: globals _Plugin 3 | 4 | -- CONFIGURATION : keep it at the file top !! 5 | local Cfg = { 6 | ReloadDefaultScript = true, -- Default script will be recompiled and run every time 7 | -- Open/OpenFilePlugin are called: set true for 8 | -- debugging, false for normal use; 9 | 10 | ReloadOnRequire = true, -- Reload lua libraries each time they are require()d: 11 | -- set true for libraries debugging, false for normal use; 12 | } 13 | 14 | -- UPVALUES : keep them above all function definitions !! 15 | local SETTINGS_KEY = nil 16 | local SETTINGS_NAME = "settings" 17 | 18 | local Sett = require "far2.settings" 19 | local Utils = require "far2.utils" 20 | 21 | local F = far.Flags 22 | local field = Sett.field 23 | local History, Env 24 | 25 | local function Require (name) 26 | package.loaded[name] = nil 27 | return require (name) 28 | end 29 | 30 | function export.Open (From, _Id, Item) 31 | if From == F.OPEN_COMMANDLINE then 32 | return Env:Open(From, Item) 33 | 34 | elseif From == F.OPEN_PLUGINSMENU then 35 | return Env:Open(From, Item) 36 | 37 | elseif From == F.OPEN_DISKMENU or From == F.OPEN_FINDLIST then 38 | return Env:NewPanel() 39 | 40 | end 41 | end 42 | 43 | function export.OpenFilePlugin (Name, Data) 44 | return Env:OpenFilePlugin (Name, Data) 45 | end 46 | 47 | function export.GetPluginInfo() 48 | local Info = Env:GetPluginInfo() 49 | --Info.Flags.preload = true 50 | return Info 51 | end 52 | 53 | function export.Configure (ItemNumber) 54 | return Env:Configure() 55 | end 56 | 57 | function export.ExitFAR() 58 | Env:ExitFAR() 59 | History.Env = Env 60 | Sett.msave(SETTINGS_KEY, SETTINGS_NAME, History) 61 | end 62 | 63 | local function InitUpvalues (plugin) 64 | History = plugin.History 65 | Require = Cfg.ReloadOnRequire and Require or require 66 | far.ReloadDefaultScript = Cfg.ReloadDefaultScript 67 | local tp = Require "far2.tmppanel" 68 | tp.SetMessageTable(require "tmpp_message") -- message localization support 69 | plugin.tmppanel = plugin.tmppanel or tp 70 | plugin.tmppanel.Env = tp.NewEnv (plugin.tmppanel.Env or field(History, "Env")) 71 | Env = plugin.tmppanel.Env 72 | for _, name in ipairs { 73 | "ClosePanel", 74 | "GetFindData", 75 | "GetOpenPanelInfo", 76 | "ProcessPanelEvent", 77 | "ProcessKey", 78 | "PutFiles", 79 | "SetDirectory", 80 | "SetFindList" } 81 | do 82 | export[name] = tp.Panel[name] 83 | end 84 | tp.Panel.ConfigFunction = export.Configure 85 | end 86 | 87 | local function main() 88 | if not _Plugin then 89 | export.OnError = Utils.OnError 90 | _Plugin = {} 91 | _Plugin.ShareDir = far.PluginStartupInfo().ShareDir 92 | _Plugin.History = Sett.mload(SETTINGS_KEY, SETTINGS_NAME) or {} 93 | end 94 | InitUpvalues(_Plugin) 95 | end 96 | 97 | main() 98 | -------------------------------------------------------------------------------- /Plugins/lftmp/src/tmpp_lang.templ: -------------------------------------------------------------------------------- 1 |  2 | [Languages] 3 | .Language=English,English 4 | .Language=Russian,Russian (Русский) 5 | 6 | [Settings] 7 | msgfile = tmpp_message.lua 8 | lngfile = tmpp 9 | 10 | [Messages] 11 | 12 | MOk 13 | "Ok" 14 | "Продолжить" 15 | 16 | MCancel 17 | "Cancel" 18 | "Отменить" 19 | 20 | MError 21 | "Error" 22 | "Ошибка" 23 | 24 | MWarning 25 | "Warning" 26 | "Предупреждение" 27 | 28 | MTempPanel 29 | "LuaFAR Temp. Panel" 30 | "Временная панель (LuaFAR)" 31 | 32 | MTempPanelTitleNum 33 | " %sLuaFAR Temp. Panel [%d] " 34 | " %sВрем. панель (LuaFAR) [%d] " 35 | 36 | MDiskMenuString 37 | "temporary (LuaFAR)" 38 | "временная (LuaFAR)" 39 | 40 | MF7 41 | "Remove" 42 | "Убрать" 43 | 44 | MAltShiftF12 45 | "Switch" 46 | "Выбор" 47 | 48 | MAltShiftF2 49 | "SavLst" 50 | "СохСпи" 51 | 52 | MAltShiftF3 53 | "Goto" 54 | "Перехо" 55 | 56 | MTempUpdate 57 | "Updating temporary panel contents" 58 | "Обновление содержимого временной панели" 59 | 60 | MTempSendFiles 61 | "Sending files to temporary panel" 62 | "Передача файлов во временную панель" 63 | 64 | MSwitchMenuTxt 65 | "Total files:" 66 | "Всего файлов:" 67 | 68 | MSwitchMenuTitle 69 | "Available temporary panels" 70 | "Доступные временные панели" 71 | 72 | MConfigTitle 73 | "LuaFAR Temporary Panel" 74 | "Временная панель (LuaFAR)" 75 | 76 | MConfigAddToDisksMenu 77 | "Add to &Disks menu" 78 | "Добавить к меню &дисков" 79 | 80 | MConfigAddToPluginsMenu 81 | "Add to &Plugins menu" 82 | "Добавить к меню &плагинов" 83 | 84 | MConfigCommonPanel 85 | "Use &common panel" 86 | "Использовать &общую панель" 87 | 88 | MSafeModePanel 89 | "&Safe panel mode" 90 | "&Безопасный режим панели" 91 | 92 | MReplaceInFilelist 93 | "&Replace files with file list" 94 | "\"&Замена\" для файла-списка" 95 | 96 | MMenuForFilelist 97 | "&Menu from file list" 98 | "&Меню из файла-списка" 99 | 100 | MCopyContents 101 | "Copy folder c&ontents" 102 | "Коп&ировать содержимое папок" 103 | 104 | MFullScreenPanel 105 | "F&ull screen mode" 106 | "Полно&экранный режим" 107 | 108 | MColumnTypes 109 | "Column &types" 110 | "&Типы колонок" 111 | 112 | MColumnWidths 113 | "Column &widths" 114 | "&Ширина колонок" 115 | 116 | MStatusColumnTypes 117 | "Status line column t&ypes" 118 | "Типы колонок строки ст&атуса" 119 | 120 | MStatusColumnWidths 121 | "Status l&ine column widths" 122 | "Ширина колонок строки стат&уса" 123 | 124 | MMask 125 | "File masks for the file &lists:" 126 | "Маски для &файла-списка:" 127 | 128 | MPrefix 129 | "Command line pre&fix:" 130 | "П&рефикс плагина:" 131 | 132 | MConfigNewOption 133 | "New settings will become active after FAR restart" 134 | "Новые параметры вступят в действие после перезапуска FAR" 135 | 136 | MNewPanelForSearchResults 137 | "&New panel for search results" 138 | "&Новая панель для рез-тов поиска" 139 | 140 | MListFilePath 141 | "Save file list as" 142 | "Сохранить список как" 143 | 144 | MCopyContentsMsg 145 | "Copy folder contents?" 146 | "Копировать содержимое папки?" 147 | 148 | MSavePanelsOnFarExit 149 | "Sa&ve panels on FAR exit" 150 | "&Сохр. панели при выходе из FAR" 151 | 152 | // End file // 153 | -------------------------------------------------------------------------------- /Plugins/luapanel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(luapanel) 2 | 3 | set(SOURCES 4 | src/GlobalInfo.c 5 | ${FARSOURCE}/luafar/src/luaplug.c 6 | ) 7 | 8 | add_library (${PROJECT_NAME} MODULE ${SOURCES}) 9 | set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) 10 | 11 | set(EXPNAMES 12 | GETFINDDATA GETOPENPLUGININFO OPENPLUGIN PROCESSEVENT PROCESSKEY 13 | ) 14 | 15 | set(EXPORTS "") 16 | foreach(f ${EXPNAMES}) 17 | list(APPEND EXPORTS "-DEXPORT_${f}") 18 | endforeach() 19 | 20 | target_compile_definitions(${PROJECT_NAME} 21 | PRIVATE ${EXPORTS} 22 | ) 23 | 24 | target_include_directories(${PROJECT_NAME} PRIVATE 25 | ${FARSOURCE}/far/far2sdk) 26 | 27 | if(${CMAKE_SYSTEM_NAME} MATCHES "Android") 28 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/luafar.so) 29 | endif() 30 | 31 | set(INSTALL_DIR "${INSTALL_DIR}/${PROJECT_NAME}") 32 | 33 | set_target_properties(${PROJECT_NAME} 34 | PROPERTIES 35 | LIBRARY_OUTPUT_DIRECTORY "${INSTALL_DIR}/plug" 36 | PREFIX "" 37 | SUFFIX ".far-plug-wide") 38 | 39 | set(MY_LIST 40 | luapanel.lua 41 | luapanel_eng.hlf 42 | ) 43 | 44 | foreach(elem ${MY_LIST}) 45 | configure_file("src/${elem}" "${INSTALL_DIR}/plug/${elem}" COPYONLY) 46 | endforeach() 47 | -------------------------------------------------------------------------------- /Plugins/luapanel/src/GlobalInfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SHAREDSYMBOL void WINAPI GetGlobalInfoW(struct GlobalInfo *aInfo) 4 | { 5 | struct VersionInfo Version = { 0,2,0,0 }; 6 | aInfo->StructSize = sizeof(*aInfo); 7 | aInfo->SysID = 0x50F187DF; 8 | aInfo->Version = Version; 9 | aInfo->Title = L"Lua Panel"; 10 | aInfo->Description = L"Panel-mode Lua-state browser"; 11 | aInfo->Author = L"Shmuel Zeigerman"; 12 | } 13 | //--------------------------------------------------------------------------- 14 | 15 | SHAREDSYMBOL int WINAPI GetMinFarVersionW(void) 16 | { 17 | return MAKEFARVERSION(2,4); 18 | } 19 | //--------------------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /Plugins/luapanel/src/luapanel_eng.hlf: -------------------------------------------------------------------------------- 1 | .Language=English,English 2 | .PluginContents=Luapanel 3 | .Options CtrlColorChar=\ 4 | 5 | @Contents 6 | $ #Luapanel - Help Contents# 7 | #Description:# 8 | Luapanel is a plugin for representation of Lua values in a Far file panel. 9 | It can be called from either plugins menu, command line or via a shortcut. 10 | 11 | #Command line:# 12 | #luapanel: []# 13 | Display contents of table (default: #_G#) 14 | 15 | #Keyboard control:# 16 | #F1# Show help 17 | #Enter# Enter a table pointed to by panel cursor 18 | -------------------------------------------------------------------------------- /Plugins/macro2lua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(macro2lua) 2 | 3 | set(SOURCES 4 | src/GlobalInfo.c 5 | ${FARSOURCE}/luafar/src/luaplug.c 6 | ) 7 | 8 | add_library (${PROJECT_NAME} MODULE ${SOURCES}) 9 | set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) 10 | 11 | set(EXPNAMES 12 | OPENPLUGIN 13 | ) 14 | 15 | set(EXPORTS "") 16 | foreach(f ${EXPNAMES}) 17 | list(APPEND EXPORTS "-DEXPORT_${f}") 18 | endforeach() 19 | 20 | target_compile_definitions(${PROJECT_NAME} 21 | PRIVATE ${EXPORTS} 22 | ) 23 | 24 | target_include_directories(${PROJECT_NAME} PRIVATE 25 | ${FARSOURCE}/far/far2sdk) 26 | 27 | if(${CMAKE_SYSTEM_NAME} MATCHES "Android") 28 | target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/luafar.so) 29 | endif() 30 | 31 | set(INSTALL_DIR "${INSTALL_DIR}/${PROJECT_NAME}") 32 | 33 | set_target_properties(${PROJECT_NAME} 34 | PROPERTIES 35 | LIBRARY_OUTPUT_DIRECTORY "${INSTALL_DIR}/plug" 36 | PREFIX "" 37 | SUFFIX ".far-plug-wide") 38 | 39 | set(MY_LIST 40 | macro2lua.lua 41 | macrosyn.lua 42 | readme.txt 43 | changelog 44 | ) 45 | 46 | foreach(elem ${MY_LIST}) 47 | configure_file("src/${elem}" "${INSTALL_DIR}/plug/${elem}" COPYONLY) 48 | endforeach() 49 | -------------------------------------------------------------------------------- /Plugins/macro2lua/src/GlobalInfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SHAREDSYMBOL void WINAPI GetGlobalInfoW(struct GlobalInfo *aInfo) 4 | { 5 | struct VersionInfo Version = { 0,11,0,0 }; 6 | aInfo->StructSize = sizeof(*aInfo); 7 | aInfo->SysID = 0x50B1ABE5; 8 | aInfo->Version = Version; 9 | aInfo->Title = L"Macro2Lua converter"; 10 | aInfo->Description = L"Converter from macro language to Lua"; 11 | aInfo->Author = L"Shmuel Zeigerman"; 12 | } 13 | //--------------------------------------------------------------------------- 14 | 15 | SHAREDSYMBOL int WINAPI GetMinFarVersionW(void) 16 | { 17 | return MAKEFARVERSION(2,4); 18 | } 19 | //--------------------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /Plugins/macro2lua/src/changelog: -------------------------------------------------------------------------------- 1 | 2024-12-22 2 | - Added support for any UTF-8 non-space character as a key 3 | - Version 0.11 4 | 5 | 2024-12-21 6 | - Prevent a runtime Lua error when no Sequence is found ("ini_file" syntax) 7 | 8 | 2024-12-21 9 | - Fix conversion of some keys such as: \, Ctrl\ and " 10 | - Preserve comments preceding a macro in "ini_file" syntax 11 | - Version 0.10 12 | 13 | 2024-12-20 14 | - Added support for Russian letters as keys 15 | - Added support for $Text operator 16 | - Key validation function: far.NameToKey is used (was: far.NameToInputRecord) 17 | - Version bumped to 0.9 18 | 19 | 2024-12-19 20 | - Added processing of far2l's key_macros.ini files (syntax: "ini_file") 21 | - The syntax "ini_file" became the default in command line 22 | 23 | 2024-12-18 24 | - Far3 plugin adapted to far2m 25 | - Build system changed from make to cmake 26 | - UTF-8 BOM is never added to output files 27 | - Removed exported functions ConvertChunk and FreeChunk; removed file macro2lua.c 28 | -------------------------------------------------------------------------------- /Plugins/macro2lua/src/m2l_test.lua: -------------------------------------------------------------------------------- 1 | -- Можно сэкономить время, чтобы образцы вывода для сравнения сгенерировал 2 | -- скрипт, то-есть, писать нужно было бы только первый аргумент вызова. 3 | 4 | local function exp (input, ref) 5 | local result = Convert("expression", input) 6 | if result ~= ref then error('['..tostring(result)..']') end 7 | end 8 | 9 | exp ('1', '1') 10 | exp ('1+2-3*4/5', '1+2-3*4/5') 11 | exp ('1 || 2 && 3', '1 or 2 and 3') 12 | exp ('1 | 2 & 3 ^ 4', 'bor(1,bxor(band(2,3),4))') 13 | exp ('', nil) 14 | exp ('a(1,2,3)', 'a(1,2,3)') 15 | exp ('Key(1)', 'mf.key(1)') 16 | exp ('Eval("Shell/CtrlC",2)', 'eval("Shell/CtrlC",2)') 17 | exp ('1 || 2 ^^ 3 && 4 | 5 ^ 6 & 7 == 8 != 9 << 10 >> 11 + 12 - 13 * 14 / 15', '1 or 2 ^^ 3 and bor(4,bxor(5,band(6,7 == 8 ~= rshift(lshift(9,10),11 + 12 - 13 * 14 / 15))))') 18 | exp ('1 / 2 * 3 - 4 + 5 >> 6 << 7 != 8 == 9 & 10 ^ 11 | 12 && 13 ^^ 14 || 15', 'bor(bxor(band(lshift(rshift(1 / 2 * 3 - 4 + 5,6),7) ~= 8 == 9,10),11),12) and 13 ^^ 14 or 15') 19 | exp ([["a\\b\n\"c"]], [["a\\b\n\"c"]]) 20 | exp ([[@"a\b\n""c"]], [["a\\b\\n\"c"]]) 21 | 22 | far.Message("All tests OK", "Macro2Lua test") 23 | -------------------------------------------------------------------------------- /Plugins/macro2lua/src/readme.txt: -------------------------------------------------------------------------------- 1 | Конвертер Macro2Lua 2 | =================== 3 | 4 | Общая информация 5 | ---------------- 6 | 7 | Конвертер преобразует макросы с макроязыка в язык Lua 5.1. 8 | 9 | Конвертер выполнен как плагин для Far3/far2m, т.к. используется фаровская 10 | функция для верификации имён клавиш. Плагин использует библиотеку LuaFAR, 11 | которая поставляется вместе с Far3/far2m. 12 | 13 | Плагин обрабатывает INI-файлы far2l (key_macros.ini), XML-файлы формата 14 | экспорта Far3 и FML-файлы плагина MacroLib. При успешном преобразовании, 15 | плагин создаёт выходной файл. 16 | 17 | Плагин запускается с командной строки двумя способами: 18 | 19 | (1) M2L: convert [] 20 | 21 | указывает синтаксис входного файла, может быть одним из: 22 | ini_file -- far2l INI файл (значение по умолчанию) 23 | 24 | chunk -- "голый" макрос 25 | expression -- выражение 26 | 27 | xml_file -- XML файл 28 | xml_macros -- секция в XML файле 29 | xml_keymacros -- секция в XML файле 30 | xml_macro -- секция в XML файле 31 | 32 | fml_file -- FML файл 33 | fml_macro -- секция Macro в FML файле 34 | 35 | При необходимости пакетной обработки можно воспользоваться командой 36 | *Apply Command* (CtrlG). 37 | 38 | (2) M2L: run