diff --git a/editor/cursor.go b/editor/cursor.go index b901d61..9db582c 100644 --- a/editor/cursor.go +++ b/editor/cursor.go @@ -12,8 +12,8 @@ import ( // Cursor is type Cursor struct { - ws *Workspace - widget *widgets.QWidget + ws *Workspace + widget *widgets.QWidget // widget *widgets.QLabel mode string modeIdx int diff --git a/editor/editor.go b/editor/editor.go index b2ef9fe..098b2cd 100644 --- a/editor/editor.go +++ b/editor/editor.go @@ -94,13 +94,13 @@ type Editor struct { notify chan *Notify cbChan chan *string - workspaces []*Workspace - active int - window *frameless.QFramelessWindow - splitter *widgets.QSplitter - wsWidget *widgets.QWidget - wsSide *WorkspaceSide - sysTray *widgets.QSystemTrayIcon + workspaces []*Workspace + active int + window *frameless.QFramelessWindow + splitter *widgets.QSplitter + wsWidget *widgets.QWidget + wsSide *WorkspaceSide + sysTray *widgets.QSystemTrayIcon width int height int @@ -189,16 +189,16 @@ func InitEditor() { } editor = &Editor{ - version: GONEOVIMVERSION, - signal: NewEditorSignal(nil), - stop: make(chan struct{}), - notify: make(chan *Notify, 10), - cbChan: make(chan *string, 240), - config: newGonvimConfig(configDir), - homeDir: home, - configDir: configDir, - args: args, - opts: opts, + version: GONEOVIMVERSION, + signal: NewEditorSignal(nil), + stop: make(chan struct{}), + notify: make(chan *Notify, 10), + cbChan: make(chan *string, 240), + config: newGonvimConfig(configDir), + homeDir: home, + configDir: configDir, + args: args, + opts: opts, } e := editor @@ -805,14 +805,14 @@ func (e *Editor) convertKey(event *gui.QKeyEvent) string { c := "" if text == "" { - if key == int(core.Qt__Key_Alt ) || - key == int(core.Qt__Key_AltGr ) || - key == int(core.Qt__Key_CapsLock) || - key == int(core.Qt__Key_Control ) || - key == int(core.Qt__Key_Meta ) || - key == int(core.Qt__Key_Shift ) || - key == int(core.Qt__Key_Super_L ) || - key == int(core.Qt__Key_Super_R ) { + if key == int(core.Qt__Key_Alt) || + key == int(core.Qt__Key_AltGr) || + key == int(core.Qt__Key_CapsLock) || + key == int(core.Qt__Key_Control) || + key == int(core.Qt__Key_Meta) || + key == int(core.Qt__Key_Shift) || + key == int(core.Qt__Key_Super_L) || + key == int(core.Qt__Key_Super_R) { return "" } text = string(key) @@ -914,19 +914,19 @@ func (e *Editor) initSpecialKeys() { e.specialKeys[core.Qt__Key_F23] = "F23" e.specialKeys[core.Qt__Key_F24] = "F24" e.specialKeys[core.Qt__Key_Backspace] = "BS" - e.specialKeys[core.Qt__Key_Delete] = "Del" - e.specialKeys[core.Qt__Key_Insert] = "Insert" - e.specialKeys[core.Qt__Key_Home] = "Home" - e.specialKeys[core.Qt__Key_End] = "End" - e.specialKeys[core.Qt__Key_PageUp] = "PageUp" - e.specialKeys[core.Qt__Key_PageDown] = "PageDown" - e.specialKeys[core.Qt__Key_Return] = "Enter" - e.specialKeys[core.Qt__Key_Enter] = "Enter" - e.specialKeys[core.Qt__Key_Tab] = "Tab" - e.specialKeys[core.Qt__Key_Backtab] = "Tab" - e.specialKeys[core.Qt__Key_Escape] = "Esc" + e.specialKeys[core.Qt__Key_Delete] = "Del" + e.specialKeys[core.Qt__Key_Insert] = "Insert" + e.specialKeys[core.Qt__Key_Home] = "Home" + e.specialKeys[core.Qt__Key_End] = "End" + e.specialKeys[core.Qt__Key_PageUp] = "PageUp" + e.specialKeys[core.Qt__Key_PageDown] = "PageDown" + e.specialKeys[core.Qt__Key_Return] = "Enter" + e.specialKeys[core.Qt__Key_Enter] = "Enter" + e.specialKeys[core.Qt__Key_Tab] = "Tab" + e.specialKeys[core.Qt__Key_Backtab] = "Tab" + e.specialKeys[core.Qt__Key_Escape] = "Esc" e.specialKeys[core.Qt__Key_Backslash] = "Bslash" - e.specialKeys[core.Qt__Key_Space] = "Space" + e.specialKeys[core.Qt__Key_Space] = "Space" if runtime.GOOS == "darwin" { e.controlModifier = core.Qt__MetaModifier diff --git a/editor/markdown.go b/editor/markdown.go index a2e7c9d..d4d06b2 100644 --- a/editor/markdown.go +++ b/editor/markdown.go @@ -294,15 +294,15 @@ func (m *Markdown) toggle() { return } pipe := ` | ` - m.ws.nvim.Command(`keepalt vertical botright split ` + GonvimMarkdownBufName + pipe + - "setlocal filetype=" + GonvimMarkdownBufName + pipe + - "setlocal buftype=nofile" + pipe + - "setlocal bufhidden=hide" + pipe + - "setlocal noswapfile" + pipe + - "setlocal nobuflisted" + pipe + - "setlocal nomodifiable" + pipe + - "setlocal nolist" + pipe + - "setlocal nowrap") + m.ws.nvim.Command(`keepalt vertical botright split ` + GonvimMarkdownBufName + pipe + + "setlocal filetype=" + GonvimMarkdownBufName + pipe + + "setlocal buftype=nofile" + pipe + + "setlocal bufhidden=hide" + pipe + + "setlocal noswapfile" + pipe + + "setlocal nobuflisted" + pipe + + "setlocal nomodifiable" + pipe + + "setlocal nolist" + pipe + + "setlocal nowrap") m.ws.nvim.Command(fmt.Sprintf( "nnoremap j :call rpcnotify(0, 'Gui', '%s')", "gonvim_markdown_scroll_down", diff --git a/editor/screen.go b/editor/screen.go index 491128b..85b688e 100644 --- a/editor/screen.go +++ b/editor/screen.go @@ -693,7 +693,7 @@ func (w *Window) drawIndentguide(p *gui.QPainter, row, rows int) { doPaintIndent := false for mm := y; mm < len(w.content); mm++ { - if drawIndents[[2]int{x+1, mm}] { + if drawIndents[[2]int{x + 1, mm}] { continue } @@ -769,8 +769,8 @@ func (w *Window) drawIndentguide(p *gui.QPainter, row, rows int) { if !doPaintIndent { break } - if !drawIndents[[2]int{x+1, mm}] { - drawIndents[[2]int{x+1, mm}] = true + if !drawIndents[[2]int{x + 1, mm}] { + drawIndents[[2]int{x + 1, mm}] = true } } } @@ -780,20 +780,20 @@ func (w *Window) drawIndentguide(p *gui.QPainter, row, rows int) { // detect current block currentBlock := make(map[IntInt]bool) for x := w.s.cursor[1]; x >= 0; x-- { - if drawIndents[[2]int{x+1, w.s.cursor[0]}] { + if drawIndents[[2]int{x + 1, w.s.cursor[0]}] { for y := w.s.cursor[0]; y >= 0; y-- { - if drawIndents[[2]int{x+1, y}] { - currentBlock[[2]int{x+1, y}] = true + if drawIndents[[2]int{x + 1, y}] { + currentBlock[[2]int{x + 1, y}] = true } - if !drawIndents[[2]int{x+1, y}] { + if !drawIndents[[2]int{x + 1, y}] { break } } for y := w.s.cursor[0]; y < len(w.content); y++ { - if drawIndents[[2]int{x+1, y}] { - currentBlock[[2]int{x+1, y}] = true + if drawIndents[[2]int{x + 1, y}] { + currentBlock[[2]int{x + 1, y}] = true } - if !drawIndents[[2]int{x+1, y}] { + if !drawIndents[[2]int{x + 1, y}] { break } } @@ -805,10 +805,10 @@ func (w *Window) drawIndentguide(p *gui.QPainter, row, rows int) { // draw indent guide for y := row; y < len(w.content); y++ { for x := 0; x < w.maxLenContent; x++ { - if !drawIndents[[2]int{x+1, y}] { + if !drawIndents[[2]int{x + 1, y}] { continue } - if currentBlock[[2]int{x+1, y}] { + if currentBlock[[2]int{x + 1, y}] { w.drawIndentline(p, x+1, y, true) } else { w.drawIndentline(p, x+1, y, false) @@ -890,10 +890,10 @@ func (w *Window) drawFloatWindowBorder(p *gui.QPainter) { width := float64(w.widget.Width()) height := float64(w.widget.Height()) - left := core.NewQRectF4( 0, 0, 1, height) - top := core.NewQRectF4( 0, 0, width, 1) - right := core.NewQRectF4(width-1, 0, 1, height) - bottom := core.NewQRectF4( 0, height-1, width, 1) + left := core.NewQRectF4(0, 0, 1, height) + top := core.NewQRectF4(0, 0, width, 1) + right := core.NewQRectF4(width-1, 0, 1, height) + bottom := core.NewQRectF4(0, height-1, width, 1) p.FillRect4( left, @@ -2487,7 +2487,7 @@ func (w *Window) fillBackground(p *gui.QPainter, y int, col int, cols int) { bg = highlight.bg() - bounds := col+cols + bounds := col + cols if col+cols > len(line) { bounds = len(line) } @@ -2872,8 +2872,8 @@ func (w *Window) drawTextDecoration(p *gui.QPainter, y int, col int, cols int) { start := float64(x) * font.truewidth end := float64(x+1) * font.truewidth - space := float64(font.lineSpace)/3.0 - if space > font.ascent / 3.0 { + space := float64(font.lineSpace) / 3.0 + if space > font.ascent/3.0 { space = font.ascent / 3.0 } descent := float64(font.height) - font.ascent @@ -2912,7 +2912,7 @@ func (w *Window) drawTextDecoration(p *gui.QPainter, y int, col int, cols int) { } freq := 1.0 phase := 0.0 - Y := float64(y*font.lineHeight+w.scrollPixels[1]) + float64(font.ascent + descent*0.3) + float64(font.lineSpace/2) + space + Y := float64(y*font.lineHeight+w.scrollPixels[1]) + float64(font.ascent+descent*0.3) + float64(font.lineSpace/2) + space Y2 := Y + amplitude*math.Sin(0) point := core.NewQPointF3(start, Y2) path := gui.NewQPainterPath2(point) diff --git a/util/utils.go b/util/utils.go index 2db7775..a44c124 100644 --- a/util/utils.go +++ b/util/utils.go @@ -1,9 +1,9 @@ package util import ( - "strings" "os/user" "path/filepath" + "strings" "github.com/therecipe/qt/core" "github.com/therecipe/qt/gui" @@ -43,6 +43,7 @@ func ReflectToFloat(iface interface{}) float64 { } return 0 } + // IsZero determines if the value of interface{} is zero func IsZero(d interface{}) bool { if d == nil {