states

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GROUP_DEADLINE_ID    = 1
	GROUP_WORKPERF_ID    = 2
	GROUP_LIFEENHANCE_ID = 3
	GROUP_WORKHACK_ID    = 4
	GROUP_LIFEHACK_ID    = 5
	GROUP_OTHER_ID       = 6
)

Group IDs for organizing entries in group mode

View Source
const (
	SelectedEntryMode_Default = iota
	SelectedEntryMode_Editing
	SelectedEntryMode_ShowActions
	SelectedEntryMode_DeleteConfirm
	SelectedEntryMode_AddingChild
)
View Source
const PAGE_SIZE = 4096 // Each page is 4096 bytes

Variables

This section is empty.

Functions

func HappeningListPage

func HappeningListPage(state *State, height int) *dom.Node

HappeningListPage renders the happening list page

func HelpPage

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

HelpPage renders the help page with scrolling support

func HumanStatePage

func HumanStatePage(state *State) *dom.Node

HumanStatePage renders the human state page

func LearningPage

func LearningPage(state *State, width int, height int) *dom.Node

LearningPage renders the learning materials page

func ReadingPage

func ReadingPage(state *State, materialID int64, width int, height int) *dom.Node

ReadingPage renders the reading page for a material

Types

type ConfigPageState

type ConfigPageState struct {
	ConfigPhase ConfigPhase

	SelectedStorageType StorageType
	PickingStorageType  StorageType

	ServerAddr      models.InputState
	ServerAuthToken models.InputState

	ConfirmButtonFocused bool
	CancelButtonFocused  bool
}

type ConfigPhase

type ConfigPhase int
const (
	ConfigPhase_PickingStorageType ConfigPhase = iota
	ConfigPhase_PickingStorageDetail
)

type DetailPageState

type DetailPageState struct {
	EntryID int64
}

type HappeningListPageState

type HappeningListPageState struct {
}

type HappeningState

