Changeset 717
- Timestamp:
- Mar 24, 2004, 9:26:14 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/ccl/examples/cocoa-editor.lisp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/examples/cocoa-editor.lisp
r716 r717 321 321 (not (eql (slot-value self 'edit-count) 0))) 322 322 323 (defun textstorage-note-insertion-at-position (self pos n) 324 (send self 325 :edited #$NSTextStorageEditedAttributes 326 :range (ns-make-range pos 0) 327 :change-in-length n) 328 (send self 329 :edited #$NSTextStorageEditedCharacters 330 :range (ns-make-range pos n) 331 :change-in-length 0)) 332 333 (define-objc-method ((:void :note-insertion params) hemlock-text-storage) 334 (let* ((pos (send (send params :object-at-index 0) 'int-value)) 335 (n (send (send params :object-at-index 1) 'int-value))) 336 (textstorage-note-insertion-at-position self pos n))) 337 338 (define-objc-method ((:void :note-deletion params) hemlock-text-storage) 339 (let* ((pos (send (send params :object-at-index 0) 'int-value)) 340 (n (send (send params :object-at-index 1) 'int-value))) 341 (send self 342 :edited #$NSTextStorageEditedCharacters 343 :range (ns-make-range pos n) 344 :change-in-length (- n)))) 345 346 (define-objc-method ((:void :note-modification params) hemlock-text-storage) 347 (let* ((pos (send (send params :object-at-index 0) 'int-value)) 348 (n (send (send params :object-at-index 1) 'int-value))) 349 (#_NSLog #@"Note modification: pos = %d, n = %d" :int pos :int n) 350 (send self 351 :edited (logior #$NSTextStorageEditedCharacters 352 #$NSTextStorageEditedAttributes) 353 :range (ns-make-range pos n) 354 :change-in-length 0))) 355 356 (define-objc-method ((:void begin-editing) hemlock-text-storage) 357 #+debug 358 (#_NSLog #@"begin-editing") 359 (incf (slot-value self 'edit-count)) 360 (send-super 'begin-editing)) 361 362 (define-objc-method ((:void end-editing) hemlock-text-storage) 363 #+debug 364 (#_NSLog #@"end-editing") 365 (send-super 'end-editing) 366 (decf (slot-value self 'edit-count))) 367 368 ;;; Return true iff we're inside a "beginEditing/endEditing" pair 369 (define-objc-method ((:<BOOL> editing-in-progress) hemlock-text-storage) 370 (not (eql (slot-value self 'edit-count) 0))) 371 323 372 324 373 … … 367 416 :with-string string) 368 417 hemlock-text-storage) 418 (declare (ignorable r string)) 369 419 #+debug 370 420 (#_NSLog #@"replace-characters-in-range (%d %d) with-string %@" … … 378 428 :range (:<NSR>ange r)) 379 429 hemlock-text-storage) 430 (declare (ignorable attributes r)) 380 431 #+debug 381 432 (#_NSLog #@"set-attributes %@ range (%d %d)" … … 893 944 (catch 'editor-top-level-catcher 894 945 (handler-bind ((error #'(lambda (condition) 895 ( lisp-error-error-handler condition946 (hi::lisp-error-error-handler condition 896 947 :internal)))) 897 ( invoke-hook hemlock::abort-hook)898 ( %command-loop))))899 ( invoke-hook hemlock::exit-hook))))948 (hi::invoke-hook hemlock::abort-hook) 949 (hi::%command-loop)))) 950 (hi::invoke-hook hemlock::exit-hook)))) 900 951 901 952 … … 1068 1119 1069 1120 (defun hi::document-set-point-position (document) 1121 #+debug 1122 (#_NSLog #@"Document set point position called") 1070 1123 (let* ((textstorage (slot-value document 'textstorage))) 1071 1124 (send textstorage … … 1075 1128 :wait-until-done t))) 1076 1129 1130 1131 1132 (defun perform-edit-change-notification (textstorage selector pos n) 1133 (let* ((number-for-pos 1134 (send (send (@class "NSNumber") 'alloc) 1135 :init-with-int pos)) 1136 (number-for-n 1137 (send (send (@class "NSNumber") 'alloc) 1138 :init-with-int n))) 1139 (%stack-block ((paramptrs (ash 2 target::word-shift))) 1140 (setf (%get-ptr paramptrs 0) number-for-pos 1141 (%get-ptr paramptrs (ash 1 target::word-shift)) 1142 number-for-n) 1143 (let* ((params (send (send (@class "NSArray") "alloc") 1144 :init-with-objects paramptrs 1145 :count 2))) 1146 (send textstorage 1147 :perform-selector-on-main-thread 1148 selector 1149 :with-object params 1150 :wait-until-done t) 1151 (send params 'release) 1152 (send number-for-pos 'release) 1153 (send number-for-n 'release))))) 1077 1154 1078 1155 (defun textstorage-note-insertion-at-position (textstorage pos n) … … 1089 1166 1090 1167 1091 (defun hi::buffer-note-modification (buffer mark n) 1092 (when (hi::bufferp buffer) 1093 (let* ((document (hi::buffer-document buffer)) 1094 (textstorage (if document (slot-value document 'textstorage)))) 1095 (when textstorage 1096 (let* ((pos (mark-absolute-position mark))) 1097 '(let* ((display (hemlock-buffer-string-cache (send textstorage 'string)))) 1098 (reset-buffer-cache display) 1099 (update-line-cache-for-index display pos)) 1100 #+debug 1101 (#_NSLog #@"Modification at %d, len %d" :int pos :int n) 1102 (send textstorage 1103 :edited (logior 1104 #$NSTextStorageEditedCharacters 1105 #$NSTextStorageEditedAttributes) 1106 :range (ns-make-range pos n) 1107 :change-in-length 0)) 1108 (sleep .1)) 1109 ))) 1168 1110 1169 1111 1170 … … 1123 1182 (reset-buffer-cache display) 1124 1183 (update-line-cache-for-index display pos)) 1125 (textstorage-note-insertion-at-position textstorage pos n)))))) 1126 1184 (perform-edit-change-notification textstorage 1185 (@selector "noteInsertion:") 1186 pos 1187 n)))))) 1188 1189 (defun hi::buffer-note-modification (buffer mark n) 1190 (when (hi::bufferp buffer) 1191 (let* ((document (hi::buffer-document buffer)) 1192 (textstorage (if document (slot-value document 'textstorage)))) 1193 (when textstorage 1194 (#_NSLog #@"enqueue modify: pos = %d, n = %d" 1195 :int (mark-absolute-position mark) 1196 :int n) 1197 (perform-edit-change-notification textstorage 1198 (@selector "noteModification:") 1199 (mark-absolute-position mark) 1200 n))))) 1127 1201 1128 1202 … … 1132 1206 (textstorage (if document (slot-value document 'textstorage)))) 1133 1207 (when textstorage 1134 (let* ((pos (mark-absolute-position mark))) 1135 (setq n (abs n)) 1136 #+debug 1137 (format t "~& pos = ~d, n = ~d" pos n) 1138 #+debug 1139 (force-output) 1140 (send textstorage 1141 :edited #$NSTextStorageEditedCharacters 1142 :range (ns-make-range pos n) 1143 :change-in-length (- n)) 1144 (let* ((cache (hemlock-buffer-string-cache (send textstorage 'string)))) 1145 (reset-buffer-cache cache) 1146 (update-line-cache-for-index cache pos))))))) 1147 1208 (perform-edit-change-notification textstorage 1209 (@selector "noteDeletion:") 1210 (mark-absolute-position mark) 1211 (abs n)))))) 1148 1212 (defun hi::set-document-modified (document flag) 1149 1213 (send document
Note:
See TracChangeset
for help on using the changeset viewer.
