model

package
v0.0.0-...-8cb0cac Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SEP = "\n---\n" // sep of slides
)

Variables

View Source
var DefaultKeyMap = KeyMap{
	Help: key.NewBinding(
		key.WithKeys(k.Help),
		key.WithHelp(k.Help, "toggle help"),
	),
	Quit: key.NewBinding(
		key.WithKeys(k.Quit...),
		key.WithHelp(k.Quit[0], "quit"),
	),

	FirstSlide: key.NewBinding(
		key.WithKeys(k.Slide.First),
		key.WithHelp(k.Slide.First, "first slide"),
	),
	LastSlide: key.NewBinding(
		key.WithKeys(k.Slide.Last),
		key.WithHelp(k.Slide.Last, "last slide"),
	),
	NextSlide: key.NewBinding(
		key.WithKeys(k.Slide.Next...),
		key.WithHelp(k.Slide.Next[0], "next slide"),
	),
	PrevSlide: key.NewBinding(
		key.WithKeys(k.Slide.Prev...),
		key.WithHelp(k.Slide.Prev[0], "previous slide"),
	),

	MoveTop: key.NewBinding(
		key.WithKeys(k.Move.Top),
		key.WithHelp(k.Move.Top, "move to the top"),
	),
	MoveBottom: key.NewBinding(
		key.WithKeys(k.Move.Bottom),
		key.WithHelp(k.Move.Bottom, "move to the bottom"),
	),
	MoveUp: key.NewBinding(
		key.WithKeys(k.Move.Up...),
		key.WithHelp(k.Move.Up[0], "move up"),
	),
	MoveDown: key.NewBinding(
		key.WithKeys(k.Move.Down...),
		key.WithHelp(k.Move.Down[0], "move down"),
	),

	ScrollDown: key.NewBinding(
		key.WithKeys(k.Scroll.Down...),
		key.WithHelp(k.Scroll.Down[0], "scroll down"),
	),
	ScrollUp: key.NewBinding(
		key.WithKeys(k.Scroll.Up...),
		key.WithHelp(k.Scroll.Up[0], "scroll up"),
	),

	Search: key.NewBinding(
		key.WithKeys(k.Search.Forward),
		key.WithHelp(k.Search.Forward, "search forward"),
	),
	PrevSearched: key.NewBinding(
		key.WithKeys(k.Search.PrevMatch),
		key.WithHelp(k.Search.PrevMatch, "go to the previous match in the slides"),
	),
	NextSearched: key.NewBinding(
		key.WithKeys(k.Search.NextMatch),
		key.WithHelp(k.Search.NextMatch, "go to the next match in the slides"),
	),

	ToggleTagbar: key.NewBinding(
		key.WithKeys(k.Tagbar.Toggle),
		key.WithHelp(k.Tagbar.Toggle, "toggle tagbar"),
	),
}

Functions

This section is empty.

Types

type KeyMap

type KeyMap struct {
	Help key.Binding
	Quit key.Binding

	FirstSlide key.Binding
	LastSlide  key.Binding
	PrevSlide  key.Binding
	NextSlide  key.Binding

	MoveTop    key.Binding
	MoveBottom key.Binding
	MoveUp     key.Binding
	MoveDown   key.Binding

	ScrollDown key.Binding
	ScrollUp   key.Binding

	Search       key.Binding
	NextSearched key.Binding
	PrevSearched key.Binding

	ToggleTagbar key.Binding
}

Keymap represents the keymap configuration.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for the expanded help view. It's part of the key.Map interface.

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns keybindings to be shown in the mini help view. It's part of the key.Map interface.

type Model

type Model struct {

	// Filename is the markdown file to be loaded
	Filename string

	// Theme is the theme style for rendering markdown
	Theme string

	// Page is the current slide number
	Page int

	// Slide is the current slide content (converted to markdown)
	Slide string

	// Slides are all the slides in the markdown file
	Slides []string

	// TagBar is the tagbar configuration
	TagBar *TagBar

	// Search is the search input
	Search *Search
	// contains filtered or unexported fields
}

Model is the main model for the slides.

func (*Model) GetAllSlides

func (m *Model) GetAllSlides() []string

GetAllSlides returns all slides.

func (*Model) GetCurrentPage

func (m *Model) GetCurrentPage() int

GetCurrentSlide returns the current slide.

func (Model) Init

func (m Model) Init() tea.Cmd

func (*Model) Initial

func (m *Model) Initial() error

func (*Model) PageTotal

func (m *Model) PageTotal() int

PageTotal returns total count of slides.

func (*Model) Render

func (m *Model) Render() string

Render returns the rendered view of the model.

func (*Model) SetPage

func (m *Model) SetPage(page int)

Setpage sets the current page.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string
type Search struct {
	// IsActive indicates if search is active
	IsActive bool

	// TextInput is the search input
	TextInput textinput.Model

	// SearchResultsCache is the cache of search results
	SearchResultsCache []int

	// CurrentCachedIndex is the current index of the cache
	CurrentCachedIndex int
}

Search is the search model.

func NewSearch

func NewSearch() *Search

NewSearch creates a new search model.

func (*Search) Begin

func (s *Search) Begin()

Begin starts a new search (delete old buffers)

func (*Search) Done

func (s *Search) Done()

func (*Search) Execute

func (s *Search) Execute(m *Model)

func (*Search) Next

func (s *Search) Next(m *Model)

func (*Search) Previous

func (s *Search) Previous(m *Model)

func (*Search) Query

func (s *Search) Query() string

func (*Search) SetQuery

func (s *Search) SetQuery(query string)

type TagBar

type TagBar struct {
	// Visible is the visibility of the tagbar.
	Visible bool

	// Width is the width of the tagbar.
	Width int
}

TagBar is the structure for the tagbar.

Jump to

Keyboard shortcuts

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