type HappeningState struct {
	Loading     bool
	Happenings  []*models.Happening
	Error       string
	Input       models.InputState
	SubmitState submit.SubmitState // Submission state management

	SelectedItemIndex int

	// 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 HelpPageState

type HelpPageState struct {
	ScrollOffset int // Current scroll position (line offset from top)
}

type HumanStatePageState

type HumanStatePageState struct {
}

type LearningPageState

type LearningPageState struct {
}

type LearningState

type LearningState struct {
	Loading   bool
	Materials []*models.LearningMaterial
	Error     string

	LoadMaterials     func(ctx context.Context, offset int, limit int) ([]*models.LearningMaterial, int64, error)
	LoadMaterialsOnce func() // Load materials once on first access

	// Selected material for reading
	SelectedMaterialIndex int
}

type MainPageState

type MainPageState struct {
	Entries []TreeEntry
}

type MutexMap

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

MutexMap provides thread-safe access to a map[int64]bool

func NewMutexMap

func NewMutexMap() *MutexMap

NewMutexMap creates a new thread-safe map

func (*MutexMap) Copy

func (m *MutexMap) Copy() map[int64]bool

Copy safely returns a copy of the entire map

func (*MutexMap) Get

func (m *MutexMap) Get(key int64) bool

Get safely reads a value from the map

func (*MutexMap) IsEmpty

func (m *MutexMap) IsEmpty() bool

IsEmpty safely checks if the map is empty

func (*MutexMap) Set

func (m *MutexMap) Set(key int64, value bool)

Set safely writes a value to the map

func (*MutexMap) Toggle

func (m *MutexMap) Toggle(key int64)

Toggle safely toggles a value in the map

type ReadingPageState

type ReadingPageState struct {
	MaterialID int64
}

type ReadingState

type ReadingState struct {
	MaterialID   int64
	CurrentPage  int
	TotalBytes   int
	Loading      bool
	Error        string
	ContentCache map[int]string // Cache content by page number (each page is 4096 bytes)

	// Word-level navigation
	FocusedWordIndex int                   // Index of currently focused word in the current page
	WordPositions    []models.WordPosition // Positions of all words in current page

	// Viewport scrolling
	ScrollOffset int // Current scroll position (line offset from top)

	// Vim-like navigation
	LastKeyWasG bool // Track if last key was 'g' for 'gg' sequence

	// Search functionality
	SearchMode        bool   // Whether in search mode (typing query)
	SearchQuery       string // Current search query
	SearchMatches     []int  // Indices of words that match the search
	CurrentMatchIndex int    // Index in SearchMatches array

	// Word definition functionality
	ShowDefinition bool   // Whether to show word definition panel
	DefinitionWord string // The word to show definition for

	LoadContent  func(ctx context.Context, materialID int64, offset int, limit int) (content string, totalBytes int, lastOffset int64, err error)
	SavePosition func(ctx context.Context, materialID int64, offset int64) error
}

type Route

type Route struct {
	Type              RouteType
	MainPage          *MainPageState
	DetailPage        *DetailPageState
	ConfigPage        *ConfigPageState
	HappeningListPage *HappeningListPageState
	HumanStatePage    *HumanStatePageState
	HelpPage          *HelpPageState
	LearningPage      *LearningPageState
	ReadingPage       *ReadingPageState
}

func ConfigRoute

func ConfigRoute(state ConfigPageState) Route

func DetailRoute

func DetailRoute(entryID int64) Route

func HappeningListRoute

func HappeningListRoute() Route

func HelpRoute

func HelpRoute() Route

func HumanStateRoute

func HumanStateRoute() Route

func LearningRoute

func LearningRoute() Route

func ReadingRoute

func ReadingRoute(materialID int64) Route

type RouteType

type RouteType int
const (
	RouteType_Main RouteType = iota
	RouteType_Detail
	RouteType_Config
	RouteType_HappeningList
	RouteType_HumanState
	RouteType_Help
	RouteType_Learning
	RouteType_Reading
)

type Routes

type Routes []Route

func (*Routes) Last

func (routes *Routes) Last() Route

func (*Routes) Pop

func (routes *Routes) Pop()

func (*Routes) Push

func (routes *Routes) Push(route Route)

type SelectedEntryMode

type SelectedEntryMode int

type SelectedSource

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

type State

type State struct {
	Entries models.LogEntryViews

	Input       models.InputState
	SubmitState submit.SubmitState // Submission state management

	SelectedEntry       models.EntryIdentity
	LastSelectedEntry   models.EntryIdentity
	EntrySliceStart     int   // Slice start for VScroller to preserve window frame position
	SelectedNoteID      int64 // ID of the selected note (0 if none)
	SelectedNoteEntryID int64 // ID of the entry that owns the selected note
	SelectFromSource    SelectedSource
	SelectedEntryMode   SelectedEntryMode
	SelectedInputState  models.InputState
	ChildInputState     models.InputState
	ChildSubmitState    submit.SubmitState // Submission state management for child entries

	SelectedDeleteConfirmButton int

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

	SelectedActionIndex int

	Routes Routes

	// Happening functionality
	Happening HappeningState

	// Human state functionality
	HumanState *human_state.HumanState

	// Learning functionality
	Learning LearningState

	// Reading functionality
	Reading ReadingState

	ShowHistory bool // Whether to show historical (done) todos from before today
	ShowNotes   bool // Whether to show all notes globally
	ExpandAll   bool // Whether to expand all entries, ignoring individual collapse flags

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

	// Cut/Paste functionality
	CuttingEntry models.EntryIdentity // ID of the entry currently being cut (0 if none)

	// Focused mode functionality
	FocusedEntry models.EntryIdentity // ID of the entry currently focused on (0 if none)

	// View mode functionality
	ViewMode ViewMode // Current view mode (default or group)

	// Group collapse state (for group mode entries that don't exist in DB)
	GroupCollapseState *MutexMap // Thread-safe map for group collapse states

	// Navigation stack for group mode 'l' and 'L' commands
	NavigationStack []models.EntryIdentity // Stack to track navigation history

	Quit func()

	Refresh func()

	OnAdd             func(ctx context.Context, viewType models.LogEntryViewType, text string) error
	OnAddChild        func(ctx context.Context, viewType models.LogEntryViewType, parentID int64, text string) (models.LogEntryViewType, int64, error)
	OnUpdate          func(viewType models.LogEntryViewType, id int64, text string) error
	OnDelete          func(viewType models.LogEntryViewType, id int64) error
	OnRemoveFromGroup func(viewType models.LogEntryViewType, id int64) error
	OnToggle          func(viewType models.LogEntryViewType, id int64) error
	OnPromote         func(viewType models.LogEntryViewType, id int64) error
	OnUpdateHighlight func(viewType models.LogEntryViewType, id int64, highlightLevel int)
	OnMove            func(id models.EntryIdentity, newParentID models.EntryIdentity) 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(ctx context.Context, entryType models.LogEntryViewType, id int64) error // Callback to toggle collapsed state for entry

	LastCtrlC time.Time

	StatusBar StatusBar
	// contains filtered or unexported fields
}

func (*State) ClearSearch

func (state *State) ClearSearch()

func (*State) ClearSearchSelectedEntry added in v0.0.30

func (state *State) ClearSearchSelectedEntry()

func (*State) ClearSelectedEntry added in v0.0.30

func (state *State) ClearSelectedEntry()

func (*State) Deselect

func (state *State) Deselect()

func (*State) Enqueue

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) FindEntryByID

