Changeset 7931
- Timestamp:
- Dec 22, 2007, 3:48:19 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/event-ide/ccl/cocoa-ide/cocoa-listener.lisp
r7929 r7931 188 188 ((filehandle :foreign-type :id) ;Filehandle for I/O 189 189 (clientfd :foreign-type :int) ;Client (listener)'s side of pty 190 (nextra :foreign-type :int) ;count of untranslated bytes remaining191 (translatebuf :foreign-type :address) ;buffer for utf8 translation192 (bufsize :foreign-type :int) ;size of translatebuf193 190 ) 194 191 (:metaclass ns:+ns-object) … … 213 210 :close-on-dealloc t))) 214 211 (setf (slot-value new 'filehandle) fh) 215 (setf (slot-value new 'clientfd) (setup-client-pty client)) 216 (let* ((bufsize #$BUFSIZ) 217 (buffer (#_malloc bufsize))) 218 (setf (slot-value new 'translatebuf) buffer 219 (slot-value new 'bufsize) bufsize 220 (slot-value new 'nextra) 0)) 221 (#/addObserver:selector:name:object: 222 (#/defaultCenter ns:ns-notification-center) 223 new 224 (@selector #/gotData:) 225 #&NSFileHandleReadCompletionNotification 226 fh) 227 (#/readInBackgroundAndNotify fh))))) 212 (setf (slot-value new 'clientfd) (setup-client-pty client)))))) 228 213 new)) 229 230 (objc:defmethod (#/gotData: :void) ((self hemlock-listener-window-controller)231 notification)232 (with-slots (filehandle nextra translatebuf bufsize) self233 (let* ((data (#/objectForKey: (#/userInfo notification)234 #&NSFileHandleNotificationDataItem))235 (encoding (load-time-value (get-character-encoding :utf-8)))236 (data-length (#/length data))237 (n nextra)238 (cursize bufsize)239 (need (+ n data-length))240 (xlate translatebuf)241 (fh filehandle))242 (when (> need cursize)243 (let* ((new (#_malloc need)))244 (dotimes (i n) (setf (%get-unsigned-byte new i)245 (%get-unsigned-byte xlate i)))246 (#_free xlate)247 (setq xlate new translatebuf new bufsize need)))248 #+debug :GZ (#_NSLog #@"got %d bytes of data" :int data-length)249 (with-macptrs ((target (%inc-ptr xlate n)))250 (#/getBytes:range: data target (ns:make-ns-range 0 data-length)))251 (let* ((total (+ n data-length)))252 (multiple-value-bind (nchars noctets-used)253 (funcall (ccl::character-encoding-length-of-memory-encoding-function encoding)254 xlate255 total256 0)257 (let* ((string (make-string nchars)))258 (funcall (ccl::character-encoding-memory-decode-function encoding)259 xlate260 noctets-used261 0262 string)263 (unless (zerop (setq n (- total noctets-used)))264 ;; By definition, the number of untranslated octets265 ;; can't be more than 3.266 (dotimes (i n)267 (setf (%get-unsigned-byte xlate i)268 (%get-unsigned-byte xlate (+ noctets-used i)))))269 (setq nextra n)270 (let ((view (hemlock-view self)))271 (queue-for-gui #'(lambda () (append-output view string))))272 (#/readInBackgroundAndNotify fh)))))))273 274 275 276 (objc:defmethod (#/dealloc :void) ((self hemlock-listener-window-controller))277 (#/removeObserver: (#/defaultCenter ns:ns-notification-center) self)278 (call-next-method))279 214 280 215 (objc:defmethod #/windowTitleForDocumentDisplayName: ((self hemlock-listener-window-controller) name)
Note:
See TracChangeset
for help on using the changeset viewer.
