aboutsummaryrefslogtreecommitdiff
path: root/bard-elisp/bard-window.el
diff options
context:
space:
mode:
Diffstat (limited to 'bard-elisp/bard-window.el')
-rw-r--r--bard-elisp/bard-window.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/bard-elisp/bard-window.el b/bard-elisp/bard-window.el
index e98e364..8860310 100644
--- a/bard-elisp/bard-window.el
+++ b/bard-elisp/bard-window.el
@@ -1,3 +1,24 @@
+(defvar prot-window-window-sizes
+ '( :max-height (lambda () (floor (frame-height) 3))
+ :min-height 10
+ :max-width (lambda () (floor (frame-width) 4))
+ :min-width 20)
+ "Property list of maximum and minimum window sizes.
+The property keys are `:max-height', `:min-height', `:max-width',
+and `:min-width'. They all accept a value of either a
+number (integer or floating point) or a function.")
+
+(defun prot-window--get-window-size (key)
+ "Extract the value of KEY from `prot-window-window-sizes'."
+ (when-let ((value (plist-get prot-window-window-sizes key)))
+ (cond
+ ((functionp value)
+ (funcall value))
+ ((numberp value)
+ value)
+ (t
+ (error "The value of `%s' is neither a number nor a function" key)))))
+
(defun prot-window-select-fit-size (window)
"Select WINDOW and resize it.
The resize pertains to the maximum and minimum values for height