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

Function TextDialog

texteditor/diffeditor.go:102–118  ·  view source on GitHub ↗

TextDialog opens a dialog for displaying text string

(ctx core.Widget, title, text string)

Source from the content-addressed store, hash-verified

100
101// TextDialog opens a dialog for displaying text string
102func TextDialog(ctx core.Widget, title, text string) *Editor {
103 d := core.NewBody().AddTitle(title)
104 ed := NewEditor(d)
105 ed.Styler(func(s *styles.Style) {
106 s.Grow.Set(1, 1)
107 })
108 ed.Buffer.SetText([]byte(text))
109 d.AddBottomBar(func(parent core.Widget) {
110 core.NewButton(parent).SetText("Copy to clipboard").SetIcon(icons.ContentCopy).
111 OnClick(func(e events.Event) {
112 d.Clipboard().Write(mimedata.NewText(text))
113 })
114 d.AddOK(parent)
115 })
116 d.RunWindowDialog(ctx)
117 return ed
118}
119
120// DiffEditor presents two side-by-side [Editor]s showing the differences
121// between two files (represented as lines of strings).

Callers 1

lookupParseFunction · 0.85

Calls 15

NewBodyFunction · 0.92
NewButtonFunction · 0.92
NewTextFunction · 0.92
NewEditorFunction · 0.85
AddTitleMethod · 0.80
StylerMethod · 0.80
AddBottomBarMethod · 0.80
AddOKMethod · 0.80
RunWindowDialogMethod · 0.80
SetMethod · 0.65
SetIconMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected