Giter VIP home page Giter VIP logo

nightroman / farnet Goto Github PK

View Code? Open in Web Editor NEW
133.0 16.0 19.0 8.91 MB

Far Manager framework for .NET modules and scripts in PowerShell, F#, JavaScript.

Home Page: https://github.com/nightroman/FarNet/wiki

License: BSD 3-Clause "New" or "Revised" License

PowerShell 29.56% C# 50.50% C++ 12.67% Lua 0.36% F# 6.42% HTML 0.01% XQuery 0.06% Python 0.07% JavaScript 0.35%
far-manager plugin dot-net c-sharp f-sharp powershell javascript

farnet's Introduction

FarNet

Far Manager platform for .NET modules and scripts in PowerShell, F#, JavaScript

  • Wiki - framework, modules, libraries
  • Issues - bug reports and problems
  • Discussions - questions and ideas

Prerequisites

.NET 8.0

Download and install .NET 8.0 SDK or runtime, x64 or x86 depending on Far Manager.
SDK is needed for developing FarNet modules but recommended in any case.

Check for existing installations by these commands:

dotnet --version
dotnet --info

Visual C++ Redistributable

Look at the installed programs and find entries like:

  • Microsoft Visual C++ 2015-2022 Redistributable (x64)
  • Microsoft Visual C++ 2015-2022 Redistributable (x86)

If they are missing, then install the required. Links are not provided, they keep changing.

Far Manager

Choose the required from downloads.
Normally the stable build is recommended.

Install using PowerShell

This way avoids manual steps and allows updates later.

Close Far Manager and start the PowerShell console.

Change to the Far Manager directory

Set-Location "C:\Program Files\Far Manager"

Import Far package functions

