1 /*@ S-nail - a mail user agent derived from Berkeley Mail.
2 *@ Header display, search, etc., related user commands.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 - 2018 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
8 * Copyright (c) 1980, 1993
9 * The Regents of the University of California. All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #define n_FILE cmd_headers
38 #ifndef HAVE_AMALGAMATION
44 /* Print out the header of a specific message.
45 * time_current must be up-to-date when this is called.
46 * a_cmd__hprf: handle *headline*
47 * a_cmd__subject: -1 if Subject: yet seen, otherwise n_alloc()d Subject:
48 * a_cmd__putindent: print out the indenting in threaded display
49 * a_cmd__putuc: print out a Unicode character or a substitute for it, return
50 * 0 on error or wcwidth() (or 1) on success */
51 static void a_cmd_print_head(size_t yetprinted
, size_t msgno
, FILE *f
,
52 bool_t threaded
, bool_t subject_thread_compress
);
54 static void a_cmd__hprf(size_t yetprinted
, char const *fmt
, size_t msgno
,
55 FILE *f
, bool_t threaded
, bool_t subject_thread_compress
,
56 char const *attrlist
);
57 static char *a_cmd__subject(struct message
*mp
, bool_t threaded
,
58 bool_t subject_thread_compress
, size_t yetprinted
);
59 static int a_cmd__putindent(FILE *fp
, struct message
*mp
, int maxwidth
);
60 static size_t a_cmd__putuc(int u
, int c
, FILE *fp
);
61 static int a_cmd__dispc(struct message
*mp
, char const *a
);
63 /* Shared `z' implementation */
64 static int a_cmd_scroll(char const *arg
, bool_t onlynew
);
66 /* Shared `headers' implementation */
67 static int _headers(int msgspec
);
70 a_cmd_print_head(size_t yetprinted
, size_t msgno
, FILE *f
, bool_t threaded
,
71 bool_t subject_thread_compress
){
73 char attrlist
[attrlen
+1], *cp
;
77 if((cp
= ok_vlook(attrlist
)) != NULL
){
78 if(strlen(cp
) == attrlen
){
79 memcpy(attrlist
, cp
, attrlen
+1);
82 n_err(_("*attrlist* is not of the correct length, using built-in\n"));
85 if(ok_blook(bsdcompat
) || ok_blook(bsdflags
)){
86 char const bsdattr
[attrlen
+1] = "NU *HMFAT+-$~";
88 memcpy(attrlist
, bsdattr
, sizeof bsdattr
);
89 }else if(ok_blook(SYSV3
)){
90 char const bsdattr
[attrlen
+1] = "NU *HMFAT+-$~";
92 memcpy(attrlist
, bsdattr
, sizeof bsdattr
);
93 n_OBSOLETE(_("*SYSV3*: please use *bsdcompat* or *bsdflags*, "
94 "or set *attrlist*"));
96 char const pattr
[attrlen
+1] = "NUROSPMFAT+-$~";
98 memcpy(attrlist
, pattr
, sizeof pattr
);
102 if((fmt
= ok_vlook(headline
)) == NULL
){
103 fmt
= ((ok_blook(bsdcompat
) || ok_blook(bsdheadline
))
104 ? "%>%a%m %-20f %16d %4l/%-5o %i%-S"
105 : "%>%a%m %-18f %-16d %4l/%-5o %i%-s");
108 a_cmd__hprf(yetprinted
, fmt
, msgno
, f
, threaded
, subject_thread_compress
,
114 a_cmd__hprf(size_t yetprinted
, char const *fmt
, size_t msgno
, FILE *f
,
115 bool_t threaded
, bool_t subject_thread_compress
, char const *attrlist
)
117 char buf
[16], cbuf
[8], *cp
, *subjline
;
118 char const *date
, *name
, *fp
, *color_tag
;
119 int i
, n
, s
, wleft
, subjlen
;
121 n_COLOUR( struct n_colour_pen
*cpen_new COMMA
*cpen_cur COMMA
*cpen_bas
; )
127 _LOOP_MASK
= (1<<4) - 1,
128 _SFMT
= 1<<4, /* It is 'S' */
129 /* For the simple byte-based counts in wleft and n we sometimes need
130 * adjustments to compensate for additional bytes of UTF-8 sequences */
131 _PUTCB_UTF8_SHIFT
= 5,
132 _PUTCB_UTF8_MASK
= 3<<5
137 if ((mp
= message
+ msgno
- 1) == dot
)
141 date
= n_header_textual_date_info(mp
, &color_tag
);
145 n_header_textual_sender_info(mp
, &cp
, NULL
, NULL
, NULL
, &isto
);
153 /* Detect the width of the non-format characters in *headline*;
154 * like that we can simply use putc() in the next loop, since we have
155 * already calculated their column widths (TODO it's sick) */
156 wleft
= subjlen
= n_scrnwidth
;
158 for (fp
= fmt
; *fp
!= '\0'; ++fp
) {
164 if (digitchar(*fp
)) {
167 n
= 10*n
+ *fp
- '0';
168 while (++fp
, digitchar(*fp
));
178 if (n_mb_cur_max
> 1) {
180 if ((s
= mbtowc(&wc
, fp
, n_mb_cur_max
)) == -1)
182 else if ((n
= wcwidth(wc
)) == -1)
194 /* Walk *headline*, producing output TODO not (really) MB safe */
196 if(n_COLOUR_IS_ACTIVE()){
198 color_tag
= n_COLOUR_TAG_SUM_DOT
;
199 cpen_bas
= n_colour_pen_create(n_COLOUR_ID_SUM_HEADER
, color_tag
);
200 n_colour_pen_put(cpen_new
= cpen_cur
= cpen_bas
);
202 cpen_new
= cpen_bas
= cpen_cur
= NULL
;
205 for (fp
= fmt
; *fp
!= '\0'; ++fp
) {
208 if ((c
= *fp
& 0xFF) != '%') {
210 if(n_COLOUR_IS_ACTIVE() && (cpen_new
= cpen_bas
) != cpen_cur
)
211 n_colour_pen_put(cpen_cur
= cpen_new
);
220 if ((c
= *++fp
) == '-') {
225 if (digitchar(*fp
)) {
227 n
= 10*n
+ *fp
- '0';
228 while (++fp
, digitchar(*fp
));
231 if ((c
= *fp
& 0xFF) == '\0')
241 if (flags
& _ISDOT
) {
243 if(n_COLOUR_IS_ACTIVE())
244 cpen_new
= n_colour_pen_create(n_COLOUR_ID_SUM_DOTMARK
,
247 if((n_psonce
& n_PSO_UNICODE
) && !ok_blook(headline_plain
)){
249 /* 25B8;BLACK RIGHT-POINTING SMALL TRIANGLE */
250 cbuf
[1] = (char)0x96, cbuf
[2] = (char)0xB8;
252 /* 25C2;BLACK LEFT-POINTING SMALL TRIANGLE */
253 cbuf
[1] = (char)0x97, cbuf
[2] = (char)0x82;
256 flags
|= 2 << _PUTCB_UTF8_SHIFT
;
265 if (UICMP(32, n_ABS(n
), >, wleft
))
266 n
= (n
< 0) ? -wleft
: wleft
;
267 snprintf(buf
, sizeof buf
, "%u.%02u",
268 (mp
->m_spamscore
>> 8), (mp
->m_spamscore
& 0xFF));
269 n
= fprintf(f
, "%*s", n
, buf
);
270 wleft
= (n
>= 0) ? wleft
- n
: 0;
277 c
= a_cmd__dispc(mp
, attrlist
);
280 if(n_COLOUR_IS_ACTIVE()){
281 if(cpen_new
== cpen_cur
)
283 if(cpen_new
!= cpen_cur
)
284 n_colour_pen_put(cpen_cur
= cpen_new
);
287 if (UICMP(32, n_ABS(n
), >, wleft
))
288 n
= (n
< 0) ? -wleft
: wleft
;
290 n
= fprintf(f
, "%*s", n
, cbuf
);
293 if ((n
= (flags
& _PUTCB_UTF8_MASK
)) != 0) {
294 n
>>= _PUTCB_UTF8_SHIFT
;
298 wleft
= 0; /* TODO I/O error.. ? break? */
301 if(n_COLOUR_IS_ACTIVE() && (cpen_new
= cpen_bas
) != cpen_cur
)
302 n_colour_pen_put(cpen_cur
= cpen_new
);
308 if (UICMP(32, n_ABS(n
), >, wleft
))
309 n
= (n
< 0) ? -wleft
: wleft
;
310 n
= fprintf(f
, "%*.*s", n
, n_ABS(n
), date
);
311 wleft
= (n
>= 0) ? wleft
- n
: 0;
316 if (UICMP(32, n_ABS(n
), >, wleft
))
317 n
= (n
< 0) ? -wleft
: wleft
;
318 n
= fprintf(f
, "%*u", n
, (threaded
== 1 ? mp
->m_level
: 0));
319 wleft
= (n
>= 0) ? wleft
- n
: 0;
330 n
= (n
< 0) ? -wleft
: wleft
;
332 if (flags
& _ISTO
) /* XXX tr()! */
334 n
= fprintf(f
, "%s%s", ((flags
& _ISTO
) ? "To " : n_empty
),
335 colalign(name
, i
, n
, &wleft
));
338 else if (flags
& _ISTO
)
344 if(n_COLOUR_IS_ACTIVE()){
345 cpen_new
= n_colour_pen_create(n_COLOUR_ID_SUM_THREAD
,
347 if(cpen_new
!= cpen_cur
)
348 n_colour_pen_put(cpen_cur
= cpen_new
);
351 n
= a_cmd__putindent(f
, mp
, n_MIN(wleft
, (int)n_scrnwidth
- 60));
352 wleft
= (n
>= 0) ? wleft
- n
: 0;
354 if(n_COLOUR_IS_ACTIVE() && (cpen_new
= cpen_bas
) != cpen_cur
)
355 n_colour_pen_put(cpen_cur
= cpen_new
);
362 if (UICMP(32, n_ABS(n
), >, wleft
))
363 n
= (n
< 0) ? -wleft
: wleft
;
365 n
= fprintf(f
, "%*ld", n
, mp
->m_xlines
);
366 wleft
= (n
>= 0) ? wleft
- n
: 0;
378 for (i
= msgCount
; i
> 999; i
/= 10)
381 if (UICMP(32, n_ABS(n
), >, wleft
))
382 n
= (n
< 0) ? -wleft
: wleft
;
383 n
= fprintf(f
, "%*lu", n
, (ul_i
)msgno
);
384 wleft
= (n
>= 0) ? wleft
- n
: 0;
389 if (UICMP(32, n_ABS(n
), >, wleft
))
390 n
= (n
< 0) ? -wleft
: wleft
;
391 n
= fprintf(f
, "%*lu", n
, (ul_i
)mp
->m_xsize
);
392 wleft
= (n
>= 0) ? wleft
- n
: 0;
404 if (UICMP(32, n_ABS(n
), >, subjlen
))
405 n
= (n
< 0) ? -subjlen
: subjlen
;
407 n
-= (n
< 0) ? -2 : 2;
410 if (subjline
== NULL
)
411 subjline
= a_cmd__subject(mp
, (threaded
&& (flags
& _IFMT
)),
412 subject_thread_compress
, yetprinted
);
413 if (subjline
== (char*)-1) {
414 n
= fprintf(f
, "%*s", n
, n_empty
);
415 wleft
= (n
>= 0) ? wleft
- n
: 0;
417 n
= fprintf(f
, ((flags
& _SFMT
) ? "\"%s\"" : "%s"),
418 colalign(subjline
, n_ABS(n
), n
, &wleft
));
423 case 'T': /* Message recipient flags */
424 switch(is_mlist_mp(mp
, MLIST_OTHER
)){
425 case MLIST_OTHER
: c
= ' '; break;
426 case MLIST_KNOWN
: c
= 'l'; break;
427 case MLIST_SUBSCRIBED
: c
= 'L'; break;
434 for (i
= msgCount
; i
> 999; i
/= 10)
437 if (UICMP(32, n_ABS(n
), >, wleft
))
438 n
= (n
< 0) ? -wleft
: wleft
;
439 n
= fprintf(f
, "%*lu",
440 n
, (threaded
? (ul_i
)mp
->m_threadpos
: (ul_i
)msgno
));
441 wleft
= (n
>= 0) ? wleft
- n
: 0;
447 if (UICMP(32, n_ABS(n
), >, wleft
))
448 n
= (n
< 0) ? -wleft
: wleft
;
449 n
= fprintf(f
, "%*" PRIu64
, n
, mp
->m_uid
);
450 wleft
= (n
>= 0) ? wleft
- n
: 0;
457 if (n_poption
& n_PO_D_V
)
458 n_err(_("Unknown *headline* format: %%%c\n"), c
);
467 n_COLOUR( n_colour_reset(); )
470 if (subjline
!= NULL
&& subjline
!= (char*)-1)
476 a_cmd__subject(struct message
*mp
, bool_t threaded
,
477 bool_t subject_thread_compress
, size_t yetprinted
)
485 if ((ms
= hfield1("subject", mp
)) == NULL
)
488 in
.l
= strlen(in
.s
= ms
);
489 mime_fromhdr(&in
, &out
, TD_ICONV
| TD_ISPR
);
492 if (!threaded
|| !subject_thread_compress
|| mp
->m_level
== 0)
495 /* In a display thread - check whether this message uses the same
496 * Subject: as it's parent or elder neighbour, suppress printing it if
497 * this is the case. To extend this a bit, ignore any leading Re: or
498 * Fwd: plus follow-up WS. Ignore invisible messages along the way */
499 ms
= n_UNCONST(subject_re_trim(n_UNCONST(ms
)));
501 for (; (mp
= prev_in_thread(mp
)) != NULL
&& yetprinted
-- > 0;) {
504 if (visible(mp
) && (os
= hfield1("subject", mp
)) != NULL
) {
508 in
.l
= strlen(in
.s
= os
);
509 mime_fromhdr(&in
, &oout
, TD_ICONV
| TD_ISPR
);
510 x
= asccasecmp(ms
, subject_re_trim(oout
.s
));
526 a_cmd__putindent(FILE *fp
, struct message
*mp
, int maxwidth
)/* XXX magics */
529 int *us
, indlvl
, indw
, i
, important
= MNEW
| MFLAGGED
;
533 if (mp
->m_level
== 0 || maxwidth
== 0) {
538 cs
= n_lofi_alloc(mp
->m_level
);
539 us
= n_lofi_alloc(mp
->m_level
* sizeof *us
);
542 if (mp
->m_younger
&& UICMP(32, i
+ 1, ==, mp
->m_younger
->m_level
)) {
543 if (mp
->m_parent
&& mp
->m_parent
->m_flag
& important
)
544 us
[i
] = mp
->m_flag
& important
? 0x2523 : 0x2520;
546 us
[i
] = mp
->m_flag
& important
? 0x251D : 0x251C;
549 if (mp
->m_parent
&& mp
->m_parent
->m_flag
& important
)
550 us
[i
] = mp
->m_flag
& important
? 0x2517 : 0x2516;
552 us
[i
] = mp
->m_flag
& important
? 0x2515 : 0x2514;
557 for (i
= mp
->m_level
- 2; i
>= 0; --i
) {
559 if (UICMP(32, i
, >, mq
->m_level
- 1)) {
564 if (mq
->m_parent
&& (mq
->m_parent
->m_flag
& important
))
577 for (indlvl
= indw
= 0; (ui8_t
)indlvl
< mp
->m_level
&& indw
< maxwidth
;
579 if (indw
< maxwidth
- 1)
580 indw
+= (int)a_cmd__putuc(us
[indlvl
], cs
[indlvl
] & 0xFF, fp
);
582 indw
+= (int)a_cmd__putuc(0x21B8, '^', fp
);
584 indw
+= a_cmd__putuc(0x25B8, '>', fp
);
594 a_cmd__putuc(int u
, int c
, FILE *fp
){
599 #ifdef HAVE_NATCH_CHAR
600 if((n_psonce
& n_PSO_UNICODE
) && (u
& ~(wchar_t)0177) &&
601 !ok_blook(headline_plain
)){
602 char mbb
[MB_LEN_MAX
];
605 if((n
= wctomb(mbb
, u
)) > 0){
607 for(i
= 0; i
< n
; ++i
)
608 if(putc(mbb
[i
] & 0377, fp
) == EOF
){
613 rv
= (putc('\0', fp
) != EOF
);
618 rv
= (putc(c
, fp
) != EOF
);
624 a_cmd__dispc(struct message
*mp
, char const *a
)
629 if ((mp
->m_flag
& (MREAD
| MNEW
)) == MREAD
)
631 if ((mp
->m_flag
& (MREAD
| MNEW
)) == (MREAD
| MNEW
))
633 if (mp
->m_flag
& MANSWERED
)
635 if (mp
->m_flag
& MDRAFTED
)
637 if ((mp
->m_flag
& (MREAD
| MNEW
)) == MNEW
)
639 if (!(mp
->m_flag
& (MREAD
| MNEW
)))
641 if (mp
->m_flag
& MSPAM
)
643 if (mp
->m_flag
& MSPAMUNSURE
)
645 if (mp
->m_flag
& MSAVED
)
647 if (mp
->m_flag
& MPRESERVE
)
649 if (mp
->m_flag
& (MBOX
| MBOXED
))
651 if (mp
->m_flag
& MFLAGGED
)
653 if (mb
.mb_threaded
== 1 && mp
->m_collapsed
> 0)
655 if (mb
.mb_threaded
== 1 && mp
->m_collapsed
< 0)
662 a_cmd_scroll(char const *arg
, bool_t onlynew
){
665 int msgspec
, size
, maxs
;
668 /* TODO scroll problem: we do not know whether + and $ have already reached
669 * TODO the last screen in threaded mode */
670 msgspec
= onlynew
? -1 : 0;
671 size
= (int)/*TODO*/n_screensize();
672 if((maxs
= msgCount
/ size
) > 0 && msgCount
% size
== 0)
703 case '1': case '2': case '3': case '4': case '5':
704 case '6': case '7': case '8': case '9': case '0':
707 if((n_idec_siz_cp(&l
, arg
, 0, NULL
708 ) & (n_IDEC_STATE_EMASK
| n_IDEC_STATE_CONSUMED
)
709 ) != n_IDEC_STATE_CONSUMED
)
711 if(l
> maxs
- (isabs
? 0 : _screen
))
713 _screen
= isabs
? (int)l
: _screen
+ l
;
719 fprintf(n_stdout
, _("On last screenful of messages\n"));
727 if((n_idec_siz_cp(&l
, ++arg
, 0, NULL
728 ) & (n_IDEC_STATE_EMASK
| n_IDEC_STATE_CONSUMED
)
729 ) != n_IDEC_STATE_CONSUMED
)
738 fprintf(n_stdout
, _("On first screenful of messages\n"));
745 n_err(_("Unrecognized scrolling command: %s\n"), arg
);
750 size
= _headers(msgspec
);
757 _headers(int msgspec
) /* TODO rework v15 */
759 bool_t needdot
, showlast
;
760 int g
, k
, mesg
, size
;
761 struct message
*lastmq
, *mp
, *mq
;
763 ui32_t
volatile flag
;
767 time_current_update(&time_current
, FAL0
);
769 fl
= MNEW
| MFLAGGED
;
774 size
= (int)/*TODO*/n_screensize();
777 #if 0 /* FIXME original code path */
790 needdot
= (msgspec
<= 0) ? TRU1
: (dot
!= &message
[msgspec
- 1]);
791 showlast
= ok_blook(showlast
);
793 if (mb
.mb_threaded
== 0) {
796 for (mp
= message
; PTRCMP(mp
, <, message
+ msgCount
); ++mp
)
800 if (mp
->m_flag
& fl
) {
804 if ((msgspec
> 0 && PTRCMP(mp
, ==, message
+ msgspec
- 1)) ||
805 (msgspec
== 0 && g
== k
) ||
806 (msgspec
== -2 && g
== k
+ size
&& lastmq
) ||
807 (msgspec
< 0 && g
>= k
&& (mp
->m_flag
& fl
) != 0))
811 if (lastmq
&& (msgspec
== -2 ||
812 (msgspec
== -1 && PTRCMP(mp
, ==, message
+ msgCount
)))) {
819 mesg
= (int)PTR2SIZE(mp
- message
);
821 if (mb
.mb_type
== MB_IMAP
)
822 imap_getheaders(mesg
+ 1, mesg
+ size
);
824 n_COLOUR( n_colour_env_create(n_COLOUR_CTX_SUM
, n_stdout
, FAL0
); )
826 for(lastmq
= NULL
, mq
= &message
[msgCount
]; mp
< mq
; lastmq
= mp
, ++mp
){
830 if (UICMP(32, flag
, >=, size
))
834 if(UICMP(32, flag
, ==, size
- 1) || &mp
[1] == mq
)
843 a_cmd_print_head(0, mesg
, n_stdout
, FAL0
, FAL0
);
846 if(needdot
&& ok_blook(showlast
)) /* xxx will not show */
849 n_COLOUR( n_colour_env_gut(); )
850 } else { /* threaded */
853 for (mp
= threadroot
; mp
; mp
= next_in_thread(mp
))
855 (mp
->m_collapsed
<= 0 ||
856 PTRCMP(mp
, ==, message
+ msgspec
- 1))) {
859 if (mp
->m_flag
& fl
) {
863 if ((msgspec
> 0 && PTRCMP(mp
, ==, message
+ msgspec
- 1)) ||
864 (msgspec
== 0 && g
== k
) ||
865 (msgspec
== -2 && g
== k
+ size
&& lastmq
) ||
866 (msgspec
< 0 && g
>= k
&& (mp
->m_flag
& fl
) != 0))
870 if (lastmq
&& (msgspec
== -2 ||
871 (msgspec
== -1 && PTRCMP(mp
, ==, message
+ msgCount
)))) {
878 n_COLOUR( n_colour_env_create(n_COLOUR_CTX_SUM
, n_stdout
, FAL0
); )
880 for(lastmq
= NULL
; mp
!= NULL
; lastmq
= mp
, mp
= mq
){
881 mq
= next_in_thread(mp
);
883 (mp
->m_collapsed
<= 0 ||
884 PTRCMP(mp
, ==, message
+ msgspec
- 1))) {
885 if (UICMP(32, flag
, >=, size
))
889 if(UICMP(32, flag
, ==, size
- 1) || mq
== NULL
)
897 a_cmd_print_head(flag
, PTR2SIZE(mp
- message
+ 1), n_stdout
,
898 mb
.mb_threaded
, TRU1
);
903 if(needdot
&& ok_blook(showlast
)) /* xxx will not show */
906 n_COLOUR( n_colour_env_gut(); )
910 fprintf(n_stdout
, _("No more mail.\n"));
911 if (n_pstate
& (n_PS_ROBOT
| n_PS_HOOK_MASK
))
924 rv
= print_header_group((int*)v
);
930 print_header_group(int *vector
)
935 assert(vector
!= NULL
&& vector
!= (void*)-1);
936 rv
= _headers(vector
[0]);
947 rv
= a_cmd_scroll(*(char const**)v
, FAL0
);
958 rv
= a_cmd_scroll(*(char const**)v
, TRU1
);
970 if (*(args
= v
) == '\0' || args
[1] != '\0') {
972 n_err(_("Synopsis: dotmove: up <-> or down <+> by one message\n"));
974 } else switch (args
[0]) {
978 fprintf(n_stdout
, _("At EOF\n"));
980 } else if (getmsglist(n_UNCONST(/*TODO*/ args
), msgvec
, 0) > 0) {
981 setdot(message
+ msgvec
[0] - 1);
983 rv
= c_headers(msgvec
);
999 FILE * volatile obuf
;
1002 if(*(msgvec
= vp
) == 0)
1005 time_current_update(&time_current
, FAL0
);
1009 if (n_psonce
& n_PSO_INTERACTIVE
) {
1010 if ((cp
= ok_vlook(crt
)) != NULL
) {
1013 for (n
= 0, ip
= msgvec
; *ip
!= 0; ++ip
)
1017 ib
= n_screensize();
1019 n_idec_uiz_cp(&ib
, cp
, 0, NULL
);
1020 if (UICMP(z
, n
, >, ib
) && (obuf
= n_pager_open()) == NULL
)
1025 /* Update dot before display so that the dotmark etc. are correct */
1026 for (ip
= msgvec
; ip
[1] != 0; ++ip
)
1028 setdot(&message
[(ok_blook(showlast
) ? *ip
: *msgvec
) - 1]);
1030 n_COLOUR( n_colour_env_create(n_COLOUR_CTX_SUM
, obuf
, obuf
!= n_stdout
); )
1032 for (n
= 0, ip
= msgvec
; *ip
!= 0; ++ip
) { /* TODO join into _print_head() */
1033 a_cmd_print_head((size_t)n
++, (size_t)*ip
, obuf
, mb
.mb_threaded
, FAL0
);
1037 n_COLOUR( n_colour_env_gut(); )
1039 if (obuf
!= n_stdout
)
1040 n_pager_close(obuf
);
1047 print_headers(size_t bottom
, size_t topx
, bool_t only_marked
,
1048 bool_t subject_thread_compress
)
1054 if (mb
.mb_type
== MB_IMAP
)
1055 imap_getheaders(bottom
, topx
);
1057 time_current_update(&time_current
, FAL0
);
1059 n_COLOUR( n_colour_env_create(n_COLOUR_CTX_SUM
, n_stdout
, FAL0
); )
1061 for (printed
= 0; bottom
<= topx
; ++bottom
) {
1062 struct message
*mp
= message
+ bottom
- 1;
1064 if (!(mp
->m_flag
& MMARK
))
1066 } else if (!visible(mp
))
1068 a_cmd_print_head(printed
++, bottom
, n_stdout
, FAL0
,
1069 subject_thread_compress
);
1073 n_COLOUR( n_colour_env_gut(); )