Changeset 597
- Timestamp:
- Mar 1, 2004, 9:01:42 AM (21 years ago)
- Location:
- trunk/ccl
- Files:
-
- 9 edited
-
examples/cocoa-editor.lisp (modified) (6 diffs)
-
examples/cocoa-listener.lisp (modified) (5 diffs)
-
examples/cocoa-window.lisp (modified) (1 diff)
-
examples/cocoa.lisp (modified) (1 diff)
-
examples/compile-hemlock.lisp (modified) (1 diff)
-
hemlock/src/buffer.lisp (modified) (2 diffs)
-
hemlock/src/listener.lisp (modified) (5 diffs)
-
hemlock/src/modeline.lisp (modified) (4 diffs)
-
hemlock/src/struct.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/examples/cocoa-editor.lisp
r592 r597 171 171 hemlock-buffer-string) 172 172 (let* ((cache (hemlock-buffer-string-cache self))) 173 (or (buffer-cache-buflen cache) 174 (setf (buffer-cache-buflen cache) 175 (hemlock-buffer-length (buffer-cache-buffer cache)))))) 173 (force-output) 174 (or (buffer-cache-buflen cache) 175 (setf (buffer-cache-buflen cache) 176 (hemlock-buffer-length (buffer-cache-buffer cache)))))) 176 177 177 178 … … 489 490 ;;; Hook things up so that the modeline is updated whenever certain buffer 490 491 ;;; attributes change. 491 (hi::%init- redisplay)492 (hi::%init-mode-redisplay) 492 493 493 494 … … 869 870 870 871 (defun hi::document-end-editing (document) 871 (send (slot-value document 'textstorage) 'end-editing)) 872 (let* ((textstorage (slot-value document 'textstorage))) 873 (send textstorage 'end-editing) 874 (for-each-textview-using-storage 875 textstorage 876 #'(lambda (tv) 877 (send tv :scroll-range-to-visible (send tv 'selected-range)))))) 872 878 873 879 (defun hi::document-set-point-position (document) … … 881 887 #'(lambda (tv) 882 888 (slet ((selection (ns-make-range pos 0))) 883 (send tv :set-selected-range selection) 884 (send tv :scroll-range-to-visible selection)))))) 889 (send tv :set-selected-range selection)))))) 885 890 886 891 … … 903 908 (unless (eq (hi::mark-%kind mark) :right-inserting) 904 909 (decf pos n)) 905 #+debug 0910 #+debug 906 911 (format t "~&pos = ~d, n = ~d" pos n) 907 912 (let* ((display (hemlock-buffer-string-cache (send textstorage 'string)))) … … 919 924 (let* ((pos (mark-absolute-position mark))) 920 925 (setq n (abs n)) 926 #+debug 927 (format t "~& pos = ~d, n = ~d" pos n) 928 (force-output) 929 (send textstorage 930 :edited #$NSTextStorageEditedCharacters 931 :range (ns-make-range pos n) 932 :change-in-length (- n)) 921 933 (let* ((cache (hemlock-buffer-string-cache (send textstorage 'string)))) 922 934 (reset-buffer-cache cache) 923 (update-line-cache-for-index cache pos)) 924 925 (send textstorage 926 :edited #$NSTextStorageEditedAttributes 927 :range (ns-make-range pos n) 928 :change-in-length (- n))))))) 935 (update-line-cache-for-index cache pos))))))) 929 936 930 937 (defun hi::set-document-modified (document flag) -
trunk/ccl/examples/cocoa-listener.lisp
r592 r597 100 100 (declare (dynamic-extent string)) 101 101 (%copy-ptr-to-ivector (send data 'bytes) 0 string 0 data-length) 102 (hi::insert-string (hi::buffer-point buffer) string) 102 (let* ((input-mark (hi::variable-value 'hemlock::buffer-input-mark :buffer buffer))) 103 (hi:with-mark ((mark input-mark :left-inserting)) 104 (hi::insert-string mark string) 105 (hi::move-mark input-mark mark))) 103 106 (send fh 'read-in-background-and-notify)))) 104 107 … … 122 125 |# 123 126 124 ;;; Action methods implemented by the controller (in its role as the 125 ;;; textview's delegate). 126 127 128 (define-objc-method ((:void :send-string string) 129 lisp-listener-window-controller) 130 (send (slot-value self 'filehandle) 131 :write-data (send string 132 :data-using-encoding #$NSASCIIStringEncoding 133 :allow-lossy-conversion t))) 127 128 129 130 134 131 135 132 … … 176 173 (:metaclass ns:+ns-object)) 177 174 175 (defun hemlock::listener-document-send-string (document string) 176 (let* ((controller (send (send document 'window-controllers) 177 :object-at-index 0)) 178 (filehandle (slot-value controller 'filehandle)) 179 (len (length string)) 180 (data (send (make-objc-instance 'ns-mutable-data 181 :with-length len) 'autorelease)) 182 (bytes (send data 'mutable-bytes))) 183 (%copy-ivector-to-ptr string 0 bytes 0 len) 184 (send filehandle :write-data data) 185 (send filehandle 'synchronize-file))) 186 178 187 179 188 (define-objc-class-method ((:id top-listener) lisp-listener-document) … … 211 220 (setf (hi::buffer-pathname buffer) nil 212 221 (hi::buffer-minor-mode buffer "Listener") t 213 (hi::buffer-name buffer) listener-name))) 222 (hi::buffer-name buffer) listener-name) 223 (hi::sub-set-buffer-modeline-fields buffer hemlock::*listener-modeline-fields*))) 214 224 doc)) 215 225 … … 244 254 |# 245 255 246 247 256 (defun cocoa-ide-note-package (package) 257 (process-interrupt *cocoa-event-process* 258 #'(lambda (proc name) 259 (dolist (buf hi::*buffer-list*) 260 (when (eq proc (hi::buffer-process buf)) 261 (setf (hi::variable-value 'hemlock::current-package :buffer buf) name)))) 262 *current-process* 263 (package-name package))) 264 265 (defmethod ui-object-do-operation ((o cocoa-ide-ui-object) 266 operation &rest args) 267 (case operation 268 (:note-package (cocoa-ide-note-package (car args))))) 269 270 271 -
trunk/ccl/examples/cocoa-window.lisp
r569 r597 353 353 (send dict :set-object color :for-key #@"NSColor")) 354 354 dict)) 355 -
trunk/ccl/examples/cocoa.lisp
r430 r597 11 11 (fake-cfbundle-path "ccl:OpenMCL.app;Contents;MacOS;dppccl")) 12 12 13 (defclass cocoa-ide-ui-object (ui-object) 14 ()) 13 15 16 (setf (application-ui-object *application*) (make-instance 'cocoa-ide-ui-object)) 14 17 15 18 (require "OBJC-SUPPORT") -
trunk/ccl/examples/compile-hemlock.lisp
r591 r597 158 158 (mapcar #'hemlock-binary-pathname *hemlock-files*) 159 159 :if-exists :supersede) 160 (provide "HEMLOCK") 160 161 ) -
trunk/ccl/hemlock/src/buffer.lisp
r569 r597 460 460 (defun defmode (name &key (setup-function #'identity) 461 461 (cleanup-function #'identity) major-p transparent-p 462 precedence documentation )462 precedence documentation hidden) 463 463 "Define a new mode, specifying whether it is a major mode, and what the 464 464 setup and cleanup functions are. Precedence, which defaults to 0.0, and is … … 491 491 :variables (make-string-table) 492 492 :bindings (make-hash-table) 493 :hook-name (getstring hook-str *global-variable-names*))) 493 :hook-name (getstring hook-str *global-variable-names*) 494 :hidden hidden)) 494 495 (setf (getstring name *mode-names*) mode))) 495 496 -
trunk/ccl/hemlock/src/listener.lisp
r595 r597 42 42 (t 43 43 (message 44 "Ignoring \"package\" file option -- cannot convert to a string.")))))) 44 "Ignoring \"package\" file option -- cannot convert to a string.")))) 45 )) 45 46 46 47 … … 83 84 (defmode "Listener" :major-p nil :setup-function #'setup-listener-mode) 84 85 86 (defparameter *listener-modeline-fields* 87 (list (modeline-field :package) 88 (modeline-field :modes) 89 (modeline-field :process-info))) 90 85 91 (defun listener-mode-lisp-mode-hook (buffer on) 86 92 "Turn on Lisp mode when we go into Listener Mode." … … 141 147 :mode "Listener") 142 148 149 (defun balanced-expressions-in-region (region) 150 "Return true if there's at least one syntactically well-formed S-expression 151 between the region's start and end, and if there are no ill-formed expressions in that region." 152 ;; It helps to know that END-MARK immediately follows a #\newline. 153 (let* ((start-mark (region-start region)) 154 (end-mark (region-end region)) 155 (end-line (mark-line end-mark)) 156 (end-charpos (mark-charpos end-mark))) 157 (with-mark ((m start-mark)) 158 (pre-command-parse-check m) 159 (when (form-offset m 1) 160 (let* ((skip-whitespace t)) 161 (loop 162 (let* ((current-line (mark-line m)) 163 (current-charpos (mark-charpos m))) 164 (when (and (eq current-line end-line) 165 (eql current-charpos end-charpos)) 166 (return t)) 167 (if skip-whitespace 168 (progn 169 (scan-char m :whitespace nil) 170 (setq skip-whitespace nil)) 171 (progn 172 (pre-command-parse-check m) 173 (unless (form-offset m 1) 174 (return nil)) 175 (setq skip-whitespace t)))))))))) 176 177 178 143 179 (defcommand "Confirm Listener Input" (p) 144 180 "Evaluate Listener Mode input between point and last prompt." … … 147 183 (let ((input-region (get-interactive-input))) 148 184 (when input-region 149 (let* ((output (value eval-output-stream)) 150 (*standard-output* output) 151 (*error-output* output) 152 (*trace-output* output)) 153 (fresh-line) 154 (in-lisp 155 ;; Copy the region to keep the output and input streams from interacting 156 ;; since input-region is made of permanent marks into the buffer. 157 (with-input-from-region (stream (copy-region input-region)) 158 (loop 159 (let ((form (read stream nil lispbuf-eof))) 160 (when (eq form lispbuf-eof) 161 ;; Move the buffer's input mark to the end of the buffer. 162 (move-mark (region-start input-region) 163 (region-end input-region)) 164 (return)) 165 (setq +++ ++ ++ + + - - form) 166 (let ((this-eval (multiple-value-list (eval form)))) 167 (fresh-line) 168 (dolist (x this-eval) (prin1 x) (terpri)) 169 (show-prompt) 170 (setq /// // // / / this-eval) 171 (setq *** ** ** * * (car this-eval))))))))))) 185 (insert-character (current-point) #\NewLine) 186 (when (balanced-expressions-in-region input-region) 187 (let* ((string (region-to-string input-region))) 188 (move-mark (value buffer-input-mark) (current-point)) 189 (listener-document-send-string (hi::buffer-document (current-buffer)) string)))))) 190 191 (defvar *control-d-string* (make-string 1 :initial-element (code-char (logand (char-code #\d) #x1f)))) 192 193 (defcommand "EOF or Delete Forward" (p) 194 "Send an EOF if input-mark is at buffer's end, else delete forward character." 195 "Send an EOF if input-mark is at buffer's end, else delete forward character." 196 (let* ((input-mark (value buffer-input-mark)) 197 (point (current-point))) 198 (if (and (null (next-character point)) 199 (null (next-character input-mark))) 200 (listener-document-send-string (hi::buffer-document (current-buffer)) *control-d-string*) 201 (delete-next-character-command p)))) 202 203 172 204 173 205 (defcommand "Abort Listener Input" (p) … … 363 395 ;;; Other stuff. 364 396 365 (defmode "Editor" )397 (defmode "Editor" :hidden t) 366 398 367 399 (defcommand "Editor Mode" (p) -
trunk/ccl/hemlock/src/modeline.lisp
r593 r597 132 132 "Returns buffer's modes followed by one space." 133 133 (declare (ignore window)) 134 (format nil "~A " (buffer-modes buffer)))) 134 (let* ((m ())) 135 (dolist (mode (buffer-mode-objects buffer)) 136 (unless (hi::mode-object-hidden mode) 137 (push (mode-object-name mode) m))) 138 (format nil "~A " (nreverse m))))) 135 139 136 140 (make-modeline-field … … 209 213 :function 'buffer-pathname-ml-field-fun) 210 214 215 (make-modeline-field 216 :name :process-info 217 :function #'(lambda (buffer window) 218 (declare (ignore window)) 219 (let* ((proc (buffer-process buffer))) 220 (when proc 221 (format nil "~a(~d) [~a]" 222 (ccl::process-name proc) 223 (ccl::process-serial-number proc) 224 (ccl::process-whostate proc)))))) 211 225 212 226 (defvar *default-modeline-fields* … … 219 233 "This is the default value for \"Default Modeline Fields\".") 220 234 221 (defun %init- redisplay ()235 (defun %init-mode-redisplay () 222 236 (add-hook hemlock::buffer-major-mode-hook 'queue-buffer-change) 223 237 (add-hook hemlock::buffer-minor-mode-hook 'queue-buffer-change) … … 225 239 (add-hook hemlock::buffer-pathname-hook 'queue-buffer-change) 226 240 (add-hook hemlock::buffer-modified-hook 'queue-buffer-change) 241 (add-hook hemlock:: 227 242 (add-hook hemlock::window-buffer-hook 'queue-window-change)) 228 243 -
trunk/ccl/hemlock/src/struct.lisp
r587 r597 163 163 variables ; String-table of mode variables 164 164 var-values ; Alist for saving mode variables 165 documentation) ; Introductory comments for mode describing commands. 165 documentation ; Introductory comments for mode describing commands. 166 hidden ; Not listed in modeline fields 167 ) 166 168 167 169 (defun %print-hemlock-mode (object stream depth)
Note:
See TracChangeset
for help on using the changeset viewer.
