zenity/internal/zenutil/osa_generated.go

80 lines
1.9 KiB
Go
Raw Normal View History

2020-01-10 20:41:13 -05:00
// Code generated by zenity; DO NOT EDIT.
// +build darwin
2020-01-19 06:57:05 -05:00
package zenutil
2020-01-10 20:41:13 -05:00
2020-01-21 07:03:58 -05:00
import "encoding/json"
import "text/template"
2020-01-10 20:41:13 -05:00
2020-01-21 07:03:58 -05:00
var scripts = template.Must(template.New("").Funcs(template.FuncMap{"json": func(v interface{}) (string, error) {
b, err := json.Marshal(v)
return string(b), err
}}).Parse(`
{{define "color" -}}tell application (path to frontmost application as text)
activate
2020-01-18 23:28:06 -05:00
{{if .Color -}}
2020-01-23 06:44:28 -05:00
set c to choose color default color { {{index .Color 0}},{{index .Color 1}},{{index .Color 2}} }
2020-01-21 07:03:58 -05:00
{{else -}}
set c to choose color
{{end}}
2020-01-21 11:13:45 -05:00
"rgb(" & (item 1 of c) div 256 & "," & (item 2 of c) div 256 & "," & (item 3 of c) div 256 & ")"
2020-01-21 07:03:58 -05:00
end tell
{{- end}}
{{define "file" -}}var app = Application.currentApplication()
2020-01-10 20:41:13 -05:00
app.includeStandardAdditions = true
app.activate()
var opts = {}
2020-01-14 20:04:06 -05:00
{{if .Prompt -}}
2020-01-21 07:03:58 -05:00
opts.withPrompt = {{json .Prompt}}
2020-01-14 20:04:06 -05:00
{{end -}}
2020-01-10 20:41:13 -05:00
{{if .Type -}}
2020-01-21 07:03:58 -05:00
opts.ofType = {{json .Type}}
2020-01-10 20:41:13 -05:00
{{end -}}
{{if .Name -}}
2020-01-21 07:03:58 -05:00
opts.defaultName = {{json .Name}}
2020-01-10 20:41:13 -05:00
{{end -}}
{{if .Location -}}
2020-01-21 07:03:58 -05:00
opts.defaultLocation = {{json .Location}}
2020-01-10 20:41:13 -05:00
{{end -}}
2020-01-14 20:04:06 -05:00
{{if .Invisibles -}}
2020-01-21 07:03:58 -05:00
opts.invisibles = {{json .Invisibles}}
2020-01-14 20:04:06 -05:00
{{end -}}
{{if .Multiple -}}
2020-01-21 07:03:58 -05:00
opts.multipleSelectionsAllowed = {{json .Multiple}}
2020-01-14 20:04:06 -05:00
{{end -}}
2020-01-21 07:03:58 -05:00
var res = app[{{json .Operation}}](opts)
2020-01-10 20:41:13 -05:00
if (Array.isArray(res)) {
2020-01-21 07:03:58 -05:00
res.join({{json .Separator}})
2020-01-10 20:41:13 -05:00
} else {
res.toString()
}
2020-01-21 07:03:58 -05:00
{{- end}}
{{define "msg" -}}var app = Application.currentApplication()
2020-01-10 20:41:13 -05:00
app.includeStandardAdditions = true
app.activate()
var opts = {}
{{if .Message -}}
2020-01-21 07:03:58 -05:00
opts.message = {{json .Message}}
2020-01-10 20:41:13 -05:00
{{end -}}
{{if .As -}}
2020-01-21 07:03:58 -05:00
opts.as = {{json .As}}
2020-01-10 20:41:13 -05:00
{{end -}}
{{if .Title -}}
2020-01-21 07:03:58 -05:00
opts.withTitle = {{json .Title}}
2020-01-10 20:41:13 -05:00
{{end -}}
{{if .Icon -}}
2020-01-21 07:03:58 -05:00
opts.withIcon = {{json .Icon}}
2020-01-10 20:41:13 -05:00
{{end -}}
{{if .Buttons -}}
2020-01-21 07:03:58 -05:00
opts.buttons = {{json .Buttons}}
2020-01-10 20:41:13 -05:00
{{end -}}
{{if .Default -}}
2020-01-21 07:03:58 -05:00
opts.defaultButton = {{json .Default}}
2020-01-10 20:41:13 -05:00
{{end -}}
{{if .Cancel -}}
2020-01-21 07:03:58 -05:00
opts.cancelButton = {{json .Cancel}}
2020-01-10 20:41:13 -05:00
{{end -}}
2020-01-21 07:03:58 -05:00
var res = app[{{json .Operation}}]({{json .Text}}, opts).buttonReturned
res === {{json .Extra}} ? res : void 0
{{- end}}`))