David Ashby
0a5cea9fb1
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
114 lines
1.8 KiB
Go
114 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"git.yetaga.in/alazyreader/library/media"
|
|
"github.com/gdamore/tcell/v2"
|
|
)
|
|
|
|
// error message
|
|
type EventError struct {
|
|
tcell.EventTime
|
|
err error
|
|
}
|
|
|
|
func NewEventError(err error) *EventError {
|
|
e := &EventError{err: err}
|
|
e.SetEventNow()
|
|
return e
|
|
}
|
|
|
|
// save change to book
|
|
type EventBookUpdate struct {
|
|
tcell.EventTime
|
|
book *media.Book
|
|
}
|
|
|
|
func NewEventBookUpdate(b *media.Book) *EventBookUpdate {
|
|
e := &EventBookUpdate{book: b}
|
|
e.SetEventNow()
|
|
return e
|
|
}
|
|
|
|
func (e *EventBookUpdate) Book() *media.Book {
|
|
return e.book
|
|
}
|
|
|
|
// open new book in display
|
|
type EventLoadBook struct {
|
|
tcell.EventTime
|
|
ID int
|
|
}
|
|
|
|
func NewEventLoadBook(id int) *EventLoadBook {
|
|
e := &EventLoadBook{ID: id}
|
|
e.SetEventNow()
|
|
return e
|
|
}
|
|
|
|
// open new book in display
|
|
type EventEnterBook struct {
|
|
tcell.EventTime
|
|
}
|
|
|
|
func NewEventEnterBook() *EventEnterBook {
|
|
e := &EventEnterBook{}
|
|
e.SetEventNow()
|
|
return e
|
|
}
|
|
|
|
// switch back to menu control
|
|
type EventExitBook struct {
|
|
tcell.EventTime
|
|
}
|
|
|
|
func NewEventExitBook() *EventExitBook {
|
|
e := &EventExitBook{}
|
|
e.SetEventNow()
|
|
return e
|
|
}
|
|
|
|
// open import window
|
|
type EventOpenImport struct {
|
|
tcell.EventTime
|
|
}
|
|
|
|
func NewEventOpenImport() *EventOpenImport {
|
|
e := &EventOpenImport{}
|
|
e.SetEventNow()
|
|
return e
|
|
}
|
|
|
|
// attempt to import given filename.csv
|
|
type EventAttemptImport struct {
|
|
tcell.EventTime
|
|
filename string
|
|
}
|
|
|
|
func NewEventAttemptImport(f string) *EventAttemptImport {
|
|
e := &EventAttemptImport{filename: f}
|
|
e.SetEventNow()
|
|
return e
|
|
}
|
|
|
|
// close import window
|
|
type EventCloseImport struct {
|
|
tcell.EventTime
|
|
}
|
|
|
|
func NewEventCloseImport() *EventCloseImport {
|
|
e := &EventCloseImport{}
|
|
e.SetEventNow()
|
|
return e
|
|
}
|
|
|
|
// quit
|
|
type EventQuit struct {
|
|
tcell.EventTime
|
|
}
|
|
|
|
func NewEventQuit() *EventQuit {
|
|
e := &EventQuit{}
|
|
e.SetEventNow()
|
|
return e
|
|
}
|