Skip to content

Commit

Permalink
textcore: add metadata to Lines -- key for storing vcs repo in Code
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Feb 22, 2025
1 parent 50e3b3f commit 7c96144
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions text/lines/lines.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"cogentcore.org/core/base/errors"
"cogentcore.org/core/base/fileinfo"
"cogentcore.org/core/base/metadata"
"cogentcore.org/core/base/slicesx"
"cogentcore.org/core/text/highlighting"
"cogentcore.org/core/text/parse"
Expand Down Expand Up @@ -83,6 +84,12 @@ type Lines struct {
// save current version as a different file. It must block until the user responds.
FileModPromptFunc func()

// Meta can be used to maintain misc metadata associated with the Lines text,
// which allows the Lines object to be the primary data type for applications
// dealing with text data, if there are just a few additional data elements needed.
// Use standard Go camel-case key names, standards in [metadata].
Meta metadata.Data

// fontStyle is the default font styling to use for markup.
// Is set to use the monospace font.
fontStyle *rich.Style
Expand Down Expand Up @@ -174,6 +181,8 @@ type Lines struct {
sync.Mutex
}

func (ls *Lines) Metadata() *metadata.Data { return &ls.Meta }

// numLines returns number of lines
func (ls *Lines) numLines() int {
return len(ls.lines)
Expand Down

0 comments on commit 7c96144

Please sign in to comment.