Changeset tag,last-working,10 for tag/last-working
- Timestamp:
- 10/18/2007 03:19:37 PM (19 years ago)
- branch-nick:
- tui
- revision id:
- dsowen@fugue88.ws-20071018151937-126h3altfrx96ahq
- Location:
- tag/last-working
- Files:
-
- 2 edited
-
cdk.lisp (modified) (1 diff)
-
flat-menu.lisp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tag/last-working/cdk.lisp
r8 r10 132 132 (move-and-add-char window y (+ x i) (aref s i)))) 133 133 134 (defcfun ("wmove" c-wmove) :int 135 (window :pointer) 136 (y :int) 137 (x :int)) 138 134 139 (defcfun ("wrefresh" c-refresh-window) :int 135 140 (window :pointer)) -
tag/last-working/flat-menu.lisp
r9 r10 1 1 (defpackage #:flat-menu 2 2 (:use #:cl #:cffi) 3 (:export)) 3 (:export #:*shortcut-style* #:*highlight-style* #:menu #:selected 4 #:make-menu)) 4 5 5 6 (in-package #:flat-menu) … … 11 12 (shortcut-pos :initarg :shortcut-pos))) 12 13 14 (defun break-text (text shortcut-pos) 15 (if shortcut-pos 16 (values (subseq text 0 shortcut-pos) 17 (string (aref text shortcut-pos)) 18 (subseq text (1+ shortcut-pos))) 19 (values "" "" text))) 20 21 (defparameter *shortcut-style* (expt 2 17)) 22 (defparameter *highlight-style* (expt 2 #|21|# 18)) 23 13 24 (defun %draw-entry (entry window row column highlight) 14 25 (with-slots (text shortcut-pos) entry 15 (when highlight 16 (cdk::c-wattron window 262144)) 17 (cdk::move-and-add-string window row column text) 18 (when shortcut-pos 19 (cdk::c-wattron window 131072) 20 (cdk::move-and-add-string window row (+ column shortcut-pos) (string (aref text shortcut-pos))) 21 (cdk::c-wattroff window 131072)) 22 (when highlight 23 (cdk::c-wattroff window 262144)))) 26 (multiple-value-bind (s1 s2 s3) (break-text text shortcut-pos) 27 (when highlight 28 (cdk::c-wattron window *highlight-style*)) 29 (cdk::move-and-add-string window row column s1) 30 (cdk::c-wattron window *shortcut-style*) 31 (cdk::move-and-add-string window row (incf column (length s1)) s2) 32 (cdk::c-wattroff window *shortcut-style*) 33 (cdk::move-and-add-string window row (incf column (length s2)) s3) 34 (when highlight 35 (cdk::c-wattroff window *highlight-style*))))) 24 36 25 37 … … 59 71 (setf (selected menu) 0)) 60 72 73 74 75 (defun parse-entry (entry) 76 (destructuring-bind (text shortcut-pos) entry 77 (make-instance 'entry :text text :shortcut-pos shortcut-pos))) 78 79 (defun make-menu (window row column entries) 80 (let ((entries (map 'vector #'parse-entry entries))) 81 (make-instance 'menu 82 :window window 83 :row row 84 :column column 85 :entries entries))) 86 87 88 61 89 (defun activate-menu (menu) 90 "Some simple behavior just for testing." 62 91 (with-slots (window) menu 63 92 (with-accessors ((selected selected)) menu … … 69 98 ((= ch 259) 70 99 (decf selected)) 71 (t ( break))))))))100 (t (return)))))))) 72 101 73 102 (defun test () … … 77 106 (cdk::c-nonl) 78 107 (cdk::c-keypad screen t) 79 (cdk::c-init-color)80 108 (cdk::c-erase-window screen) 81 (let ((entry1 (make-instance 'entry :text "Hello, world!" :shortcut-pos 0)) 82 (entry2 (make-instance 'entry :text "Goodbye, galaxy!" :shortcut-pos 0))) 83 (let ((menu (make-instance 'menu :window screen :row 5 :column 10 :entries (vector entry1 entry2)))) 84 (activate-menu menu) 85 (format t "Here~%") 86 (read-line))) 87 (cdk::c-refresh-window screen) 88 (read-line) 109 (let ((menu (make-menu screen 5 10 '(("Hello, world!" 7) ("Goodbye, galaxy!" 9))))) 110 (activate-menu menu)) 89 111 (cdk::c-end-curses)))
Note: See TracChangeset
for help on using the changeset viewer.
