From 7b3ee042ba45d5b4b1ba747867f0a79f6c8b3ce5 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sat, 24 Sep 2022 17:30:47 +0900 Subject: [PATCH] fixup --- editor/extmarks.go | 24 +++++++++++++++++ editor/guiwidget.go | 6 +++++ editor/window.go | 63 +++++++++++++++++++++++++-------------------- 3 files changed, 65 insertions(+), 28 deletions(-) diff --git a/editor/extmarks.go b/editor/extmarks.go index 94f1249e..92cf00fd 100644 --- a/editor/extmarks.go +++ b/editor/extmarks.go @@ -1,6 +1,8 @@ package editor import ( + "fmt" + "github.com/akiyosi/goneovim/util" "github.com/neovim/go-client/nvim" ) @@ -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]) @@ -21,6 +24,7 @@ func (ws *Workspace) windowExtmarks(args []interface{}) { win, ok := ws.screen.getWindow(grid) if !ok { + fmt.Println("debug 21:: continue") return } @@ -37,6 +41,7 @@ func (ws *Workspace) windowExtmarks(args []interface{}) { return true }) if gw == nil { + fmt.Println("debug 22:: continue") continue } @@ -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() } } diff --git a/editor/guiwidget.go b/editor/guiwidget.go index b1ff3bf5..6e7c1671 100644 --- a/editor/guiwidget.go +++ b/editor/guiwidget.go @@ -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) @@ -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 } @@ -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{}) { @@ -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 diff --git a/editor/window.go b/editor/window.go index dd8f4639..ccbbf731 100644 --- a/editor/window.go +++ b/editor/window.go @@ -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 } @@ -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] @@ -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.