[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 485060813b 277/372: - added procedures to pad mul
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 485060813b 277/372: - added procedures to pad multiline annotation text. |
Date: |
Fri, 4 Feb 2022 16:59:07 -0500 (EST) |
branch: elpa/annotate
commit 485060813b34d2d3344d099b263c9dd66c435f6f
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- added procedures to pad multiline annotation text.
---
annotate.el | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 53 insertions(+), 7 deletions(-)
diff --git a/annotate.el b/annotate.el
index 65b899eb2a..2e7ce2b8a0 100644
--- a/annotate.el
+++ b/annotate.el
@@ -1029,6 +1029,55 @@ to 'maximum-width'."
(append lineated
(list (pad last-line max-width nil)))))))
+(cl-defun annotate--split-lines (text &optional (separator "\n"))
+ "Returns text splitted by `separator' (default: \"\n\")"
+ (split-string text "\n"))
+
+(defun annotate-wrap-annotation-in-box (annotation-overlay
+ begin-of-line
+ end-of-line
+ annotation-on-is-own-line-p)
+ "Pads or breaks annotation text (as property of
+ `annotation-overlay' so that all lines have the same width.
+
+If annotation is a placed on the margin of a window (that is
`annotation-on-is-own-line-p' is
+nil) the text is broken (regardless of words) to fit on the side
+of the window using `begin-of-line' `end-of-line'.
+
+If annotation is a note that is placed in its own line the text is padded with
spaces so that
+a 'box' surround the text without seams, e.g:
+
+aaa aaa
+aa -> aa*
+a a**
+"
+ (let ((annotation-text (overlay-get annotation-overlay 'annotation)))
+ (cl-labels ((boxify-multiline ()
+ (let* ((lines (annotate--split-lines
annotation-text))
+ (lines-widths (mapcar 'string-width lines))
+ (max-width (cl-reduce (lambda (a b) (if (> a b)
+ a
+ b))
+ lines-widths
+ :initial-value -1))
+ (padding-sizes (mapcar (lambda (a) (max (- max-width
+
(string-width a)
+ 1)
+ 0))
+ lines))
+ (paddings (mapcar (lambda (a) (make-string a ? ))
+ padding-sizes))
+ (box-lines (cl-mapcar (lambda (a b) (concat a b))
+ lines paddings)))
+ (cl-reduce (lambda (a b) (concat a "\n" b))
+ box-lines))))
+
+ (if annotation-on-is-own-line-p
+ (list (boxify-multiline))
+ (save-match-data
+ (annotate--split-lines (annotate-lineate annotation-text
+ (- end-of-line
begin-of-line))))))))
+
(defun annotate--annotation-builder ()
"Searches the line before point for annotations, and returns a
`facespec` with the annotation in its `display` property."
@@ -1088,13 +1137,10 @@ to 'maximum-width'."
annotation-long-p))
(otherwise
nil)))
- (multiline-annotation (if position-new-line-p
- (list (overlay-get ov 'annotation))
- (save-match-data
- (split-string (annotate-lineate
(overlay-get ov
-
'annotation)
- (-
eol bol))
- "\n"))))
+ (multiline-annotation (annotate-wrap-annotation-in-box ov
+ bol
+ eol
+
position-new-line-p))
(annotation-stopper (if position-new-line-p
(if (= annotation-counter
(length overlays))
- [nongnu] elpa/annotate c42686bab5 271/372: - allow overwriting (even partial) of annotations., (continued)
- [nongnu] elpa/annotate c42686bab5 271/372: - allow overwriting (even partial) of annotations., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9b824d23ec 267/372: - updated Changelog and NEWS.org., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e015655f62 255/372: - fixed version number contained in code top comment., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 2bf7a7c1ac 254/372: Merge pull request #77 from cage2/signalling-errors, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate bd31608f50 260/372: - added command 'annotate-summary-of-file-from-current-pos', ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a8857153ca 276/372: - extracted local function and taken into account info node names, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 12ad966a9d 278/372: - wrapped 'annotate-wrap-annotation-in-box' with 'save-match-data., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 401dab7723 291/372: - updated README, Changelog and version number., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 44ac24f63d 274/372: Merge pull request #87 from cage2/overwrite-annotations, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 8b06586497 282/372: - fixed integration of multiline annotated text., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 485060813b 277/372: - added procedures to pad multiline annotation text.,
ELPA Syncer <=
- [nongnu] elpa/annotate e004ae7e97 281/372: - updated version;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3e5d14fde8 287/372: - updated documentation., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6415fb6111 294/372: - updated NEWS and CHANGELOG;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4890d2d2a2 295/372: Merge pull request #95 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 85d7c87e08 293/372: - added padding also for notes placed on the margin of the window., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ac55086d60 301/372: - fixed typo., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3415b7ac08 321/372: - changed behaviour when user is annotation a newline character;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f33eecba7b 362/372: - prevented asking to delete a database that does not actually exists, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1350e1d073 338/372: - fixed annotated text shown in the summary window, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3e3c1b1066 368/372: - fixed function name;, ELPA Syncer, 2022/02/04