From mboxrd@z Thu Jan 1 00:00:00 1970 From: Danny Milosavljevic Subject: bug#22536: Progress on the guix download progress display Date: Fri, 8 Apr 2016 20:45:30 +0200 Message-ID: <20160408204530.56912d28@scratchpost.org> References: <20160407143744.3b0d8e98@scratchpost.org> <20160407150957.GA18750@jasmine> <8760vt84zg.fsf@gnu.org> <20160408200745.49b3a761@scratchpost.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aobQ0-0005gV-IK for bug-guix@gnu.org; Fri, 08 Apr 2016 14:46:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aobPx-0003BN-Ax for bug-guix@gnu.org; Fri, 08 Apr 2016 14:46:08 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:42593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aobPx-0003B4-7k for bug-guix@gnu.org; Fri, 08 Apr 2016 14:46:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1aobPu-0005EG-3l for bug-guix@gnu.org; Fri, 08 Apr 2016 14:46:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <20160408200745.49b3a761@scratchpost.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" Cc: 22536@debbugs.gnu.org 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)