user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 09/11] lei_view_text: improve attachment display
Date: Wed, 28 Apr 2021 07:52:03 +0000	[thread overview]
Message-ID: <20210428075205.19440-10-e@80x24.org> (raw)
In-Reply-To: <20210428075205.19440-1-e@80x24.org>

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 .= <<EOF if $err;
+	my $abuf = $err ? <<EOF : '';
 [-- Warning: decoded text below may be mangled, UTF-8 assumed --]
 EOF
-	my $blob = $self->{-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};
 }
 

  parent reply	other threads:[~2021-04-28  7:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28  7:51 [PATCH 00/11] lei: misc fixes, more lcat color support Eric Wong
2021-04-28  7:51 ` [PATCH 01/11] t/lei-p2q: add diagnostics Eric Wong
2021-04-28  7:51 ` [PATCH 02/11] tests: restore CWD with "lei -C" and run_script Eric Wong
2021-04-28  7:51 ` [PATCH 03/11] view_diff: minor coding style fixes Eric Wong
2021-04-28  7:51 ` [PATCH 04/11] lei_p2q: add _lei_wq_eof callback Eric Wong
2021-04-28  7:51 ` [PATCH 05/11] lei-daemon: note FD count mismatch to client Eric Wong
2021-04-28  7:52 ` [PATCH 06/11] t/run.perl: add (GNU) tail and strace support Eric Wong
2021-04-28  7:52 ` [PATCH 07/11] lei: quiet down Eml-related warnings consistently Eric Wong
2021-04-28  7:52 ` [PATCH 08/11] lei: simple WQ workers use {wq1} field Eric Wong
2021-04-28  7:52 ` Eric Wong [this message]
2021-04-28  7:52 ` [PATCH 10/11] lei_view_text: translate background colors from git Eric Wong
2021-04-28  7:52 ` [PATCH 11/11] lei (lcat|q): support --no-color and --color Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210428075205.19440-10-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    --subject='Re: [PATCH 09/11] lei_view_text: improve attachment display' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git