[Top][All Lists]

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

Re: More enhancements to fringe bitmaps.

From: Masatake YAMATO
Subject: Re: More enhancements to fringe bitmaps.
Date: Mon, 09 Feb 2004 17:54:44 +0900 (JST)

> I have just committed changes to implement a very old item on my
> personal to-do list:
>    You can now redefine the built-in fringe bitmaps!

> ;;; ====================================================================
> ;;; Here is an example of using a user-defined fringe bitmaps; it is a red
> ;;; circle which can be used to mark a debugger breakpoint (instead of
> ;;; using the display margin as gdba current does).
> ;;;
> ;;; Eval this and try M-x xb RET
> (defface fringe-standout
>   '((t
>      :inherit fringe
>      :foreground "red"))
>   "Face for fringe bitmaps which should stand out.")
> ;; ..xxxx..
> ;; .xxxxxx.
> ;; xxxxxxxx
> ;; xxxxxxxx
> ;; xxxxxxxx
> ;; xxxxxxxx
> ;; .xxxxxx.
> ;; ..xxxx..

> (defvar circle-fringe-bitmap 
>  (define-fringe-bitmap "\x3c\x7e\xff\xff\xff\xff\x7e\x3c"))

Why we have to write such fringe bitmap figure in comments?
Instead, the figure itself should be passed to the lisp function, I think.

=> "<~\377\377\377\377~<"

(defun fringe-make-bitmap-from-strings (strings &optional on off)
  "Make fringe bitmap string from lists of strings.
>From STRINGS, a bitmap string suitable for the argument of 
`define-fringe-bitmap' is made. 

ON and OFF stands for the on-bit and off-bit characters. If ON
is not given, ?x is used. If OFF is not given, ?. is used.

STRINGS is a list of strings. Each element stands for a line
of the bitmap; and its length must be 8. The content of element
must be ON or OFF. 

   \"__@@@@__\") ?@ ?_)


  (unless on  (setq on ?x))
  (unless off (setq off ?.))
  (mapconcat (lambda (string)
               (if (not (eq 8 (length string)))
                   (error "Wrong lenght string: %d" (length string)))
               (let ((i 7)
                     (line 0))
                 (mapc (lambda (c)
                          ((eq on c)
                           (setq line (logior line (lsh 1 i))))
                          ((eq off c))
                           (error "Wrong charset in string: %c" c)))
                         (setq i (1- i)))
                 (funcall 'string line)))
             strings ""))

(defun fringe-decode-bitmap-string (bitmap &optional on off)
  "Make a list of strings from a fringe bitmap string."
  (unless on  (setq on ?x))
  (unless off (setq off ?.))
   (lambda (c)
     (setq c (string-to-char c))
      (if (eq 0 (logand (lsh 1 7) c)) off on)
      (if (eq 0 (logand (lsh 1 6) c)) off on)
      (if (eq 0 (logand (lsh 1 5) c)) off on)
      (if (eq 0 (logand (lsh 1 4) c)) off on)
      (if (eq 0 (logand (lsh 1 3) c)) off on)
      (if (eq 0 (logand (lsh 1 2) c)) off on)
      (if (eq 0 (logand (lsh 1 1) c)) off on)
      (if (eq 0 (logand (lsh 1 0) c)) off on)))

reply via email to

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