func (state *State) FindEntryByID(entryID int64) *models.LogEntryView

FindEntryByID finds an entry by its ID in the entries tree

func (*State) FindGroupForEntry

func (state *State) FindGroupForEntry(entryID int64) int64

findGroupForEntry finds which group an entry belongs to in group mode

func (*State) IsDescendantOf

func (state *State) IsDescendantOf(potentialChild models.EntryIdentity, potentialParent models.EntryIdentity) bool

IsDescendant checks if potentialChild is a descendant of potentialParent cannot paste a parent into its child

func (*State) PopFromNavigationStack

func (state *State) PopFromNavigationStack() (models.EntryIdentity, bool)

PopFromNavigationStack pops and returns the last entry from the navigation stack

func (*State) PushToNavigationStack

func (state *State) PushToNavigationStack(entry models.EntryIdentity)

PushToNavigationStack pushes the current selected entry to the navigation stack

func (*State) Requesting

func (state *State) Requesting() bool

Requesting returns true if there are ongoing actions

func (*State) ResetAllChildrenVisibility

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

func (state *State) Select(entyType models.LogEntryViewType, id int64)

func (*State) SelectNote

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

func (*State) SetSearchSelectedEntry added in v0.0.30

func (state *State) SetSearchSelectedEntry(entry models.EntryIdentity)

type StatusBar

type StatusBar struct {
	Error   string
	Storage string
}

type StorageType

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

type TreeEntry

type TreeEntry struct {
	Type   models.LogEntryViewType
	Prefix string
	IsLast bool

	// for all
	Entry *models.LogEntryView

	Log         *TreeLog
	Note        *TreeNote // TODO: remove
	FocusedItem *TreeFocusedItem
	Group       *TreeGroup
}

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

func (*TreeEntry) Text

func (c *TreeEntry) Text() string

type TreeFocusedItem

type TreeFocusedItem struct {
	RootPath []string
}

TreeFocusedItem represents the focused root path

type TreeGroup

type TreeGroup struct {
	ID   int64
	Name string
}

TreeGroup represents a group entry

type TreeLog

type TreeLog struct {
}

TreeLog represents a flattened log entry

type TreeNote

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

TreeNote represents a flattened note

type ViewMode

type ViewMode int
const (
	ViewMode_Default ViewMode = iota
	ViewMode_Group
)

Jump to

Keyboard shortcuts

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