From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1B0381FD5A for ; Wed, 28 Apr 2021 07:52:06 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 09/11] lei_view_text: improve attachment display Date: Wed, 28 Apr 2021 07:52:03 +0000 Message-Id: <20210428075205.19440-10-e@80x24.org> In-Reply-To: <20210428075205.19440-1-e@80x24.org> References: <20210428075205.19440-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Support setting a color to distinguish from user-supplied text. We'll also put the $BLOB:$IDX identifier on a separate line and just put the entire corresponding lei command in the form of: "[-- lei blob $BLOB:$IDX --]" to teach users how to access it. --- lib/PublicInbox/LeiViewText.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/LeiViewText.pm b/lib/PublicInbox/LeiViewText.pm index 6f5fca49..5d649840 100644 --- a/lib/PublicInbox/LeiViewText.pm +++ b/lib/PublicInbox/LeiViewText.pm @@ -25,6 +25,7 @@ my %DEFAULT_COLOR = ( quoted => 'blue', hdrdefault => 'cyan', status => 'bright_cyan', # smsg stuff + attachment => 'bright_red', # git names and defaults, falls back to ~/.gitconfig new => 'green', @@ -113,20 +114,21 @@ sub hdr_buf ($$) { sub attach_note ($$$$;$) { my ($self, $ct, $p, $fn, $err) = @_; my ($part, $depth, $idx) = @$p; - my $obuf = $self->{obuf}; my $nl = $idx eq '1' ? '' : "\n"; # like join("\n", ...) - $$obuf .= <{-smsg}->{blob} // ''; - $blob .= ':' if $blob ne ''; - $$obuf .= "[-- Attachment $blob$idx "; + $abuf .= "[-- Attachment #$idx: "; _xs($ct); my $size = length($part->body); my $ts = "Type: $ct, Size: $size bytes"; my $d = $part->header('Content-Description') // $fn // ''; _xs($d); - $$obuf .= $d eq '' ? "$ts --]\n" : "$d --]\n[-- $ts --]\n"; + $abuf .= $d eq '' ? "$ts --]\n" : "$d --]\n[-- $ts --]\n"; + if (my $blob = $self->{-smsg}->{blob}) { + $abuf .= "[-- lei blob $blob:$idx --]\n"; + } + $self->{-colored}->($self, 'attachment', $abuf); hdr_buf($self, $part) if $part->{is_submsg}; }