Changeset main,80
- Timestamp:
- 12/13/2007 12:47:56 AM (18 years ago)
- branch-nick:
- tui
- revision id:
- dsowen@fugue88.ws-20071213004756-lr4quvaf0hy1zpub
- Location:
- main
- Files:
-
- 2 edited
-
form.lisp (modified) (7 diffs)
-
widget/textbox.lisp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
main/form.lisp
r79 r80 55 55 56 56 (defun make-textbox-def (row column name display-width 57 &key data-width read-only (validat e 'nothing)57 &key data-width read-only (validator 'identity) 58 58 (inactive-background 59 59 *default-inactive-widget-background*) … … 64 64 :display-width ,display-width :data-width ,data-width 65 65 :read-only ,read-only 66 :validator ',validat e66 :validator ',validator 67 67 :inactive-background (list ,@inactive-background) 68 68 :active-background (list ,@active-background))) … … 70 70 (defun make-numberbox-def (row column name display-width 71 71 &key data-width precision read-only 72 (validat e 'nothing)72 (validator 'identity) 73 73 (inactive-background 74 74 *default-inactive-widget-background*) … … 79 79 :display-width ,display-width :data-width ,data-width 80 80 :precision ,precision :read-only ,read-only 81 :validator ',validat e81 :validator ',validator 82 82 :inactive-background (list ,@inactive-background) 83 83 :active-background (list ,@active-background))) … … 130 130 (create-label window row column text)))) 131 131 (:method ((tbd textbox-def) form) 132 (with-slots (row column name display-width inactive-background132 (with-slots (row column name validator display-width inactive-background 133 133 active-background) tbd 134 134 (with-slots (data window scroll) form 135 135 (let ((r (make-reflector data name))) 136 136 (create-textbox window (- row scroll) column r display-width 137 :validator validator 137 138 :inactive-background inactive-background 138 139 :active-background active-background))))) 139 140 (:method ((nbd numberbox-def) form) 140 (with-slots (row column name display-width inactive-background141 (with-slots (row column name validator display-width inactive-background 141 142 active-background) nbd 142 143 (with-slots (data window scroll) form 143 144 (let ((r (make-reflector data name))) 144 145 (create-numberbox window (- row scroll) column r display-width 146 :validator validator 145 147 :inactive-background inactive-background 146 148 :active-background active-background)))))) … … 256 258 (assert (> n 0) nil "The form has no fields.") 257 259 (labels ((f-idx () (aref focusables focus)) 258 (f-peer () (aref peers (f-idx))) 259 (f-def () (aref widget-defs (f-idx))) 260 (validate () 261 (let* ((v (slot-value (f-def) 'validator)) 262 (name (slot-value (f-def) 'name)) 263 (text (form-value data name)) 264 (r (funcall v text))) 265 (when r 266 (setf (form-value data name) r))))) 260 (f-peer () (aref peers (f-idx)))) 267 261 (loop 268 262 (ensure-widget-visible form (f-idx)) … … 271 265 (case key 272 266 ((#\Return #\Newline #\Tab :key-down) 273 #|(setf focus (mod (1+ focus) n))|#274 (validate)275 267 (incf focus) 276 268 (boundf focus 0 (1- n))) 277 269 ((:key-btab :key-up) 278 #|(setf focus (mod (1- focus) n))|#279 (validate)280 270 (decf focus) 281 271 (boundf focus 0 (1- n))) -
main/widget/textbox.lisp
r65 r80 10 10 (defclass textbox (widget scroll insertion-point) 11 11 ((data :initarg :data) 12 (validator :initform 'identity :initarg :validator :reader validator) 12 13 (window :initarg :window) 13 14 (active :type boolean :initform nil))) … … 63 64 64 65 65 (defun create-textbox (parent-window y x data width & key66 (defun create-textbox (parent-window y x data width &rest args &key validator 66 67 (inactive-background '(#\Space 0)) 67 68 (active-background '(#\Space 0))) 69 (declare (ignore validator inactive-background active-background)) 68 70 (let* ((window (tui-window::create-subwindow parent-window 1 width y x)) 69 (inst (make-instance 'textbox 70 :data data 71 :window window 72 :inactive-background inactive-background 73 :active-background active-background))) 71 (inst (apply 'make-instance 'textbox :data data :window window args))) 74 72 (draw inst) 75 73 inst)) … … 123 121 (let ((r (funcall key-callback key))) 124 122 (when r 125 (setf (insertion-point textbox) 0) 126 (return-from activate r))) 123 (let ((q (funcall (validator textbox) (text data)))) 124 (when q 125 (setf (text data) q) 126 (setf (insertion-point textbox) 0) 127 (return-from activate r))))) 127 128 (multiple-value-bind (left right) (split textbox) 128 129 (setf (text data)
Note: See TracChangeset
for help on using the changeset viewer.
