ui: 'display-generation' emits a hyperlink for the generation.
* guix/ui.scm (supports-hyperlinks?): Make 'port' optional. (display-generation): Use 'file-hyperlink' for the heading when 'supports-hyperlinks?' returns true.master
parent
fa983b8257
commit
055f052574
guix
29
guix/ui.scm
29
guix/ui.scm
|
@ -1247,7 +1247,7 @@ documented at
|
||||||
(string-append "\x1b]8;;" uri "\x1b\\"
|
(string-append "\x1b]8;;" uri "\x1b\\"
|
||||||
text "\x1b]8;;\x1b\\"))
|
text "\x1b]8;;\x1b\\"))
|
||||||
|
|
||||||
(define (supports-hyperlinks? port)
|
(define* (supports-hyperlinks? #:optional (port (current-output-port)))
|
||||||
"Return true if PORT is a terminal that supports hyperlink escapes."
|
"Return true if PORT is a terminal that supports hyperlink escapes."
|
||||||
;; Note that terminals are supposed to ignore OSC escapes they don't
|
;; Note that terminals are supposed to ignore OSC escapes they don't
|
||||||
;; understand (this is the case of xterm as of version 349, for instance.)
|
;; understand (this is the case of xterm as of version 349, for instance.)
|
||||||
|
@ -1613,17 +1613,22 @@ DURATION-RELATION with the current time."
|
||||||
(define (display-generation profile number)
|
(define (display-generation profile number)
|
||||||
"Display a one-line summary of generation NUMBER of PROFILE."
|
"Display a one-line summary of generation NUMBER of PROFILE."
|
||||||
(unless (zero? number)
|
(unless (zero? number)
|
||||||
(let ((header (format #f (highlight (G_ "Generation ~a\t~a")) number
|
(let* ((file (generation-file-name profile number))
|
||||||
(date->string
|
(link (if (supports-hyperlinks?)
|
||||||
(time-utc->date
|
(cut file-hyperlink file <>)
|
||||||
(generation-time profile number))
|
identity))
|
||||||
;; TRANSLATORS: This is a format-string for date->string.
|
(header (format #f (link (highlight (G_ "Generation ~a\t~a")))
|
||||||
;; Please choose a format that corresponds to the
|
number
|
||||||
;; usual way of presenting dates in your locale.
|
(date->string
|
||||||
;; See https://www.gnu.org/software/guile/manual/html_node/SRFI_002d19-Date-to-string.html
|
(time-utc->date
|
||||||
;; for details.
|
(generation-time profile number))
|
||||||
(G_ "~b ~d ~Y ~T"))))
|
;; TRANSLATORS: This is a format-string for date->string.
|
||||||
(current (generation-number profile)))
|
;; Please choose a format that corresponds to the
|
||||||
|
;; usual way of presenting dates in your locale.
|
||||||
|
;; See https://www.gnu.org/software/guile/manual/html_node/SRFI_002d19-Date-to-string.html
|
||||||
|
;; for details.
|
||||||
|
(G_ "~b ~d ~Y ~T"))))
|
||||||
|
(current (generation-number profile)))
|
||||||
(if (= number current)
|
(if (= number current)
|
||||||
;; TRANSLATORS: The word "current" here is an adjective for
|
;; TRANSLATORS: The word "current" here is an adjective for
|
||||||
;; "Generation", as in "current generation". Use the appropriate
|
;; "Generation", as in "current generation". Use the appropriate
|
||||||
|
|
Reference in New Issue