├── FarNet ├── FarNetMan │ ├── stdafx.cpp │ ├── FCTL_GETPANELINFO.h │ ├── AssemblyResolver.h │ ├── History.h │ ├── AssemblyInfo.cpp │ ├── Export.def │ ├── ListItemCollection.h │ ├── Viewer0.h │ ├── Window.h │ ├── EditorBookmark.h │ └── AssemblyResolver.cpp ├── Docs │ ├── .gitignore │ ├── About.content │ └── Resource.items ├── FarNet │ ├── Enums │ │ ├── FormatMessageMode.cs │ │ ├── BufferCellType.cs │ │ ├── EditorChangeKind.cs │ │ ├── HistoryKind.cs │ │ ├── SpecialFolder.cs │ │ ├── ViewerViewMode.cs │ │ ├── PanelDotsMode.cs │ │ ├── PanelKind.cs │ │ ├── ExpandTabsMode.cs │ │ ├── PanelHighlighting.cs │ │ ├── OpenMode.cs │ │ ├── ViewFrameOptions.cs │ │ └── PlaceKind.cs │ ├── Works │ │ ├── Regexes.cs │ │ ├── Tasks2.cs │ │ ├── Abc.cs │ │ ├── Dialog │ │ │ └── DialogTools.cs │ │ └── Config │ │ │ └── Assembly.cs │ ├── Module │ │ ├── ModuleEditorEventArgs.cs │ │ ├── ModuleAction.cs │ │ ├── ModuleItemKind.cs │ │ ├── ModuleToolAttribute.cs │ │ ├── ModuleEditorAttribute.cs │ │ ├── ModuleCommandAttribute.cs │ │ ├── ModuleDrawerAttribute.cs │ │ └── ModuleHostAttribute.cs │ ├── About │ │ ├── QuittingEventArgs.cs │ │ ├── KeyEventArgs.cs │ │ ├── IFace.cs │ │ └── Disposable.cs │ ├── Tools │ │ ├── ValueGetter.cs │ │ ├── Res.cs │ │ └── Xml │ │ │ └── Xslt.cs │ ├── Forms │ │ ├── DrawnEventArgs.cs │ │ ├── DropDownClosedEventArgs.cs │ │ ├── DropDownOpeningEventArgs.cs │ │ ├── IComboBox.cs │ │ ├── DrawingEventArgs.cs │ │ ├── InitializedEventArgs.cs │ │ ├── AnyEventArgs.cs │ │ ├── LosingFocusEventArgs.cs │ │ ├── SizeEventArgs.cs │ │ ├── ClosingEventArgs.cs │ │ ├── IDropDown.cs │ │ ├── TextChangedEventArgs.cs │ │ └── KeyPressedEventArgs.cs │ ├── Explorer │ │ ├── CreateFileEventArgs.cs │ │ ├── OpenFileEventArgs.cs │ │ ├── ExploreRootEventArgs.cs │ │ ├── ExploreParentEventArgs.cs │ │ ├── CloneFileEventArgs.cs │ │ ├── RenameFileEventArgs.cs │ │ ├── ExploreEventArgs.cs │ │ ├── ExploreLocationEventArgs.cs │ │ ├── ExplorerFileEventArgs.cs │ │ ├── ExploreDirectoryEventArgs.cs │ │ ├── ExplorerEnteredEventArgs.cs │ │ ├── SetTextEventArgs.cs │ │ └── SetFileEventArgs.cs │ ├── AssemblyInfo.cs │ ├── Panel │ │ ├── PanelEventArgs.cs │ │ ├── ViewChangedEventArgs.cs │ │ ├── CommandLineEventArgs.cs │ │ └── SetColumn.cs │ ├── FarNetApi.build.ps1 │ ├── Settings │ │ └── ModuleSettingsArgs.cs │ ├── Editor │ │ └── MouseEventArgs.cs │ ├── File │ │ └── FileFileComparer.cs │ ├── Viewer │ │ └── IAnyViewer.cs │ └── History │ │ └── GetHistoryArgs.cs └── FarNetTest │ └── AbcTest.cs ├── FSharpFar ├── samples │ ├── fsx-sample │ │ ├── .fs.ini │ │ ├── Module1.fs │ │ ├── App1.fsx │ │ └── App2.fsx │ ├── PanelEditFile │ │ ├── App1.fsx │ │ └── PanelEditFile.fs.ini │ ├── fsi-object │ │ └── Fsi.fs.ini │ ├── Async │ │ ├── .fs.ini │ │ └── MyPanel.fs │ ├── Testing │ │ ├── .fs.ini │ │ └── App1.fsx │ ├── TryPanelFSharp │ │ ├── TryPanelFSharp.fs.ini │ │ └── Module.fs │ ├── Lib │ │ └── SessionVariablesPanel.fsx │ └── PowerShellFar │ │ └── PanelObjects.fsx ├── src │ ├── fsx │ │ ├── Tests │ │ │ ├── test_01 │ │ │ │ ├── .fs.ini │ │ │ │ ├── Test.fsx │ │ │ │ └── Abc.fs │ │ │ └── test_02 │ │ │ │ ├── FakeFarInput.fs │ │ │ │ └── .fs.ini │ │ └── .build.ps1 │ ├── FarNet.Common │ │ ├── Abc.fs │ │ └── AbcService.fs │ ├── FarNet.FSharp │ │ └── Works.fs │ ├── FSharpFar │ │ ├── FarHost.fs │ │ └── ProxyWriter.fs │ └── .vscode │ │ ├── tasks.json │ │ └── launch.json ├── tests │ ├── PSF.test │ │ ├── Vanilla │ │ │ ├── Vanilla.fs.ini │ │ │ ├── Vanilla.fs │ │ │ └── Vanilla.fsx │ │ ├── SessionError │ │ │ ├── SessionError.fs.ini │ │ │ ├── App.fsx │ │ │ └── Lib.fs │ │ ├── UseFileOddity │ │ │ ├── Use.fsx │ │ │ ├── UseFileOddity.fs.ini │ │ │ └── App.fsx │ │ ├── LibInIni │ │ │ ├── LibInIni.fs.ini │ │ │ └── LibInIni.fsx │ │ ├── PowerShell │ │ │ ├── App.fsx │ │ │ └── PowerShell.fs.ini │ │ ├── Test-170827.LibInIni.fas.ps1 │ │ ├── Test-200603.fsx1.fas.ps1 │ │ ├── Test-160904.Editor.Complete.fas.ps1 │ │ ├── basic.test.ps1 │ │ ├── Test-160902.Close.fas.ps1 │ │ ├── Test-160828.Command.fas.ps1 │ │ ├── Test-160902.r.FarNet.fas.ps1 │ │ ├── Test-200603.fsx2.fas.ps1 │ │ ├── Test-170828.PowerShell.fas.ps1 │ │ ├── Test-181218.PanelVariables1.fas.ps1 │ │ ├── Test-160904.Editor.Load.fas.ps1 │ │ └── Test-181218.PanelVariables2.fas.ps1 │ ├── App1.fsx │ ├── README.md │ ├── .fs.ini │ ├── TestParallel.fs │ └── AutoTest.fs ├── .gitignore └── FSharpFar.slnx ├── Zoo ├── Test-Install-FarPackage │ ├── Data │ │ ├── FarHome │ │ │ ├── FarNet │ │ │ │ └── DLL.txt │ │ │ ├── app.exe.config │ │ │ └── Трудное + имя │ │ │ │ └── Трудное + имя.txt │ │ ├── FarHome.x64 │ │ │ └── Plugins │ │ │ │ └── FarNetMan │ │ │ │ └── DLL64.txt │ │ └── FarHome.x86 │ │ │ └── Plugins │ │ │ └── FarNetMan │ │ │ └── DLL86.txt │ └── .build.ps1 ├── FarNetLogo.png ├── FSharpFar │ └── samples │ │ └── Charting │ │ ├── FoxesRubbitsModal.fsx │ │ ├── FoxesRubbitsAsync.fsx │ │ ├── LineChartAsync.fsx │ │ └── LineChart.fs ├── Test-NuGet-FarNet.txt └── FarNet.Works.Editor │ └── EditorTools.cs ├── JavaScriptFar ├── Samples │ ├── interop │ │ ├── input.js │ │ ├── message.js │ │ ├── app1.far.ps1 │ │ └── app2.far.ps1 │ ├── modules │ │ ├── use-mix │ │ │ ├── _session.1.js │ │ │ ├── _session.2.cjs │ │ │ ├── _session.2.mjs │ │ │ ├── try.js │ │ │ └── README.md │ │ ├── CommonJS │ │ │ ├── try.js │ │ │ ├── const.js │ │ │ ├── tools.js │ │ │ └── _session.xml │ │ ├── Standard │ │ │ ├── try.js │ │ │ ├── const.js │ │ │ ├── tools.js │ │ │ └── _session.xml │ │ ├── try.cjs │ │ ├── try.mjs │ │ └── README.md │ ├── extras │ │ ├── error-throw-string.js │ │ ├── error-throw-error.js │ │ ├── error-reference.js │ │ └── test-MyLibForJS.ps1 │ ├── message-box.js │ ├── events │ │ ├── disconnect.js │ │ ├── _session.js │ │ └── connect.js │ ├── input-output.js │ ├── config │ │ ├── WebLoadingAndSearchPath.js │ │ ├── StringifyEnhancements.js │ │ ├── _session.xml │ │ └── TaskPromiseConversion.js │ ├── README.md │ └── message-choice.js ├── Tests │ ├── message-box.fas.ps1 │ ├── input-output.fas.ps1 │ ├── session-parameter.fas.ps1 │ ├── interop-psf.fas.ps1 │ ├── message-choice.fas.ps1 │ ├── test-MyLibForJS.fas.ps1 │ └── flow.fas.ps1 ├── Res.cs └── ExecuteArgs.cs ├── Drawer ├── Zoo │ ├── Tabs-1.tsv │ └── CurrentWord-1.html └── Drawer.csproj ├── GitKit ├── Properties │ └── GitKit.fs.ini ├── Tests │ ├── FSF │ │ ├── .fs.ini │ │ ├── Credentials.fsx │ │ ├── PanelCommit.fsx │ │ └── PanelBranch.fsx │ ├── edit.fas.ps1 │ ├── commits.fas.ps1 │ └── init.fas.ps1 ├── Panels │ ├── BaseExplorer.cs │ └── BasePanel.cs ├── Commands │ ├── BranchesCommand.cs │ └── InitCommand.cs ├── GitKit.macro.lua ├── Const.cs └── Settings.cs ├── .gitattributes ├── Modules ├── XGraphQL │ ├── .Format.GraphQL.fn.dbcs │ ├── .Add.UndefinedTypes.fn.dbcs │ ├── 1.build.ps1 │ └── README.md ├── ScriptPS │ ├── Script.fn.dbcs │ └── README.md ├── ScriptFS │ └── Demo.fs ├── Backslash │ ├── README.md │ ├── 1.build.ps1 │ └── Backslash.csproj ├── IronPythonFar │ ├── Samples │ │ ├── far_input.py │ │ ├── print.py │ │ ├── far_message.py │ │ └── http_client.py │ └── 1.build.ps1 ├── FarNet.Demo │ ├── FarNet.Demo.ru.restext │ ├── Script.cs │ ├── FarNet.Demo.restext │ └── Scripts │ │ ├── Settings.far.ps1 │ │ └── Workings.far.ps1 ├── Script │ ├── Script.lua │ └── Script.csproj └── TryPanelCSharp │ ├── 1.build.ps1 │ └── TryPanelCSharp.csproj ├── Test ├── Settings │ ├── Test-1-Scripts.fas.ps1 │ └── Test-MySettings.far.ps1 ├── Editor │ └── Test-Bench-Script.fas.ps1 ├── XPath │ ├── x-profile-1.xq │ ├── empty-directory.xq │ ├── sln-with-csproj.xq │ ├── sln-with-no-csproj.xq │ ├── upper-case.xq │ ├── x-profile-2-.ps1 │ ├── x-profile-1-.ps1 │ └── x-profile-2.xq ├── Panels │ ├── Test-z_161015.#7.fas.ps1 │ ├── Test-z_230805_1220_Closure.far.ps1 │ ├── Test-Panel-Unsubscribed.fas.ps1 │ ├── Test-z_181105_OpenPanelFromEditor.fas.ps1 │ ├── Test-FormatPanel.fas.ps1 │ ├── Test-z_230805_1220_Closure.fas.ps1 │ ├── Test-GroupInfo.fas.ps1 │ ├── Test-Panel-AutoColumn-01.fas.ps1 │ ├── Test-z_191223_BadCurrentFile.fas.ps1 │ └── Test-Panel_090321_210416.fas.ps1 ├── Panels.Item │ └── Test-ItemPanel-Certificate.fas.ps1 ├── Dialog │ ├── zoo-Mantis-2241.fas.ps1 │ ├── Test-UndoRedo.fas.ps1 │ ├── 2024-02-04-IEdit-set-IsPath.fas.ps1 │ ├── 2022-02-21-Initialized.fas.ps1 │ ├── Test-ProgressForm-99percent.fas.ps1 │ ├── Test-ComboBox.fas.ps1 │ ├── Test-Message.ShortWithButtons.fas.ps1 │ ├── zoo-Mantis-2511.fas.ps1 │ └── 2020-11-18-1658-leak-crash.fas.ps1 ├── Basics.Posts │ ├── PostJob-seq.fas.ps1 │ ├── PostStep-rec.fas.ps1 │ └── PostJob-rec.fas.ps1 ├── Host │ ├── zoo.ps1 │ ├── Test-CC-OpenPanel.fas.ps1 │ ├── Test-Read-Host-UnusualPrompt.fas.ps1 │ ├── Test-Read-Host-1.fas.ps1 │ ├── Test-CC-KeyF4.fas.ps1 │ ├── Test-Prompt-Parameter.fas.ps1 │ ├── Test-Read-Host-0.fas.ps1 │ ├── Test-Read-Host-1_CC.fas.ps1 │ └── Test-CC-KeyPanel.fas.ps1 ├── Basics │ ├── Test-System.Drawing.far.ps1 │ ├── Test-Editor-Crash.far.ps1 │ └── Test-AnyPanel.far.ps1 ├── Utility │ ├── Test-Input.fas.ps1 │ ├── Test-Go-HeadFile.fas.ps1 │ └── Update-FarManager.test.ps1 ├── Panels.Object │ └── Test_211231_2g_PSCustomObject.fas.ps1 ├── TabExpansion │ ├── Bad.ArgumentCompleters.ps1 │ └── Test-TabExpansionUI-Command.fas.ps1 ├── Basics.Tasks │ ├── Var.fas.ps1 │ └── Parameters.fas.ps1 ├── Panels.Script │ └── Test-FarInventory.fas.ps1 ├── Script │ ├── Test-Escape.fas.ps1 │ ├── Test-InvokeCommand.fas.ps1 │ └── Snippet.fas.ps1 ├── Debugger │ └── abc.ps1 └── Panels.Cmd │ ├── Test-InvokeSelected.fas.ps1 │ └── Test-ExpandCodeWithPrefix.fas.ps1 ├── .github └── FUNDING.yml ├── PowerShellFar ├── History4.txt ├── About │ ├── Profile-Local.ps1 │ └── Profile-Console.ps1 ├── Properties │ └── launchSettings.json ├── Works │ ├── Enums.cs │ └── RunArgs.cs ├── OutputWriters │ ├── EditorOutputWriterNormal.cs │ ├── EditorOutputWriterAsync.cs │ └── StreamOutputWriter.cs ├── Panels │ ├── ListExplorer.cs │ └── TableExplorer.cs ├── Bench │ ├── Go-HeadFile.ps1 │ ├── Show-EditorColor.ps1 │ └── Get-FarVersion.ps1 ├── Commands │ ├── OpenFarViewerCommand.cs │ ├── InvokeTaskMacro.cs │ └── InvokeTaskKeys.cs ├── UI │ ├── CommandHistoryMenu.cs │ └── InputBox2.cs ├── Modules │ └── pwsf │ │ ├── 1.build.ps1 │ │ └── pwsf.csproj ├── About.md ├── My │ └── MyRegex.cs └── Host │ └── VariablePath.cs ├── Get-Version.ps1 ├── JsonKit ├── Tests │ ├── x-values.json │ ├── x-array.json │ ├── 1-open-values.fas.ps1 │ ├── x-object.json │ └── 1-open-array.fas.ps1 ├── Commands │ └── AbcCommand.cs ├── Host.cs └── Panels │ └── ObjectPanel.cs ├── Samples ├── Tests │ ├── Test-Editor.far.ps1 │ ├── Test-RegisterTool.far.ps1 │ ├── Test-TrimEnd.ps1 │ ├── Test-RegisterCommand.far.ps1 │ └── Test-Panel-DBCategories.far.ps1 ├── FarTask │ ├── Case │ │ ├── FarTaskError1.far.ps1 │ │ ├── FarTaskError2.far.ps1 │ │ ├── FarTaskError3.far.ps1 │ │ ├── FarTaskError4.far.ps1 │ │ ├── FarTaskError5.far.ps1 │ │ └── dump-variables.far.ps1 │ ├── MainAndAsyncCommon │ │ ├── Test-CommonCode.far.ps1 │ │ └── CommonCode.far.ps1 │ ├── NestedTasks.fas.ps1 │ ├── Parameters=3.fas.ps1 │ ├── Parameters=1.far.ps1 │ ├── KeysAndMacro.fas.ps1 │ └── Parameters=2.far.ps1 ├── README.md ├── FarRedisTask │ └── PingPong.far.ps1 └── Quit │ └── README.md ├── HelpDown └── HtmlToFarHelp │ ├── HtmlToFarHelp.png │ ├── Test │ ├── 2024-12-31-0758-missing-space.html │ └── cases.test.ps1 │ ├── HtmlToFarHelp.csproj │ ├── More │ └── README.md │ └── Types.cs ├── RightWords ├── Data │ └── Test-2.lng ├── HelpTopic.cs ├── TheHost.cs ├── RightWords.restext ├── RightWords.ru.restext └── DictionaryInfo.cs ├── RedisKit ├── Tests │ ├── keys.fas.ps1 │ ├── about.fas.ps1 │ ├── edit=list.fas.ps1 │ ├── edit=set.fas.ps1 │ └── edit=hash.fas.ps1 ├── Panels │ ├── BasePanel.cs │ ├── BaseExplorer.cs │ └── Files.cs ├── Host.cs └── Commands │ ├── AbcCommand.cs │ ├── KeysCommand.cs │ ├── SetCommand.cs │ ├── ListCommand.cs │ ├── HashCommand.cs │ └── TreeCommand.cs ├── .gitignore ├── .editorconfig ├── FarNet.slnx ├── CopyColor └── CopyColor.csproj ├── EditorKit └── Settings.cs ├── Explore └── Explore.csproj ├── Vessel ├── Vessel.csproj └── Settings.cs ├── RightControl └── RightControl.csproj └── web.ps1 /FarNet/FarNetMan/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /FSharpFar/samples/fsx-sample/.fs.ini: -------------------------------------------------------------------------------- 1 | [fsc] 2 | Module1.fs 3 | -------------------------------------------------------------------------------- /FSharpFar/src/fsx/Tests/test_01/.fs.ini: -------------------------------------------------------------------------------- 1 | [fsc] 2 | Abc.fs 3 | -------------------------------------------------------------------------------- /Zoo/Test-Install-FarPackage/Data/FarHome/FarNet/DLL.txt: -------------------------------------------------------------------------------- 1 | DLL.txt -------------------------------------------------------------------------------- /FSharpFar/samples/PanelEditFile/App1.fsx: -------------------------------------------------------------------------------- 1 | PanelEditFile.run () 2 | -------------------------------------------------------------------------------- /FSharpFar/samples/fsi-object/Fsi.fs.ini: -------------------------------------------------------------------------------- 1 | [fsi] 2 | --use:fsi.fsx 3 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Vanilla/Vanilla.fs.ini: -------------------------------------------------------------------------------- 1 | ; keep it empty 2 | -------------------------------------------------------------------------------- /FarNet/Docs/.gitignore: -------------------------------------------------------------------------------- 1 | *.shfbproj_* 2 | *.sln 3 | Help 4 | obj 5 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/interop/input.js: -------------------------------------------------------------------------------- 1 | 2 | far.Input('user') 3 | -------------------------------------------------------------------------------- /Zoo/Test-Install-FarPackage/Data/FarHome/app.exe.config: -------------------------------------------------------------------------------- 1 | app.exe.config -------------------------------------------------------------------------------- /FSharpFar/samples/PanelEditFile/PanelEditFile.fs.ini: -------------------------------------------------------------------------------- 1 | [fsc] 2 | PanelEditFile.fs 3 | -------------------------------------------------------------------------------- /Zoo/Test-Install-FarPackage/Data/FarHome.x64/Plugins/FarNetMan/DLL64.txt: -------------------------------------------------------------------------------- 1 | DLL64.txt -------------------------------------------------------------------------------- /Zoo/Test-Install-FarPackage/Data/FarHome.x86/Plugins/FarNetMan/DLL86.txt: -------------------------------------------------------------------------------- 1 | DLL86.txt -------------------------------------------------------------------------------- /Drawer/Zoo/Tabs-1.tsv: -------------------------------------------------------------------------------- 1 | 2 | 0 3 | 1 4 | 2 5 | space and tab 6 | 7 | 8 | -------------------------------------------------------------------------------- /FSharpFar/samples/Async/.fs.ini: -------------------------------------------------------------------------------- 1 | [fsc] 2 | MyPanel.fs 3 | Parallel.fs 4 | Wizard.fs 5 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/SessionError/SessionError.fs.ini: -------------------------------------------------------------------------------- 1 | 2 | [fsc] 3 | Lib.fs 4 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/UseFileOddity/Use.fsx: -------------------------------------------------------------------------------- 1 | 2 | let see obj = printfn "%A" obj 3 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/interop/message.js: -------------------------------------------------------------------------------- 1 | 2 | far.Message(`Hello, ${args.user}`) 3 | -------------------------------------------------------------------------------- /GitKit/Properties/GitKit.fs.ini: -------------------------------------------------------------------------------- 1 | 2 | [fsc] 3 | -r:.\GitKit.dll 4 | -r:.\LibGit2Sharp.dll 5 | -------------------------------------------------------------------------------- /Zoo/FarNetLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nightroman/FarNet/HEAD/Zoo/FarNetLogo.png -------------------------------------------------------------------------------- /Zoo/Test-Install-FarPackage/Data/FarHome/Трудное + имя/Трудное + имя.txt: -------------------------------------------------------------------------------- 1 | Трудное + имя.txt -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.cmd text eol=crlf 3 | *.hrc text eol=lf 4 | *.sh text eol=lf 5 | -------------------------------------------------------------------------------- /FSharpFar/src/fsx/Tests/test_01/Test.fsx: -------------------------------------------------------------------------------- 1 | test () 2 | printfn "fsx: %A" fsi.CommandLineArgs 3 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/UseFileOddity/UseFileOddity.fs.ini: -------------------------------------------------------------------------------- 1 | 2 | [fsi] 3 | --use:Use.fsx 4 | -------------------------------------------------------------------------------- /Modules/XGraphQL/.Format.GraphQL.fn.dbcs: -------------------------------------------------------------------------------- 1 | script=XGraphQL; method=.Format.GraphQL; unload=true 2 | -------------------------------------------------------------------------------- /Test/Settings/Test-1-Scripts.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { & "$PSScriptRoot\Test-MySettings.far.ps1" } 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [nightroman] 4 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/use-mix/_session.1.js: -------------------------------------------------------------------------------- 1 | let CommonJS = null 2 | let Standard = null 3 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/use-mix/_session.2.cjs: -------------------------------------------------------------------------------- 1 | CommonJS = require('../CommonJS/Const.js') 2 | -------------------------------------------------------------------------------- /Modules/XGraphQL/.Add.UndefinedTypes.fn.dbcs: -------------------------------------------------------------------------------- 1 | script=XGraphQL; method=.Add.UndefinedTypes; unload=true 2 | -------------------------------------------------------------------------------- /PowerShellFar/History4.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nightroman/FarNet/HEAD/PowerShellFar/History4.txt -------------------------------------------------------------------------------- /JavaScriptFar/Samples/extras/error-throw-string.js: -------------------------------------------------------------------------------- 1 | // Fails due to thrown error. 2 | 3 | throw 'Oops' 4 | -------------------------------------------------------------------------------- /FSharpFar/samples/fsx-sample/Module1.fs: -------------------------------------------------------------------------------- 1 | module Module1 2 | 3 | let hello name = 4 | printfn "Hello, %s!" name 5 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/LibInIni/LibInIni.fs.ini: -------------------------------------------------------------------------------- 1 | 2 | [fsc] 3 | --lib:%FarHome%\FarNet\Modules\PowerShellFar 4 | -------------------------------------------------------------------------------- /Get-Version.ps1: -------------------------------------------------------------------------------- 1 | $FarVersion = "3.0.6570" 2 | $FarNetVersion = "10.0.15" 3 | $PowerShellFarVersion = "10.0.19" 4 | -------------------------------------------------------------------------------- /GitKit/Tests/FSF/.fs.ini: -------------------------------------------------------------------------------- 1 | 2 | [use] 3 | %FARHOME%\FarNet\Modules\GitKit\GitKit.fs.ini 4 | 5 | [fsc] 6 | GitKit.fs 7 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/extras/error-throw-error.js: -------------------------------------------------------------------------------- 1 | // Fails due to thrown error. 2 | 3 | throw Error('Oops') 4 | -------------------------------------------------------------------------------- /FSharpFar/src/FarNet.Common/Abc.fs: -------------------------------------------------------------------------------- 1 | namespace FarNet.FSharp 2 | 3 | [] 4 | do () 5 | -------------------------------------------------------------------------------- /JsonKit/Tests/x-values.json: -------------------------------------------------------------------------------- 1 | // values 2 | null 3 | true 4 | false 5 | 42 6 | 3.14 7 | "текст" 8 | [] 9 | {} 10 | -------------------------------------------------------------------------------- /Samples/Tests/Test-Editor.far.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nightroman/FarNet/HEAD/Samples/Tests/Test-Editor.far.ps1 -------------------------------------------------------------------------------- /Test/Editor/Test-Bench-Script.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | & "$env:FarNetCode\Samples\Tests\Test-Editor.far.ps1" 4 | } 5 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/message-box.js: -------------------------------------------------------------------------------- 1 | // Simple message box. 2 | 3 | far.Message('Hello from JavaScript!', 'JavaScript') 4 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/use-mix/_session.2.mjs: -------------------------------------------------------------------------------- 1 | import * as Const from '../Standard/const.js' 2 | Standard = Const 3 | -------------------------------------------------------------------------------- /Modules/ScriptPS/Script.fn.dbcs: -------------------------------------------------------------------------------- 1 | script=ScriptPS; 2 | method=Message; 3 | unload=true 4 | ;; 5 | name=John Doe; 6 | age=42 7 | -------------------------------------------------------------------------------- /Samples/FarTask/Case/FarTaskError1.far.ps1: -------------------------------------------------------------------------------- 1 | # An error in task code. 2 | 3 | Start-FarTask { 4 | throw 'oops-async' 5 | } 6 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/SessionError/App.fsx: -------------------------------------------------------------------------------- 1 | 2 | // exec this file -> it fails due to problem in Lib.fs 3 | 4 | open Lib 5 | -------------------------------------------------------------------------------- /HelpDown/HtmlToFarHelp/HtmlToFarHelp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nightroman/FarNet/HEAD/HelpDown/HtmlToFarHelp/HtmlToFarHelp.png -------------------------------------------------------------------------------- /FSharpFar/src/fsx/Tests/test_01/Abc.fs: -------------------------------------------------------------------------------- 1 | [] 2 | module Abc 3 | 4 | let test () = 5 | printfn "fs: %A" fsi.CommandLineArgs 6 | -------------------------------------------------------------------------------- /Samples/FarTask/Case/FarTaskError2.far.ps1: -------------------------------------------------------------------------------- 1 | # An error in job code. 2 | 3 | Start-FarTask { 4 | job { 5 | throw 'oops-job' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Samples/FarTask/Case/FarTaskError3.far.ps1: -------------------------------------------------------------------------------- 1 | # An error in ps: code. 2 | 3 | Start-FarTask { 4 | ps: { 5 | throw 'oops-ps:' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Test/XPath/x-profile-1.xq: -------------------------------------------------------------------------------- 1 | 2 | //File 3 | [ 4 | @Name = 'Readme.txt' 5 | and 6 | compare(@LastWriteTime, '2009-01-01') > 0 7 | ] 8 | -------------------------------------------------------------------------------- /FSharpFar/samples/Testing/.fs.ini: -------------------------------------------------------------------------------- 1 | [use] 2 | %FARHOME%\FarNet\Lib\FarNet.FSharp.Unquote\FarNet.FSharp.Unquote.ini 3 | 4 | [fsc] 5 | Tests.fs 6 | -------------------------------------------------------------------------------- /RightWords/Data/Test-2.lng: -------------------------------------------------------------------------------- 1 | 2 | "M&an" 3 | "Ma&n" 4 | "Man&" 5 | "&Man" 6 | 7 | "M&anz" 8 | "Ma&nz" 9 | "Man&z" 10 | "Manz&" 11 | -------------------------------------------------------------------------------- /Test/XPath/empty-directory.xq: -------------------------------------------------------------------------------- 1 | 2 | //Directory 3 | [ 4 | not(Directory | File) 5 | and 6 | not((../.. | ../../..)/*[@Name = '.svn']) 7 | ] 8 | -------------------------------------------------------------------------------- /FSharpFar/.gitignore: -------------------------------------------------------------------------------- 1 | .vs/ 2 | bin/ 3 | obj/ 4 | z/ 5 | 6 | packages/ 7 | paket-files 8 | 9 | *.nupkg 10 | z.* 11 | 12 | Directory.Build.props 13 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/CommonJS/try.js: -------------------------------------------------------------------------------- 1 | // This script imports a module. 2 | 3 | const Tools = require('./tools.js') 4 | 5 | Tools.hello() 6 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/Standard/try.js: -------------------------------------------------------------------------------- 1 | // This script imports a module. 2 | 3 | import * as Tools from './tools.js' 4 | 5 | Tools.hello() 6 | -------------------------------------------------------------------------------- /Samples/FarTask/Case/FarTaskError4.far.ps1: -------------------------------------------------------------------------------- 1 | # Error in run block before UI. 2 | 3 | Start-FarTask { 4 | run { 5 | throw 'oops-run-before' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Test/XPath/sln-with-csproj.xq: -------------------------------------------------------------------------------- 1 | 2 | //File 3 | [ 4 | is-match(@Name, '(?i)\.sln$') 5 | and 6 | ../File[is-match(@Name, '(?i)\.csproj$')] 7 | ] 8 | -------------------------------------------------------------------------------- /Modules/ScriptFS/Demo.fs: -------------------------------------------------------------------------------- 1 | module ScriptFS 2 | open FarNet 3 | 4 | let message (name: string) (age: int) = 5 | far.Message($"name: {name}, age: {age}") 6 | -------------------------------------------------------------------------------- /Test/XPath/sln-with-no-csproj.xq: -------------------------------------------------------------------------------- 1 | 2 | //File 3 | [ 4 | is-match(@Name, '(?i)\.sln$') 5 | and 6 | not(../File[is-match(@Name, '(?i)\.csproj$')]) 7 | ] 8 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/SessionError/Lib.fs: -------------------------------------------------------------------------------- 1 | 2 | // this file has a deliberate call to a missing function 3 | 4 | module Lib 5 | 6 | let x = missing () 7 | -------------------------------------------------------------------------------- /FarNet/FarNetMan/FCTL_GETPANELINFO.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | bool TryPanelInfo(HANDLE handle, PanelInfo& info); 4 | void GetPanelInfo(HANDLE handle, PanelInfo& info); 5 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/extras/error-reference.js: -------------------------------------------------------------------------------- 1 | // Fails due to not defined `answer`. It requires `var`, `let`, or `const. 2 | 3 | 'use strict'; 4 | answer = 42 5 | -------------------------------------------------------------------------------- /Modules/Backslash/README.md: -------------------------------------------------------------------------------- 1 | # Backslash 2 | 3 | Simple module with two editor operations. 4 | 5 | See also: 6 | 7 | - [Script with same operations](../Script) 8 | -------------------------------------------------------------------------------- /Modules/IronPythonFar/Samples/far_input.py: -------------------------------------------------------------------------------- 1 | # The variable `far` is predefined. 2 | 3 | res = far.Input('Enter your name') 4 | if res: 5 | far.Message(res, 'Hello') 6 | -------------------------------------------------------------------------------- /FSharpFar/src/FarNet.Common/AbcService.fs: -------------------------------------------------------------------------------- 1 | [] 2 | module FSharpFarAbc 3 | 4 | /// Interactive session settings. 5 | let fsi = FSharp.Compiler.Interactive.Shell.Settings.fsi 6 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/Standard/const.js: -------------------------------------------------------------------------------- 1 | // Demo module for tests. 2 | 3 | /** 4 | * Some exported variable. 5 | */ 6 | export const myName = 'JavaScriptFar/Standard' 7 | -------------------------------------------------------------------------------- /Samples/FarTask/Case/FarTaskError5.far.ps1: -------------------------------------------------------------------------------- 1 | # Error in run block after UI. 2 | 3 | Start-FarTask { 4 | run { 5 | $Far.Message('working') 6 | throw 'oops-run-after' 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /FSharpFar/src/FarNet.FSharp/Works.fs: -------------------------------------------------------------------------------- 1 | /// FarNet FSharp tools available on `open FarNet`. 2 | [] 3 | module FarNet.Works 4 | 5 | /// The FarNet.Far.Api instance. 6 | let far = Far.Api 7 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/PowerShell/App.fsx: -------------------------------------------------------------------------------- 1 | 2 | open System.Management.Automation 3 | 4 | let ps = PowerShell.Create () 5 | ps.AddScript "'answer', 42" 6 | ps.Invoke () 7 | |> printfn "%A" 8 | -------------------------------------------------------------------------------- /Test/XPath/upper-case.xq: -------------------------------------------------------------------------------- 1 | 2 | //File[ 3 | upper-case(substring(@Name, string-length(@Name) - 6)) = '.CSPROJ' 4 | and 5 | ../*[upper-case(substring(@Name, string-length(@Name) - 3)) = '.SLN'] 6 | ] 7 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/CommonJS/const.js: -------------------------------------------------------------------------------- 1 | // Demo module for tests. 2 | 3 | /** 4 | * Some exported variable. 5 | */ 6 | const myName = 'JavaScriptFar/CommonJS' 7 | 8 | module.exports = { myName } 9 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/use-mix/try.js: -------------------------------------------------------------------------------- 1 | 2 | function test() { 3 | let name1 = CommonJS.myName 4 | let name2 = Standard.myName 5 | far.Message(`${name1}\n${name2}`) 6 | } 7 | 8 | test() 9 | -------------------------------------------------------------------------------- /Zoo/FSharpFar/samples/Charting/FoxesRubbitsModal.fsx: -------------------------------------------------------------------------------- 1 | 2 | #r "System.Windows.Forms.DataVisualization.dll" 3 | #load "FoxesRubbits.fs" 4 | open FoxesRubbits 5 | 6 | form.TopMost <- true 7 | form.ShowDialog() 8 | -------------------------------------------------------------------------------- /FSharpFar/FSharpFar.slnx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /FSharpFar/samples/fsx-sample/App1.fsx: -------------------------------------------------------------------------------- 1 | open Module1 2 | 3 | let name = 4 | if fsi.CommandLineArgs.Length > 1 then 5 | fsi.CommandLineArgs[1] 6 | else 7 | "unknown" 8 | 9 | hello name 10 | -------------------------------------------------------------------------------- /HelpDown/HtmlToFarHelp/Test/2024-12-31-0758-missing-space.html: -------------------------------------------------------------------------------- 1 |

