finish upgrade
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2023-04-07 22:42:54 -04:00
parent 2118e8b790
commit 0a5cea9fb1
7 changed files with 47 additions and 33 deletions

View File

@@ -3,7 +3,7 @@ package ui
import (
"fmt"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
type coord struct {
@@ -38,8 +38,18 @@ func (m *MockScreen) SetContent(x int, y int, mainc rune, combc []rune, style tc
m.content[coord{x, y}] = mainc
}
func (m *MockScreen) Suspend() error {
return nil
}
func (m *MockScreen) Resume() error {
return nil
}
func (m *MockScreen) SetStyle(style tcell.Style) {}
func (m *MockScreen) SetCursorStyle(style tcell.CursorStyle) {}
func (m *MockScreen) ShowCursor(x int, y int) {}
func (m *MockScreen) HideCursor() {}
@@ -52,16 +62,26 @@ func (m *MockScreen) PollEvent() tcell.Event {
return tcell.NewEventError(fmt.Errorf("mock error"))
}
func (m *MockScreen) ChannelEvents(ch chan<- tcell.Event, quit <-chan struct{}) {}
func (m *MockScreen) HasPendingEvent() bool {
return false
}
func (m *MockScreen) PostEvent(ev tcell.Event) error {
return nil
}
func (m *MockScreen) PostEventWait(ev tcell.Event) {}
func (m *MockScreen) EnableMouse() {}
func (m *MockScreen) EnableMouse(...tcell.MouseFlags) {}
func (m *MockScreen) DisableMouse() {}
func (m *MockScreen) EnablePaste() {}
func (m *MockScreen) DisablePaste() {}
func (m *MockScreen) HasMouse() bool {
return false
}
@@ -90,6 +110,10 @@ func (m *MockScreen) Resize(x, y, h, w int) {
m.x, m.y, m.h, m.w = x, y, h, w
}
func (m *MockScreen) SetSize(h, w int) {
m.h, m.w = h, w
}
func (m *MockScreen) HasKey(tcell.Key) bool {
return true
}

View File

@@ -5,7 +5,7 @@ import (
"strings"
"git.yetaga.in/alazyreader/library/media"
"github.com/gdamore/tcell"
"github.com/gdamore/tcell/v2"
)
type Drawable interface {
@@ -37,8 +37,8 @@ const (
)
var (
StyleActive = tcell.Style(0).Foreground(tcell.ColorWhite).Background(tcell.ColorBlack)
StyleInactive = tcell.Style(0).Foreground(tcell.ColorGray).Background(tcell.ColorBlack)
StyleActive = tcell.Style{}.Foreground(tcell.ColorWhite).Background(tcell.ColorBlack)
StyleInactive = tcell.Style{}.Foreground(tcell.ColorGray).Background(tcell.ColorBlack)
)
// A Container has no visible UI of its own, but arranges sub-components on the screen.

View File

@@ -3,6 +3,8 @@ package ui
import (
"fmt"
"testing"
"github.com/gdamore/tcell/v2"
)
func TestContainerOneBox(t *testing.T) {
@@ -13,7 +15,7 @@ func TestContainerOneBox(t *testing.T) {
└──────────────────┘
`
m := &MockScreen{}
one := NewBox("box one", nil, Contents{}, 0, false)
one := NewBox("box one", nil, Contents{}, tcell.Style{}, false)
container := NewContainer(
Contents{{Container: one}},
LayoutHorizontalEven,
@@ -38,8 +40,8 @@ func TestContainerTwoBoxesHStack(t *testing.T) {
└────────┘└────────┘
`
m := &MockScreen{}
one := NewBox("one", nil, Contents{}, 0, false)
two := NewBox("two", nil, Contents{}, 0, false)
one := NewBox("one", nil, Contents{}, tcell.Style{}, false)
two := NewBox("two", nil, Contents{}, tcell.Style{}, false)
container := NewContainer(
Contents{{Container: one}, {Container: two}},
LayoutHorizontalEven,
@@ -64,9 +66,9 @@ func TestContainerThreeBoxesUnevenHStack(t *testing.T) {
└────────┘└────────┘└───────┘
`
m := &MockScreen{}
one := NewBox("one", nil, Contents{}, 0, false)
two := NewBox("two", nil, Contents{}, 0, false)
three := NewBox("three", nil, Contents{}, 0, false)
one := NewBox("one", nil, Contents{}, tcell.Style{}, false)
two := NewBox("two", nil, Contents{}, tcell.Style{}, false)
three := NewBox("three", nil, Contents{}, tcell.Style{}, false)
container := NewContainer(
Contents{{Container: one}, {Container: two}, {Container: three}},
LayoutHorizontalEven,
@@ -91,8 +93,8 @@ func TestContainerTwoBoxesHPercentStack(t *testing.T) {
└────────────┘└──────┘
`
m := &MockScreen{}
one := NewBox("one", nil, Contents{}, 0, false)
two := NewBox("two", nil, Contents{}, 0, false)
one := NewBox("one", nil, Contents{}, tcell.Style{}, false)
two := NewBox("two", nil, Contents{}, tcell.Style{}, false)
container := NewContainer(
Contents{
{Container: one, Offsets: Offsets{Percent: 2}},
@@ -124,8 +126,8 @@ func TestContainerTwoBoxesVStack(t *testing.T) {
└────────┘
`
m := &MockScreen{}
one := NewBox("one", nil, Contents{}, 0, false)
two := NewBox("two", nil, Contents{}, 0, false)
one := NewBox("one", nil, Contents{}, tcell.Style{}, false)
two := NewBox("two", nil, Contents{}, tcell.Style{}, false)
container := NewContainer(
Contents{{Container: one}, {Container: two}},
LayoutVerticalEven,
@@ -155,8 +157,8 @@ func TestContainerTwoBoxesPercentageVStack(t *testing.T) {
└────────┘
`
m := &MockScreen{}
one := NewBox("one", nil, Contents{}, 0, false)
two := NewBox("two", nil, Contents{}, 0, false)
one := NewBox("one", nil, Contents{}, tcell.Style{}, false)
two := NewBox("two", nil, Contents{}, tcell.Style{}, false)
container := NewContainer(
Contents{
{Container: one, Offsets: Offsets{Percent: 2}},