Skip to content

Commit

Permalink
update win_extmarks definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatao Li committed Apr 24, 2022
1 parent 7ce386a commit ec7c082
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions ViewModels/GridViewModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ and GridViewModel(_gridid: int, ?_parent: GridViewModel, ?_gridsize: GridSize) a
| PopupMenuHide -> hidePopupMenu ()
| WinExternalPos(_,win) -> setWinExternalPos win
| WinViewport(id, win, top, bot, row, col, lc) -> setWinViewport win top bot row col lc
| WinExtmarks(win, marks) -> if win = m_winhnd then putExtmarks marks
| WinExtmarksClear(win) -> if win = m_winhnd then clearMarks()
| WinExtmarks(id, win, marks) -> putExtmarks marks
| x -> trace _gridid "unimplemented command: %A" x

let fontConfig() =
Expand Down
16 changes: 7 additions & 9 deletions def.fs
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ type RedrawCommand =
/// window. Only emitted after the client calls `nvim_ui_watch_extmark` to
/// watch for a specific namespace `ns_id`. `start_row`, `end_row` and
/// `start_col` are relative to the window.
| WinExtmarks of win: int * marks: Extmark[]
| WinExtmarksClear of win: int
| WinExtmarks of grid:int * win: int * marks: Extmark[]
/// Display messages on `grid`. The grid will be displayed at `row` on the
/// default grid (grid=1), covering the full column width. `scrolled`
/// indicates whether the message area has been scrolled to cover other
Expand Down Expand Up @@ -696,15 +695,15 @@ let parse_int_singleton =

let parse_win_extmarks_1 =
function
| ObjArray [| Integer32 a; Integer32 b; Integer32 c; Integer32 d; Integer32 e |]
-> Some(a,{ns=b;mark=c;row=d;col=e})
| ObjArray [| Integer32 a; Integer32 b; Integer32 c; Integer32 d; Integer32 e; Integer32 f; |]
-> Some(a,b,{ns=c;mark=d;row=e;col=f})
| _ -> None

let parse_win_extmarks_2 (tuples: (int*Extmark)[]) =
let parse_win_extmarks_2 (tuples: (int*int*Extmark)[]) =
tuples
|> Array.groupBy fst
|> Array.map(fun (win, marks) ->
WinExtmarks(win, marks |> Array.map snd))
|> Array.groupBy (fun (a,b,c) -> (a, b))
|> Array.map(fun ((grid, win), marks) ->
WinExtmarks(grid, win, marks |> Array.map (fun (a,b,c) -> c)))

let unwrap_multi xs =
match xs with
Expand Down Expand Up @@ -747,7 +746,6 @@ let parse_redrawcmd (x: obj) =
| C("win_close", PX(parse_int_singleton)ids) -> ids |> Array.map(WinClose) |> unwrap_multi
| C("win_viewport", PX(parse_win_viewport)cmds) -> unwrap_multi cmds
| C("win_extmarks", PX(parse_win_extmarks_1)cmds) -> cmds |> parse_win_extmarks_2 |> unwrap_multi
| C("win_extmarks_clear", PX(parse_int_singleton)ids) -> ids |> Array.map(WinExtmarksClear) |> unwrap_multi
| C1("msg_set_pos", [|
(Integer32 grid); (Integer32 row)
(Bool scrolled); (String sep_char) |]) -> MsgSetPos(grid, row,scrolled, sep_char)
Expand Down
4 changes: 2 additions & 2 deletions model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ module private ModelImpl =
| PopupMenuSelect _ | PopupMenuHide _
| Busy _ | Mouse _
| ModeChange _ | GridCursorGoto _
| WinExtmarks _
| WinExtmarksClear _ -> broadcast cmd
-> broadcast cmd
// Unicast
| GridClear id | GridScroll(id,_,_,_,_,_,_)
| WinClose id | WinHide(id)
| WinExtmarks(id,_,_)
| WinViewport(id,_,_,_,_,_,_) -> unicast id cmd
| WinExternalPos(id,_) -> unicast_detach id cmd
| WinFloatPos(id, _, _, pid, _, _, _, _)
Expand Down

0 comments on commit ec7c082

Please sign in to comment.