[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/telephone-line 835179cc9b 060/195: Put segment stuff back
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/telephone-line 835179cc9b 060/195: Put segment stuff back in the correct place, further refactor for the new separators |
Date: |
Wed, 5 Jan 2022 02:59:26 -0500 (EST) |
branch: elpa/telephone-line
commit 835179cc9b6693aad93d3e0044abf395e49f1de5
Author: Daniel Bordak <dbordak@fastmail.fm>
Commit: Daniel Bordak <dbordak@fastmail.fm>
Put segment stuff back in the correct place, further refactor for the new
separators
---
telephone-line-utils.el | 121 +++++++++++++++++++++++++-----------------------
1 file changed, 62 insertions(+), 59 deletions(-)
diff --git a/telephone-line-utils.el b/telephone-line-utils.el
index ba1e92d000..473f472f49 100644
--- a/telephone-line-utils.el
+++ b/telephone-line-utils.el
@@ -137,56 +137,6 @@ color1 and color2."
`(lambda (x)
(- (,func x))))
-(defun telephone-line--separator-arg-handler (arg)
- "Translate ARG into an appropriate color for a separator."
- (if (facep arg)
- (face-attribute arg :background)
- arg))
-
-(defun telephone-line--pad-body (body char-width)
- "Pad 2d byte-list BODY to a width of CHAR-WIDTH, given as a number of
characters."
- (let* ((body-width (length (car body)))
- (padding-width (- (* char-width (frame-char-width)) body-width))
- (left-padding (make-list (floor padding-width 2) 1))
- (right-padding (make-list (ceiling padding-width 2) 1)))
- (mapcar (lambda (row)
- (append left-padding row right-padding))
- body)))
-
-:autoload
-(defmacro telephone-line-defsegment (name body)
- "Create function NAME by wrapping BODY with telephone-line padding and
propertization."
- (declare (indent defun))
- `(defun ,name (face)
- (telephone-line-raw ,body face)))
-
-:autoload
-(defmacro telephone-line-defsegment* (name body)
- "Create function NAME by wrapping BODY with telephone-line padding and
propertization.
-Segment is not precompiled."
- (declare (indent defun))
- `(defun ,name (face)
- (telephone-line-raw ,body)))
-
-:autoload
-(defmacro telephone-line-defsegment-plist (name plists)
- (declare (indent defun))
- `(defun ,name (face)
- (telephone-line-raw
- (mapcar (lambda (plist)
- (plist-put plist 'face face))
- ,plists))))
-
-:autoload
-(defun telephone-line-raw (str &optional compiled)
- "Conditionally render STR as mode-line data, or just verify output if not
COMPILED.
-Return nil for blank/empty strings."
- (let ((trimmed-str (s-trim (format-mode-line str))))
- (unless (s-blank? trimmed-str)
- (if compiled
- (replace-regexp-in-string "%" "%%" trimmed-str)
- str))))
-
(defclass telephone-line-separator ()
((axis-func :initarg :axis-func)
(pattern-func :initarg :pattern-func :initform #'telephone-line-row-pattern)
@@ -216,33 +166,86 @@ Return nil for blank/empty strings."
(* x scaling-factor) width))
normalized-axis)))
+(defun telephone-line--pad-body (body char-width)
+ "Pad 2d byte-list BODY to a width of CHAR-WIDTH, given as a number of
characters."
+ (let* ((body-width (length (car body)))
+ (padding-width (- (* char-width (frame-char-width)) body-width))
+ (left-padding (make-list (floor padding-width 2) 1))
+ (right-padding (make-list (ceiling padding-width 2) 1)))
+ (mapcar (lambda (row)
+ (append left-padding row right-padding))
+ body)))
+
(defmethod telephone-line-separator-create-body ((obj
telephone-line-subseparator))
(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--arg-handler (arg) :static
+ "Translate ARG into an appropriate color for a separator."
+ (if (facep arg)
+ (face-attribute arg :background)
+ arg))
+
(defmethod telephone-line-separator-render ((obj telephone-line-separator)
foreground background)
- (let* ((bg-color (telephone-line--separator-arg-handler background))
- (fg-color (telephone-line--separator-arg-handler foreground))
- (hash-key (concat bg-color "_" fg-color)))
- (if window-system
+ (telephone-line-separator--render obj
+ (telephone-line-separator--arg-handler foreground)
+ (telephone-line-separator--arg-handler background)))
+
+(defmethod telephone-line-separator--render ((obj telephone-line-separator)
foreground background)
+ (if window-system
+ (let ((hash-key (concat background "_" foreground)))
;; Return cached image if we have it.
(or (gethash hash-key (oref obj image-cache))
(puthash hash-key
(telephone-line-propertize-image
(telephone-line--create-pbm-image
(telephone-line-separator-create-body obj)
- bg-color fg-color))
- (oref obj image-cache)))
+ background foreground))
+ (oref obj image-cache))))
(list :propertize (char-to-string (oref obj alt-char))
- 'face (list :foreground fg-color
- :background bg-color
- :inverse-video t)))))
+ 'face (list :foreground foreground
+ :background background
+ :inverse-video t))))
(defmethod telephone-line-separator-clear-cache ((obj
telephone-line-separator))
(clrhash (oref obj image-cache)))
+:autoload
+(defmacro telephone-line-defsegment (name body)
+ "Create function NAME by wrapping BODY with telephone-line padding and
propertization."
+ (declare (indent defun))
+ `(defun ,name (face)
+ (telephone-line-raw ,body face)))
+
+:autoload
+(defmacro telephone-line-defsegment* (name body)
+ "Create function NAME by wrapping BODY with telephone-line padding and
propertization.
+Segment is not precompiled."
+ (declare (indent defun))
+ `(defun ,name (face)
+ (telephone-line-raw ,body)))
+
+:autoload
+(defmacro telephone-line-defsegment-plist (name plists)
+ (declare (indent defun))
+ `(defun ,name (face)
+ (telephone-line-raw
+ (mapcar (lambda (plist)
+ (plist-put plist 'face face))
+ ,plists))))
+
+:autoload
+(defun telephone-line-raw (str &optional compiled)
+ "Conditionally render STR as mode-line data, or just verify output if not
COMPILED.
+Return nil for blank/empty strings."
+ (let ((trimmed-str (s-trim (format-mode-line str))))
+ (unless (s-blank? trimmed-str)
+ (if compiled
+ (replace-regexp-in-string "%" "%%" trimmed-str)
+ str))))
+
;;Stole this bit from seq.el
(defun telephone-line--activate-font-lock-keywords ()
"Activate font-lock keywords for some symbols defined in telephone-line."
- [nongnu] elpa/telephone-line 220a1a4a89 141/195: Update defaults + unify config, (continued)
- [nongnu] elpa/telephone-line 220a1a4a89 141/195: Update defaults + unify config, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 92a5cc6bb9 136/195: Added segments for window number and projectile., ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 1c154b7fd0 154/195: Inherit error face in telephone-line-error face., ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line a9d89b876d 157/195: Fix for symlinks, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 401a9c6ad6 159/195: Merge pull request #81 from ogdenwebb/fix-projectile-buffer-segment, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line fb62b73c9f 164/195: Add docstring for HUD axis func, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 0e6fbc2a23 165/195: Merge branch 'master' into master, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 1025d435af 169/195: Removed duplicate segment, renamed absolute-path segment for clarity, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 3a6c433348 173/195: Add support for irc clients that use tracking mode, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line bf35654a67 011/195: Merge pull request #7 from syohex/cl-lib, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 835179cc9b 060/195: Put segment stuff back in the correct place, further refactor for the new separators,
ELPA Syncer <=
- [nongnu] elpa/telephone-line ba6a56e027 018/195: Minor mode, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 41edbc236a 053/195: Not sure why I memoized this in the first place?, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 7a6ac904b3 059/195: Further consolidate old stuff into new stuff, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 426a598c4a 056/195: Start work on memoize replacement, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line c73b2c210d 027/195: Fix face definitions, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 5c0af25f19 073/195: Explain config ordering, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 74cd7ea3ee 082/195: Fix telephone-line-nil, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line b2439795a4 078/195: Improve default colors., ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 07858899cc 052/195: Readme update, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line bfd9c8b431 067/195: New string trimmer fixes appearance of paradox line number segment, ELPA Syncer, 2022/01/05