bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22536: Progress on the guix download progress display


From: Danny Milosavljevic
Subject: bug#22536: Progress on the guix download progress display
Date: Fri, 8 Apr 2016 20:45:30 +0200

A quick try to get a prefer-the-tail string concatenator to work - still has 
some limitations:

(define (abbreviate text len)
  (string-take text (min len (string-length text))))
(define (abbreviate-texts-prefer-to-take-tail texts len)
  "Given a list of strings TEXTS, returns a string, containing at most LEN 
codepoints.
   If possible, prefers to still keep the last text. If this text is too long, 
takes as many heading codepoints as possible of it.
   If there's still space, also keeps the second-to-last text. If this text is 
too long, takes as many heading codepoints as possible of it.
   ...
   If there's still space, also keeps the first text. If this text is too long, 
takes as many heading codepoints as possible of it.
   We have no idea how wide it will actually be when displayed, so:
   - make sure to only use it with ASCII text, or
   - at least only use it with half-width characters."
  (if (null? texts)
      ""
      (let* ((remainder (abbreviate-texts-prefer-to-take-tail (cdr texts) len))
             (len (- len (string-length remainder)))
             (text (abbreviate (car texts) len)))
             (string-append text remainder))))
(display (abbreviate-texts-prefer-to-take-tail '("hello world" " " "this i") 
10))
(newline)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]