Changeset 6668
- Timestamp:
- Jun 3, 2007, 3:04:25 AM (17 years ago)
- File:
-
- 1 edited
-
branches/ide-1.0/ccl/examples/cocoa-editor.lisp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ide-1.0/ccl/examples/cocoa-editor.lisp
r6622 r6668 1 ;; -*- Mode: LISP; Package: CCL -*-1 ;;;-*- Mode: LISP; Package: CCL -*- 2 2 3 3 … … 58 58 (#/yellowColor color-class))) 59 59 (styles (make-array (the fixnum (* 4 (length colors))))) 60 (bold-stroke-width 8.5f0)60 (bold-stroke-width -10.0f0) 61 61 (fonts (vector font (or bold-font font) (or oblique-font font) (or bold-oblique-font font))) 62 62 (real-fonts (vector font bold-font oblique-font bold-oblique-font)) … … 575 575 (objc:defmethod (#/replaceCharactersInRange:withString: :void) 576 576 ((self hemlock-text-storage) (r :<NSR>ange) string) 577 #+debug 0 (#_NSLog #@"Replace in range %ld/%ld with %@" 578 :<NSI>nteger (pref r :<NSR>ange.location) 579 :<NSI>nteger (pref r :<NSR>ange.length) 580 :id string) 577 581 (let* ((cache (hemlock-buffer-string-cache (#/string self))) 578 582 (buffer (if cache (buffer-cache-buffer cache))) … … 602 606 (t 603 607 (move-hemlock-mark-to-absolute-position point cache location)))) 604 (hi::insert-string point (lisp-string-from-nsstring string)))) 608 (let* ((lisp-string (lisp-string-from-nsstring string))) 609 (hi::enqueue-buffer-operation 610 buffer 611 #'(lambda () 612 (unwind-protect 613 (progn 614 (hi::buffer-document-begin-editing buffer) 615 (hi::insert-string point lisp-string)) 616 (hi::buffer-document-end-editing buffer))))))) 605 617 606 618 … … 784 796 ((pane :foreign-type :id :accessor text-view-pane)) 785 797 (:metaclass ns:+ns-object)) 798 799 800 801 786 802 787 803 ;;; Access the underlying buffer in one swell foop. … … 837 853 ;;; Translate a keyDown NSEvent to a Hemlock key-event. 838 854 (defun nsevent-to-key-event (nsevent) 839 (let* ((unmodchars (#/charactersIgnoringModifiers nsevent)) 840 (n (if (%null-ptr-p unmodchars) 841 0 842 (#/length unmodchars))) 843 (c (if (eql n 1) 844 (#/characterAtIndex: unmodchars 0)))) 845 (when c 846 (let* ((bits 0) 847 (modifiers (#/modifierFlags nsevent)) 848 (useful-modifiers (logandc2 modifiers 849 (logior #$NSShiftKeyMask 850 #$NSAlphaShiftKeyMask)))) 851 (dolist (map hemlock-ext::*modifier-translations*) 852 (when (logtest useful-modifiers (car map)) 853 (setq bits (logior bits (hemlock-ext::key-event-modifier-mask 854 (cdr map)))))) 855 (hemlock-ext::make-key-event c bits))))) 855 (let* ((modifiers (#/modifierFlags nsevent))) 856 (unless (logtest #$NSCommandKeyMask modifiers) 857 (let* ((unmodchars (#/charactersIgnoringModifiers nsevent)) 858 (n (if (%null-ptr-p unmodchars) 859 0 860 (#/length unmodchars))) 861 (c (if (eql n 1) 862 (#/characterAtIndex: unmodchars 0)))) 863 (when c 864 (let* ((bits 0) 865 (useful-modifiers (logandc2 modifiers 866 (logior #$NSShiftKeyMask 867 #$NSAlphaShiftKeyMask)))) 868 (dolist (map hemlock-ext::*modifier-translations*) 869 (when (logtest useful-modifiers (car map)) 870 (setq bits (logior bits (hemlock-ext::key-event-modifier-mask 871 (cdr map)))))) 872 (hemlock-ext::make-key-event c bits))))))) 856 873 857 874 (defun pass-key-down-event-to-hemlock (self event) … … 860 877 (let* ((buffer (text-view-buffer self))) 861 878 (when buffer 862 (let* ((q (hemlock-frame-event-queue (#/window self)))) 863 (hi::enqueue-key-event q (nsevent-to-key-event event)))))) 864 865 (defun enqueue-buffer-operation (buffer thunk) 879 (let* ((hemlock-event (nsevent-to-key-event event))) 880 (when hemlock-event 881 (let* ((q (hemlock-frame-event-queue (#/window self)))) 882 (hi::enqueue-key-event q hemlock-event))))))) 883 884 (defun hi::enqueue-buffer-operation (buffer thunk) 866 885 (dolist (w (hi::buffer-windows buffer)) 867 886 (let* ((q (hemlock-frame-event-queue (#/window w))) … … 1173 1192 (#/setBackgroundColor: tv color) 1174 1193 (#/setSmartInsertDeleteEnabled: tv nil) 1194 (#/setAllowsUndo: tv t) 1175 1195 (#/setUsesFindPanel: tv t) 1176 1196 (#/setWidthTracksTextView: container tracks-width) … … 1330 1350 (let* ((message (#/objectAtIndex: info 0)) 1331 1351 (signal (#/objectAtIndex: info 1))) 1332 (#_NSLog #@"runErrorSheet: signal = %@" :id signal)1352 #+debug (#_NSLog #@"runErrorSheet: signal = %@" :id signal) 1333 1353 (#_NSBeginAlertSheet #@"Error in Hemlock command processing" ;title 1334 1354 (if (logbitp 0 (random 2)) … … 2203 2223 #+debug 2204 2224 (#_NSLog #@"update Hemlock selection: charpos = %d, abspos = %d" 2205 :int (hi::mark-charpos point) :int po s)2225 :int (hi::mark-charpos point) :int pointpos) 2206 2226 (for-each-textview-using-storage 2207 2227 self … … 2243 2263 *nsapp* (@selector #/stringToPasteBoard:) (%make-nsstring string) t))) 2244 2264 2265 ;;; The default #/paste method seems to want to set the font to 2266 ;;; something ... inappropriate. If we can figure out why it 2267 ;;; does that and persuade it not to, we wouldn't have to do 2268 ;;; this here. 2269 ;;; (It's likely to also be the case that Carbon applications 2270 ;;; terminate lines with #\Return when writing to the clipboard; 2271 ;;; we may need to continue to override this method in order to 2272 ;;; fix that.) 2273 (objc:defmethod (#/paste: :void) ((self hemlock-text-view) sender) 2274 (declare (ignorable sender)) 2275 #+debug (#_NSLog #@"Paste: sender = %@" :id sender) 2276 (let* ((pb (general-pasteboard)) 2277 (string (progn (#/types pb) (#/stringForType: pb #&NSStringPboardType)))) 2278 (unless (%null-ptr-p string) 2279 (unless (zerop (ns:ns-range-length (#/rangeOfString: string *ns-cr-string*))) 2280 (setq string (#/stringByReplacingOccurrencesOfString:withString: string *ns-cr-string* *ns-lf-string*))) 2281 (let* ((textstorage (#/textStorage self)) 2282 (selectedrange (#/selectedRange self))) 2283 (#/replaceCharactersInRange:withString: textstorage selectedrange string))))) 2284 2245 2285 2246 2286
Note:
See TracChangeset
for help on using the changeset viewer.
