1 /*
2  * $Id: mailindx.h 770 2007-10-24 00:23:09Z hubert@u.washington.edu $
3  *
4  * ========================================================================
5  * Copyright 2013-2021 Eduardo Chappa
6  * Copyright 2006-2007 University of Washington
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * ========================================================================
15  */
16 
17 #ifndef PINE_MAILINDX_INCLUDED
18 #define PINE_MAILINDX_INCLUDED
19 
20 
21 #include "../pith/mailindx.h"
22 #include "context.h"
23 #include "keymenu.h"
24 #include "../pith/state.h"
25 #include "../pith/msgno.h"
26 #include "../pith/indxtype.h"
27 #include "../pith/thread.h"
28 #include "../pith/color.h"
29 
30 
31 /*-----------
32   Saved state to redraw message index body
33   ----*/
34 struct entry_state {
35     unsigned hilite:1;
36     unsigned bolded:1;
37     unsigned already_erased:1;
38     int      plus;
39     long     msgno;		/* last msgno we drew */
40     unsigned long id;
41 };
42 
43 
44 struct index_state {
45     long         msg_at_top,
46 	         lines_per_page;
47     struct       entry_state *entry_state;
48     MSGNO_S     *msgmap;
49     MAILSTREAM  *stream;
50     IndexColType status_fld;		/* field for select X's */
51     int          status_col;		/* column for select X's */
52     IndexColType plus_fld;		/* field for threading '+' or '>' */
53     int          plus_col;		/* column for threading '+' or '>' */
54     IndexColType arrow_fld;		/* field for cursor arrow */
55 };
56 
57 
58 #define	AC_NONE		0x00		/* flags modifying apply_command */
59 #define	AC_FROM_THREAD	0x01		/* called from thread_command    */
60 #define	AC_COLL		0x02		/* offer collapse command        */
61 #define	AC_EXPN		0x04		/* offer expand command          */
62 #define	AC_UNSEL	0x08		/* all selected, offer UnSelect  */
63 
64 
65 /*
66  * Macro to reveal horizontal scroll margin.  It can be no greater than
67  * half the number of lines on the display...
68  */
69 #define	HS_MAX_MARGIN(p)	(((p)->ttyo->screen_rows-FOOTER_ROWS(p)-3)/2)
70 #define	HS_MARGIN(p)		MIN((p)->scroll_margin, HS_MAX_MARGIN(p))
71 
72 
73 /*
74  * Flags to indicate how much index border to paint
75  */
76 #define	INDX_CLEAR	0x01
77 #define	INDX_HEADER	0x02
78 #define	INDX_FOOTER	0x04
79 
80 
81 typedef enum {MsgIndex, MultiMsgIndex, ZoomIndex, ThreadIndex} IndexType;
82 
83 
84 /*
85  * Macro to simplify clearing body portion of pine's display
86  */
87 #define ClearBody()	ClearLines(1, ps_global->ttyo->screen_rows 	      \
88 						  - FOOTER_ROWS(ps_global) - 1)
89 
90 
91 extern struct index_state *current_index_state;
92 
93 
94 /* exported prototypes */
95 void		 mail_index_screen(struct pine *);
96 struct key_menu *do_index_border(CONTEXT_S *, char *, MAILSTREAM *, MSGNO_S *, IndexType, int *, int);
97 void		*stop_threading_temporarily(void);
98 void		 restore_threading(void **);
99 int		 index_lister(struct pine *, CONTEXT_S *, char *, MAILSTREAM *, MSGNO_S *);
100 ICE_S		*build_header_line(struct pine *, MAILSTREAM *, MSGNO_S *, long, int *);
101 int		 condensed_thread_cue(PINETHRD_S *, ICE_S *, char **, size_t *, int, int);
102 int		 truncate_subj_and_from_strings(void);
103 void		 paint_index_hline(MAILSTREAM *, long, ICE_S *);
104 void		 setup_index_state(int);
105 void		 warn_other_cmds(void);
106 void		 thread_command(struct pine *, MAILSTREAM *, MSGNO_S *, UCS, int);
107 COLOR_PAIR      *apply_rev_color(COLOR_PAIR *, int);
108 #ifdef	_WINDOWS
109 int		 index_sort_callback(int, long);
110 void             view_in_new_window(void);
111 #endif
112 
113 
114 #endif /* PINE_MAILINDX_INCLUDED */
115