ui

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColorScheme

type ColorScheme int

ColorScheme represents a color scheme

const (
	// DefaultColorScheme is the default color scheme
	DefaultColorScheme ColorScheme = iota
	// DarkColorScheme is the dark color scheme
	DarkColorScheme
	// LightColorScheme is the light color scheme
	LightColorScheme
)

type UI

type UI struct {
	App           *tview.Application
	Container     *tview.Flex
	Horizontal    *tview.Flex
	Content       *tview.Flex
	LeftPanel     *tview.Box
	RightPanel    *tview.Box
	TextArea      *tview.TextView
	StatusBar     *tview.TextView
	SearchInput   *tview.InputField // VIM style search input
	ColorScheme   ColorScheme
	Width         int
	JumpList      map[rune][4]interface{} // [index, width, pos, pctg]
	SearchPattern string
	Images        []string                            // Images in the current chapter
	IsSearchMode  bool                                // Mark if the search mode is active
	CountPrefix   int                                 // Numeric prefix for commands like [count]=
	ReadChapter   func(index int, pctg float64) error // Chapter to jump to
}

UI represents the user interface

func NewUI

func NewUI() *UI

NewUI creates a new UI instance

func (*UI) CycleColorScheme

func (ui *UI) CycleColorScheme()

CycleColorScheme cycles through the color schemes

func (*UI) OpenImage

func (ui *UI) OpenImage(imagePath string) error

OpenImage opens an image using the default image viewer

func (*UI) ReRender

func (ui *UI) ReRender()

func (*UI) SelectImage

func (ui *UI) SelectImage(images []string, startLine int, endLine int) (string, error)

SelectImage shows a dialog to select an image

func (*UI) SetCapture

func (ui *UI) SetCapture(f func(event *tcell.EventKey) *tcell.EventKey) func()

SetCapture sets the input capture function return a function to restore the original input capture

func (*UI) SetColorScheme

func (ui *UI) SetColorScheme(scheme ColorScheme)

SetColorScheme sets the color scheme

func (*UI) SetStatus

func (ui *UI) SetStatus(text string)

SetStatus sets the status bar text

func (*UI) SetTempContent

func (ui *UI) SetTempContent(view tview.Primitive) func()

SetTempContent sets a temporary content

func (*UI) SetTempStatus

func (ui *UI) SetTempStatus(views ...tview.Primitive) func()

Make text display a norm for the Status Bar This method is used to set a temporary new Status Bar It will return a restoration method

func (*UI) SetWidth

func (ui *UI) SetWidth(width int)

SetWidth this func actually sets the width of the goread window

func (*UI) ShowHelp

func (ui *UI) ShowHelp() error

ShowHelp shows the help screen

func (*UI) ShowImageSelect

func (ui *UI) ShowImageSelect(images []string, callback func(string)) error

ShowImageSelect shows an input dialog for selecting an image by number

func (*UI) ShowMetadata

func (ui *UI) ShowMetadata(metadata [][]string) error

ShowMetadata shows the metadata

func (*UI) ShowSearch

func (ui *UI) ShowSearch(cb func()) error

ShowSearch shows the search dialog in VIM style

Jump to

Keyboard shortcuts

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