This patch allows the user to customize vertical padding in the message window. This is done by setting the new variable *message-window-vertical-padding*.
For clarity it also deprecates *message-window-padding* in favor of new variable *message-window-horizontal-padding*. A new function message-window-horizontal-padding is defined for compatibility, returning the value of *message-window-padding* if set, otherwise *message-window-horizontal-padding*. Lacking something like defalias I'm not sure how to make this cleaner. Thanks, Thomas
>From 84cdfb59ee50ba4bedb3bce73cea94722c16f46e Mon Sep 17 00:00:00 2001 From: Thomas Morgan <t...@ziiuu.com> Date: Tue, 28 Feb 2012 16:06:07 +0100 Subject: [PATCH] Make vertical padding in message window customizable. Define new variables `*message-window-horizontal-padding*' and `*message-window-vertical-padding*'. Add function `message-window-horizontal-padding' to allow for use of now deprecated variable `*message-window-padding*'. --- NEWS | 3 +++ color.lisp | 3 ++- input.lisp | 27 ++++++++++++++++----------- message-window.lisp | 19 +++++++++++++------ primitives.lisp | 17 +++++++++++++++-- stumpwm.texi.in | 2 ++ 6 files changed, 51 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index afb64f0..394cd23 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ This file documents user visible changes between versions of StumpWM ** support for ECL added +** New variables *message-window-horizontal-padding* and *message-window-vertical-padding* +These replace *message-window-padding* which is now deprecated. + * Changes since 0.9.5 ** add frame-windowlist command diff --git a/color.lisp b/color.lisp index 30396bc..155f686 100644 --- a/color.lisp +++ b/color.lisp @@ -226,7 +226,8 @@ then call (update-color-map).") while en)) when (find i highlights :test 'eql) do (when draw (invert-rect screen px - 0 (* i height) + 0 + (+ *message-window-vertical-padding* (* i height)) (xlib:drawable-width px) height))) (when draw diff --git a/input.lisp b/input.lisp index 3013b87..5d126ff 100644 --- a/input.lisp +++ b/input.lisp @@ -110,7 +110,8 @@ (defun setup-input-window (screen prompt input) "Set the input window up to read input" (let* ((height (+ (xlib:font-descent (screen-font screen)) - (xlib:font-ascent (screen-font screen)))) + (xlib:font-ascent (screen-font screen)) + (* 2 *message-window-vertical-padding*))) (win (screen-input-window screen))) ;; Window dimensions (xlib:with-state (win) @@ -249,36 +250,40 @@ match with an element of the completions." (width (+ prompt-width (max 100 (+ full-string-width space-width tail-width))))) (xlib:with-state (win) - (xlib:clear-area win :x (+ *message-window-padding* + (xlib:clear-area win :x (+ (message-window-horizontal-padding) prompt-width string-width)) - (setf (xlib:drawable-width win) (+ width (* *message-window-padding* 2))) + (setf (xlib:drawable-width win) (+ width (* (message-window-horizontal-padding) 2))) (setup-win-gravity screen win *input-window-gravity*)) (xlib:with-state (win) (xlib:draw-image-glyphs win gcontext - *message-window-padding* - (xlib:font-ascent (screen-font screen)) + (message-window-horizontal-padding) + (+ (xlib:font-ascent (screen-font screen)) + *message-window-vertical-padding*) prompt :translate #'translate-id :size 16) (xlib:draw-image-glyphs win gcontext - (+ *message-window-padding* prompt-width) - (xlib:font-ascent (screen-font screen)) + (+ (message-window-horizontal-padding) prompt-width) + (+ (xlib:font-ascent (screen-font screen)) + *message-window-vertical-padding*) string :translate #'translate-id :size 16) (xlib:draw-image-glyphs win gcontext - (+ *message-window-padding* prompt-width full-string-width space-width) - (xlib:font-ascent (screen-font screen)) + (+ (message-window-horizontal-padding) + prompt-width full-string-width space-width) + (+ (xlib:font-ascent (screen-font screen)) + *message-window-vertical-padding*) tail :translate #'translate-id :size 16) ;; draw a block cursor (invert-rect screen win - (+ *message-window-padding* + (+ (message-window-horizontal-padding) prompt-width (xlib:text-width (screen-font screen) (subseq string 0 pos) :translate #'translate-id)) - 0 + *message-window-vertical-padding* (xlib:text-width (screen-font screen) (if (>= pos (length string)) " " (string (char string pos))) diff --git a/message-window.lisp b/message-window.lisp index 908d41e..7f4ab30 100644 --- a/message-window.lisp +++ b/message-window.lisp @@ -64,14 +64,15 @@ function expects to be wrapped in a with-state for win." (xlib:drawable-x win) (max (head-x (current-head)) (+ (head-x (current-head)) x))))))) (defun setup-message-window (screen lines width) - (let ((height (* lines - (+ (xlib:font-ascent (screen-font screen)) - (xlib:font-descent (screen-font screen))))) + (let ((height (+ (* lines + (+ (xlib:font-ascent (screen-font screen)) + (xlib:font-descent (screen-font screen)))) + (* 2 *message-window-vertical-padding*))) (win (screen-message-window screen))) ;; Now that we know the dimensions, raise and resize it. (xlib:with-state (win) (setf (xlib:drawable-height win) height - (xlib:drawable-width win) (+ width (* *message-window-padding* 2)) + (xlib:drawable-width win) (+ width (* (message-window-horizontal-padding) 2)) (xlib:window-priority win) :above) (setup-win-gravity screen win *message-window-gravity*)) (xlib:map-window win) @@ -208,9 +209,15 @@ function expects to be wrapped in a with-state for win." the nth entry to highlight." (when strings (unless *executing-stumpwm-command* - (let ((width (render-strings screen (screen-message-cc screen) *message-window-padding* 0 strings '() nil))) + (let ((width (render-strings screen (screen-message-cc screen) + (message-window-horizontal-padding) + *message-window-vertical-padding* + strings '() nil))) (setup-message-window screen (length strings) width) - (render-strings screen (screen-message-cc screen) *message-window-padding* 0 strings highlights)) + (render-strings screen (screen-message-cc screen) + (message-window-horizontal-padding) + *message-window-vertical-padding* + strings highlights)) (setf (screen-current-msg screen) strings (screen-current-msg-highlights screen) diff --git a/primitives.lisp b/primitives.lisp index 50d062e..a499e96 100644 --- a/primitives.lisp +++ b/primitives.lisp @@ -319,8 +319,21 @@ Include only those we are ready to support.") "The events to listen for on managed windows' parents.") ;; Message window variables -(defvar *message-window-padding* 5 - "The number of pixels that pad the text in the message window.") +(defvar *message-window-horizontal-padding* 5 + "The number of pixels that pad the text horizontally in the message window.") + +(defvar *message-window-padding* nil + "The number of pixels that pad the text horizontally in the message window. +Deprecated: please use `*message-window-horizontal-padding*'.") + +;; Provide for the case that deprecated variable +;; `*message-window-padding*' has been set. +(defun message-window-horizontal-padding () + "Return number of pixels that pad the text horizontally in the message window." + (or *message-window-padding* *message-window-horizontal-padding*)) + +(defvar *message-window-vertical-padding* 0 + "The number of pixels that pad the text vertically in the message window.") (defvar *message-window-gravity* :top-right "This variable controls where the message window appears. The follow diff --git a/stumpwm.texi.in b/stumpwm.texi.in index ef283c3..3ff15ff 100644 --- a/stumpwm.texi.in +++ b/stumpwm.texi.in @@ -684,6 +684,8 @@ functions and variables. @@@ set-font ### *message-window-padding* +### *message-window-horizontal-padding* +### *message-window-vertical-padding* ### *message-window-gravity* ### *timeout-wait* ### *input-window-gravity* -- 1.7.5.4
_______________________________________________ Stumpwm-devel mailing list Stumpwm-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/stumpwm-devel