From d5851d591a9d7d52daf1d5fe1173127bffa31d1a Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sat, 26 Jun 2021 00:45:46 +0900 Subject: [PATCH 01/15] Fix readme --- README.md | 4 ++-- editor/editor.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5d1f6d18..c5824ab8 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Goneovim ![test](https://github.com/akiyosi/goneovim/workflows/test/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/akiyosi/goneovim)](https://goreportcard.com/report/github.com/akiyosi/goneovim) -![GitHub Releases](https://img.shields.io/github/downloads/akiyosi/goneovim/v0.4.11/total) +![GitHub Releases](https://img.shields.io/github/downloads/akiyosi/goneovim/v0.4.12/total) [![Join the chat at https://gitter.im/goneovim/community](https://badges.gitter.im/goneovim/community.svg)](https://gitter.im/goneovim/community) Goneovim is a Neovim GUI written in Go, using a [Qt binding for Go](https://github.com/therecipe/qt). @@ -44,7 +44,7 @@ All of the features are optional. You can use it like a plain nvim or as a nvim ## Requirements -* Neovim (v0.4.4 or later) +* Neovim v0.5.0-dev (Commit 8d23941af or later versions) See [Installing Neovim](https://github.com/neovim/neovim/wiki/Installing-Neovim) diff --git a/editor/editor.go b/editor/editor.go index 8173021d..383996fe 100644 --- a/editor/editor.go +++ b/editor/editor.go @@ -25,7 +25,7 @@ import ( var editor *Editor const ( - GONEOVIMVERSION = "v0.4.11" + GONEOVIMVERSION = "v0.4.12" WORKSPACELEN = 10 ) From fff80701c8975fd915642b71e3ecf98044536663 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sat, 26 Jun 2021 16:47:15 +0900 Subject: [PATCH 02/15] Add debug log --- editor/font.go | 1 + editor/window.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/editor/font.go b/editor/font.go index be47dc36..e8a8a7cf 100644 --- a/editor/font.go +++ b/editor/font.go @@ -114,6 +114,7 @@ func (f *Font) putDebugLog() { editor.putLog( "detect font family:", fi.Family(), + fi.PointSizeF(), fi.StyleName(), fmt.Sprintf("%v", fi.PointSizeF()), ) diff --git a/editor/window.go b/editor/window.go index 466649ae..3509d4ca 100644 --- a/editor/window.go +++ b/editor/window.go @@ -2025,6 +2025,18 @@ func (w *Window) newTextCache(text string, highlight *Highlight, isNormalWidth b font := w.getFont() + // Put debug log + if editor.opts.Debug != "" { + fi := gui.NewQFontInfo(font.fontNew) + editor.putLog( + "Outputs font information creating word cache:", + fi.Family(), + fi.PointSizeF(), + fi.StyleName(), + fmt.Sprintf("%v", fi.PointSizeF()), + ) + } + width := float64(len(text)) * font.italicWidth fg := highlight.fg() if !isNormalWidth { From ea18bc8d1b97b892858d06eefd489d0fe4a0c378 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sat, 26 Jun 2021 20:21:24 +0900 Subject: [PATCH 03/15] Suppress unnecessary detours of the smooth cursor --- editor/screen.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/editor/screen.go b/editor/screen.go index 6bf023a4..12cc2938 100644 --- a/editor/screen.go +++ b/editor/screen.go @@ -904,8 +904,9 @@ func (s *Screen) gridCursorGoto(args []interface{}) { for _, arg := range args { gridid := util.ReflectToInt(arg.([]interface{})[0]) - s.cursor[0] = util.ReflectToInt(arg.([]interface{})[1]) - s.cursor[1] = util.ReflectToInt(arg.([]interface{})[2]) + x := util.ReflectToInt(arg.([]interface{})[1]) + y := util.ReflectToInt(arg.([]interface{})[2]) + if isSkipGlobalId(gridid) { continue } @@ -915,6 +916,17 @@ func (s *Screen) gridCursorGoto(args []interface{}) { continue } + // Suppress unnecessary detours of the smooth cursor. + if win.isMsgGrid && x == 0 && y == 0 { + continue + } + if win.isMsgGrid && editor.config.Editor.ExtCmdline { + continue + } + + s.cursor[0] = x + s.cursor[1] = y + if s.ws.cursor.gridid != gridid { if !win.isMsgGrid { s.ws.cursor.bufferGridid = gridid From 548073066e7b4344d71bb919b90311c765a36fc1 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sun, 27 Jun 2021 01:50:46 +0900 Subject: [PATCH 04/15] It seems that neovim/neovim issue 12985 is stil occuring --- editor/screen.go | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/editor/screen.go b/editor/screen.go index 12cc2938..1ae95152 100644 --- a/editor/screen.go +++ b/editor/screen.go @@ -1436,28 +1436,24 @@ func (s *Screen) windowFloatPosition(args []interface{}) { case "SW": x = anchorposx + anchorCol - if editor.config.Editor.WorkAroundNeovimIssue12985 { - // In multigrid ui, the completion float window position information is not correct. - // Therefore, we implement a hack to compensate for this. - // ref: src/nvim/popupmenu.c:L205-, L435- - if win.id == -1 && !pumInMsgWin { - - row := 0 - contextLine := 0 - if anchorwin.rows-s.cursor[0] >= 2 { - contextLine = 2 - } else { - contextLine = anchorwin.rows - s.cursor[0] - } - if anchorposy+s.cursor[0] >= win.rows+contextLine { - row = anchorRow + win.rows - } else { - row = -anchorposy - } - y = anchorposy + row + // In multigrid ui, the completion float window position information is not correct. + // Therefore, we implement a hack to compensate for this. + // ref: src/nvim/popupmenu.c:L205-, L435- + if win.id == -1 && !pumInMsgWin { + + row := 0 + contextLine := 0 + if anchorwin.rows-s.cursor[0] >= 2 { + contextLine = 2 + } else { + contextLine = anchorwin.rows - s.cursor[0] + } + if anchorposy+s.cursor[0] >= win.rows+contextLine { + row = anchorRow + win.rows } else { - y = anchorposy + anchorRow - win.rows + row = -anchorposy } + y = anchorposy + row } else { y = anchorposy + anchorRow - win.rows } From f58881931b12757ff9a3e6ff69bc2aff386f93e5 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Thu, 1 Jul 2021 22:46:17 +0900 Subject: [PATCH 05/15] Minor fixes --- editor/workspace.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/workspace.go b/editor/workspace.go index 65699b55..1d24db3b 100644 --- a/editor/workspace.go +++ b/editor/workspace.go @@ -192,7 +192,7 @@ func newWorkspace(path string) (*Workspace, error) { if editor.config.Editor.ExtMessages { w.message = initMessage() w.message.ws = w - w.message.widget.SetParent(editor.window) + w.message.widget.SetParent(w.widget) } // If Statusline.Visible is true, then we create statusline UI component From d9506c8d432e6e5dfda470241251d41f9a6a6f73 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Fri, 2 Jul 2021 01:37:21 +0900 Subject: [PATCH 06/15] Fix popup-tooltip position --- editor/screen.go | 74 +++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/editor/screen.go b/editor/screen.go index 1ae95152..bce816fd 100644 --- a/editor/screen.go +++ b/editor/screen.go @@ -1325,26 +1325,24 @@ func (s *Screen) windowFloatPosition(args []interface{}) { // which is created as a tooltip suggested by LSP, is not the correct // position in multigrid ui api. isExistPopupmenu := false - if editor.config.Editor.WorkAroundNeovimIssue12985 { - if s.ws.mode == "insert" && !editor.config.Editor.ExtPopupmenu { - s.windows.Range(func(_, winITF interface{}) bool { - win := winITF.(*Window) - if win == nil { - return true - } - if win.grid == 1 { - return true - } - if win.isMsgGrid { - return true - } - if win.isPopupmenu { - isExistPopupmenu = true - } - + if s.ws.mode == "insert" { + s.windows.Range(func(_, winITF interface{}) bool { + win := winITF.(*Window) + if win == nil { return true - }) - } + } + if win.grid == 1 { + return true + } + if win.isMsgGrid { + return true + } + if win.isPopupmenu { + isExistPopupmenu = true + } + + return true + }) } for _, arg := range args { @@ -1369,11 +1367,11 @@ func (s *Screen) windowFloatPosition(args []interface{}) { editor.putLog("float window generated:", "anchorgrid", anchorGrid, "anchor", win.anchor, "anchorCol", anchorCol, "anchorRow", anchorRow) - if editor.config.Editor.WorkAroundNeovimIssue12985 { + // if editor.config.Editor.WorkAroundNeovimIssue12985 { if isExistPopupmenu && win.id != -1 { anchorGrid = s.ws.cursor.gridid } - } + // } // win.SetParent(win.s.ws.screen.widget) win.SetParent(win.s.ws.widget) @@ -1436,24 +1434,28 @@ func (s *Screen) windowFloatPosition(args []interface{}) { case "SW": x = anchorposx + anchorCol - // In multigrid ui, the completion float window position information is not correct. - // Therefore, we implement a hack to compensate for this. - // ref: src/nvim/popupmenu.c:L205-, L435- - if win.id == -1 && !pumInMsgWin { + if editor.config.Editor.WorkAroundNeovimIssue12985 { + // In multigrid ui, the completion float window position information is not correct. + // Therefore, we implement a hack to compensate for this. + // ref: src/nvim/popupmenu.c:L205-, L435- + if win.id == -1 && !pumInMsgWin { - row := 0 - contextLine := 0 - if anchorwin.rows-s.cursor[0] >= 2 { - contextLine = 2 - } else { - contextLine = anchorwin.rows - s.cursor[0] - } - if anchorposy+s.cursor[0] >= win.rows+contextLine { - row = anchorRow + win.rows + row := 0 + contextLine := 0 + if anchorwin.rows-s.cursor[0] >= 2 { + contextLine = 2 + } else { + contextLine = anchorwin.rows - s.cursor[0] + } + if anchorposy+s.cursor[0] >= win.rows+contextLine { + row = anchorRow + win.rows + } else { + row = -anchorposy + } + y = anchorposy + row } else { - row = -anchorposy + y = anchorposy + anchorRow - win.rows } - y = anchorposy + row } else { y = anchorposy + anchorRow - win.rows } From e3a66e9a356aff2bae136e8b185db095e8b6d375 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sat, 3 Jul 2021 13:15:58 +0900 Subject: [PATCH 07/15] Fix the required Neovim version to v0.5.0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5824ab8..2316ae70 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ All of the features are optional. You can use it like a plain nvim or as a nvim ## Requirements -* Neovim v0.5.0-dev (Commit 8d23941af or later versions) +* Neovim v0.5.0 See [Installing Neovim](https://github.com/neovim/neovim/wiki/Installing-Neovim) From 435df01222d19f4e12afff23f805ec95157abb2e Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sat, 3 Jul 2021 14:10:32 +0900 Subject: [PATCH 08/15] add: why Neovim GUI --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 2316ae70..1b636abe 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,23 @@ This repository forked from the original [Gonvim](https://github.com/dzhou121/go ![](https://raw.githubusercontent.com/wiki/akiyosi/goneovim/screenshots/v0.4.10-top.png) + +## Why Neovim GUI + +Traditionally, Neovim (and even Vim) has been optimized for working with Terminal, and some Terminal-based workflows cannot be achieved with a GUI. +Therefore, for some people, a GUI would be an unnecessary additional stuff. +On the other hand, in my opinion, there are some attractive features of GUI as follows. + +* **More meta keys can be used** + * Since Neovim performs all of its operations with the keyboard, having more meta keys available is a simple advantage. +* **Terminal is also available in Neovim GUI** + * Neovim has an embedded terminal emulator that can be run in `:terminal`, so you can run basic terminal workflows using `:terminal` with `bash` or `zsh` in Neovim GUI. It is also possible to use remote control tools such as [nvr](https://github.com/mhinz/neovim-remote) to avoid nvim in nvim in Neovim GUI. +* **Experience the rich drawing expressions of GUI** + * For example, it is possible to scroll based on pixels, to set different font families and point sizes for each window. + +If you are interested in these GUI attractions, try goneovim. + + ## Features All of the features are optional. You can use it like a plain nvim or as a nvim with a rich UI. From 0f53ce2c07215a864d81bb10f8a905f5be8b34de Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sat, 3 Jul 2021 23:48:09 +0900 Subject: [PATCH 09/15] Fix Makefile --- Makefile | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index d3874ced..71ed9c4a 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +TAG := $(shell git describe --tags --abbrev=0) # deployment directory DEPLOYMENT_WINDOWS:=deploy/windows @@ -23,43 +24,62 @@ ifeq (debug,$(firstword $(MAKECMDGOALS))) $(eval $(DEBUG_ARGS):;@:) endif -rebuild: - cd cmd/goneovim ; \ - qtmoc ; \ - qtdeploy build desktop ; \ - cp -pR ../../runtime $(RUNTIME_DIR) +all: moc build + +release: build-alldist-in-darwin rename archive-in-darwin + +build-alldist-in-darwin: moc build build-docker-linux + +rename: + @cd cmd/goneovim/deploy ; \ + mv darwin Goneovim-$(TAG)-macos ;\ + mv linux Goneovim-$(TAG)-linux + +archive-in-darwin: + @cd cmd/goneovim/deploy ; \ + tar jcvf Goneovim-$(TAG)-macos.tar.bz2 Goneovim-$(TAG)-macos ;\ + tar jcvf Goneovim-$(TAG)-linux.tar.bz2 Goneovim-$(TAG)-linux moc: + @export export GO111MODULE=off ; \ cd cmd/goneovim ; \ qtmoc build: + @export GO111MODULE=off ; \ cd cmd/goneovim ; \ test -f ../../editor/moc.go & qtmoc ; \ qtdeploy build desktop ; \ cp -pR ../../runtime $(RUNTIME_DIR) debug: + @export GO111MODULE=off ; \ cd cmd/goneovim ; \ test -f ../../editor/moc.go & qtmoc ; \ dlv debug --build-flags -race -- $(DEBUG_ARGS) + run: + @export GO111MODULE=off ; \ cd cmd/goneovim; \ test -f ../../editor/moc.go & qtmoc ; \ go run main.go clean: + @export GO111MODULE=off ; \ rm -fr cmd/goneovim/deploy/* ; \ rm -fr editor/*moc* - build-docker-linux: + @export GO111MODULE=off ; \ cd cmd/goneovim ; \ qtdeploy -docker build linux ; \ cp -pR ../../runtime $(DEPLOYMENT_LINUX) build-docker-windows: + @export GO111MODULE=off ; \ cd cmd/goneovim ; \ qtdeploy -docker build akiyosi/qt:windows_64_shared_msvc_512 ; \ cp -pR ../../runtime $(DEPLOYMENT_WINDOWS) +release: + From adb5ec5232be58c4e0dd427283500a4a85c113cf Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sun, 4 Jul 2021 09:17:01 +0900 Subject: [PATCH 10/15] fix an issue where the foreground color is not changed when changing the colorscheme --- editor/screen.go | 59 ++++++++++++++++++++++----------------------- editor/workspace.go | 3 +++ 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/editor/screen.go b/editor/screen.go index bce816fd..49ee0d27 100644 --- a/editor/screen.go +++ b/editor/screen.go @@ -951,12 +951,6 @@ func (s *Screen) setHlAttrDef(args []interface{}) { h = s.hlAttrDef } - isUpdateBg := true - curwin, ok := s.getWindow(s.ws.cursor.gridid) - if ok { - isUpdateBg = !curwin.background.equals(s.ws.background) - } - h[0] = &Highlight{ foreground: s.ws.foreground, background: s.ws.background, @@ -971,30 +965,35 @@ func (s *Screen) setHlAttrDef(args []interface{}) { s.hlAttrDef = h } - // Update all cell's highlight - if isUpdateBg { - s.windows.Range(func(_, winITF interface{}) bool { - win := winITF.(*Window) - if win == nil { - return true - } - if !win.isShown() { - return true - } - if win.content == nil { - return true - } - for _, line := range win.content { - for _, cell := range line { - if cell != nil { - cell.highlight = s.hlAttrDef[cell.highlight.id] - } - } - } - - return true - }) - } + // // Update all cell's highlight + // // It looks like we don't need it anymore. + // isUpdateBg := true + // curwin, ok := s.getWindow(s.ws.cursor.gridid) + // if ok { + // isUpdateBg = !curwin.background.equals(s.ws.background) + // } + // if isUpdateBg { + // s.windows.Range(func(_, winITF interface{}) bool { + // win := winITF.(*Window) + // if win == nil { + // return true + // } + // if !win.isShown() { + // return true + // } + // if win.content == nil { + // return true + // } + // for _, line := range win.content { + // for _, cell := range line { + // if cell != nil { + // cell.highlight = s.hlAttrDef[cell.highlight.id] + // } + // } + // } + // return true + // }) + // } } func (s *Screen) setHighlightGroup(args []interface{}) { diff --git a/editor/workspace.go b/editor/workspace.go index 1d24db3b..9f303cd4 100644 --- a/editor/workspace.go +++ b/editor/workspace.go @@ -1264,6 +1264,9 @@ func (w *Workspace) handleRedraw(updates [][]interface{}) { } } + // Purge all text cache for window's + w.screen.purgeTextCacheForWins() + case "hl_attr_define": s.setHlAttrDef(args) // if goneovim own statusline is visible From a4118ae7a7402423a7c8768da613d46a8342a1e4 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sun, 4 Jul 2021 20:32:03 +0900 Subject: [PATCH 11/15] Fix invalid memory access --- editor/cursor.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/editor/cursor.go b/editor/cursor.go index 5cd34b81..e0bacd2f 100644 --- a/editor/cursor.go +++ b/editor/cursor.go @@ -128,12 +128,14 @@ func (c *Cursor) wheelEvent(event *gui.QWheelEvent) { }) } - targetwin.WheelEvent( - // NOTE: This is not an exact implementation, as it requires - // a coordinate transformation of the Pos of QwheelEvent, but - // in the current handling of QWheelevent, it can be substituted as is. - event, - ) + if targetwin != nil { + targetwin.WheelEvent( + // NOTE: This is not an exact implementation, as it requires + // a coordinate transformation of the Pos of QwheelEvent, but + // in the current handling of QWheelevent, it can be substituted as is. + event, + ) + } } func (c *Cursor) paint(event *gui.QPaintEvent) { From 421c94d99020a31132e45a4e2bb52542c960aad5 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sun, 4 Jul 2021 23:31:10 +0900 Subject: [PATCH 12/15] Fix an issue where the indentation guide was not displayed when creating a new window --- editor/window.go | 11 ++++++++++- editor/workspace.go | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/editor/window.go b/editor/window.go index 3509d4ca..7aa54b87 100644 --- a/editor/window.go +++ b/editor/window.go @@ -306,7 +306,9 @@ func (w *Window) drawIndentguide(p *gui.QPainter, row, rows int) { return } if w.ft == "" { - return + w.s.ws.optionsetMutex.Lock() + w.ft = w.s.ws.windowsFt[w.id] + w.s.ws.optionsetMutex.Unlock() } if !w.isShown() { return @@ -2408,6 +2410,13 @@ func (w *Window) raise() { func (w *Window) show() { w.fill() w.Show() + + // set buffer local ts value + if w.s.ws.ts != w.ts { + w.s.ws.optionsetMutex.Lock() + w.s.ws.ts = w.ts + w.s.ws.optionsetMutex.Unlock() + } } func (w *Window) hide() { diff --git a/editor/workspace.go b/editor/workspace.go index 9f303cd4..2821f079 100644 --- a/editor/workspace.go +++ b/editor/workspace.go @@ -86,6 +86,7 @@ type Workspace struct { special *RGBA mode string modeIdx int + windowsFt map[nvim.Window]string // TODO filepath string cwd string cwdBase string @@ -134,6 +135,7 @@ func newWorkspace(path string) (*Workspace, error) { foreground: newRGBA(255, 255, 255, 1), background: newRGBA(0, 0, 0, 1), special: newRGBA(255, 255, 255, 1), + windowsFt: make(map[nvim.Window]string), } w.registerSignal() @@ -1952,9 +1954,9 @@ func (w *Workspace) handleRPCGui(updates []interface{}) { w.setBuffname(updates[2], updates[3]) w.setBuffTS() case "gonvim_winenter_filetype": - w.setFileType(updates) w.setBuffname(updates[2], updates[3]) w.setBuffTS() + w.setFileType(updates) case "gonvim_markdown_update": if editor.config.Markdown.Disable { return @@ -2372,7 +2374,7 @@ func (w *Workspace) getPumHeight() { func (w *Workspace) setFileType(args []interface{}) { ft := args[1].(string) - wid := util.ReflectToInt(args[2]) + wid := (nvim.Window)(util.ReflectToInt(args[2])) for _, v := range editor.config.Editor.IndentGuideIgnoreFtList { if v == ft { @@ -2380,6 +2382,14 @@ func (w *Workspace) setFileType(args []interface{}) { } } + // NOTE: There are cases where the target grid is not yet created on the front-end side + // when the FileType autocmd is fired. There may be a better way to implement this, + // and it is an item for improvement in the future. + w.optionsetMutex.Lock() + w.windowsFt[wid] = ft + w.optionsetMutex.Unlock() + + // Update ft on the window w.screen.windows.Range(func(_, winITF interface{}) bool { win := winITF.(*Window) @@ -2392,7 +2402,7 @@ func (w *Workspace) setFileType(args []interface{}) { if win.isMsgGrid { return true } - if int(win.id) != wid { + if win.id != wid { return true } From 992f627832c9c7da7a6a6e81bc4cb2679a5c0423 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Thu, 8 Jul 2021 21:54:39 +0900 Subject: [PATCH 13/15] Fix a problem where the drawing area by smooth scrolling becomes narrow when the window width is narrow --- editor/window.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/editor/window.go b/editor/window.go index 7aa54b87..59bfb75b 100644 --- a/editor/window.go +++ b/editor/window.go @@ -257,10 +257,12 @@ func (w *Window) drawScrollSnapshot(p *gui.QPainter) { if w.s.name == "minimap" { return } - if w.snapshot == nil || editor.isKeyAutoRepeating { return } + if w.scrollPixels2 == 0 { + return + } font := w.getFont() height := w.scrollCols * font.lineHeight @@ -966,7 +968,7 @@ func (win *Window) smoothScroll(diff int) { 0, 0, int(float64(win.cols)*font.truewidth), - win.cols*font.lineHeight, + win.rows*font.lineHeight, ) if win.scrollPixels2 == 0 { win.doErase = true From 20ed5ebd1eae1f57ae6445f4d7bfd372ba214dd0 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sat, 10 Jul 2021 00:36:28 +0900 Subject: [PATCH 14/15] Change the file open command in File Explorer to the command specified in the configuration --- editor/workspace.go | 21 +++++++++++---------- filer/filer.go | 12 +++++++----- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/editor/workspace.go b/editor/workspace.go index 2821f079..15dc837e 100644 --- a/editor/workspace.go +++ b/editor/workspace.go @@ -296,7 +296,7 @@ func (w *Workspace) lazyDrawUI() { // Add editor feature go fuzzy.RegisterPlugin(w.nvim, w.uiRemoteAttached) - go filer.RegisterPlugin(w.nvim) + go filer.RegisterPlugin(w.nvim, editor.config.Editor.FileOpenCmd) // markdown if !editor.config.Markdown.Disable { @@ -2764,15 +2764,16 @@ func (i *WorkspaceSideItem) fileDoubleClicked(item *widgets.QListWidgetItem) { } filepath := path + sep + filename - exec := "" - switch runtime.GOOS { - case "darwin": - exec = ":silent !open " - case "windows": - exec = ":silent !explorer " - case "linux": - exec = ":silent !xdg-open " - } + // exec := "" + // switch runtime.GOOS { + // case "darwin": + // exec = ":silent !open " + // case "windows": + // exec = ":silent !explorer " + // case "linux": + // exec = ":silent !xdg-open " + // } + exec := editor.config.Editor.FileOpenCmd + " " execCommand := exec + filepath for j, ws := range editor.workspaces { diff --git a/filer/filer.go b/filer/filer.go index 4b39d74a..22c581f6 100644 --- a/filer/filer.go +++ b/filer/filer.go @@ -14,17 +14,19 @@ type Filer struct { nvim *nvim.Nvim selectnum int items [](map[string]string) + openCmd string } // RegisterPlugin registers this remote plugin -func RegisterPlugin(nvim *nvim.Nvim) { +func RegisterPlugin(nvim *nvim.Nvim, openCmd string) { nvim.Subscribe("GonvimFiler") - shim := &Filer{ - nvim: nvim, + f := &Filer{ + nvim: nvim, + openCmd: openCmd, } nvim.RegisterHandler("GonvimFiler", func(args ...interface{}) { - go shim.handle(args...) + go f.handle(args...) }) finderFunction := ` aug GonvimAuFiler | au! | aug END @@ -223,7 +225,7 @@ func (f *Filer) right() { command := "" cdCommand := ":tchdir" - editCommand := ":e" + editCommand := f.openCmd switch filetype { case "/": command = "silent " + cdCommand + " " + filename + " | | :redraw!" From b82c2d5a4fc74a6a7a1ff21997b714c7d58500a7 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Sat, 10 Jul 2021 16:58:24 +0900 Subject: [PATCH 15/15] Apply ReversingScrollDirection to markdown preview window --- editor/markdown.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/editor/markdown.go b/editor/markdown.go index fd17c5d0..ed63df07 100644 --- a/editor/markdown.go +++ b/editor/markdown.go @@ -114,16 +114,21 @@ func newMarkdown(workspace *Workspace) *Markdown { func (m *Markdown) wheelEvent(event *gui.QWheelEvent) { var horiz int + direction := 1 + if editor.config.Editor.ReversingScrollDirection { + direction = -1 + } + switch runtime.GOOS { case "darwin": pixels := event.PixelDelta() if pixels != nil { horiz = pixels.Y() } - m.webpage.RunJavaScript(fmt.Sprintf("window.scrollBy(0, %v)", horiz*(-1))) + m.webpage.RunJavaScript(fmt.Sprintf("window.scrollBy(0, %v)", horiz*(-1)*direction)) default: horiz = event.AngleDelta().Y() - m.webpage.RunJavaScript(fmt.Sprintf("window.scrollBy(0, %v)", horiz)) + m.webpage.RunJavaScript(fmt.Sprintf("window.scrollBy(0, %v)", horiz*direction)) } event.Accept()