TextDialog opens a dialog for displaying text string
(ctx core.Widget, title, text string)
| 100 | |
| 101 | // TextDialog opens a dialog for displaying text string |
| 102 | func 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). |
no test coverage detected