bound-check-menu
Victor Martinez <[email protected]> Mon, 17 Aug 2020 15:05:37 +0000
| Newsgroups | gmane.comp.window-managers.stumpwm.devel |
|---|---|
| Message-ID | <[email protected]> |
bound-check-menu does not consider monitor height/width.
For instance if you try in package stumpwm-user
(select-from-menu
(current-screen)
(loop repeat 100 for i = 0 then (1+ i) collect (format nil "~a" i)))
depending on the monitor size parts of the menu are not shown.
The following replacement for bound-check-menu in menu-definitions.lisp works
for me although it doesn't consider monitor width, modline higth, boders, ...:
in menu-definitions.lisp:
; new function
(defun menu-height (menu)
(let ((len (length (menu-table menu))))
(min (or *menu-maximum-height* len) len)))
; new function
(defun frame-lines-height (&optional
(frame (current-head))
(screen (current-screen)))
"Return how many text lines fit in the current monitor (?) considering the font in use."
(floor (frame-height frame)
(xlib:font-property (stumpwm::screen-font screen) :pixel_size)))
; new function
(defun max-menu-height (&optional
(frame (current-head))
(screen (current-screen)))
"Todo: consider modline height, border height, ..."
(max 0 (- (frame-lines-height frame screen) 3))) ; 3 because of 1 or 2 lines "..." and one line for menu label
(defun menu-start-end (i m l)
"Return the start index and end index of the partition of l which corresponds
to index i where l is greedily partitioned in pieces of max size m."
(values
(* m (floor i m))
(min l (+ m (* m (floor i m))))))
(defun bound-check-menu (menu)
"Adjust the menu view and selected item based
on current view and new selection."
(let ((len (length (menu-table menu))))
;; Wrap around
(setf (menu-selected menu)
(if (zerop len) 0 (mod (menu-selected menu) len)))
(setf (values (menu-view-start menu)
(menu-view-end menu))
(menu-start-end
(menu-selected menu)
(max-menu-height)
len))))
signature.asc
(application/pgp-signature, 659 B)
-----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEFwXOpRjhm5+GfH+k4NmopOeWrEgFAl86nL0ACgkQ4NmopOeW rEixnQv/R9mb0uHm38tSmiTaGgl2wuJdCELQz91zpjW1XD+nTe5fzW8bCFPjGFDt Tlg9mbLFC5IUR9O+vEvwgAqduJbdmzI9lJC0HyywHtO1YIFKMV6sZJXuU1sxpOYt kkuZzGzNkU5sVgeDbsh9YPFixGF00973XMAj+GLZ3cxkLwL0FExcRlzbDy6UONbb 5/sllDeDU6MgmKeXMTFnh0O4/wzT9uXYZMQTvikbfWJuNypfvjKs6p96F7ovb6X+ IwjzVaBebdu0Z5RzUgtkKDHMNw77eQ0XCaX8On75Jt9yKC9zGagQkoJUpuKvneGs CQXFkxIuIZuJbAiYq8h/lYl2xk5sYJpFozsp+2UgOBXqN3Sbk4aRBD9bVJVlEDS5 e1d8yrt1/xjQs3dLr9Ee0Efz4YP20SwhVDELtvig6lFUiWl68557KhL216VcsL9N EyFgdULKro16q/C7FVpZhZxB4GdI4fSciAdqRafynUXzJ69cDr8ZCP/ByaCFZeBU pxrAkJM8 =+4Ot -----END PGP SIGNATURE-----