- Timestamp:
- 11/03/2007 03:55:10 PM (19 years ago)
- branch-nick:
- tui
- revision id:
- dsowen@fugue88.ws-20071103155510-r69yh2jkr423i49e
- Location:
- main
- Files:
-
- 2 edited
-
display-string.lisp (modified) (3 diffs)
-
tui.asd (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
main/display-string.lisp
r22.1.1 r25 30 30 (f 0))) 31 31 32 33 32 34 (defun renderlen-part (part) 33 35 (destructuring-bind (class image) part 34 ( if (eq class 'literal)35 (length image)36 0)))36 (ecase class 37 (literal (length image)) 38 (escape 0)))) 37 39 38 40 (defun renderlen (parts) 39 41 (let ((lens (mapcar 'renderlen-part parts))) 40 42 (reduce '+ lens))) 43 44 41 45 42 46 (defconstant +attributes+ '(#\s #.(expt 2 16) … … 49 53 #\p #.(expt 2 24))) 50 54 55 (defun fmt-part (part) 56 (destructuring-bind (class image) part 57 (ecase class 58 (literal (enquote image)) 59 (escape (format nil "`~A" image))))) 60 61 (defun fmt (parts) 62 (let ((s (mapcar 'fmt-part parts))) 63 (apply 'concatenate 'string s))) 64 65 66 51 67 (defun render (dstr window y x) 52 (let ((parts (scan-dstring dstr)) )53 (cdk:wmove window y x)68 (let ((parts (scan-dstring dstr)) 69 (printed 0)) 54 70 (dolist (p parts) 55 71 (destructuring-bind (class image) p 56 72 (if (eq class 'literal) 57 (add-string window image) 73 (let ((n (length image))) 74 (add-clipped-string window y (+ x printed) image) 75 (incf printed n)) 58 76 (let ((on (upper-case-p image)) 59 77 (attr (getf +attributes+ (char-downcase image)))) … … 63 81 64 82 (defun test () 65 (with-screen (s) 66 (render "Now `B`Ris `bthe`r ``time.'" s 10 10) 67 (input:%wget-wch s))) 83 (let ((m "`UNow `B`Ris `bthe`r ``time.'`u")) 84 (with-screen (s) 85 (cdk::c-erase-window s) 86 (cdk::c-refresh-window s) 87 (with-der-window (w s 3 10 5 5) 88 (wmove w 0 0) 89 (add-string w (make-sequence 'string 15 :initial-element #\.)) 90 (render m w 1 -2) 91 (input:%wget-wch w))))) -
main/tui.asd
r22.1.1 r25 6 6 (:file "cdk") 7 7 (:file "display-string" 8 :depends-on ("cdk")) 8 ;; "input" only for testing 9 :depends-on ("cdk" "input")) 9 10 (:module "grid" 10 :depends-on ("cdk" )11 :depends-on ("cdk" "display-string") 11 12 :components ((:file "package") 12 13 (:file "model")
Note: See TracChangeset
for help on using the changeset viewer.
