Changeset 743
- Timestamp:
- Mar 27, 2004, 2:57:01 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/ccl/examples/cocoa-listener.lisp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/examples/cocoa-listener.lisp
r722 r743 1 ;; ;-*- Mode: LISP; Package: CCL -*-1 ;;-*- Mode: LISP; Package: CCL -*- 2 2 3 3 (in-package "CCL") … … 9 9 (def-cocoa-default *listener-rows* :int 16) 10 10 (def-cocoa-default *listener-columns* :int 80) 11 12 (def-cocoa-default *listener-background-red-component* :int 0.75f0) 13 (def-cocoa-default *listener-background-green-component* :int 0.75f0) 14 (def-cocoa-default *listener-background-blue-component* :int 0.75f0) 15 (def-cocoa-default *listener-background-alpha-component* :int 1.0f0) 11 16 12 17 ;;; Setup the server end of a pty pair. … … 26 31 27 32 (defclass cocoa-listener-process (process) 28 ((input-stream :reader cocoa-listener-process-input-stream))) 33 ((input-stream :reader cocoa-listener-process-input-stream) 34 (backtrace-contexts :initform nil 35 :accessor cocoa-listener-process-backtrace-contexts))) 36 29 37 30 38 (defun new-cocoa-listener-process (procname input-fd output-fd peer-fd) … … 124 132 (send fh 'read-in-background-and-notify)))) 125 133 126 #|127 ;;; The Hemlock-Listener-Window-Controller is the textview's "delegate": it128 ;;; gets consulted before certain actions are performed, and can129 ;;; perform actions on behalf of the textview.130 131 (define-objc-method ((:<BOOL> :text-view tv132 :should-change-text-in-range (:<NSR>ange range)133 :replacement-string replacement-string)134 hemlock-listener-window-controller)135 (declare (ignorable replacement-string))136 (if (< (pref range :<NSR>ange.location) (slot-value self 'outpos))137 (progn138 (#_NSBeep) ;Overkill, maybe.139 nil)140 (progn141 (send tv :set-typing-attributes (slot-value self 'userta))142 t)))143 |#144 134 145 135 … … 157 147 () 158 148 (:metaclass ns:+ns-object)) 149 150 (defmethod textview-background-color ((doc hemlock-listener-document)) 151 (send (find-class 'ns:ns-color) 152 :color-with-calibrated-red *listener-background-red-component* 153 :green *listener-background-green-component* 154 :blue *listener-background-blue-component* 155 :alpha *listener-background-alpha-component*)) 156 159 157 160 158 (defun hemlock::listener-document-send-string (document string) … … 217 215 *listener-columns* 218 216 *listener-rows* 219 t))) 217 t 218 (textview-background-color self)))) 220 219 (listener-name (hi::buffer-name (hemlock-document-buffer self)))) 221 220 (send self :add-window-controller controller) … … 228 227 controller)) 229 228 230 ;;; This is almost completely wrong: we need to ensure that the form 231 ;;; is read in the correct package, etc. 232 #| 233 (defun send-to-top-listener (sender-info nsstring &optional (append-newline t)) 234 (declare (ignorable sender-info)) 235 (let* ((listener 236 (info-from-document (send (@class hemlock-listener-document) 237 'top-listener)))) 238 (when listener 239 (let* ((controller (cocoa-editor-info-controller listener))) 240 (send controller :send-string nsstring) 241 (when append-newline 242 (send controller :send-string #@" 243 " 244 )))))) 245 |# 229 ;;; Action methods 230 (define-objc-method ((:void :interrupt sender) hemlock-listener-document) 231 (declare (ignore sender)) 232 (let* ((buffer (hemlock-document-buffer self)) 233 (process (if buffer (hi::buffer-process buffer)))) 234 (when (typep process 'cocoa-listener-process) 235 (ccl::force-break-in-listener process)))) 236 237 (defmethod listener-backtrace-context ((proc cocoa-listener-process)) 238 (car (cocoa-listener-process-backtrace-contexts proc))) 239 240 (define-objc-method ((:void :backtrace sender) hemlock-listener-document) 241 (declare (ignore sender)) 242 (let* ((buffer (hemlock-document-buffer self)) 243 (process (if buffer (hi::buffer-process buffer)))) 244 (when (typep process 'cocoa-listener-process) 245 (let* ((context (listener-backtrace-context process))) 246 (when context 247 (send (backtrace-controller-for-context context) 248 :show-window (%null-ptr))))))) 249 250 ;;; Menu item action validation. It'd be nice if we could distribute this a 251 ;;; bit better, so that this method didn't have to change whenever a new 252 ;;; action was implemented in this class. For now, we have to do so. 253 254 (defmethod document-validate-menu-item ((doc hemlock-listener-document) item) 255 ;; Return two values: the first is true if the second is definitive. 256 ;; So far, all actions demand that there be an underlying process, so 257 ;; check for that first. 258 (let* ((buffer (hemlock-document-buffer doc)) 259 (process (if buffer (hi::buffer-process buffer)))) 260 (if (typep process 'cocoa-listener-process) 261 (let* ((action (send item 'action))) 262 (cond 263 ((eql action (@selector "interrupt:")) (values t t)) 264 ((eql action (@selector "backtrace:")) 265 (values t 266 (not (null (listener-backtrace-context process))))))) 267 (values nil nil)))) 268 269 (define-objc-method ((:<BOOL> :validate-menu-item item) 270 hemlock-listener-document) 271 (multiple-value-bind (have-opinion opinion) 272 (document-validate-menu-item self item) 273 (if have-opinion 274 opinion 275 (send-super :validate-menu-item item)))) 246 276 247 277 (defun shortest-package-name (package) … … 297 327 298 328 299 (defmethod ui-object-do-operation ((o ns:ns-application) 300 operation &rest args) 301 (case operation 302 (:note-current-package (ui-object-note-package o (car args))) 303 (:eval-selection (ui-object-eval-selection o (car args))))) 329 304 330 305 331
Note:
See TracChangeset
for help on using the changeset viewer.
