stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [STUMP] [PATCH] Right-justification of mode line elements


From: Bronsa
Subject: Re: [STUMP] [PATCH] Right-justification of mode line elements
Date: Mon, 1 Nov 2010 17:36:40 +0100

Man, i think i love you

2010/11/1, Nils Anspach <address@hidden>:
> Hello list,
>
> attached is a patch which allows for text elements of the mode line
> (and those of the message window, if that is required) to be
> right-justified.
>
> For this to work you have to put a '^>' into the respective format
> command, for instance:
>
> (setf *screen-mode-line-format*
>       (list "[%n:%h] %v^>"
>             '(:eval (run-shell-command "echo -n `date +'%a %e-%b %R'`"
>             t))))
>
> It also works in case of multiple lines of text. Everything after '^>'
> up to the end of the respective line is right-justified. The next line
> then starts left-justified again.
>
> Nils
>
> ---
> diff --git a/color.lisp b/color.lisp
> index 5885861..425feb7 100644
> --- a/color.lisp
> +++ b/color.lisp
> @@ -193,13 +193,15 @@ then call (update-color-map).")
>      (loop for s in strings
>            ;; We need this so we can track the row for each element
>            for i from 0 to (length strings)
> -          do (let ((x 0) (off 0))
> +          do (let ((x 0) (off 0) (len (length s)))
>                 (loop
>                  for st = 0 then (+ en (1+ off))
>                  as en = (position #\^ s :start st)
>                  do (progn
> -                     (let ((en (if (and en (eq #\^ (elt s (1+ en)))) (1+
> en) en)))
> -                       (when draw
> +                  (let ((en (cond ((and en (= (1+ en) len)) nil)
> +                                  ((and en (char= #\^ (char s (1+ en)))) (1+ 
> en))
> +                                  (t en))))
> +                    (when draw
>                           (xlib:draw-image-glyphs px gc
>                                                   (+ padx x)
>                                                   (+ pady (* i height)
> @@ -207,11 +209,22 @@ then call (update-color-map).")
>                                                   (subseq s st en)
>                                                   :translate #'translate-id
>                                                   :size 16))
> -                       (setf x (+ x (xlib:text-width (screen-font screen)
> (subseq s st en) :translate #'translate-id))))
> -                     (when en
> -                       (setf off (set-color screen cc s (1+ en))))
> -                     (setf width (max width x)))
> -                while en))
> +                    (setf x (+ x (xlib:text-width (screen-font screen) 
> (subseq s st
> en) :translate #'translate-id))
> +                          width (max width x)))
> +                  (when (and en (< (1+ en) len))
> +                    ;; right-align rest of string?
> +                    (if (char= #\> (char s (1+ en)))
> +                        (progn
> +                          (when draw
> +                            (setf x (- (xlib:drawable-width px) (* 2 padx)
> +                                       ;; get width of rest of s
> +                                       (render-strings screen cc padx pady
> +                                                       (list (subseq s (+ en 
> 2)))
> +                                                       '() nil))
> +                                  width (- (xlib:drawable-width px) (* 2 
> padx))))
> +                          (setf off 1))
> +                        (setf off (set-color screen cc s (1+ en))))))
> +               while en))
>            when (find i highlights :test 'eql)
>            do (when draw (invert-rect screen px
>                                       0 (* i height)
> --
> 1.6.5.7
>
>
> _______________________________________________
> Stumpwm-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/stumpwm-devel
>

-- 
Inviato dal mio dispositivo mobile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]