Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posframe-poshandler-point-bottom-center feature? #131

Open
rickalex21 opened this issue May 18, 2023 · 2 comments
Open

posframe-poshandler-point-bottom-center feature? #131

rickalex21 opened this issue May 18, 2023 · 2 comments

Comments

@rickalex21
Copy link

Hello, thanks for this awesome package.

I was having problems centering the hydras with hints so I decided to go this route.

For small hydras it's not an issue to use the posframe-poshandler-point-bottom-left-corner
but for bigger ones I would like to center on the cursor above or below. If I'm on the
edge of the screen default to left or right of the cursor.

Is there a way to place the center of the frame above or below the cursor like this?

Thanks

@tumashu
Copy link
Owner

tumashu commented May 19, 2023

Try below poshandler or write your own poshandler.

  1. `posframe-poshandler-point-window-center'
  2. `posframe-poshandler-point-frame-center'

@rickalex21
Copy link
Author

I was looking at posframe-poshandler-point-1 and I noticed that a few functions call it with no arguments other than info? How does it change positions with no arguments...

For example:

(defun posframe-poshandler-point-bottom-left-corner (info)
  "Posframe's position handler.

This poshandler function let top left corner of posframe align to
bottom left corner of point.

The structure of INFO can be found in docstring of
`posframe-show'."
  (posframe-poshandler-point-1 info))

This is what I came up with, not perfect, needs some work. It does not work
on my laptop, only on my hdmi monitor. By any chance is there any way I can use your code to simply the function?

(defun my-posframe-poshandler (info)
  "Custom poshandler function for Posframe."
  (let* ((window (plist-get info :parent-window))
         (pos (plist-get info :position))
         (pos (if (integerp pos) (posn-at-point pos window) pos))
         (pwidth (plist-get info :posframe-width))
         (pheight (plist-get info :posframe-height))
         (fheight (plist-get info :parent-frame-height))
         (fonth (plist-get info :font-height))
         (bottom (+ (nth 2 (window-pixel-edges window)) 10))
         (x (- (car (posn-x-y pos)) (/ pwidth 2)))
         (x (or (and (< x 0) 0) x))
         (y (+ (cdr (posn-x-y pos)) (* fonth 3)))
         (y (or (and (> (+ y pheight ) bottom) (- y (* 2 pheight))) y)))
    (cons x  y)))
  
(let ((hydra-posframe-show-params
         '(:internal-border-width 1
          :internal-border-color "black"
          :poshandler my-posframe-poshandler))
       (hydra-hint-display-type 'posframe))
       
(hydra-org-agenda/body))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants