chiark / gitweb /
wip gui
authorian <ian>
Sat, 31 May 2008 21:35:12 +0000 (21:35 +0000)
committerian <ian>
Sat, 31 May 2008 21:35:12 +0000 (21:35 +0000)
hostside/gui [new file with mode: 0755]
hostside/gui-config [new file with mode: 0644]

diff --git a/hostside/gui b/hostside/gui
new file mode 100755 (executable)
index 0000000..1e17c59
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/wishx
+
+source lib.tcl
+
+proc widgets {} {
+    set sizes [exec ./gui-plan-bot --sizes]
+    frame .picture -background {} \
+           -width [lindex $sizes 0] \
+           -height [lindex $sizes 1]
+    pack .picture
+    tkwait visibility .picture
+}
+
+proc bgerror {emsg} {
+    global errorCode errorInfo
+    catch {
+       puts stderr "UNEXPECTED BACKGROUND ERROR\n"
+       puts stderr "$errorCode\n$errorInfo\n$emsg"
+    }
+    exit 16
+}
+
+proc gui-pipe-readable {args} {
+    global gui_pipe
+    while {[gets $gui_pipe l] >= 0} {
+       puts "<gui-plan $l"
+    }
+    if {[eof $gui_pipe]} {
+       close $gui_pipe
+       error "gui-plan crashed"
+    }
+}
+
+proc engage {} {
+    global gui_pipe server port
+    global sconn
+
+    set sconn [socket $server $port]
+    fconfig-trainproto $sconn
+
+    set cmdl [list ./gui-plan-bot [winfo id .picture] @$server,$port]
+    lappend cmdl 2>@ stderr
+    set gui_pipe [open |$cmdl r]
+
+    puts stderr "running $cmdl"
+    fconfigure $gui_pipe -blocking no
+    fileevent $gui_pipe readable gui-pipe-readable
+
+    start_commandloop
+}
+
+proc main {} {
+    setting server railway {[[0-9a-z:].*}
+    parse-argv {}
+    widgets
+    engage
+}
+
+main
diff --git a/hostside/gui-config b/hostside/gui-config
new file mode 100644 (file)
index 0000000..e8bbc45
--- /dev/null
@@ -0,0 +1,3 @@
+movpos
+
+