emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/telephone-line 2e7ba0bfc2 015/195: Make utf-8 separators a


From: ELPA Syncer
Subject: [nongnu] elpa/telephone-line 2e7ba0bfc2 015/195: Make utf-8 separators a part of pbm separators, rather than separate entities altogether
Date: Wed, 5 Jan 2022 02:59:17 -0500 (EST)

branch: elpa/telephone-line
commit 2e7ba0bfc27a2584e0d38a9f34b51a258b8fef10
Author: Daniel Bordak <dbordak@fastmail.fm>
Commit: Daniel Bordak <dbordak@fastmail.fm>

    Make utf-8 separators a part of pbm separators, rather than separate 
entities altogether
    
    The idea is that now a given separator function will have a graphic and 
utf-8 version, so that you don't need to set up a conditional to decide which 
separator you want.
---
 telephone-line-separators.el | 48 ++++++++------------------------------------
 telephone-line-utils.el      | 28 +++++++++++++++-----------
 2 files changed, 24 insertions(+), 52 deletions(-)

diff --git a/telephone-line-separators.el b/telephone-line-separators.el
index 6c2e507626..9716c04646 100644
--- a/telephone-line-separators.el
+++ b/telephone-line-separators.el
@@ -27,26 +27,6 @@
 (require 'color)
 (require 'telephone-line-utils)
 
-(defcustom telephone-line-utf-8-primary-left-separator #xe0b0
-    "The unicode codepoint for the left facing primary separator."
-    :group 'telephone-line
-    :type  '(choice integer (const nil)))
-
-(defcustom telephone-line-utf-8-secondary-left-separator #xe0b1
-    "The unicode codepoint for the left facing secondary separator."
-    :group 'telephone-line
-    :type  '(choice integer (const nil)))
-
-(defcustom telephone-line-utf-8-primary-right-separator #xe0b2
-    "The unicode codepoint for the right facing primary separator."
-    :group 'telephone-line
-    :type  '(choice integer (const nil)))
-
-(defcustom telephone-line-utf-8-secondary-right-separator #xe0b3
-    "The unicode codepoint for the right facing secondary separator."
-    :group 'telephone-line
-    :type  '(choice integer (const nil)))
-
 (defun telephone-line-row-pattern-fixed-gradient (_ width)
   "Create a gradient bytestring of WIDTH from FG-COLOR to BG-COLOR."
   (mapcar (lambda (num)
@@ -54,13 +34,17 @@
           (number-sequence 1 width)))
 
 (telephone-line-defseparator telephone-line-abs-right
-  #'abs #'telephone-line-row-pattern)
+  #'abs #'telephone-line-row-pattern
+  #xe0b2)
 (telephone-line-defseparator telephone-line-abs-left
-  (telephone-line-complement abs) #'telephone-line-row-pattern)
+  (telephone-line-complement abs) #'telephone-line-row-pattern
+  #xe0b0)
 (telephone-line-defsubseparator telephone-line-abs-hollow-right
-  #'abs #'telephone-line-row-pattern-hollow)
+  #'abs #'telephone-line-row-pattern-hollow
+  #xe0b3)
 (telephone-line-defsubseparator telephone-line-abs-hollow-left
-  (telephone-line-complement abs) #'telephone-line-row-pattern-hollow)
+  (telephone-line-complement abs) #'telephone-line-row-pattern-hollow
+  #xe0b1)
 (telephone-line-defseparator telephone-line-cubed-right
   (lambda (x) (expt x 3)) #'telephone-line-row-pattern)
 (telephone-line-defseparator telephone-line-cubed-left
@@ -78,21 +62,5 @@
 (defmemoize telephone-line-nil (color1 color2)
   nil)
 
-(defmemoize telephone-line-utf-8-filled-left (foreground background)
-  (propertize (char-to-string telephone-line-utf-8-primary-left-separator)
-              'face `(:foreground ,foreground :background ,background)))
-
-(defmemoize telephone-line-utf-8-filled-right (background foreground) ;Note 
the reversed params
-  (propertize (char-to-string telephone-line-utf-8-primary-right-separator)
-              'face `(:foreground ,foreground :background ,background)))
-
-(defmemoize telephone-line-utf-8-left (foreground background)
-  (propertize (concat " " (char-to-string 
telephone-line-utf-8-secondary-left-separator) " ")
-              'face `(:foreground ,foreground :background ,background)))
-
-(defmemoize telephone-line-utf-8-right (foreground background)
-  (propertize (concat " " (char-to-string 
telephone-line-utf-8-secondary-right-separator) " ")
-              'face `(:foreground ,foreground :background ,background)))
-
 (provide 'telephone-line-separators)
 ;;; telephone-line-separators.el ends here
diff --git a/telephone-line-utils.el b/telephone-line-utils.el
index 3fb7d8d4e5..fac12947c9 100644
--- a/telephone-line-utils.el
+++ b/telephone-line-utils.el
@@ -139,26 +139,29 @@ color1 and color2."
       (face-attribute arg :background)
     arg))
 
-(defmacro -defseparator-internal (name body)
+(defmacro -defseparator-internal (name body &optional alt-string)
   (declare (indent defun))
   `(defmemoize ,name (foreground background)
-     (when window-system
-       (telephone-line-propertize-image
-        (telephone-line--create-pbm-image
-         ,body
-         (telephone-line--separator-arg-handler background)
-         (telephone-line--separator-arg-handler foreground))))))
-
-(defmacro defseparator (name axis-func pattern-func &optional forced-width)
+     (if window-system
+         (telephone-line-propertize-image
+          (telephone-line--create-pbm-image
+           ,body
+           (telephone-line--separator-arg-handler background)
+           (telephone-line--separator-arg-handler foreground)))
+       (propertize ,alt-string
+                   'face `(:foreground ,foreground :background ,background)))))
+
+(defmacro defseparator (name axis-func pattern-func &optional alt-char 
forced-width)
   "Define a separator named NAME, using AXIS-FUNC and PATTERN-FUNC to create 
the shape, optionally forcing FORCED-WIDTH.
 
 NOTE: Forced-width primary separators are not currently supported."
   `(telephone-line--defseparator-internal ,name
      (let ((height (telephone-line-separator-height))
            (width (or ,forced-width (telephone-line-separator-width))))
-       (telephone-line-create-body width height ,axis-func ,pattern-func))))
+       (telephone-line-create-body width height ,axis-func ,pattern-func))
+     (char-to-string ,alt-char)))
 
-(defmacro defsubseparator (name axis-func pattern-func &optional forced-width)
+(defmacro defsubseparator (name axis-func pattern-func &optional alt-char 
forced-width)
   "Define a subseparator named NAME, using AXIS-FUNC and PATTERN-FUNC to 
create the shape, optionally forcing FORCED-WIDTH."
   `(telephone-line--defseparator-internal ,name
      (let* ((height (telephone-line-separator-height))
@@ -167,7 +170,8 @@ NOTE: Forced-width primary separators are not currently 
supported."
                            telephone-line-separator-extra-padding)))
         (telephone-line-pad-body
          (telephone-line-create-body width height ,axis-func ,pattern-func)
-         char-width))))
+         char-width))
+     (string ?  ,alt-char ? )))
 
 (defun pad-body (body char-width)
   (let* ((body-width (length (car body)))



reply via email to

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