Apply gofmt

This commit is contained in:
Drew DeVault 2018-06-11 20:04:21 -04:00
parent d67c8a60ef
commit 6728a11fdf
6 changed files with 17 additions and 17 deletions

View file

@ -3,9 +3,9 @@ package ui
import (
"fmt"
"github.com/mattn/go-runewidth"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/views"
"github.com/mattn/go-runewidth"
)
// A context allows you to draw in a sub-region of the terminal
@ -40,10 +40,10 @@ func NewContext(width, height int, screen tcell.Screen) *Context {
func (ctx *Context) Subcontext(x, y, width, height int) *Context {
vp_width, vp_height := ctx.viewport.Size()
if (x < 0 || y < 0) {
if x < 0 || y < 0 {
panic(fmt.Errorf("Attempted to create context with negative offset"))
}
if (x + width > vp_width || y + height > vp_height) {
if x+width > vp_width || y+height > vp_height {
panic(fmt.Errorf("Attempted to create context larger than parent"))
}
vp := views.NewViewPort(ctx.viewport, x, y, width, height)
@ -88,7 +88,7 @@ func (ctx *Context) Printf(x, y int, style tcell.Style,
crunes := []rune{}
ctx.viewport.SetContent(x, y, ch, crunes, style)
x += runewidth.RuneWidth(ch)
if x == old_x + width {
if x == old_x+width {
if !newline() {
return runewidth.StringWidth(str)
}

View file

@ -7,7 +7,7 @@ import (
)
type Stack struct {
children []Drawable
children []Drawable
onInvalidate []func(d Drawable)
}
@ -15,7 +15,7 @@ func NewStack() *Stack {
return &Stack{}
}
func (stack *Stack) OnInvalidate(onInvalidate func (d Drawable)) {
func (stack *Stack) OnInvalidate(onInvalidate func(d Drawable)) {
stack.onInvalidate = append(stack.onInvalidate, onInvalidate)
}

View file

@ -1,8 +1,8 @@
package ui
import (
"github.com/mattn/go-runewidth"
"github.com/gdamore/tcell"
"github.com/mattn/go-runewidth"
)
const (

View file

@ -69,10 +69,10 @@ func NewAerc(logger *log.Logger) *Aerc {
})()
return &Aerc{
grid: mainGrid,
statusbar: statusbar,
statusline: statusline,
tabs: tabs,
grid: mainGrid,
statusbar: statusbar,
statusline: statusline,
tabs: tabs,
}
}
@ -94,7 +94,7 @@ func (aerc *Aerc) Event(event tcell.Event) bool {
if event.Rune() == ':' {
exline := NewExLine(func(command string) {
aerc.statusline.Push(fmt.Sprintf("TODO: execute %s", command),
3 * time.Second)
3*time.Second)
aerc.statusbar.Pop()
aerc.interactive = nil
}, func() {

View file

@ -1,8 +1,8 @@
package widgets
import (
"github.com/mattn/go-runewidth"
"github.com/gdamore/tcell"
"github.com/mattn/go-runewidth"
"git.sr.ht/~sircmpwn/aerc2/lib/ui"
)
@ -21,7 +21,7 @@ type ExLine struct {
onInvalidate func(d ui.Drawable)
}
func NewExLine(commit func (cmd string), cancel func()) *ExLine {
func NewExLine(commit func(cmd string), cancel func()) *ExLine {
return &ExLine{
cancel: cancel,
commit: commit,
@ -43,7 +43,7 @@ func (ex *ExLine) Draw(ctx *ui.Context) {
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
ctx.Printf(0, 0, tcell.StyleDefault, ":%s", string(ex.command))
cells := runewidth.StringWidth(string(ex.command[:ex.index]))
ctx.SetCursor(cells + 1, 0)
ctx.SetCursor(cells+1, 0)
}
func (ex *ExLine) insert(ch rune) {

View file

@ -31,7 +31,7 @@ func NewStatusLine() *StatusLine {
}
}
func (status *StatusLine) OnInvalidate(onInvalidate func (d ui.Drawable)) {
func (status *StatusLine) OnInvalidate(onInvalidate func(d ui.Drawable)) {
status.onInvalidate = onInvalidate
}
@ -68,7 +68,7 @@ func (status *StatusLine) Push(text string, expiry time.Duration) *StatusMessage
message: text,
}
status.stack = append(status.stack, msg)
go (func () {
go (func() {
time.Sleep(expiry)
for i, m := range status.stack {
if m == msg {