branch: externals/posframe
commit f413a4f622eb7c94b73985cab6fc3cfc85333872
Author: conao3 <[email protected]>
Commit: conao3 <[email protected]>
add center handler
Add below center handler functions
- posframe-poshandler-frame-bottom-center
- posframe-poshandler-window-top-center
- posframe-poshandler-window-bottom-center
---
posframe.el | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 55 insertions(+), 9 deletions(-)
diff --git a/posframe.el b/posframe.el
index 561ba3f..3eb533d 100644
--- a/posframe.el
+++ b/posframe.el
@@ -382,15 +382,18 @@ The builtin poshandler functions are listed below:
2. `posframe-poshandler-frame-top-center'
3. `posframe-poshandler-frame-top-left-corner'
4. `posframe-poshandler-frame-top-right-corner'
-5. `posframe-poshandler-frame-bottom-left-corner'
-6. `posframe-poshandler-frame-bottom-right-corner'
-7. `posframe-poshandler-window-center'
-8. `posframe-poshandler-window-top-left-corner'
-9. `posframe-poshandler-window-top-right-corner'
-10. `posframe-poshandler-window-bottom-left-corner'
-11. `posframe-poshandler-window-bottom-right-corner'
-12. `posframe-poshandler-point-top-left-corner'
-13. `posframe-poshandler-point-bottom-left-corner'
+5. `posframe-poshandler-frame-bottom-center'
+6. `posframe-poshandler-frame-bottom-left-corner'
+7. `posframe-poshandler-frame-bottom-right-corner'
+8. `posframe-poshandler-window-center'
+9. `posframe-poshandler-window-top-center'
+10. `posframe-poshandler-window-top-left-corner'
+11. `posframe-poshandler-window-top-right-corner'
+12. `posframe-poshandler-window-bottom-center'
+13. `posframe-poshandler-window-bottom-left-corner'
+14. `posframe-poshandler-window-bottom-right-corner'
+15. `posframe-poshandler-point-top-left-corner'
+16. `posframe-poshandler-point-bottom-left-corner'
This posframe's buffer is BUFFER-OR-NAME, which can be a buffer
or a name of a (possibly nonexistent) buffer.
@@ -879,6 +882,19 @@ in docstring of `posframe-show'."
(plist-get info :mode-line-height)
(plist-get info :minibuffer-height))))
+(defun posframe-poshandler-frame-bottom-center (info)
+ "Posframe's position handler.
+
+Get a position which let posframe stay onto its parent-frame's
+bottom center. The structure of INFO can be found in docstring of
+`posframe-show'."
+ (cons (/ (- (plist-get info :parent-frame-width)
+ (plist-get info :posframe-width))
+ 2)
+ (- 0
+ (plist-get info :mode-line-height)
+ (plist-get info :minibuffer-height))))
+
(defun posframe-poshandler-window-center (info)
"Posframe's position handler.
@@ -919,6 +935,19 @@ docstring of `posframe-show'."
(- 0 posframe-width))
window-top)))
+(defun posframe-poshandler-window-top-center (info)
+ "Posframe's position handler.
+
+Get a position which let posframe stay onto current window's
+top center. The structure of INFO can be found in docstring of
+`posframe-show'."
+ (let* ((window-left (plist-get info :parent-window-left))
+ (window-top (plist-get info :parent-window-top))
+ (window-width (plist-get info :parent-window-width))
+ (posframe-width (plist-get info :posframe-width)))
+ (cons (+ window-left (/ (- window-width posframe-width) 2))
+ window-top)))
+
(defun posframe-poshandler-window-bottom-left-corner (info)
"Posframe's position handler.
@@ -952,6 +981,23 @@ docstring of `posframe-show'."
(+ window-top window-height
(- 0 mode-line-height posframe-height)))))
+(defun posframe-poshandler-window-bottom-center (info)
+ "Posframe's position handler.
+
+Get a position which let posframe stay onto current window's
+bottom center. The structure of INFO can be found in docstring of
+`posframe-show'."
+ (let* ((window-left (plist-get info :parent-window-left))
+ (window-top (plist-get info :parent-window-top))
+ (window-width (plist-get info :parent-window-width))
+ (window-height (plist-get info :parent-window-height))
+ (posframe-width (plist-get info :posframe-width))
+ (posframe-height (plist-get info :posframe-height))
+ (mode-line-height (plist-get info :mode-line-height)))
+ (cons (+ window-left (/ (- window-width posframe-width) 2))
+ (+ window-top window-height
+ (- 0 mode-line-height posframe-height)))))
+
(provide 'posframe)
;;; posframe.el ends here