app

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtrlCExitDelayMs = 1000
	UIWidth          = 50 // Shared width for status bar and input components
)
View Source
const (
	SelectedEntryMode_Default = iota
	SelectedEntryMode_Editing
	SelectedEntryMode_ShowActions
	SelectedEntryMode_DeleteConfirm
	SelectedEntryMode_AddingChild
)
View Source
const HEADER_HEIGHT = 1

Variables

This section is empty.

Functions

func App

func App(state *State, window *dom.Window) *dom.Node

func ConfigPage added in v0.0.10

func ConfigPage(state *State) *dom.Node

func ConfirmDialog

func ConfirmDialog(props ConfirmDialogProps) *dom.Node

ConfirmDialog creates a confirmation dialog with action and cancel buttons

func DetailPage added in v0.0.4

func DetailPage(state *State, id int64) *dom.Node

func ExportVisibleEntries added in v0.0.10

func ExportVisibleEntries(filename string, visibleEntries []TreeEntry) error

ExportVisibleEntries exports the currently visible entries to a JSON file

func HappeningListPage added in v0.0.15

func HappeningListPage(state *State) *dom.Node

HappeningListPage renders the happening list page

func MainInput added in v0.0.9

func MainInput(state *State, fullEntries []TreeEntry) *dom.Node

func MainPage added in v0.0.4

func MainPage(state *State, window *dom.Window) *dom.Node
func Menu(props MenuProps) *dom.Node

func RenderRoute added in v0.0.10

func RenderRoute(state *State, route Route) *dom.Node

func SearchInput added in v0.0.4

func SearchInput(props InputProps) *dom.Node

SearchInput wraps the component.SearchInput with app-specific defaults

func TodoItem added in v0.0.4

func TodoItem(props TodoItemProps) *dom.Node

func TodoNote added in v0.0.14

func TodoNote(props TodoNoteProps) *dom.Node

func Tree added in v0.0.14

func Tree(props TreeProps) []*dom.Node

Tree builds and renders the tree of entries as DOM nodes

Types

type ChildNotesSection added in v0.0.10

type ChildNotesSection struct {
	Entry *models.LogEntryView
	Path  string
	Notes []*models.NoteView
}

type ComputeResult added in v0.0.6

type ComputeResult struct {
	EntriesAbove        int
	EntriesBelow        int
	VisibleEntries      []TreeEntry
	FullEntries         []TreeEntry
	EffectiveSliceStart int
}

type ConfigPageState added in v0.0.10

type ConfigPageState struct {
	ConfigPhase ConfigPhase

	SelectedStorageType StorageType
	PickingStorageType  StorageType

	ServerAddr      models.InputState
	ServerAuthToken models.InputState

	ConfirmButtonFocused bool
	CancelButtonFocused  bool
}

type ConfigPhase added in v0.0.10

type ConfigPhase int
const (
	ConfigPhase_PickingStorageType ConfigPhase = iota
	ConfigPhase_PickingStorageDetail
)

type ConfirmDialogProps

type ConfirmDialogProps struct {
	SelectedButton  int
	PromptText      string // e.g., "Delete todo?"
	DeleteText      string // e.g., "[Delete]" or "[OK]"
	CancelText      string // e.g., "[Cancel]"
	OnDelete        func()
	OnCancel        func()
	OnNavigateRight func()
	OnNavigateLeft  func()
}

ConfirmDialogProps contains the properties for the confirmation dialog

type DetailPageState added in v0.0.10

type DetailPageState struct {
	EntryID int64
}

type ExportData added in v0.0.10

type ExportData struct {
	Entries []ExportEntry `json:"entries"`
}

ExportData represents the structure for exporting entries

type ExportEntry added in v0.0.10

type ExportEntry struct {
	Data  *models.LogEntry `json:"data"`
	Notes []ExportNote     `json:"notes"`
}

ExportEntry represents a single entry with its notes for export

type ExportNote added in v0.0.10

type ExportNote struct {
	Data *models.Note `json:"data"`
}

ExportNote represents a single note for export

type HappeningListPageState added in v0.0.15

type HappeningListPageState struct {
}

type HappeningState added in v0.0.15

type HappeningState struct {
	Loading    bool
	Happenings []*models.Happening
	Error      string
	Input      models.InputState

	FocusedItemID int64

	// Edit/Delete state
	EditingItemID       int64
	EditInputState      models.InputState
	DeletingItemID      int64
	DeleteConfirmButton int // 0 = Delete, 1 = Cancel

	LoadHappenings  func(ctx context.Context) ([]*models.Happening, error)
	AddHappening    func(ctx context.Context, content string) (*models.Happening, error)
	UpdateHappening func(ctx context.Context, id int64, update *models.HappeningOptional) (*models.Happening, error)
	DeleteHappening func(ctx context.Context, id int64) error
}

type IDs added in v0.0.10

type IDs []int64

func (IDs) Last added in v0.0.10

func (ids IDs) Last() int64

func (*IDs) Pop added in v0.0.10

func (ids *IDs) Pop()

func (*IDs) Push added in v0.0.10

func (ids *IDs) Push(id int64)

func (IDs) SetLast added in v0.0.10

func (ids IDs) SetLast(id int64)

type InputProps

type InputProps = component.InputProps

InputProps is an alias for component.InputProps for backward compatibility

type MainPageState added in v0.0.10

type MainPageState struct {
	Entries []TreeEntry
}
type MenuItem struct {
	Text     string
	Color    string
	OnSelect func()
}
type MenuProps struct {
	Title         string
	SelectedIndex int
	Items         []MenuItem
	OnSelect      func(index int)
	OnKeyDown     func(e *dom.DOMEvent)

	OnDismiss func()
}

type Route added in v0.0.10

type Route struct {
	Type              RouteType
	MainPage          *MainPageState
	DetailPage        *DetailPageState
	ConfigPage        *ConfigPageState
	HappeningListPage *HappeningListPageState
}

func ConfigRoute added in v0.0.10

func ConfigRoute(state ConfigPageState) Route

func DetailRoute added in v0.0.10

func DetailRoute(entryID int64) Route

func HappeningListRoute added in v0.0.15

func HappeningListRoute() Route

type RouteType added in v0.0.10

type RouteType int
const (
	RouteType_Main RouteType = iota
	RouteType_Detail
	RouteType_Config
	RouteType_HappeningList
)

type Routes added in v0.0.10

type Routes []Route

func (*Routes) Last added in v0.0.10

func (routes *Routes) Last() Route

func (*Routes) Pop added in v0.0.10

func (routes *Routes) Pop()

func (*Routes) Push added in v0.0.10

func (routes *Routes) Push(route Route)

type SelectedEntryMode added in v0.0.3

type SelectedEntryMode int

type SelectedSource added in v0.0.10

type SelectedSource int
const (
	SelectedSource_Default SelectedSource = iota
	SelectedSource_Search
	SelectedSource_NavigateByKey
)

type State

type State struct {
	Entries models.LogEntryViews

	Input               models.InputState
	SelectedEntryID     int64
	SelectedNoteID      int64 // ID of the selected note (0 if none)
	SelectedNoteEntryID int64 // ID of the entry that owns the selected note
	SelectFromSource    SelectedSource
	LastSelectedEntryID int64
	SelectedEntryMode   SelectedEntryMode
	SelectedInputState  models.InputState
	ChildInputState     models.InputState

	SelectedDeleteConfirmButton int

	// in ZenMode, only show highlighted and
	// unfinished entries
	ZenMode bool

	SelectedActionIndex int

	Routes Routes

	// Happening functionality
	Happening HappeningState

	ShowHistory bool // Whether to show historical (done) todos from before today
	ShowNotes   bool // Whether to show all notes globally

	// Search functionality
	SearchQuery    string // Current search query (without the ? prefix)
	IsSearchActive bool   // Whether search mode is active

	// Pagination
	SliceStart int // Starting index for the slice of entries to display

	// Cut/Paste functionality
	CuttingEntryID int64 // ID of the entry currently being cut (0 if none)

	// Focused mode functionality
	FocusedEntryID int64 // ID of the entry currently focused on (0 if none)

	Quit func()

	Refresh func()

	OnAdd             func(string) error
	OnAddChild        func(parentID int64, text string) (int64, error)
	OnUpdate          func(id int64, text string) error
	OnDelete          func(id int64) error
	OnToggle          func(id int64) error
	OnPromote         func(id int64) error
	OnUpdateHighlight func(id int64, highlightLevel int)
	OnMove            func(id int64, newParentID int64) error

	OnAddNote    func(id int64, text string) error
	OnUpdateNote func(entryID int64, noteID int64, text string)
	OnDeleteNote func(entryID int64, noteID int64)

	RefreshEntries       func(ctx context.Context) error                     // Callback to refresh entries when ShowHistory changes
	OnShowTop            func(id int64, text string, duration time.Duration) // Callback to show todo in macOS floating bar
	OnToggleVisibility   func(id int64) error                                // Callback to toggle visibility of all children including history
	OnToggleNotesDisplay func(id int64) error                                // Callback to toggle notes display for entry and its subtree
	OnToggleCollapsed    func(id int64) error                                // Callback to toggle collapsed state for entry

	LastCtrlC time.Time

	StatusBar StatusBar
	// contains filtered or unexported fields
}

