Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
akiyosi committed Sep 24, 2022
1 parent a6e1d3a commit 7b3ee04
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 28 deletions.
24 changes: 24 additions & 0 deletions editor/extmarks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package editor

import (
"fmt"

"github.com/akiyosi/goneovim/util"
"github.com/neovim/go-client/nvim"
)
Expand All @@ -10,6 +12,7 @@ import (
// Updates the position of an extmark which is currently visible in a
// window. Only emitted if the mark has the `ui_watched` attribute.
func (ws *Workspace) windowExtmarks(args []interface{}) {
fmt.Println("win_extmark event")
for _, e := range args {
arg := e.([]interface{})
grid := util.ReflectToInt(arg[0])
Expand All @@ -21,6 +24,7 @@ func (ws *Workspace) windowExtmarks(args []interface{}) {

win, ok := ws.screen.getWindow(grid)
if !ok {
fmt.Println("debug 21:: continue")
return
}

Expand All @@ -37,6 +41,7 @@ func (ws *Workspace) windowExtmarks(args []interface{}) {
return true
})
if gw == nil {
fmt.Println("debug 22:: continue")
continue
}

Expand All @@ -48,5 +53,24 @@ func (ws *Workspace) windowExtmarks(args []interface{}) {
markid: markid,
}
}

win.hasExtmarks = true
// if gw.width == 0 && gw.height == 0 {
// continue
// }
// fmt.Println("debug::", "gridid", win.grid, gw.markID, "text", gw.text, "row,col:", row, col, "width, height:", gw.width, gw.height)
// win.queueRedraw(row, col, gw.width+1, gw.height)
// for i := row; i <= row+gw.height; i++ {
// if i >= len(win.contentMask) {
// continue
// }
// for j := col; j <= col+gw.height; j++ {
// if j >= len(win.contentMask[i]) {
// continue
// }
// win.contentMask[i][j] = true
// }
// }
// win.update()
}
}
6 changes: 6 additions & 0 deletions editor/guiwidget.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ func initGuiwidget() *Guiwidget {

// GuiWidgetPut pushes visual resource data to the front-end
func (w *Workspace) handleRPCGuiwidgetput(updates []interface{}) {
fmt.Println("put guiwidgets")
for _, update := range updates {
a := update.(map[string]interface{})

idITF, ok := a["id"]
if !ok {
fmt.Println("debug 7:: continue")
continue
}
id := util.ReflectToInt(idITF)
Expand Down Expand Up @@ -88,12 +90,14 @@ func (w *Workspace) handleRPCGuiwidgetput(updates []interface{}) {
// A placement associates an extmark with a resource id, and provides
// display options for a widget (width, height, mouse events etc.).
func (w *Workspace) handleRPCGuiwidgetview(updates []interface{}) {
fmt.Println("view guiwidgets")
var markid, resid, width, height int
for _, update := range updates {
a := update.(map[string]interface{})

buf, ok := a["buf"]
if !ok {
fmt.Println("debug 10:: continue")
continue
}

Expand All @@ -116,6 +120,7 @@ func (w *Workspace) handleRPCGuiwidgetview(updates []interface{}) {

widgets, ok := a["widgets"]
if !ok {
fmt.Println("debug 11:: continue")
continue
}
for _, e := range widgets.([]interface{}) {
Expand Down Expand Up @@ -144,6 +149,7 @@ func (w *Workspace) handleRPCGuiwidgetview(updates []interface{}) {
g.markID = markid
g.width = width
g.height = height

switch g.mime {
case "text/plain":
baseFont := g.s.ws.font
Expand Down
63 changes: 35 additions & 28 deletions editor/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -1306,33 +1306,34 @@ func (w *Window) countContent(row int) {
!cell.highlight.underline &&
!cell.highlight.undercurl &&
!cell.highlight.strikethrough {
if cell.decal != nil {
if cell.decal.exists {
w.hasExtmarks = true

// If an extmark exists, the following process is performed
// to allocate the corresponding area for updating.
w.s.ws.guiWidgets.Range(func(_, resITF interface{}) bool {
res := resITF.(*Guiwidget)
if res == nil {
return true
}

if res.markID == cell.decal.markid {
width += res.width
breakFlag[1] = true
for k := 1; k <= res.height; k++ {
w.lenOldContent[k] = width
}
}

return true
})

}
} else {
width--
}
// if cell.decal != nil {
// if cell.decal.exists {
// w.hasExtmarks = true

// // If an extmark exists, the following process is performed
// // to allocate the corresponding area for updating.
// w.s.ws.guiWidgets.Range(func(_, resITF interface{}) bool {
// res := resITF.(*Guiwidget)
// if res == nil {
// return true
// }

// if res.markID == cell.decal.markid {
// width += res.width
// breakFlag[1] = true
// for k := 1; k <= res.height; k++ {
// w.lenOldContent[k] = width
// }
// }

// return true
// })

// }
// } else {
// width--
// }
width--
} else {
breakFlag[1] = true
}
Expand Down Expand Up @@ -1565,7 +1566,7 @@ func (w *Window) update() {
drawWithSingleRect := false

// If DrawIndentGuide is enabled
if editor.config.Editor.IndentGuide || w.hasExtmarks {
if editor.config.Editor.IndentGuide {
if i < w.rows-1 {
if width < w.lenContent[i+1] {
width = w.lenContent[i+1]
Expand All @@ -1590,6 +1591,12 @@ func (w *Window) update() {
drawWithSingleRect = true
}
}
// If window has extmark
if w.hasExtmarks {
width = w.cols
drawWithSingleRect = true
}

width++

// Create rectangles that require updating.
Expand Down

0 comments on commit 7b3ee04

Please sign in to comment.