diff --git a/private/web-racket.rkt b/private/web-racket.rkt index bcbf1d8..07c6d2d 100644 --- a/private/web-racket.rkt +++ b/private/web-racket.rkt @@ -640,12 +640,12 @@ (define/override (html-loaded) (ww-debug "HTML LOADED") (super html-loaded) - (let* ((btn (send this element 'app-button))) - (send btn connect 'click (λ (data) - (new test-dialog% [parent this])))) - (ww-debug "SETTING MENU") - (send this set-menu! test-menu) - (send this connect-menu! 'm-quit (λ () (send this close))) + ;(let* ((btn (send this element 'app-button))) + ; (send btn connect 'click (λ (data) + ; (new test-dialog% [parent this])))) + ;(ww-debug "SETTING MENU") + ;(send this set-menu! test-menu) + ;(send this connect-menu! 'm-quit (λ () (send this close))) ) (begin diff --git a/private/web-wire.rkt b/private/web-wire.rkt index 868aac5..cc7af3a 100644 --- a/private/web-wire.rkt +++ b/private/web-wire.rkt @@ -9,7 +9,6 @@ "../utils/utils.rkt" "css.rkt" "menu.rkt" - "webui-wire-ffi.rkt" "webui-wire-ipc.rkt" "webui-wire-download.rkt" ) @@ -174,6 +173,7 @@ [reader-thread #:mutable] [type #:mutable] ) + #:transparent ) (define ww-current-handle #f) @@ -251,12 +251,6 @@ (define process-log process-log-ipc) - (define (process-log-ffi kind* msg*) - (let ((kind (bytes->string/utf-8 kind*)) - (msg (bytes->string/utf-8 msg*))) - (put-in-fifo kind msg) - (ensure-fifo))) - (define (ww-do-display item filter) (let ((displ #f)) (when (eq? filter #f) @@ -322,21 +316,16 @@ (when (eq? ww-current-handle #f) (let ((h (make-web-rkt (if (eq? type 'ipc) (webui-ipc event-queuer-ipc process-log-ipc) - (let ((existing-h (webwire-current))) - (if (eq? existing-h #f) - (webwire-new) - existing-h))) + (error "ffi integration not implemented")) #f #f #f type))) (when (eq? type 'ffi) - (unless (eq? (webwire-status (web-rkt-handle h)) 'valid) - (error (format "Invalid handle, cannot start webui-wire ffi, reason: ~a" - (webwire-status->string (webwire-status (web-rkt-handle h))))))) + (error "ffi integration not implemented")) (let ((thrd (event-handler h))) (when (eq? type 'ffi) - (webwire-handlers! (web-rkt-handle h) event-queuer-ffi process-log-ffi)) + (error "ffi integration not implemented")) (set-web-rkt-event-thread! h thrd) (set! ww-current-handle h)) )) @@ -355,11 +344,12 @@ (let ((handler (hash-ref windows-evt-handlers win-id))) (handler 'destroyed #f))) keys)) - (ww-cmd "exit") + (with-handlers ([exn:fail? (λ (e) #t)]) + (ww-cmd "exit")) (let ((thr (web-rkt-event-thread ww-current-handle))) (kill-thread thr)) (when (eq? (web-rkt-type ww-current-handle) 'ffi) - (webwire-destroy (web-rkt-handle ww-current-handle))) + (error "ffi integration not implemented")) (set! ww-current-handle #f))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -429,7 +419,7 @@ (let* ((type (web-rkt-type ww-current-handle)) (result (if (eq? type 'ipc) ((web-rkt-handle ww-current-handle) cmd) - (webwire-command (web-rkt-handle ww-current-handle) cmd))) + (error "ffi implementation not implemented"))) ) (let ((r (convert-result result))) (check-nok cmd r) @@ -474,6 +464,9 @@ (define (any? v) #t) + (define (path-or-string? s) + (or (path? s) (string? s))) + (define (selector? s) (or (symbol? s) (string? s) (if (list? s) @@ -522,6 +515,7 @@ ((eq? type 'ww-win) (make-ww-win (string->number str))) ((eq? type 'void) 'void) ((eq? type 'css-style) (string->css-style str)) + ((eq? type 'path) (string->path str)) (else str))) (define (check-cmd-type v vname type typename) @@ -559,6 +553,9 @@ ((eq? type 'boolean?) (if (eq? v #f) 'false 'true)) ((eq? type 'symbol-or-string?) v) ((eq? type 'number?) v) + ((eq? type 'path-or-string?) (if (string? v) + v + (path->string v))) (else (begin (ww-error (format "Convert-arg-to-cmd Unexpected: ~a ~a ~a" vname type v)) v)))) @@ -726,15 +723,22 @@ ;; Web Wire Commands ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - + ;; Set the log level of webui-wire (def-cmd ww-log-level loglevel () ((level symbol?)) -> symbol) + + ;; Get the spoken protocol by webui-wire (def-cmd ww-protocol protocol () () -> int) + ;; Get/set the current directory of webui-wire + (def-cmd ww-cwd + cwd () [(path path-or-string?)] -> path) + ;; Global stylesheet (def-cmd ww-set-stylesheet set-stylesheet ((st stylesheet-or-string?)) () -> void) + (def-cmd ww-get-stylesheet get-stylesheet () () -> stylesheet) diff --git a/private/webui-wire-download.rkt b/private/webui-wire-download.rkt index a4adcf1..2cb1577 100644 --- a/private/webui-wire-download.rkt +++ b/private/webui-wire-download.rkt @@ -17,7 +17,8 @@ ;(define (current-release os) (define (ww-webui-wire) - (list "/home/hans/src/racket/webui-wire/build/Release/webui-wire") + (list "C:/devel/racket/webui-wire/build/Release/webui-wire.exe") + ;(list "/home/hans/src/racket/webui-wire/build/Release/webui-wire") ;(list "/usr/bin/flatpak" "run" "nl.dijkewijk.webui-wire") ;(list "/Users/hans/src/webui-wire/build/Release/webui-wire") ) diff --git a/private/webui-wire-ipc.rkt b/private/webui-wire-ipc.rkt index 1b86c19..166a6fc 100644 --- a/private/webui-wire-ipc.rkt +++ b/private/webui-wire-ipc.rkt @@ -14,6 +14,8 @@ #t #f))) + ;; This function only expects one character, namely \n + ;; In windows disable text mode on stdout/stderr of webui-wire. (define (read-eol port) (read-string 1 port))