USING: kernel io io.streams.duplex io.sockets namespaces sequences math math.parser threads quotations splitting ui ui.gadgets ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.tracks ui.tools.interactor ; IN: cabal.ui TUPLE: cabal-gadget input output ; : ( -- gadget ) gadget get cabal-gadget-output ; : ( -- gadget ) cabal-gadget construct-empty dup [ over dupd set-cabal-gadget-output 5/6 track, over dupd set-cabal-gadget-input 1/6 track, drop ] curry { 0 1 } build-track ; M: cabal-gadget pref-dim* drop { 550 650 } ; : cabal-stream ( cabal -- stream ) dup cabal-gadget-input swap cabal-gadget-output ; : incoming-loop ( stream -- ) dup stream-readln print incoming-loop ; : outgoing-loop ( stream -- ) readln over stream-print dup stream-flush outgoing-loop ; : cabal-thread ( -- ) "cabal://" write readln ":" split1 string>number [ outgoing-loop ] in-thread incoming-loop ; : cabal-client ( -- ) dup "Cabal Client" open-window cabal-stream [ [ cabal-thread ] with-stream ] in-thread drop ; : cabal-client* ( -- ) [ cabal-client ] with-ui ; MAIN: cabal-client*