Basic input and output now can be done through gui

This commit is contained in:
Ibrahim Mkusa 2017-04-23 03:50:12 -04:00
parent a1798d9e3d
commit ed5d1d7571
3 changed files with 30 additions and 5 deletions

View File

@ -13,6 +13,11 @@
(provide make-gui)
; store input into a message list
; will create closure later
(define messages '())
; (define-values (gui-in gui-out) (make-pipe #f))
(define (make-gui)
;;Create the frame/window with title "Example5", width 500 and height 700
(define main-frame (new frame%
@ -68,11 +73,28 @@
(if (color-change-request? (send input get-value))
(set! my-color (get-color-from-input (send input get-value)))
(if (< 0 (string-length (send input get-value)))
(send-message (send input get-value) my-color);;
(begin
; (send-message (send input get-value) my-color);;
(set! messages (append messages (list (send input get-value))))
; (open-input-string )
)
'()))
(send input set-value "")
)
(define (get-message)
(define one-message
(if (not (null? messages))
(begin
;(define msg (car messages))
(car messages)
;(set! messages (cdr messages))
)
'()))
(if (not (string? one-message))
(get-message)
(begin (set! messages (cdr messages))
one-message)))
; creates the send button
(define send-button (new button%
[parent main-frame]
@ -99,6 +121,7 @@
(substring str start (+ start index))
(helper str (+ index 1))))
(helper string-i 0))
;; draws a user input to the screen
(define (user-message user-input)
@ -181,6 +204,7 @@
;;Something up with that
; else should assume a message and output to screen we do not want it
; to fail
((eq? command 'get-message) get-message)
(else (error "Invalid Request" command))
))
;;dispatch goes below that

View File

@ -12,7 +12,7 @@
(define hermes-gui (make-gui)) ;; our gui
((hermes-gui 'show))
(sleep 0.25)
;(sleep 0.25)
(define host3 "localhost")
@ -20,7 +20,7 @@
(define sleep-t 0.1)
; we won't need this. Just me being overzealous
(define hermes-conf (open-output-file "./hermes_client.conf" #:exists'append))
(define hermes-conf (open-output-file "./hermes_client.conf" #:exists 'append))
(define hermes-conf-s (make-semaphore 1))
(define convs-out (open-output-file "./convs_client.out" #:exists 'append))
@ -93,7 +93,8 @@
" | "))
;; read, quits when user types in "quit"
;; TODO read from GUI instead
(define input (read-line))
;(define input (read-line))
(define input ((hermes-gui 'get-message)))
; TODO /quit instead of quit
(cond ((string=? input "quit")
(displayln (string-append date-print username " signing out. See ya!") out)

View File

@ -186,7 +186,7 @@
(define list-count (regexp-match #px"(.*)/list\\s+count\\s*" evt-t0)) ;; is client asking for number of logged in users
(define list-users (regexp-match #px"(.*)/list\\s+users\\s*" evt-t0)) ;; user names
; do something whether it was a message, a whisper, request for number of users and so on
; TODO if user doesn't exist handle it
; TODO if user doesn't exist handle it********
(cond [whisper
(semaphore-wait connections-s)
; get output port for user