zenity/internal/zenutil/osa_generated.go

72 lines
2 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
2021-04-08 12:23:17 -04:00
import (
"encoding/json"
"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(`
2020-12-11 12:33:30 -05:00
{{define "color" -}}
2021-02-19 12:46:47 -05:00
var app=Application.currentApplication()
app.includeStandardAdditions=true
2021-02-18 21:20:57 -05:00
app.activate()
2021-02-19 12:46:47 -05:00
var res=app.chooseColor({defaultColor:{{json .}}})
{"rgb("+res.map(x=>Math.round(x*255))+")"}
2020-01-21 07:03:58 -05:00
{{- end}}
2021-03-04 21:01:59 -05:00
{{define "dialog" -}}
2021-02-19 12:46:47 -05:00
var app=Application.currentApplication()
app.includeStandardAdditions=true
2020-01-10 20:41:13 -05:00
app.activate()
2021-03-03 21:52:05 -05:00
ObjC.import("stdlib")
ObjC.import("stdio")
2021-03-03 11:05:11 -05:00
var res=app.{{.Operation}}({{json .Text}},{{json .Options}})
2021-03-03 21:52:05 -05:00
if(res.gaveUp){$.exit(5)}
if(res.buttonReturned==={{json .Extra}}){$.puts(res.buttonReturned)
$.exit(1)}
2021-03-04 21:01:59 -05:00
res.textReturned
{{- end}}
{{define "file" -}}
var app=Application.currentApplication()
app.includeStandardAdditions=true
app.activate()
var res=app.{{.Operation}}({{json .Options}})
if(Array.isArray(res)){res.join({{json .Separator}})}else{res.toString()}
2020-01-26 11:04:49 -05:00
{{- end}}
2021-04-07 09:16:35 -04:00
{{define "list" -}}
var app=Application.currentApplication()
app.includeStandardAdditions=true
var res=app.chooseFromList({{json .Items}},{{json .Options}})
res.join({{json .Separator}})
{{- end}}
2020-12-11 12:33:30 -05:00
{{define "notify" -}}
2021-02-19 12:46:47 -05:00
var app=Application.currentApplication()
app.includeStandardAdditions=true
void app.displayNotification({{json .Text}},{{json .Options}})
2020-01-21 07:03:58 -05:00
{{- end}}`))
2021-04-22 10:03:08 -04:00
var progress =`
var app=Application.currentApplication()
app.includeStandardAdditions=true
app.activate()
ObjC.import('stdlib')
ObjC.import('readline')
function run(args){Progress.totalUnitCount=100
Progress.completedUnitCount=0
Progress.description=args[0]||"Progress"
Progress.additionalDescription=args[1]||"Running..."
while(true){var s
try{s=$.readline('')}catch(e){if(e.errorNumber===-128)$.exit(1)
break}
if(s.indexOf('#')===0){Progress.additionalDescription=s.slice(1).trim()
continue}
var i=parseInt(s)
if(Number.isSafeInteger(i)){Progress.completedUnitCount=i
continue}}
Progress.completedUnitCount=100}`