func (*State) ClearSearch added in v0.0.4

func (state *State) ClearSearch()

func (*State) Deselect added in v0.0.9

func (state *State) Deselect()

func (*State) Enqueue added in v0.0.11

func (state *State) Enqueue(action func(ctx context.Context) error)

Enqueue schedules an action to run in a goroutine and tracks its status

func (*State) IsDescendant added in v0.0.9

func (state *State) IsDescendant(potentialChild int64, potentialParent int64) bool

IsDescendant checks if potentialChild is a descendant of potentialParent

func (*State) Requesting added in v0.0.11

func (state *State) Requesting() bool

Requesting returns true if there are ongoing actions

func (*State) ResetAllChildrenVisibility added in v0.0.12

func (state *State) ResetAllChildrenVisibility()

ResetAllChildrenVisibility resets all IncludeHistory states to false This is used when /history is toggled off to reset all 'v' command states

func (*State) Select added in v0.0.9

func (state *State) Select(id int64)

func (*State) SelectNote added in v0.0.14

func (state *State) SelectNote(noteID int64, entryID int64)

type StatusBar added in v0.0.10

type StatusBar struct {
	Error   string
	Storage string
}

type StorageType added in v0.0.10

type StorageType int
const (
	StorageType_LocalFile StorageType = iota
	StorageType_LocalSqlite
	StorageType_Server
)

type TodoItemProps added in v0.0.4

type TodoItemProps struct {
	Item       *models.LogEntryView
	Prefix     string
	IsLast     bool
	IsSelected bool
	State      *State

	OnNavigate func(e *dom.DOMEvent, direction int)
	OnEnter    func(e *dom.DOMEvent, entryID int64)
	// gg
	OnGoToFirst func(e *dom.DOMEvent)
	// G
	OnGoToLast func(e *dom.DOMEvent)

	// gt -> top
	OnGoToTop func(e *dom.DOMEvent)
	// gb -> bottom
	OnGoToBottom func(e *dom.DOMEvent)
}

type TodoNoteProps added in v0.0.14

type TodoNoteProps struct {
	Note       *models.NoteView
	EntryID    int64 // ID of the entry that owns this note
	Prefix     string
	IsLast     bool
	IsSelected bool
	State      *State

	OnNavigate func(e *dom.DOMEvent, direction int)
	OnEnter    func(e *dom.DOMEvent, entryID int64)
}

type TreeEntry added in v0.0.14

type TreeEntry struct {
	Type   TreeEntryType
	Prefix string
	IsLast bool

	Log         *TreeLog
	Note        *TreeNote
	FocusedItem *TreeFocusedItem
}

TreeEntry wraps either a log entry or a note for unified tree rendering

func (*TreeEntry) Text added in v0.0.14

func (c *TreeEntry) Text() string

type TreeEntryType added in v0.0.14

type TreeEntryType string

TreeEntryType represents the type of entry in a TreeEntry

const (
	TreeEntryType_Log         TreeEntryType = "Log"
	TreeEntryType_Note        TreeEntryType = "Note"
	TreeEntryType_FocusedItem TreeEntryType = "FocusedItem"
)

type TreeFocusedItem added in v0.0.15

type TreeFocusedItem struct {
	RootPath []string
}

TreeFocusedItem represents the focused root path

type TreeLog added in v0.0.14

type TreeLog struct {
	Entry *models.LogEntryView
}

TreeLog represents a flattened log entry

type TreeNote added in v0.0.14

type TreeNote struct {
	Note    *models.NoteView
	EntryID int64 // ID of the entry that owns this note
}

TreeNote represents a flattened note

type TreeProps added in v0.0.14

type TreeProps struct {
	State        *State // The application state
	Entries      []TreeEntry
	EntriesAbove int
	EntriesBelow int

	OnNavigate   func(e *dom.DOMEvent, entryType TreeEntryType, entryID int64, direction int)
	OnEnter      func(e *dom.DOMEvent, entryType TreeEntryType, entryID int64)
	OnGoToFirst  func(e *dom.DOMEvent)
	OnGoToLast   func(e *dom.DOMEvent)
	OnGoToTop    func(e *dom.DOMEvent)
	OnGoToBottom func(e *dom.DOMEvent)
}

TreeProps contains configuration for rendering the entry tree

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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