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

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

[nongnu] elpa/telephone-line 7a6ac904b3 059/195: Further consolidate old


From: ELPA Syncer
Subject: [nongnu] elpa/telephone-line 7a6ac904b3 059/195: Further consolidate old stuff into new stuff
Date: Wed, 5 Jan 2022 02:59:26 -0500 (EST)

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

    Further consolidate old stuff into new stuff
---
 telephone-line-utils.el | 43 ++++++++++++++++---------------------------
 telephone-line.el       |  7 ++++---
 2 files changed, 20 insertions(+), 30 deletions(-)

diff --git a/telephone-line-utils.el b/telephone-line-utils.el
index 82b94ae02c..ba1e92d000 100644
--- a/telephone-line-utils.el
+++ b/telephone-line-utils.el
@@ -41,14 +41,6 @@
   :type 'boolean
   :group 'telephone-line-evil)
 
-(defun telephone-line-separator-height ()
-  "Get the height for a telephone-line separator."
-  (or telephone-line-height (frame-char-height)))
-
-(defun telephone-line-separator-width ()
-  "Get the default width for a telephone-line separator."
-  (ceiling (telephone-line-separator-height) 2))
-
 (defun telephone-line-create-axis (length)
   "Create an axis of length LENGTH.
 For odd lengths, this is a sequence from -floor(LENGTH/2) to
@@ -202,36 +194,33 @@ Return nil for blank/empty strings."
    (alt-char :initarg :alt-char)
    (image-cache :initform (make-hash-table :test 'equal :size 10))))
 
+(defmethod telephone-line-separator-height ((obj telephone-line-separator))
+  (or telephone-line-height (frame-char-height)))
+
+(defmethod telephone-line-separator-width ((obj telephone-line-separator))
+  (or (oref obj forced-width) (ceiling (telephone-line-separator-height obj) 
2)))
+
 (defclass telephone-line-subseparator (telephone-line-separator)
   ((pattern-func :initarg :pattern-func :initform 
#'telephone-line-row-pattern-hollow)))
 
-(defun telephone-line--create-body (width height axis-func pattern-func)
+(defmethod telephone-line-separator-create-body ((obj 
telephone-line-separator))
   "Create a bytestring of a PBM image body of dimensions WIDTH and HEIGHT, and 
shape created from AXIS-FUNC and PATTERN-FUNC."
-  (let* ((normalized-axis (telephone-line--normalize-axis
-                           (mapcar axis-func (telephone-line-create-axis 
height))))
+  (let* ((height (telephone-line-separator-height obj))
+         (width (telephone-line-separator-width obj))
+         (normalized-axis (telephone-line--normalize-axis
+                           (mapcar (oref obj axis-func) 
(telephone-line-create-axis height))))
          (range (1+ (seq-max normalized-axis)))
          (scaling-factor (/ width (float range))))
     (mapcar (lambda (x)
-              (funcall pattern-func
+              (funcall (oref obj pattern-func)
                        (* x scaling-factor) width))
             normalized-axis)))
 
-(defmethod telephone-line-separator-create-body ((obj 
telephone-line-separator))
-  (telephone-line--create-body (telephone-line-separator-width)
-                 (telephone-line-separator-height)
-                 (oref obj axis-func)
-                 (oref obj pattern-func)))
-
 (defmethod telephone-line-separator-create-body ((obj 
telephone-line-subseparator))
-  (let* ((height (telephone-line-separator-height))
-         (width (or (oref obj forced-width) (telephone-line-separator-width)))
-         (char-width (+ (ceiling width (frame-char-width))
-                        telephone-line-separator-extra-padding)))
-    (telephone-line--pad-body
-     (telephone-line--create-body width height
-                   (oref obj axis-func)
-                   (oref obj pattern-func))
-     char-width)))
+  (telephone-line--pad-body (call-next-method)
+              (+ (ceiling (telephone-line-separator-width obj)
+                          (frame-char-width))
+                 telephone-line-separator-extra-padding)))
 
 (defmethod telephone-line-separator-render ((obj telephone-line-separator) 
foreground background)
   (let* ((bg-color (telephone-line--separator-arg-handler background))
diff --git a/telephone-line.el b/telephone-line.el
index 4374b9767d..c76678d863 100644
--- a/telephone-line.el
+++ b/telephone-line.el
@@ -222,10 +222,10 @@ separators, as they are conditional, are evaluated 
on-the-fly."
                 (seq-reverse segments))
         '(nil . nil))))
 
-(defun telephone-line-width (values num-separators)
+(defun telephone-line-width (values num-separators separator)
   "Get the column-length of VALUES, with NUM-SEPARATORS interposed."
   (let ((base-width (string-width (format-mode-line values)))
-        (separator-width (/ (telephone-line-separator-width)
+        (separator-width (/ (telephone-line-separator-width separator)
                             (float (frame-char-width)))))
     (if window-system
         (+ base-width
@@ -265,7 +265,8 @@ separators, as they are conditional, are evaluated 
on-the-fly."
     (:eval (telephone-line-fill
             (telephone-line-width
              ',(telephone-line--generate-mode-line-rhs)
-             ,(- (length telephone-line-rhs) 1))))
+             ,(- (length telephone-line-rhs) 1)
+             ,telephone-line-primary-right-separator)))
     ,@(telephone-line--generate-mode-line-rhs)))
 
 (defvar telephone-line--default-mode-line mode-line-format)



reply via email to

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