Help us shape the future of Go! Take the 2026 Go Developer Survey

reader

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindChapterIndexByTitle

func FindChapterIndexByTitle(r Reader, title string) int

func RestoreFromAnchor

func RestoreFromAnchor(r Reader, anchor ProgressAnchor)

Types

type EpubReader

type EpubReader struct {
	// contains filtered or unexported fields
}

func NewEpubReader

func NewEpubReader() *EpubReader

func (*EpubReader) BookTitle

func (epub *EpubReader) BookTitle() string

func (*EpubReader) Current

func (r *EpubReader) Current() string

func (*EpubReader) CurrentChapterIndex

func (epub *EpubReader) CurrentChapterIndex() int

func (*EpubReader) CurrentChapterTitle

func (epub *EpubReader) CurrentChapterTitle() string

func (*EpubReader) CurrentPos

func (r *EpubReader) CurrentPos() int

func (*EpubReader) CurrentView

func (r *EpubReader) CurrentView(lines int) string

func (*EpubReader) First

func (r *EpubReader) First() string

func (*EpubReader) GetProgress

func (epub *EpubReader) GetProgress() string

func (*EpubReader) GetTOC

func (epub *EpubReader) GetTOC() string

func (*EpubReader) GetTOCWithSelection

func (epub *EpubReader) GetTOCWithSelection(selected, pageSize int) string

func (*EpubReader) Goto

func (r *EpubReader) Goto(pos int) string

func (*EpubReader) GotoChapter

func (epub *EpubReader) GotoChapter(index int) string

func (*EpubReader) Last

func (r *EpubReader) Last() string

func (*EpubReader) Load

func (epub *EpubReader) Load(filePath string) error

func (*EpubReader) Next

func (r *EpubReader) Next() string

func (*EpubReader) NextChapter

func (epub *EpubReader) NextChapter() string

func (*EpubReader) Prev

func (r *EpubReader) Prev() string

func (*EpubReader) PrevChapter

func (epub *EpubReader) PrevChapter() string

func (*EpubReader) Reflow

func (epub *EpubReader) Reflow(width int)

func (*EpubReader) Search

func (r *EpubReader) Search(query string, start int, forward bool) (int, bool)

func (*EpubReader) Total

func (r *EpubReader) Total() int

type OnlineReader added in v0.4.0

type OnlineReader struct {
	Book     booksource.Book
	Chapters []booksource.Chapter
	Index    int
	// contains filtered or unexported fields
}

OnlineReader holds one downloaded chapter. Networking is performed by the UI controller, outside the render/input loop, before installing a new chapter.

func NewOnlineReader added in v0.4.0

func NewOnlineReader(book booksource.Book, chapters []booksource.Chapter, index int, text string) *OnlineReader

func (*OnlineReader) BookTitle added in v0.4.0

func (r *OnlineReader) BookTitle() string

func (*OnlineReader) ChapterOffset added in v0.4.0

func (r *OnlineReader) ChapterOffset() float64

func (*OnlineReader) ChapterTitle added in v0.4.0

func (r *OnlineReader) ChapterTitle(index int) string

func (*OnlineReader) Current added in v0.4.0

func (r *OnlineReader) Current() string

func (*OnlineReader) CurrentChapterIndex added in v0.4.0

func (r *OnlineReader) CurrentChapterIndex() int

func (*OnlineReader) CurrentChapterTitle added in v0.4.0

func (r *OnlineReader) CurrentChapterTitle() string

func (*OnlineReader) CurrentPos added in v0.4.0

func (r *OnlineReader) CurrentPos() int

func (*OnlineReader) CurrentView added in v0.4.0

func (r *OnlineReader) CurrentView(lines int) string

func (*OnlineReader) First added in v0.4.0

func (r *OnlineReader) First() string

func (*OnlineReader) GetProgress added in v0.4.0

func (r *OnlineReader) GetProgress() string

func (*OnlineReader) GetTOC added in v0.4.0

func (r *OnlineReader) GetTOC() string

func (*OnlineReader) GetTOCWithSelection added in v0.4.0

func (r *OnlineReader) GetTOCWithSelection(selected, pageSize int) string

func (*OnlineReader) Goto added in v0.4.0

func (r *OnlineReader) Goto(pos int) string

func (*OnlineReader) GotoChapter added in v0.4.0

func (r *OnlineReader) GotoChapter(index int) string

func (*OnlineReader) Last added in v0.4.0

func (r *OnlineReader) Last() string

func (*OnlineReader) Load added in v0.4.0

func (r *OnlineReader) Load(string) error

func (*OnlineReader) Next added in v0.4.0