bar

2 | 7 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/events/disconnect.js: -------------------------------------------------------------------------------- 1 | if (connection) { 2 | connection.disconnect() 3 | connection = null 4 | message('Disconnected.') 5 | } 6 | else { 7 | message('Not connected.') 8 | } 9 | -------------------------------------------------------------------------------- /PowerShellFar/About/Profile-Local.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Local async session profile sample. 4 | #> 5 | 6 | # Global concurrent dictionary. 7 | Set-Variable -Name _data -Value ([FarNet.User]::Data) -Option ReadOnly 8 | -------------------------------------------------------------------------------- /PowerShellFar/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Far": { 4 | "commandName": "Executable", 5 | "executablePath": "Far.exe", 6 | "nativeDebugging": true 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /Drawer/Zoo/CurrentWord-1.html: -------------------------------------------------------------------------------- 1 | With "Visual" scheme, `script` is Yellow BG by Colorer, together with markup. 2 | With CurrentWord, tags `script` are Gray but other words in text are Yellow. 3 | 4 | 6 | -------------------------------------------------------------------------------- /FSharpFar/src/fsx/Tests/test_02/FakeFarInput.fs: -------------------------------------------------------------------------------- 1 | namespace FarNet 2 | 3 | type DummyFar () = 4 | member _.Input(_) = 5 | "Dummy" 6 | 7 | [] 8 | module FarNetAuto = 9 | let far = DummyFar () 10 | -------------------------------------------------------------------------------- /GitKit/Panels/BaseExplorer.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | 3 | namespace GitKit.Panels; 4 | 5 | public abstract class BaseExplorer(string gitDir, Guid typeId) : Explorer(typeId) 6 | { 7 | public string GitDir => gitDir; 8 | } 9 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/input-output.js: -------------------------------------------------------------------------------- 1 | // Input dialog with result printed to the console. 2 | 3 | res = far.Input('Enter your name', null, 'JavaScript', 'John Doe') 4 | if (res) { 5 | far.UI.WriteLine('Hello, ' + res) 6 | } 7 | -------------------------------------------------------------------------------- /JsonKit/Tests/x-array.json: -------------------------------------------------------------------------------- 1 | // array 2 | [ 3 | null, 4 | true, 5 | false, 6 | 42, 7 | 3.14, 8 | "текст", 9 | [], 10 | {}, 11 | [ 12 | [ 13 | 1, 14 | 2 15 | ] 16 | ], // comma 17 | ] 18 | -------------------------------------------------------------------------------- /FSharpFar/tests/App1.fsx: -------------------------------------------------------------------------------- 1 | open FarNet 2 | open FarNet.FSharp 3 | 4 | // windows must be closed 5 | if far.Window.Count <> 2 then failwith "Close Far Manager internal windows before tests." 6 | 7 | // run added tests 8 | Test.Run() 9 | -------------------------------------------------------------------------------- /FarNet/Docs/About.content: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RedisKit/Tests/keys.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $Far.InvokeCommand('rk:keys') 4 | } 5 | 6 | job { 7 | $r = $Far.Panel 8 | Assert-Far $r.GetType().Name -eq KeysPanel 9 | Assert-Far ($r.Title -like 'Keys 127.0.0.1:3278,*') 10 | $r.Close() 11 | } 12 | -------------------------------------------------------------------------------- /RightWords/HelpTopic.cs: -------------------------------------------------------------------------------- 1 | namespace RightWords; 2 | 3 | static class HelpTopic 4 | { 5 | public const string 6 | AddToDictionary = "add-to-dictionary", 7 | CorrectionList = "correction-list", 8 | MainMenu = "main-menu"; 9 | } 10 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/try.cjs: -------------------------------------------------------------------------------- 1 | // Due to the extension this file is CommonJS in sessions with any 2 | // DocumentCategory. Imported modules are CommonJS automatically. 3 | 4 | const Tools = require('./CommonJS/tools.js') 5 | 6 | Tools.hello() 7 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/try.mjs: -------------------------------------------------------------------------------- 1 | // Due to the extension this file is Standard in sessions with any 2 | // DocumentCategory. Imported modules are Standard automatically. 3 | 4 | import * as Tools from './Standard/tools.js' 5 | 6 | Tools.hello() 7 | -------------------------------------------------------------------------------- /JsonKit/Tests/1-open-values.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $Far.InvokeCommand('jk:open file=x-values.json') 4 | } 5 | 6 | job { 7 | Assert-Far -Plugin 8 | Assert-Far $Far.Panel.Title -eq 'Array $' 9 | } 10 | 11 | job { 12 | $Far.Panel.Close() 13 | } 14 | -------------------------------------------------------------------------------- /RedisKit/Tests/about.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $Far.InvokeCommand('rk:keys') 4 | } 5 | 6 | job { 7 | $r = $Far.Panel 8 | Assert-Far $r.GetType().Name -eq KeysPanel 9 | Assert-Far ($r.Title -like 'Keys 127.0.0.1:3278,*') 10 | $r.Close() 11 | } 12 | -------------------------------------------------------------------------------- /FSharpFar/samples/TryPanelFSharp/TryPanelFSharp.fs.ini: -------------------------------------------------------------------------------- 1 | ; Specify required sources and options 2 | [fsc] 3 | TryPanelFSharp.fs 4 | 5 | ; Build FarNet module TryPanelFSharp 6 | [out] 7 | Module.fs 8 | -o:%FARHOME%\FarNet\Modules\TryPanelFSharp\TryPanelFSharp.dll 9 | -------------------------------------------------------------------------------- /PowerShellFar/About/Profile-Console.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Sample command console profile. 4 | 5 | .Description 6 | Location: %FARPROFILE%\FarNet\PowerShellFar\Profile-Console.ps1 7 | #> 8 | 9 | # custom prompt 10 | # . $PSScriptRoot\prompt-1.ps1 11 | -------------------------------------------------------------------------------- /GitKit/Tests/edit.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $Far.InvokeCommand("gk:edit path=.git\config; repo=$env:FarNetCode") 4 | } 5 | job { 6 | Assert-Far -Editor 7 | Assert-Far $Far.Editor.FileName -eq $env:FarNetCode\.git\config 8 | $Far.Editor.Close() 9 | } 10 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/config/WebLoadingAndSearchPath.js: -------------------------------------------------------------------------------- 1 | // Without DocumentSearchPath or EnableAllLoading this script fails: 2 | // 'const.js' is either not found or cannot be loaded. 3 | 4 | import * as Const from 'const.js' 5 | 6 | far.Message(Const.myName) 7 | -------------------------------------------------------------------------------- /Modules/XGraphQL/1.build.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Build script, https://github.com/nightroman/Invoke-Build 4 | #> 5 | 6 | task build { 7 | exec { dotnet build -c Release } 8 | } 9 | 10 | task clean { 11 | remove obj 12 | } 13 | 14 | task . build, clean 15 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/Standard/tools.js: -------------------------------------------------------------------------------- 1 | // Demo module for tests. 2 | 3 | import * as Const from './const.js' 4 | 5 | /** 6 | * Shows a message box. 7 | */ 8 | export function hello() { 9 | far.Message(`Hello from ${Const.myName}`) 10 | } 11 | -------------------------------------------------------------------------------- /RightWords/TheHost.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | 3 | namespace RightWords; 4 | 5 | public class TheHost : ModuleHost 6 | { 7 | public static TheHost Instance { get; private set; } = null!; 8 | 9 | public TheHost() 10 | { 11 | Instance = this; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Vanilla/Vanilla.fs: -------------------------------------------------------------------------------- 1 | 2 | module Vanilla 3 | open FarNet 4 | open FarNet.Tools 5 | 6 | // `far` is available via FarNet.dll, FSharpFar.dll and auto module 7 | far.UI.WriteLine "hi" 8 | 9 | // FarNet.Tools 10 | let form = ProgressForm () 11 | -------------------------------------------------------------------------------- /FSharpFar/tests/README.md: -------------------------------------------------------------------------------- 1 | # FSharpFar tests 2 | 3 | Tests cover FSharpFar and also some FarNet and PowerShellFar. 4 | 5 | How to run all tests: 6 | 7 | fs:exec file=App1.fsx 8 | 9 | How to run a particular test by name: 10 | 11 | fs: run "TestName" 12 | -------------------------------------------------------------------------------- /Samples/README.md: -------------------------------------------------------------------------------- 1 | # Samples 2 | 3 | - [FarRedisTask](FarRedisTask) -- toy examples of `Send-FarRedisTask.ps1` 4 | - [FarTask](FarTask) -- use `Start-FarTask` for async scripting 5 | - [Quit](Quit) -- "Quit()" method and handlers 6 | - [Tests](Tests) -- various demo and test scripts 7 | -------------------------------------------------------------------------------- /Test/Panels/Test-z_161015.#7.fas.ps1: -------------------------------------------------------------------------------- 1 | #! _201225_28 Panel is opened from Desktop window 2 | 3 | macro 'print "ps: 42; $Host | Out-FarPanel"; Keys "Enter"' # $r 4 | job { 5 | Assert-Far -Plugin 6 | $__.Close() 7 | 8 | # REPL $r 9 | Assert-Far $r -eq 42 10 | } 11 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/FormatMessageMode.cs: -------------------------------------------------------------------------------- 1 | namespace FarNet.Works; 2 | #pragma warning disable 1591 3 | 4 | public enum FormatMessageMode 5 | { 6 | // Cut wide lines. 7 | Cut, 8 | 9 | // Wrap by \s. 10 | Space, 11 | 12 | // Wrap by \W. 13 | NonWord, 14 | } 15 | -------------------------------------------------------------------------------- /Test/Panels/Test-z_230805_1220_Closure.far.ps1: -------------------------------------------------------------------------------- 1 | # 230805_1220 -- GetNewClosure is needed 2 | 3 | $230805_1220 = '1234567890' 4 | 5 | 5 | Out-FarPanel @( 6 | @{Expression={$230805_1220.Substring(0, $_)}} 7 | @{Expression={$230805_1220.Substring(0, $_)}.GetNewClosure()} 8 | ) 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | bin 3 | obj 4 | Debug 5 | Release 6 | TestResults 7 | z 8 | 9 | z.* 10 | *.bak 11 | *.clixml 12 | *.user 13 | 14 | *.htm* 15 | *.nupkg 16 | Active.h 17 | AssemblyInfo.cs 18 | AssemblyMeta.* 19 | Directory.Build.props 20 | launchSettings.json 21 | -------------------------------------------------------------------------------- /FarNet/FarNet/Works/Regexes.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace FarNet.Works; 4 | #pragma warning disable 1591 5 | 6 | public static partial class Regexes 7 | { 8 | [GeneratedRegex(@"[\t\r\n]+")] 9 | public static partial Regex TabsAndNewLines(); 10 | } 11 | -------------------------------------------------------------------------------- /HelpDown/HtmlToFarHelp/HtmlToFarHelp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | net472 5 | true 6 | 7 | 8 | -------------------------------------------------------------------------------- /JsonKit/Commands/AbcCommand.cs: -------------------------------------------------------------------------------- 1 | namespace JsonKit.Commands; 2 | 3 | abstract class AbcCommand 4 | { 5 | protected static class Param 6 | { 7 | public const string File = "File"; 8 | public const string Select = "Select"; 9 | } 10 | 11 | public abstract void Invoke(); 12 | } 13 | -------------------------------------------------------------------------------- /PowerShellFar/Works/Enums.cs: -------------------------------------------------------------------------------- 1 | 2 | // PowerShellFar module for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace PowerShellFar; 6 | 7 | /// 8 | /// Used in panels. 9 | /// 10 | enum UserAction 11 | { 12 | None, 13 | Enter 14 | } 15 | -------------------------------------------------------------------------------- /Zoo/FSharpFar/samples/Charting/FoxesRubbitsAsync.fsx: -------------------------------------------------------------------------------- 1 | #r "System.Windows.Forms.DataVisualization.dll" 2 | #load "FoxesRubbits.fs" 3 | open FoxesRubbits 4 | 5 | async { form.ShowDialog() |> ignore } 6 | |> if fsi.CommandLineArgs[0].EndsWith(".fsx") then Async.RunSynchronously else Async.Start 7 | -------------------------------------------------------------------------------- /JavaScriptFar/Tests/message-box.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | run { 3 | $Far.InvokeCommand("js:@ $env:FarNetCode\JavaScriptFar\Samples\message-box.js") 4 | } 5 | job { 6 | Assert-Far -Dialog 7 | Assert-Far $Far.Dialog[1].Text -eq 'Hello from JavaScript!' 8 | 9 | $Far.Dialog.Close() 10 | } 11 | -------------------------------------------------------------------------------- /JsonKit/Host.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | 3 | namespace JsonKit; 4 | 5 | public class Host : ModuleHost 6 | { 7 | internal const string MyName = "JsonKit"; 8 | 9 | internal static Host Instance { get; private set; } = null!; 10 | 11 | public Host() 12 | { 13 | Instance = this; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Modules/IronPythonFar/Samples/print.py: -------------------------------------------------------------------------------- 1 | # Standard and error output (no difference for now). 2 | 3 | # standard output 4 | print('standard') 5 | 6 | # error output 7 | import sys 8 | sys.stderr.write('error1\n') 9 | sys.stderr.write('error2') #! last line is not printed without \n 10 | -------------------------------------------------------------------------------- /Test/Panels.Item/Test-ItemPanel-Certificate.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | # open cert: 4 | (New-Object PowerShellFar.ItemPanel cert:\).Open() 5 | } 6 | job { 7 | Find-FarFile 'CurrentUser' 8 | } 9 | job { 10 | Find-FarFile 'LocalMachine' 11 | } 12 | 13 | # exit panel 14 | keys Esc 15 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/CommonJS/tools.js: -------------------------------------------------------------------------------- 1 | // Demo module for tests. 2 | 3 | const Const = require('./const.js') 4 | 5 | /** 6 | * Shows a message box. 7 | */ 8 | function hello() { 9 | far.Message(`Hello from ${Const.myName}`) 10 | } 11 | 12 | module.exports = { hello } 13 | -------------------------------------------------------------------------------- /Samples/FarTask/MainAndAsyncCommon/Test-CommonCode.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Calls "CommonCode.far.ps1" in main and async sessions. 4 | #> 5 | 6 | # Main session 7 | & $PSScriptRoot\CommonCode.far.ps1 8 | 9 | # Async session 10 | Start-FarTask { 11 | & $PSScriptRoot\CommonCode.far.ps1 12 | } 13 | -------------------------------------------------------------------------------- /RightWords/RightWords.restext: -------------------------------------------------------------------------------- 1 | AddToDictionary=Add to Dictionary 2 | DoIgnore=&1. Ignore 3 | DoIgnoreAll=&2. Ignore All 4 | DoAddToDictionary=&3. Add to Dictionary 5 | DoCorrectWord=&1. Correct word 6 | DoCorrectText=&2. Correct text 7 | Common=Common 8 | NewWord=New word 9 | SampleStem=Sample stem 10 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/BufferCellType.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Works; 6 | #pragma warning disable 1591 7 | 8 | public enum BufferCellType 9 | { 10 | Complete = 0, 11 | 12 | Leading = 1, 13 | 14 | Trailing = 2, 15 | } 16 | -------------------------------------------------------------------------------- /RedisKit/Panels/BasePanel.cs: -------------------------------------------------------------------------------- 1 | using StackExchange.Redis; 2 | 3 | namespace RedisKit.Panels; 4 | 5 | abstract class BasePanel(T explorer) : AbcPanel(explorer) where T : BaseExplorer 6 | { 7 | public IDatabase Database { get; } = explorer.Database; 8 | 9 | public new T Explorer => (T)base.Explorer; 10 | } 11 | -------------------------------------------------------------------------------- /FSharpFar/src/fsx/Tests/test_02/.fs.ini: -------------------------------------------------------------------------------- 1 | ; Test here by: 2 | ; fsx ..\..\..\..\samples\fsx-sample\App2.fsx 3 | 4 | ; Include the sample configuration 5 | [use] 6 | ..\..\..\..\samples\fsx-sample\.fs.ini 7 | 8 | ; Define FARNET to fake FarNet.far.Input used by App2.fsx 9 | [fsc] 10 | --define:FARNET 11 | FakeFarInput.fs 12 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/events/_session.js: -------------------------------------------------------------------------------- 1 | // This session script is loaded once for this folder session. 2 | // Other scripts in this folder use assets defined here. 3 | 4 | // Event connection. 5 | let connection = null 6 | 7 | // Common function. 8 | function message(text) { 9 | far.Message(text) 10 | } 11 | -------------------------------------------------------------------------------- /FSharpFar/samples/fsx-sample/App2.fsx: -------------------------------------------------------------------------------- 1 | open Module1 2 | 3 | #if FARNET 4 | open FarNet 5 | let input () = 6 | far.Input("Enter your name:") 7 | 8 | #else 9 | open System 10 | let input () = 11 | printfn "Enter your name:" 12 | Console.ReadLine() 13 | 14 | #endif 15 | 16 | let name = input () 17 | 18 | hello name 19 | -------------------------------------------------------------------------------- /FarNet/FarNet/Module/ModuleEditorEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Module editor event arguments. 11 | /// 12 | public class ModuleEditorEventArgs : EventArgs 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /RightWords/RightWords.ru.restext: -------------------------------------------------------------------------------- 1 | AddToDictionary=Добавить в словарь 2 | DoIgnore=&1. Пропустить 3 | DoIgnoreAll=&2. Пропустить все 4 | DoAddToDictionary=&3. Добавить в словарь 5 | DoCorrectWord=&1. Исправить слово 6 | DoCorrectText=&2. Исправить текст 7 | Common=Общий 8 | NewWord=Новое слово 9 | SampleStem=Образец слова 10 | -------------------------------------------------------------------------------- /Test/Panels/Test-Panel-Unsubscribed.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | [PowerShellFar.PowerExplorer]::new('f8872f07-f878-4e63-9981-5984c193e620').CreatePanel().Open() 4 | } 5 | job { 6 | Assert-Far -Panels -Plugin 7 | } 8 | macro 'Keys"F3 F4 F5 F6 F7 F8"' 9 | job { 10 | Assert-Far -Panels -Plugin 11 | } 12 | job { 13 | $__.Close() 14 | } 15 | -------------------------------------------------------------------------------- /Test/Dialog/zoo-Mantis-2241.fas.ps1: -------------------------------------------------------------------------------- 1 | # FarNet 5.2.14 + PowerShellFar 5.2.6 2 | 3 | macro 'Keys[[CtrlG CtrlDown]]' 4 | job { 5 | # used to hang due to Far critical sections and not main PowerShell threads 6 | Assert-Far ($Far.Window.Kind -eq 'Menu') 7 | } 8 | keys Esc 9 | job { 10 | Assert-Far -Dialog 11 | } 12 | keys Esc 13 | -------------------------------------------------------------------------------- /JavaScriptFar/Res.cs: -------------------------------------------------------------------------------- 1 | 2 | // JavaScriptFar module for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace JavaScriptFar; 6 | 7 | static class Res 8 | { 9 | public const string 10 | Prefix = "js", 11 | DebugTitle = "Debug JavaScript", 12 | MyName = "JavaScriptFar", 13 | Result = "JavaScript result"; 14 | } 15 | -------------------------------------------------------------------------------- /Test/XPath/x-profile-2-.ps1: -------------------------------------------------------------------------------- 1 | 2 | $explorer = [PowerShellFar.ItemExplorer]"C:\Program Files" 3 | $search = [FarNet.Tools.SearchFileCommand]$explorer 4 | $search.XFile = "$env:FarNetCode\Test\XPath\x-profile-2.xq" 5 | 6 | $sw = [Diagnostics.Stopwatch]::StartNew() 7 | $res = @($search.Invoke()) 8 | $res.Count 9 | $sw.Elapsed.ToString() 10 | -------------------------------------------------------------------------------- /PowerShellFar/OutputWriters/EditorOutputWriterNormal.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | 3 | namespace PowerShellFar; 4 | 5 | /// 6 | /// Sync editor writer. 7 | /// 8 | sealed class EditorOutputWriterNormal(IEditor editor) : EditorOutputWriter(editor) 9 | { 10 | public override void Flush() 11 | { 12 | Editor.Redraw(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /PowerShellFar/Panels/ListExplorer.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using System; 3 | 4 | namespace PowerShellFar; 5 | 6 | /// 7 | /// Base list explorer. 8 | /// 9 | /// . 10 | public abstract class ListExplorer(Guid typeId) : Explorer(typeId) 11 | { 12 | internal bool SkipDeleteFiles { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /FarNet/FarNet/Works/Tasks2.cs: -------------------------------------------------------------------------------- 1 | namespace FarNet.Works; 2 | #pragma warning disable CS1591 3 | 4 | public static class Tasks2 5 | { 6 | public static async Task Wait(string message, Func job) 7 | { 8 | if (await Tasks.Wait(50, 5000, job)) 9 | return null; 10 | else 11 | throw new Exception(message); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /HelpDown/HtmlToFarHelp/More/README.md: -------------------------------------------------------------------------------- 1 | # More 2 | 3 | - *Demo.text* 4 | 5 | This Markdown file is the original version of the current *Demo/README.md*. 6 | It uses "PHP Markdown Extra" and shows manually set heading identifiers and 7 | definition lists. 8 | 9 | This file shows some differences on converting by Pandoc and MarkdownDeep. 10 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/PowerShell/PowerShell.fs.ini: -------------------------------------------------------------------------------- 1 | [fsc] 2 | 3 | ; _000000 keep it simple, assembly details may fail on some machines 4 | ; _210206 FCS 39 fails 5 | ;-r:System.Management.Automation 6 | 7 | ; _210206 use this way with FCS 39 8 | -r:%ProgramFiles(x86)%\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll 9 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-170827.LibInIni.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | Open-FarEditor $PSScriptRoot\LibInIni\LibInIni.fsx -DisableHistory 4 | } 5 | macro @' 6 | Plugin.Menu("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "65BD5625-769A-4253-8FDE-FFCC3F72489D") 7 | Keys'c' -- check 8 | '@ 9 | job { 10 | Assert-Far -Editor 11 | $Far.Editor.Close() 12 | } 13 | -------------------------------------------------------------------------------- /FarNet/FarNet/About/QuittingEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace FarNet; 2 | 3 | /// 4 | /// Quitting arguments. 5 | /// 6 | public sealed class QuittingEventArgs : EventArgs 7 | { 8 | /// 9 | /// Ignore event. 10 | /// 11 | public bool Ignore { get => _Ignore; set { if (value) _Ignore = true; } } 12 | bool _Ignore; 13 | } 14 | -------------------------------------------------------------------------------- /GitKit/Commands/BranchesCommand.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using GitKit.Panels; 3 | 4 | namespace GitKit.Commands; 5 | 6 | sealed class BranchesCommand(CommandParameters parameters) : BaseCommand(parameters) 7 | { 8 | public override void Invoke() 9 | { 10 | new BranchesExplorer(GitDir) 11 | .CreatePanel() 12 | .Open(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/events/connect.js: -------------------------------------------------------------------------------- 1 | if (connection) { 2 | message('Already connected, open any editor.') 3 | } 4 | else { 5 | connection = far.AnyEditor.Opened.connect((editor) => { 6 | message(`Opened ${editor.FileName}\nRun disconnect.js to disconnect.`) 7 | }) 8 | 9 | message('Connected, open any editor.') 10 | } 11 | -------------------------------------------------------------------------------- /Test/Basics.Posts/PostJob-seq.fas.ps1: -------------------------------------------------------------------------------- 1 | #! no need to sync `PostJob` and `job` 2 | 3 | job { 4 | $global:log = 'do1/' 5 | $Far.PostJob({ 6 | $global:log += 'do2/' 7 | }) 8 | $Far.PostJob({ 9 | $global:log += 'do3/' 10 | }) 11 | } 12 | job { 13 | Assert-Far $global:log -eq 'do1/do2/do3/' 14 | Remove-Variable log -Scope global 15 | } 16 | -------------------------------------------------------------------------------- /Test/Dialog/Test-UndoRedo.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | run { 3 | $null = Read-Host undo/redo 4 | } 5 | 6 | keys A 7 | keys B 8 | job { 9 | Assert-Far -Dialog 10 | Assert-Far $__[2].Text -eq AB 11 | } 12 | 13 | keys CtrlZ 14 | job { 15 | Assert-Far $__[2].Text -eq A 16 | } 17 | 18 | keys CtrlY 19 | job { 20 | Assert-Far $__[2].Text -eq AB 21 | $__.Close() 22 | } 23 | -------------------------------------------------------------------------------- /Test/Host/zoo.ps1: -------------------------------------------------------------------------------- 1 | 2 | function global:TestManyMandatoryParameters { 3 | param ( 4 | [Parameter(Mandatory=$true, HelpMessage='Help for Name')] 5 | [string]$Name, 6 | [Parameter(Mandatory=$true)] 7 | [string[]]$Tags, 8 | [Parameter(Mandatory=$true)] 9 | [System.Security.SecureString]$Password 10 | ) 11 | $PSBoundParameters 12 | } 13 | -------------------------------------------------------------------------------- /FarNet/Docs/Resource.items: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Modules/FarNet.Demo/FarNet.Demo.ru.restext: -------------------------------------------------------------------------------- 1 | 2 | # Russian translation 3 | MenuTitle=Трассировка 4 | itemShowFile=&*. Просмотр трассировки 5 | itemListener=&0. Трассировка в файл 6 | itemWarning=&1. Предупреждения и ошибки 7 | itemInformation=&2. Информационная 8 | itemVerbose=&3. Подробная 9 | itemAll=&4. Полная 10 | BadResources=Это не файл ресурсов. 11 | -------------------------------------------------------------------------------- /FarNet/FarNet/Tools/ValueGetter.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet.Tools; 8 | 9 | class ValueGetter(string name, Func value) 10 | { 11 | public string Name { get; } = name; 12 | 13 | public Func Value { get; } = value; 14 | } 15 | -------------------------------------------------------------------------------- /FarNet/FarNet/Module/ModuleAction.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Abstract parent of , , . 9 | /// 10 | public abstract class ModuleAction : BaseModuleItem 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /FarNet/FarNetMan/AssemblyResolver.h: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | #pragma once 6 | 7 | namespace FarNet 8 | { 9 | public ref class AssemblyResolver 10 | { 11 | public: 12 | static void Init(); 13 | private: 14 | static Assembly^ AssemblyResolve(Object^ sender, ResolveEventArgs^ args); 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /Test/Panels/Test-z_181105_OpenPanelFromEditor.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Regression: could not open a panel from an editor. 3 | #> 4 | 5 | job { 6 | Open-FarEditor z.z 7 | } 8 | job { 9 | Assert-Far -Editor 10 | } 11 | job { 12 | 1 | Out-FarPanel 13 | } 14 | job { 15 | Assert-Far -Panels -Plugin 16 | } 17 | macro 'Keys"Esc F12 2 Esc" -- exit panel and editor' 18 | -------------------------------------------------------------------------------- /Test/XPath/x-profile-1-.ps1: -------------------------------------------------------------------------------- 1 | 2 | $explorer = [PowerShellFar.ItemExplorer] "C:\Program Files" #'C:\', "C:\Program Files" 3 | $search = [FarNet.Tools.SearchFileCommand]$explorer 4 | $search.XFile = "$env:FarNetCode\Test\XPath\x-profile-1.xq" 5 | 6 | $sw = [Diagnostics.Stopwatch]::StartNew() 7 | $res = @($search.Invoke()) 8 | $res.Count 9 | $sw.Elapsed.ToString() 10 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/EditorChangeKind.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Editor change constants. 9 | /// 10 | public enum EditorChangeKind 11 | { 12 | /// 13 | LineChanged, 14 | 15 | /// 16 | LineAdded, 17 | 18 | /// 19 | LineRemoved 20 | } 21 | -------------------------------------------------------------------------------- /HelpDown/HtmlToFarHelp/Test/cases.test.ps1: -------------------------------------------------------------------------------- 1 | 2 | # should have a space after link before text 3 | task 2024-12-31-0758-missing-space { 4 | exec { HtmlToFarHelp.exe from=2024-12-31-0758-missing-space.html to=z.hlf } 5 | $text = [System.IO.File]::ReadAllText("$PSScriptRoot\z.hlf") 6 | assert $text.Contains('@https://github.com/fsprojects/FSharp.Data@ package') 7 | remove z.hlf 8 | } 9 | -------------------------------------------------------------------------------- /FarNet/FarNetMan/History.h: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | #pragma once 6 | 7 | namespace FarNet 8 | { 9 | ref class History sealed : IHistory 10 | { 11 | public: 12 | virtual array^ GetHistory(GetHistoryArgs^ args) override; 13 | internal: 14 | static History Instance; 15 | private: 16 | History() {} 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /GitKit/Tests/FSF/Credentials.fsx: -------------------------------------------------------------------------------- 1 | // get credentials, user name / password dialog 2 | 3 | open FarNet 4 | open GitKit 5 | open LibGit2Sharp 6 | 7 | do 8 | far.LoadModule("GitKit") 9 | let handler = Host.LocalCredentialsHandler("https://github.com/nightroman/FarNet.git", null, SupportedCredentialTypes.Default) 10 | 11 | User.Data["LocalCredentialsHandler"] <- handler 12 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/config/StringifyEnhancements.js: -------------------------------------------------------------------------------- 1 | // Without EnableStringifyEnhancements JSON.stringify returns undefined and 2 | // this script fails because far.Message cannot accept undefined. 3 | 4 | let dic = new clr.System.Collections.Generic.Dictionary(System.String, System.Object) 5 | dic.Add('foo', 123) 6 | dic.Add('bar', 'baz') 7 | 8 | far.Message(JSON.stringify(dic)) 9 | -------------------------------------------------------------------------------- /FSharpFar/samples/Testing/App1.fsx: -------------------------------------------------------------------------------- 1 | (* 2 | Runs tests defined in the executing assembly, i.e. the current F# session. 3 | It is more reliable to specify the assembly explicitly. But in some cases 4 | the parameter may be omitted, e.g. this command line seems to work fine: 5 | fs: FarNet.FSharp.Test.Run() 6 | *) 7 | 8 | open FarNet.FSharp 9 | 10 | Test.Run() 11 | -------------------------------------------------------------------------------- /Test/Host/Test-CC-OpenPanel.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Command console opens a panel. 4 | #> 5 | 6 | job { $Psf.RunCommandConsole() } 7 | job { 8 | $Far.Dialog[1].Text = '42 | Out-FarPanel' 9 | } 10 | keys Enter 11 | job { 12 | Assert-Far -ExplorerTypeId ([PowerShellFar.Guids]::ObjectExplorer) 13 | Find-FarFile 42 14 | $__.Close() 15 | [FarNet.Tasks]::WaitForPanels(9) 16 | } 17 | -------------------------------------------------------------------------------- /Test/Host/Test-Read-Host-UnusualPrompt.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | run { 3 | $res = Read-Host @' 4 | Question? 5 | [1] Answer1 6 | [2] Answer2 7 | '@ 8 | Assert-Far $res -eq '2' 9 | } 10 | job { 11 | Assert-Far -Dialog 12 | Assert-Far $__[1].Text -eq 'Question?' 13 | Assert-Far $__[2].Text -eq '[1] Answer1' 14 | Assert-Far $__[3].Text -eq '[2] Answer2' 15 | } 16 | keys 2 Enter 17 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/interop/app1.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Run JavaScript commands using JavaScriptFar interop. 4 | #> 5 | 6 | # step 1: get the function to run commands 7 | $EvaluateCommand = $Far.GetModuleInterop('JavaScriptFar', 'EvaluateCommand', $null) 8 | 9 | # step 2: run commands with parameters 10 | $EvaluateCommand.Invoke('args.LiveObject', @{LiveObject = $Host}) 11 | -------------------------------------------------------------------------------- /Modules/IronPythonFar/Samples/far_message.py: -------------------------------------------------------------------------------- 1 | # Using FarNet and .NET types. 2 | 3 | import clr 4 | clr.AddReference('FarNet') 5 | 6 | from FarNet import * 7 | from System import * 8 | 9 | args = MessageArgs() 10 | args.Text = 'from:' + __file__ + __name__ 11 | args.Caption = 'Hello' 12 | args.Buttons = Array[str](['&Ready', '&Steady', '&Go']) 13 | 14 | res = far.Message(args) 15 | -------------------------------------------------------------------------------- /Test/Host/Test-Read-Host-1.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Read-Host 1 line prompt 4 | #> 5 | 6 | run { 7 | # show prompt 8 | $r = Read-Host -Prompt Prompt 9 | Assert-Far $r -eq '090328_192727' 10 | } 11 | job { 12 | Assert-Far -Dialog 13 | Assert-Far $__[1].Text -eq 'Prompt' 14 | Assert-Far $__[2].Text -eq '' 15 | 16 | $__[2].Text = '090328_192727' 17 | } 18 | keys Enter 19 | -------------------------------------------------------------------------------- /FSharpFar/src/FSharpFar/FarHost.fs: -------------------------------------------------------------------------------- 1 | namespace FSharpFar 2 | open FarNet 3 | 4 | [] 5 | type FarHost() = 6 | inherit ModuleHost() 7 | 8 | override __.Connect() = 9 | // on saving configs, notify sessions 10 | far.AnyEditor.Saving.Add <| fun e -> 11 | if String.endsWithIgnoreCase e.FileName ".fs.ini" then 12 | Session.OnSavingConfig e.FileName 13 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/HistoryKind.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Supported history kinds. 9 | /// 10 | public enum HistoryKind 11 | { 12 | /// 13 | Command = 1, 14 | 15 | /// 16 | Folder = 2, 17 | 18 | /// 19 | Viewer = 3, 20 | 21 | /// 22 | Editor = 4, 23 | } 24 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/DrawnEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// event arguments. 9 | /// 10 | /// Control that is drawn. 11 | public sealed class DrawnEventArgs(IControl control) : AnyEventArgs(control) 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/CreateFileEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Create file arguments. 9 | /// 10 | /// See 11 | public sealed class CreateFileEventArgs(ExplorerModes mode) : ExplorerEventArgs(mode) 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /PowerShellFar/OutputWriters/EditorOutputWriterAsync.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | 3 | namespace PowerShellFar; 4 | 5 | /// 6 | /// Async editor writer. 7 | /// 8 | sealed class EditorOutputWriterAsync(IEditor editor) : EditorOutputWriter(editor) 9 | { 10 | public override void Flush() 11 | { 12 | A.AwaitJob(() => 13 | { 14 | Editor.Sync(); 15 | Editor.Redraw(); 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Test/Basics/Test-System.Drawing.far.ps1: -------------------------------------------------------------------------------- 1 | # https://github.com/PowerShell/PowerShell/discussions/24562 2 | 3 | #! needed in Desktop 4 | if ($PSEdition -eq 'Desktop') { 5 | Add-Type -AssemblyName System.Windows.Forms 6 | } 7 | 8 | $path = "$PSScriptRoot\..\..\Zoo\FarNetLogo.png" 9 | $bm = [System.Drawing.Bitmap]::new($path) 10 | $size = $bm.Size 11 | if ($size.Width -ne 60) {throw} 12 | if ($size.Height -ne 55) {throw} 13 | -------------------------------------------------------------------------------- /Test/XPath/x-profile-2.xq: -------------------------------------------------------------------------------- 1 | 2 | (: Example XPath input file :) 3 | 4 | (: External variable. An input box is shown to enter the value. :) 5 | declare variable $external external; 6 | 7 | declare variable $studio := 'Studio'; 8 | 9 | //File 10 | [ 11 | ancestor-or-self::self[contains(@Name, $studio)] 12 | and 13 | @Name = 'Readme.txt' 14 | and 15 | compare(@LastWriteTime, '2009-01-01') > 0 16 | ] 17 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/OpenFileEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Open file arguments. 9 | /// 10 | /// See 11 | public sealed class OpenFileEventArgs(FarFile file) : ExplorerFileEventArgs(ExplorerModes.None, file) 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /Test/Utility/Test-Input.fas.ps1: -------------------------------------------------------------------------------- 1 | # _090308_055056 Cannot get text of editbox in input box dialog 2 | 3 | run { 4 | # open input box 5 | $Far.Input('Test') 6 | } 7 | 8 | # type text 9 | macro 'Keys"T e x t"' 10 | 11 | job { 12 | $eb = $__[2] 13 | Assert-Far $eb.Line.Text -eq 'Text' # worked fine; weird 14 | Assert-Far $eb.Text -eq 'Text' # used to get empty string 15 | } 16 | 17 | # exit 18 | keys Esc 19 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Vanilla/Vanilla.fsx: -------------------------------------------------------------------------------- 1 | 2 | // Far home is predefined as --lib by FCS, so we can use paths from it 3 | #r "FarNet/Modules/FSharpFar/FSharp.Compiler.Service.dll" 4 | #r "System.Console" // net6 5 | 6 | open FarNet 7 | open FarNet.Tools 8 | 9 | // `far` is available via FarNet.dll, FSharpFar.dll and auto module 10 | far.UI.WriteLine "hi" 11 | 12 | // FarNet.Tools 13 | let form = ProgressForm () 14 | -------------------------------------------------------------------------------- /Zoo/FSharpFar/samples/Charting/LineChartAsync.fsx: -------------------------------------------------------------------------------- 1 | #r "System.Windows.Forms.DataVisualization.dll" 2 | #load "LineChart.fs" 3 | open LineChart 4 | 5 | let data = [ 6 | for i in 1..1000 do 7 | yield sin (float i / 100.0) 8 | ] 9 | 10 | let form = new LineChartForm("sin", data) 11 | 12 | async { form.ShowDialog() |> ignore } 13 | |> if fsi.CommandLineArgs[0].EndsWith(".fsx") then Async.RunSynchronously else Async.Start 14 | -------------------------------------------------------------------------------- /FSharpFar/src/FSharpFar/ProxyWriter.fs: -------------------------------------------------------------------------------- 1 | namespace FSharpFar 2 | open System.IO 3 | 4 | type ProxyWriter(writer: TextWriter) = 5 | inherit TextWriter() 6 | let mutable writer = writer 7 | override __.Encoding = writer.Encoding 8 | override __.Write(value: char) = writer.Write value 9 | override __.Write(value: string) = writer.Write value 10 | member __.Writer with get () = writer and set value = writer <- value 11 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/ExploreRootEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Arguments of . 9 | /// 10 | /// See 11 | public sealed class ExploreRootEventArgs(ExplorerModes mode) : ExploreEventArgs(mode) 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/CommonJS/_session.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | EnableFileLoading 4 | CommonJS 5 | 6 | None 7 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/Standard/_session.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | EnableFileLoading 4 | Standard 5 | 6 | None 7 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-200603.fsx1.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | # open empty session 4 | $Far.InvokeCommand("fs:open with=$env:FarNetCode\FSharpFar\samples\fsx-sample\.fs.ini") 5 | } 6 | 7 | job { 8 | Assert-Far -Editor 9 | } 10 | 11 | macro 'print [[Module1.hello "May"]]; Keys"ShiftEnter"' 12 | 13 | job { 14 | Assert-Far $Far.Editor[2].Text -eq 'Hello, May!' 15 | } 16 | 17 | macro 'Keys[[# q u i t ShiftEnter]]' 18 | -------------------------------------------------------------------------------- /FarNet/FarNetMan/AssemblyInfo.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "stdafx.h" 3 | 4 | using namespace System; 5 | using namespace System::Reflection; 6 | using namespace System::Runtime::CompilerServices; 7 | using namespace System::Runtime::InteropServices; 8 | 9 | #include "AssemblyMeta.h" 10 | 11 | [assembly: ComVisible(false)]; 12 | [assembly: CLSCompliant(true)]; 13 | 14 | [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]; 15 | -------------------------------------------------------------------------------- /JsonKit/Tests/x-object.json: -------------------------------------------------------------------------------- 1 | // object 2 | { 3 | "null": null, 4 | "true": true, 5 | "false": false, 6 | "int": 42, 7 | "double": 3.14, 8 | "string": "текст", 9 | "array": [ 10 | "текст" 11 | ], 12 | "arrayOfInt": [ 13 | 1 14 | ], 15 | "object": { 16 | "string": "текст", // comma 17 | }, 18 | "nest1": { 19 | "nest2": { 20 | "id": 1, 21 | "name": "Joe", 22 | } 23 | }, // comma 24 | } 25 | -------------------------------------------------------------------------------- /Modules/FarNet.Demo/Script.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace FarNet.Demo; 3 | 4 | /// 5 | /// Methods for calls by the command `fn:`. 6 | /// 7 | /// 8 | /// fn: module=FarNet.Demo; method=Message ;; name=John Doe; age=42 9 | /// 10 | public static class Script 11 | { 12 | public static void Message(string name = "unknown", int age = -1) 13 | { 14 | Far.Api.Message($"name: {name}, age: {age}"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /PowerShellFar/Bench/Go-HeadFile.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Goes to the first panel file. 4 | Author: Roman Kuzmin 5 | 6 | .Description 7 | The script sets current panel position to the head of files. 8 | #> 9 | 10 | $panel = $Far.Panel 11 | $items = $panel.Files 12 | for($i = 0; $i -lt $items.Count; ++$i) { 13 | $item = $items[$i] 14 | if ($item -and !$item.IsDirectory) { 15 | $panel.Redraw($i, $true) 16 | return 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FarNet/FarNet/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: ComVisible(false)] 7 | [assembly: CLSCompliant(true)] 8 | [assembly: InternalsVisibleTo("FarNetTest")] 9 | 10 | #if DEBUG 11 | [assembly: AssemblyDescription("FarNet API (DEBUG)")] 12 | #else 13 | [assembly: AssemblyDescription("FarNet API")] 14 | #endif 15 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/ExploreParentEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Arguments of . 9 | /// 10 | /// See 11 | public sealed class ExploreParentEventArgs(ExplorerModes mode) : ExploreEventArgs(mode) 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/DropDownClosedEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// event arguments. 9 | /// 10 | /// Control which drop down is closed. 11 | public sealed class DropDownClosedEventArgs(IControl control) : AnyEventArgs(control) 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /FarNet/FarNet/Module/ModuleItemKind.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Module item kinds. 9 | /// 10 | public enum ModuleItemKind 11 | { 12 | /// 13 | None, 14 | 15 | /// 16 | Host, 17 | 18 | /// 19 | Command, 20 | 21 | /// 22 | Editor, 23 | 24 | /// 25 | Tool, 26 | 27 | /// 28 | Drawer 29 | } 30 | -------------------------------------------------------------------------------- /GitKit/Commands/InitCommand.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using LibGit2Sharp; 3 | 4 | namespace GitKit.Commands; 5 | 6 | sealed class InitCommand(CommandParameters parameters) : AbcCommand 7 | { 8 | readonly string _path = parameters.GetPathOrCurrentDirectory(Param.Path); 9 | readonly bool _isBare = parameters.GetBool(Param.IsBare); 10 | 11 | public override void Invoke() 12 | { 13 | Repository.Init(_path, _isBare); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /RedisKit/Host.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | 3 | namespace RedisKit; 4 | 5 | public class Host : ModuleHost 6 | { 7 | internal const string MyName = "RedisKit"; 8 | 9 | internal static class History 10 | { 11 | public const string Key = "RedisKey"; 12 | public const string Prefix = "RedisPrefix"; 13 | } 14 | 15 | public static Host Instance { get; private set; } = null!; 16 | 17 | public Host() 18 | { 19 | Instance = this; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /RightWords/DictionaryInfo.cs: -------------------------------------------------------------------------------- 1 | using WeCantSpell.Hunspell; 2 | 3 | namespace RightWords; 4 | 5 | class DictionaryInfo 6 | { 7 | public required string Language { get; init; } 8 | public required string HunspellAffFile { get; init; } 9 | public required string HunspellDictFile { get; init; } 10 | public int HitCount { get; set; } 11 | public WordList? WordList { get; set; } 12 | public WordList? UserList { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /Test/Settings/Test-MySettings.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Scripted FarNet.ModuleSettings with the specified file. 4 | #> 5 | 6 | $script = "$env:FarNetCode\Modules\FarNet.Demo\Scripts\MySettings.far.ps1" 7 | $file = "$env:TEMP\MySettings.xml" 8 | [IO.File]::Delete($file) 9 | 10 | $data1 = & $script 11 | Assert-Far (Test-Path $file) 12 | Assert-Far $data1.Age -eq 1 13 | 14 | $data2 = & $script 15 | Assert-Far $data2.Age -eq 2 16 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/DropDownOpeningEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// event arguments. 9 | /// 10 | /// Control which drop down is opening. 11 | public sealed class DropDownOpeningEventArgs(IControl control) : AnyEventArgs(control) 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /GitKit/GitKit.macro.lua: -------------------------------------------------------------------------------- 1 | -- GitKit sample macros 2 | 3 | Event { 4 | group = "FolderChanged"; description = "GitKit setenv"; 5 | action = function() Plugin.SyncCall("10435532-9BB3-487B-A045-B0E6ECAAB6BC", [[gk:setenv name=_branch]]) end; 6 | } 7 | 8 | Macro { 9 | area="Common"; key="CtrlShiftB"; description = "GitKit setenv"; 10 | action = function() Plugin.SyncCall("10435532-9BB3-487B-A045-B0E6ECAAB6BC", [[gk:setenv name=_branch]]) end; 11 | } 12 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-160904.Editor.Complete.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | # kill test file 3 | Remove-Item c:/tmp/tmp.fsx* 4 | job { 5 | Open-FarEditor c:/tmp/tmp.fsx -DisableHistory 6 | } 7 | macro "print'Micros' -- type text" 8 | macro "Keys'Tab' -- complete" 9 | job { 10 | #! fixed 11 | Assert-Far $Far.Editor.GetText() -eq 'Microsoft' 12 | } 13 | macro "Keys'Esc n' -- exit" 14 | job { 15 | Assert-Far (![IO.File]::Exists('c:/tmp/tmp.fsx')) 16 | } 17 | -------------------------------------------------------------------------------- /JavaScriptFar/Tests/input-output.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | run { 3 | $Far.InvokeCommand("js:@ $env:FarNetCode\JavaScriptFar\Samples\input-output.js") 4 | } 5 | job { 6 | Assert-Far -Dialog 7 | Assert-Far $Far.Dialog[1].Text -eq 'Enter your name' 8 | Assert-Far $Far.Dialog[2].Text -eq 'John Doe' 9 | 10 | $Far.Dialog[2].Text = 'Foo Bar' 11 | $Far.Dialog.Close() 12 | } 13 | job { 14 | Assert-Far $Far.UI.GetBufferLineText(-2) -eq 'Hello, Foo Bar' 15 | } 16 | -------------------------------------------------------------------------------- /GitKit/Tests/FSF/PanelCommit.fsx: -------------------------------------------------------------------------------- 1 | // get panel cursor commit 2 | 3 | open FarNet 4 | open GitKit 5 | open LibGit2Sharp 6 | 7 | do 8 | let panel = Api.CommitsPanel() 9 | let file = panel.CurrentFile :?> Panels.CommitFile 10 | 11 | use repo = panel.UseRepository() 12 | let commit = repo.Lookup(file.CommitSha) 13 | 14 | User.Data["PanelCommit"] <- {| 15 | Author = commit.Author 16 | Message = commit.Message 17 | |} 18 | -------------------------------------------------------------------------------- /Samples/Tests/Test-RegisterTool.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Shows how to register tools dynamically. 4 | 5 | .Description 6 | Steps: 7 | - invoke this script to register the tool 8 | - try it in F11 menus 9 | #> 10 | 11 | Register-FarTool -Options F11Menus 'PSF test tool' f2a1fc38-35d0-4546-b67c-13d8bb93fa2e { 12 | Show-FarMessage "Hello from $($_.From)" 13 | } 14 | 15 | Show-FarMessage "Tool 'PSF test tool' is registered. Try it in F11 menus, e.g. now." 16 | -------------------------------------------------------------------------------- /Test/Basics.Posts/PostStep-rec.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $global:tcs = [System.Threading.Tasks.TaskCompletionSource[object]]::new() 4 | $global:log = 'do1/' 5 | $Far.PostStep({ 6 | $global:log += 'do2/' 7 | $Far.PostStep({ 8 | $global:log += 'do3/' 9 | $global:tcs.SetResult($null) 10 | }) 11 | }) 12 | $global:tcs.Task 13 | } 14 | job { 15 | Assert-Far $global:log -eq 'do1/do2/do3/' 16 | Remove-Variable log, tcs -Scope global 17 | } 18 | -------------------------------------------------------------------------------- /Test/Dialog/2024-02-04-IEdit-set-IsPath.fas.ps1: -------------------------------------------------------------------------------- 1 | # Fixed Far 3.0.6268 https://github.com/FarGroup/FarManager/issues/790 2 | 3 | run { 4 | $dialog = $Far.CreateDialog(-1, -1, 52, 3) 5 | $edit = $dialog.AddEdit(1, 1, 50, 'my-text') 6 | $null = $dialog.Show() 7 | } 8 | 9 | keys Del 10 | 11 | job { 12 | Assert-Far $__.Focused.Text -eq '' 13 | $__.Focused.IsPath = $true 14 | Assert-Far $__.Focused.Text -eq '' #! used to be my-text 15 | 16 | $__.Close() 17 | } 18 | -------------------------------------------------------------------------------- /FarNet/FarNet/Works/Abc.cs: -------------------------------------------------------------------------------- 1 | namespace FarNet.Works; 2 | #pragma warning disable 1591 3 | 4 | public static class Abc 5 | { 6 | // Gets property value if any or null. 7 | public static object? TryProperty(this object obj, string name) 8 | { 9 | try 10 | { 11 | var meta = obj.GetType().GetProperty(name); 12 | return meta?.GetValue(obj); 13 | } 14 | catch (Exception ex) 15 | { 16 | Log.TraceException(ex); 17 | return null; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PowerShellFar/Works/RunArgs.cs: -------------------------------------------------------------------------------- 1 | namespace PowerShellFar; 2 | 3 | class RunArgs(string code) 4 | { 5 | public string Code { get; } = code; 6 | 7 | public AbcOutputWriter? Writer { get; set; } 8 | 9 | public bool NoOutReason { get; set; } 10 | 11 | public bool UseLocalScope { get; set; } 12 | 13 | public bool UseTeeResult { get; set; } 14 | 15 | public object[]? Arguments { get; set; } 16 | 17 | public Exception? Reason { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /Test/Panels.Object/Test_211231_2g_PSCustomObject.fas.ps1: -------------------------------------------------------------------------------- 1 | #_211231_2g PSCustomObject used to be lost on unwrapping PSObject. 2 | 3 | job { 4 | [PSCustomObject]@{ 5 | q1 = [PSCustomObject]@{q2 = 42} 6 | } | 7 | Out-FarPanel 8 | } 9 | 10 | job { 11 | Find-FarFile '@{q2=42}' 12 | } 13 | 14 | keys Enter 15 | 16 | job { 17 | Find-FarFile q1 18 | 19 | #! used to be empty 20 | Assert-Far -FileDescription '@{q2=42}' 21 | } 22 | 23 | keys ShiftEsc 24 | -------------------------------------------------------------------------------- /FSharpFar/tests/.fs.ini: -------------------------------------------------------------------------------- 1 | [use] 2 | ..\samples\Async\.fs.ini 3 | ..\samples\PanelEditFile\PanelEditFile.fs.ini 4 | %FARHOME%\FarNet\Lib\FarNet.FSharp.Unquote\FarNet.FSharp.Unquote.ini 5 | 6 | [fsc] 7 | AutoTest.fs 8 | TestCase01.fs 9 | TestDialog.fs 10 | TestError.fs 11 | TestModal.fs 12 | TestPanel01.fs 13 | TestPanel02.fs 14 | TestPanelEditFile.fs 15 | TestParallel.fs 16 | TestPSFar.fs 17 | TestTasks.fs 18 | TestViewer.fs 19 | TestWizard.fs 20 | 21 | [out] 22 | -o:c:\temp\z.dll 23 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/LibInIni/LibInIni.fsx: -------------------------------------------------------------------------------- 1 | (* 2 | Our config must be used on getting options from script. This test sets 3 | `--lib` in the config file -> `#r "PowerShellFar.dll"` should work. 4 | 5 | NB Use full paths for `--lib` to avoid problems. F# looks for DLLs in lib 6 | paths but it does not combine lib paths in the same way. 7 | *) 8 | 9 | #r "PowerShellFar.dll" 10 | open PowerShellFar 11 | 12 | Settings.Default.CommandForegroundColor 13 | -------------------------------------------------------------------------------- /FarNet/FarNet/About/KeyEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FarNet; 4 | 5 | /// 6 | /// Arguments of key events. 7 | /// 8 | /// Key data. 9 | public sealed class KeyEventArgs(KeyInfo key) : EventArgs 10 | { 11 | /// 12 | /// Key data. 13 | /// 14 | public KeyInfo Key { get; } = key; 15 | 16 | /// 17 | /// Ignore event. 18 | /// 19 | public bool Ignore { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /FarNet/FarNet/Panel/PanelEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Panel event arguments. 11 | /// 12 | public class PanelEventArgs : EventArgs 13 | { 14 | /// 15 | /// Tells that a job is done or an action has to be ignored, it depends on the event. 16 | /// 17 | public bool Ignore { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /Modules/FarNet.Demo/FarNet.Demo.restext: -------------------------------------------------------------------------------- 1 | 2 | # Strings translated into other languages, see .ru.restext 3 | MenuTitle=Tracing 4 | itemShowFile=&*. View tracing 5 | itemListener=&0. Tracing to the file 6 | itemWarning=&1. Warnings and errors 7 | itemInformation=&2. Information 8 | itemVerbose=&3. Verbose 9 | itemAll=&4. All 10 | BadResources=This is not a resource file. 11 | 12 | # Invariant strings may be included to this file only 13 | SomeInvariantString={0}, {1}! 14 | -------------------------------------------------------------------------------- /RedisKit/Commands/AbcCommand.cs: -------------------------------------------------------------------------------- 1 | namespace RedisKit.Commands; 2 | 3 | abstract class AbcCommand 4 | { 5 | public static class Param 6 | { 7 | public const string Colon = "Colon"; 8 | public const string DB = "DB"; 9 | public const string Eol = "Eol"; 10 | public const string Key = "Key"; 11 | public const string Mask = "Mask"; 12 | public const string Redis = "Redis"; 13 | public const string Root = "Root"; 14 | } 15 | 16 | public abstract void Invoke(); 17 | } 18 | -------------------------------------------------------------------------------- /RedisKit/Commands/KeysCommand.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using RedisKit.Panels; 3 | 4 | namespace RedisKit.Commands; 5 | 6 | sealed class KeysCommand : BaseCommand 7 | { 8 | readonly string? _mask; 9 | 10 | public KeysCommand(CommandParameters parameters) : base(parameters) 11 | { 12 | _mask = parameters.GetString(Param.Mask); 13 | } 14 | 15 | public override void Invoke() 16 | { 17 | new KeysExplorer(Database, _mask) 18 | .CreatePanel() 19 | .Open(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Samples/Tests/Test-TrimEnd.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Removes end spaces from the input objects property Text 4 | 5 | .Description 6 | Processes any input objects with the string property Text. 7 | Examples: 8 | $Far.Editor.Lines | Test-TrimEnd.ps1 9 | $Far.Editor.SelectedLines | Test-TrimEnd.ps1 10 | #> 11 | 12 | process { 13 | $text1 = $_.Text 14 | $text2 = $text1.TrimEnd() 15 | if (![object]::ReferenceEquals($text1, $text2)) { 16 | $_.Text = $text2 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FarNet/FarNetMan/Export.def: -------------------------------------------------------------------------------- 1 | LIBRARY FarNetMan 2 | EXPORTS 3 | GetGlobalInfoW 4 | ClosePanelW 5 | ConfigureW 6 | DeleteFilesW 7 | ExitFARW 8 | FreeFindDataW 9 | GetFilesW 10 | GetFindDataW 11 | GetOpenPanelInfoW 12 | GetPluginInfoW 13 | OpenW 14 | ProcessEditorEventW 15 | ProcessEditorInputW 16 | ProcessPanelEventW 17 | ProcessPanelInputW 18 | ProcessSynchroEventW 19 | ProcessViewerEventW 20 | PutFilesW 21 | SetDirectoryW 22 | SetStartupInfoW 23 | -------------------------------------------------------------------------------- /JavaScriptFar/Tests/session-parameter.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | #! normal root of main session 4 | $Far.InvokeCommand("js: _220807_1300 = 42 :: _session=$env:FARPROFILE\FarNet\JavaScriptFar") 5 | } 6 | 7 | job { 8 | #! path with slashes is resolved to main session (test same variable) 9 | $Far.InvokeCommand("js: _220807_1300 + 42 :: _session=$env:FARPROFILE/FarNet/JavaScriptFar") 10 | } 11 | 12 | job { 13 | Assert-Far $Far.UI.GetBufferLineText(-2) -eq '84' 14 | } 15 | -------------------------------------------------------------------------------- /FarNet/FarNet/About/IFace.cs: -------------------------------------------------------------------------------- 1 | using FarNet.Forms; 2 | 3 | namespace FarNet; 4 | 5 | /// 6 | /// Common for , , , . 7 | /// 8 | public interface IFace 9 | { 10 | /// 11 | /// Gets the identifier. 12 | /// 13 | public nint Id { get; } 14 | 15 | /// 16 | /// Gets the window kind. 17 | /// 18 | public WindowKind WindowKind { get; } 19 | } 20 | -------------------------------------------------------------------------------- /JsonKit/Tests/1-open-array.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $Far.InvokeCommand('jk:open file=x-array.json') 4 | } 5 | 6 | job { 7 | Assert-Far -Plugin 8 | Assert-Far $Far.Panel.Title -eq 'Array $' 9 | } 10 | 11 | job { 12 | Find-FarFile '"текст"' 13 | } 14 | 15 | keys F4 16 | 17 | job { 18 | Assert-Far -Editor 19 | Assert-Far $Far.Editor.Title -eq '"текст"' 20 | Assert-Far $Far.Editor[0].Text -eq 'текст' 21 | $Far.Editor.Close() 22 | } 23 | 24 | job { 25 | $Far.Panel.Close() 26 | } 27 | -------------------------------------------------------------------------------- /RedisKit/Panels/BaseExplorer.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using StackExchange.Redis; 3 | 4 | namespace RedisKit.Panels; 5 | 6 | abstract class BaseExplorer(IDatabase database, Guid typeId) : Explorer(typeId) 7 | { 8 | public IDatabase Database { get; } = database; 9 | 10 | public IServer GetServer() => 11 | DB.GetServer(Database); 12 | 13 | protected abstract string PanelTitle(); 14 | 15 | public override void EnterPanel(Panel panel) 16 | { 17 | panel.Title = PanelTitle(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Samples/FarTask/Case/dump-variables.far.ps1: -------------------------------------------------------------------------------- 1 | 2 | Start-FarTask { 3 | Get-Variable -Scope 0 | Select-Object Name, Options | Export-Csv z.task.0.csv 4 | Get-Variable -Scope 1 | Select-Object Name, Options | Export-Csv z.task.1.csv 5 | Get-Variable | Select-Object Name, Options | Export-Csv z.task.2.csv 6 | job { 7 | Get-Variable -Scope 0 | Select-Object Name, Options | Export-Csv z.job.0.csv 8 | Get-Variable -Scope 1 | Select-Object Name, Options | Export-Csv z.job.1.csv 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Samples/Tests/Test-RegisterCommand.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Shows how to register commands dynamically. 4 | 5 | .Description 6 | Steps: 7 | - invoke this script to register the command 8 | - type in the command line 9 | mycmd: 10 | #> 11 | 12 | Register-FarCommand -Prefix mycmd 'PSF test command' 053a9a98-db98-415c-9c80-88eee2f336ae { 13 | Show-FarMessage ($_ | Format-List | Out-String).Trim() 14 | } 15 | 16 | Show-FarMessage 'Command prefix "mycmd:" is registered.' 17 | -------------------------------------------------------------------------------- /FSharpFar/src/fsx/.build.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Build script (https://github.com/nightroman/Invoke-Build) 4 | #> 5 | 6 | param( 7 | $FarHome = (property FarHome C:\Bin\Far\x64), 8 | $Configuration = (property Configuration Release) 9 | ) 10 | 11 | task build { 12 | exec {dotnet build /p:FarHome=$FarHome /p:Configuration=$Configuration} 13 | } 14 | 15 | task clean { 16 | remove bin, obj 17 | } 18 | 19 | task test { 20 | Invoke-Build ** Tests 21 | } 22 | 23 | task . build, test, clean 24 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/SpecialFolder.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Special folder constants. 9 | /// 10 | public enum SpecialFolder 11 | { 12 | /// 13 | /// Local data folder, %FARLOCALPROFILE%. 14 | /// 15 | LocalData = 0, 16 | 17 | /// 18 | /// Roaming data folder, %FARPROFILE%. 19 | /// 20 | RoamingData = 1 21 | } 22 | -------------------------------------------------------------------------------- /Modules/Script/Script.lua: -------------------------------------------------------------------------------- 1 | 2 | Macro { 3 | area="Editor"; key="CtrlShiftF9"; description="Escape"; 4 | action=function() 5 | Plugin.Call("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "fn: script=Script; method=Script.Editor.Escape") 6 | end; 7 | } 8 | 9 | Macro { 10 | area="Editor"; key="CtrlShiftF9"; description="Unescape"; 11 | action=function() 12 | Plugin.Call("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "fn: script=Script; method=Script.Editor.Unescape") 13 | end; 14 | } 15 | -------------------------------------------------------------------------------- /Modules/ScriptPS/README.md: -------------------------------------------------------------------------------- 1 | # FarNet script using PowerShell 2 | 3 | Requires `FarNet.PowerShellFar` either for pure PowerShell or PowerShellFar sessions. 4 | 5 | The project file `ScriptPS.csproj` shows how to reference `System.Management.Automation.dll`. 6 | 7 | FarNet command for testing 8 | 9 | ``` 10 | fn: script=ScriptPS; method=Message ;; name=John Doe; age=42 11 | ``` 12 | 13 | See also: 14 | 15 | - [Script in CSharp](../Script) 16 | - [Script in FSharp](../ScriptFS) 17 | -------------------------------------------------------------------------------- /Test/Dialog/2022-02-21-Initialized.fas.ps1: -------------------------------------------------------------------------------- 1 | # https://forum.farmanager.com/viewtopic.php?t=12755 2 | # FarNet 5.8.3 3 | 4 | run { 5 | $dialog = $Far.CreateDialog(-1, -1, 52, 3) 6 | $edit = $dialog.AddEdit(1, 1, 50, '') 7 | $dialog.add_Initialized({ 8 | $edit.Text = 'my edit' 9 | $edit.Line.Caret = 3 10 | }) 11 | $null = $dialog.Show() 12 | } 13 | 14 | job { 15 | Assert-Far -Dialog 16 | Assert-Far $__[0].Text -eq 'my edit' 17 | Assert-Far $__[0].Line.Caret -eq 3 18 | $__.Close() 19 | } 20 | -------------------------------------------------------------------------------- /Test/Panels/Test-FormatPanel.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $r = [System.Management.ManagementObjectSearcher]::new("SELECT * FROM Win32_Process WHERE ProcessId = $PID").Get()[0] 4 | $r | Out-FarPanel 5 | } 6 | job { 7 | $Columns = $__.GetPlan(0).Columns 8 | Assert-Far $Columns.Count -eq $Psf.Settings.MaximumPanelColumnCount 9 | Assert-Far @( 10 | $Columns[0].Name -eq 'Name' 11 | $Columns[1].Name -eq 'Description' 12 | $Columns[2].Name -eq 'Status' 13 | ) 14 | $__.Close() 15 | } 16 | -------------------------------------------------------------------------------- /Zoo/Test-Install-FarPackage/.build.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | NuGet 4.6.0 does not encode file names as URLs. 3 | https://github.com/NuGet/NuGetGallery/issues/7955 4 | Thus, System.IO.Packaging misses some files and we use System.IO.Compression instead. 5 | FarPackage works again, good, but it looks like unusual file names are better be avoided. 6 | #> 7 | 8 | task clean { 9 | remove C:\TEMP\FarHome, z, z.*, NR.Try.*.nupkg 10 | } 11 | 12 | task test { 13 | Invoke-Build ** 14 | } 15 | 16 | task . test, clean 17 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/README.md: -------------------------------------------------------------------------------- 1 | # JavaScript samples 2 | 3 | Scripts in this folder show main features. 4 | 5 | See other folders for advanced features: 6 | 7 | - [async](async) - async, task, promise, etc. samples 8 | - [config](config) - what configuration files can do 9 | - [events](events) - editor events, session script 10 | - [extras](extras) - special cases and techniques 11 | - [interop](interop) - PowerShell calls JavaScript 12 | - [modules](modules) - Standard/CommonJS modules 13 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/interop/app2.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Runs JavaScript scripts using JavaScriptFar interop. 4 | #> 5 | 6 | # step 1: get the function to run scripts 7 | $EvaluateDocument = $Far.GetModuleInterop('JavaScriptFar', 'EvaluateDocument', $null) 8 | 9 | ### step 2: run scripts with parameters 10 | $user = $EvaluateDocument.Invoke("$PSScriptRoot\input.js", $null) 11 | if ($user) { 12 | $null = $EvaluateDocument.Invoke("$PSScriptRoot\message.js", @{user = $user}) 13 | } 14 | -------------------------------------------------------------------------------- /FSharpFar/src/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "windows": { 4 | "options": { 5 | "shell": { 6 | "executable": "cmd.exe", 7 | "args": [ "/c" ] 8 | } 9 | } 10 | }, 11 | "tasks": [ 12 | { 13 | "label": "build", 14 | "type": "shell", 15 | "group": { 16 | "kind": "build", 17 | "isDefault": true 18 | }, 19 | "problemMatcher": [ "$msCompile" ], 20 | "command": "dotnet build" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /FarNet/FarNet/FarNetApi.build.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Build script, https://github.com/nightroman/Invoke-Build 4 | #> 5 | 6 | param( 7 | $Platform = (property Platform x64), 8 | $FarHome = (property FarHome "C:\Bin\Far\$Platform"), 9 | $Configuration = (property Configuration Release) 10 | ) 11 | 12 | $fa_outdir = "$FarHome\FarNet" 13 | 14 | task clean { 15 | remove bin, obj 16 | } 17 | 18 | task install 19 | 20 | task uninstall { 21 | remove "$fa_outdir\FarNet.dll", "$fa_outdir\FarNet.xml" 22 | } 23 | -------------------------------------------------------------------------------- /PowerShellFar/Panels/TableExplorer.cs: -------------------------------------------------------------------------------- 1 | 2 | // PowerShellFar module for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using FarNet; 6 | using System; 7 | 8 | namespace PowerShellFar; 9 | 10 | /// 11 | /// Abstract table explorer. 12 | /// 13 | /// 14 | public abstract class TableExplorer(Guid typeId) : PowerExplorer(typeId) 15 | { 16 | /// 17 | internal virtual object[]? Columns { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/ViewerViewMode.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Viewer modes. 9 | /// 10 | public enum ViewerViewMode 11 | { 12 | /// 13 | /// Text view mode. 14 | /// 15 | Text, 16 | 17 | /// 18 | /// Hex view mode. 19 | /// 20 | Hex, 21 | 22 | /// 23 | /// Dump view mode. 24 | /// 25 | Dump 26 | } 27 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/CloneFileEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Clone file arguments. 9 | /// 10 | /// See 11 | /// See 12 | public sealed class CloneFileEventArgs(ExplorerModes mode, FarFile file) : ExplorerFileEventArgs(mode, file) 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/RenameFileEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Rename file arguments. 9 | /// 10 | /// See 11 | /// See 12 | public sealed class RenameFileEventArgs(ExplorerModes mode, FarFile file) : ExplorerFileEventArgs(mode, file) 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/IComboBox.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// Combo box control. 9 | /// It is created and added to a dialog by . 10 | /// 11 | public interface IComboBox : IBaseList, IEditable, IDropDown 12 | { 13 | /// 14 | /// Tells to be a non editable drop down list. 15 | /// 16 | bool DropDownList { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /JavaScriptFar/ExecuteArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // JavaScriptFar module for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | using System.Collections; 7 | 8 | namespace JavaScriptFar; 9 | 10 | class ExecuteArgs 11 | { 12 | public string? Command { get; set; } 13 | public string? Document { get; set; } 14 | public bool IsTask { get; set; } 15 | public bool IsDebug { get; set; } 16 | public Action? Print { get; set; } 17 | public IDictionary? Parameters { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /Samples/Tests/Test-Panel-DBCategories.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Test panel with simple table TestCategories. 4 | 5 | .Description 6 | How to use Panel-DBData to browse a data table. 7 | #> 8 | 9 | [CmdletBinding()] 10 | param( 11 | $Lookup 12 | ) 13 | 14 | if (!$PSCmdlet.GetVariableValue('DbConnection')) { 15 | & $PSScriptRoot\Initialize-Test.far.ps1 16 | } 17 | 18 | Panel-DBData -Lookup $Lookup -Title TestCategories -TableName TestCategories -Columns Category, Remarks -ExcludeMemberPattern '^CategoryId$' 19 | -------------------------------------------------------------------------------- /Test/Panels/Test-z_230805_1220_Closure.fas.ps1: -------------------------------------------------------------------------------- 1 | # 230805_1220 2 | 3 | job { 4 | #! Use as script. If the code is here then the case is not reproducible. 5 | & "$PSScriptRoot\Test-z_230805_1220_Closure.far.ps1" 6 | } 7 | 8 | job { 9 | Assert-Far "$($global:Error[0])" -eq 'You cannot call a method on a null-valued expression.' 10 | 11 | $file = $__.Files[1] 12 | Assert-Far $file.Name -eq $null 13 | Assert-Far $file.Description -eq '12345' 14 | 15 | $__.Close() 16 | $global:Error.Clear() 17 | } 18 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/README.md: -------------------------------------------------------------------------------- 1 | # JavaScript modules 2 | 3 | Main samples: 4 | 5 | - [CommonJS](CommonJS) - CommonJS modules and session configured as CommonJS 6 | - [Standard](Standard) - Standard modules and session configured as Standard 7 | 8 | Mixed sample: 9 | 10 | - [use-mix](use-mix) - P.O.C. mixed modules in a session 11 | 12 | This folder: 13 | 14 | - [try.cjs](try.cjs) always works as CommonJS module due to .cjs 15 | - [try.mjs](try.mjs) always works as Standard module due to .mjs 16 | -------------------------------------------------------------------------------- /Modules/Backslash/1.build.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Build script, https://github.com/nightroman/Invoke-Build 4 | #> 5 | 6 | param( 7 | $FarHome = (property FarHome C:\Bin\Far\x64), 8 | $Configuration = (property Configuration Release), 9 | $FarNetModules = (property FarNetModules $FarHome\FarNet\Modules) 10 | ) 11 | 12 | task build { 13 | exec { dotnet build -c $Configuration /p:FarHome=$FarHome /p:FarNetModules=$FarNetModules} 14 | } 15 | 16 | task clean { 17 | remove bin, obj 18 | } 19 | 20 | task . build, clean 21 | -------------------------------------------------------------------------------- /Test/Basics.Posts/PostJob-rec.fas.ps1: -------------------------------------------------------------------------------- 1 | #! how to use TaskCompletionSource to sync steps and jobs 2 | 3 | job { 4 | $global:tcs = [System.Threading.Tasks.TaskCompletionSource[object]]::new() 5 | $global:log = 'do1/' 6 | $Far.PostJob({ 7 | $global:log += 'do2/' 8 | $Far.PostJob({ 9 | $global:log += 'do3/' 10 | $global:tcs.SetResult($null) 11 | }) 12 | }) 13 | $global:tcs.Task 14 | } 15 | job { 16 | Assert-Far $global:log -eq 'do1/do2/do3/' 17 | Remove-Variable log, tcs -Scope global 18 | } 19 | -------------------------------------------------------------------------------- /FarNet/FarNet/Settings/ModuleSettingsArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Settings arguments. 9 | /// 10 | public class ModuleSettingsArgs 11 | { 12 | /// 13 | /// Tells to use the local settings file. 14 | /// 15 | public bool IsLocal { get; set; } 16 | 17 | /// 18 | /// Tells to use the spefified file path. 19 | /// 20 | public string? FileName { get; set; } 21 | } 22 | -------------------------------------------------------------------------------- /HelpDown/HtmlToFarHelp/Types.cs: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (c) Roman Kuzmin 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | namespace HtmlToFarHelp 6 | { 7 | enum ListKind 8 | { 9 | Ordered, 10 | Unordered, 11 | Definition 12 | } 13 | 14 | class ListInfo 15 | { 16 | public ListKind Kind { get; private set; } 17 | public int Item; 18 | public int ItemCount; 19 | public int TermCount; 20 | public int CountParaInItem; 21 | public ListInfo(ListKind kind) 22 | { 23 | Kind = kind; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JavaScriptFar/Tests/interop-psf.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | $Data.FileName = "$env:FarNetCode\JavaScriptFar\Samples\interop-psf.js" 3 | job { 4 | Open-FarEditor $Data.FileName -DisableHistory 5 | } 6 | job { 7 | Assert-Far -Editor 8 | Assert-Far $Far.Editor.FileName -eq $Data.FileName 9 | } 10 | keys F5 11 | job { 12 | Assert-Far -Editor 13 | Assert-Far $Far.Editor.Title -eq 'JavaScript result' 14 | Assert-Far $Far.Editor[0].Text -eq '{' 15 | Assert-Far ($Far.Editor[1].Text -like ' "*":*,') 16 | } 17 | keys Esc Esc 18 | -------------------------------------------------------------------------------- /Modules/TryPanelCSharp/1.build.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Build script, https://github.com/nightroman/Invoke-Build 4 | #> 5 | 6 | param( 7 | $FarHome = (property FarHome C:\Bin\Far\x64), 8 | $Configuration = (property Configuration Release), 9 | $FarNetModules = (property FarNetModules $FarHome\FarNet\Modules) 10 | ) 11 | 12 | task build { 13 | exec { dotnet build -c $Configuration /p:FarHome=$FarHome /p:FarNetModules=$FarNetModules } 14 | } 15 | 16 | task clean { 17 | remove bin, obj 18 | } 19 | 20 | task . build, clean 21 | -------------------------------------------------------------------------------- /RedisKit/Commands/SetCommand.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using RedisKit.Panels; 3 | using StackExchange.Redis; 4 | 5 | namespace RedisKit.Commands; 6 | 7 | sealed class SetCommand : BaseCommand 8 | { 9 | readonly RedisKey _key; 10 | 11 | public SetCommand(CommandParameters parameters) : base(parameters) 12 | { 13 | _key = GetRequiredRedisKeyOfType(parameters, RedisType.Set); 14 | } 15 | 16 | public override void Invoke() 17 | { 18 | new SetExplorer(Database, _key) 19 | .CreatePanel() 20 | .Open(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Modules/XGraphQL/README.md: -------------------------------------------------------------------------------- 1 | # FarNet script XGraphQL 2 | 3 | XGraphQL provides methods for GraphQL source code. 4 | 5 | **Format the file in panels or text in editor** 6 | 7 | See [Format.cs](Format.cs) for available parameters. 8 | 9 | ``` 10 | fn: script=XGraphQL; method=.Format.GraphQL 11 | ``` 12 | 13 | **Add undefined types as scalars** 14 | 15 | ``` 16 | fn: script=XGraphQL; method=.Add.UndefinedTypes 17 | ``` 18 | 19 | **Note** 20 | 21 | For complex commands use command files 22 | 23 | ``` 24 | fn:@ 25 | ``` 26 | -------------------------------------------------------------------------------- /RedisKit/Commands/ListCommand.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using RedisKit.Panels; 3 | using StackExchange.Redis; 4 | 5 | namespace RedisKit.Commands; 6 | 7 | sealed class ListCommand : BaseCommand 8 | { 9 | readonly RedisKey _key; 10 | 11 | public ListCommand(CommandParameters parameters) : base(parameters) 12 | { 13 | _key = GetRequiredRedisKeyOfType(parameters, RedisType.List); 14 | } 15 | 16 | public override void Invoke() 17 | { 18 | new ListExplorer(Database, _key) 19 | .CreatePanel() 20 | .Open(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Modules/Script/Script.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | C:\Bin\Far\x64 4 | $(FarHome)\FarNet\Scripts\$(AssemblyName) 5 | false 6 | net10.0 7 | 8 | 9 | 10 | False 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | trim_trailing_whitespace = true 7 | indent_style = tab 8 | tab_width = 4 9 | 10 | [*.{fs,fsx,fsi,js,md,text,help.txt,COMMIT_EDITMSG}] 11 | indent_style = space 12 | indent_size = 4 13 | 14 | [*.{json,xml,*proj,hrc,hrd,lua}] 15 | indent_style = space 16 | indent_size = 2 17 | 18 | [*.{h,cpp}] 19 | cpp_indent_namespace_contents = false 20 | 21 | [*.cs] 22 | dotnet_diagnostic.IDE0008.severity = none 23 | dotnet_diagnostic.IDE0130.severity = none 24 | -------------------------------------------------------------------------------- /GitKit/Tests/commits.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | ### commits panel 3 | job { 4 | $Far.InvokeCommand("gk:commits repo=$PSScriptRoot") 5 | } 6 | 7 | job { 8 | Assert-Far $Far.Panel.GetType().Name -eq CommitsPanel 9 | } 10 | 11 | ### test F# 12 | job { 13 | $Far.InvokeCommand("fs:exec file=FSF\PanelCommit.fsx") 14 | Assert-Far ([FarNet.User]::Data["PanelCommit"].Author.Email.Contains('@')) 15 | } 16 | 17 | ### changes panel 18 | keys Enter 19 | job { 20 | Assert-Far $Far.Panel.GetType().Name -eq ChangesPanel 21 | } 22 | keys ShiftEsc 23 | -------------------------------------------------------------------------------- /Test/Dialog/Test-ProgressForm-99percent.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | At 99% keep 1 slot not filled 4 | #> 5 | 6 | run { 7 | $Var.progress = $progress = [FarNet.Tools.ProgressForm]::new() 8 | $progress.CanCancel = $true 9 | $done = $progress.Show() 10 | } 11 | 12 | # set progress async and let it update 13 | $progress.SetProgressValue(99, 100) 14 | Start-Sleep -Milliseconds 300 15 | 16 | job { 17 | Assert-Far $__[2].Text.StartsWith('█████████████████████████████████████████████████████████████░') 18 | $__.Close() 19 | } 20 | -------------------------------------------------------------------------------- /Test/Host/Test-CC-KeyF4.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | F3/F4 in command console. 4 | #> 5 | 6 | ### init 7 | job { $__.GoToPath($PSCommandPath) } 8 | job { $Psf.RunCommandConsole() } 9 | 10 | ### F4 11 | keys F4 12 | job { 13 | Assert-Far -Editor 14 | $__.SetText("'text from editor'") 15 | $__.Save() 16 | $__.Close() 17 | } 18 | 19 | job { 20 | Assert-Far -DialogTypeId ([PowerShellFar.Guids]::ReadCommandDialog) 21 | Assert-Far $Far.Dialog[1].Text -eq "'text from editor'" 22 | $Far.Dialog[1].Text = '' 23 | } 24 | 25 | keys Esc # exit CC 26 | -------------------------------------------------------------------------------- /Zoo/Test-NuGet-FarNet.txt: -------------------------------------------------------------------------------- 1 | FarHome 2 | FarHome.x64 3 | FarHome.x64\Plugins 4 | FarHome.x64\Plugins\FarNet 5 | FarHome.x64\Plugins\FarNet\FarNetMan.dll 6 | FarHome.x64\Plugins\FarNet\Ijwhost.dll 7 | FarHome\FarNet 8 | FarHome\FarNet\About-FarNet.html 9 | FarHome\FarNet\FarNet.dll 10 | FarHome\FarNet\FarNet.xml 11 | FarHome\FarNet\FarNetAPI.chm 12 | FarHome\FarNet\History.txt 13 | FarHome\FarNet\LICENSE 14 | FarHome\Plugins 15 | FarHome\Plugins\FarNet 16 | FarHome\Plugins\FarNet\FarNetMan.hlf 17 | FarHome\Plugins\FarNet\FarNetMan.runtimeconfig.json 18 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/DrawingEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// event arguments. 9 | /// 10 | /// Control that is about to be drawn. 11 | public sealed class DrawingEventArgs(IControl control) : AnyEventArgs(control) 12 | { 13 | /// 14 | /// Ingore and don't draw the control. 15 | /// 16 | public bool Ignore { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/InitializedEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// event arguments. 9 | /// 10 | /// Control that will initially receive focus. 11 | public sealed class InitializedEventArgs(IControl focused) : AnyEventArgs(focused) 12 | { 13 | /// 14 | /// Ingore changes. 15 | /// 16 | public bool Ignore { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /FarNet/FarNet/Module/ModuleToolAttribute.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Module tool action attribute. 11 | /// 12 | [AttributeUsage(AttributeTargets.Class)] 13 | public sealed class ModuleToolAttribute : ModuleActionAttribute 14 | { 15 | /// 16 | /// The tool options with at least one target area specified. 17 | /// 18 | public ModuleToolOptions Options { get; set; } 19 | } 20 | -------------------------------------------------------------------------------- /GitKit/Tests/FSF/PanelBranch.fsx: -------------------------------------------------------------------------------- 1 | // get panel cursor branch 2 | 3 | open FarNet 4 | open GitKit 5 | open LibGit2Sharp 6 | 7 | do 8 | let panel = Api.BranchesPanel() 9 | let file = panel.CurrentFile :?> Panels.BranchFile 10 | 11 | use repo = panel.UseRepository() 12 | let branch = repo.Branches[file.Name] 13 | 14 | User.Data["PanelBranch"] <- {| 15 | FriendlyName = branch.FriendlyName 16 | RemoteName = branch.RemoteName 17 | Message = branch.Tip.Message 18 | Author = branch.Tip.Author 19 | |} 20 | -------------------------------------------------------------------------------- /Test/TabExpansion/Bad.ArgumentCompleters.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Bad completion profile. 4 | .Description 5 | -- Start Far 6 | -- Add this folder to the path 7 | -- Trigger any completion 8 | -- Examine $Error for issues 9 | #> 10 | 11 | ### Issue - unexpected output from profile 12 | 42 13 | 14 | $TabExpansionOptions.InputProcessors += { 15 | ### Issue - invalid input processor result 16 | 42 17 | } 18 | 19 | $TabExpansionOptions.ResultProcessors += { 20 | ### Issue - unexpected result processor output 21 | 42 22 | } 23 | -------------------------------------------------------------------------------- /FarNet/FarNet/Tools/Res.cs: -------------------------------------------------------------------------------- 1 | namespace FarNet.Tools; 2 | 3 | static class Res 4 | { 5 | public const string 6 | Search = "Search", 7 | SearchActivityRecurse = "Found {0} items in {1} directories.\n{2:n2} directory/second.", 8 | SearchActivityBfs = "Found {0} items in {1} directories, {2} in the queue.\n{3:n2} directory/second.", 9 | Searching = "Searching...", 10 | SearchTitle = "Found {0} items in {1} directories. {2}", 11 | StateCompleted = "Completed.", 12 | StateStopped = "Stopped.", 13 | StopSearch = "Stop search."; 14 | } 15 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/message-choice.js: -------------------------------------------------------------------------------- 1 | // A message box with custom buttons and the choice index result. 2 | // When run from editor by [F5], the result is shown in the title. 3 | 4 | function test() { 5 | const args = new clr.FarNet.MessageArgs 6 | args.Text = 'Hello from JavaScript!' 7 | args.Caption = 'JavaScript' 8 | args.Buttons = host.newArr(System.String, 3) 9 | args.Buttons[0] = '&Ready' 10 | args.Buttons[1] = '&Steady' 11 | args.Buttons[2] = '&Go' 12 | return far.Message(args) 13 | } 14 | 15 | test() 16 | -------------------------------------------------------------------------------- /JavaScriptFar/Tests/message-choice.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | $Data.FileName = "$env:FarNetCode\JavaScriptFar\Samples\message-choice.js" 3 | job { 4 | Open-FarEditor $Data.FileName -DisableHistory 5 | } 6 | job { 7 | Assert-Far -Editor 8 | Assert-Far $Far.Editor.FileName -eq $Data.FileName 9 | } 10 | keys F5 11 | job { 12 | Assert-Far -Dialog 13 | Assert-Far $Far.Dialog[1].Text -eq 'Hello from JavaScript!' 14 | } 15 | keys g 16 | job { 17 | Assert-Far -Editor 18 | Assert-Far $Far.Editor.Title -eq "2 -- $($Data.FileName)" 19 | } 20 | keys Esc 21 | -------------------------------------------------------------------------------- /JavaScriptFar/Tests/test-MyLibForJS.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | $dll = "$env:TEMP\MyLibForJS.dll" 3 | if (!(Test-Path $dll)) { 4 | #? cannot load if compile in PSCore, use v5 5 | powershell -Command $env:FarNetCode\JavaScriptFar\Samples\extras\test-MyLibForJS.ps1 6 | if ($LASTEXITCODE) {throw} 7 | } 8 | 9 | run { 10 | $Far.InvokeCommand("js:@ $env:FarNetCode\JavaScriptFar\Samples\extras\test-MyLibForJS.js") 11 | } 12 | job { 13 | Assert-Far -Dialog 14 | Assert-Far $Far.Dialog[1].Text -eq 'done Job1, done Job2' 15 | 16 | $Far.Dialog.Close() 17 | } 18 | -------------------------------------------------------------------------------- /Test/Basics.Tasks/Var.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | $var1 = 'some' 3 | 4 | ps: { 5 | # get existing 6 | Assert-Far $Var.var1 -eq some 7 | 8 | # set existing 9 | $Var.var1 = 'value1' 10 | Assert-Far $Var.var1 -eq value1 11 | 12 | # get missing 13 | Assert-Far $Var.var2 -eq $null 14 | 15 | # get missing in strict mode 16 | Set-StrictMode -Version 3 17 | Assert-Far $Var.var2 -eq $null 18 | 19 | # set missing 20 | $Var.var2 = 'value2' 21 | Assert-Far $Var.var2 -eq value2 22 | 23 | # calls GetEnumerator() 24 | ($r = Get-Variable -Scope 0 | Out-String) 25 | } 26 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/basic.test.ps1: -------------------------------------------------------------------------------- 1 | Set-StrictMode -Version 3 2 | 3 | task invalid-parameter-open { 4 | try { throw $Far.InvokeCommand("fs:project open=z") } 5 | catch { equals $_.Exception.InnerException?.Message "Command: project`r`nParameter 'open': Invalid value 'z'. Valid values: VS, VSCode." } 6 | } 7 | 8 | task invalid-parameter-type { 9 | try { throw $Far.InvokeCommand("fs:project type=z") } 10 | catch { equals $_.Exception.InnerException?.Message "Command: project`r`nParameter 'type': Invalid value 'z'. Valid values: Normal, Script." } 11 | } 12 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/PanelDotsMode.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Panel dots item modes. 9 | /// 10 | public enum PanelDotsMode 11 | { 12 | /// 13 | /// Add the dots item if the panel is a child panel. 14 | /// 15 | Auto, 16 | 17 | /// 18 | /// Always add the dots item. 19 | /// 20 | Dots, 21 | 22 | /// 23 | /// No dots item. 24 | /// 25 | Off 26 | } 27 | -------------------------------------------------------------------------------- /GitKit/Const.cs: -------------------------------------------------------------------------------- 1 | namespace GitKit; 2 | 3 | static class Const 4 | { 5 | public const string 6 | BlameFile = "&Blame file", 7 | CommitLog = "Commit lo&g", 8 | CompareBranches = "&Compare branches", 9 | CompareCommits = "&Compare commits", 10 | CopyInfoMenu = "Copy &info", 11 | CopyInfoTitle = "Copy info", 12 | CreateBranch = "Create branch", 13 | EditFile = "&Edit file", 14 | Help = "Help", 15 | MergeBranch = "&Merge branch", 16 | FinishBranch = "&Finish branch", 17 | NoBranchName = "(no branch)", 18 | PushBranch = "&Push branch"; 19 | } 20 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-160902.Close.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | macro @' 3 | Plugin.Menu("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "65BD5625-769A-4253-8FDE-FFCC3F72489D") 4 | Keys'1' -- open F# Interactive 5 | '@ 6 | job { 7 | Assert-Far -EditorTitle 'F# main.fs.ini *_??????_??????.interactive.fsx' 8 | } 9 | 10 | macro "Keys'Esc' -- exit to panels" 11 | 12 | #! must not try to close a closed editor 13 | macro @' 14 | Plugin.Menu("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "65BD5625-769A-4253-8FDE-FFCC3F72489D") 15 | Keys'0 Del Esc' -- kill session, exit menu 16 | '@ 17 | -------------------------------------------------------------------------------- /Samples/FarRedisTask/PingPong.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | How to use Send-FarRedisTask.ps1 4 | 5 | .Description 6 | Sending tasks between two paired Far instances without data. 7 | #> 8 | 9 | # send from this Far 1 to another Far 2 10 | Send-FarRedisTask { 11 | # show ping message in Far 2 12 | job { 13 | Show-FarMessage Ping 14 | } 15 | 16 | # send from Far 2 to Far 1 17 | Send-FarRedisTask { 18 | # show pong message in Far 1 19 | job { 20 | Show-FarMessage Pong 21 | } 22 | } 23 | 24 | # exit Far 2 25 | job { 26 | $Far.Quit() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /FarNet/FarNet/Works/Dialog/DialogTools.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using FarNet.Forms; 6 | using System.Collections.Generic; 7 | 8 | namespace FarNet.Works; 9 | #pragma warning disable 1591 10 | 11 | public static class DialogTools 12 | { 13 | public static IEnumerable GetControls(IDialog dialog) 14 | { 15 | for (int i = 0; ; ++i) 16 | { 17 | IControl control = dialog[i]; 18 | if (control == null) 19 | break; 20 | 21 | yield return control; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Modules/FarNet.Demo/Scripts/Settings.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | How to get, update, edit settings. 4 | 5 | .Description 6 | This script works with the static cached instance. 7 | 8 | PowerShellFar command: 9 | ps: .\Settings.far.ps1 10 | #> 11 | 12 | # load the library 13 | Add-Type -Path "$env:FARHOME\FarNet\Modules\FarNet.Demo\FarNet.Demo.dll" 14 | 15 | # get settings 16 | $settings = [FarNet.Demo.Settings]::Default 17 | $data = $settings.GetData() 18 | 19 | # update settings 20 | ++$data.Age 21 | $settings.Save() 22 | 23 | # edit settings 24 | $settings.Edit() 25 | -------------------------------------------------------------------------------- /Samples/Quit/README.md: -------------------------------------------------------------------------------- 1 | # "Quit()" method and handlers 2 | 3 | In order to tell Far to exit, use `$Far.Quit()`, either directly from scripts or by `[F10]` using macro: 4 | 5 | ```lua 6 | Macro { 7 | area="Shell"; key="F10"; description="PSF: Quit Far"; 8 | action=function() 9 | if not Plugin.Call("10435532-9BB3-487B-A045-B0E6ECAAB6BC", [[vps:$Far.Quit()]]) then Keys "F10" end 10 | end; 11 | } 12 | ``` 13 | 14 | **Samples** 15 | 16 | - [Quit-Running-FarTask.far.ps1](Quit-Running-FarTask.far.ps1) 17 | - [Register-Quitting-Once.far.ps1](Register-Quitting-Once.far.ps1) 18 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-160828.Command.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $Far.InvokeCommand('fs: let x = 42') 4 | 5 | $y = $Host.UI.RawUI.CursorPosition.Y 6 | $rect = New-Object System.Management.Automation.Host.Rectangle 0, ($y - 3), 20, ($y - 1) 7 | $buff = $Host.UI.RawUI.GetBufferContents($rect) 8 | $buff | Select-Object Character, ForegroundColor | Export-Csv -NoTypeInformation c:\temp\buffer.csv 9 | $md5 = (Get-FileHash C:\TEMP\buffer.csv -Algorithm MD5).Hash 10 | Assert-Far $md5 -eq '92ECA6CDC8B9C6BD33BF4B22A8BA881A' 11 | Remove-Item C:\TEMP\buffer.csv 12 | } 13 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/PanelKind.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Far panel kind. 9 | /// 10 | public enum PanelKind 11 | { 12 | /// 13 | /// File list. 14 | /// 15 | File, 16 | 17 | /// 18 | /// File tree. 19 | /// 20 | Tree, 21 | 22 | /// 23 | /// Quick view. 24 | /// 25 | QView, 26 | 27 | /// 28 | /// Information. 29 | /// 30 | Info 31 | } 32 | -------------------------------------------------------------------------------- /FarNet/FarNet/Panel/ViewChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Arguments of event. [FE_CHANGEVIEWMODE], [Column types]. 9 | /// 10 | /// See 11 | public sealed class ViewChangedEventArgs(string columns) : PanelEventArgs 12 | { 13 | /// 14 | /// Gets column kinds, e.g. N,S,D,T. 15 | /// 16 | public string Columns { get; } = columns; 17 | } 18 | -------------------------------------------------------------------------------- /Modules/FarNet.Demo/Scripts/Workings.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | How to get, update, edit settings. 4 | 5 | .Description 6 | This script works a newly created settings instance. 7 | 8 | PowerShellFar command: 9 | ps: .\Workings.far.ps1 10 | #> 11 | 12 | # load the library 13 | Add-Type -Path "$env:FARHOME\FarNet\Modules\FarNet.Demo\FarNet.Demo.dll" 14 | 15 | # get settings 16 | $settings = [FarNet.Demo.Workings]::new() 17 | $data = $settings.GetData() 18 | 19 | # update settings 20 | ++$data.MoreCount 21 | $settings.Save() 22 | 23 | # edit settings 24 | $settings.Edit() 25 | -------------------------------------------------------------------------------- /Test/Basics/Test-Editor-Crash.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Crash found 3.0.3980, fixed 3.0.3992 4 | .Description 5 | Confirmations \ [ ] Reload edited file 6 | 7 | 8 | 9 | 10 | #> 11 | 12 | $Test = "C:\tmp\$([guid]::NewGuid())" 13 | 14 | $Editor = New-FarEditor $Test -DisableHistory 15 | $Editor.Open() 16 | $Editor.Close() 17 | 18 | $Editor = New-FarEditor $Test -DisableHistory 19 | $Editor.Open() 20 | $Editor.Close() 21 | -------------------------------------------------------------------------------- /Test/Panels.Script/Test-FarInventory.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Test FarInventory + _100410_051915 4 | #> 5 | 6 | job { 7 | Import-Module $PSScriptRoot\..\..\PowerShellFar\Modules\FarInventory 8 | Open-LogicalDiskPanel 9 | } 10 | job { 11 | Find-FarFile 'C:' 12 | $CurrentFile = $__.CurrentFile 13 | Assert-Far @( 14 | $CurrentFile.Name -eq 'C:' 15 | $CurrentFile.Description -eq 'Local Fixed Disk' 16 | $CurrentFile.Owner -eq 'NTFS' 17 | @($CurrentFile.Columns)[0] -eq 'Local Disk' # _100410_051915 fixed $_ in modules 18 | ) 19 | $__.Close() 20 | } 21 | -------------------------------------------------------------------------------- /Test/Utility/Test-Go-HeadFile.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $__.CurrentDirectory = 'C:\ROM' 4 | $__.Redraw(0, $true) 5 | Assert-Far $__.CurrentIndex -eq 0 6 | } 7 | job { 8 | Go-HeadFile.ps1 9 | $Data.Index = $__.CurrentIndex 10 | Assert-Far @( 11 | $Data.Index -ne 0 12 | !$__.CurrentFile.IsDirectory 13 | ) 14 | } 15 | keys Up 16 | job { 17 | Assert-Far $__.CurrentFile.IsDirectory 18 | } 19 | job { 20 | Go-HeadFile.ps1 21 | Assert-Far $__.CurrentIndex -eq $Data.Index 22 | } 23 | keys End 24 | job { 25 | Go-HeadFile.ps1 26 | Assert-Far $__.CurrentIndex -eq $Data.Index 27 | } 28 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/ExpandTabsMode.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Editor expand tabs mode. 9 | /// 10 | public enum ExpandTabsMode 11 | { 12 | /// 13 | /// Tabs are not replaced with spaces. 14 | /// 15 | None, 16 | 17 | /// 18 | /// All tabs are replaced with spaces. 19 | /// 20 | All, 21 | 22 | /// 23 | /// Only new tabs are replaced with spaces. 24 | /// 25 | New 26 | } 27 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/ExploreEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Arguments of ExploreX methods. 9 | /// 10 | /// See 11 | public class ExploreEventArgs(ExplorerModes mode) : ExplorerEventArgs(mode) 12 | { 13 | /// 14 | /// Tells to create a new panel even if the new explorer has the same type as the current. 15 | /// 16 | public bool NewPanel { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/AnyEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet.Forms; 8 | 9 | /// 10 | /// Base class of dialog and control event arguments. 11 | /// 12 | /// The control related to this event. 13 | public class AnyEventArgs(IControl? control) : EventArgs 14 | { 15 | /// 16 | /// Gets the event control. See the constructor for details. 17 | /// 18 | public IControl? Control { get; } = control; 19 | } 20 | -------------------------------------------------------------------------------- /FarNet/FarNet/Module/ModuleEditorAttribute.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Module editor action attribute. 11 | /// 12 | [AttributeUsage(AttributeTargets.Class)] 13 | public sealed class ModuleEditorAttribute : ModuleActionAttribute 14 | { 15 | /// 16 | public string Mask 17 | { 18 | get => _mask ?? string.Empty; 19 | set => _mask = value; 20 | } 21 | string? _mask; 22 | } 23 | -------------------------------------------------------------------------------- /Samples/FarTask/NestedTasks.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | How to combine task scripts. 4 | 5 | .Description 6 | Jobs call `Start-FarTask ... -AsTask` and return tasks. 7 | The job runner awaits tasks and outputs their results. 8 | #> 9 | 10 | # Run DialogNonModalInput.fas.ps1 and keep the result as $text. 11 | $text = job { 12 | Start-FarTask $PSScriptRoot\DialogNonModalInput.fas.ps1 -AsTask 13 | } 14 | 15 | # Run InputEditorMessage.fas.ps1 using the result $text as $Var.text. 16 | job { 17 | Start-FarTask $PSScriptRoot\InputEditorMessage.fas.ps1 -Text $Var.text -AsTask 18 | } 19 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-160902.r.FarNet.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | # open empty session 4 | $Far.InvokeCommand("fs:open with=$PSScriptRoot\Vanilla\Vanilla.fs.ini") 5 | } 6 | 7 | job { 8 | Assert-Far -EditorTitle 'F# Vanilla.fs.ini *_??????_??????.interactive.fsx' 9 | } 10 | 11 | macro @' 12 | print '#r "FarNet/FarNet.dll"'; Keys'ShiftEnter' -- ref FarNet.dll 13 | '@ 14 | 15 | job { 16 | Assert-Far ($Far.Editor[3].Text -like "--> Referenced '*\FarNet/FarNet.dll' (file may be locked by F# Interactive process)") 17 | } 18 | 19 | macro "Keys '# q u i t ShiftEnter'" 20 | -------------------------------------------------------------------------------- /FarNet.slnx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/PanelHighlighting.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Panel highlighting modes. 9 | /// 10 | public enum PanelHighlighting 11 | { 12 | /// 13 | /// Highlighting by item attributes only. 14 | /// 15 | Default, 16 | 17 | /// 18 | /// Highlighting by attributes and names. 19 | /// 20 | Full, 21 | 22 | /// 23 | /// Highlighting is turned off. 24 | /// 25 | Off 26 | } 27 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/LosingFocusEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// event arguments. 9 | /// 10 | /// Control losing focus. 11 | public sealed class LosingFocusEventArgs(IControl losing) : AnyEventArgs(losing) 12 | { 13 | /// 14 | /// Control you want to pass focus to or leave it null to allow losing focus. 15 | /// 16 | public IControl? Focused { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/SizeEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// Size event arguments, e.g. of event. 9 | /// 10 | /// It is null. 11 | /// The size. 12 | public sealed class SizeEventArgs(IControl control, Point size) : AnyEventArgs(control) 13 | { 14 | /// 15 | /// The size. 16 | /// 17 | public Point Size { get; set; } = size; 18 | } 19 | -------------------------------------------------------------------------------- /PowerShellFar/Commands/OpenFarViewerCommand.cs: -------------------------------------------------------------------------------- 1 | 2 | // PowerShellFar module for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using FarNet; 6 | using System.Management.Automation; 7 | 8 | namespace PowerShellFar.Commands; 9 | 10 | sealed class OpenFarViewerCommand : NewFarViewerCommand 11 | { 12 | [Parameter] 13 | public SwitchParameter Modal { get; set; } 14 | 15 | protected override void ProcessRecord() 16 | { 17 | var viewer = CreateViewer(); 18 | if (Modal) 19 | viewer.Open(OpenMode.Modal); 20 | else 21 | viewer.Open(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CopyColor/CopyColor.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | C:\Bin\Far\x64 4 | $(FarHome)\FarNet\Modules\$(AssemblyName) 5 | false 6 | net10.0-windows 7 | true 8 | 9 | 10 | 11 | False 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /FSharpFar/tests/TestParallel.fs: -------------------------------------------------------------------------------- 1 | module TestParallel 2 | open Parallel 3 | open FarNet 4 | open FarNet.FSharp 5 | open System.Text.RegularExpressions 6 | open Swensen.Unquote 7 | 8 | Test.Add("TestParallel", async { 9 | Async.Start(demo 1.) 10 | do! Assert.Wait(fun () -> Window.IsDialog() && far.Dialog[0].Text = "done") 11 | 12 | do! job { 13 | let text = far.Dialog[1].Text 14 | let m = Regex.Match(text, "^\d+ \d+ \d+$") 15 | test <@ m.Success && text <> "0 0 0" @> 16 | } 17 | 18 | do! Jobs.Keys "Esc" 19 | do! job { Assert.NativePanel() } 20 | }) 21 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/modules/use-mix/README.md: -------------------------------------------------------------------------------- 1 | # P.O.C. mixed modules in a session 2 | 3 | This use case might be rare or unlikely but it works and covered by tests. 4 | 5 | `_session.*` files .js, .cjs, .mjs are auto loaded in alphabetical order: 6 | 7 | - [_session.1.js](_session.1.js) declares common variables 8 | - [_session.2.cjs](_session.2.cjs) exposes CommonJS module assets for scripts 9 | - [_session.2.mjs](_session.2.mjs) exposes Standard module assets for scripts 10 | 11 | Then: 12 | 13 | - [try.js](try.js) script uses assert from both CommonJS and Standard worlds 14 | -------------------------------------------------------------------------------- /PowerShellFar/UI/CommandHistoryMenu.cs: -------------------------------------------------------------------------------- 1 | 2 | using FarNet; 3 | using FarNet.Tools; 4 | 5 | namespace PowerShellFar.UI; 6 | 7 | class CommandHistoryMenu : HistoryMenu 8 | { 9 | public CommandHistoryMenu(HistoryStore history, string prefix) : base(history) 10 | { 11 | Settings.Default.ListMenu(Menu); 12 | Menu.HelpTopic = Entry.Instance.GetHelpTopic(HelpTopic.CommandHistory); 13 | Menu.Title = "PowerShell history"; 14 | Menu.Incremental = prefix; 15 | 16 | Menu.AddKey(KeyCode.Enter); 17 | Menu.AddKey(KeyCode.Enter, ControlKeyStates.LeftCtrlPressed); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Samples/FarTask/Parameters=3.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | How to pass parameters in script files. 4 | 5 | .Description 6 | (1) Define parameters in the script file as usual. 7 | (2) Specify them as dynamic parameters for Start-FarTask. 8 | (!) Avoid switch parameters or specify after parameter Script. 9 | 10 | .Example 11 | Start-FarTask .\Parameters=3.fas.ps1 -Param1 Hi -Param2 Joe 12 | #> 13 | 14 | param( 15 | $Param1 = 'Hello', 16 | $Param2 = 'World' 17 | ) 18 | 19 | # Jobs may access task variables as $Var. 20 | job { 21 | $Far.Message($Var.Param1 + ' ' + $Var.Param2) 22 | } 23 | -------------------------------------------------------------------------------- /Test/Host/Test-Prompt-Parameter.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Prompt() with one field 4 | #> 5 | 6 | run { 7 | # remove the variable 8 | if (Test-Path Variable:\090328194636) { Remove-Item Variable:\090328194636 } 9 | 10 | # trigger prompt dialog 11 | $null = New-Variable -Scope global 12 | } 13 | job { 14 | Assert-Far ($__[0].Text -match '^cmdlet New-Variable') 15 | } 16 | keys 0 9 0 3 2 8 1 9 4 6 3 6 Enter 17 | job { 18 | # variable exist 19 | Assert-Far -Panels 20 | Assert-Far (Test-Path Variable:\090328194636) 21 | Remove-Variable -Scope Global 090328194636 22 | } 23 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/ClosingEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// event arguments. 9 | /// 10 | /// Control that had the keyboard focus when [CtrlEnter] was pressed or the default control. 11 | public sealed class ClosingEventArgs(IControl? selected) : AnyEventArgs(selected) 12 | { 13 | /// 14 | /// Ingore and don't close the dialog. 15 | /// 16 | public bool Ignore { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /RedisKit/Commands/HashCommand.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using RedisKit.Panels; 3 | using StackExchange.Redis; 4 | 5 | namespace RedisKit.Commands; 6 | 7 | sealed class HashCommand : BaseCommand 8 | { 9 | readonly RedisKey _key; 10 | readonly bool _eol; 11 | 12 | public HashCommand(CommandParameters parameters) : base(parameters) 13 | { 14 | _key = GetRequiredRedisKeyOfType(parameters, RedisType.Hash); 15 | _eol = parameters.GetBool(Param.Eol); 16 | } 17 | 18 | public override void Invoke() 19 | { 20 | new HashExplorer(Database, _key, _eol) 21 | .CreatePanel() 22 | .Open(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Test/Script/Test-Escape.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | run { 3 | $Far.AnyEditor.EditText(@{Text = '\"'}) 4 | } 5 | 6 | job { 7 | Assert-Far -Editor 8 | Assert-Far $__[0].Text -eq '\"' 9 | 10 | $__.SelectAllText() 11 | } 12 | 13 | job { 14 | $Far.InvokeCommand('fn: script=Script; unload=true; method=Script.Editor.Escape') 15 | } 16 | 17 | job { 18 | Assert-Far $__[0].Text -eq '\\\"' 19 | } 20 | 21 | job { 22 | $Far.InvokeCommand('fn: script=Script; unload=true; method=Script.Editor.Unescape') 23 | } 24 | 25 | job { 26 | Assert-Far $__[0].Text -eq '\"' 27 | 28 | $__.Close() 29 | } 30 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-200603.fsx2.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | # open empty session 4 | $Far.InvokeCommand("fs:open with=$env:FarNetCode\FSharpFar\samples\fsx-sample\.fs.ini") 5 | } 6 | 7 | job { 8 | Assert-Far -Editor 9 | } 10 | 11 | macro @" 12 | print [[#load "$("$env:FarNetCode\FSharpFar\samples\fsx-sample\App2.fsx".Replace('\', '\\'))"]]; Keys'ShiftEnter' 13 | "@ 14 | 15 | job { 16 | Assert-Far -Dialog 17 | } 18 | 19 | macro 'Keys"M a y Enter"' 20 | 21 | job { 22 | Assert-Far $Far.Editor[3].Text -eq 'Hello, May!' 23 | } 24 | 25 | macro 'Keys[[# q u i t ShiftEnter]]' 26 | -------------------------------------------------------------------------------- /FarNet/FarNet/Editor/MouseEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Arguments of mouse events. 11 | /// 12 | /// Mouse data. 13 | public sealed class MouseEventArgs(MouseInfo mouse) : EventArgs 14 | { 15 | /// 16 | /// Mouse data. 17 | /// 18 | public MouseInfo Mouse { get; } = mouse; 19 | 20 | /// 21 | /// Ignore event. 22 | /// 23 | public bool Ignore { get; set; } 24 | } 25 | -------------------------------------------------------------------------------- /PowerShellFar/Modules/pwsf/1.build.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Build script, https://github.com/nightroman/Invoke-Build 4 | #> 5 | 6 | param( 7 | $Configuration = (property Configuration Release), 8 | $FarHome = (property FarHome "C:\Bin\Far\x64") 9 | ) 10 | 11 | $_name_pwsf = 'pwsf' 12 | $_root_pwsf = $FarHome 13 | 14 | task build { 15 | exec { dotnet build -c $Configuration -p:FarHome=$FarHome --tl:off } 16 | } 17 | 18 | task publish { 19 | remove "$_root_pwsf\$_name_pwsf.pdb", "$_root_pwsf\$_name_pwsf.exe.config" 20 | } 21 | 22 | task clean { 23 | remove bin, obj 24 | } 25 | 26 | task . build, clean 27 | -------------------------------------------------------------------------------- /GitKit/Settings.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | 3 | namespace GitKit; 4 | 5 | public class Settings : ModuleSettings 6 | { 7 | public static Settings Default { get; } = new Settings(); 8 | 9 | public class Data 10 | { 11 | public string DiffTool { get; set; } = @"%LOCALAPPDATA%\Programs\Microsoft VS Code\bin\code.cmd"; 12 | public string DiffToolArguments { get; set; } = "--diff \"%1\" \"%2\""; 13 | 14 | public bool UseGitCredentials { get; set; } 15 | 16 | public int CommitsPageLimit { get; set; } = 100; 17 | 18 | public int ShaPrefixLength { get; set; } = 7; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/config/_session.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | EnableAllLoading 4 | Standard 5 | https://raw.githubusercontent.com/nightroman/FarNet/848c23db70fb401982b08e8f5dee3888ce14c629/JavaScriptFar/Samples/modules/ 6 | EnableTaskPromiseConversion, EnableStringifyEnhancements 7 | -------------------------------------------------------------------------------- /Test/Script/Test-InvokeCommand.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | It should show error dialog on command exceptions. 4 | #> 5 | 6 | job { 7 | [FarNet.Works.Script]::InvokeCommand() 8 | [FarNet.Tasks]::WaitForDialog(999) 9 | } 10 | 11 | job { 12 | Assert-Far -DialogTypeId ([FarNet.Tools.InputBox]::DefaultTypeId) 13 | 14 | $__[2].Text = 'fn: script=Script; method=Message ;; name="Joe"' 15 | $__.Close() 16 | } 17 | 18 | job { 19 | Assert-Far -Dialog 20 | Assert-Far $__[0].Text -eq 'System.ArgumentException' 21 | Assert-Far $__[1].Text -eq 'Age cannot be negative.' 22 | $__.Close() 23 | } 24 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-170828.PowerShell.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | Open-FarEditor $PSScriptRoot\PowerShell\App.fsx -DisableHistory 4 | } 5 | macro @' 6 | Plugin.Menu("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "65BD5625-769A-4253-8FDE-FFCC3F72489D") 7 | Keys'l' -- load 8 | '@ 9 | job { 10 | Assert-Far -EditorTitle 'F# Output' 11 | Assert-Far $Far.Editor[1].Text -eq 'seq [answer; 42]' 12 | } 13 | macro 'Keys [[Esc Esc]] -- exit output and script' 14 | macro @' 15 | Plugin.Menu("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "65BD5625-769A-4253-8FDE-FFCC3F72489D") 16 | Keys'0 Del Esc' -- kill session 17 | '@ 18 | -------------------------------------------------------------------------------- /FarNet/FarNetTest/AbcTest.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using FarNetTest.About; 3 | using System.Reflection; 4 | 5 | namespace FarNetTest; 6 | 7 | public abstract class AbcTest 8 | { 9 | public static string TestRoot { get; } 10 | public static string RepoRoot { get; } 11 | 12 | static AbcTest() 13 | { 14 | Far.Api = new TestFar(); 15 | 16 | Environment.SetEnvironmentVariable("FarNetTest", "1"); 17 | 18 | var appRoot = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!; 19 | TestRoot = Path.GetFullPath($"{appRoot}/../../..")!; 20 | RepoRoot = Path.GetFullPath($"{TestRoot}/../..")!; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /PowerShellFar/About.md: -------------------------------------------------------------------------------- 1 | # FarNet.PowerShellFar 2 | 3 | PowerShell Core host and scripting environment for Far Manager 4 | 5 | ## Installation 6 | 7 | - Far Manager 8 | - Package [FarNet](https://www.nuget.org/packages/FarNet/) 9 | - Package [FarNet.PowerShellFar](https://www.nuget.org/packages/FarNet.PowerShellFar/) 10 | 11 | How to install and update FarNet and modules:\ 12 | https://github.com/nightroman/FarNet#readme 13 | 14 | ## See also 15 | 16 | - [README](https://github.com/nightroman/FarNet/tree/main/PowerShellFar#readme) 17 | - [Wiki](https://github.com/nightroman/FarNet/wiki/PowerShellFar) 18 | -------------------------------------------------------------------------------- /Modules/Backslash/Backslash.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | C:\Bin\Far\x64 4 | $(FarHome)\FarNet\Modules 5 | $(FarNetModules)\$(AssemblyName) 6 | false 7 | net10.0 8 | 9 | 10 | 11 | False 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /PowerShellFar/My/MyRegex.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace PowerShellFar; 4 | 5 | static partial class MyRegex 6 | { 7 | [GeneratedRegex(@"^(.*[!;\(\{\|""'']*)\$(global:|script:|private:)?(\w*)$", RegexOptions.IgnoreCase)] 8 | public static partial Regex CompleteVariable(); 9 | 10 | [GeneratedRegex(@"(?:^|\s)(\S+)$")] 11 | public static partial Regex CompleteWord(); 12 | 13 | [GeneratedRegex(@"ErrorActionPreference.*Stop:\s*(.*)")] 14 | public static partial Regex ErrorActionPreference(); 15 | 16 | [GeneratedRegex(@"\s+")] 17 | public static partial Regex Spaces(); 18 | } 19 | -------------------------------------------------------------------------------- /RedisKit/Tests/edit=list.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | Import-Module $PSScriptRoot\zoo.psm1 4 | Remove-RedisKey test:edit 5 | Set-RedisList test:edit q1 6 | 7 | $Far.InvokeCommand('rk:edit key=test:edit') 8 | } 9 | 10 | job { 11 | Assert-Far -Editor 12 | $Editor = $Far.Editor 13 | Assert-Far $Editor.Title -eq 'List test:edit' 14 | Assert-Far $Editor.GetText() -eq 'q1' 15 | 16 | $Editor.SetText("q1`nq2") 17 | $Editor.Save() 18 | 19 | $r = (Get-RedisList test:edit) -join '#' 20 | Assert-Far $r -eq q1#q2 21 | 22 | $Editor.Close() 23 | } 24 | 25 | job { 26 | Assert-Far -Panels 27 | Remove-RedisKey test:edit 28 | } 29 | -------------------------------------------------------------------------------- /FSharpFar/samples/TryPanelFSharp/Module.fs: -------------------------------------------------------------------------------- 1 | module Module 2 | open FarNet 3 | open TryPanelFSharp 4 | 5 | /// The module menu item: F11 \ TryPanelFSharp 6 | [] 7 | type MyTool() = 8 | inherit ModuleTool() 9 | override _.Invoke(_, _) = run () 10 | 11 | /// The module command "TryPanelFSharp:" 12 | [] 13 | type MyCommand() = 14 | inherit ModuleCommand() 15 | override _.Invoke(_, _) = run () 16 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/ExploreLocationEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Explore location arguments. 9 | /// 10 | /// See 11 | /// See 12 | public sealed class ExploreLocationEventArgs(ExplorerModes mode, string location) : ExploreEventArgs(mode) 13 | { 14 | /// 15 | /// Gets the location. 16 | /// 17 | public string Location { get; } = location; 18 | } 19 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/ExplorerFileEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Arguments of methods operating on a single file. 9 | /// 10 | /// See 11 | /// See 12 | public abstract class ExplorerFileEventArgs(ExplorerModes mode, FarFile file) : ExplorerEventArgs(mode) 13 | { 14 | /// 15 | /// Gets the file to be processed. 16 | /// 17 | public FarFile File => file; 18 | } 19 | -------------------------------------------------------------------------------- /JsonKit/Panels/ObjectPanel.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | 3 | namespace JsonKit.Panels; 4 | 5 | sealed class ObjectPanel : AbcPanel 6 | { 7 | public ObjectPanel(ObjectExplorer explorer) : base(explorer) 8 | { 9 | Title = $"Object {explorer.Node.GetPath()}"; 10 | SortMode = PanelSortMode.Unsorted; 11 | 12 | var cn = new SetColumn { Kind = "N", Name = "Name", Width = -40 }; 13 | var cz = new SetColumn { Kind = "Z", Name = "Value" }; 14 | 15 | var plan0 = new PanelPlan { Columns = [cn, cz] }; 16 | SetPlan(0, plan0); 17 | 18 | SetView(plan0); 19 | } 20 | 21 | protected override string HelpTopic => "object-panel"; 22 | } 23 | -------------------------------------------------------------------------------- /PowerShellFar/Commands/InvokeTaskMacro.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using System.Management.Automation; 3 | 4 | namespace PowerShellFar.Commands; 5 | 6 | internal sealed class InvokeTaskMacro : PSCmdlet 7 | { 8 | internal const string MyName = "Invoke-FarTaskMacro"; 9 | 10 | [Parameter(Position = 0, Mandatory = true)] 11 | public string Macro { get; set; } = null!; 12 | 13 | protected override void BeginProcessing() 14 | { 15 | if (A.IsMainSession) 16 | throw new InvalidOperationException("Cannot run in main session."); 17 | 18 | Tasks.Macro(Macro).Await(); 19 | FarNet.Works.Far2.Api.WaitSteps().Await(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Samples/FarTask/Parameters=1.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | How to pass data in task scripts. 4 | 5 | .Description 6 | Use parameter -Data to add variables and hashtables to $Data. 7 | #> 8 | 9 | # some variables 10 | $variable1 = 'Hi' 11 | $hashtable1 = @{user = 'Joe'; id = 42} 12 | 13 | # start task with the variable and hashtable added to $Data 14 | Start-FarTask -Data variable1, $hashtable1 { 15 | # use $Data in task 16 | if ($Data.variable1 -ne 'Hi' -or $Data.user -ne 'Joe') { throw } 17 | 18 | job { 19 | # use $Data in jobs 20 | $Far.Message($Data.variable1 + ' ' + $Data.user + ' (' + $Data.id + ')') 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Test/Debugger/abc.ps1: -------------------------------------------------------------------------------- 1 | # Assert/Debug moved from _220809_2057 2 | 3 | function global:Set-AddDebuggerIO { 4 | Set-Alias Read-Debugger Read-Debugger2 -Scope global -Option AllScope 5 | function global:Read-Debugger2 { 6 | param($Prompt, $Default) 7 | Read-Host $Prompt 8 | } 9 | 10 | Set-Alias Write-Debugger Write-Debugger2 -Scope global -Option AllScope 11 | function global:Write-Debugger2 { 12 | param($Data) 13 | } 14 | } 15 | 16 | function global:Remove-AddDebuggerIO { 17 | Remove-Alias Read-Debugger -Scope global -ErrorAction 0 18 | Remove-Alias Write-Debugger -Scope global -ErrorAction 0 19 | } 20 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/OpenMode.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Open modes of editor and viewer. 9 | /// 10 | public enum OpenMode 11 | { 12 | /// 13 | /// Tells to open not modal editor or viewer and return immediately. 14 | /// 15 | None, 16 | 17 | /// 18 | /// Tells to open not modal editor or viewer and wait for exit. 19 | /// 20 | Wait, 21 | 22 | /// 23 | /// Tells to open modal editor or viewer. 24 | /// 25 | Modal, 26 | } 27 | -------------------------------------------------------------------------------- /FarNet/FarNet/Works/Config/Assembly.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | namespace FarNet.Works; 9 | 10 | static class MenuExtensions 11 | { 12 | internal static void AddSimpleConfigItems(this IMenu menu, IEnumerable items) 13 | { 14 | var max1 = items.Max(x => x.Name.Length); 15 | var max2 = items.Max(x => x.Manager.ModuleName.Length); 16 | foreach (var it in items) 17 | menu.Add($"{it.Name.PadRight(max1)} {it.Manager.ModuleName.PadRight(max2)} {it.Id}").Data = it; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/config/TaskPromiseConversion.js: -------------------------------------------------------------------------------- 1 | // Without EnableTaskPromiseConversion this script works incorrectly: 2 | // instead of sleeping for 5 seconds it shows the result immediately. 3 | 4 | function sleep(milliseconds) { 5 | return clr.System.Threading.Tasks.Task.Delay(milliseconds) 6 | } 7 | 8 | function job(proc) { 9 | return clr.FarNet.Tasks.Job(host.proc(0, proc)) 10 | } 11 | 12 | async function test(milliseconds) { 13 | await sleep(milliseconds) 14 | await job(() => far.Message(`done in ${milliseconds} milliseconds`)) 15 | } 16 | 17 | test(parseInt(args.milliseconds ?? 5000)) 18 | -------------------------------------------------------------------------------- /Modules/TryPanelCSharp/TryPanelCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | C:\Bin\Far\x64 4 | $(FarHome)\FarNet\Modules 5 | $(FarNetModules)\$(AssemblyName) 6 | false 7 | net10.0 8 | 9 | 10 | 11 | False 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Test/Dialog/Test-ComboBox.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Drop down used to break steps. 4 | Not a problem with task jobs. 5 | #> 6 | 7 | run { 8 | # show dialog with a combo 9 | $d = $Far.CreateDialog(-1, -1, 52, 3) 10 | $e = $d.AddComboBox(1, 1, 50, '') 11 | $null = $e.Add('item1') 12 | $null = $e.Add('item2') 13 | $null = $d.Show() 14 | } 15 | 16 | macro 'Keys"CtrlDown" -- open combo' 17 | 18 | job { 19 | Assert-Far ($Far.Window.Kind -eq 'ComboBox') 20 | } 21 | 22 | keys 'Down Enter' 23 | 24 | job { 25 | Assert-Far -Dialog 26 | Assert-Far $__[0].Text -eq 'item2' 27 | } 28 | 29 | keys Esc 30 | -------------------------------------------------------------------------------- /Test/Panels/Test-GroupInfo.fas.ps1: -------------------------------------------------------------------------------- 1 | # Columns of `Group-Object` and `Group-Object -NoElement` objects 2 | 3 | job { 4 | [pscustomobject]@{p1='q1'} | Group-Object p1 | Out-FarPanel 5 | } 6 | 7 | job { 8 | $1, $2, $3, $null = $__.GetPlan(0).Columns 9 | Assert-Far $1.Kind -eq S 10 | Assert-Far $2.Kind -eq N 11 | Assert-Far $3.Kind -eq Z 12 | $__.Close() 13 | } 14 | 15 | job { 16 | [pscustomobject]@{p1='q1'} | Group-Object p1 -NoElement | Out-FarPanel 17 | } 18 | 19 | job { 20 | $1, $2, $null = $__.GetPlan(0).Columns 21 | Assert-Far $1.Kind -eq S 22 | Assert-Far $2.Kind -eq N 23 | $__.Close() 24 | } 25 | -------------------------------------------------------------------------------- /Test/Panels/Test-Panel-AutoColumn-01.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Fixed: null Name; auto column types on many columns. 4 | #> 5 | 6 | job { 7 | # make more columns than max 8 | $props = 'Name', 'Description', 'InvariantName', 'AssemblyQualifiedName', 'q1', 'q2', 'q3', 'q4', 'q5' 9 | Assert-Far ($props.Count -gt $Psf.Settings.MaximumPanelColumnCount) 10 | 11 | # couple of objects 12 | $ob1 = 1 | Select-Object $props 13 | $ob2 = 1 | Select-Object $props 14 | 15 | # out 16 | $ob1, $ob2 | Out-FarPanel -Title AutoColumnType 17 | } 18 | job { 19 | Assert-Far $__.Title -eq AutoColumnType 20 | } 21 | keys Esc 22 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-181218.PanelVariables1.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $Far.InvokeCommand("fs:exec file=$env:FarNetCode\FSharpFar\samples\PowerShellFar\PanelObjects.fsx") 4 | } 5 | job { 6 | Assert-Far -Plugin 7 | Assert-Far $Far.Panel.Title -eq 'Objects' 8 | $files = $Far.Panel.GetFiles() 9 | Assert-Far @( 10 | $files.Count -eq 3 11 | $files[0].Name -eq 'John Doe' 12 | $files[2].Name -eq 'Fluppy Foo' 13 | ) 14 | } 15 | macro "Keys'Esc' -- exit panel" 16 | macro @' 17 | Plugin.Menu("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "65BD5625-769A-4253-8FDE-FFCC3F72489D") 18 | Keys'0 Del Esc' -- kill session 19 | '@ 20 | -------------------------------------------------------------------------------- /PowerShellFar/Modules/pwsf/pwsf.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | C:\Bin\Far\x64 4 | $(FarHome) 5 | Exe 6 | net48 7 | 11 8 | enable 9 | enable 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /RedisKit/Panels/Files.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using StackExchange.Redis; 3 | 4 | namespace RedisKit.Panels; 5 | 6 | static class Files 7 | { 8 | public record FileDataFolder(string Prefix); 9 | public static FileDataFolder DataFolder(this FarFile file) => (FileDataFolder)file.Data!; 10 | 11 | public record FileDataKey(RedisKey Key); 12 | public static FileDataKey DataKey(this FarFile file) => (FileDataKey)file.Data!; 13 | 14 | public record ArgsDataName(string Name); 15 | public static ArgsDataName DataName(this ExplorerEventArgs args) => (ArgsDataName)args.Data!; 16 | 17 | public record KeyInput(string Name, string? Prefix); 18 | } 19 | -------------------------------------------------------------------------------- /RedisKit/Tests/edit=set.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | Import-Module $PSScriptRoot\zoo.psm1 4 | Remove-RedisKey test:edit 5 | Set-RedisSet test:edit q1 6 | 7 | $Far.InvokeCommand('rk:edit key=test:edit') 8 | } 9 | 10 | job { 11 | Assert-Far -Editor 12 | $Editor = $Far.Editor 13 | Assert-Far $Editor.Title -eq 'Set test:edit' 14 | Assert-Far $Editor.GetText() -eq 'q1' 15 | 16 | $Editor.SetText("q2`nq1`nq2") 17 | $Editor.Save() 18 | 19 | $r = (Get-RedisSet test:edit | Sort-Object) -join '#' 20 | Assert-Far $r -eq q1#q2 21 | 22 | $Editor.Close() 23 | } 24 | 25 | job { 26 | Assert-Far -Panels 27 | Remove-RedisKey test:edit 28 | } 29 | -------------------------------------------------------------------------------- /EditorKit/Settings.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using System.Xml.Serialization; 3 | 4 | namespace EditorKit; 5 | 6 | public class Settings : ModuleSettings 7 | { 8 | public static Settings Default { get; } = new Settings(); 9 | 10 | public class Data 11 | { 12 | public ColorerType[] ColorerTypes { get; set; } = [new() { Type = "json", Mask = "*.canvas" }]; 13 | } 14 | 15 | public class ColorerType 16 | { 17 | [XmlAttribute] 18 | public required string Type { get; set; } 19 | 20 | [XmlAttribute] 21 | public required string Mask { get; set; } 22 | 23 | [XmlAttribute] 24 | public bool Full { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /FarNet/FarNet/File/FileFileComparer.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System.Collections.Generic; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Compares files by their references. 11 | /// 12 | public sealed class FileFileComparer : EqualityComparer 13 | { 14 | /// 15 | public override bool Equals(FarFile? x, FarFile? y) 16 | { 17 | return object.Equals(x, y); 18 | } 19 | 20 | /// 21 | public override int GetHashCode(FarFile obj) 22 | { 23 | return obj == null ? 0 : obj.GetHashCode(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /FarNet/FarNet/Panel/CommandLineEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Arguments of . 9 | /// Set = true to tell that command has been processed internally. 10 | /// 11 | /// See 12 | public sealed class CommandLineEventArgs(string command) : PanelEventArgs 13 | { 14 | /// 15 | /// Gets the command to be processed. 16 | /// 17 | public string Command { get; } = command; 18 | } 19 | -------------------------------------------------------------------------------- /Modules/IronPythonFar/1.build.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Build script, https://github.com/nightroman/Invoke-Build 4 | #> 5 | 6 | param( 7 | $FarHome = (property FarHome C:\Bin\Far\x64), 8 | $Configuration = (property Configuration Release), 9 | $FarNetModules = (property FarNetModules $FarHome\FarNet\Modules) 10 | ) 11 | 12 | Set-StrictMode -Version 3 13 | $ModuleName = 'IronPythonFar' 14 | $ModuleRoot = "$FarNetModules\$ModuleName" 15 | 16 | task build { 17 | exec { dotnet build -c $Configuration -p:FarHome=$FarHome -p:FarNetModules=$FarNetModules } 18 | } 19 | 20 | task clean { 21 | remove z, bin, obj 22 | } 23 | 24 | task . build, clean 25 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/ExploreDirectoryEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Arguments of 9 | /// 10 | /// See 11 | /// See 12 | public sealed class ExploreDirectoryEventArgs(ExplorerModes mode, FarFile file) : ExploreEventArgs(mode) 13 | { 14 | /// 15 | /// Gets the directory file to explore. 16 | /// 17 | public FarFile File { get; } = file; 18 | } 19 | -------------------------------------------------------------------------------- /PowerShellFar/OutputWriters/StreamOutputWriter.cs: -------------------------------------------------------------------------------- 1 | 2 | // PowerShellFar module for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System.IO; 6 | 7 | namespace PowerShellFar; 8 | 9 | sealed class StreamOutputWriter(StreamWriter writer) : TextOutputWriter 10 | { 11 | readonly StreamWriter _writer = writer; 12 | 13 | protected override void Append(string value) 14 | { 15 | _writer.Write(value); 16 | } 17 | 18 | protected override void AppendLine() 19 | { 20 | _writer.WriteLine(); 21 | } 22 | 23 | protected override void AppendLine(string value) 24 | { 25 | _writer.WriteLine(value); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /FSharpFar/src/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": ".NET Far", 6 | "type": "clr", 7 | "request": "launch", 8 | "preLaunchTask": "build", 9 | "program": "Far.exe", 10 | "args": [], 11 | "cwd": "${workspaceRoot}", 12 | "stopAtEntry": false, 13 | "console": "externalTerminal" 14 | }, 15 | { 16 | "name": ".NET Far Attach", 17 | "type": "clr", 18 | "request": "attach", 19 | "processName": "Far.exe" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /FarNet/FarNet/Module/ModuleCommandAttribute.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Module command attribute. 11 | /// 12 | [AttributeUsage(AttributeTargets.Class)] 13 | public sealed class ModuleCommandAttribute : ModuleActionAttribute 14 | { 15 | /// 16 | /// The mandatory not empty command prefix. 17 | /// 18 | /// 19 | /// This is the default prefix, the actual prefix may be configured by a user. 20 | /// 21 | public string Prefix { get; set; } = null!; 22 | } 23 | -------------------------------------------------------------------------------- /FarNet/FarNet/Viewer/IAnyViewer.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Any viewer operator. 9 | /// Exposed as . 10 | /// 11 | public abstract class IAnyViewer : IViewerBase 12 | { 13 | /// 14 | /// Opens a viewer to view some text. 15 | /// 16 | /// The text to view. 17 | /// The viewer title. 18 | /// The open mode. 19 | public abstract void ViewText(string text, string title, OpenMode mode); 20 | } 21 | -------------------------------------------------------------------------------- /RedisKit/Tests/edit=hash.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | Import-Module $PSScriptRoot\zoo.psm1 4 | Remove-RedisKey test:edit 5 | Set-RedisHash test:edit f1 v1 6 | 7 | $Far.InvokeCommand('rk:edit key=test:edit') 8 | } 9 | 10 | job { 11 | Assert-Far -Editor 12 | $Editor = $Far.Editor 13 | Assert-Far $Editor.Title -eq 'Hash test:edit' 14 | Assert-Far ($Editor.Strings -join '|') -eq 'f1|v1|' 15 | 16 | $Editor[0].Text = 'f2' 17 | $Editor.Save() 18 | 19 | $r = Get-RedisHash test:edit | ConvertTo-Json -Compress 20 | Assert-Far $r -eq '{"f2":"v1"}' 21 | 22 | $Editor.Close() 23 | } 24 | 25 | job { 26 | Assert-Far -Panels 27 | Remove-RedisKey test:edit 28 | } 29 | -------------------------------------------------------------------------------- /Test/Panels/Test-z_191223_BadCurrentFile.fas.ps1: -------------------------------------------------------------------------------- 1 | # Panel used to open with the current item 3 due to the empty "name". 2 | # https://forum.farmanager.com/viewtopic.php?f=8&t=11965#p158120 3 | 4 | job { 5 | $Explorer = [PowerShellFar.ObjectExplorer]::new() 6 | $Explorer.AsGetData = { 7 | [PSCustomObject]@{_id = 1; name = 'name1'} 8 | [PSCustomObject]@{_id = 2; name = 'name2'} 9 | [PSCustomObject]@{_id = 3} 10 | } 11 | $Explorer.CreatePanel().Open() 12 | } 13 | job { 14 | # current item is ".." 15 | Assert-Far -Plugin 16 | Assert-Far $( 17 | $__.CurrentIndex -eq 0 18 | $__.Files[0].Name -eq '..' 19 | ) 20 | } 21 | keys Esc 22 | -------------------------------------------------------------------------------- /GitKit/Tests/init.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | ### init path 3 | 4 | job { 5 | if (Test-Path c:\temp\z) { 6 | Remove-Item c:\temp\z -Force -Recurse 7 | } 8 | 9 | $Far.InvokeCommand("gk:init path=c:\temp\z") 10 | } 11 | 12 | job { 13 | Assert-Far .git -eq (Get-Item c:\temp\z\* -Force).Name 14 | } 15 | 16 | ### init path isBare 17 | 18 | job { 19 | if (Test-Path c:\temp\z) { 20 | Remove-Item c:\temp\z -Force -Recurse 21 | } 22 | 23 | $Far.InvokeCommand("gk:init path=c:\temp\z; isBare=true") 24 | } 25 | 26 | job { 27 | Assert-Far hooks/info/objects/refs/config/description/HEAD -eq ((Get-Item c:\temp\z\*).ForEach{$_.Name} -join '/') 28 | } 29 | -------------------------------------------------------------------------------- /Samples/FarTask/KeysAndMacro.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | How to use `keys` and `macro` jobs in task scripts. 4 | 5 | .Description 6 | It opens "Apply command", types "cls", tests results. 7 | #> 8 | 9 | # ensure panels 10 | job { 11 | Assert-Far -Panels -Message 'Please run from panels.' 12 | } 13 | 14 | # open Apply Command dialog using `keys` 15 | keys CtrlG 16 | 17 | # the dialog is shown 18 | job { 19 | Assert-Far -Dialog 20 | } 21 | 22 | # type the text 23 | macro 'print"cls"' 24 | 25 | # test the typed text 26 | job { 27 | Assert-Far -Dialog 28 | Assert-Far $Far.Dialog[2].Text -eq 'cls' 29 | } 30 | 31 | # invoke the typed command 32 | keys Enter 33 | -------------------------------------------------------------------------------- /Test/Panels.Cmd/Test-InvokeSelected.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $global:tmp = 1 4 | } 5 | 6 | # ps: no spaces 7 | job { 8 | $Far.CommandLine.Text = 'ps:$global:tmp = 2' 9 | $Psf.InvokeSelectedCode() 10 | Assert-Far $global:tmp -eq 2 11 | Assert-Far $Far.CommandLine.Text -eq 'ps:$global:tmp = 2' 12 | } 13 | 14 | # vps: with spaces 15 | job { 16 | $Far.CommandLine.Text = ' vps: $global:tmp = 3' 17 | $Psf.InvokeSelectedCode() 18 | Assert-Far $global:tmp -eq 3 19 | Assert-Far $Far.CommandLine.Text -eq ' vps: $global:tmp = 3' 20 | } 21 | 22 | job { 23 | $Far.CommandLine.Text = '' 24 | Remove-Variable -Name tmp -Scope global 25 | } 26 | -------------------------------------------------------------------------------- /Test/TabExpansion/Test-TabExpansionUI-Command.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | TabExpansion UI with a command. 4 | #> 5 | 6 | job { 7 | $Far.CommandLine.Text = 'Get-Hist' 8 | } 9 | 10 | macro @' 11 | Plugin.Menu("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "7DEF4106-570A-41AB-8ECB-40605339E6F7") 12 | Keys"7" -- expand 13 | '@ 14 | 15 | job { 16 | # two items shown differently 17 | Assert-Far -Dialog 18 | $r = $__[1].Items 19 | Assert-Far $r.Count -eq 2 20 | Assert-Far $r[0].Text -eq 'Get-History' 21 | Assert-Far $r[1].Text -eq 'Microsoft.PowerShell.Core\Get-History' 22 | } 23 | 24 | macro 'Keys"Esc Esc" -- exit list, drop command line' 25 | -------------------------------------------------------------------------------- /Test/Utility/Update-FarManager.test.ps1: -------------------------------------------------------------------------------- 1 | #! $HOME should have 2+ packages "Far*.7z". 2 | 3 | Set-StrictMode -Version 3 4 | . Update-FarManager.ps1 5 | 6 | task pattern { 7 | ($r = archive_pattern -Platform x64 -PackageType 7z) 8 | equals $r '^Far\.x64\.(\d+\.\d+\.\d+\.\d+)\.\w+\.7z$' 9 | } 10 | 11 | task archives { 12 | 'get_archives' 13 | $r1 = @(get_archives -Platform x64 -PackageType 7z) 14 | $r1 | Out-String 15 | assert ($r1.Count -ge 2) 16 | 17 | 'get_old_versions' 18 | $MaxVersions = 1 19 | $r2 = @(get_old_versions -Platform x64 -PackageType 7z -MaxVersions $MaxVersions) 20 | $r2 | Out-String 21 | equals $r2.Count ($r1.Count - $MaxVersions) 22 | } 23 | -------------------------------------------------------------------------------- /Explore/Explore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | C:\Bin\Far\x64 4 | $(FarHome)\FarNet\Modules\$(AssemblyName) 5 | false 6 | net10.0 7 | enable 8 | enable 9 | True 10 | 11 | 12 | 13 | False 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/IDropDown.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet.Forms; 8 | 9 | /// 10 | /// Common members of controls with a drop down box, i.e. edit boxes and combo boxes. 11 | /// 12 | public interface IDropDown 13 | { 14 | /// 15 | /// Called when a drop down list is opening. 16 | /// 17 | event EventHandler DropDownOpening; 18 | 19 | /// 20 | /// Called when a drop down list is closed. 21 | /// 22 | event EventHandler DropDownClosed; 23 | } 24 | -------------------------------------------------------------------------------- /Vessel/Vessel.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | C:\Bin\Far\x64 4 | $(FarHome)\FarNet\Modules\$(AssemblyName) 5 | false 6 | net10.0 7 | enable 8 | enable 9 | true 10 | 11 | 12 | 13 | False 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /FSharpFar/samples/Async/MyPanel.fs: -------------------------------------------------------------------------------- 1 | // Object panel used by the sample wizard. 2 | 3 | module MyPanel 4 | open FarNet 5 | open System 6 | 7 | type MyFile(obj) = 8 | inherit FarFile() 9 | override _.Name = sprintf "%A" obj 10 | override _.Description = obj.GetType().FullName 11 | 12 | type MyExplorer(items) = 13 | inherit Explorer(Guid "4c22f997-b124-490c-a2fe-2364d8d51330") 14 | override _.GetFiles _ = 15 | items |> Seq.map MyFile |> Seq.cast 16 | override x.CreatePanel() = 17 | Panel(x, Title="Objects", SortMode=PanelSortMode.Unsorted, ViewMode=PanelViewMode.Descriptions) 18 | 19 | let panel items = 20 | (MyExplorer items).CreatePanel() 21 | -------------------------------------------------------------------------------- /FarNet/FarNet/Panel/SetColumn.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Panel column options. 9 | /// 10 | /// 11 | /// Use this class directly to create column options instance and set its properties. 12 | /// See for details. 13 | /// 14 | public sealed class SetColumn : FarColumn 15 | { 16 | /// 17 | public override string? Name { get; set; } 18 | 19 | /// 20 | public override string? Kind { get; set; } 21 | 22 | /// 23 | public override int Width { get; set; } 24 | } 25 | -------------------------------------------------------------------------------- /PowerShellFar/Commands/InvokeTaskKeys.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using System.Management.Automation; 3 | 4 | namespace PowerShellFar.Commands; 5 | 6 | internal sealed class InvokeTaskKeys : PSCmdlet 7 | { 8 | internal const string MyName = "Invoke-FarTaskKeys"; 9 | 10 | [Parameter(ValueFromRemainingArguments = true, Mandatory = true)] 11 | public string[] Keys { get; set; } = null!; 12 | 13 | protected override void BeginProcessing() 14 | { 15 | if (A.IsMainSession) 16 | throw new InvalidOperationException("Cannot run in main session."); 17 | 18 | var keys = string.Join(" ", Keys); 19 | Tasks.Keys(keys).Await(); 20 | FarNet.Works.Far2.Api.WaitSteps().Await(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /RightControl/RightControl.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | C:\Bin\Far\x64 4 | $(FarHome)\FarNet\Modules\$(AssemblyName) 5 | false 6 | net10.0 7 | enable 8 | enable 9 | true 10 | 11 | 12 | 13 | False 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /FSharpFar/samples/Lib/SessionVariablesPanel.fsx: -------------------------------------------------------------------------------- 1 | (* 2 | The script gets session variables using "SessionVariables.fs" and sends 3 | them to the PowerShellFar panel for browsing. 4 | 5 | How to invoke with the required session: 6 | 7 | fs:exec with=.; file=...\SessionVariablesPanel.fsx 8 | 9 | where `with=.` means the .fs.ini in the current panel, you may have to 10 | specify the actual session config path and the path to this script. 11 | *) 12 | 13 | #load "SessionVariables.fs" 14 | open FarNet.FSharp 15 | 16 | // get session variables and send them to the panel 17 | PSFar.Invoke("$args[0] | Out-FarPanel", [| SessionVariables.getVariables () |]) 18 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/UseFileOddity/App.fsx: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | (1) Open this file in editor; check -> `see` is not defined because we do not add use-files. 4 | I tried to add them to checker. This did not help, probably because they are .fsx, not .fs. 5 | 6 | (2) Load or exec this -> works fin because `see` is preloaded from use-file to the session. 7 | So there is some inconsistency between check and exec with use-files. 8 | I am not sure how to deal with this and if this is a problem at all. 9 | 10 | So: 11 | -- use-files are just for interactive 12 | -- for checker, use proper modules and `[]` 13 | *) 14 | 15 | let x = 42 16 | see x 17 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/ViewFrameOptions.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Options for . 11 | /// 12 | [Flags] 13 | public enum ViewFrameOptions 14 | { 15 | /// 16 | None, 17 | 18 | /// 19 | /// Don't redraw. 20 | /// 21 | NoRedraw = 1, 22 | 23 | /// 24 | /// Offset is defined in percents. 25 | /// 26 | Percent = 2, 27 | 28 | /// 29 | /// Offset is relative to the current (and can be negative). 30 | /// 31 | Relative = 4, 32 | } 33 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/ExplorerEnteredEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Arguments of the method and the event. 11 | /// 12 | /// See 13 | public sealed class ExplorerEnteredEventArgs(Explorer explorer) : EventArgs 14 | { 15 | /// 16 | /// The old explorer replaced by the new just entered . 17 | /// 18 | public Explorer Explorer { get; } = explorer; 19 | } 20 | -------------------------------------------------------------------------------- /FarNet/FarNetMan/ListItemCollection.h: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | #pragma once 6 | 7 | namespace FarNet 8 | {; 9 | ref class FarBaseList; 10 | 11 | ref class ListItemCollection : public Collection 12 | { 13 | public: 14 | ListItemCollection(FarBaseList^ box); 15 | protected: 16 | virtual void ClearItems() override; 17 | virtual void InsertItem(int index, FarItem^ item) override; 18 | virtual void RemoveItem(int index) override; 19 | virtual void SetItem(int index, FarItem^ item) override; 20 | internal: 21 | void SetBox(FarBaseList^ value); 22 | private: 23 | FarBaseList^ _box; 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Samples/FarTask/MainAndAsyncCommon/CommonCode.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | This code may be called from main and async sessions. 4 | See "Test-CommonCode.far.ps1" 5 | #> 6 | 7 | # shared data 8 | $Data = @{ 9 | var1 = 1 10 | } 11 | 12 | # test, increment, print 13 | ps: { 14 | Write-Host "Testing common code." -ForegroundColor Cyan 15 | Assert-Far $Data.var1 -eq 1 16 | ++$Data.var1 17 | $Data.var1 18 | } 19 | 20 | # test, increment, return 21 | $result = job { 22 | Assert-Far $Data.var1 -eq 2 23 | ++$Data.var1 24 | $Data.var1 25 | } 26 | 27 | # test result 28 | Assert-Far $result -eq 3 29 | 30 | # test and print 31 | ps: { 32 | Assert-Far $Data.var1 -eq 3 33 | $Data.var1 34 | } 35 | -------------------------------------------------------------------------------- /Test/Host/Test-Read-Host-0.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Read-Host empty prompt and [Esc] 4 | 5 | .Description 6 | This scenario calls ReadLine(), not Prompt() 7 | #> 8 | 9 | ### Test Esc 10 | 11 | run { 12 | # show prompt 13 | $r = Read-Host 14 | Assert-Far $r -eq $null 15 | } 16 | job { 17 | Assert-Far -Dialog 18 | } 19 | keys Esc 20 | job { 21 | Assert-Far -Panels 22 | } 23 | 24 | ### Test Enter 25 | 26 | run { 27 | # show prompt 28 | $r = Read-Host 29 | Assert-Far $r -eq 140302_142029 30 | } 31 | job { 32 | Assert-Far -Dialog 33 | Assert-Far $Far.Dialog[1].Text -eq '' 34 | 35 | $Far.Dialog[1].Text = '140302_142029' 36 | } 37 | keys Enter 38 | -------------------------------------------------------------------------------- /FarNet/FarNet/Module/ModuleDrawerAttribute.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Module editor drawer attribute. 11 | /// 12 | [AttributeUsage(AttributeTargets.Class)] 13 | public sealed class ModuleDrawerAttribute : ModuleActionAttribute 14 | { 15 | /// 16 | public string Mask 17 | { 18 | get => _mask ?? string.Empty; 19 | set => _mask = value; 20 | } 21 | string? _mask; 22 | 23 | /// 24 | /// Color priority. 25 | /// 26 | public int Priority { get; set; } 27 | } 28 | -------------------------------------------------------------------------------- /FarNet/FarNetMan/Viewer0.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Viewer.h" 3 | 4 | namespace FarNet 5 | { 6 | ref class Viewer0 7 | { 8 | Viewer0() {} 9 | internal: 10 | static array^ Viewers(); 11 | static Viewer^ GetCurrentViewer(); 12 | static IViewer^ GetViewer(intptr_t id); 13 | static int AsProcessViewerEvent(const ProcessViewerEventInfo* info); 14 | internal: 15 | // Viewer waiting for ID 16 | static Viewer^ _viewerWaiting; 17 | // Any viewer object 18 | static AnyViewer _anyViewer; 19 | private: 20 | static void Register(Viewer^ viewer, const ViewerInfo& vi); 21 | private: 22 | // Registered opened viewers 23 | static List _viewers; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /FarNet/FarNetMan/Window.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace FarNet 4 | {; 5 | ref class Window sealed : IWindow 6 | { 7 | public: 8 | virtual property bool IsModal { bool get() override; } 9 | virtual property int Count { int get() override; } 10 | virtual property WindowKind Kind { WindowKind get() override; } 11 | public: 12 | virtual IFace^ GetAt(int index) override; 13 | virtual IntPtr GetIdAt(int index) override; 14 | virtual String^ GetNameAt(int index) override; 15 | virtual void SetCurrentAt(int index) override; 16 | virtual WindowKind GetKindAt(int index) override; 17 | internal: 18 | static Window Instance; 19 | private: 20 | Window() {} 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /JavaScriptFar/Samples/extras/test-MyLibForJS.ps1: -------------------------------------------------------------------------------- 1 | # This script creates the library MyLibForJS.dll for test-MyLibForJS.js. 2 | # The library provides MyLibForJS.DifficultForJS with two methods: 3 | # - static method Job1() 4 | # - object method Job2() 5 | 6 | $ErrorActionPreference=1 7 | 8 | $dll = "$env:TEMP\MyLibForJS.dll" 9 | if (Test-Path $dll) { 10 | return 11 | } 12 | 13 | Add-Type -OutputAssembly $dll @' 14 | namespace MyLibForJS 15 | { 16 | public class DifficultForJS 17 | { 18 | public static string Job1() 19 | { 20 | return "done Job1"; 21 | } 22 | 23 | public string Job2() 24 | { 25 | return "done Job2"; 26 | } 27 | } 28 | } 29 | '@ 30 | -------------------------------------------------------------------------------- /RedisKit/Commands/TreeCommand.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using RedisKit.Panels; 3 | 4 | namespace RedisKit.Commands; 5 | 6 | sealed class TreeCommand : BaseCommand 7 | { 8 | readonly string _colon; 9 | readonly string? _root; 10 | 11 | public TreeCommand(CommandParameters parameters) : base(parameters) 12 | { 13 | _colon = parameters.GetString(Param.Colon) ?? ":"; 14 | _root = parameters.GetString(Param.Root); 15 | 16 | // ensure root ends with colon 17 | if (_root is { } && !_root.EndsWith(_colon)) 18 | _root += _colon; 19 | } 20 | 21 | public override void Invoke() 22 | { 23 | new KeysExplorer(Database, _colon, _root, null) 24 | .CreatePanel() 25 | .Open(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Test/Dialog/Test-Message.ShortWithButtons.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Short text and relatively long button line. 4 | 5 | .Description 6 | FarNet 5.0.55: buttons were shown out of the dialog box. 7 | #> 8 | 9 | run { 10 | $a = New-Object FarNet.MessageArgs 11 | $a.Text = 'Short text' 12 | $a.Caption = 'Short text' 13 | $a.Buttons = "Long button 1", "Long button 2" 14 | $a.Position = New-Object FarNet.Point 1, 1 15 | $null = $Far.Message($a) 16 | } 17 | job { 18 | Assert-Far -Dialog 19 | Assert-Far @( 20 | $r = $__.Rect 21 | $r.Top -eq 1 22 | $r.Left -eq 1 23 | $r.Right -eq 45 24 | $r.Bottom -eq 7 25 | ) 26 | } 27 | macro 'Keys"Esc" -- exit dialog' 28 | -------------------------------------------------------------------------------- /Test/Script/Snippet.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Tests Snippet.ps1 indent, tabs, escaping. 4 | #> 5 | 6 | job { 7 | Open-FarEditor "$env:TEMP\$([guid]::NewGuid()).ps1" -DisableHistory -DeleteSource File 8 | } 9 | 10 | job { 11 | $Editor = $__ 12 | $Editor.ExpandTabs = 'All' 13 | $Editor.TabSize = 2 14 | $Editor.InsertText(' ') 15 | Snippet.ps1 foreach 16 | } 17 | 18 | job { 19 | Assert-Far -Editor 20 | $Editor = $__ 21 | Assert-Far $Editor.Count -eq 3 22 | Assert-Far $Editor.Caret.X -eq 16 23 | Assert-Far $Editor[0].Text -eq ' foreach($_ in ) {' 24 | Assert-Far $Editor[1].Text -eq ' $_' 25 | Assert-Far $Editor[2].Text -eq ' }' 26 | } 27 | 28 | job { 29 | $__.Close() 30 | } 31 | -------------------------------------------------------------------------------- /FSharpFar/samples/PowerShellFar/PanelObjects.fsx: -------------------------------------------------------------------------------- 1 | (* 2 | The script shows how to use PowerShellFar object panel in order to browse 3 | some objects created in the script. Note that opening the panel normally 4 | should be the last script statement. 5 | *) 6 | 7 | // Some sample data (using F# 4.6 anonymous records). 8 | let persons = [| 9 | {| Name = "John Doe"; Id = 1; Tags = [| "unknown"; "stranger" |] |} 10 | {| Name = "Anna Kern"; Id = 2; Tags = [| "heroine" |] |} 11 | {| Name = "Fluppy Foo"; Id = 3; Tags = null |} 12 | |] 13 | 14 | // Call Out-FarPanel in order to show our data in the panel. 15 | open FarNet.FSharp 16 | PSFar.Invoke("$args[0] | Out-FarPanel", [| persons |]) 17 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-160904.Editor.Load.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | # open test file, type code, do not save 4 | Open-FarEditor c:/tmp/tmp.fsx -CodePage 65001 -DisableHistory 5 | $Far.Editor.SetText('printfn "привет_160904_185241"') 6 | } 7 | macro @' 8 | Plugin.Menu("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "65BD5625-769A-4253-8FDE-FFCC3F72489D") 9 | Keys'L' -- load script 10 | '@ 11 | job { 12 | $editor = $Far.Editor 13 | Assert-Far -Editor 14 | Assert-Far @( 15 | $editor[0].Text -ceq '[Loading C:\tmp\tmp.fsx]' 16 | $editor[1].Text -ceq 'привет_160904_185241' 17 | ) 18 | } 19 | macro "Keys'Esc Esc' -- exit two editors" 20 | job { 21 | Remove-Item c:/tmp/tmp.fsx 22 | } 23 | -------------------------------------------------------------------------------- /Test/Host/Test-Read-Host-1_CC.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Read-Host 1 line prompt 4 | #> 5 | 6 | job { $Psf.RunCommandConsole() } 7 | 8 | run { 9 | Assert-Far -DialogTypeId ([PowerShellFar.Guids]::ReadCommandDialog) 10 | $Far.Dialog[1].Text = 'Read-Host -Prompt Prompt' 11 | } 12 | keys Enter 13 | job { 14 | Assert-Far -DialogTypeId ([PowerShellFar.Guids]::ReadLineDialog) 15 | Assert-Far $Far.Dialog[0].Text -eq 'Prompt: ' 16 | $Far.Dialog[1].Text = '090328_192727' 17 | } 18 | keys Enter 19 | job { 20 | Assert-Far $Far.UI.GetBufferLineText(-3) -eq 'Prompt: 090328_192727' 21 | Assert-Far $Far.UI.GetBufferLineText(-2) -eq '090328_192727' 22 | } 23 | 24 | keys Esc # exit CC 25 | -------------------------------------------------------------------------------- /Vessel/Settings.cs: -------------------------------------------------------------------------------- 1 | 2 | using FarNet; 3 | 4 | namespace Vessel; 5 | 6 | public sealed class Settings : ModuleSettings 7 | { 8 | public static Settings Default { get; } = new Settings(); 9 | 10 | public class Data 11 | { 12 | public int MaximumDayCount { get; set; } = 42; 13 | 14 | public int MaximumFileAge { get; set; } = 365; 15 | 16 | public int MaximumFileCount { get; set; } = 1000; 17 | 18 | public int MaximumFileCountFromFar { get; set; } = 1000; 19 | 20 | public int MinimumRecentFileCount { get; set; } = 10; 21 | 22 | public int Limit0 { get; set; } = 2; 23 | 24 | public string ChoiceLog { get; set; } = string.Empty; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /web.ps1: -------------------------------------------------------------------------------- 1 | 2 | [System.Net.ServicePointManager]::SecurityProtocol = "$([System.Net.ServicePointManager]::SecurityProtocol),Tls11,Tls12" 3 | $web = New-Object -TypeName System.Net.WebClient 4 | $web.UseDefaultCredentials = $true 5 | 6 | $uri = 'https://raw.githubusercontent.com/nightroman/FarNet/main/PowerShellFar/Modules/FarPackage/FarPackage.psm1' 7 | Write-Host "Importing $uri" 8 | Invoke-Expression $web.DownloadString($uri) 9 | Write-Host @' 10 | Imported commands (for more details use: Get-Help ): 11 | Install-FarPackage - installs or updates one package 12 | Update-FarPackage - updates all installed packages 13 | Uninstall-FarPackage - removes the specified package 14 | '@ 15 | -------------------------------------------------------------------------------- /FarNet/FarNet/Enums/PlaceKind.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Kinds of screen or text places. 9 | /// 10 | /// 11 | /// A place is completely defined by its kind and coordinates (). 12 | /// 13 | public enum PlaceKind 14 | { 15 | /// 16 | None = 0, 17 | 18 | /// 19 | /// Continuous stream place. Example: classic editor selection. 20 | /// 21 | Stream = 1, 22 | 23 | /// 24 | /// Rectangular place, block of columns. Example: column editor selection. 25 | /// 26 | Column = 2, 27 | } 28 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/SetTextEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Update file from text arguments. 9 | /// 10 | /// See 11 | /// See 12 | /// See 13 | public class SetTextEventArgs(ExplorerModes mode, FarFile file, string text) : ExplorerFileEventArgs(mode, file) 14 | { 15 | /// 16 | /// Gets the text to be imported. 17 | /// 18 | public string Text { get; } = text; 19 | } 20 | -------------------------------------------------------------------------------- /Test/Dialog/zoo-Mantis-2511.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | http://bugs.farmanager.com/view.php?id=2511 4 | #> 5 | 6 | macro 'Keys"CtrlG" -- open dialog' 7 | job { 8 | Assert-Far -Dialog 9 | } 10 | macro @' 11 | Plugin.Menu("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "7DEF4106-570A-41AB-8ECB-40605339E6F7") 12 | Keys"1" -- open command box 13 | '@ 14 | job { 15 | Assert-Far -DialogTypeId 416ff960-9b6b-4f3f-8bda-0c9274c75e53 16 | $Far.Dialog[2].Text = '$Far.Dialog' 17 | } 18 | macro 'Keys"Enter" -- invoke, *** USED TO HANG ***' 19 | job { 20 | Assert-Far -Viewer 21 | } 22 | macro 'Keys"Esc" -- exit viewer' 23 | job { 24 | Assert-Far -Dialog 25 | } 26 | macro 'Keys"Esc" -- exit dialog' 27 | -------------------------------------------------------------------------------- /Zoo/FSharpFar/samples/Charting/LineChart.fs: -------------------------------------------------------------------------------- 1 | 2 | module LineChart 3 | open System.Windows.Forms 4 | open System.Windows.Forms.DataVisualization.Charting 5 | 6 | type LineChartForm(title, xs : float seq) as self = 7 | inherit Form(Text = title) 8 | let chart = new Chart(Dock = DockStyle.Fill) 9 | let area = new ChartArea(Name = "Area1") 10 | let series = new Series() 11 | do 12 | series.ChartType <- SeriesChartType.Line 13 | xs |> Seq.iter (series.Points.Add >> ignore) 14 | series.ChartArea <- "Area1" 15 | chart.Series.Add series 16 | chart.ChartAreas.Add area 17 | self.Controls.Add chart 18 | self.Load.Add(fun _ -> self.Activate()) 19 | -------------------------------------------------------------------------------- /Zoo/FarNet.Works.Editor/EditorTools.cs: -------------------------------------------------------------------------------- 1 | /// 2 | // how to find if Colorer works without Far settings 3 | // not cached, the public method is cached in C++ 4 | public static bool HasColorer(IEditor editor) 5 | { 6 | var guidColorer = new Guid("d2f36b62-a470-418d-83a3-ed7a3710e5b5"); 7 | var lineStart = editor.Frame.VisibleLine; 8 | var lineEnd = lineStart + editor.WindowSize.Y; 9 | var colors = new List(); 10 | for (int i = lineStart; i < lineEnd; ++i) 11 | { 12 | editor.GetColors(i, colors); 13 | if (colors.Count > 0) 14 | return colors.FirstOrDefault(x => x.Owner == guidColorer) != null; 15 | } 16 | return false; 17 | } 18 | /// 19 | -------------------------------------------------------------------------------- /Drawer/Drawer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | C:\Bin\Far\x64 4 | $(FarHome)\FarNet\Modules\$(AssemblyName) 5 | false 6 | net10.0 7 | enable 8 | enable 9 | true 10 | FarNet250103;FarNet250104 11 | 12 | 13 | 14 | False 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /FarNet/FarNet/History/GetHistoryArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Arguments of . 9 | /// 10 | public class GetHistoryArgs 11 | { 12 | /// 13 | /// Specifies command, folder, editor, viewer. 14 | /// 15 | public HistoryKind Kind { get; set; } 16 | 17 | /// 18 | /// Specifies the dialog history name. 19 | /// 20 | public string? Name { get; set; } 21 | 22 | /// 23 | /// Tells to take the specified number of last items. 24 | /// 25 | public int Last { get; set; } 26 | } 27 | -------------------------------------------------------------------------------- /Modules/IronPythonFar/Samples/http_client.py: -------------------------------------------------------------------------------- 1 | # This script uses %FARHOME%\FarNet\Modules\IronPythonFar\Lib libraries 2 | # https://docs.python.org/3/library/http.client.html#module-http.client 3 | 4 | import http.client 5 | 6 | conn = http.client.HTTPSConnection("www.python.org") 7 | conn.request("GET", "/") 8 | r1 = conn.getresponse() 9 | print(r1.status, r1.reason) 10 | 11 | # get entire content 12 | data1 = r1.read() 13 | print(len(data1)) 14 | print(data1) 15 | 16 | # get data in chunks 17 | conn.request("GET", "/") 18 | r1 = conn.getresponse() 19 | while True: 20 | chunk = r1.read(100) 21 | if not chunk: 22 | break 23 | print(repr(chunk)) 24 | 25 | conn.close() 26 | -------------------------------------------------------------------------------- /Test/Host/Test-CC-KeyPanel.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Panel keys in command console. 4 | #> 5 | 6 | ### init 7 | job { $__.GoToPath($PSCommandPath) } 8 | job { $Psf.RunCommandConsole() } 9 | 10 | ### Up/Down 11 | keys Up 12 | job { 13 | [FarNet.Works.Tasks2]::Wait('Wait', { $Far.Window.Kind -eq 'Dialog' -and $Far.Dialog.TypeId -eq ([PowerShellFar.Guids]::ReadCommandDialog) }) 14 | Assert-Far ($__.CurrentFile -ne 'Test-CC-KeyPanel.fas.ps1') 15 | } 16 | keys Down 17 | job { 18 | [FarNet.Works.Tasks2]::Wait('Wait', { $Far.Window.Kind -eq 'Dialog' -and $Far.Dialog.TypeId -eq ([PowerShellFar.Guids]::ReadCommandDialog) }) 19 | Assert-Far -FileName 'Test-CC-KeyPanel.fas.ps1' 20 | } 21 | 22 | keys Esc # exit CC 23 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/TextChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// TextChanged event arguments for , . 9 | /// 10 | /// Edit control. 11 | /// New text. 12 | public sealed class TextChangedEventArgs(IControl edit, string text) : AnyEventArgs(edit) 13 | { 14 | /// 15 | /// New text. 16 | /// 17 | public string Text { get; } = text; 18 | 19 | /// 20 | /// Ignore changes. 21 | /// 22 | public bool Ignore { get; set; } 23 | } 24 | -------------------------------------------------------------------------------- /FarNet/FarNet/Explorer/SetFileEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet; 6 | 7 | /// 8 | /// Update file from file arguments. 9 | /// 10 | /// See 11 | /// See 12 | /// See 13 | public class SetFileEventArgs(ExplorerModes mode, FarFile file, string fileName) : ExplorerFileEventArgs(mode, file) 14 | { 15 | /// 16 | /// Gets the source file path. 17 | /// 18 | public string FileName { get; } = fileName; 19 | } 20 | -------------------------------------------------------------------------------- /FarNet/FarNetMan/EditorBookmark.h: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | #pragma once 6 | 7 | namespace FarNet 8 | {; 9 | ref class EditorBookmark sealed : IEditorBookmark 10 | { 11 | public: 12 | virtual ICollection^ Bookmarks() override; 13 | virtual void AddSessionBookmark() override; 14 | virtual void ClearSessionBookmarks() override; 15 | virtual void RemoveSessionBookmarkAt(int index) override; 16 | virtual ICollection^ SessionBookmarks() override; 17 | virtual void GoToNextSessionBookmark() override; 18 | virtual void GoToPreviousSessionBookmark() override; 19 | internal: 20 | static EditorBookmark Instance; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /Samples/FarTask/Parameters=2.far.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | How to pass parameters in script blocks. 4 | 5 | .Description 6 | (1) Define parameters in script blocks as usual. 7 | (2) Specify them as dynamic parameters for Start-FarTask. 8 | (!) Avoid switch parameters or specify after parameter Script. 9 | #> 10 | 11 | Start-FarTask -Param1 Hi -Param2 Joe { 12 | param($Param1, $Param2) 13 | 14 | # script parameters are defined 15 | if ($Param1 -ne 'Hi' -or $Param2 -ne 'Joe') {throw} 16 | 17 | # key values are added to $Data 18 | if ($Data.Param1 -ne 'Hi' -or $Data.Param2 -ne 'Joe') {throw} 19 | 20 | job { 21 | # key values are added to $Data 22 | $Far.Message($Data.Param1 + ' ' + $Data.Param2) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /FarNet/FarNet/Tools/Xml/Xslt.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | using System.Xml.XPath; 7 | 8 | namespace FarNet.Tools; 9 | 10 | static class Xslt 11 | { 12 | public static XPathResultType[] ArgStringString { get; } = [XPathResultType.String, XPathResultType.String]; 13 | 14 | public static string ArgumentToString(object value) 15 | { 16 | if (value is string text) 17 | return text; 18 | 19 | if (value is not XPathNodeIterator iter) 20 | throw new InvalidOperationException("Cannot convert to string."); 21 | 22 | if (!iter.MoveNext()) 23 | return string.Empty; 24 | 25 | return iter.Current!.Value; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /PowerShellFar/Bench/Show-EditorColor.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Shows color information for the current editor. 4 | Author: Roman Kuzmin 5 | #> 6 | 7 | Assert-Far -Editor -Message 'Run this script from editor.' -Title Show-EditorColor.ps1 8 | 9 | $Editor = $Far.Editor 10 | $colors = [System.Collections.Generic.List[FarNet.EditorColorInfo]]::new() 11 | foreach($line in $Editor.Lines) { 12 | '' 13 | $text = $line.Text 14 | $Editor.GetColors($line.Index, $colors) 15 | foreach($color in $colors | Sort-Object Priority, Start, End) { 16 | if ($color.End -le $text.Length) { 17 | '{0,-80} : {1}' -f $color, $text.Substring($color.Start, $color.End - $color.Start) 18 | } 19 | else { 20 | "$color" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Test/Basics.Tasks/Parameters.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | ### =1 3 | job { 4 | & "$env:FarNetCode\Samples\FarTask\Parameters=1.far.ps1" 5 | [FarNet.Tasks]::WaitForDialog(999) 6 | } 7 | job { 8 | Assert-Far $__[1].Text -eq 'Hi Joe (42)' 9 | $__.Close() 10 | } 11 | 12 | ### =2 13 | job { 14 | & "$env:FarNetCode\Samples\FarTask\Parameters=2.far.ps1" 15 | [FarNet.Tasks]::WaitForDialog(999) 16 | } 17 | job { 18 | Assert-Far $__[1].Text -eq 'Hi Joe' 19 | $__.Close() 20 | } 21 | 22 | ### =3 23 | run { 24 | Start-FarTask "$env:FarNetCode\Samples\FarTask\Parameters=3.fas.ps1" -Param1 Hi -Param2 Joe 25 | } 26 | job { 27 | [FarNet.Tasks]::WaitForDialog(999) 28 | } 29 | job { 30 | Assert-Far $__[1].Text -eq 'Hi Joe' 31 | $__.Close() 32 | } 33 | -------------------------------------------------------------------------------- /FSharpFar/tests/PSF.test/Test-181218.PanelVariables2.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $Far.InvokeCommand("fs:exec file=$env:FarNetCode\FSharpFar\samples\PowerShellFar\PanelSessionVariables.fsx") 4 | } 5 | job { 6 | Assert-Far -Plugin 7 | Assert-Far $Far.Panel.Title -eq 'Objects' 8 | $files = $Far.Panel.GetFiles() 9 | Assert-Far @( 10 | $files.Count -eq 2 11 | $files[0].Name -eq 'psf' -and $files[0].Description -eq 'PowerShellFar.Actor' 12 | $files[1].Name -eq 'far' -and $files[1].Description -eq 'FarNet.Far1' 13 | ) 14 | } 15 | macro "Keys'Esc' -- exit panel" 16 | macro @' 17 | Plugin.Menu("10435532-9BB3-487B-A045-B0E6ECAAB6BC", "65BD5625-769A-4253-8FDE-FFCC3F72489D") 18 | Keys'0 Del Esc' -- kill session 19 | '@ 20 | -------------------------------------------------------------------------------- /FarNet/FarNet/About/Disposable.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace FarNet; 3 | 4 | /// 5 | /// Disposable object with . 6 | /// 7 | public abstract class Disposable : IDisposable 8 | { 9 | bool _IsDisposed; 10 | 11 | /// 12 | /// Gets the disposed state. 13 | /// 14 | public bool IsDisposed => IsDisposed; 15 | 16 | /// 17 | /// Disposes this object. 18 | /// 19 | public void Dispose() 20 | { 21 | if (!_IsDisposed) 22 | { 23 | Disposing(); 24 | _IsDisposed = true; 25 | GC.SuppressFinalize(this); 26 | } 27 | } 28 | 29 | /// 30 | /// Implements disposing. 31 | /// 32 | protected abstract void Disposing(); 33 | } 34 | -------------------------------------------------------------------------------- /PowerShellFar/Host/VariablePath.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using PowerShellFar.Commands; 3 | using System.Management.Automation; 4 | 5 | namespace PowerShellFar; 6 | 7 | internal class VariablePath() : PSVariable("_path", null, ScopedItemOptions.ReadOnly) 8 | { 9 | public override string Description { get => "Cursor file, folder, provider path."; set => base.Description = value; } 10 | 11 | public override object? Value 12 | { 13 | set => base.Value = value; 14 | get 15 | { 16 | return Far.Api.Window.Kind switch 17 | { 18 | WindowKind.Editor => Far.Api.Editor!.FileName, 19 | WindowKind.Viewer => Far.Api.Viewer!.FileName, 20 | _ => BaseFileCmdlet.GetCurrentPath(Far.Api.Panel!), 21 | }; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /PowerShellFar/UI/InputBox2.cs: -------------------------------------------------------------------------------- 1 | using FarNet; 2 | using FarNet.Tools; 3 | 4 | namespace PowerShellFar.UI; 5 | 6 | sealed class InputBox2 : InputBox 7 | { 8 | public InputBox2(string? prompt = null, string? title = null) : base(prompt, title) 9 | { 10 | Dialog.TypeId = new System.Guid(Guids.InputDialog); 11 | 12 | // hotkeys 13 | Edit.KeyPressed += (sender, e) => 14 | { 15 | switch (e.Key.VirtualKeyCode) 16 | { 17 | case KeyCode.Tab: 18 | e.Ignore = true; 19 | EditorKit.ExpandCode(Edit.Line, null); 20 | break; 21 | case KeyCode.F1: 22 | e.Ignore = true; 23 | Help.ShowHelpForContext(HelpTopic.InvokeCommands); 24 | break; 25 | } 26 | }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Test/Panels.Cmd/Test-ExpandCodeWithPrefix.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | # ps: with no spaces 3 | job { 4 | $Far.CommandLine.Text = 'ps:ls -pa' 5 | $Psf.ExpandCode($Far.CommandLine) 6 | Assert-Far $Far.CommandLine.Text -eq 'ps:ls -Path' 7 | } 8 | 9 | # ps: with spaces before and after 10 | job { 11 | $Far.CommandLine.Text = ' ps: ls -pa' 12 | $Psf.ExpandCode($Far.CommandLine) 13 | Assert-Far $Far.CommandLine.Text -eq ' ps: ls -Path' 14 | } 15 | 16 | # vps: with a space after 17 | job { 18 | $Far.CommandLine.Text = 'vps: ls -pa' 19 | $Psf.ExpandCode($Far.CommandLine) 20 | Assert-Far $Far.CommandLine.Text -eq 'vps: ls -Path' 21 | } 22 | 23 | # clean command line 24 | job { 25 | $Far.CommandLine.Text = '' 26 | } 27 | -------------------------------------------------------------------------------- /Test/Panels/Test-Panel_090321_210416.fas.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Fixed _090321_210416 4 | #> 5 | 6 | job { 7 | # go to the folder with some files 8 | $__.CurrentDirectory = 'C:\ROM\APS' 9 | } 10 | job { 11 | Assert-Far $__.CurrentIndex -eq 0 12 | } 13 | job { 14 | # open the panel 15 | & "$env:FarNetCode\Samples\Tests\Test-Panel.far.ps1" 16 | } 17 | # add 2 items, go to end 18 | macro 'Keys"F7 F7 End"' 19 | job { 20 | Assert-Far $__.CurrentIndex -eq 2 21 | } 22 | # close the panel, choose '1' in the dialog 23 | macro 'Keys"Esc 1"' 24 | job { 25 | # exited? 26 | Assert-Far -Native 27 | # _090321_210416 fixed: index used to be still 2; it is 0 now! 28 | Assert-Far $__.CurrentIndex -eq 0 29 | } 30 | -------------------------------------------------------------------------------- /FSharpFar/tests/AutoTest.fs: -------------------------------------------------------------------------------- 1 | // Common test helpers. 2 | [] 3 | module AutoTest 4 | open FarNet 5 | open FarNet.FSharp 6 | 7 | let run name = 8 | Test.Run(name) 9 | 10 | let isWizard () = 11 | Window.IsDialog() && far.Dialog[0].Text = "Wizard" 12 | 13 | let isError () = 14 | Window.IsDialog() && far.Dialog[0].Text = "Exception" && far.Dialog[1].Text = "Oh" 15 | 16 | let isMyPanel () = 17 | Window.IsModulePanel() && ((far.Panel :?> Panel).Title = "Objects") 18 | 19 | let showWideDialog () = 20 | far.Message "relatively_long_text_message_for_relatively_wide_dialog" 21 | 22 | let isWideDialog () = 23 | Window.IsDialog() && far.Dialog[1].Text = "relatively_long_text_message_for_relatively_wide_dialog" 24 | -------------------------------------------------------------------------------- /FarNet/FarNet/Forms/KeyPressedEventArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | namespace FarNet.Forms; 6 | 7 | /// 8 | /// KeyPressed event arguments for and . 9 | /// 10 | /// Current control. 11 | /// The key. 12 | public sealed class KeyPressedEventArgs(IControl control, KeyInfo key) : AnyEventArgs(control) 13 | { 14 | /// 15 | /// The key. 16 | /// 17 | public KeyInfo Key { get; } = key; 18 | 19 | /// 20 | /// Ignore further processing. 21 | /// 22 | public bool Ignore { get; set; } 23 | } 24 | -------------------------------------------------------------------------------- /PowerShellFar/Bench/Get-FarVersion.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Gets versions of Far, FarNet, PowerShell, PowerShellFar. 4 | Author: Roman Kuzmin 5 | #> 6 | 7 | #requires -Version 7.4 8 | $ErrorActionPreference=1; if ($Host.Name -ne 'FarHost') {throw 'Requires FarHost.'} 9 | 10 | if ((Get-Item $env:FARHOME\FarNet\FarNet.dll).VersionInfo.Comments -like '*DEBUG*') { Write-Host FN=DEBUG -ForegroundColor Red } 11 | if ((Get-Item $env:FARHOME\FarNet\Modules\PowerShellFar\PowerShellFar.dll).VersionInfo.Comments -like '*DEBUG*') { Write-Host PS=DEBUG -ForegroundColor Red } 12 | 13 | [ordered]@{ 14 | Far = $Far.FarVersion 15 | FarNet = $Far.FarNetVersion 16 | PowerShell = $PSVersionTable.PSVersion 17 | PowerShellFar = $Host.Version 18 | } 19 | -------------------------------------------------------------------------------- /FarNet/FarNet/Module/ModuleHostAttribute.cs: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | using System; 6 | 7 | namespace FarNet; 8 | 9 | /// 10 | /// Module host attribute. 11 | /// 12 | [AttributeUsage(AttributeTargets.Class)] 13 | public sealed class ModuleHostAttribute : Attribute 14 | { 15 | /// 16 | /// Tells to load and connect the host always. There should be good reasons for 'true'. 17 | /// 18 | /// 19 | /// If the module host is the only implemented module item then this flag 20 | /// has to be set to true. Otherwise the host has no chances to be used. 21 | /// 22 | public bool Load { get; set; } 23 | } 24 | -------------------------------------------------------------------------------- /FarNet/FarNetMan/AssemblyResolver.cpp: -------------------------------------------------------------------------------- 1 | 2 | // FarNet plugin for Far Manager 3 | // Copyright (c) Roman Kuzmin 4 | 5 | #include "stdafx.h" 6 | #include "AssemblyResolver.h" 7 | 8 | namespace FarNet 9 | { 10 | void AssemblyResolver::Init() 11 | { 12 | // load FarNet explicitly 13 | Assembly::LoadFrom(Environment::ExpandEnvironmentVariables("%FARHOME%\\FarNet\\FarNet.dll")); 14 | 15 | //! add C++/CLI handler, adding C# handler will crash 16 | AppDomain::CurrentDomain->AssemblyResolve += gcnew ResolveEventHandler(AssemblyResolve); 17 | } 18 | 19 | Assembly^ AssemblyResolver::AssemblyResolve(Object^ /*sender*/, ResolveEventArgs^ args) 20 | { 21 | return Works::AssemblyResolver::ResolveAssembly(args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /GitKit/Panels/BasePanel.cs: -------------------------------------------------------------------------------- 1 | using LibGit2Sharp; 2 | 3 | namespace GitKit.Panels; 4 | 5 | public abstract class BasePanel(BaseExplorer explorer) : AbcPanel(explorer) 6 | { 7 | public string GitDir => explorer.GitDir; 8 | 9 | public BaseExplorer MyExplorer => (BaseExplorer)Explorer; 10 | 11 | public Repository UseRepository() 12 | { 13 | return new Repository(GitDir); 14 | } 15 | 16 | protected void CompareCommits(string oldCommitSha, string newCommitSha) 17 | { 18 | new ChangesExplorer(GitDir, new() 19 | { 20 | Kind = ChangesExplorer.Kind.CommitsRange, 21 | NewCommitSha = newCommitSha, 22 | OldCommitSha = oldCommitSha, 23 | }) 24 | .CreatePanel() 25 | .OpenChild(this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /JavaScriptFar/Tests/flow.fas.ps1: -------------------------------------------------------------------------------- 1 | 2 | job { 3 | $Far.InvokeCommand("js:@ $env:FarNetCode\JavaScriptFar\Samples\async\flow.js") 4 | } 5 | Start-Sleep -Milliseconds 100 6 | job { 7 | Assert-Far -Dialog 8 | Assert-Far $Far.Dialog[0].Text -eq dialog1 9 | 10 | $Far.Dialog[1].Text = 'result1' 11 | $Far.Dialog.Close() 12 | } 13 | Start-Sleep -Milliseconds 100 14 | job { 15 | Assert-Far -Dialog 16 | Assert-Far $Far.Dialog[0].Text -eq result1 17 | 18 | $Far.Dialog[1].Text = 'result2' 19 | $Far.Dialog.Close() 20 | } 21 | Start-Sleep -Milliseconds 100 22 | job { 23 | Assert-Far -Dialog 24 | Assert-Far $Far.Dialog[0].Text -eq result 25 | Assert-Far $Far.Dialog[1].Text -eq result2 26 | $Far.Dialog.Close() 27 | } 28 | -------------------------------------------------------------------------------- /Test/Basics/Test-AnyPanel.far.ps1: -------------------------------------------------------------------------------- 1 | 2 | # the panel 3 | $Panel = $__ 4 | 5 | function TestPanelFlag($Flag) 6 | { 7 | # the original mode, to be restored 8 | $1 = $Panel.$Flag 9 | 10 | # test new mode 11 | $Panel.$Flag = !$1 12 | Assert-Far ($Panel.$Flag -ne $1) -Message "Flag = $Flag" 13 | 14 | # test/restore old mode 15 | $Panel.$Flag = $1 16 | Assert-Far ($Panel.$Flag -eq $1) -Message "Flag = $Flag" 17 | } 18 | 19 | ### test settable panel flags 20 | TestPanelFlag DirectoriesFirst 21 | 22 | ### test sort mode Unsorted, then set Name 23 | $Panel.SortMode = 'UnsortedReversed' 24 | Assert-Far ($Panel.SortMode -eq 'UnsortedReversed') 25 | $Panel.SortMode = 'Name' 26 | Assert-Far ($Panel.SortMode -eq 'Name') 27 | -------------------------------------------------------------------------------- /Test/Dialog/2020-11-18-1658-leak-crash.fas.ps1: -------------------------------------------------------------------------------- 1 | # Stop and Free were not called due to exception in Closing. 2 | # 2020-11-18-1658 After fixing it crashed at first. 3 | 4 | job { 5 | Assert-Far -Title Ensure -NoError 6 | 7 | $form = $Far.CreateDialog(-1, -1, 52, 3) 8 | $null = $form.AddText(1, 1, 50, 'throw-in-Closing') 9 | $form.add_Closing({ 10 | throw 42 11 | }) 12 | $form.Open() 13 | } 14 | job { 15 | Assert-Far -Dialog 16 | Assert-Far $__[0].Text -eq throw-in-Closing 17 | } 18 | keys Esc #! close by Esc 19 | job { 20 | Assert-Far -Dialog 21 | Assert-Far @( 22 | $__[0].Text -eq 'Error in Closing' 23 | $__[1].Text -eq '42' 24 | $global:Error.Count -ne 0 25 | ) 26 | $__.Close() 27 | 28 | $global:Error.Clear() 29 | } 30 | --------------------------------------------------------------------------------