From 178ac4393aa5bc6879efb2bc2f0bb8ca16a6e889 Mon Sep 17 00:00:00 2001 From: Chris Bradbury Date: Wed, 21 Sep 2022 12:37:02 +0100 Subject: [PATCH] Enable paste support in `views.Application` Pasting is not supported when using the `Application` view. This commit enables pasting support on an opt-in basis. Fixes #552 --- views/app.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/views/app.go b/views/app.go index 21aca059..1a6e2c5e 100644 --- a/views/app.go +++ b/views/app.go @@ -27,6 +27,7 @@ type Application struct { style tcell.Style err error wg sync.WaitGroup + paste bool } // SetRootWidget sets the primary (root, main) Widget to be displayed. @@ -34,6 +35,12 @@ func (app *Application) SetRootWidget(widget Widget) { app.widget = widget } +// EnablePaste enables or disables pasting support in the application. +// It must be called before Start or Run or else it will have no effect. +func (app *Application) EnablePaste(on bool) { + app.paste = on +} + // initialize initializes the application. It will normally attempt to // allocate a default screen if one is not already established. func (app *Application) initialize() error { @@ -127,6 +134,9 @@ func (app *Application) run() { }() screen.Init() screen.EnableMouse() + if app.paste { + screen.EnablePaste() + } screen.Clear() widget.SetView(screen)