mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-02-01 15:26:47 +01:00
ui: Add 'indented-string'.
* guix/scripts/pull.scm (display-news-entry): Remove extra space in format string for 'indented-string'. (indented-string): Remove. (display-new/upgraded-packages)[pretty]: Pass #:initial-indent? to 'indented-string'. * guix/ui.scm (indented-string): New procedure.
This commit is contained in:
parent
ea6e2299b4
commit
7b322d3c4c
2 changed files with 20 additions and 15 deletions
|
@ -269,7 +269,7 @@ (define commit
|
||||||
(let ((body (or (assoc-ref body language)
|
(let ((body (or (assoc-ref body language)
|
||||||
(assoc-ref body (%default-message-language))
|
(assoc-ref body (%default-message-language))
|
||||||
"")))
|
"")))
|
||||||
(format port " ~a~%"
|
(format port "~a~%"
|
||||||
(indented-string
|
(indented-string
|
||||||
(parameterize ((%text-width (- (%text-width) 4)))
|
(parameterize ((%text-width (- (%text-width) 4)))
|
||||||
(string-trim-right
|
(string-trim-right
|
||||||
|
@ -520,19 +520,6 @@ (define (ensure-default-profile)
|
||||||
;;; Queries.
|
;;; Queries.
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define (indented-string str indent)
|
|
||||||
"Return STR with each newline preceded by IDENT spaces."
|
|
||||||
(define indent-string
|
|
||||||
(make-list indent #\space))
|
|
||||||
|
|
||||||
(list->string
|
|
||||||
(string-fold-right (lambda (chr result)
|
|
||||||
(if (eqv? chr #\newline)
|
|
||||||
(cons chr (append indent-string result))
|
|
||||||
(cons chr result)))
|
|
||||||
'()
|
|
||||||
str)))
|
|
||||||
|
|
||||||
(define profile-package-alist
|
(define profile-package-alist
|
||||||
(mlambda (profile)
|
(mlambda (profile)
|
||||||
"Return a name/version alist representing the packages in PROFILE."
|
"Return a name/version alist representing the packages in PROFILE."
|
||||||
|
@ -589,7 +576,7 @@ (define* (display-new/upgraded-packages alist1 alist2
|
||||||
(define (pretty str column)
|
(define (pretty str column)
|
||||||
(indented-string (fill-paragraph str (- (%text-width) 4)
|
(indented-string (fill-paragraph str (- (%text-width) 4)
|
||||||
column)
|
column)
|
||||||
4))
|
4 #:initial-indent? #f))
|
||||||
|
|
||||||
(define concise/max-item-count
|
(define concise/max-item-count
|
||||||
;; Maximum number of items to display when CONCISE? is true.
|
;; Maximum number of items to display when CONCISE? is true.
|
||||||
|
|
18
guix/ui.scm
18
guix/ui.scm
|
@ -104,6 +104,7 @@ (define-module (guix ui)
|
||||||
read/eval
|
read/eval
|
||||||
read/eval-package-expression
|
read/eval-package-expression
|
||||||
check-available-space
|
check-available-space
|
||||||
|
indented-string
|
||||||
fill-paragraph
|
fill-paragraph
|
||||||
%text-width
|
%text-width
|
||||||
texi->plain-text
|
texi->plain-text
|
||||||
|
@ -1206,6 +1207,23 @@ (define-syntax with-error-handling
|
||||||
(lambda ()
|
(lambda ()
|
||||||
body ...)))))
|
body ...)))))
|
||||||
|
|
||||||
|
(define* (indented-string str indent
|
||||||
|
#:key (initial-indent? #t))
|
||||||
|
"Return STR with each newline preceded by IDENT spaces. When
|
||||||
|
INITIAL-INDENT? is true, the first line is also indented."
|
||||||
|
(define indent-string
|
||||||
|
(make-list indent #\space))
|
||||||
|
|
||||||
|
(list->string
|
||||||
|
(string-fold-right (lambda (chr result)
|
||||||
|
(if (eqv? chr #\newline)
|
||||||
|
(cons chr (append indent-string result))
|
||||||
|
(cons chr result)))
|
||||||
|
'()
|
||||||
|
(if initial-indent?
|
||||||
|
(string-append (list->string indent-string) str)
|
||||||
|
str))))
|
||||||
|
|
||||||
(define* (fill-paragraph str width #:optional (column 0))
|
(define* (fill-paragraph str width #:optional (column 0))
|
||||||
"Fill STR such that each line contains at most WIDTH characters, assuming
|
"Fill STR such that each line contains at most WIDTH characters, assuming
|
||||||
that the first character is at COLUMN.
|
that the first character is at COLUMN.
|
||||||
|
|
Loading…
Reference in a new issue