2 * $Id: indxtype.h 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2013-2022 Eduardo Chappa
6 * Copyright 2006-2008 University of Washington
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
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * ========================================================================
17 #ifndef PITH_INDXTYPE_INCLUDED
18 #define PITH_INDXTYPE_INCLUDED
20 #include "../pith/osdep/color.h"
22 #include "../pith/msgno.h"
23 #include "../pith/charset.h"
27 * Flags for msgline_hidden.
29 * MH_NONE means we should only consider messages which are or would be
30 * visible in the index view. That is, messages which are not hidden due
31 * to zooming, not hidden because they are in a collapsed part of a
32 * thread, and not hidden because we are in one thread and they are in
33 * another and the view we are using only shows one thread.
34 * MH_THISTHD changes that a little bit. It considers more messages
35 * to be visible. In particular, messages in this thread which are
36 * hidden due to collapsing are considered to be visible instead of hidden.
37 * This is useful if we are viewing a message and hit Next, and want
38 * to see the next message in the thread even if it was in a
39 * collapsed thread. This only makes sense when using the separate
40 * thread index and viewing a thread. "This thread" is the thread that
41 * is being viewed, not the thread that msgno is part of. So it is the
42 * thread that has been marked MN_CHID2.
43 * MH_ANYTHD adds more visibility. It doesn't matter if the message is in
44 * the same thread or if it is collapsed or not. If a message is not
45 * hidden due to zooming, then it is not hidden. Notice that ANYTHD
49 #define MH_THISTHD 0x1
53 typedef enum {iNothing
, iStatus
, iFStatus
, iIStatus
, iSIStatus
,
54 iDate
, iLDate
, iS1Date
, iS2Date
, iS3Date
, iS4Date
, iSDate
,
56 iSDateIso
, iSDateIsoS
, iSDateS1
, iSDateS2
, iSDateS3
, iSDateS4
,
58 iSDateTimeIso
, iSDateTimeIsoS
, iSDateTimeS1
,
59 iSDateTimeS2
, iSDateTimeS3
, iSDateTimeS4
,
61 iSDateTimeIso24
, iSDateTimeIsoS24
, iSDateTimeS124
,
62 iSDateTimeS224
, iSDateTimeS324
, iSDateTimeS424
,
65 iCurDate
, iCurDateIso
, iCurDateIsoS
, iCurTime24
, iCurTime12
,
66 iCurDay
, iCurDay2Digit
, iCurDayOfWeek
, iCurDayOfWeekAbb
,
67 iCurMon
, iCurMon2Digit
, iCurMonLong
, iCurMonAbb
,
68 iCurYear
, iCurYear2Digit
,
69 iLstMon
, iLstMon2Digit
, iLstMonLong
, iLstMonAbb
,
70 iLstMonYear
, iLstMonYear2Digit
,
71 iLstYear
, iLstYear2Digit
,
72 iMessNo
, iAtt
, iMsgID
,
73 iSubject
, iShortSubject
,
74 iSubjKey
, iShortSubjKey
,
75 iSubjKeyInit
, iShortSubjKeyInit
,
76 iSubjectText
, iSubjKeyText
, iSubjKeyInitText
,
77 iOpeningText
, iOpeningTextNQ
,
79 iPrefDate
, iPrefTime
, iPrefDateTime
,
80 iCurPrefDate
, iCurPrefTime
, iCurPrefDateTime
,
81 iSize
, iSizeComma
, iSizeNarrow
, iDescripSize
,
82 iNewsAndTo
, iToAndNews
, iNewsAndRecips
, iRecipsAndNews
,
83 iFromTo
, iFromToNotNews
, iFrom
, iTo
, iSender
, iCc
, iNews
, iRecips
,
85 iMailbox
, iAddress
, iInit
, iCursorPos
,
86 iDay2Digit
, iMon2Digit
, iYear2Digit
,
87 iSTime
, iSTime24
, iKSize
,
90 iPrio
, iPrioAlpha
, iPrioBang
,
91 iScore
, iDayOfWeekAbb
, iDayOfWeek
,
92 iDay
, iDayOrdinal
, iMonAbb
, iMonLong
, iMon
, iYear
} IndexColType
;
94 typedef enum {AllAuto
, Fixed
, Percent
, WeCalculate
, Special
} WidthType
;
96 typedef enum {eText
= 0, eKeyWord
, eThreadCount
, eThreadInfo
, eTypeCol
} ElemType
;
98 typedef enum {Left
, Right
} ColAdj
;
100 typedef struct index_parse_tokens
{
107 /* these are flags for the what_for field in INDEX_PARSE_T */
108 #define FOR_NOTHING 0x00
109 #define FOR_INDEX 0x01
110 #define FOR_REPLY_INTRO 0x02
111 #define FOR_TEMPLATE 0x04 /* or for signature */
112 #define FOR_FILT 0x08
113 #define DELIM_USCORE 0x10
114 #define DELIM_PAREN 0x20
115 #define DELIM_COLON 0x40
118 #define DEFAULT_REPLY_INTRO "default"
121 typedef struct hdr_token_description
{
129 typedef struct col_description
{
135 int monabb_width
; /* hack */
137 HEADER_TOK_S
*hdrtok
;
142 * Ensure that all the data in an index_elem (in the data member)
143 * is stored in UTF-8. The writing routines (paint_index_line() for pine)
144 * should then assume UTF-8 when using the data. The process of putting
145 * data into an index_elem will likely involve a conversion into UTF-8.
146 * For example, the Subject or From fields may have data in some arbitrary
149 typedef struct index_elem
{
150 struct index_elem
*next
;
152 COLOR_PAIR
*color
; /* color, if any, for this element */
153 char *data
; /* ptr to full text for this element */
154 unsigned int datalen
; /* not counting terminating null */
155 ElemType type
; /* part of field data represents */
156 unsigned freedata
:1; /* free data when done */
157 unsigned freecolor
:1; /* free color when done */
158 unsigned freeprintf
:8; /* how much alloced for print_format */
159 unsigned wid
:16; /* redundant, width from print_format */
164 * 3 is room for '%', '.', and 's'. You need to add one for '\0';
165 * The format string looks like:
167 * %13.13s or %-13.13s
169 * The '-' is there if left is set and the 13 is the 'width' in the call.
171 #define PRINT_FORMAT_LEN(width,left) (3 + ((left) ? 1 : 0) + 2 * ((width) > 999 ? 4 : (width) > 99 ? 3 : (width) > 9 ? 2 : 1))
175 * Each field consists of a list of elements. The leftadj bit means we
176 * should left adjust the whole thing in the field width, padding on the
177 * right with spaces or truncating on the right. We haven't yet fully
178 * implemented right adjust, except that it is easy for a single element
179 * field. So be careful with multi-element, right-adjusted fields.
181 typedef struct index_field
{
182 struct index_field
*next
;
184 unsigned width
:16; /* width of whole field */
185 unsigned leftadj
:1; /* left adjust elements in field */
186 IELEM_S
*ielem
; /* list of elements in this field */
191 * If the index_cache_entry has an ifield list, it is assumed that the
192 * ifields have had their ielement lists filled in.
193 * The widths_done bit is set after the widths and print formats are setup
194 * to do the correct width. A width change could be done by unsetting
195 * the widths_done bit and then recalculating the widths in the ifields
196 * and resetting the print_format strings in the ielems.
198 typedef struct index_cache_entry
{
199 IFIELD_S
*ifield
; /* list of fields */
200 COLOR_PAIR
*linecolor
;
201 unsigned color_lookup_done
:1; /* efficiency hacks */
202 unsigned widths_done
:1;
206 unsigned long id
; /* hash value */
207 struct index_cache_entry
*tice
; /* thread index header line */
212 * Pieces needed to construct a valid folder index entry, and to
213 * control what can be fetched when (due to callbacks and such)
215 typedef struct index_data
{
217 ADDRESS
*from
, /* always valid */
218 *to
, /* check valid bit, fetch as req'd */
219 *cc
, /* check valid bit, fetch as req'd */
220 *sender
; /* check valid bit, fetch as req'd */
221 char *newsgroups
, /* check valid bit, fetch as req'd */
222 *subject
, /* always valid */
223 *date
; /* always valid */
224 long msgno
, /* tells us what we're looking at */
226 size
; /* always valid */
227 unsigned no_fetch
:1, /* lit when we're in a callback */
228 bogus
:2, /* lit when there were problems */
229 valid_to
:1, /* trust struct's "to" pointer */
230 valid_cc
:1, /* trust struct's "cc" pointer */
231 valid_sender
:1, /* trust struct's "sender" pointer */
232 valid_news
:1, /* trust struct's "news" pointer */
233 valid_resent_to
:1, /* trust struct's "resent-to" ptr */
234 resent_to_us
:1; /* lit when we know its true */
239 * Line_hash can't return LINE_HASH_N, so we use it in a couple places as
240 * a special value that we can assign knowing it can't be a real hash value.
242 #define LINE_HASH_N 0xffffffff
245 typedef enum {NoKW
, KW
, KWInit
} SubjKW
;
248 /* exported prototypes */
251 #endif /* PITH_INDXTYPE_INCLUDED */