Skip to content

Commit

Permalink
Merge branch '0.4.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
akiyosi committed Jul 10, 2021
2 parents 6543ab0 + b82c2d5 commit 88fbf9e
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 92 deletions.
32 changes: 26 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
TAG := $(shell git describe --tags --abbrev=0)

# deployment directory
DEPLOYMENT_WINDOWS:=deploy/windows
Expand All @@ -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:

21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,31 @@ 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).
This repository forked from the original [Gonvim](https://github.com/dzhou121/gonvim) for the purpose of maintenance and enhancement.

![](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.
Expand Down Expand Up @@ -44,7 +61,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

See [Installing Neovim](https://github.com/neovim/neovim/wiki/Installing-Neovim)

Expand Down
14 changes: 8 additions & 6 deletions editor/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion editor/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
var editor *Editor

const (
GONEOVIMVERSION = "v0.4.11"
GONEOVIMVERSION = "v0.4.12"
WORKSPACELEN = 10
)

Expand Down
1 change: 1 addition & 0 deletions editor/font.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func (f *Font) putDebugLog() {
editor.putLog(
"detect font family:",
fi.Family(),
fi.PointSizeF(),
fi.StyleName(),
fmt.Sprintf("%v", fi.PointSizeF()),
)
Expand Down
9 changes: 7 additions & 2 deletions editor/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
115 changes: 62 additions & 53 deletions editor/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -939,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,
Expand All @@ -959,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{}) {
Expand Down Expand Up @@ -1313,26 +1324,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 {
Expand All @@ -1357,11 +1366,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)
Expand Down
Loading

0 comments on commit 88fbf9e

Please sign in to comment.