This commit is contained in:
akiyosi 2020-09-26 12:04:36 +09:00
parent 06ce0a7f9f
commit 966a1c5513
21 changed files with 568 additions and 586 deletions

View file

@ -87,8 +87,8 @@ type statusLineConfig struct {
} }
type tabLineConfig struct { type tabLineConfig struct {
Visible bool Visible bool
ShowIcon bool ShowIcon bool
} }
type popupMenuConfig struct { type popupMenuConfig struct {

View file

@ -25,7 +25,7 @@ var editor *Editor
const ( const (
GONEOVIMVERSION = "v0.4.7" GONEOVIMVERSION = "v0.4.7"
WORKSPACELEN = 10 WORKSPACELEN = 10
) )
// ColorPalette is // ColorPalette is
@ -99,9 +99,9 @@ type Editor struct {
sysTray *widgets.QSystemTrayIcon sysTray *widgets.QSystemTrayIcon
chanVisible chan bool chanVisible chan bool
width int width int
height int height int
iconSize int iconSize int
stop chan struct{} stop chan struct{}
stopOnce sync.Once stopOnce sync.Once
@ -170,15 +170,15 @@ func InitEditor() {
} }
editor = &Editor{ editor = &Editor{
version: GONEOVIMVERSION, version: GONEOVIMVERSION,
signal: NewEditorSignal(nil), signal: NewEditorSignal(nil),
notify: make(chan *Notify, 10), notify: make(chan *Notify, 10),
stop: make(chan struct{}), stop: make(chan struct{}),
guiInit: make(chan bool, 1), guiInit: make(chan bool, 1),
config: newGonvimConfig(home), config: newGonvimConfig(home),
homeDir: home, homeDir: home,
args: args, args: args,
opts: opts, opts: opts,
chanVisible: make(chan bool, 2), chanVisible: make(chan bool, 2),
} }
e := editor e := editor
@ -755,6 +755,7 @@ func (e *Editor) convertKey(event *gui.QKeyEvent) string {
c := "" c := ""
if text == "" { if text == "" {
if key == int(core.Qt__Key_Alt ) || if key == int(core.Qt__Key_Alt ) ||
key == int(core.Qt__Key_AltGr ) || key == int(core.Qt__Key_AltGr ) ||
key == int(core.Qt__Key_CapsLock) || key == int(core.Qt__Key_CapsLock) ||
@ -789,7 +790,7 @@ func (e *Editor) convertKey(event *gui.QKeyEvent) string {
if runtime.GOOS == "darwin" { if runtime.GOOS == "darwin" {
// Remove ALT/OPTION // Remove ALT/OPTION
if (char.Unicode() >= 0x80 && char.IsPrint()) { if char.Unicode() >= 0x80 && char.IsPrint() {
mod &= ^core.Qt__AltModifier mod &= ^core.Qt__AltModifier
} }
} }
@ -870,13 +871,11 @@ func (e *Editor) initSpecialKeys() {
e.specialKeys[core.Qt__Key_End] = "End" e.specialKeys[core.Qt__Key_End] = "End"
e.specialKeys[core.Qt__Key_PageUp] = "PageUp" e.specialKeys[core.Qt__Key_PageUp] = "PageUp"
e.specialKeys[core.Qt__Key_PageDown] = "PageDown" e.specialKeys[core.Qt__Key_PageDown] = "PageDown"
e.specialKeys[core.Qt__Key_Return] = "Enter" e.specialKeys[core.Qt__Key_Return] = "Enter"
e.specialKeys[core.Qt__Key_Enter] = "Enter" e.specialKeys[core.Qt__Key_Enter] = "Enter"
e.specialKeys[core.Qt__Key_Tab] = "Tab" e.specialKeys[core.Qt__Key_Tab] = "Tab"
e.specialKeys[core.Qt__Key_Backtab] = "Tab" e.specialKeys[core.Qt__Key_Backtab] = "Tab"
e.specialKeys[core.Qt__Key_Escape] = "Esc" e.specialKeys[core.Qt__Key_Escape] = "Esc"
e.specialKeys[core.Qt__Key_Backslash] = "Bslash" e.specialKeys[core.Qt__Key_Backslash] = "Bslash"
e.specialKeys[core.Qt__Key_Space] = "Space" e.specialKeys[core.Qt__Key_Space] = "Space"

View file

@ -12,26 +12,25 @@ import (
func TestLinuxEditor_convertKey(t *testing.T) { func TestLinuxEditor_convertKey(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
args *gui.QKeyEvent args *gui.QKeyEvent
want string want string
}{ }{
{ {
`convertKey() Linux LessThan modifier keys 1`, `convertKey() Linux LessThan modifier keys 1`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier | core.Qt__ControlModifier, "<", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier|core.Qt__ControlModifier, "<", false, 1),
"<C-lt>", "<C-lt>",
}, },
{ {
`convertKey() Linux LessThan modifier keys 2`, `convertKey() Linux LessThan modifier keys 2`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier | core.Qt__AltModifier, "<", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier|core.Qt__AltModifier, "<", false, 1),
"<A-lt>", "<A-lt>",
}, },
{ {
`convertKey() Linux LessThan modifier keys 3`, `convertKey() Linux LessThan modifier keys 3`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier | core.Qt__MetaModifier, "<", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier|core.Qt__MetaModifier, "<", false, 1),
"<D-lt>", "<D-lt>",
}, },
} }
e := &Editor{} e := &Editor{}
e.InitSpecialKeys() e.InitSpecialKeys()
@ -39,9 +38,9 @@ func TestLinuxEditor_convertKey(t *testing.T) {
tests = append( tests = append(
tests, tests,
[]struct { []struct {
name string name string
args *gui.QKeyEvent args *gui.QKeyEvent
want string want string
}{ }{
{ {
`convertKey() Linux special keys`, `convertKey() Linux special keys`,

View file

@ -12,9 +12,9 @@ import (
func TestDarwinEditor_convertKey(t *testing.T) { func TestDarwinEditor_convertKey(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
args *gui.QKeyEvent args *gui.QKeyEvent
want string want string
}{ }{
{ {
`convertKey() MacOS Alt special key input å`, `convertKey() MacOS Alt special key input å`,
@ -23,27 +23,27 @@ func TestDarwinEditor_convertKey(t *testing.T) {
}, },
{ {
`convertKey() MacOS Alt special key input Å`, `convertKey() MacOS Alt special key input Å`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_A), core.Qt__ShiftModifier | core.Qt__AltModifier, "Å", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_A), core.Qt__ShiftModifier|core.Qt__AltModifier, "Å", false, 1),
"Å", "Å",
}, },
{ {
`convertKey() MacOS Alt special key input Ò`, `convertKey() MacOS Alt special key input Ò`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_L), core.Qt__ShiftModifier | core.Qt__AltModifier, "Ò", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_L), core.Qt__ShiftModifier|core.Qt__AltModifier, "Ò", false, 1),
"Ò", "Ò",
}, },
{ {
`convertKey() MacOS LessThan modifier keys 1`, `convertKey() MacOS LessThan modifier keys 1`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier | core.Qt__ControlModifier, "<", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier|core.Qt__ControlModifier, "<", false, 1),
"<D-lt>", "<D-lt>",
}, },
{ {
`convertKey() MacOS LessThan modifier keys 2`, `convertKey() MacOS LessThan modifier keys 2`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier | core.Qt__AltModifier, "<", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier|core.Qt__AltModifier, "<", false, 1),
"<A-lt>", "<A-lt>",
}, },
{ {
`convertKey() MacOS LessThan modifier keys 3`, `convertKey() MacOS LessThan modifier keys 3`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier | core.Qt__MetaModifier, "<", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier|core.Qt__MetaModifier, "<", false, 1),
"<C-lt>", "<C-lt>",
}, },
{ {
@ -53,20 +53,19 @@ func TestDarwinEditor_convertKey(t *testing.T) {
}, },
{ {
`convertKey() MacOS keyboardlayout unicode hex input 2`, `convertKey() MacOS keyboardlayout unicode hex input 2`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_A), core.Qt__AltModifier | core.Qt__ShiftModifier, "", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_A), core.Qt__AltModifier|core.Qt__ShiftModifier, "", false, 1),
"<A-A>", "<A-A>",
}, },
{ {
`convertKey() MacOS keyboardlayout unicode hex input 3`, `convertKey() MacOS keyboardlayout unicode hex input 3`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_A), core.Qt__MetaModifier | core.Qt__AltModifier, "", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_A), core.Qt__MetaModifier|core.Qt__AltModifier, "", false, 1),
"<C-A-a>", "<C-A-a>",
}, },
{ {
`convertKey() MacOS keyboardlayout unicode hex input 4`, `convertKey() MacOS keyboardlayout unicode hex input 4`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_A), core.Qt__MetaModifier | core.Qt__AltModifier | core.Qt__ShiftModifier, "", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_A), core.Qt__MetaModifier|core.Qt__AltModifier|core.Qt__ShiftModifier, "", false, 1),
"<C-A-A>", "<C-A-A>",
}, },
} }
e := &Editor{} e := &Editor{}
e.InitSpecialKeys() e.InitSpecialKeys()
@ -77,9 +76,9 @@ func TestDarwinEditor_convertKey(t *testing.T) {
tests = append( tests = append(
tests, tests,
[]struct { []struct {
name string name string
args *gui.QKeyEvent args *gui.QKeyEvent
want string want string
}{ }{
{ {
`convertKey() MacOS special keys`, `convertKey() MacOS special keys`,

View file

@ -9,9 +9,9 @@ import (
func TestEditor_convertKey(t *testing.T) { func TestEditor_convertKey(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
args *gui.QKeyEvent args *gui.QKeyEvent
want string want string
}{ }{
{ {
`convertKey() Shift is implied with "<", send "<lt>" instead`, `convertKey() Shift is implied with "<", send "<lt>" instead`,
@ -98,7 +98,6 @@ func TestEditor_convertKey(t *testing.T) {
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_CapsLock), core.Qt__ControlModifier, "", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_CapsLock), core.Qt__ControlModifier, "", false, 1),
"", "",
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt tt := tt

View file

@ -12,26 +12,25 @@ import (
func TestLinuxEditor_convertKey(t *testing.T) { func TestLinuxEditor_convertKey(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
args *gui.QKeyEvent args *gui.QKeyEvent
want string want string
}{ }{
{ {
`convertKey() Linux LessThan modifier keys 1`, `convertKey() Linux LessThan modifier keys 1`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier | core.Qt__ControlModifier, "<", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier|core.Qt__ControlModifier, "<", false, 1),
"<C-lt>", "<C-lt>",
}, },
{ {
`convertKey() Linux LessThan modifier keys 2`, `convertKey() Linux LessThan modifier keys 2`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier | core.Qt__AltModifier, "<", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier|core.Qt__AltModifier, "<", false, 1),
"<A-lt>", "<A-lt>",
}, },
{ {
`convertKey() Linux LessThan modifier keys 3`, `convertKey() Linux LessThan modifier keys 3`,
gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier | core.Qt__MetaModifier, "<", false, 1), gui.NewQKeyEvent(core.QEvent__KeyPress, int(core.Qt__Key_Less), core.Qt__ShiftModifier|core.Qt__MetaModifier, "<", false, 1),
"<lt>", "<lt>",
}, },
} }
e := &Editor{} e := &Editor{}
e.InitSpecialKeys() e.InitSpecialKeys()
@ -39,9 +38,9 @@ func TestLinuxEditor_convertKey(t *testing.T) {
tests = append( tests = append(
tests, tests,
[]struct { []struct {
name string name string
args *gui.QKeyEvent args *gui.QKeyEvent
want string want string
}{ }{
{ {
`convertKey() Linux special keys`, `convertKey() Linux special keys`,

View file

@ -3,4 +3,3 @@ package editor
func (e *Editor) InitSpecialKeys() { func (e *Editor) InitSpecialKeys() {
e.initSpecialKeys() e.initSpecialKeys()
} }

View file

@ -100,7 +100,6 @@ func (f *Font) change(family string, size float64, weight gui.QFont__Weight, str
f.ws.screen.purgeTextCacheForWins() f.ws.screen.purgeTextCacheForWins()
} }
func (f *Font) changeLineSpace(lineSpace int) { func (f *Font) changeLineSpace(lineSpace int) {
f.lineSpace = lineSpace f.lineSpace = lineSpace
f.lineHeight = f.height + lineSpace f.lineHeight = f.height + lineSpace

View file

@ -9,13 +9,13 @@ import (
"github.com/akiyosi/goneovim/util" "github.com/akiyosi/goneovim/util"
"github.com/alecthomas/chroma/formatters/html" "github.com/alecthomas/chroma/formatters/html"
"github.com/yuin/goldmark"
highlighting "github.com/yuin/goldmark-highlighting"
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui" "github.com/therecipe/qt/gui"
"github.com/therecipe/qt/webchannel" "github.com/therecipe/qt/webchannel"
"github.com/therecipe/qt/webengine" "github.com/therecipe/qt/webengine"
"github.com/therecipe/qt/widgets" "github.com/therecipe/qt/widgets"
"github.com/yuin/goldmark"
highlighting "github.com/yuin/goldmark-highlighting"
) )
// //
@ -62,14 +62,14 @@ func newMarkdown(workspace *Workspace) *Markdown {
var err error var err error
go func() { go func() {
basePath, err = m.ws.nvim.CommandOutput(`echo expand('%:p:h')`) basePath, err = m.ws.nvim.CommandOutput(`echo expand('%:p:h')`)
done <-err done <- err
}() }()
select { select {
case <-done: case <-done:
case <-time.After(40 * time.Millisecond): case <-time.After(40 * time.Millisecond):
} }
// Create bae url // Create bae url
baseUrl := `file://`+ basePath +`/` baseUrl := `file://` + basePath + `/`
if !m.htmlSet { if !m.htmlSet {
m.htmlSet = true m.htmlSet = true
m.webpage.SetHtml(m.getHTML(content), core.NewQUrl3(baseUrl, 0)) m.webpage.SetHtml(m.getHTML(content), core.NewQUrl3(baseUrl, 0))

View file

@ -5,8 +5,8 @@ import (
"math" "math"
"runtime" "runtime"
"github.com/akiyosi/goneovim/util"
"github.com/akiyosi/goneovim/fuzzy" "github.com/akiyosi/goneovim/fuzzy"
"github.com/akiyosi/goneovim/util"
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui" "github.com/therecipe/qt/gui"
"github.com/therecipe/qt/svg" "github.com/therecipe/qt/svg"

View file

@ -43,7 +43,7 @@ type PopupItem struct {
wordRequest string wordRequest string
kindwidget *widgets.QWidget kindwidget *widgets.QWidget
kindIcon *svg.QSvgWidget kindIcon *svg.QSvgWidget
menuLabel *widgets.QLabel menuLabel *widgets.QLabel
menu string menu string
@ -56,7 +56,7 @@ type PopupItem struct {
selected bool selected bool
selectedRequest bool selectedRequest bool
hidden bool hidden bool
detailText string detailText string
} }
@ -131,12 +131,12 @@ func initPopupmenuNew() *PopupMenu {
itemLayout.AddWidget2(info, i, 3, core.Qt__AlignLeft) itemLayout.AddWidget2(info, i, 3, core.Qt__AlignLeft)
popupItem := &PopupItem{ popupItem := &PopupItem{
p: popup, p: popup,
kindIcon: kindIcon, kindIcon: kindIcon,
kindwidget: iconwidget, kindwidget: iconwidget,
wordLabel: word, wordLabel: word,
menuLabel: menu, menuLabel: menu,
infoLabel: info, infoLabel: info,
} }
popupItems = append(popupItems, popupItem) popupItems = append(popupItems, popupItem)
} }
@ -155,7 +155,7 @@ func (p *PopupMenu) updateFont(font *Font) {
popupItem.menuLabel.SetFont(font.fontNew) popupItem.menuLabel.SetFont(font.fontNew)
popupItem.infoLabel.SetFont(font.fontNew) popupItem.infoLabel.SetFont(font.fontNew)
popupItem.kindIcon.SetFixedSize2(font.lineHeight, font.lineHeight) popupItem.kindIcon.SetFixedSize2(font.lineHeight, font.lineHeight)
popupItem.kindwidget.SetFixedWidth(font.lineHeight+editor.config.Editor.Linespace*2) popupItem.kindwidget.SetFixedWidth(font.lineHeight + editor.config.Editor.Linespace*2)
} }
} }
@ -234,7 +234,7 @@ func (p *PopupMenu) showItems(args []interface{}) {
p.detailLabel.SetText("") p.detailLabel.SetText("")
popupItems := p.items popupItems := p.items
itemHeight := (lineHeight)+(editor.config.Editor.Linespace+4) itemHeight := (lineHeight) + (editor.config.Editor.Linespace + 4)
// Calc the maximum completion items // Calc the maximum completion items
// where, // where,
@ -242,7 +242,7 @@ func (p *PopupMenu) showItems(args []interface{}) {
// `p.ws.screen.height` is the entire screen height // `p.ws.screen.height` is the entire screen height
heightLeft := 0 heightLeft := 0
if isCursorBelowTheCenter { if isCursorBelowTheCenter {
heightLeft = row*lineHeight heightLeft = row * lineHeight
} else { } else {
heightLeft = p.ws.screen.height - (row+1)*lineHeight heightLeft = p.ws.screen.height - (row+1)*lineHeight
} }
@ -254,7 +254,7 @@ func (p *PopupMenu) showItems(args []interface{}) {
} }
startNum := 0 startNum := 0
if selected >= len(items) - p.showTotal && len(items) > p.total { if selected >= len(items)-p.showTotal && len(items) > p.total {
startNum = len(items) - p.showTotal startNum = len(items) - p.showTotal
} }
@ -574,47 +574,47 @@ func (p *PopupItem) setKind(kind string, selected bool) {
icon := "" icon := ""
switch formattedKind { switch formattedKind {
case "text" : case "text":
icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword) icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword)
case "method", "function", "constructor" : case "method", "function", "constructor":
icon = editor.getSvg("lsp_function", colorOfFunc) icon = editor.getSvg("lsp_function", colorOfFunc)
case "field", "variable", "property" : case "field", "variable", "property":
icon = editor.getSvg("lsp_variable", colorOfFunc) icon = editor.getSvg("lsp_variable", colorOfFunc)
case "class" : case "class":
icon = editor.getSvg("lsp_"+formattedKind, colorOfFunc) icon = editor.getSvg("lsp_"+formattedKind, colorOfFunc)
case "interface" : case "interface":
icon = editor.getSvg("lsp_"+formattedKind, colorOfFunc) icon = editor.getSvg("lsp_"+formattedKind, colorOfFunc)
case "module" : case "module":
icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword) icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword)
case "unit" : case "unit":
icon = editor.getSvg("lsp_"+formattedKind, colorOfStatement) icon = editor.getSvg("lsp_"+formattedKind, colorOfStatement)
case "value" : case "value":
icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword) icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword)
case "enum" : case "enum":
icon = editor.getSvg("lsp_"+formattedKind, colorOfType) icon = editor.getSvg("lsp_"+formattedKind, colorOfType)
case "keyword" : case "keyword":
icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword) icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword)
case "snippet" : case "snippet":
icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword) icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword)
case "color" : case "color":
icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword) icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword)
case "file" : case "file":
icon = editor.getSvg("lsp_"+formattedKind, colorOfType) icon = editor.getSvg("lsp_"+formattedKind, colorOfType)
case "reference" : case "reference":
icon = editor.getSvg("lsp_"+formattedKind, colorOfType) icon = editor.getSvg("lsp_"+formattedKind, colorOfType)
case "folder" : case "folder":
icon = editor.getSvg("lsp_"+formattedKind, colorOfType) icon = editor.getSvg("lsp_"+formattedKind, colorOfType)
case "enummember" : case "enummember":
icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword) icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword)
case "constant" : case "constant":
icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword) icon = editor.getSvg("lsp_"+formattedKind, colorOfKeyword)
case "struct" : case "struct":
icon = editor.getSvg("lsp_"+formattedKind, colorOfStatement) icon = editor.getSvg("lsp_"+formattedKind, colorOfStatement)
case "event" : case "event":
icon = editor.getSvg("lsp_"+formattedKind, colorOfStatement) icon = editor.getSvg("lsp_"+formattedKind, colorOfStatement)
case "operato" : case "operato":
icon = editor.getSvg("lsp_"+formattedKind, colorOfStatement) icon = editor.getSvg("lsp_"+formattedKind, colorOfStatement)
case "typeparameter" : case "typeparameter":
icon = editor.getSvg("lsp_"+formattedKind, colorOfType) icon = editor.getSvg("lsp_"+formattedKind, colorOfType)
default: default:
iconColor := warpColor(editor.colors.fg, -45) iconColor := warpColor(editor.colors.fg, -45)
@ -644,32 +644,32 @@ func (p *PopupItem) setKind(kind string, selected bool) {
} }
func normalizeKind(kind string) string { func normalizeKind(kind string) string {
// Completion kinds is // Completion kinds is
// Text // Text
// Method // Method
// Function // Function
// Constructor // Constructor
// Field // Field
// Variable // Variable
// Class // Class
// Interface // Interface
// Module // Module
// Property // Property
// Unit // Unit
// Value // Value
// Enum // Enum
// Keyword // Keyword
// Snippet // Snippet
// Color // Color
// File // File
// Reference // Reference
// Folder // Folder
// EnumMember // EnumMember
// Constant // Constant
// Struct // Struct
// Event // Event
// Operator // Operator
// TypeParameter // TypeParameter
if len(kind) == 1 { if len(kind) == 1 {
switch kind { switch kind {
case "v": case "v":
@ -677,7 +677,7 @@ func normalizeKind(kind string) string {
case "f": case "f":
return "function" // equate with "method", "constructor" return "function" // equate with "method", "constructor"
case "m": case "m":
return "field" // equate with "property", "enumMember" return "field" // equate with "property", "enumMember"
case "C": case "C":
return "class" return "class"
case "I": case "I":
@ -687,13 +687,13 @@ func normalizeKind(kind string) string {
case "U": case "U":
return "unit" return "unit"
case "E": case "E":
return "enum" // equate with "event"?? return "enum" // equate with "event"??
case "k": case "k":
return "keyword" return "keyword"
case "S": case "S":
return "snippet" // equate with "struct"?? return "snippet" // equate with "struct"??
case "F": case "F":
return "file" // equate with "folder" return "file" // equate with "folder"
case "r": case "r":
return "reference" return "reference"
case "O": case "O":
@ -705,7 +705,7 @@ func normalizeKind(kind string) string {
lowerKindText := strings.ToLower(kind) lowerKindText := strings.ToLower(kind)
switch lowerKindText { switch lowerKindText {
case "func", "instance" : case "func", "instance":
return "function" return "function"
case "var", "statement", "param", "const": case "var", "statement", "param", "const":
return "variable" return "variable"

View file

@ -186,7 +186,6 @@ func newRGBA(r int, g int, b int, a float64) *RGBA {
} }
} }
func (rgba *RGBA) XYZ() *XYZ { func (rgba *RGBA) XYZ() *XYZ {
r := float64(rgba.R) / 255.0 r := float64(rgba.R) / 255.0
g := float64(rgba.G) / 255.0 g := float64(rgba.G) / 255.0

View file

@ -445,8 +445,8 @@ func (s *Screen) gridFont(update interface{}) {
s.ws.cursor.updateFont(font) s.ws.cursor.updateFont(font)
if win.isExternal { if win.isExternal {
width := int(float64(newCols) * win.font.truewidth) + EXTWINBORDERSIZE*2 width := int(float64(newCols)*win.font.truewidth) + EXTWINBORDERSIZE*2
height := newRows * win.font.lineHeight + EXTWINBORDERSIZE*2 height := newRows*win.font.lineHeight + EXTWINBORDERSIZE*2
win.extwin.Resize2(width, height) win.extwin.Resize2(width, height)
} }
} }
@ -827,10 +827,9 @@ func (w *Window) drawFloatWindowBorder(p *gui.QPainter) {
width := float64(w.widget.Width()) width := float64(w.widget.Width())
height := float64(w.widget.Height()) height := float64(w.widget.Height())
left := core.NewQRectF4( 0, 0, 1, height)
left := core.NewQRectF4( 0, 0, 1, height) top := core.NewQRectF4( 0, 0, width, 1)
top := core.NewQRectF4( 0, 0, width, 1) right := core.NewQRectF4(width-1, 0, 1, height)
right := core.NewQRectF4(width-1, 0, 1, height)
bottom := core.NewQRectF4( 0, height-1, width, 1) bottom := core.NewQRectF4( 0, height-1, width, 1)
p.FillRect4( p.FillRect4(
@ -934,17 +933,17 @@ func (w *Window) drawWindowSeparator(p *gui.QPainter, gwinrows int) {
if w.s.ws.showtabline == 2 && drawTabline && numOfTabs == 1 { if w.s.ws.showtabline == 2 && drawTabline && numOfTabs == 1 {
tablineNum = -1 tablineNum = -1
} }
shift := font.lineHeight/2 shift := font.lineHeight / 2
if w.rows+w.s.ws.showtabline+tablineNum+1 == gwinrows { if w.rows+w.s.ws.showtabline+tablineNum+1 == gwinrows {
winHeight = w.rows * font.lineHeight winHeight = w.rows * font.lineHeight
shift = 0 shift = 0
} else { } else {
if w.pos[1] == tablineNum { if w.pos[1] == tablineNum {
winHeight = w.rows * font.lineHeight + int(float64(font.lineHeight)/2.0) winHeight = w.rows*font.lineHeight + int(float64(font.lineHeight)/2.0)
shift = 0 shift = 0
} }
if w.pos[1]+w.rows == gwinrows-2 { if w.pos[1]+w.rows == gwinrows-2 {
winHeight = w.rows * font.lineHeight + int(float64(font.lineHeight)/2.0) winHeight = w.rows*font.lineHeight + int(float64(font.lineHeight)/2.0)
} }
} }
@ -1897,11 +1896,11 @@ func (s *Screen) updateGridContent(arg []interface{}) {
if s.name != "minimap" { if s.name != "minimap" {
// Draw bottom statusline // Draw bottom statusline
if row == win.rows - 2 { if row == win.rows-2 {
isSkipDraw = false isSkipDraw = false
} }
// Draw tabline // Draw tabline
if row == 0 { if row == 0 {
isSkipDraw = false isSkipDraw = false
} }
@ -2001,8 +2000,8 @@ func (w *Window) updateLine(col, row int, cells []interface{}) {
} }
if line[col].highlight.uiName == "Pmenu" || if line[col].highlight.uiName == "Pmenu" ||
line[col].highlight.uiName == "PmenuSel" || line[col].highlight.uiName == "PmenuSel" ||
line[col].highlight.uiName == "PmenuSbar" { line[col].highlight.uiName == "PmenuSbar" {
w.isPopupmenu = true w.isPopupmenu = true
} }
@ -2838,11 +2837,11 @@ func (w *Window) getFillpatternAndTransparent(hl *Highlight) (core.Qt__BrushStyl
t := 255 t := 255
// if pumblend > 0 // if pumblend > 0
if w.isPopupmenu { if w.isPopupmenu {
t = int(((transparent() * 255.0)) * ((100.0 - float64(w.s.ws.pb)) / 100.0)) t = int((transparent() * 255.0) * ((100.0 - float64(w.s.ws.pb)) / 100.0))
} }
// if winblend > 0 // if winblend > 0
if !w.isPopupmenu && w.wb > 0 { if !w.isPopupmenu && w.wb > 0 {
t = int(((transparent() * 255.0)) * ((100.0 - float64(w.wb)) / 100.0)) t = int((transparent() * 255.0) * ((100.0 - float64(w.wb)) / 100.0))
} }
if w.isMsgGrid && editor.config.Message.Transparent < 1.0 { if w.isMsgGrid && editor.config.Message.Transparent < 1.0 {
t = int(editor.config.Message.Transparent * 255.0) t = int(editor.config.Message.Transparent * 255.0)
@ -2971,14 +2970,13 @@ func (win *Window) getWinblend() {
wb := 0 wb := 0
go func() { go func() {
err := win.s.ws.nvim.WindowOption(win.id, "winblend", &wb) err := win.s.ws.nvim.WindowOption(win.id, "winblend", &wb)
errCh <-err errCh <- err
}() }()
select { select {
case <-errCh: case <-errCh:
case <-time.After(40 * time.Millisecond): case <-time.After(40 * time.Millisecond):
} }
if wb > 0 { if wb > 0 {
win.widget.SetAutoFillBackground(false) win.widget.SetAutoFillBackground(false)
} else { } else {
@ -3070,7 +3068,7 @@ func (s *Screen) windowFloatPosition(args []interface{}) {
row := 0 row := 0
contextLine := 0 contextLine := 0
if anchorwin.rows - s.cursor[0] >= 2 { if anchorwin.rows-s.cursor[0] >= 2 {
contextLine = 2 contextLine = 2
} else { } else {
contextLine = anchorwin.rows - s.cursor[0] contextLine = anchorwin.rows - s.cursor[0]

View file

@ -7,11 +7,10 @@ import (
func createExternalWin() *ExternalWin { func createExternalWin() *ExternalWin {
extwin := NewExternalWin(nil, 0) extwin := NewExternalWin(nil, 0)
extwin.SetWindowFlag(core.Qt__WindowMaximizeButtonHint, false) extwin.SetWindowFlag(core.Qt__WindowMaximizeButtonHint, false)
extwin.SetWindowFlag(core.Qt__WindowMinimizeButtonHint, false) extwin.SetWindowFlag(core.Qt__WindowMinimizeButtonHint, false)
extwin.SetWindowFlag(core.Qt__WindowCloseButtonHint, false) extwin.SetWindowFlag(core.Qt__WindowCloseButtonHint, false)
extwin.SetWindowFlag(core.Qt__WindowContextHelpButtonHint, false) extwin.SetWindowFlag(core.Qt__WindowContextHelpButtonHint, false)
return extwin return extwin
} }

View file

@ -98,35 +98,35 @@ func TestHighlight_fg(t *testing.T) {
func TestWindow_updateLine(t *testing.T) { func TestWindow_updateLine(t *testing.T) {
type fields struct { type fields struct {
// rwMutex sync.RWMutex // rwMutex sync.RWMutex
// paintMutex sync.Mutex // paintMutex sync.Mutex
// redrawMutex sync.Mutex // redrawMutex sync.Mutex
s *Screen s *Screen
content [][]*Cell content [][]*Cell
// lenLine []int // lenLine []int
// lenContent []int // lenContent []int
// lenOldContent []int // lenOldContent []int
grid gridId grid gridId
// isGridDirty bool // isGridDirty bool
// id nvim.Window // id nvim.Window
// bufName string // bufName string
// pos [2]int // pos [2]int
// anchor string // anchor string
cols int cols int
rows int rows int
// isMsgGrid bool // isMsgGrid bool
// isFloatWin bool // isFloatWin bool
// widget *widgets.QWidget // widget *widgets.QWidget
// shown bool // shown bool
// queueRedrawArea [4]int // queueRedrawArea [4]int
// scrollRegion []int // scrollRegion []int
// devicePixelRatio float64 // devicePixelRatio float64
// textCache gcache.Cache // textCache gcache.Cache
// font *Font // font *Font
// fobackground *RGBA // fobackground *RGBA
// width float64 // width float64
// height int // height int
// localWindows *[4]localWindow // localWindows *[4]localWindow
} }
type args struct { type args struct {
col int col int
@ -205,107 +205,103 @@ func TestWindow_updateLine(t *testing.T) {
{ {
"test_updateline() 1", "test_updateline() 1",
fields{ fields{
s: &Screen{hlAttrDef: hldef}, s: &Screen{hlAttrDef: hldef},
content: content, content: content,
grid: gridid, grid: gridid,
cols: cols, cols: cols,
rows: rows, rows: rows,
}, },
args{ args{
col: 0, col: 0,
row: row, row: row,
cells: []interface{}{ cells: []interface{}{
[]interface{}{"~", 7}, []interface{}{"~", 7},
[]interface{}{" ", 7, 4}, []interface{}{" ", 7, 4},
}, },
}, },
[]Cell{ []Cell{
Cell{ true, "~", hldef[7] }, Cell{true, "~", hldef[7]},
Cell{ true, " ", hldef[7] }, Cell{true, " ", hldef[7]},
Cell{ true, " ", hldef[7] }, Cell{true, " ", hldef[7]},
Cell{ true, " ", hldef[7] }, Cell{true, " ", hldef[7]},
Cell{ true, " ", hldef[7] }, Cell{true, " ", hldef[7]},
}, },
}, },
{ {
"test_updateline() 2", "test_updateline() 2",
fields{ fields{
s: &Screen{hlAttrDef: hldef}, s: &Screen{hlAttrDef: hldef},
content: content, content: content,
grid: 6, grid: 6,
cols: cols, cols: cols,
rows: rows, rows: rows,
}, },
args{ args{
col: 3, col: 3,
row: row, row: row,
cells: []interface{}{ cells: []interface{}{
[]interface{}{"*", 6, 2}, []interface{}{"*", 6, 2},
}, },
}, },
[]Cell{ []Cell{
Cell{ true, "~", hldef[7] }, Cell{true, "~", hldef[7]},
Cell{ true, " ", hldef[7] }, Cell{true, " ", hldef[7]},
Cell{ true, " ", hldef[7] }, Cell{true, " ", hldef[7]},
Cell{ true, "*", hldef[6] }, Cell{true, "*", hldef[6]},
Cell{ true, "*", hldef[6] }, Cell{true, "*", hldef[6]},
}, },
}, },
{ {
"test_updateline() 3", "test_updateline() 3",
fields{ fields{
s: &Screen{hlAttrDef: hldef}, s: &Screen{hlAttrDef: hldef},
content: content, content: content,
grid: 6, grid: 6,
cols: cols, cols: cols,
rows: rows, rows: rows,
}, },
args{ args{
col: 1, col: 1,
row: row, row: row,
cells: []interface{}{ cells: []interface{}{
[]interface{}{"@", 6}, []interface{}{"@", 6},
[]interface{}{"v"}, []interface{}{"v"},
[]interface{}{"i"}, []interface{}{"i"},
[]interface{}{"m"}, []interface{}{"m"},
}, },
}, },
[]Cell{ []Cell{
Cell{ true, "~", hldef[7] }, Cell{true, "~", hldef[7]},
Cell{ true, "@", hldef[6] }, Cell{true, "@", hldef[6]},
Cell{ true, "v", hldef[6] }, Cell{true, "v", hldef[6]},
Cell{ true, "i", hldef[6] }, Cell{true, "i", hldef[6]},
Cell{ true, "m", hldef[6] }, Cell{true, "m", hldef[6]},
}, },
}, },
{ {
"test_updateline() 4", "test_updateline() 4",
fields{ fields{
s: &Screen{hlAttrDef: hldef}, s: &Screen{hlAttrDef: hldef},
content: content, content: content,
grid: 6, grid: 6,
cols: cols, cols: cols,
rows: rows, rows: rows,
}, },
args{ args{
col: 0, col: 0,
row: row, row: row,
cells: []interface{}{ cells: []interface{}{
[]interface{}{" ", 7, 2}, []interface{}{" ", 7, 2},
[]interface{}{"J"}, []interface{}{"J"},
}, },
}, },
[]Cell{ []Cell{
Cell{ true, " ", hldef[7] }, Cell{true, " ", hldef[7]},
Cell{ true, " ", hldef[7] }, Cell{true, " ", hldef[7]},
Cell{ true, "J", hldef[7] }, Cell{true, "J", hldef[7]},
Cell{ true, "i", hldef[6] }, Cell{true, "i", hldef[6]},
Cell{ true, "m", hldef[6] }, Cell{true, "m", hldef[6]},
}, },
}, },
} }
@ -314,15 +310,15 @@ func TestWindow_updateLine(t *testing.T) {
tt := tt tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
w := &Window{ w := &Window{
s: tt.fields.s, s: tt.fields.s,
content: tt.fields.content, content: tt.fields.content,
grid: tt.fields.grid, grid: tt.fields.grid,
cols: tt.fields.cols, cols: tt.fields.cols,
rows: tt.fields.rows, rows: tt.fields.rows,
} }
w.updateLine(tt.args.col, tt.args.row, tt.args.cells) w.updateLine(tt.args.col, tt.args.row, tt.args.cells)
got := w.content[row]; got := w.content[row]
for i, cell := range got { for i, cell := range got {
if cell == nil { if cell == nil {
continue continue

View file

@ -7,9 +7,9 @@ import (
func createExternalWin() *ExternalWin { func createExternalWin() *ExternalWin {
extwin := NewExternalWin(nil, 0) extwin := NewExternalWin(nil, 0)
extwin.SetWindowFlag(core.Qt__WindowMaximizeButtonHint, false) extwin.SetWindowFlag(core.Qt__WindowMaximizeButtonHint, false)
extwin.SetWindowFlag(core.Qt__WindowMinimizeButtonHint, false) extwin.SetWindowFlag(core.Qt__WindowMinimizeButtonHint, false)
extwin.SetWindowFlag(core.Qt__WindowCloseButtonHint, false) extwin.SetWindowFlag(core.Qt__WindowCloseButtonHint, false)
extwin.SetWindowFlag(core.Qt__WindowContextHelpButtonHint, false) extwin.SetWindowFlag(core.Qt__WindowContextHelpButtonHint, false)
return extwin return extwin

View file

@ -6,14 +6,14 @@ import (
"sync" "sync"
"github.com/akiyosi/goneovim/util" "github.com/akiyosi/goneovim/util"
"github.com/therecipe/qt/widgets"
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui" "github.com/therecipe/qt/gui"
"github.com/therecipe/qt/widgets"
) )
// ScrollBar is // ScrollBar is
type ScrollBar struct { type ScrollBar struct {
mu sync.Mutex mu sync.Mutex
ws *Workspace ws *Workspace
widget *widgets.QWidget widget *widgets.QWidget
@ -36,7 +36,7 @@ func newScrollBar() *ScrollBar {
thumb: thumb, thumb: thumb,
} }
scrollBar.thumb.ConnectMousePressEvent(scrollBar. thumbPress) scrollBar.thumb.ConnectMousePressEvent(scrollBar.thumbPress)
scrollBar.thumb.ConnectMouseMoveEvent(scrollBar.thumbScroll) scrollBar.thumb.ConnectMouseMoveEvent(scrollBar.thumbScroll)
scrollBar.thumb.ConnectMouseReleaseEvent(scrollBar.thumbRelease) scrollBar.thumb.ConnectMouseReleaseEvent(scrollBar.thumbRelease)
scrollBar.thumb.ConnectEnterEvent(scrollBar.thumbEnter) scrollBar.thumb.ConnectEnterEvent(scrollBar.thumbEnter)
@ -79,7 +79,7 @@ func (s *ScrollBar) thumbScroll(e *gui.QMouseEvent) {
if s.height < 20 { if s.height < 20 {
thumbHeight = 20 thumbHeight = 20
} }
ratio := float64((s.ws.maxLine * font.lineHeight) + thumbHeight) / float64(s.widget.Height()) ratio := float64((s.ws.maxLine*font.lineHeight)+thumbHeight) / float64(s.widget.Height())
v := s.beginPosY - e.GlobalPos().Y() v := s.beginPosY - e.GlobalPos().Y()
if v == 0 { if v == 0 {
return return

View file

@ -22,10 +22,10 @@ import (
// Statusline is // Statusline is
type Statusline struct { type Statusline struct {
ws *Workspace ws *Workspace
hl *Highlight hl *Highlight
widget *widgets.QWidget widget *widgets.QWidget
height int height int
left *LeftStatusItem left *LeftStatusItem
@ -121,10 +121,10 @@ type StatuslineMode struct {
// StatuslineGit is // StatuslineGit is
type StatuslineGit struct { type StatuslineGit struct {
s *Statusline s *Statusline
branch string branch string
file string file string
c *StatuslineComponent c *StatuslineComponent
} }
// StatuslineEncoding is // StatuslineEncoding is
@ -443,7 +443,6 @@ func (s *Statusline) setContentsMarginsForWidgets(l int, u int, r int, d int) {
s.lint.c.widget.SetContentsMargins(l, u, r, d) s.lint.c.widget.SetContentsMargins(l, u, r, d)
} }
func (s *Statusline) getColor() { func (s *Statusline) getColor() {
if s.ws.screen.highlightGroup == nil || s.ws.screen.hlAttrDef == nil { if s.ws.screen.highlightGroup == nil || s.ws.screen.hlAttrDef == nil {
return return

File diff suppressed because one or more lines are too long

View file

@ -170,9 +170,9 @@ func newTab() *Tab {
l.AddWidget(closeIcon, 0, 0) l.AddWidget(closeIcon, 0, 0)
w.SetLayout(l) w.SetLayout(l)
tab := &Tab{ tab := &Tab{
widget: w, widget: w,
layout: l, layout: l,
file: file, file: file,
closeIcon: closeIcon, closeIcon: closeIcon,
} }
if editor.config.Tabline.ShowIcon { if editor.config.Tabline.ShowIcon {
@ -387,7 +387,6 @@ func (t *Tabline) update(args []interface{}) {
} }
} }
func getFileType(text string) string { func getFileType(text string) string {
if strings.HasPrefix(text, "term://") { if strings.HasPrefix(text, "term://") {
return "terminal" return "terminal"

View file

@ -244,7 +244,7 @@ func newWorkspace(path string) (*Workspace, error) {
} }
scrWidget.SetLayout(scrLayout) scrWidget.SetLayout(scrLayout)
// assemble all neovim ui // assemble all neovim ui
if editor.config.Editor.ExtTabline { if editor.config.Editor.ExtTabline {
layout.AddWidget(w.tabline.widget, 0, 0) layout.AddWidget(w.tabline.widget, 0, 0)
} }
@ -513,7 +513,7 @@ func (w *Workspace) initGonvim() {
command! GonvimVersion echo "%s"`, editor.version) command! GonvimVersion echo "%s"`, editor.version)
if !w.uiRemoteAttached { if !w.uiRemoteAttached {
if !editor.config.MiniMap.Disable { if !editor.config.MiniMap.Disable {
gonvimCommands = gonvimCommands + ` gonvimCommands = gonvimCommands + `
command! GonvimMiniMap call rpcnotify(0, "Gui", "gonvim_minimap_toggle") command! GonvimMiniMap call rpcnotify(0, "Gui", "gonvim_minimap_toggle")
` `
} }
@ -565,7 +565,7 @@ func (w *Workspace) getColorscheme() {
colorscheme := "" colorscheme := ""
go func() { go func() {
w.nvim.Var("colors_name", &colorscheme) w.nvim.Var("colors_name", &colorscheme)
done <-true done <- true
}() }()
select { select {
case <-done: case <-done:
@ -579,7 +579,7 @@ func (w *Workspace) getTS() {
ts := 8 ts := 8
go func() { go func() {
w.nvim.Option("ts", &ts) w.nvim.Option("ts", &ts)
done <-true done <- true
}() }()
select { select {
case <-done: case <-done:
@ -593,7 +593,7 @@ func (w *Workspace) getBG() {
screenbg := "dark" screenbg := "dark"
go func() { go func() {
w.nvim.Option("background", &screenbg) w.nvim.Option("background", &screenbg)
done <-true done <- true
}() }()
select { select {
case <-done: case <-done:
@ -635,7 +635,7 @@ func (w *Workspace) getKeymaps() {
if err != nil { if err != nil {
return return
} }
done <-true done <- true
}() }()
select { select {
case <-done: case <-done:
@ -666,7 +666,7 @@ func (w *Workspace) getKeymaps() {
w.escKeyInNormal = mapping.LHS w.escKeyInNormal = mapping.LHS
} }
} }
if strings.EqualFold(mapping.LHS, "<C-y>") || strings.EqualFold(mapping.LHS, "<C-e>"){ if strings.EqualFold(mapping.LHS, "<C-y>") || strings.EqualFold(mapping.LHS, "<C-e>") {
w.isMappingScrollKey = true w.isMappingScrollKey = true
} }
// Count user def alt/meta key mappings // Count user def alt/meta key mappings
@ -692,7 +692,7 @@ func (w *Workspace) getNumOfTabs() int {
num := 0 num := 0
go func() { go func() {
w.nvim.Eval("tabpagenr('$')", &num) w.nvim.Eval("tabpagenr('$')", &num)
done <-true done <- true
}() }()
select { select {
case <-done: case <-done:
@ -719,23 +719,23 @@ func (w *Workspace) nvimEval(s string) (interface{}, error) {
} }
func (w *Workspace) handleChangeCwd(cwdinfo map[string]interface{}) { func (w *Workspace) handleChangeCwd(cwdinfo map[string]interface{}) {
scope, ok := cwdinfo["scope"] scope, ok := cwdinfo["scope"]
if !ok { if !ok {
scope = "global" scope = "global"
} }
cwdITF, ok := cwdinfo["cwd"] cwdITF, ok := cwdinfo["cwd"]
if !ok { if !ok {
return return
} }
cwd := cwdITF.(string) cwd := cwdITF.(string)
switch scope { switch scope {
case "global" : case "global":
w.setCwd(cwd) w.setCwd(cwd)
case "tab" : case "tab":
w.setCwdInTab(cwd) w.setCwdInTab(cwd)
case "window" : case "window":
w.setCwdInWin(cwd) w.setCwdInWin(cwd)
} }
} }
func (w *Workspace) setCwd(cwd string) { func (w *Workspace) setCwd(cwd string) {
@ -1368,8 +1368,8 @@ func (w *Workspace) getPos() {
} }
w.curPosMutex.Lock() w.curPosMutex.Lock()
w.curLine = curPos[1] w.curLine = curPos[1]
w.curColm = curPos[2] w.curColm = curPos[2]
w.curPosMutex.Unlock() w.curPosMutex.Unlock()
} }
@ -1482,7 +1482,7 @@ func (w *Workspace) handleRPCGui(updates []interface{}) {
case "gonvim_workspace_switch": case "gonvim_workspace_switch":
editor.workspaceSwitch(util.ReflectToInt(updates[1])) editor.workspaceSwitch(util.ReflectToInt(updates[1]))
case "gonvim_workspace_cwd": case "gonvim_workspace_cwd":
cwdinfo :=updates[1].(map[string]interface{}) cwdinfo := updates[1].(map[string]interface{})
w.handleChangeCwd(cwdinfo) w.handleChangeCwd(cwdinfo)
case "gonvim_workspace_filepath": case "gonvim_workspace_filepath":
w.minimap.mu.Lock() w.minimap.mu.Lock()
@ -1688,7 +1688,7 @@ func getFontFamilyAndHeightAndWeightAndStretch(s string) (string, float64, gui.Q
if height <= 1.0 && width <= 0 { if height <= 1.0 && width <= 0 {
height = 12 height = 12
width = 6 width = 6
} else if height > 1.0 && width == -1.0 { } else if height > 1.0 && width == -1.0 {
width = height / 2.0 width = height / 2.0
} else if height <= 1.0 && width >= 1.0 { } else if height <= 1.0 && width >= 1.0 {
@ -1825,7 +1825,7 @@ func (w *Workspace) getPumHeight() {
errCh := make(chan error, 60) errCh := make(chan error, 60)
go func() { go func() {
err := w.nvim.Option("pumheight", &ph) err := w.nvim.Option("pumheight", &ph)
errCh <-err errCh <- err
}() }()
select { select {
case <-errCh: case <-errCh:
@ -1882,7 +1882,6 @@ func (w *Workspace) getFileType(args []interface{}) {
} }
func (w *Workspace) getWinblendAll() { func (w *Workspace) getWinblendAll() {
w.screen.windows.Range(func(_, winITF interface{}) bool { w.screen.windows.Range(func(_, winITF interface{}) bool {
win := winITF.(*Window) win := winITF.(*Window)
@ -1966,7 +1965,7 @@ type WorkspaceSide struct {
header *widgets.QLabel header *widgets.QLabel
items []*WorkspaceSideItem items []*WorkspaceSideItem
isShown bool isShown bool
isInitResize bool isInitResize bool
} }
@ -2054,7 +2053,7 @@ func (side *WorkspaceSide) show() {
if !side.isInitResize { if !side.isInitResize {
editor.splitter.SetSizes( editor.splitter.SetSizes(
[]int{editor.config.SideBar.Width, []int{editor.config.SideBar.Width,
editor.width - editor.config.SideBar.Width}, editor.width - editor.config.SideBar.Width},
) )
side.isInitResize = true side.isInitResize = true
} }