Apply gofmt
This commit is contained in:
parent
d67c8a60ef
commit
6728a11fdf
|
@ -3,9 +3,9 @@ package ui
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/mattn/go-runewidth"
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
"github.com/gdamore/tcell/views"
|
"github.com/gdamore/tcell/views"
|
||||||
|
"github.com/mattn/go-runewidth"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A context allows you to draw in a sub-region of the terminal
|
// 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 {
|
func (ctx *Context) Subcontext(x, y, width, height int) *Context {
|
||||||
vp_width, vp_height := ctx.viewport.Size()
|
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"))
|
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"))
|
panic(fmt.Errorf("Attempted to create context larger than parent"))
|
||||||
}
|
}
|
||||||
vp := views.NewViewPort(ctx.viewport, x, y, width, height)
|
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{}
|
crunes := []rune{}
|
||||||
ctx.viewport.SetContent(x, y, ch, crunes, style)
|
ctx.viewport.SetContent(x, y, ch, crunes, style)
|
||||||
x += runewidth.RuneWidth(ch)
|
x += runewidth.RuneWidth(ch)
|
||||||
if x == old_x + width {
|
if x == old_x+width {
|
||||||
if !newline() {
|
if !newline() {
|
||||||
return runewidth.StringWidth(str)
|
return runewidth.StringWidth(str)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Stack struct {
|
type Stack struct {
|
||||||
children []Drawable
|
children []Drawable
|
||||||
onInvalidate []func(d Drawable)
|
onInvalidate []func(d Drawable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ func NewStack() *Stack {
|
||||||
return &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)
|
stack.onInvalidate = append(stack.onInvalidate, onInvalidate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mattn/go-runewidth"
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
|
"github.com/mattn/go-runewidth"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -69,10 +69,10 @@ func NewAerc(logger *log.Logger) *Aerc {
|
||||||
})()
|
})()
|
||||||
|
|
||||||
return &Aerc{
|
return &Aerc{
|
||||||
grid: mainGrid,
|
grid: mainGrid,
|
||||||
statusbar: statusbar,
|
statusbar: statusbar,
|
||||||
statusline: statusline,
|
statusline: statusline,
|
||||||
tabs: tabs,
|
tabs: tabs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ func (aerc *Aerc) Event(event tcell.Event) bool {
|
||||||
if event.Rune() == ':' {
|
if event.Rune() == ':' {
|
||||||
exline := NewExLine(func(command string) {
|
exline := NewExLine(func(command string) {
|
||||||
aerc.statusline.Push(fmt.Sprintf("TODO: execute %s", command),
|
aerc.statusline.Push(fmt.Sprintf("TODO: execute %s", command),
|
||||||
3 * time.Second)
|
3*time.Second)
|
||||||
aerc.statusbar.Pop()
|
aerc.statusbar.Pop()
|
||||||
aerc.interactive = nil
|
aerc.interactive = nil
|
||||||
}, func() {
|
}, func() {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package widgets
|
package widgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mattn/go-runewidth"
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
|
"github.com/mattn/go-runewidth"
|
||||||
|
|
||||||
"git.sr.ht/~sircmpwn/aerc2/lib/ui"
|
"git.sr.ht/~sircmpwn/aerc2/lib/ui"
|
||||||
)
|
)
|
||||||
|
@ -21,7 +21,7 @@ type ExLine struct {
|
||||||
onInvalidate func(d ui.Drawable)
|
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{
|
return &ExLine{
|
||||||
cancel: cancel,
|
cancel: cancel,
|
||||||
commit: commit,
|
commit: commit,
|
||||||
|
@ -43,7 +43,7 @@ func (ex *ExLine) Draw(ctx *ui.Context) {
|
||||||
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
|
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
|
||||||
ctx.Printf(0, 0, tcell.StyleDefault, ":%s", string(ex.command))
|
ctx.Printf(0, 0, tcell.StyleDefault, ":%s", string(ex.command))
|
||||||
cells := runewidth.StringWidth(string(ex.command[:ex.index]))
|
cells := runewidth.StringWidth(string(ex.command[:ex.index]))
|
||||||
ctx.SetCursor(cells + 1, 0)
|
ctx.SetCursor(cells+1, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ex *ExLine) insert(ch rune) {
|
func (ex *ExLine) insert(ch rune) {
|
||||||
|
|
|
@ -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
|
status.onInvalidate = onInvalidate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ func (status *StatusLine) Push(text string, expiry time.Duration) *StatusMessage
|
||||||
message: text,
|
message: text,
|
||||||
}
|
}
|
||||||
status.stack = append(status.stack, msg)
|
status.stack = append(status.stack, msg)
|
||||||
go (func () {
|
go (func() {
|
||||||
time.Sleep(expiry)
|
time.Sleep(expiry)
|
||||||
for i, m := range status.stack {
|
for i, m := range status.stack {
|
||||||
if m == msg {
|
if m == msg {
|
||||||
|
|
Loading…
Reference in New Issue