Skip to content

Commit 8a6f26b

Browse files
author
Yatao Li
committed
Merge branch 'master' of github.com:yatli/fvim
2 parents 3dcf53d + f4eb8c9 commit 8a6f26b

4 files changed

Lines changed: 39 additions & 31 deletions

File tree

.vscode/launch.json

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5-
"version": "0.2.0",
62
"configurations": [
7-
{
8-
"name": ".NET Core Launch (console)",
9-
"type": "coreclr",
10-
"request": "launch",
11-
"preLaunchTask": "build",
12-
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/FVim.dll",
13-
"args": [],
14-
"cwd": "${workspaceFolder}",
15-
"stopAtEntry": false,
16-
"console": "integratedTerminal",
17-
"justMyCode": false,
18-
"enableStepFiltering": false
19-
}
20-
3+
{
4+
"name": "fvr daemon",
5+
"type": "coreclr",
6+
"request": "launch",
7+
"preLaunchTask": "build",
8+
"program": "${workspaceFolder}/bin/Debug/net6.0/FVim.dll",
9+
"args": ["--daemon"],
10+
"cwd": "${workspaceFolder}",
11+
"stopAtEntry": false,
12+
"console": "internalConsole"
13+
}
2114
]
15+
2216
}

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ Cross platform Neovim front-end UI, built with [F#](https://fsharp.org/) + [Aval
1919
- Arch Linux: [Install via AUR](https://aur.archlinux.org/packages/fvim/)
2020
- RPM-based distributions: `rpm -ivh fvim_package_name.rpm`
2121
- Fedora: `dnf install fvim_package_name.rpm`
22-
- Compile from Source (having dotnet-sdk-5.0.x installed):
22+
- Compile from Source (having dotnet-sdk-6.0.x installed):
2323
```
24-
git clone https://github.com/yatli/fvim && cd fvim && dotnet publish -f net5.0 -c Release -r linux-x64 --self-contained
24+
git clone https://github.com/yatli/fvim && cd fvim && dotnet publish -f net6.0 -c Release -r linux-x64 --self-contained
2525
```
26-
- Note, currently FVim will treat all keyboards as en-US so characters and symbols are mapped incorrectly if you use a non en-US layout. [The issue is tracked here](https://github.com/yatli/fvim/issues/36).
2726
2827
### Features
2928
@@ -85,7 +84,7 @@ Detaching a window into an external OS window with `Ctrl-w ge`:
8584
Detach as many and span them over your monitors!
8685

8786
### Building from source
88-
We're now targeting `net5.0` so make sure to install the latest preview SDK from the [.NET site](https://dotnet.microsoft.com/download/dotnet/5.0).
87+
We're now targeting `net6.0` so make sure to install the latest preview SDK from the [.NET site](https://dotnet.microsoft.com/download/dotnet/6.0).
8988
We're actively tracking the head of `Avalonia`, and fetch the nightly packages from myget (see `NuGet.config`).
9089

9190
Then, simply:

daemon.fs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ let newSession nvim stderrenc args svrpipe =
8686
sessions.[myid].exitHandle.Dispose()
8787
sessions.Remove(myid) |> ignore
8888
proc.Dispose()
89+
try svrpipe.Dispose()
90+
with dispose_ex -> trace "%O" dispose_ex
8991
)
9092
}
9193

@@ -132,7 +134,8 @@ let serve nvim stderrenc (pipe: NamedPipeServerStream) =
132134
if rbuf.[0..3] <> FVR_MAGIC then
133135
trace "Incorrect handshake magic. Got: %A" rbuf.[0..3]
134136
return()
135-
let len = rbuf.[4..7] |> toInt32LE
137+
let lenbuf = rbuf.[4..7]
138+
let len = lenbuf |> toInt32LE
136139
if len >= rbuf.Length || len <= 0 then
137140
trace "Invalid payload length %d" len
138141
return()
@@ -158,10 +161,10 @@ let serve nvim stderrenc (pipe: NamedPipeServerStream) =
158161
trace "Request %A is attaching to session %d" request session.id
159162
do! fromInt32LE session.id |> readonlymemory |> write pipe
160163
do! serveSession session
161-
finally
162-
try
163-
pipe.Dispose()
164-
with ex -> trace "%O" ex
164+
with ex ->
165+
trace "%O" ex
166+
try pipe.Dispose()
167+
with dispose_ex -> trace "%O" dispose_ex
165168
}
166169

167170
let daemon (pname: string option) (nvim: string) (stderrenc: Text.Encoding) =

input.fs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ open neovim
55

66
open Avalonia.Input
77
open System
8+
open System.Runtime.InteropServices
89
open FSharp.Control.Reactive
910
open Avalonia.Interactivity
1011

@@ -94,6 +95,7 @@ let DIR (dx: float, dy: float, horizontal: bool) =
9495

9596
let mutable accumulatedX = 0.0
9697
let mutable accumulatedY = 0.0
98+
let mutable blockNextTextInput = false
9799

98100
// Avoid sending Rejected key as a sequence, e.g. "capslock"
99101
let RejectKeys = set [
@@ -285,7 +287,7 @@ let (|Special|Normal|Rejected|) (x: InputEvent) =
285287
// | ' | ' | ä |
286288
// | Ctrl-' | <C-'> | <C-'> |
287289
//
288-
| Key(m, Key.Back) -> Special "BS"
290+
| Key(_, Key.Back) -> Special "BS"
289291
| Key(_, Key.Tab) -> Special "Tab"
290292
| Key(_, Key.LineFeed) -> Special "NL"
291293
| Key(_, Key.Return) -> Special "CR"
@@ -359,8 +361,14 @@ let (|Special|Normal|Rejected|) (x: InputEvent) =
359361
| Key(_, Key.Divide) -> Special("kDivide")
360362
| Key(_, Key.Separator) -> Special("kEnter")
361363
| Key(_, Key.Decimal) -> Special("kPoint")
362-
| Key(NoFlag(KeyModifiers.Shift), x) -> Normal (x.ToString().ToLowerInvariant())
363-
| Key(_, x) -> Normal (x.ToString())
364+
| Key(NoFlag(KeyModifiers.Shift) as m, x) ->
365+
if RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && m = KeyModifiers.Alt
366+
then blockNextTextInput <- true
367+
Normal (x.ToString().ToLowerInvariant())
368+
| Key(m, x) ->
369+
if RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && m = (KeyModifiers.Alt ||| KeyModifiers.Shift)
370+
then blockNextTextInput <- true
371+
Normal (x.ToString())
364372
| _ -> Rejected
365373

366374
let rec ModifiersPrefix (x: InputEvent) =
@@ -398,7 +406,11 @@ let onInput (nvim: Nvim) (input: IObservable<int*InputEvent*RoutedEventArgs>) =
398406
match x with
399407
| TextInput txt ->
400408
ev.Handled <- true
401-
if txt = "<" then Some "<LT>" else Some txt
409+
if blockNextTextInput then
410+
blockNextTextInput <- false
411+
None
412+
elif txt = "<" then Some "<LT>"
413+
else Some txt
402414
| InputEvent.Key _ ->
403415
ev.Handled <- true
404416
let pref = ModifiersPrefix x

0 commit comments

Comments
 (0)