shell

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color struct {
	R float64
	G float64
	B float64
	A float64
}

type Indicator

type Indicator struct {
	handle.Handle

	Icon string
	Text string
	Menu *Menu
}
Example
sh := New(nil)
//sh.Debug = os.Stderr
if err := sh.Open(); err != nil {
	log.Fatal(err)
}
defer sh.Close()

i := Indicator{
	Text: "Example",
	Menu: &Menu{
		Items: []MenuItem{
			{Title: "Test", Enabled: true, OnClick: fn.Callback(func() {
				fmt.Fprintln(os.Stderr, "Test")
			})},
			{Separator: true},
			{Title: "Quit", Enabled: true},
		},
	},
}

if err := sh.Sync(&i); err != nil {
	log.Fatal(err)
}

// // Output:
type Menu struct {
	handle.Handle

	Icon    string
	Title   string
	Tooltip string
	Items   []MenuItem
}
type MenuItem struct {
	Title     string
	Icon      string
	Tooltip   string
	Separator bool
	Enabled   bool
	Checked   bool

	OnClick  *fn.Ptr
	SubItems []MenuItem
}

type Point

type Point struct {
	X float64
	Y float64
}

type Shell

type Shell struct {
	Debug io.Writer
	// contains filtered or unexported fields
}

func New

func New(sess *mux.Session) *Shell

func (*Shell) Close

func (sh *Shell) Close() error

func (*Shell) Discard

func (sh *Shell) Discard(v interface{}) error

func (*Shell) Open

func (sh *Shell) Open() error

func (*Shell) Sync

func (sh *Shell) Sync(v interface{}) error

func (*Shell) Wait

func (sh *Shell) Wait() error

type Size

type Size struct {
	W float64
	H float64
}

type Window

type Window struct {
	handle.Handle

	Title        string
	Position     Point
	Size         Size
	Closable     bool
	Minimizable  bool
	Resizable    bool
	Background   *Color
	Borderless   bool
	CornerRadius float64
	AlwaysOnTop  bool
	IgnoreMouse  bool
	Center       bool
	URL          string
	Image        string
}
Example
sh := New(nil)
sh.Debug = os.Stderr
if err := sh.Open(); err != nil {
	log.Fatal(err)
}
defer sh.Close()

w := Window{
	Title:    "Title",
	Size:     Size{W: 480, H: 240},
	Position: Point{X: 0, Y: 0},
	Center:   true,
}

if err := sh.Sync(&w); err != nil {
	log.Fatal(err)
}

if w.Position.X == 0 {
	log.Fatal("expected position to change")
}

if err := sh.Discard(&w); err != nil {
	log.Fatal(err)
}

// // Output:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL