Changeset 12407


Ignore:
Timestamp:
Jul 14, 2009, 5:32:31 AM (10 years ago)
Author:
mikel
Message:

Fixed spurious newlines in listener input.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/hemlock/src/listener.lisp

    r12406 r12407  
    233233                        (copy-mark (region-end input-region) :right-inserting)))))
    234234    (when input-region
    235       (insert-character (current-point-for-insertion) #\NewLine)
    236       (when (or (input-stream-reading-line
    237                  (top-listener-input-stream))
    238                 (balanced-expressions-in-region input-region))
    239         (let* ((string (region-to-string input-region))
    240                (ring (value interactive-history)))
    241           (when (and (or (zerop (ring-length ring))
    242                          (string/= string (region-to-string (ring-ref ring 0))))
    243                      (> (length string) (value minimum-interactive-input-length)))
    244             (ring-push (copy-region input-region) ring))
    245           (push (cons r nil) (value input-regions))
    246           (move-mark (value buffer-input-mark) (current-point))
    247           (append-font-regions (current-buffer))
    248           (hemlock-ext:send-string-to-listener (current-buffer) string))))))
     235      (if (or (input-stream-reading-line
     236               (top-listener-input-stream))
     237              (balanced-expressions-in-region input-region))
     238          ;; complete expression: send it to lisp
     239          (let* ((string (region-to-string input-region))
     240                 (ring (value interactive-history)))
     241            (when (and (or (zerop (ring-length ring))
     242                           (string/= string (region-to-string (ring-ref ring 0))))
     243                       (> (length string) (value minimum-interactive-input-length)))
     244              (ring-push (copy-region input-region) ring))
     245            (push (cons r nil) (value input-regions))
     246            (move-mark (value buffer-input-mark) (current-point))
     247            (append-font-regions (current-buffer))
     248            (hemlock-ext:send-string-to-listener (current-buffer) (concatenate 'string string '(#\Newline)))
     249            (buffer-end (current-point)))
     250          ;; incomplete expression: enter a newline
     251          (progn
     252            (insert-character (current-point-for-insertion) #\NewLine))))))
    249253
    250254(defun copy-region-to-input (region)
    251   (let* ((region-string (when region (region-to-string region))))
     255  (let* ((region-string (when region (region-to-string region)))
     256         (input-mark (value buffer-input-mark))
     257         (end-mark (region-end (buffer-region (current-buffer))))
     258         (input-region (region input-mark end-mark)))
    252259    (with-mark ((input-mark (value buffer-input-mark)))
    253260      (move-mark (current-point) input-mark)
     261      (delete-region input-region)
    254262      (insert-string (current-point) region-string)
    255263      (buffer-end (current-point)))))
Note: See TracChangeset for help on using the changeset viewer.