model

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MinWidth = 60

MinWidth is the minimum usable width for the application.

Variables

This section is empty.

Functions

func IsMarkdownFile added in v0.2.1

func IsMarkdownFile(name string) bool

IsMarkdownFile reports whether name has a markdown extension (case-insensitive).

Types

type BackToBookMsg

type BackToBookMsg struct{}

BackToBookMsg signals returning to the Book view.

type Book

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

Book is the file browser view.

func NewBook

func NewBook(ctx *ViewContext, dir string) Book

NewBook creates a new Book file browser for the given directory.

func NewBookFromFiles

func NewBookFromFiles(ctx *ViewContext, files []string) Book

NewBookFromFiles creates a Book view from explicit file/directory paths instead of scanning a directory. Used when ink is called with multiple args.

func (Book) Init

func (b Book) Init() tea.Cmd

func (Book) Update

func (b Book) Update(msg tea.Msg) (Book, tea.Cmd)

func (Book) View

func (b Book) View() string

type Chapter

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

Chapter is the markdown viewer.

func NewChapter

func NewChapter(ctx *ViewContext, filePath string) Chapter

NewChapter creates a new Chapter viewer for the given file.

func (Chapter) Init

func (c Chapter) Init() tea.Cmd

func (Chapter) Update

func (c Chapter) Update(msg tea.Msg) (Chapter, tea.Cmd)

func (Chapter) View

func (c Chapter) View() string

type CloseEditorMsg

type CloseEditorMsg struct {
	FilePath string
}

CloseEditorMsg signals the editor has closed.

type Editor

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

Editor is the distraction-free markdown editor.

func NewEditor

func NewEditor(ctx *ViewContext, filePath string, content string) Editor

NewEditor creates a new Editor for the given file content.

func (Editor) Init

func (e Editor) Init() tea.Cmd

func (Editor) Update

func (e Editor) Update(msg tea.Msg) (Editor, tea.Cmd)

func (Editor) View

func (e Editor) View() string

type ExternalEditorClosedMsg

type ExternalEditorClosedMsg struct {
	Err error
}

ExternalEditorClosedMsg signals the external editor has exited.

type FileSavedMsg

type FileSavedMsg struct{}

FileSavedMsg signals a file was saved successfully.

type Model

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

Model is the root application model that routes between views.

func New

func New(dir string, maxWidth int) Model

New creates the root model.

func NewFromFile

func NewFromFile(filePath string, maxWidth int) Model

NewFromFile creates a model that opens a single markdown file directly in ChapterView. Pressing back/esc quits the app instead of returning to BookView.

func NewFromFiles

func NewFromFiles(files []string, maxWidth int) Model

NewFromFiles creates a model that shows a filtered BookView with the given file/dir paths.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

func (Model) View

func (m Model) View() string

type OpenChapterMsg

type OpenChapterMsg struct {
	FilePath string
}

OpenChapterMsg requests switching to the Chapter view for the given file.

type OpenEditorMsg

type OpenEditorMsg struct {
	FilePath string
	Content  string
}

OpenEditorMsg requests switching to the Editor view.

type OpenExternalEditorMsg

type OpenExternalEditorMsg struct {
	FilePath string
}

OpenExternalEditorMsg requests opening the file in $EDITOR.

type ViewContext added in v0.2.0

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

ViewContext holds shared state across all views.

type ViewState

type ViewState int

ViewState represents which view is currently active.

const (
	BookView ViewState = iota
	ChapterView
	EditorView
)

Jump to

Keyboard shortcuts

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