Start memory view
This commit is contained in:
parent
0c029118f0
commit
feb07d43c8
42
scmvm.scm
42
scmvm.scm
@ -3,16 +3,11 @@ exec guile -L . -e main -s "$0" "$@"
|
|||||||
!#
|
!#
|
||||||
(use-modules (rnrs bytevectors)
|
(use-modules (rnrs bytevectors)
|
||||||
(ice-9 binary-ports)
|
(ice-9 binary-ports)
|
||||||
|
(ice-9 format)
|
||||||
(srfi srfi-26)
|
(srfi srfi-26)
|
||||||
|
(srfi srfi-43)
|
||||||
(scmvm vm))
|
(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)
|
(eval-when (expand load eval)
|
||||||
(use-modules (oop goops)
|
(use-modules (oop goops)
|
||||||
(g-golf))
|
(g-golf))
|
||||||
@ -25,7 +20,25 @@ exec guile -L . -e main -s "$0" "$@"
|
|||||||
'("Application"
|
'("Application"
|
||||||
"ApplicationWindow"
|
"ApplicationWindow"
|
||||||
"CallbackAction"
|
"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 (open-file win cb)
|
||||||
(define dialog (make <gtk-file-dialog>))
|
(define dialog (make <gtk-file-dialog>))
|
||||||
@ -57,6 +70,19 @@ exec guile -L . -e main -s "$0" "$@"
|
|||||||
"open-file"
|
"open-file"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(open-file win load-binary))))
|
(open-file win load-binary))))
|
||||||
|
|
||||||
|
(define box (make <gtk-box>
|
||||||
|
#:orientation 'vertical))
|
||||||
|
(define textview (make <gtk-text-view>
|
||||||
|
#: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))
|
(present win))
|
||||||
|
|
||||||
(define* (main #:optional args)
|
(define* (main #:optional args)
|
||||||
|
Loading…
Reference in New Issue
Block a user