Commit da210f54 authored by Tomohiro Matsuyama's avatar Tomohiro Matsuyama

Revert "Not to insert newlines."

This reverts commit 88efff50.
parent 6862a473
...@@ -239,7 +239,7 @@ buffer." ...@@ -239,7 +239,7 @@ buffer."
parent depth parent depth
face mouse-face selection-face face mouse-face selection-face
margin-left margin-right margin-left-cancel scroll-bar symbol margin-left margin-right margin-left-cancel scroll-bar symbol
cursor offset scroll-top current-height list padding cursor offset scroll-top current-height list newlines
pattern original-list) pattern original-list)
(defun popup-item-propertize (item &rest properties) (defun popup-item-propertize (item &rest properties)
...@@ -393,7 +393,7 @@ usual." ...@@ -393,7 +393,7 @@ usual."
(unless (overlay-get overlay 'dangle) (unless (overlay-get overlay 'dangle)
(overlay-put overlay 'display (concat prefix (substring content 0 1))) (overlay-put overlay 'display (concat prefix (substring content 0 1)))
(setq prefix nil (setq prefix nil
content (substring content 1))) content (concat (substring content 1))))
(overlay-put overlay (overlay-put overlay
'after-string 'after-string
(concat prefix (concat prefix
...@@ -523,15 +523,13 @@ KEYMAP is a keymap that will be put on the popup contents." ...@@ -523,15 +523,13 @@ KEYMAP is a keymap that will be put on the popup contents."
;; Calculate direction ;; Calculate direction
(popup-calculate-direction height row))) (popup-calculate-direction height row)))
(depth (if parent (1+ (popup-depth parent)) 0)) (depth (if parent (1+ (popup-depth parent)) 0))
padding (newlines (max 0 (+ (- height (count-lines point (point-max))) (if around 1 0))))
current-column) current-column)
;; Case: no room to put overlays ;; Case: no newlines at the end of the buffer
(when (eobp) (when (> newlines 0)
(popup-save-buffer-state (popup-save-buffer-state
(let ((begin (point))) (goto-char (point-max))
(insert " ") (insert (make-string newlines ?\n))))
(setq padding (make-overlay begin (point)))
(overlay-put padding 'evaporate t))))
;; Case: the popup overflows ;; Case: the popup overflows
(if overflow (if overflow
...@@ -556,11 +554,11 @@ KEYMAP is a keymap that will be put on the popup contents." ...@@ -556,11 +554,11 @@ KEYMAP is a keymap that will be put on the popup contents."
(setq margin-left-cancel t)) (setq margin-left-cancel t))
(dotimes (i height) (dotimes (i height)
(let (overlay begin w bottom (dangle t) (prefix "") (postfix "")) (let (overlay begin w (dangle t) (prefix "") (postfix ""))
(when around (when around
(setq bottom (zerop (popup-vertical-motion column direction)))) (popup-vertical-motion column direction))
(setq around t) (setq around t
(setq current-column (if bottom 0 (popup-current-physical-column))) current-column (popup-current-physical-column))
(when (> current-column column) (when (> current-column column)
(backward-char) (backward-char)
...@@ -568,8 +566,7 @@ KEYMAP is a keymap that will be put on the popup contents." ...@@ -568,8 +566,7 @@ KEYMAP is a keymap that will be put on the popup contents."
(when (< current-column column) (when (< current-column column)
;; Extend short buffer lines by popup prefix (line of spaces) ;; Extend short buffer lines by popup prefix (line of spaces)
(setq prefix (make-string (setq prefix (make-string
(+ (if (and (not bottom) (+ (if (= current-column 0)
(= current-column 0))
(- window-hscroll (current-column)) (- window-hscroll (current-column))
0) 0)
(- column current-column)) (- column current-column))
...@@ -577,8 +574,6 @@ KEYMAP is a keymap that will be put on the popup contents." ...@@ -577,8 +574,6 @@ KEYMAP is a keymap that will be put on the popup contents."
(setq begin (point)) (setq begin (point))
(setq w (+ popup-width (length prefix))) (setq w (+ popup-width (length prefix)))
(when bottom
(setq prefix (concat "\n" prefix)))
(while (and (not (eolp)) (> w 0)) (while (and (not (eolp)) (> w 0))
(setq dangle nil) (setq dangle nil)
(decf w (char-width (char-after))) (decf w (char-width (char-after)))
...@@ -586,7 +581,6 @@ KEYMAP is a keymap that will be put on the popup contents." ...@@ -586,7 +581,6 @@ KEYMAP is a keymap that will be put on the popup contents."
(if (< w 0) (if (< w 0)
(setq postfix (make-string (- w) ? ))) (setq postfix (make-string (- w) ? )))
(setq overlay (make-overlay begin (point))) (setq overlay (make-overlay begin (point)))
(overlay-put overlay 'window window) (overlay-put overlay 'window window)
(overlay-put overlay 'dangle dangle) (overlay-put overlay 'dangle dangle)
...@@ -621,7 +615,7 @@ KEYMAP is a keymap that will be put on the popup contents." ...@@ -621,7 +615,7 @@ KEYMAP is a keymap that will be put on the popup contents."
:scroll-top 0 :scroll-top 0
:current-height 0 :current-height 0
:list nil :list nil
:padding padding :newlines newlines
:overlays overlays :overlays overlays
:keymap keymap))) :keymap keymap)))
(push it popup-instances) (push it popup-instances)
...@@ -634,10 +628,14 @@ KEYMAP is a keymap that will be put on the popup contents." ...@@ -634,10 +628,14 @@ KEYMAP is a keymap that will be put on the popup contents."
(mapc 'delete-overlay (popup-overlays popup)) (mapc 'delete-overlay (popup-overlays popup))
(setf (popup-overlays popup) nil) (setf (popup-overlays popup) nil)
(setq popup-instances (delq popup popup-instances)) (setq popup-instances (delq popup popup-instances))
(let ((padding (popup-padding popup))) ;; Restore newlines state
(when (overlayp padding) (let ((newlines (popup-newlines popup)))
(when (> newlines 0)
(popup-save-buffer-state (popup-save-buffer-state
(delete-region (overlay-start padding) (overlay-end padding)))))) (goto-char (point-max))
(dotimes (i newlines)
(if (= (char-before) ?\n)
(delete-char -1)))))))
nil) nil)
(defun popup-draw (popup) (defun popup-draw (popup)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment