github.com/pluralsh/plural-cli@v0.9.5/pkg/ui/window.go (about)

     1  //go:build ui || generate
     2  
     3  package ui
     4  
     5  import (
     6  	"context"
     7  
     8  	"github.com/wailsapp/wails/v2/pkg/runtime"
     9  )
    10  
    11  const (
    12  	Width  = 1024
    13  	Height = 768
    14  )
    15  
    16  // Window struct
    17  type Window struct {
    18  	ctx context.Context
    19  }
    20  
    21  // startup is called when the app starts. The context is saved
    22  // so we can call the runtime methods.
    23  func (this *Window) startup(ctx context.Context) {
    24  	this.ctx = ctx
    25  }
    26  
    27  func (this *Window) width() int {
    28  	return Width
    29  }
    30  
    31  func (this *Window) height() int {
    32  	return Height
    33  }
    34  
    35  // Close closes the application
    36  func (this *Window) Close() {
    37  	runtime.Quit(this.ctx)
    38  }
    39  
    40  // SetClipboard allows to copy provided text to OS clipboard
    41  func (this *Window) SetClipboard(text string) error {
    42  	return runtime.ClipboardSetText(this.ctx, text)
    43  }
    44  
    45  // NewWindow creates a new App application struct
    46  func NewWindow() *Window {
    47  	return &Window{}
    48  }