MCPcopy Create free account
hub / github.com/cogentcore/core / IsValid

Method IsValid

paint/span.go:72–80  ·  view source on GitHub ↗

IsValid ensures that at least some text is represented and the sizes of Text and Render slices are the same, and that the first render info is non-nil

()

Source from the content-addressed store, hash-verified

70// IsValid ensures that at least some text is represented and the sizes of
71// Text and Render slices are the same, and that the first render info is non-nil
72func (sr *Span) IsValid() error {
73 if len(sr.Text) == 0 {
74 return errors.New("core.Text: Text is empty")
75 }
76 if len(sr.Text) != len(sr.Render) {
77 return fmt.Errorf("core.Text: Render length %v != Text length %v for text: %v", len(sr.Render), len(sr.Text), string(sr.Text))
78 }
79 return sr.Render[0].HasNil()
80}
81
82// SizeHV computes the size of the text span from the first char to the last
83// position, which is valid for purely horizontal or vertical text lines --

Callers 15

SizeHVMethod · 0.95
SetRunePosLRMethod · 0.95
SetRunePosTBMethod · 0.95
SetRunePosTBRotMethod · 0.95
GetDocFunction · 0.45
GetFieldFunction · 0.45
RenderMethod · 0.45
RenderTopPosMethod · 0.45
LayoutStdLRMethod · 0.45
writeLineDirectiveMethod · 0.45
writeStringMethod · 0.45
writeCommentPrefixMethod · 0.45

Calls 3

HasNilMethod · 0.80
NewMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected