make it possible to switch between panels
This commit is contained in:
27
ui/ui.go
27
ui/ui.go
@@ -3,6 +3,7 @@ package ui
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.yetaga.in/alazyreader/library/book"
|
||||
"github.com/gdamore/tcell"
|
||||
)
|
||||
|
||||
@@ -266,6 +267,32 @@ func (l *List) ListMembers() []string {
|
||||
return l.listItems
|
||||
}
|
||||
|
||||
// A List is a scrollable, pageable list with a selector token.
|
||||
type BookDetails struct {
|
||||
x, y int
|
||||
h, w int
|
||||
selected int
|
||||
book book.Book
|
||||
}
|
||||
|
||||
func NewBookDetails() *BookDetails {
|
||||
return &BookDetails{}
|
||||
}
|
||||
|
||||
func (l *BookDetails) SetSize(x, y, h, w int) {
|
||||
l.x, l.y, l.h, l.w = x, y, h, w
|
||||
}
|
||||
|
||||
func (l *BookDetails) Draw(s tcell.Screen) {
|
||||
items := []string{"title", "authors", "isbn-10", "isbn-13"}
|
||||
for i := range items {
|
||||
for j, r := range items[i] {
|
||||
s.SetContent(l.x+j, l.y+i, r, nil, tcell.StyleDefault)
|
||||
}
|
||||
s.SetContent(l.x+len(items[i]), l.y+i, ':', nil, tcell.StyleDefault)
|
||||
}
|
||||
}
|
||||
|
||||
// PaddedText outputs strings with a space on both sides.
|
||||
// Useful for generating headings, footers, etc. Used by Box.
|
||||
type PaddedText struct {
|
||||
|
Reference in New Issue
Block a user