library/cmd/cli/events.go

114 lines
1.8 KiB
Go
Raw Normal View History

2021-07-29 01:36:45 +00:00
package main
import (
2022-03-05 15:58:15 +00:00
"git.yetaga.in/alazyreader/library/media"
2023-04-08 02:42:54 +00:00
"github.com/gdamore/tcell/v2"
2021-07-29 01:36:45 +00:00
)
2021-08-01 22:50:53 +00:00
// error message
type EventError struct {
tcell.EventTime
err error
}
func NewEventError(err error) *EventError {
e := &EventError{err: err}
e.SetEventNow()
return e
}
2021-07-29 01:36:45 +00:00
// save change to book
type EventBookUpdate struct {
tcell.EventTime
2022-03-05 15:58:15 +00:00
book *media.Book
2021-07-29 01:36:45 +00:00
}
2022-03-05 15:58:15 +00:00
func NewEventBookUpdate(b *media.Book) *EventBookUpdate {
2021-07-29 01:36:45 +00:00
e := &EventBookUpdate{book: b}
e.SetEventNow()
return e
}
2022-03-05 15:58:15 +00:00
func (e *EventBookUpdate) Book() *media.Book {
2021-07-29 01:36:45 +00:00
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
}
2021-08-01 22:50:53 +00:00
// 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
}
2021-07-29 01:36:45 +00:00
// 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
}