Skip to content

Commit

Permalink
Enable paste support in views.Application
Browse files Browse the repository at this point in the history
Pasting is not supported when using the `Application` view. This commit enables pasting support on an opt-in basis.

Fixes #552
  • Loading branch information
chrBrd authored and gdamore committed Oct 17, 2022
1 parent 43efca7 commit 178ac43
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions views/app.go
Expand Up @@ -27,13 +27,20 @@ type Application struct {
style tcell.Style
err error
wg sync.WaitGroup
paste bool
}

// SetRootWidget sets the primary (root, main) Widget to be displayed.
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 {
Expand Down Expand Up @@ -127,6 +134,9 @@ func (app *Application) run() {
}()
screen.Init()
screen.EnableMouse()
if app.paste {
screen.EnablePaste()
}
screen.Clear()
widget.SetView(screen)

Expand Down

0 comments on commit 178ac43

Please sign in to comment.