Changeset 6682


Ignore:
Timestamp:
Jun 8, 2007, 3:12:53 PM (17 years ago)
Author:
Gary Byers
Message:

Use are real stream to write to input.
Default-style stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ide-1.0/ccl/examples/cocoa-listener.lisp

    r6672 r6682  
    4343    ((input-stream :reader cocoa-listener-process-input-stream)
    4444     (output-stream :reader cocoa-listener-process-output-stream)
     45     (input-peer-stream :reader cocoa-listener-process-input-peer-stream)
    4546     (backtrace-contexts :initform nil
    4647                         :accessor cocoa-listener-process-backtrace-contexts)
     
    6465                                         #$_PC_MAX_INPUT)
    6566                                        :encoding :utf-8))
     67         (peer-stream (make-fd-stream peer-fd :direction :output
     68                                      :sharing :lock
     69                                      :elements-per-buffer
     70                                      (#_fpathconf
     71                                         peer-fd
     72                                         #$_PC_MAX_INPUT)
     73                                      :encoding :utf-8))
    6674         (proc
    6775          (make-mcl-listener-process
     
    8795    (setf (slot-value proc 'input-stream) input-stream)
    8896    (setf (slot-value proc 'output-stream) output-stream)
     97    (setf (slot-value proc 'input-peer-stream) peer-stream)
    8998    (setf (slot-value proc 'window) window)
    9099    (setf (slot-value proc 'buffer) buffer)
     
    204213  (:metaclass ns:+ns-object))
    205214
     215(defmethod hi::document-encoding-name ((doc hemlock-listener-document))
     216  "UTF-8")
     217
     218(defmethod user-input-style ((doc hemlock-listener-document))
     219  hi::*listener-input-style*)
     220 
    206221(defmethod textview-background-color ((doc hemlock-listener-document))
    207222  (#/colorWithCalibratedRed:green:blue:alpha:
     
    270285    doc))
    271286
    272 (def-cocoa-default *initial-listener-x-pos* :float 400.0f0 "X position of upper-left corner of initial listener")
    273 
    274 (def-cocoa-default *initial-listener-y-pos* :float 400.0f0 "Y position of upper-left corner of initial listener")
     287(def-cocoa-default *initial-listener-x-pos* :float -100.0f0 "X position of upper-left corner of initial listener")
     288
     289(def-cocoa-default *initial-listener-y-pos* :float 100.0f0 "Y position of upper-left corner of initial listener")
    275290
    276291(defloadvar *next-listener-x-pos* nil) ; set after defaults initialized
     
    284299                  *listener-rows*
    285300                  t
    286                   (textview-background-color self)))
     301                  (textview-background-color self)
     302                  (user-input-style self)))
    287303         (controller (make-instance
    288304                      'hemlock-listener-window-controller
     
    298314    (#/release controller)
    299315    (ns:with-ns-point (current-point
    300                        (or *next-listener-x-pos* *initial-listener-x-pos*)
    301                        (or *next-listener-y-pos* *initial-listener-y-pos*))
     316                       (or *next-listener-x-pos*
     317                           (x-pos-for-window window *initial-listener-x-pos*))
     318                       (or *next-listener-y-pos*
     319                           (y-pos-for-window window *initial-listener-y-pos*)))
    302320      (let* ((new-point (#/cascadeTopLeftFromPoint: window current-point)))
    303321        (setf *next-listener-x-pos* (ns:ns-point-x new-point)
     
    393411(defmethod hi::send-string-to-listener-process ((process cocoa-listener-process)
    394412                                                string &key path package)
    395   (let* ((fd (selection-input-stream-peer-fd (cocoa-listener-process-input-stream process))))
    396     (%stack-block ((buf 512))
    397       (let* ((nout 0))
    398          (labels ((flush ()
    399                     (when (> nout 0)
    400                     (fd-write fd buf nout)
    401                     (setq nout 0)))
    402                   (out-raw-char (ch)
    403                     (when (= nout 512)
    404                       (flush))
    405                     (let* ((code (char-code ch)))
    406                       (if (> code 255)
    407                         (setq code (char-code #\Sub)))
    408                       (setf (%get-unsigned-byte buf nout) code)
    409                       (incf nout)))
    410                   (out-ch (ch)
    411                       (when (or (eql ch #\^v)
    412                                 (eql ch #\^p)
    413                                 (eql ch #\newline)
    414                                 (eql ch #\^q))
    415                         (out-raw-char #\^q))
    416                       (out-raw-char ch))
    417                   (out-string (s)
    418                     (dotimes (i (length s))
    419                       (out-ch (char s i)))))
    420            (out-raw-char #\^p)
    421            (when package (out-string package))
    422            (out-raw-char #\newline)
    423            (out-raw-char #\^v)
    424            (when path (out-string path))
    425            (out-raw-char #\newline)
    426            (out-string string)
    427            (flush))))))
     413  (let* ((stream (cocoa-listener-process-input-peer-stream process)))
     414    (labels ((out-raw-char (ch)
     415               (write-char ch stream))
     416             (out-ch (ch)
     417               (when (or (eql ch #\^v)
     418                         (eql ch #\^p)
     419                         (eql ch #\newline)
     420                         (eql ch #\^q))
     421                 (out-raw-char #\^q))
     422               (out-raw-char ch))
     423             (out-string (s)
     424               (dotimes (i (length s))
     425                 (out-ch (char s i)))))
     426      (out-raw-char #\^p)
     427      (when package (out-string package))
     428      (out-raw-char #\newline)
     429      (out-raw-char #\^v)
     430      (when path (out-string path))
     431      (out-raw-char #\newline)
     432      (out-string string)
     433      (force-output stream))))
    428434
    429435
Note: See TracChangeset for help on using the changeset viewer.