Skip to content

Commit

Permalink
external pum geometry notify. requires neovim/11943
Browse files Browse the repository at this point in the history
  • Loading branch information
yatli committed Feb 24, 2020
1 parent 3c2d7c1 commit 3a76c2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions ViewModels/EditorViewModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ type EditorViewModel(GridId: int, ?parent: EditorViewModel, ?_gridsize: GridSize
trace "show popup menu at [%O, %O]" startPos cursorPos

// Decide the maximum size of the popup menu based on grid dimensions
let menuLines = items.Length
let menuLines = min items.Length 15
let menuCols =
items
|> Array.map CompleteItem.GetLength
Expand All @@ -242,8 +242,11 @@ type EditorViewModel(GridId: int, ?parent: EditorViewModel, ?_gridsize: GridSize
m_popupmenu_vm.SetItems(items, startPos, cursorPos, m_glyphsize.Height, bounds, editorSize)
m_popupmenu_vm.Show <- true

let w = int(m_popupmenu_vm.Width / m_glyphsize.Width)
let h = int(m_popupmenu_vm.Height / m_glyphsize.Height)
Model.SetPopupMenuHeight h
let r = int(m_popupmenu_vm.Y / m_glyphsize.Height)
let c = int(m_popupmenu_vm.X / m_glyphsize.Width)
Model.SetPopupMenuPos w h r c

let redraw(cmd: RedrawCommand) =
//trace "%A" cmd
Expand Down
8 changes: 4 additions & 4 deletions model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -702,11 +702,11 @@ let SelectPopupMenuItem (index: int) (insert: bool) (finish: bool) =
in ()
} |> ignore

let SetPopupMenuHeight (h: int) =
trace "SetPopupMenuHeight: h=%d" h
let SetPopupMenuPos width height row col =
trace "SetPopupMenuPos: w=%d h=%d r=%d c=%d" width height row col
task {
let! _ = nvim.command (sprintf "call nvim_ui_pum_set_height(%d)" h)
in ()
let! _ = nvim.call { method = "nvim_ui_pum_set"; parameters = mkparams4 width height row col}
in ()
} |> ignore

let OnFocusLost() =
Expand Down

0 comments on commit 3a76c2d

Please sign in to comment.