func (r *OnlineReader) Next() string

func (*OnlineReader) NextChapter added in v0.4.0

func (r *OnlineReader) NextChapter() string

func (*OnlineReader) OverallProgress added in v0.4.0

func (r *OnlineReader) OverallProgress() float64

Progress is based on chapter index plus progress within the current chapter.

func (*OnlineReader) Prev added in v0.4.0

func (r *OnlineReader) Prev() string

func (*OnlineReader) PrevChapter added in v0.4.0

func (r *OnlineReader) PrevChapter() string

func (*OnlineReader) Reflow added in v0.4.0

func (r *OnlineReader) Reflow(width int)

func (*OnlineReader) RestoreOffset added in v0.4.0

func (r *OnlineReader) RestoreOffset(offset float64)

func (*OnlineReader) Search added in v0.4.0

func (r *OnlineReader) Search(query string, start int, forward bool) (int, bool)

func (*OnlineReader) SetDisplayTitles added in v0.4.0

func (r *OnlineReader) SetDisplayTitles(titles []string)

Display titles can be purified without altering the source metadata used for requests, matching, and the original chapter cache.

func (*OnlineReader) Total added in v0.4.0

func (r *OnlineReader) Total() int

type ProgressAnchor

type ProgressAnchor struct {
	Pos           int
	ChapterIndex  int
	ChapterOffset float64
	OverallRatio  float64
}

func AnchorFromReader

func AnchorFromReader(r Reader) ProgressAnchor

type Reader

type Reader interface {
	Load(path string) error
	Reflow(width int)
	BookTitle() string
	Current() string
	CurrentView(lines int) string
	Total() int
	Search(query string, start int, forward bool) (int, bool)
	Next() string
	Prev() string
	First() string
	Last() string
	CurrentPos() int
	Goto(pos int) string
	GetProgress() string
	CurrentChapterTitle() string
	CurrentChapterIndex() int
	NextChapter() string
	PrevChapter() string
	GetTOC() string
	GetTOCWithSelection(selected, pageSize int) string
	GotoChapter(index int) string
}

func ReaderFromSnapshot

func ReaderFromSnapshot(snapshot Snapshot, width int) (Reader, error)

type Snapshot

type Snapshot struct {
	Kind          string   `json:"kind"`
	Title         string   `json:"title,omitempty"`
	RawText       string   `json:"raw_text,omitempty"`
	ChapterText   []string `json:"chapter_text,omitempty"`
	ChapterTitles []string `json:"chapter_titles,omitempty"`
}

func SnapshotFromReader

func SnapshotFromReader(r Reader) (*Snapshot, bool)

type TxtReader

type TxtReader struct {
	// contains filtered or unexported fields
}

func NewTxtReader

func NewTxtReader() *TxtReader

func (*TxtReader) BookTitle

func (txt *TxtReader) BookTitle() string

func (*TxtReader) Current

func (r *TxtReader) Current() string

func (*TxtReader) CurrentChapterIndex

func (txt *TxtReader) CurrentChapterIndex() int

func (*TxtReader) CurrentChapterTitle

func (txt *TxtReader) CurrentChapterTitle() string

func (*TxtReader) CurrentPos

func (r *TxtReader) CurrentPos() int

func (*TxtReader) CurrentView

func (r *TxtReader) CurrentView(lines int) string

func (*TxtReader) First

func (r *TxtReader) First() string

func (*TxtReader) GetProgress

func (r *TxtReader) GetProgress() string

func (*TxtReader) GetTOC

func (txt *TxtReader) GetTOC() string

func (*TxtReader) GetTOCWithSelection

func (txt *TxtReader) GetTOCWithSelection(selected, pageSize int) string

func (*TxtReader) Goto

func (r *TxtReader) Goto(pos int) string

func (*TxtReader) GotoChapter

func (txt *TxtReader) GotoChapter(index int) string

func (*TxtReader) Last

func (r *TxtReader) Last() string

func (*TxtReader) Load

func (txt *TxtReader) Load(path string) error

func (*TxtReader) Next

func (r *TxtReader) Next() string

func (*TxtReader) NextChapter

func (txt *TxtReader) NextChapter() string

func (*TxtReader) Prev

func (r *TxtReader) Prev() string

func (*TxtReader) PrevChapter

func (txt *TxtReader) PrevChapter() string

func (*TxtReader) Reflow

func (txt *TxtReader) Reflow(width int)

func (*TxtReader) Search

func (r *TxtReader) Search(query string, start int, forward bool) (int, bool)

func (*TxtReader) Total

func (r *TxtReader) Total() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL