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 /* ... And place the extracted date in `date' */
45 static void _parse_from_(struct message
*mp
, char date
[n_FROM_DATEBUF
]);
47 /* Print out the header of a specific message
48 * a_cmd__hprf: handle *headline*
49 * a_cmd__subject: -1 if Subject: yet seen, otherwise smalloc()d Subject:
50 * a_cmd__putindent: print out the indenting in threaded display
51 * a_cmd__putuc: print out a Unicode character or a substitute for it, return
52 * 0 on error or wcwidth() (or 1) on success */
53 static void a_cmd_print_head(size_t yetprinted
, size_t msgno
, FILE *f
,
56 static void a_cmd__hprf(size_t yetprinted
, char const *fmt
, size_t msgno
,
57 FILE *f
, bool_t threaded
, char const *attrlist
);
58 static char *a_cmd__subject(struct message
*mp
, bool_t threaded
,
60 static int a_cmd__putindent(FILE *fp
, struct message
*mp
, int maxwidth
);
61 static size_t a_cmd__putuc(int u
, int c
, FILE *fp
);
62 static int a_cmd__dispc(struct message
*mp
, char const *a
);
64 /* Shared `z' implementation */
65 static int a_cmd_scroll(char const *arg
, bool_t onlynew
);
67 /* Shared `headers' implementation */
68 static int _headers(int msgspec
);
71 _parse_from_(struct message
*mp
, char date
[n_FROM_DATEBUF
]) /* TODO line pool */
79 if ((ibuf
= setinput(&mb
, mp
, NEED_HEADER
)) != NULL
&&
80 (hlen
= readline_restart(ibuf
, &hline
, &hsize
, 0)) > 0)
81 extract_date_from_from_(hline
, hlen
, date
);
88 a_cmd_print_head(size_t yetprinted
, size_t msgno
, FILE *f
, bool_t threaded
){
90 char attrlist
[attrlen
+1], *cp
;
94 if((cp
= ok_vlook(attrlist
)) != NULL
){
95 if(strlen(cp
) == attrlen
){
96 memcpy(attrlist
, cp
, attrlen
+1);
99 n_err(_("*attrlist* is not of the correct length, using built-in\n"));
102 if(ok_blook(bsdcompat
) || ok_blook(bsdflags
)){
103 char const bsdattr
[attrlen
+1] = "NU *HMFAT+-$~";
105 memcpy(attrlist
, bsdattr
, sizeof bsdattr
);
106 }else if(ok_blook(SYSV3
)){
107 char const bsdattr
[attrlen
+1] = "NU *HMFAT+-$~";
109 memcpy(attrlist
, bsdattr
, sizeof bsdattr
);
110 n_OBSOLETE(_("*SYSV3*: please use *bsdcompat* or *bsdflags*, "
111 "or set *attrlist*"));
113 char const pattr
[attrlen
+1] = "NUROSPMFAT+-$~";
115 memcpy(attrlist
, pattr
, sizeof pattr
);
119 if((fmt
= ok_vlook(headline
)) == NULL
){
120 fmt
= ((ok_blook(bsdcompat
) || ok_blook(bsdheadline
))
121 ? "%>%a%m %-20f %16d %4l/%-5o %i%-S"
122 : "%>%a%m %-18f %-16d %4l/%-5o %i%-s");
125 a_cmd__hprf(yetprinted
, fmt
, msgno
, f
, threaded
, attrlist
);
130 a_cmd__hprf(size_t yetprinted
, char const *fmt
, size_t msgno
, FILE *f
,
131 bool_t threaded
, char const *attrlist
)
133 char buf
[16], datebuf
[n_FROM_DATEBUF
], cbuf
[8], *cp
, *subjline
;
134 char const *datefmt
, *date
, *name
, *fp
n_COLOUR( COMMA
*colo_tag
);
135 int i
, n
, s
, wleft
, subjlen
;
138 n_COLOUR( struct n_colour_pen
*cpen_new COMMA
*cpen_cur COMMA
*cpen_bas
; )
145 _LOOP_MASK
= (1<<4) - 1,
146 _SFMT
= 1<<4, /* It is 'S' */
147 /* For the simple byte-based counts in wleft and n we sometimes need
148 * adjustments to compensate for additional bytes of UTF-8 sequences */
149 _PUTCB_UTF8_SHIFT
= 5,
150 _PUTCB_UTF8_MASK
= 3<<5
155 if ((mp
= message
+ msgno
- 1) == dot
)
159 n_COLOUR( colo_tag
= NULL
; )
161 datefmt
= ok_vlook(datefield
);
163 if (datefmt
!= NULL
) {
164 fp
= hfield1("date", mp
);/* TODO use m_date field! */
170 date
= n_time_ctime(datet
, NULL
);
171 fp
= ok_vlook(datefield_markout_older
);
172 i
= (*datefmt
!= '\0');
174 i
|= (*fp
!= '\0') ? 2 | 4 : 2; /* XXX no magics */
176 /* May we strftime(3)? */
178 /* This localtime(3) should not fail since rfctime(3).. but .. */
182 /* TODO the datetime stuff is horror: mails should be parsed into
183 * TODO an object tree, and date: etc. have a datetime object, which
184 * TODO verifies upon parse time; then ALL occurrences of datetime are
185 * TODO valid all through the program; and: to_wire, to_user! */
188 if((tmp
= localtime(&datet2
)) == NULL
){
190 goto jredo_localtime
;
192 memcpy(&time_current
.tc_local
, tmp
, sizeof(*tmp
));
196 (UICMP(64,datet
, >, time_current
.tc_time
+ n_DATE_SECSDAY
) ||
197 #define _6M ((n_DATE_DAYSYEAR / 2) * n_DATE_SECSDAY)
198 UICMP(64,datet
+ _6M
, <, time_current
.tc_time
))) {
200 if ((datefmt
= (i
& 4) ? fp
: NULL
) == NULL
) {
201 memset(datebuf
, ' ', n_FROM_DATEBUF
); /* xxx ur */
202 memcpy(datebuf
+ 4, date
+ 4, 7);
203 datebuf
[4 + 7] = ' ';
204 memcpy(datebuf
+ 4 + 7 + 1, date
+ 20, 4);
205 datebuf
[4 + 7 + 1 + 4] = '\0';
208 n_COLOUR( colo_tag
= n_COLOUR_TAG_SUM_OLDER
; )
209 } else if ((i
& 1) == 0)
211 } else if (datet
== (time_t)0 && !(mp
->m_flag
& MNOFROM
)) {
212 /* TODO eliminate this path, query the FROM_ date in setptr(),
213 * TODO all other codepaths do so by themselves ALREADY ?????
214 * TODO assert(mp->m_time != 0);, then
215 * TODO ALSO changes behaviour of datefield_markout_older */
216 _parse_from_(mp
, datebuf
);
219 date
= n_time_ctime(datet
, NULL
);
223 if (name
!= NULL
&& ok_blook(showto
) && n_is_myname(skin(name
))) {
224 if ((cp
= hfield1("to", mp
)) != NULL
) {
234 name
= ok_blook(showname
) ? realname(name
) : prstr(skin(name
));
238 /* Detect the width of the non-format characters in *headline*;
239 * like that we can simply use putc() in the next loop, since we have
240 * already calculated their column widths (TODO it's sick) */
241 wleft
= subjlen
= n_scrnwidth
;
243 for (fp
= fmt
; *fp
!= '\0'; ++fp
) {
249 if (digitchar(*fp
)) {
252 n
= 10*n
+ *fp
- '0';
253 while (++fp
, digitchar(*fp
));
263 if (n_mb_cur_max
> 1) {
265 if ((s
= mbtowc(&wc
, fp
, n_mb_cur_max
)) == -1)
267 else if ((n
= wcwidth(wc
)) == -1)
279 /* Walk *headline*, producing output TODO not (really) MB safe */
281 if(n_COLOUR_IS_ACTIVE()){
283 colo_tag
= n_COLOUR_TAG_SUM_DOT
;
284 cpen_bas
= n_colour_pen_create(n_COLOUR_ID_SUM_HEADER
, colo_tag
);
285 n_colour_pen_put(cpen_new
= cpen_cur
= cpen_bas
);
287 cpen_new
= cpen_bas
= cpen_cur
= NULL
;
290 for (fp
= fmt
; *fp
!= '\0'; ++fp
) {
293 if ((c
= *fp
& 0xFF) != '%') {
295 if(n_COLOUR_IS_ACTIVE() && (cpen_new
= cpen_bas
) != cpen_cur
)
296 n_colour_pen_put(cpen_cur
= cpen_new
);
305 if ((c
= *++fp
) == '-') {
310 if (digitchar(*fp
)) {
312 n
= 10*n
+ *fp
- '0';
313 while (++fp
, digitchar(*fp
));
316 if ((c
= *fp
& 0xFF) == '\0')
326 if (flags
& _ISDOT
) {
328 if(n_COLOUR_IS_ACTIVE())
329 cpen_new
= n_colour_pen_create(n_COLOUR_ID_SUM_DOTMARK
,
332 if((n_psonce
& n_PSO_UNICODE
) && !ok_blook(headline_plain
)){
334 /* 25B8;BLACK RIGHT-POINTING SMALL TRIANGLE */
335 cbuf
[1] = (char)0x96, cbuf
[2] = (char)0xB8;
337 /* 25C2;BLACK LEFT-POINTING SMALL TRIANGLE */
338 cbuf
[1] = (char)0x97, cbuf
[2] = (char)0x82;
341 flags
|= 2 << _PUTCB_UTF8_SHIFT
;
350 if (UICMP(32, n_ABS(n
), >, wleft
))
351 n
= (n
< 0) ? -wleft
: wleft
;
352 snprintf(buf
, sizeof buf
, "%u.%02u",
353 (mp
->m_spamscore
>> 8), (mp
->m_spamscore
& 0xFF));
354 n
= fprintf(f
, "%*s", n
, buf
);
355 wleft
= (n
>= 0) ? wleft
- n
: 0;
362 c
= a_cmd__dispc(mp
, attrlist
);
365 if(n_COLOUR_IS_ACTIVE()){
366 if(cpen_new
== cpen_cur
)
368 if(cpen_new
!= cpen_cur
)
369 n_colour_pen_put(cpen_cur
= cpen_new
);
372 if (UICMP(32, n_ABS(n
), >, wleft
))
373 n
= (n
< 0) ? -wleft
: wleft
;
375 n
= fprintf(f
, "%*s", n
, cbuf
);
378 if ((n
= (flags
& _PUTCB_UTF8_MASK
)) != 0) {
379 n
>>= _PUTCB_UTF8_SHIFT
;
383 wleft
= 0; /* TODO I/O error.. ? break? */
386 if(n_COLOUR_IS_ACTIVE() && (cpen_new
= cpen_bas
) != cpen_cur
)
387 n_colour_pen_put(cpen_cur
= cpen_new
);
391 if (datefmt
!= NULL
) {
392 i
= strftime(datebuf
, sizeof datebuf
, datefmt
,
393 &time_current
.tc_local
);
397 n_err(_("Ignoring date format, it is either empty or "
398 "excesses buffer size (%lu bytes)\n"),
399 (ul_i
)sizeof(datebuf
));
404 if (UICMP(32, n_ABS(n
), >, wleft
))
405 n
= (n
< 0) ? -wleft
: wleft
;
406 n
= fprintf(f
, "%*.*s", n
, n_ABS(n
), date
);
407 wleft
= (n
>= 0) ? wleft
- n
: 0;
412 if (UICMP(32, n_ABS(n
), >, wleft
))
413 n
= (n
< 0) ? -wleft
: wleft
;
414 n
= fprintf(f
, "%*u", n
, (threaded
== 1 ? mp
->m_level
: 0));
415 wleft
= (n
>= 0) ? wleft
- n
: 0;
426 n
= (n
< 0) ? -wleft
: wleft
;
428 if (flags
& _ISTO
) /* XXX tr()! */
430 n
= fprintf(f
, "%s%s", ((flags
& _ISTO
) ? "To " : n_empty
),
431 colalign(name
, i
, n
, &wleft
));
434 else if (flags
& _ISTO
)
440 if(n_COLOUR_IS_ACTIVE()){
441 cpen_new
= n_colour_pen_create(n_COLOUR_ID_SUM_THREAD
, colo_tag
);
442 if(cpen_new
!= cpen_cur
)
443 n_colour_pen_put(cpen_cur
= cpen_new
);
446 n
= a_cmd__putindent(f
, mp
, n_MIN(wleft
, (int)n_scrnwidth
- 60));
447 wleft
= (n
>= 0) ? wleft
- n
: 0;
449 if(n_COLOUR_IS_ACTIVE() && (cpen_new
= cpen_bas
) != cpen_cur
)
450 n_colour_pen_put(cpen_cur
= cpen_new
);
457 if (UICMP(32, n_ABS(n
), >, wleft
))
458 n
= (n
< 0) ? -wleft
: wleft
;
460 n
= fprintf(f
, "%*ld", n
, mp
->m_xlines
);
461 wleft
= (n
>= 0) ? wleft
- n
: 0;
473 for (i
= msgCount
; i
> 999; i
/= 10)
476 if (UICMP(32, n_ABS(n
), >, wleft
))
477 n
= (n
< 0) ? -wleft
: wleft
;
478 n
= fprintf(f
, "%*lu", n
, (ul_i
)msgno
);
479 wleft
= (n
>= 0) ? wleft
- n
: 0;
484 if (UICMP(32, n_ABS(n
), >, wleft
))
485 n
= (n
< 0) ? -wleft
: wleft
;
486 n
= fprintf(f
, "%*lu", n
, (ul_i
)mp
->m_xsize
);
487 wleft
= (n
>= 0) ? wleft
- n
: 0;
499 if (UICMP(32, n_ABS(n
), >, subjlen
))
500 n
= (n
< 0) ? -subjlen
: subjlen
;
502 n
-= (n
< 0) ? -2 : 2;
505 if (subjline
== NULL
)
506 subjline
= a_cmd__subject(mp
, (threaded
&& (flags
& _IFMT
)),
508 if (subjline
== (char*)-1) {
509 n
= fprintf(f
, "%*s", n
, n_empty
);
510 wleft
= (n
>= 0) ? wleft
- n
: 0;
512 n
= fprintf(f
, ((flags
& _SFMT
) ? "\"%s\"" : "%s"),
513 colalign(subjline
, n_ABS(n
), n
, &wleft
));
518 case 'T': /* Message recipient flags */
519 switch(is_mlist_mp(mp
, MLIST_OTHER
)){
520 case MLIST_OTHER
: c
= ' '; break;
521 case MLIST_KNOWN
: c
= 'l'; break;
522 case MLIST_SUBSCRIBED
: c
= 'L'; break;
529 for (i
= msgCount
; i
> 999; i
/= 10)
532 if (UICMP(32, n_ABS(n
), >, wleft
))
533 n
= (n
< 0) ? -wleft
: wleft
;
534 n
= fprintf(f
, "%*lu",
535 n
, (threaded
? (ul_i
)mp
->m_threadpos
: (ul_i
)msgno
));
536 wleft
= (n
>= 0) ? wleft
- n
: 0;
542 if (UICMP(32, n_ABS(n
), >, wleft
))
543 n
= (n
< 0) ? -wleft
: wleft
;
544 n
= fprintf(f
, "%*" PRIu64
, n
, mp
->m_uid
);
545 wleft
= (n
>= 0) ? wleft
- n
: 0;
552 if (n_poption
& n_PO_D_V
)
553 n_err(_("Unknown *headline* format: %%%c\n"), c
);
562 n_COLOUR( n_colour_reset(); )
565 if (subjline
!= NULL
&& subjline
!= (char*)-1)
571 a_cmd__subject(struct message
*mp
, bool_t threaded
, size_t yetprinted
)
579 if ((ms
= hfield1("subject", mp
)) == NULL
)
582 in
.l
= strlen(in
.s
= ms
);
583 mime_fromhdr(&in
, &out
, TD_ICONV
| TD_ISPR
);
586 if (!threaded
|| mp
->m_level
== 0)
589 /* In a display thread - check whether this message uses the same
590 * Subject: as it's parent or elder neighbour, suppress printing it if
591 * this is the case. To extend this a bit, ignore any leading Re: or
592 * Fwd: plus follow-up WS. Ignore invisible messages along the way */
593 ms
= n_UNCONST(subject_re_trim(n_UNCONST(ms
)));
595 for (; (mp
= prev_in_thread(mp
)) != NULL
&& yetprinted
-- > 0;) {
598 if (visible(mp
) && (os
= hfield1("subject", mp
)) != NULL
) {
602 in
.l
= strlen(in
.s
= os
);
603 mime_fromhdr(&in
, &oout
, TD_ICONV
| TD_ISPR
);
604 x
= asccasecmp(ms
, subject_re_trim(oout
.s
));
620 a_cmd__putindent(FILE *fp
, struct message
*mp
, int maxwidth
)/* XXX magics */
623 int *us
, indlvl
, indw
, i
, important
= MNEW
| MFLAGGED
;
627 if (mp
->m_level
== 0 || maxwidth
== 0) {
632 cs
= ac_alloc(mp
->m_level
);
633 us
= ac_alloc(mp
->m_level
* sizeof *us
);
636 if (mp
->m_younger
&& UICMP(32, i
+ 1, ==, mp
->m_younger
->m_level
)) {
637 if (mp
->m_parent
&& mp
->m_parent
->m_flag
& important
)
638 us
[i
] = mp
->m_flag
& important
? 0x2523 : 0x2520;
640 us
[i
] = mp
->m_flag
& important
? 0x251D : 0x251C;
643 if (mp
->m_parent
&& mp
->m_parent
->m_flag
& important
)
644 us
[i
] = mp
->m_flag
& important
? 0x2517 : 0x2516;
646 us
[i
] = mp
->m_flag
& important
? 0x2515 : 0x2514;
651 for (i
= mp
->m_level
- 2; i
>= 0; --i
) {
653 if (UICMP(32, i
, >, mq
->m_level
- 1)) {
658 if (mq
->m_parent
&& (mq
->m_parent
->m_flag
& important
))
671 for (indlvl
= indw
= 0; (ui8_t
)indlvl
< mp
->m_level
&& indw
< maxwidth
;
673 if (indw
< maxwidth
- 1)
674 indw
+= (int)a_cmd__putuc(us
[indlvl
], cs
[indlvl
] & 0xFF, fp
);
676 indw
+= (int)a_cmd__putuc(0x21B8, '^', fp
);
678 indw
+= a_cmd__putuc(0x25B8, '>', fp
);
688 a_cmd__putuc(int u
, int c
, FILE *fp
){
693 #ifdef HAVE_NATCH_CHAR
694 if((n_psonce
& n_PSO_UNICODE
) && (u
& ~(wchar_t)0177) &&
695 !ok_blook(headline_plain
)){
696 char mbb
[MB_LEN_MAX
];
699 if((n
= wctomb(mbb
, u
)) > 0){
701 for(i
= 0; i
< n
; ++i
)
702 if(putc(mbb
[i
] & 0377, fp
) == EOF
){
707 rv
= (putc('\0', fp
) != EOF
);
712 rv
= (putc(c
, fp
) != EOF
);
718 a_cmd__dispc(struct message
*mp
, char const *a
)
723 if ((mp
->m_flag
& (MREAD
| MNEW
)) == MREAD
)
725 if ((mp
->m_flag
& (MREAD
| MNEW
)) == (MREAD
| MNEW
))
727 if (mp
->m_flag
& MANSWERED
)
729 if (mp
->m_flag
& MDRAFTED
)
731 if ((mp
->m_flag
& (MREAD
| MNEW
)) == MNEW
)
733 if (!(mp
->m_flag
& (MREAD
| MNEW
)))
735 if (mp
->m_flag
& MSPAM
)
737 if (mp
->m_flag
& MSPAMUNSURE
)
739 if (mp
->m_flag
& MSAVED
)
741 if (mp
->m_flag
& MPRESERVE
)
743 if (mp
->m_flag
& (MBOX
| MBOXED
))
745 if (mp
->m_flag
& MFLAGGED
)
747 if (mb
.mb_threaded
== 1 && mp
->m_collapsed
> 0)
749 if (mb
.mb_threaded
== 1 && mp
->m_collapsed
< 0)
756 a_cmd_scroll(char const *arg
, bool_t onlynew
){
759 int msgspec
, size
, maxs
;
762 /* TODO scroll problem: we do not know whether + and $ have already reached
763 * TODO the last screen in threaded mode */
764 msgspec
= onlynew
? -1 : 0;
765 size
= (int)/*TODO*/n_screensize();
766 if((maxs
= msgCount
/ size
) > 0 && msgCount
% size
== 0)
797 case '1': case '2': case '3': case '4': case '5':
798 case '6': case '7': case '8': case '9': case '0':
801 if((n_idec_siz_cp(&l
, arg
, 0, NULL
802 ) & (n_IDEC_STATE_EMASK
| n_IDEC_STATE_CONSUMED
)
803 ) != n_IDEC_STATE_CONSUMED
)
805 if(l
> maxs
- (isabs
? 0 : _screen
))
807 _screen
= isabs
? (int)l
: _screen
+ l
;
813 fprintf(n_stdout
, _("On last screenful of messages\n"));
821 if((n_idec_siz_cp(&l
, ++arg
, 0, NULL
822 ) & (n_IDEC_STATE_EMASK
| n_IDEC_STATE_CONSUMED
)
823 ) != n_IDEC_STATE_CONSUMED
)
832 fprintf(n_stdout
, _("On first screenful of messages\n"));
839 n_err(_("Unrecognized scrolling command: %s\n"), arg
);
844 size
= _headers(msgspec
);
851 _headers(int msgspec
) /* TODO rework v15 */
853 bool_t needdot
, showlast
;
854 int g
, k
, mesg
, size
;
855 struct message
*lastmq
, *mp
, *mq
;
857 ui32_t
volatile flag
;
861 time_current_update(&time_current
, FAL0
);
863 fl
= MNEW
| MFLAGGED
;
868 size
= (int)/*TODO*/n_screensize();
871 #if 0 /* FIXME original code path */
884 needdot
= (msgspec
<= 0) ? TRU1
: (dot
!= &message
[msgspec
- 1]);
885 showlast
= ok_blook(showlast
);
887 if (mb
.mb_threaded
== 0) {
890 for (mp
= message
; PTRCMP(mp
, <, message
+ msgCount
); ++mp
)
894 if (mp
->m_flag
& fl
) {
898 if ((msgspec
> 0 && PTRCMP(mp
, ==, message
+ msgspec
- 1)) ||
899 (msgspec
== 0 && g
== k
) ||
900 (msgspec
== -2 && g
== k
+ size
&& lastmq
) ||
901 (msgspec
< 0 && g
>= k
&& (mp
->m_flag
& fl
) != 0))
905 if (lastmq
&& (msgspec
== -2 ||
906 (msgspec
== -1 && PTRCMP(mp
, ==, message
+ msgCount
)))) {
913 mesg
= (int)PTR2SIZE(mp
- message
);
915 if (mb
.mb_type
== MB_IMAP
)
916 imap_getheaders(mesg
+ 1, mesg
+ size
);
918 n_COLOUR( n_colour_env_create(n_COLOUR_CTX_SUM
, n_stdout
, FAL0
); )
920 for(lastmq
= NULL
, mq
= &message
[msgCount
]; mp
< mq
; lastmq
= mp
, ++mp
){
924 if (UICMP(32, flag
, >=, size
))
928 if(UICMP(32, flag
, ==, size
- 1) || &mp
[1] == mq
)
937 a_cmd_print_head(0, mesg
, n_stdout
, 0);
940 if(needdot
&& ok_blook(showlast
)) /* xxx will not show */
943 n_COLOUR( n_colour_env_gut(); )
945 } else { /* threaded */
948 for (mp
= threadroot
; mp
; mp
= next_in_thread(mp
))
950 (mp
->m_collapsed
<= 0 ||
951 PTRCMP(mp
, ==, message
+ msgspec
- 1))) {
954 if (mp
->m_flag
& fl
) {
958 if ((msgspec
> 0 && PTRCMP(mp
, ==, message
+ msgspec
- 1)) ||
959 (msgspec
== 0 && g
== k
) ||
960 (msgspec
== -2 && g
== k
+ size
&& lastmq
) ||
961 (msgspec
< 0 && g
>= k
&& (mp
->m_flag
& fl
) != 0))
965 if (lastmq
&& (msgspec
== -2 ||
966 (msgspec
== -1 && PTRCMP(mp
, ==, message
+ msgCount
)))) {
973 n_COLOUR( n_colour_env_create(n_COLOUR_CTX_SUM
, n_stdout
, FAL0
); )
975 for(lastmq
= NULL
; mp
!= NULL
; lastmq
= mp
, mp
= mq
){
976 mq
= next_in_thread(mp
);
978 (mp
->m_collapsed
<= 0 ||
979 PTRCMP(mp
, ==, message
+ msgspec
- 1))) {
980 if (UICMP(32, flag
, >=, size
))
984 if(UICMP(32, flag
, ==, size
- 1) || mq
== NULL
)
992 a_cmd_print_head(flag
, PTR2SIZE(mp
- message
+ 1), n_stdout
,
998 if(needdot
&& ok_blook(showlast
)) /* xxx will not show */
1001 n_COLOUR( n_colour_env_gut(); )
1005 fprintf(n_stdout
, _("No more mail.\n"));
1006 if (n_pstate
& (n_PS_ROBOT
| n_PS_HOOK_MASK
))
1019 rv
= print_header_group((int*)v
);
1025 print_header_group(int *vector
)
1030 assert(vector
!= NULL
&& vector
!= (void*)-1);
1031 rv
= _headers(vector
[0]);
1042 rv
= a_cmd_scroll(*(char const**)v
, FAL0
);
1053 rv
= a_cmd_scroll(*(char const**)v
, TRU1
);
1065 if (*(args
= v
) == '\0' || args
[1] != '\0') {
1067 n_err(_("Synopsis: dotmove: up <-> or down <+> by one message\n"));
1069 } else switch (args
[0]) {
1072 if (msgCount
== 0) {
1073 fprintf(n_stdout
, _("At EOF\n"));
1075 } else if (getmsglist(n_UNCONST(/*TODO*/ args
), msgvec
, 0) > 0) {
1076 setdot(message
+ msgvec
[0] - 1);
1078 rv
= c_headers(msgvec
);
1092 int *msgvec
, *ip
, n
;
1094 FILE * volatile obuf
;
1097 if(*(msgvec
= vp
) == 0)
1100 time_current_update(&time_current
, FAL0
);
1104 if (n_psonce
& n_PSO_INTERACTIVE
) {
1105 if ((cp
= ok_vlook(crt
)) != NULL
) {
1108 for (n
= 0, ip
= msgvec
; *ip
!= 0; ++ip
)
1112 ib
= n_screensize();
1114 n_idec_uiz_cp(&ib
, cp
, 0, NULL
);
1115 if (UICMP(z
, n
, >, ib
) && (obuf
= n_pager_open()) == NULL
)
1120 /* Update dot before display so that the dotmark etc. are correct */
1121 for (ip
= msgvec
; ip
[1] != 0; ++ip
)
1123 setdot(&message
[(ok_blook(showlast
) ? *ip
: *msgvec
) - 1]);
1125 n_COLOUR( n_colour_env_create(n_COLOUR_CTX_SUM
, obuf
, obuf
!= n_stdout
); )
1127 for (n
= 0, ip
= msgvec
; *ip
!= 0; ++ip
) { /* TODO join into _print_head() */
1128 a_cmd_print_head((size_t)n
++, (size_t)*ip
, obuf
, mb
.mb_threaded
);
1132 n_COLOUR( n_colour_env_gut(); )
1134 if (obuf
!= n_stdout
)
1135 n_pager_close(obuf
);
1142 print_headers(size_t bottom
, size_t topx
, bool_t only_marked
)
1148 if (mb
.mb_type
== MB_IMAP
)
1149 imap_getheaders(bottom
, topx
);
1151 time_current_update(&time_current
, FAL0
);
1153 n_COLOUR( n_colour_env_create(n_COLOUR_CTX_SUM
, n_stdout
, FAL0
); )
1155 for (printed
= 0; bottom
<= topx
; ++bottom
) {
1156 struct message
*mp
= message
+ bottom
- 1;
1158 if (!(mp
->m_flag
& MMARK
))
1160 } else if (!visible(mp
))
1162 a_cmd_print_head(printed
++, bottom
, n_stdout
, FAL0
);
1166 n_COLOUR( n_colour_env_gut(); )