Skip to content

Commit ee2f4cf

Browse files
Updated custome handler abilities for menu, documentation, and connection handling
1 parent 461062a commit ee2f4cf

File tree

10 files changed

+493
-160
lines changed

10 files changed

+493
-160
lines changed

connection/connection.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func GetCommunicationChannels() (*Out, *In) {
6969
func Reader(out *Out, in *In) {
7070

7171
r := bufio.NewReader(StdOut)
72+
defer StdIn.Close()
7273
for {
7374
select {
7475
case quit := <-in.Quit:

demo.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ func main() {
3737
}
3838
out, in := connection.GetCommunicationChannels()
3939

40-
thrustWindow := window.Window{}
40+
thrustWindow := window.Window{
41+
Url: "file:///Users/mhernandez/jibe/go/src/github.com/miketheprogrammer/go-thrust/html/index.html",
42+
}
4143
rootMenu := menu.Menu{}
4244
fileMenu := menu.Menu{}
4345
checkList := menu.Menu{}
@@ -52,6 +54,9 @@ func main() {
5254

5355
fileMenu.Create(in)
5456
fileMenu.AddItem(3, "Open")
57+
fileMenu.RegisterEventHandlerByCommandID(4, func(reply commands.CommandResponse, item *menu.MenuItem) {
58+
os.Exit(2)
59+
})
5560
fileMenu.AddItem(4, "Close")
5661
fileMenu.AddSeparator()
5762

doc/commands.html

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Inter
149149

150150

151151

152-
<h2 id="Command">type <a href="/src/target/commands.go?s=731:1042#L18">Command</a></h2>
152+
<h2 id="Command">type <a href="/src/target/commands.go?s=901:1212#L21">Command</a></h2>
153153
<pre>type Command struct {
154-
ID <a href="/pkg/builtin/#int">int</a> `json:&#34;_id&#34;`
154+
ID <a href="/pkg/builtin/#uint">uint</a> `json:&#34;_id&#34;`
155155
Action <a href="/pkg/builtin/#string">string</a> `json:&#34;_action&#34;`
156156
ObjectType <a href="/pkg/builtin/#string">string</a> `json:&#34;_type,omitempty&#34;`
157157
Method <a href="/pkg/builtin/#string">string</a> `json:&#34;_method&#34;`
158-
TargetID <a href="/pkg/builtin/#int">int</a> `json:&#34;_target,omitempty&#34;`
158+
TargetID <a href="/pkg/builtin/#uint">uint</a> `json:&#34;_target,omitempty&#34;`
159159
Args <a href="#CommandArguments">CommandArguments</a> `json:&#34;_args&#34;`
160160
}</pre>
161161

@@ -172,7 +172,7 @@ <h2 id="Command">type <a href="/src/target/commands.go?s=731:1042#L18">Command</
172172

173173

174174

175-
<h3 id="Command.Send">func (Command) <a href="/src/target/commands.go?s=1044:1080#L27">Send</a></h3>
175+
<h3 id="Command.Send">func (Command) <a href="/src/target/commands.go?s=1214:1250#L30">Send</a></h3>
176176
<pre>func (c <a href="#Command">Command</a>) Send(conn <a href="/pkg/net/">net</a>.<a href="/pkg/net/#Conn">Conn</a>)</pre>
177177

178178

@@ -182,18 +182,21 @@ <h3 id="Command.Send">func (Command) <a href="/src/target/commands.go?s=1044:108
182182

183183

184184

185-
<h2 id="CommandArguments">type <a href="/src/target/commands.go?s=241:730#L6">CommandArguments</a></h2>
185+
<h2 id="CommandArguments">type <a href="/src/target/commands.go?s=243:900#L6">CommandArguments</a></h2>
186186
<pre>type CommandArguments struct {
187-
RootUrl <a href="/pkg/builtin/#string">string</a> `json:&#34;root_url,omitempty&#34;`
188-
Title <a href="/pkg/builtin/#string">string</a> `json:&#34;title,omitempty&#34;`
189-
Size <a href="#SizeHW">SizeHW</a> `json:&#34;size,omitempty&#34;`
190-
X <a href="/pkg/builtin/#int">int</a> `json:&#34;x,omitempty&#34;`
191-
Y <a href="/pkg/builtin/#int">int</a> `json:&#34;y,omitempty&#34;`
192-
CommandID <a href="/pkg/builtin/#int">int</a> `json:&#34;command_id,omitempty&#34;`
193-
Label <a href="/pkg/builtin/#string">string</a> `json:&#34;label,omitempty&#34;`
194-
MenuID <a href="/pkg/builtin/#int">int</a> `json:&#34;menu_id,omitempty&#34;` <span class="comment">// this should never be 0 anyway</span>
195-
GroupID <a href="/pkg/builtin/#int">int</a> `json:&#34;group_id,omitempty&#34;`
196-
Value <a href="/pkg/builtin/#bool">bool</a> `json:&#34;value&#34;`
187+
RootUrl <a href="/pkg/builtin/#string">string</a> `json:&#34;root_url,omitempty&#34;`
188+
Title <a href="/pkg/builtin/#string">string</a> `json:&#34;title,omitempty&#34;`
189+
Size <a href="#SizeHW">SizeHW</a> `json:&#34;size,omitempty&#34;`
190+
X <a href="/pkg/builtin/#int">int</a> `json:&#34;x,omitempty&#34;`
191+
Y <a href="/pkg/builtin/#int">int</a> `json:&#34;y,omitempty&#34;`
192+
CommandID <a href="/pkg/builtin/#uint">uint</a> `json:&#34;command_id,omitempty&#34;`
193+
Label <a href="/pkg/builtin/#string">string</a> `json:&#34;label,omitempty&#34;`
194+
MenuID <a href="/pkg/builtin/#uint">uint</a> `json:&#34;menu_id,omitempty&#34;` <span class="comment">// this should never be 0 anyway</span>
195+
WindowID <a href="/pkg/builtin/#uint">uint</a> `json:&#34;window_id,omitempty&#34;`
196+
GroupID <a href="/pkg/builtin/#uint">uint</a> `json:&#34;group_id,omitempty&#34;`
197+
Value <a href="/pkg/builtin/#bool">bool</a> `json:&#34;value&#34;`
198+
CookieStore <a href="/pkg/builtin/#bool">bool</a> `json:&#34;cookie_store&#34;`
199+
OffTheRecord <a href="/pkg/builtin/#bool">bool</a> `json:&#34;off_the_record&#34;`
197200
}</pre>
198201
<p>
199202
Covers all possible argument combinations.
@@ -215,11 +218,11 @@ <h2 id="CommandArguments">type <a href="/src/target/commands.go?s=241:730#L6">Co
215218

216219

217220

218-
<h2 id="CommandResponse">type <a href="/src/target/commands.go?s=1346:1606#L42">CommandResponse</a></h2>
221+
<h2 id="CommandResponse">type <a href="/src/target/commands.go?s=1519:1779#L45">CommandResponse</a></h2>
219222
<pre>type CommandResponse struct {
220223
Action <a href="/pkg/builtin/#string">string</a> `json:&#34;_action,omitempty&#34;`
221224
Error <a href="/pkg/builtin/#string">string</a> `json:&#34;_error,omitempty&#34;`
222-
ID <a href="/pkg/builtin/#int">int</a> `json:&#34;_id,omitempty&#34;`
225+
ID <a href="/pkg/builtin/#uint">uint</a> `json:&#34;_id,omitempty&#34;`
223226
Result <a href="#ReplyResult">ReplyResult</a> `json:&#34;_result,omitempty&#34;`
224227
Event <a href="#EventResult">EventResult</a> `json:&#34;_event,omitempty&#34;`
225228
}</pre>
@@ -239,10 +242,10 @@ <h2 id="CommandResponse">type <a href="/src/target/commands.go?s=1346:1606#L42">
239242

240243

241244

242-
<h2 id="EventResult">type <a href="/src/target/commands.go?s=1224:1344#L37">EventResult</a></h2>
245+
<h2 id="EventResult">type <a href="/src/target/commands.go?s=1395:1517#L40">EventResult</a></h2>
243246
<pre>type EventResult struct {
244-
CommandID <a href="/pkg/builtin/#int">int</a> `json:&#34;command_id,omitempty&#34;`
245-
EventFlags <a href="/pkg/builtin/#int">int</a> `json:&#34;event_flags,omitempty&#34;`
247+
CommandID <a href="/pkg/builtin/#uint">uint</a> `json:&#34;command_id,omitempty&#34;`
248+
EventFlags <a href="/pkg/builtin/#int">int</a> `json:&#34;event_flags,omitempty&#34;`
246249
}</pre>
247250

248251

@@ -260,9 +263,9 @@ <h2 id="EventResult">type <a href="/src/target/commands.go?s=1224:1344#L37">Even
260263

261264

262265

263-
<h2 id="ReplyResult">type <a href="/src/target/commands.go?s=1154:1222#L33">ReplyResult</a></h2>
266+
<h2 id="ReplyResult">type <a href="/src/target/commands.go?s=1324:1393#L36">ReplyResult</a></h2>
264267
<pre>type ReplyResult struct {
265-
TargetID <a href="/pkg/builtin/#int">int</a> `json:&#34;_target,omitempty&#34;`
268+
TargetID <a href="/pkg/builtin/#uint">uint</a> `json:&#34;_target,omitempty&#34;`
266269
}</pre>
267270

268271

@@ -280,10 +283,10 @@ <h2 id="ReplyResult">type <a href="/src/target/commands.go?s=1154:1222#L33">Repl
280283

281284

282285

283-
<h2 id="SizeHW">type <a href="/src/target/commands.go?s=37:134#L1">SizeHW</a></h2>
286+
<h2 id="SizeHW">type <a href="/src/target/commands.go?s=37:136#L1">SizeHW</a></h2>
284287
<pre>type SizeHW struct {
285-
Width <a href="/pkg/builtin/#int">int</a> `json:&#34;width,omitempty&#34;`
286-
Height <a href="/pkg/builtin/#int">int</a> `json:&#34;height,omitempty&#34;`
288+
Width <a href="/pkg/builtin/#uint">uint</a> `json:&#34;width,omitempty&#34;`
289+
Height <a href="/pkg/builtin/#uint">uint</a> `json:&#34;height,omitempty&#34;`
287290
}</pre>
288291

289292

doc/common.html

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
5757
<dd><a href="#pkg-variables">Variables</a></dd>
5858

5959

60+
61+
<dd><a href="#InitLogger">func InitLogger()</a></dd>
62+
6063

6164

6265
</dl>
@@ -118,22 +121,36 @@ <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Inter
118121
<h2 id="pkg-constants">Constants</h2>
119122

120123
<pre>const (
121-
<span id="SOCKET_BOUNDARY">SOCKET_BOUNDARY</span> = &#34;--(Foo)++__THRUST_SHELL_BOUNDARY__++(Bar)--&#34;
124+
<span id="SOCKET_BOUNDARY">SOCKET_BOUNDARY</span> = &#34;--(Foo)++__THRUST_SHELL_BOUNDARY__++(Bar)--&#34;
125+
<span id="THRUST_VERSION">THRUST_VERSION</span> = &#34;0.7.0&#34;
126+
<span id="THRUST_GO_VERSION">THRUST_GO_VERSION</span> = &#34;0.1.0&#34;
122127
)</pre>
123128

124129

125130

126131

127132
<h2 id="pkg-variables">Variables</h2>
128133

129-
<pre>var <span id="ActionId">ActionId</span> <a href="/pkg/builtin/#int">int</a> = 0</pre>
134+
<pre>var <span id="ActionId">ActionId</span> <a href="/pkg/builtin/#uint">uint</a> = 0</pre>
130135
<p>
131136
Global ID tracking for Commands
132137
Could probably move this to a factory function
133138
</p>
134139

135140

141+
<pre>var <span id="Log">Log</span> <a href="/pkg/github.com/alexcesaro/log/">log</a>.<a href="/pkg/github.com/alexcesaro/log/#Logger">Logger</a></pre>
142+
143+
144+
136145

146+
147+
148+
<h2 id="InitLogger">func <a href="/src/target/common.go?s=355:372#L10">InitLogger</a></h2>
149+
<pre>func InitLogger()</pre>
150+
151+
152+
153+
137154

138155

139156

0 commit comments

Comments
 (0)