diff --git a/scmvm.scm b/scmvm.scm index 074306e..ad1441c 100755 --- a/scmvm.scm +++ b/scmvm.scm @@ -3,16 +3,11 @@ exec guile -L . -e main -s "$0" "$@" !# (use-modules (rnrs bytevectors) (ice-9 binary-ports) + (ice-9 format) (srfi srfi-26) + (srfi srfi-43) (scmvm vm)) -(define the-vm #f) -(define the-program #f) - -(define (load-binary port) - (set! the-vm (make-vm)) - (set! the-program port)) - (eval-when (expand load eval) (use-modules (oop goops) (g-golf)) @@ -25,7 +20,25 @@ exec guile -L . -e main -s "$0" "$@" '("Application" "ApplicationWindow" "CallbackAction" - "FileDialog"))) + "FileDialog" + "Box" + "TextView"))) + +(define %vm (make-vm #:memory-size 100)) +(define %program #f) +(define %buffer #f) + +(define (load-binary port) + (set! %program port)) + +(define (update-memory-buffer!) + (when (and %buffer %vm) + (define ram (vm-memory %vm)) + (set-text %buffer "" 0) + (vector-for-each + (lambda (_ byte) + (insert-at-cursor %buffer (format #f "~2'0x " byte) 3)) + ram))) (define (open-file win cb) (define dialog (make )) @@ -57,6 +70,19 @@ exec guile -L . -e main -s "$0" "$@" "open-file" (lambda () (open-file win load-binary)))) + + (define box (make + #:orientation 'vertical)) + (define textview (make + #:vexpand #t + #:editable #f + #:cursor-visible #f + #:wrap-mode 'word)) + (set! %buffer (get-buffer textview)) + (update-memory-buffer!) + (append box textview) + (set-child win box) + (present win)) (define* (main #:optional args)