This repository has been archived by the owner on Mar 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathatom.go
188 lines (154 loc) · 5.16 KB
/
atom.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
package atom
import "github.com/gopherjs/gopherjs/js"
var atom js.Object
var atomApi js.Object
// Commands doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-commands
var Commands *CommandRegistry
// Workspace doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-workspace
var Workspace *WorkspaceT
func init() {
atomApi = js.Global.Call("require", "atom")
atom = js.Global.Get("atom")
Commands = new(CommandRegistry)
Commands.o = atom.Get("commands")
Workspace = new(WorkspaceT)
Workspace.o = atom.Get("workspace")
}
func Activate(callback func()) {
js.Module.Get("exports").Set("activate", callback)
}
// OnDidBeep doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-onDidBeep
func OnDidBeep(callback func()) Disposable {
return &disposableImpl{o: atom.Call("onDidBeep", callback)}
}
// OnWillThrowError doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-onWillThrowError
// TODO: THIS NEEDS TESTING!
func OnWillThrowError(callback func(*Event)) Disposable {
// catch the js event object and convert it into a Event type and call the orginal callback
disposable := &disposableImpl{}
disposable.o = atom.Call("onWillThrowError", func(jsEvent js.Object) {
event := newEventFromJsObject(jsEvent)
callback(event)
})
return disposable
}
// OnDidThrowError doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-onDidThrowError
// TODO: THIS NEEDS TESTING!
func OnDidThrowError(callback func(*Event)) Disposable {
disposable := &disposableImpl{}
disposable.o = atom.Call("onDidThrowError", func(jsEvent js.Object) {
event := newEventFromJsObject(jsEvent)
callback(event)
})
return disposable
}
// InDevMode doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-inDevMode
func InDevMode() bool {
return atom.Call("inDevMode").Bool()
}
// InSafeMode doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-inSafeMode
func InSafeMode() bool {
return atom.Call("inSafeMode").Bool()
}
// InSpecMode doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-inSpecMode
func InSpecMode() bool {
return atom.Call("inSpecMode").Bool()
}
// GetVersion doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-getVersion
func GetVersion() string {
return atom.Call("getVersion").Str()
}
// IsReleasedVersion doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-isReleasedVersion
func IsReleasedVersion() bool {
return atom.Call("isReleasedVersion").Bool()
}
// GetWindowLoadTime doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-getWindowLoadTime
func GetWindowLoadTime() int {
return atom.Call("getWindowLoadTime").Int()
}
// Open doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-open
func Open(options *OpenOptions) {
if options == nil {
options = &OpenOptions{}
}
atom.Call("open", options)
}
// Close doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-close
func Close() {
atom.Call("close")
}
// GetSize doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-getSize
// The only difference is the values are retuned sperated not as an object.
func GetSize() (width, heigth int) {
jsObject := atom.Call("getSize")
width = jsObject.Get("width").Int()
heigth = jsObject.Get("heigth").Int()
return
}
// SetSize doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-setSize
func SetSize(width, heigth int) {
atom.Call("setSize", width, heigth)
}
// GetPosition doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-getPosition
func GetPosition() (x, y int) {
jsObject := atom.Call("getPosition")
x = jsObject.Get("x").Int()
y = jsObject.Get("y").Int()
return
}
// Center doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-center
func Center() {
atom.Call("center")
}
// Focus doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-focus
func Focus() {
atom.Call("focus")
}
// Show doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-show
func Show() {
atom.Call("show")
}
// Hide doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-hide
func Hide() {
atom.Call("hide")
}
// Reload doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-reload
func Reload() {
atom.Call("reload")
}
// IsMaximixed doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-isMaximixed
func IsMaximixed() bool {
return atom.Call("isMaximixed").Bool()
}
// IsFullScreen doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-isFullScreen
func IsFullScreen() bool {
return atom.Call("isFullScreen").Bool()
}
// SetFullScreen doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-setFullScreen
func SetFullScreen() {
atom.Call("setFullScreen")
}
// ToggleFullScreen doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-toggleFullScreen
func ToggleFullScreen() {
atom.Call("toggleFullScreen")
}
// Beep doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-beep
func Beep() {
atom.Call("beep")
}
// Confirm doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-confirm
func Confirm(options *ConfirmOption) int {
index := -1
index = atom.Call("confirm", options.toJsObject()).Int()
return index
}
// OpenDevTools doc at: https://atom.io/docs/api/v0.165.0/Atom#instance-openDevTools
func OpenDevTools() {
atom.Call("openDevTools")
}
func ToggleDevTools() {
atom.Call("toggleDevTools")
}
func ExecuteJavaScriptInDevTools() {
atom.Call("executeJavaScriptInDevTools")
}