;;;; client.scm (use rfb srfi-18 matchable ansi-escape-sequences extras posix miscmacros) (define-optionals ((host "localhost") (count "100000")) (command-line-arguments)) (define rfb (rfb-connect host)) (thread-sleep! 1) (print* (erase-display)) (set-pixel-format rfb (pixel-format bits-per-pixel: 8 depth: 6 red-max: 3 green-max: 3 blue-max: 3 red-shift: 4 green-shift: 2 blue-shift: 0)) (define fw (rfb-session-width rfb)) (define fh (rfb-session-height rfb)) (framebuffer-update-request rfb 0 0 fw fh #f) (let loop ((i (string->number count))) (when (positive? i) (framebuffer-update-request rfb 0 0 fw fh #t) (thread-sleep! 0.1) (match (read-server-message rfb) ((? eof-object?) #f) (('FramebufferUpdate rects ...) (for-each (lambda (rect) (match rect (('Raw #(x y w h data)) (do ((i 0 (add1 i))) ((>= i h)) (do ((j 0 (add1 j))) ((>= j w)) (print* (cursor-position (+ y i) (+ x j)) (if (zero? (u8vector-ref data (+ j (* i w)))) #\. #\*))))) (msg #f))) rects) (loop (sub1 i))) (_ (loop (sub1 i)))))) (print* (erase-display)) (rfb-close rfb)