|
|
@ -1,6 +1,8 @@
|
|
|
|
#lang debug racket/gui
|
|
|
|
#lang debug racket/gui
|
|
|
|
(require pollen/private/log
|
|
|
|
(require pollen/private/log
|
|
|
|
pollen/private/command)
|
|
|
|
pollen/private/command
|
|
|
|
|
|
|
|
pollen/setup
|
|
|
|
|
|
|
|
pollen/private/project-server)
|
|
|
|
|
|
|
|
|
|
|
|
(define app-mono-fam
|
|
|
|
(define app-mono-fam
|
|
|
|
(for*/first ([preferred
|
|
|
|
(for*/first ([preferred
|
|
|
@ -14,7 +16,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(define window (new frame% [label "Pollen Helper"]
|
|
|
|
(define window (new frame% [label "Pollen Helper"]
|
|
|
|
[width 700]
|
|
|
|
[width 700]
|
|
|
|
[height 700]
|
|
|
|
[height 500]
|
|
|
|
[x 40]
|
|
|
|
[x 40]
|
|
|
|
[y 40]
|
|
|
|
[y 40]
|
|
|
|
[alignment '(left top)]
|
|
|
|
[alignment '(left top)]
|
|
|
@ -28,6 +30,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(define hpanel-select (make-hpanel))
|
|
|
|
(define hpanel-select (make-hpanel))
|
|
|
|
(define current-manager-directory (make-parameter #f))
|
|
|
|
(define current-manager-directory (make-parameter #f))
|
|
|
|
|
|
|
|
(define current-server-stopper (make-parameter #f))
|
|
|
|
|
|
|
|
|
|
|
|
(define (set-current-manager-directory val)
|
|
|
|
(define (set-current-manager-directory val)
|
|
|
|
(current-manager-directory val)
|
|
|
|
(current-manager-directory val)
|
|
|
@ -38,7 +41,11 @@
|
|
|
|
(new button%
|
|
|
|
(new button%
|
|
|
|
[label str]
|
|
|
|
[label str]
|
|
|
|
[parent hpanel-select]
|
|
|
|
[parent hpanel-select]
|
|
|
|
[callback (λ (button evt) (set-current-manager-directory (get-directory str)))])))
|
|
|
|
[callback (λ (button evt)
|
|
|
|
|
|
|
|
(define dir (get-directory str))
|
|
|
|
|
|
|
|
(when dir
|
|
|
|
|
|
|
|
(set-current-manager-directory dir)
|
|
|
|
|
|
|
|
(set-server-port (setup:project-server-port dir))))])))
|
|
|
|
|
|
|
|
|
|
|
|
(define directory-msg
|
|
|
|
(define directory-msg
|
|
|
|
(new message%
|
|
|
|
(new message%
|
|
|
@ -46,16 +53,61 @@
|
|
|
|
[parent hpanel-select]
|
|
|
|
[parent hpanel-select]
|
|
|
|
[auto-resize #true]))
|
|
|
|
[auto-resize #true]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define hpanel-server-options (make-hpanel))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define server-option-port
|
|
|
|
|
|
|
|
(new text-field%
|
|
|
|
|
|
|
|
[parent hpanel-server-options]
|
|
|
|
|
|
|
|
[label "server port"]
|
|
|
|
|
|
|
|
[min-width 150]
|
|
|
|
|
|
|
|
[stretchable-width #false]
|
|
|
|
|
|
|
|
[init-value (number->string (setup:project-server-port))]
|
|
|
|
|
|
|
|
[callback (λ (tf evt)
|
|
|
|
|
|
|
|
(set-server-port (string->number (send tf get-value))))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (set-server-port num)
|
|
|
|
|
|
|
|
(when (number? num)
|
|
|
|
|
|
|
|
(current-server-port num)
|
|
|
|
|
|
|
|
(send server-option-port set-value (number->string num))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define server-option-local
|
|
|
|
|
|
|
|
(new check-box%
|
|
|
|
|
|
|
|
[parent hpanel-server-options]
|
|
|
|
|
|
|
|
[label "local only"]
|
|
|
|
|
|
|
|
[callback (λ (cb evt)
|
|
|
|
|
|
|
|
(current-server-listen-ip (and (send cb get-value) "127.0.0.1")))]))
|
|
|
|
|
|
|
|
|
|
|
|
(define hpanel-server-controls (make-hpanel))
|
|
|
|
(define hpanel-server-controls (make-hpanel))
|
|
|
|
|
|
|
|
|
|
|
|
(define (make-alert str)
|
|
|
|
(define dialog-alert (new dialog%
|
|
|
|
(define d (new dialog%
|
|
|
|
[label "Error"]
|
|
|
|
[label str]
|
|
|
|
[border 6]
|
|
|
|
[width 300]
|
|
|
|
[spacing 6]
|
|
|
|
[height 300]
|
|
|
|
|
|
|
|
[parent #f]))
|
|
|
|
[parent #f]))
|
|
|
|
#R d
|
|
|
|
|
|
|
|
#R (send d show #f))
|
|
|
|
(define dialog-message (new message%
|
|
|
|
|
|
|
|
[parent dialog-alert]
|
|
|
|
|
|
|
|
[auto-resize #t]
|
|
|
|
|
|
|
|
[label ""]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define dialog-alert-button-pane
|
|
|
|
|
|
|
|
(new horizontal-pane%
|
|
|
|
|
|
|
|
[parent dialog-alert]
|
|
|
|
|
|
|
|
[alignment '(right bottom)]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define dialog-alert-button-ok
|
|
|
|
|
|
|
|
(new button%
|
|
|
|
|
|
|
|
[parent dialog-alert-button-pane]
|
|
|
|
|
|
|
|
[label "OK"]
|
|
|
|
|
|
|
|
[style '(border)]
|
|
|
|
|
|
|
|
[callback (λ (button evt)
|
|
|
|
|
|
|
|
(send dialog-alert show #f))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (make-alert str)
|
|
|
|
|
|
|
|
(send dialog-message set-label str)
|
|
|
|
|
|
|
|
(send dialog-alert show #t))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define button-start
|
|
|
|
(define button-start
|
|
|
|
(new button%
|
|
|
|
(new button%
|
|
|
@ -63,22 +115,43 @@
|
|
|
|
[parent hpanel-server-controls]
|
|
|
|
[parent hpanel-server-controls]
|
|
|
|
[callback (λ (button evt)
|
|
|
|
[callback (λ (button evt)
|
|
|
|
(match (current-manager-directory)
|
|
|
|
(match (current-manager-directory)
|
|
|
|
[#false (make-alert "boo")]
|
|
|
|
[#false (make-alert "No project directory selected.")]
|
|
|
|
[dir
|
|
|
|
[dir
|
|
|
|
(with-logging-to-port
|
|
|
|
(message "starting project server")
|
|
|
|
(current-error-port)
|
|
|
|
(define cthd (current-thread))
|
|
|
|
(λ () (start-project-server dir))
|
|
|
|
(define server-thd
|
|
|
|
#:logger pollen-logger
|
|
|
|
(thread (λ ()
|
|
|
|
'info
|
|
|
|
(parameterize ([current-project-root dir])
|
|
|
|
'pollen)]))]))
|
|
|
|
(define stop
|
|
|
|
|
|
|
|
(start-server (format "/~a" (setup:main-pagetree dir)) #:serve-only #true))
|
|
|
|
|
|
|
|
(thread-send cthd stop)
|
|
|
|
|
|
|
|
(with-handlers ([exn:break? (λ (e) (stop))])
|
|
|
|
|
|
|
|
(sync/enable-break never-evt))))))
|
|
|
|
|
|
|
|
(current-server-stopper (thread-receive))]))]))
|
|
|
|
|
|
|
|
|
|
|
|
(define button-stop
|
|
|
|
(define button-stop
|
|
|
|
(new button%
|
|
|
|
(new button%
|
|
|
|
[label "Stop project server"]
|
|
|
|
[label "Stop project server"]
|
|
|
|
[parent hpanel-server-controls]
|
|
|
|
[parent hpanel-server-controls]
|
|
|
|
[callback (λ (button evt) (void))]))
|
|
|
|
[callback (λ (button evt)
|
|
|
|
|
|
|
|
(match (current-server-stopper)
|
|
|
|
|
|
|
|
[#false (make-alert "Project server not running.")]
|
|
|
|
|
|
|
|
[stopper-proc
|
|
|
|
|
|
|
|
(stopper-proc)
|
|
|
|
|
|
|
|
(current-server-stopper #false)
|
|
|
|
|
|
|
|
(message "project server stopped")]))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define button-launch
|
|
|
|
|
|
|
|
(new button%
|
|
|
|
|
|
|
|
[label "Launch browser"]
|
|
|
|
|
|
|
|
[parent hpanel-server-controls]
|
|
|
|
|
|
|
|
[callback (λ (button evt)
|
|
|
|
|
|
|
|
(match (current-server-stopper)
|
|
|
|
|
|
|
|
[#false (make-alert "Project server not running.")]
|
|
|
|
|
|
|
|
[dir #R 'wish-i-could-launch]))]))
|
|
|
|
|
|
|
|
|
|
|
|
(define wordbox (let* ([wb (new text-field%
|
|
|
|
(define status-box
|
|
|
|
|
|
|
|
(let* ([wb (new text-field%
|
|
|
|
[label #f]
|
|
|
|
[label #f]
|
|
|
|
[style '(multiple)]
|
|
|
|
[style '(multiple)]
|
|
|
|
[parent window]
|
|
|
|
[parent window]
|
|
|
@ -88,6 +161,16 @@
|
|
|
|
(send ed set-padding 6 3 6 3)
|
|
|
|
(send ed set-padding 6 3 6 3)
|
|
|
|
wb))
|
|
|
|
wb))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define status-box-ed (send status-box get-editor))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define log-receiver-thread
|
|
|
|
|
|
|
|
(thread (λ ()
|
|
|
|
|
|
|
|
(define rcvr (make-log-receiver pollen-logger 'info 'pollen))
|
|
|
|
|
|
|
|
(for ([vec (in-producer (λ () (sync rcvr)))])
|
|
|
|
|
|
|
|
(match-define (vector _ msg _ _) vec)
|
|
|
|
|
|
|
|
(send status-box-ed insert msg)
|
|
|
|
|
|
|
|
(send status-box-ed insert "\n")
|
|
|
|
|
|
|
|
(sleep 0)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(send window show #t)
|
|
|
|
(send window show #t)
|
|
|
|