iex (iwr https://raw.githubusercontent.com/nightroman/FarNet/main/web.ps1)

If it fails on older systems, try

[Net.ServicePointManager]::SecurityProtocol = "Tls11,Tls12,$([Net.ServicePointManager]::SecurityProtocol)"
iex (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/nightroman/FarNet/main/web.ps1')

Install FarNet

Install-FarPackage FarNet

Install modules

Install-FarPackage FarNet.CopyColor
Install-FarPackage FarNet.Drawer
Install-FarPackage FarNet.EditorKit
Install-FarPackage FarNet.Explore
Install-FarPackage FarNet.FolderChart
Install-FarPackage FarNet.FSharpFar
Install-FarPackage FarNet.GitKit
Install-FarPackage FarNet.JavaScriptFar
Install-FarPackage FarNet.PowerShellFar
Install-FarPackage FarNet.RedisKit
Install-FarPackage FarNet.RightControl
Install-FarPackage FarNet.RightWords
Install-FarPackage FarNet.Vessel

Install libraries

Install-FarPackage FarNet.FSharp.Charting
Install-FarPackage FarNet.FSharp.Data
Install-FarPackage FarNet.FSharp.PowerShell
Install-FarPackage FarNet.FSharp.Unquote
Install-FarPackage FarNet.Redis
Install-FarPackage FarNet.ScottPlot
Install-FarPackage FarNet.Stateless
Install-FarPackage FarNet.SQLite

You may start Far Manager after this. Modules are installed in %FARHOME%\FarNet\Modules. Libraries are installed in %FARHOME%\FarNet\Lib.

Update using PowerShell

FarNet packages installed by Install-FarPackage may be updated in the same way.

Close Far Manager, open PowerShell console, and invoke

Set-Location "C:\Program Files\Far Manager"
iex (iwr https://raw.githubusercontent.com/nightroman/FarNet/main/web.ps1)

To update all packages, use

Update-FarPackage

To update one package, use Install-FarPackage

Install-FarPackage FarNet.PowerShellFar

To remove one package, use Uninstall-FarPackage

Uninstall-FarPackage FarNet.PowerShellFar

Install packages manually

Given a package Bar, download it as https://nuget.org/api/v2/package/Bar

The downloaded file name is Bar.<version>.nupkg. This is a zip archive, you may save it with the zip extension for easier unpacking.

All needed files are in the folder tools. This folder contains FarHome and may contain FarHome.x64 and FarHome.x86 folders.

Copy FarHome items to the Far Manager home directory preserving the folder structure. For example, by this command in Far Manager:

robocopy FarHome "%FARHOME%" /s

If FarHome.x64 and FarHome.x86 exist then, depending on x64 or x86, copy items of FarHome.x64 or FarHome.x86 to Far Manager:

robocopy FarHome.x64 "%FARHOME%" /s
robocopy FarHome.x86 "%FARHOME%" /s

farnet's People

Contributors

nightroman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

farnet's Issues

HtmlToFarHelp: нюансы со вложенными списками

<ul>
<li>Внешний список
  <ul>
  <li>Вложенный список</li>
  </ul>
  Продолжение элемента внешнего списка
</li>
<li>Следующий элемент внешнего списка</li>
</ul>
   • §¦Внешний список

  
       • §¦Вложенный список
  
  Продолжение элемента внешнего списка
   • §¦Следующий элемент внешнего списка
  • Как видно, "Продолжение элемента внешнего списка" вообще выпало из списка.
  • Начальная позиция "Продолжение ..." в данном примере 2, т.е. совпадает с таковой в html.
    Соответственно если начать текст с позиции 0, то и в hlf он будет стоять с начала строки, и как результат - склеится с предыдущей строкой.
  • И почему-то между внешним и вложенным списком интервал 2 строки. Если убрать из исходного html некоторые переносы строк, то лишних интервалов не будет.

HtmlToFarHelp: wrong handling of <br />

Sample markdown source:

Test
====

Definition list

term1
:	definition1 \
	sample

In html:

<h2>Test</h2>
<p>Definition list</p>
<dl>
<dt>term1</dt>
<dd>
definition1<br />
sample
</dd>
</dl>

Resulting hlf:

.Language=English,English
.Options CtrlStartPosChar=§¦


@Contents
$ #Test#

 Definition list

 term1
     §¦definition1
sample

That is wrong, because in Far help it looks like this:

Definition list

term1
    definition1 sample

I suppose the correct handling would be to indent next line after <br />, like this:

 term1
     §¦definition1
     §¦sample

PS Rework SyncPaths on invoking commands

Old behaviour: on invoking commands, set the current PowerShell location and
the process current directory to the active panel path.

New behaviour: on invoking commands, set the current PowerShell location to the
active panel path. Do not change the process current directory.

Some "lazy" scripts may be affected. Note that PowerShell scripts should not
rely on the process current directory, they should use PS provider locations.

NB Changing the process current directory could be removed long time ago.

Long paths

Windows PowerShell (used by PSF up to v5) has many problems with long paths.
In particular it cannot set the current location to a long path. PSF in such
cases asked users how to proceed with kind of useful but annoying dialogs.

PowerShell Core (used by PSF v6+) works better with long paths. In particular
it sets the current location just fine. Thus, these annoying errors are gone.
But if we keep temporarily changing the process current location then we get
new kind of errors (generic .NET and OS issue, not PowerShell).

That is why we finally retire changing the current directory.
This started to be clearly inconvenient in some cases.

NOTE PS and other applications may still have long path issues.
Try to avoid anything PowerShell "intensive" in long path locations.

PSF Cannot open panel after output

This works

$host | Out-FarPanel

This used to work but fails after some changes in Far about user screen

42
$host | Out-FarPanel

42 triggers ShowUserScreen. It is now kind of modal in Far and panels cannot be set current.

We need either exit user screen or make the switch to panels and opening async.

HtmlToFarHelp: увеличить интервал перед заголовками

Сейчас что до что после заголовка интервал одинаков - 1 строка.

Как правило, я каждый раз редактирую потом hlf вручную, чтобы между текстом, и последующим заголовком было две строки.

Возможно стоит сделать это настраиваемым.

Location on launch and exit

Is it possible to make active panel location per active directory where far was launched. And the other way - is it possible to set location in powershell after exiting Far per path in active panel when exiting?

Feature Request: Support Chocolatey distribution

Hello!
It would really great, if you consider some common channels of distribution, which much simplify install and upgrade.
Chocolatey is good example for it - you can specify dependencies which will automatically installed with you package (if them not exists already) and all your prereq are already exists in choco library.
Also, it comply with your current install method - it use nuget packages as container and then run powershell script that place files to its places. Also, they have some nice inbuild ps function like Get-AppInstallLocation to place module files into Far installation folder.

P.S. Many thanks for this plugins!

powershell 6 and command line defaults

Hello Roman,

hope you are doing well. I have a couple of questions:

  • I don't seem to be able to figure out how to make far use powershell 6, is this possible?
  • Is it possible to have far execute powershell by default, eg without the ps: prefix?

Many thanks,
Andrew

HtmlToFarHelp: игнорировать неподдерживаемые тэги

Такие как div, details, summary.

Их присутствие в исходном маркдаун обусловлено потребностью генерировать из него не только hlf, но и html.
Div в частности бывает необходим для того чтобы добавить информацию о стиле вложенного элемента.

В настоящий момент перед конвертацией в hlf удаляю всё неподдерживаемое скриптом.

Exception при загрузке

Впервые устанавил FarNet, по инструкции https://github.com/nightroman/FarNet#install-using-powershell
При запуске падает.

bug_report.txt

C:\Apps\Far3\Plugins>dotnet --version
7.0.306

C:\Apps\Far3\Plugins>dotnet --info
.NET SDK:
 Version:   7.0.306
 Commit:    f500069cb7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.306\

Host:
  Version:      7.0.9
  Architecture: x64
  Commit:       8e9a17b221

.NET SDKs installed:
  7.0.306 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

PowershellFar Console

For the last two years, I used daily as my shell environment
ConEmu + FarManager + PowerShellFar.

The startup task on ConEmu was
>d:\Bin\Far\Far.exe /w ps:$Psf.StartConsole()
as suggested here.

Also, I had made a multiple-color, two-lines custom prompt for my PowerShellFar Console.

I have build the majority of my ps scripts (100s) around the above environment,
utilizing the PowershellFar library, which I find extremely helpful.

After my FarNet update today, when I opened my shell I've got the error:

ps:$Psf.StartConsole()                                                                                 
ERROR: RuntimeException:                                                                               
Method invocation failed because [PowerShellFar.Actor] does not contain a method named 'StartConsole'. 

I traced the latest commits and History, and I've noticed that on version 5.2.0
Retired command console, and on 5.2.1 Editor console -> Interactive

To my opinion, Interactive is totally different experience compared to Console,
and PowershellFar's Console was one of the main strengths.

Please restore back PowershellFar Console!

PSF First output line is not colored

PowerShellFar 5.2.3
Script Write-Red.ps1

    function Write-Red ($text) {
        $color = $host.UI.RawUI.ForegroundColor
        $host.UI.RawUI.ForegroundColor = 'Red'
        $text
        $host.UI.RawUI.ForegroundColor = $color
    }

    Write-Red 'must be red, it is not in PSF 5.2.3'
    Write-Red 'must be red, it is'

It is a generic PS script, not specific for Far.
We can call it by powershell.exe

powershell.exe .\Write-Red.ps1

and it writes two red lines.

To make colored output, the script uses ForegroundColor instead of Write-Host -ForegroundColor .... This technique allows redirection of output, i.e. we can

powershell.exe .\Write-Red.ps1 > log.txt

and log.txt contains our two lines. This is not possible with Write-Host.

This technique of colored output is commonly used in PS, e.g. by

The problem

If we invoke the above script in PSF (or use the mentioned or similar tools in PSF):

ps: .\Write-Red.ps1

then the first line is not colored, as we expect.

The problem is caused by a known change in Far, to be discussed with its author.

Install/Update failed

When trying to install / update FarNet, I get error 400 (bad request), NuGet works. Tested on Windows 10 and Windows 10 Developer Virtual Machine from Microsoft without any changes (.NET 4.8 included with system).

HtmlToFarHelp fails on formatting inside link's body

Consider such source sample:

Test 1
======

[Sample _link_](http://example.com)
html
<h2>Test 1</h2>
<p><a href="http://example.com"><em>Sample</em> link</a></p>

This produces such hlf link: ~Sample ~@http://example.com@#link#. (Notice that link-part is here outside the link. But ok.)

Now consider another sample:

Test 1
======

[_Sample_ link](http://example.com)
html
<h2>Test 2</h2>
<p><a href="http://example.com"><em>Sample</em> link</a></p>

Such input now causes an error: Invalid or not supported HTML: Expected <a href=...>...</a>. At test2.html:2:34

I suppose that simplest way would be just to skip any formatting in link's body.

FSharpFar: Escape non-standard names on code completion

Example:

#I @"packages\FSharp.Management\lib\net40"
#r @"FSharp.Management.PowerShell.dll"

open FSharp.Management

// Let the type provider infer the signatures of available cmdlets
type PS = PowerShellProvider< "Microsoft.PowerShell.Management;Microsoft.PowerShell.Core" >
PS. // <- [Tab] here

As a result, FSharpFar correctly shows the menu with PS command names. But on selection it inserts names literally, i.e.

PS.Add-Content

Non-standard F# names should be escaped, i.e.

PS.``Add-Content``

Can't run FarNet under latest stable/nightly Far manager build

Hello,
I'm trying to run the latest (7.0.5) FarNet package under the latest stable (3.0.6060) or nightly (3.0.6117) Far manager build. But after installing the package, Far manager is failing to start, crashing on FarNet plugin.
I have tried to install some previous FarNet version (7.0.1), but no luck either.
Windows 11 22H2 Build 22621.963.
Any help/suggestions?
Thanks in advance!
bug_report.txt
far.mdmp.zip

.Net Core support

I could not find information about netcore support.
Also dotnet template for it would be great.

PSF: Pressing Tab in Editor throws an exception when "Cursor beyond end of line" is enabled

When editing a PowerShell script in Far Editor, pressing Tab on an empty line with the cursor past the end of line (such as when Auto Indent is enabled) causes the following exception to be thrown:

IndexOutOfRangeException:
Index was outside the bounds of the array.

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at PowerShellFar.EditorKit.NeedsTabExpansion(IEditor editor)
   at PowerShellFar.EditorKit.OnKeyDownPSFile(Object sender, KeyEventArgs e)
   at FarNet.Editor0.AsProcessEditorInput(ProcessEditorInputInfo* info)
   at ProcessEditorInputW(ProcessEditorInputInfo* info)

An example of how to reproduce this:

  • Open a PowerShell script, or edit a new one, in Far Editor.
  • Set the following options, if not already set:
    [x] Cursor beyond end of line
    [x] Auto indent (not required for the example, but it makes my life easier 😄 )
  • Enter the following starting at any column > 1:
    if ($foo -eq "bar")<Enter>
    {<Enter>
  • At this point the cursor is on an empty line directly underneath the opening brace, "{".
  • Now, press Tab and you will see the message box referring to the exception. Selecting "[ More ]" will display the exception and stack trace in a new modal Editor.

Versions

  • Far Manager 3.0.4949 x64
  • FarNet and PowerShellFar 5.2.3

Thanks in advance,
Buck

.Net Core 3+ Support

Are there any plans to support .Net Core 3.0 or 3.1 instead of / in addition to .Net Framework?

Remove FarPackage from PowerShellFar

Following the discussion #19 and recent NuGet breaking changes (retired API).
It makes sense to remove the module FarPackage from PowerShellFar.
Reasons:

  1. Users should use the online install/update scenario described in README instead of using local FarPackage. This reduces chances of FarPackage being out of date and related issues.
  2. FarPackage distribution with PowerShellFar is awkward anyway because in many cases using it requires Far Manager exit. This makes little sense for having FarPackage in PowerShellFar\Modules.

PSF RawUI must not be bound to ShowUserScreen

It was tempting to ShowUserScreen from RawUI set-members and it was done in
PSF 5.2.2. It is a bad idea. PS core may call these members unexpectedly, and
from other threads, too.

In other words, raw console API must not be bound to Far API, at least not to
ShowUserScreen.

Symptoms in 5.2.2

Type something in the command line and call PSF TabExpansion. As a result, the
user screen is shown unexpectedly and the completion menu is shown at the left
most position, not at the expected caret position on typing.

It turns out PS plays with ForegroundColor when we call TabExpansion. We
cannot control and avoid such calls. Even if we add an ugly workaround for this
use case, we will not solve the problem in other similar cases.

TabExpansion2 v1.0.1 regression on read only results

v1.0.1 uses the work around read only results borrowed from TabExpansionPlusPlus:

if ($result.CompletionMatches.IsReadOnly) {
    $private:collection = New-Object System.Collections.ObjectModel.Collection[System.Management.Automation.CompletionResult]
    foreach($_ in $result.CompletionMatches) {
        $collection.Add($_)
    }
    $result.GetType().GetProperty('CompletionMatches').SetValue($result, $collection)
}

It works but it makes incorrect ReplacementIndex and ReplacementLength.
E.g. for ... [cmd= as if we are about to replace just =, not [cmd=.
Note that some ... is essential, v1.0.1 works fine for a one-liner [cmd=.

Complete revision of TabExpansion2.ps1

See #2 for the introduction of coming changes and the reasons.

Remove the obsolete wrapper New-CompletionResult.
New-Object System.Management.Automation.CompletionResult should be used instead.

Remove support for obsolete profile names *TabExpansionProfile*.ps1.
Names like *ArgumentCompleters.ps1 should be used instead.

Add new functions Register-InputCompleter and Register-ResultCompleter.
They should be used instead of adding completers directly to options.
Old adding to options still works but this may change later.

Improve the work around read-only result collections.

Upgrade the sample TabExpansionProfile.ps1 according to the above notes.
Fix some minor code defects, including leaked completers variables.

PowerShellFar 5.0.91 - Refactoring of TabExpansion2.ps1

Changes are not breaking now. It is recommended to start the migration in order
to be ready to the future breaking changes. The goal is to be compatible with
v5 built-in and TabExpansionPlusPlus Register-ArgumentCompleter.

The wrapper New-CompletionResult is obsolete and will be removed. Instead,
use New-Object System.Management.Automation.CompletionResult directly.
Reasons:

  • PowerShell v5 does not have anything like this at all.
  • TabExpansionPlusPlus has it but it is not compatible.

Profile naming convention. Names like *ArgumentCompleters.ps1 should be used
instead of *TabExpansionProfile*.ps1 in order to follow the current trends.
Some completer profiles are supposed to be reusable in other scenarios.

The new function Register-ArgumentCompleter should be used instead of adding
completers directly to tables. In this way, the same completers can be used in
PowerShell v5 natively or with TabExpansionPlusPlus.

The sample TabExpansionProfile.ps1 was renamed to ArgumentCompleters.ps1
and its code was upgraded according to the above notes.

Explorer problems

  1. Exiting Explorer returned from OpenFile closes parents panel, also without notifying on UIClosing, not letting to interrupt.
    Is that intended behaviour? If so, is there a way to implement file explorer chaining (like archive within archive)?
  2. First created Explorer does not notify ExploreParent until other folder is opened.
  3. After setting CanExploreLocation, only File.Name is passed to GetContent & OpenFile, without File.Data

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.