Fix progress bar, add more examples

externals/org-modern
Daniel Mendler 2024-05-15 21:32:02 +02:00
parent 750fd57ec1
commit ea829ce4b3
No known key found for this signature in database
GPG Key ID: D88ADB2A2693CA43
2 changed files with 39 additions and 20 deletions

View File

@ -120,16 +120,34 @@ radio link
* Progress bars
- progress [1/13]
- progress [2/13]
- progress [3/13]
- progress [4/13]
- progress [5/13]
- progress [6/13]
- progress [7/13]
- progress [8/13]
- progress [9/13]
- progress [10/13]
- progress [11/13]
- progress [12/13]
- progress [13/13]
- quotient [1/13]
- quotient [2/13]
- quotient [3/13]
- quotient [4/13]
- quotient [5/13]
- quotient [6/13]
- quotient [7/13]
- quotient [8/13]
- quotient [9/13]
- quotient [10/13]
- quotient [11/13]
- quotient [12/13]
- quotient [13/13]
- percent [0%]
- percent [1%]
- percent [2%]
- percent [5%]
- percent [10%]
- percent [20%]
- percent [30%]
- percent [40%]
- percent [50%]
- percent [60%]
- percent [70%]
- percent [80%]
- percent [90%]
- percent [100%]
- overflow [110%]
- overflow [20/10]

View File

@ -418,12 +418,13 @@ the font.")
"Prettify progress as color-coded bar."
(let* ((beg (match-beginning 1))
(end (match-end 1))
(val (if (match-beginning 2)
(* 0.01 (string-to-number (match-string-no-properties 2)))
(let ((q (string-to-number (match-string-no-properties 4))))
(if (= q 0)
1.0
(/ (* 1.0 (string-to-number (match-string-no-properties 3))) q)))))
(val (min 1.0
(if (match-beginning 2)
(* 0.01 (string-to-number (match-string-no-properties 2)))
(let ((q (string-to-number (match-string-no-properties 4))))
(if (= q 0)
1.0
(/ (* 1.0 (string-to-number (match-string-no-properties 3))) q))))))
(w org-modern-progress)
(complete (floor (* w val)))
(w0 (- end beg 2))
@ -435,7 +436,7 @@ the font.")
(put-text-property complete w 'face 'org-modern-progress-incomplete bar)
(put-text-property beg end 'face 'org-modern-label)
(put-text-property beg (1+ beg) 'display (substring bar 0 w1))
(put-text-property (1- end) end 'display (substring bar (- w w1) w))
(put-text-property (1- end) end 'display (substring bar (+ w1 w0) w))
(dotimes (i w0)
(put-text-property (+ 1 beg i) (+ 2 beg i)
'display (substring bar (+ w1 i) (+ w1 i 1))))))