Documentation
¶
Index ¶
- Constants
- Variables
- func CwdHasProject() bool
- func Execute()
- func GetConfigDir() string
- func RandomId(length int) string
- type MdProject
- type MdpNode
- func (n *MdpNode) AddChildNode(node *MdpNode)
- func (n *MdpNode) FindNodeByRelativeId(nodeId string) *MdpNode
- func (n *MdpNode) GetFQId() string
- func (n *MdpNode) GetRelativeId() string
- func (n *MdpNode) GetStatus() Status
- func (n *MdpNode) IsDescendantOf(node *MdpNode) bool
- func (n *MdpNode) RemoveChildNodeById(id string)
- func (n *MdpNode) SetContents(contents string)
- func (n *MdpNode) SetStatus(status Status) error
- func (n MdpNode) StyledString() string
- func (n MdpNode) ToMarkdown(level int) string
- func (n *MdpNode) ToTviewTreeNode(focusedNodeId string) (*tview.TreeNode, *tview.TreeNode)
- type Mode
- type Status
Constants ¶
const CHILD_NODE_ID_LENGTH int = 4
const COLOR_DONE string = "color_done"
const COLOR_FLAG string = "color_flag"
const COLOR_ID string = "color_id"
const COLOR_TODO string = "color_todo"
const COLOR_UNCATEGORIZED string = "color_uncategorized"
const CONFIG_FILE_EXT string = "yaml"
const CONFIG_FILE_NAME string = "user-config"
const PROJECT_AUTHOR string = "author"
const PROJECT_FILENAME_MD string = "project_filename_md"
const PROJECT_FILENAME_PMD string = "project_filename_pmd"
const ROOT_PROJECT_ID_LENGTH int = 4
Here, the top level node gets an ID of length 4, and the children get an ID of length 4. Each child node will add on it's own ID to the end of the parent's ID, so that if you're interested in finding the information about a given node, even if you only search for the parent, you should see results from it's children. This mya break down a bit if nodes start to get moved around a lot.
Variables ¶
var ( // These variables are injected in by the goreleaser build script only for releases Version = "development" CommitSHA = "none" BuildDate = "unknown" )
Functions ¶
func CwdHasProject ¶
func CwdHasProject() bool
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func GetConfigDir ¶
func GetConfigDir() string
Types ¶
type MdProject ¶
func NewMdProject ¶
func ProjectFromStr ¶
Takes in a string containing the raw JSON of a project file, and returns a MdProject struct.
func (MdProject) SaveAsMarkdown ¶
func (p MdProject) SaveAsMarkdown()
func (MdProject) SaveAsPmdBackup ¶
func (p MdProject) SaveAsPmdBackup()
type MdpNode ¶
type MdpNode struct { Id string Name string Content string MarkedStatus Status CreatedAt time.Time Parent *MdpNode `json:"-"` // This is a pointer to the parent node. It is not serialized. Nodes []*MdpNode TVNode *tview.TreeNode `json:"-"` // This is a pointer to the tview node that represents this node in the tree. It is not serialized. }
func NewMdpNode ¶
Create a new MdpNode with a random ID. It does not have a parent node, and it's status is UNCATEGORIZED.
func (*MdpNode) AddChildNode ¶
func (*MdpNode) FindNodeByRelativeId ¶
A recursive function to find a given node by ID. It will search all the children and the parents of this node (but not any of the parents children). It will return nil if not found.
func (*MdpNode) GetFQId ¶
Gets the fully qualified (absolute) ID of a given node, recursively. The fully qualified ID is the relative ID concatenated with the relative IDs of all the parents. An example might be "AB12.CD34.EF56", where the relative ID of the same node is "EF56".
func (*MdpNode) GetRelativeId ¶
Gets the relative ID of a given node. The relative ID is normally fairly short (4 chars), and does not include information about it's place in the overall hierarchy, although it is unique. An example might be "AB12"
func (*MdpNode) GetStatus ¶
This is a recursive function that calculates the "true" status of a node. The true status basically relies on the status of the node's children. If the node has no children, then the node's status is the true status. If any child node is FLAG, then it's parent is also FLAG. If the child nodes are all either TODO, DONE or UNCATEGORIZED, then this node CAN be DONE, but is otherwise TODO (as DONE is set manually). Uncategorized basically means that it was inserted automatically by some other means, and we just need to move it to where it goes, at which point it will be changed to TODO.
func (*MdpNode) IsDescendantOf ¶
func (*MdpNode) RemoveChildNodeById ¶
func (*MdpNode) SetContents ¶
func (*MdpNode) SetStatus ¶
This function will attempt to set the status of a node. It will return an error if the status change is invalid. For example, you cannot set the status of a node to DONE if any of it's children are not already DONE.
func (MdpNode) StyledString ¶
This returns a node string styled in accordance with https://pkgo.dev/github.com/rivo/tview#hdr-Styles__Colors__and_Hyperlinks
func (MdpNode) ToMarkdown ¶
Recursive function to convert an MdpNode to Markdown.
func (*MdpNode) ToTviewTreeNode ¶
A recursive function to build a tview tree from any given MdpNode (including an MdProject). The second returned node is the "focused" node that should be selected when the entire tree is done. It can be nil, and if so, just select the root node, or ignore it.