Victor Martinez
unread,Aug 17, 2020, 11:53:41 AM8/17/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Stumpwm-devel
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))))