Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
hayato-hashimoto committed Dec 8, 2011
1 parent 80427d2 commit 61d49a3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
17 changes: 9 additions & 8 deletions 1/paint.scm
Expand Up @@ -105,18 +105,19 @@
((frame)
(size)
(document)
(document-overlay)
(document-by-id)
(document-uri-internal)
(document-uri
:allocation :virtual
:slot-ref
(^w (slot-ref w 'document-uri-internal))
:slot-set!
(^(w uri)
(slot-set! w 'document-uri-internal uri)
(let1 pair (spd-parse (open-input-file (~ window 'document-uri)))
(set! (~ window 'document-by-id) (cadr pair))
(set! (~ window 'document) (car pair)))))
(^(self uri)
(slot-set! self 'document-uri-internal uri)
(let1 pair (spd-parse (open-input-file (~ self 'document-uri)))
(set! (~ self 'document-by-id) (cadr pair))
(set! (~ self 'document) (car pair)))))
(stylesheet)
(stylesheet-uri)
(cairo)
Expand Down Expand Up @@ -159,9 +160,9 @@
(define meter% #f)
(define-method paint ((w <window>))
(set! meter% (cut meter <> (text-extent (~ w 'cairo))))
(sst-reset (~ w 'document))
(sst-apply (~ w 'document) (open-input-file (~ w 'stylesheet-uri)))
(set! (~ w 'frame) (spd-frame-construct (~ w 'document)))
(sst-reset (~ w 'current-page 'document))
(sst-apply (~ w 'current-page 'document) (open-input-file (~ w 'current-page 'stylesheet-uri)))
(set! (~ w 'frame) (spd-frame-construct (~ w 'current-page 'document)))
(set! (~ w 'frame 'style :min-size) (~ w 'size))
(if (not (eq? (~ w 'frame 'style :scroll) 'horizontal))
(set! (~ w 'frame 'style :max-size 0) (~ w 'size 0)))
Expand Down
19 changes: 9 additions & 10 deletions 1/viewer.scm
Expand Up @@ -20,24 +20,23 @@
(connect SDL-keydown #\f (^e (show-hints (~ window 'current-page 'document) (~ window 'current-page 'document-overlay))))
(connect SDL-keydown #\space (^e (update! (~ window 'current-page 'scroll-position 1) (^x (min (ceiling (- (~ window 'current-page 'size 1) (~ window 'size 1))) (+ x 240)))) (repaint window)))
(set! (~ window 'current-page) (make <window>))
(set! (~ window 'stylesheet-uri) "preferences/userContent.sst")
(set! (~ window 'document-uri) uri)
(set! (~ window 'current-page 'stylesheet-uri) "preferences/userContent.sst")
(set! (~ window 'current-page 'document-uri) uri)
(paint window)
(mainloop))

(define (show-hints doc target)
(define hint-text-chars "asdfqwer")
(define next-text
(define (next-text)
(define i 0)
(define base (string-length hint-text-chars))
(lambda ()
(begin0
(if (= i 0) "a"
(string
(unfold i (^i (= i 0)) (^i (values (~ hint-text-chars (floor (/ i base))) (- i (floor (/ i base))))))))
(set! i (+ i 1)))))
(begin0
(if (= i 0) "a"
(string
(unfold i (^i (= i 0)) (^i (values (~ hint-text-chars (floor (/ i base))) (- i (floor (/ i base))))))))
(set! i (+ i 1))))
(for-each
(^x
(append-child! target
(graphlib: append! target
(vertice `(.hint :style (:position ,(~ x 'style :position)) ,(next-text)))))
(query doc .a)))

0 comments on commit 61d49a3

Please sign in to comment.