history

package
v0.0.0-...-0ab5f93 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOperationDescription

func GetOperationDescription(op *Operation) string

GetOperationDescription returns a human-readable description of an operation

Types

type History

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

History manages undo/redo stacks

func New

func New(maxSize int) *History

New creates a new history manager

func (*History) CanRedo

func (h *History) CanRedo() bool

CanRedo returns true if redo is available

func (*History) CanUndo

func (h *History) CanUndo() bool

CanUndo returns true if undo is available

func (*History) Clear

func (h *History) Clear()

Clear resets all history

func (*History) GetUndoStack

func (h *History) GetUndoStack() []*Operation

GetUndoStack returns a copy of the undo stack for display (newest first)

func (*History) Len

func (h *History) Len() (int, int)

Len returns the current sizes of undo and redo stacks

func (*History) Record

func (h *History) Record(op *Operation)

Record adds an operation to the undo stack and clears the redo stack

func (*History) Redo

func (h *History) Redo() *Operation

Redo returns the operation to redo and moves it back to the undo stack

func (*History) RedoSize

func (h *History) RedoSize() int

RedoSize returns the number of redo operations available

func (*History) Undo

func (h *History) Undo() *Operation

Undo returns the operation to undo and moves it to the redo stack

func (*History) UndoSize

func (h *History) UndoSize() int

UndoSize returns the number of undo operations available

type Operation

type Operation struct {
	Type        OperationType `json:"type"`
	Description string        `json:"description"`
	Timestamp   time.Time     `json:"timestamp"`

	// Affected task IDs
	TaskIDs []string `json:"task_ids"`

	// Snapshots of tasks before and after the operation
	// Before: original state before operation
	// After: state after operation (for redo)
	Before []core.Task `json:"before"`
	After  []core.Task `json:"after"`
}

Operation represents a single undoable operation

func CreateOperation

func CreateOperation(opType OperationType, description string, taskIDs []string, before, after []core.Task) *Operation

CreateOperation is a helper to create a new operation record

type OperationType

type OperationType int

OperationType defines the type of operation recorded in history

const (
	OpCreate OperationType = iota
	OpUpdate
	OpDelete
	OpBulkDelete
	OpToggleStatus
	OpBulkToggleStatus
	OpChangePriority
	OpChangeDeadline
	OpChangeCollapsed
	OpBulkOperation
)

func (OperationType) String

func (op OperationType) String() string

Jump to

Keyboard shortcuts

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