management server listener (#17)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: #17 Co-authored-by: David Ashby <delta.mu.alpha@gmail.com> Co-committed-by: David Ashby <delta.mu.alpha@gmail.com>
This commit is contained in:
113
cmd/cli/events.go
Normal file
113
cmd/cli/events.go
Normal file
@@ -0,0 +1,113 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user