Skip to content

Commit

Permalink
implement ime client cursor rect.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatao Li committed Jul 13, 2021
1 parent 226f56b commit b8d12c1
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Views/Grid.xaml.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Grid() as this =
let mutable grid_vm: GridViewModel = Unchecked.defaultof<_>

let mutable m_debug = states.ui_multigrid
let mutable m_cursor: FVim.Cursor = Unchecked.defaultof<_>

let ev_cursor_rect_changed = Event<EventHandler,EventArgs>()
let ev_text_view_visual_changed = Event<EventHandler,EventArgs>()
Expand Down Expand Up @@ -398,6 +399,14 @@ type Grid() as this =
vm.SetMeasuredSize sz
sz)

override this.OnInitialized() =
m_cursor <- this.FindControl<FVim.Cursor>("cursor")
this.Watch [
m_cursor.ObservableForProperty(fun c -> c.Bounds)
|> Observable.subscribe(fun _ ->
ev_cursor_rect_changed.Trigger(this, EventArgs.Empty))
]

interface IViewFor<GridViewModel> with

member this.ViewModel
Expand All @@ -417,10 +426,8 @@ type Grid() as this =
member _.TextBeforeCursor: string = raise (NotSupportedException())
[<CLIEvent>] member _.SurroundingTextChanged: IEvent<EventHandler,EventArgs> = raise (NotSupportedException())

member _.CursorRectangle: Rect =
Rect()
member _.TextViewVisual: IVisual =
this.FindControl<FVim.Cursor>("cursor") :> IVisual
member _.CursorRectangle: Rect = m_cursor.Bounds
member _.TextViewVisual: IVisual = this :> IVisual
[<CLIEvent>] member _.CursorRectangleChanged: IEvent<EventHandler,EventArgs> = ev_cursor_rect_changed.Publish
[<CLIEvent>] member _.TextViewVisualChanged: IEvent<EventHandler,EventArgs> = ev_text_view_visual_changed.Publish

Expand Down
107 changes: 107 additions & 0 deletions fvim_avalonia.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>FVim</AssemblyName>
<Prefer32Bit>false</Prefer32Bit>
<ApplicationIcon>fvim.ico</ApplicationIcon>
<OutputType>Exe</OutputType>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<OutputType>WinExe</OutputType>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<TrimMode>link</TrimMode>
</PropertyGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PublishReadyToRunExclude Include="Microsoft.CodeAnalysis.dll" />
</ItemGroup>

<ItemGroup>
<Compile Include="DesignTime\TitleBarSampleData.fs" />
<Compile Include="DesignTime\GridSampleData.fs" />
<Compile Include="DesignTime\CrashReportSampleData.fs" />
<Compile Include="DesignTime\MainWindowSampleData.fs" />
<Compile Include="common.fs" />
<Compile Include="config.fs" />
<Compile Include="getopt.fs" />
<Compile Include="log.fs" />
<Compile Include="def.fs" />
<Compile Include="wcwidth.fs" />
<Compile Include="daemon.fs" />
<Compile Include="shell.fs" />
<Compile Include="states.fs" />
<Compile Include="neovim.fs" />
<Compile Include="ui.fs" />
<Compile Include="theme.fs" />
<Compile Include="input.fs" />
<Compile Include="model.fs" />
<Compile Include="ViewModels\ViewModelBase.fs" />
<Compile Include="ViewModels\ThemableViewModelBase.fs" />
<Compile Include="ViewModels\TitleBarViewModel.fs" />
<Compile Include="ViewModels\CursorViewModel.fs" />
<Compile Include="ViewModels\CompletionItemViewModel.fs" />
<Compile Include="ViewModels\PopupMenuViewModel.fs" />
<Compile Include="ViewModels\GridViewModel.fs" />
<Compile Include="ViewModels\FrameViewModel.fs" />
<Compile Include="ViewModels\CrashReportViewModel.fs" />
<Compile Include="Views\ViewBase.fs" />
<Compile Include="Views\Cursor.xaml.fs" />
<Compile Include="Views\Frame.xaml.fs" />
<Compile Include="Views\CompletionItem.xaml.fs" />
<Compile Include="Views\PopupMenu.xaml.fs" />
<Compile Include="Views\Grid.xaml.fs" />
<Compile Include="Views\CrashReport.xaml.fs" />
<Compile Include="Views\TitleBar.xaml.fs" />
<Compile Include="App.xaml.fs" />
<Compile Include="Program.fs" />
<ApplicationDefinition Include="fvim.config" />
</ItemGroup>

<ItemGroup>
<Compile Update="**\*.xaml.fs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<AvaloniaResource Include="Assets\**\*" />
<Content Include="**\*.xaml" />
<AvaloniaResource Include="**\*.xaml">
<SubType>Designer</SubType>
</AvaloniaResource>
<EmbeddedResource Include="Fonts\nerd.ttf" />
<Content Include="Assets\*" />
<None Include="icons\*.ico" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>

<PackageReference Include="FSharp.Control.Reactive" Version="5.0.2" />
<PackageReference Include="FSharp.Data" Version="4.1.1" />
<PackageReference Include="FSharp.Span.Utils" Version="1.1.3353.13900" />
<PackageReference Include="FSharp.SystemTextJson" Version="0.17.4" />
<PackageReference Include="MessagePack" Version="1.9.11" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="NSubsys" Version="1.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="TaskBuilder.fs" Version="2.1.0" />
<PackageReference Include="UACHelper" Version="1.3.0.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Avalonia\packages\Avalonia\Avalonia.csproj" />
<ProjectReference Include="..\Avalonia\src\Avalonia.Desktop\Avalonia.Desktop.csproj" />
<ProjectReference Include="..\Avalonia\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
<ProjectReference Include="..\Avalonia\src\Avalonia.ReactiveUI\Avalonia.ReactiveUI.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="5.0.2" />
</ItemGroup>

<Import Project="..\Avalonia\build\SampleApp.props" />

<Import Project="..\Avalonia\build\BuildTargets.targets" />
</Project>

0 comments on commit b8d12c1

Please sign in to comment.