~ubuntu-branches/debian/squeeze/alpine/squeeze

« back to all changes in this revision

Viewing changes to pith/indxtype.h

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2007-02-17 13:17:42 UTC
  • Revision ID: james.westby@ubuntu.com-20070217131742-99x5c6cpg1pbkdhw
Tags: upstream-0.82+dfsg
ImportĀ upstreamĀ versionĀ 0.82+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: indxtype.h 380 2007-01-23 00:09:18Z hubert@u.washington.edu $
 
3
 *
 
4
 * ========================================================================
 
5
 * Copyright 2006-2007 University of Washington
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * ========================================================================
 
14
 */
 
15
 
 
16
#ifndef PITH_INDXTYPE_INCLUDED
 
17
#define PITH_INDXTYPE_INCLUDED
 
18
 
 
19
#include "../pith/osdep/color.h"
 
20
 
 
21
#include "../pith/msgno.h"
 
22
#include "../pith/charset.h"
 
23
 
 
24
 
 
25
/*
 
26
 * Flags for msgline_hidden.
 
27
 *
 
28
 * MH_NONE means we should only consider messages which are or would be
 
29
 *   visible in the index view. That is, messages which are not hidden due
 
30
 *   to zooming, not hidden because they are in a collapsed part of a
 
31
 *   thread, and not hidden because we are in one thread and they are in
 
32
 *   another and the view we are using only shows one thread.
 
33
 * MH_THISTHD changes that a little bit. It considers more messages
 
34
 *   to be visible. In particular, messages in this thread which are
 
35
 *   hidden due to collapsing are considered to be visible instead of hidden.
 
36
 *   This is useful if we are viewing a message and hit Next, and want
 
37
 *   to see the next message in the thread even if it was in a
 
38
 *   collapsed thread. This only makes sense when using the separate
 
39
 *   thread index and viewing a thread. "This thread" is the thread that
 
40
 *   is being viewed, not the thread that msgno is part of. So it is the
 
41
 *   thread that has been marked MN_CHID2.
 
42
 * MH_ANYTHD adds more visibility. It doesn't matter if the message is in
 
43
 *   the same thread or if it is collapsed or not. If a message is not
 
44
 *   hidden due to zooming, then it is not hidden. Notice that ANYTHD
 
45
 *   implies THISTHD.
 
46
 */
 
47
#define MH_NONE         0x0
 
48
#define MH_THISTHD      0x1
 
49
#define MH_ANYTHD       0x2
 
50
 
 
51
 
 
52
typedef enum {iNothing, iStatus, iFStatus, iIStatus,
 
53
              iDate, iLDate, iS1Date, iS2Date, iS3Date, iS4Date, iSDate,
 
54
              iDateIso, iDateIsoS,
 
55
              iSDateIso, iSDateIsoS, iSDateS1, iSDateS2, iSDateS3, iSDateS4,
 
56
              iSDateTime,
 
57
              iSDateTimeIso, iSDateTimeIsoS, iSDateTimeS1,
 
58
              iSDateTimeS2, iSDateTimeS3, iSDateTimeS4,
 
59
              iSDateTime24,
 
60
              iSDateTimeIso24, iSDateTimeIsoS24, iSDateTimeS124,
 
61
              iSDateTimeS224, iSDateTimeS324, iSDateTimeS424,
 
62
              iRDate, iTimezone,
 
63
              iTime24, iTime12,
 
64
              iCurDate, iCurDateIso, iCurDateIsoS, iCurTime24, iCurTime12,
 
65
              iCurDay, iCurDay2Digit, iCurDayOfWeek, iCurDayOfWeekAbb,
 
66
              iCurMon, iCurMon2Digit, iCurMonLong, iCurMonAbb,
 
67
              iCurYear, iCurYear2Digit,
 
68
              iLstMon, iLstMon2Digit, iLstMonLong, iLstMonAbb,
 
69
              iLstMonYear, iLstMonYear2Digit,
 
70
              iLstYear, iLstYear2Digit,
 
71
              iMessNo, iAtt, iMsgID,
 
72
              iSubject, iSubjKey, iSubjKeyInit,
 
73
              iSubjectText, iSubjKeyText, iSubjKeyInitText,
 
74
              iKey, iKeyInit,
 
75
              iSize, iSizeComma, iSizeNarrow, iDescripSize,
 
76
              iNewsAndTo, iToAndNews, iNewsAndRecips, iRecipsAndNews,
 
77
              iFromTo, iFromToNotNews, iFrom, iTo, iSender, iCc, iNews, iRecips,
 
78
              iCurNews, iArrow,
 
79
              iMailbox, iAddress, iInit, iCursorPos,
 
80
              iDay2Digit, iMon2Digit, iYear2Digit,
 
81
              iSTime, iKSize,
 
82
              iRoleNick,
 
83
              iScore, iDayOfWeekAbb, iDayOfWeek,
 
84
              iDay, iDayOrdinal, iMonAbb, iMonLong, iMon, iYear} IndexColType;
 
85
 
 
86
typedef enum {AllAuto, Fixed, Percent, WeCalculate, Special} WidthType;
 
87
 
 
88
typedef enum {eText = 0, eKeyWord, eThreadCount, eThreadInfo, eOpening} ElemType;
 
89
 
 
90
typedef enum {Left, Right} ColAdj;
 
91
 
 
92
typedef struct index_parse_tokens {
 
93
    char        *name;
 
94
    IndexColType ctype;
 
95
    int          what_for;
 
96
} INDEX_PARSE_T;
 
97
 
 
98
 
 
99
/* these are flags for the what_for field in INDEX_PARSE_T */
 
100
#define FOR_NOTHING     0x00
 
101
#define FOR_INDEX       0x01
 
102
#define FOR_REPLY_INTRO 0x02
 
103
#define FOR_TEMPLATE    0x04            /* or for signature */
 
104
#define FOR_FILT        0x08
 
105
#define DELIM_USCORE    0x10
 
106
#define DELIM_PAREN     0x20
 
107
 
 
108
 
 
109
#define DEFAULT_REPLY_INTRO "default"
 
110
 
 
111
 
 
112
typedef struct col_description {
 
113
    IndexColType ctype;
 
114
    WidthType    wtype;
 
115
    int          req_width;
 
116
    int          width;
 
117
    int          actual_length;
 
118
    ColAdj       adjustment;
 
119
} INDEX_COL_S;
 
120
 
 
121
 
 
122
/*
 
123
 * Ensure that all the data in an index_elem (in the data member)
 
124
 * is stored in UTF-8. The writing routines (paint_index_line() for pine)
 
125
 * should then assume UTF-8 when using the data. The process of putting
 
126
 * data into an index_elem will likely involve a conversion into UTF-8.
 
127
 * For example, the Subject or From fields may have data in some arbitrary
 
128
 * character set.
 
129
 */
 
130
typedef struct index_elem {
 
131
    struct index_elem *next;
 
132
    char              *print_format;
 
133
    COLOR_PAIR        *color;           /* color, if any, for this element */
 
134
    char              *data;            /* ptr to full text for this element */
 
135
    unsigned int       datalen;         /* not counting terminating null */
 
136
    ElemType           type;            /* part of field data represents */
 
137
    unsigned           freedata:1;      /* free data when done */
 
138
    unsigned           freecolor:1;     /* free color when done */
 
139
    unsigned           freeprintf:8;    /* how much alloced for print_format */
 
140
    unsigned           wid:8;           /* redundant, width from print_format */
 
141
} IELEM_S;
 
142
 
 
143
 
 
144
/*
 
145
 * 3 is room for '%', '.', and 's'. You need to add one for '\0';
 
146
 * The format string looks like:
 
147
 *
 
148
 *   %13.13s  or %-13.13s
 
149
 *
 
150
 * The '-' is there if left is set and the 13 is the 'width' in the call.
 
151
 */
 
152
#define PRINT_FORMAT_LEN(width,left) (3 + ((left) ? 1 : 0) + 2 * ((width) > 999 ? 4 : (width) > 99 ? 3 : (width) > 9 ? 2 : 1))
 
153
 
 
154
 
 
155
/*
 
156
 * Each field consists of a list of elements. The leftadj bit means we
 
157
 * should left adjust the whole thing in the field width, padding on the
 
158
 * right with spaces or truncating on the right. We haven't yet fully
 
159
 * implemented right adjust, except that it is easy for a single element
 
160
 * field. So be careful with multi-element, right-adjusted fields.
 
161
 */
 
162
typedef struct index_field {
 
163
    struct index_field *next;
 
164
    IndexColType        ctype;
 
165
    unsigned            width:8;        /* width of whole field           */
 
166
    unsigned            leftadj:1;      /* left adjust elements in field  */
 
167
    IELEM_S            *ielem;          /* list of elements in this field */
 
168
} IFIELD_S;
 
169
 
 
170
 
 
171
/*
 
172
 * If the index_cache_entry has an ifield list, it is assumed that the
 
173
 * ifields have had their ielement lists filled in.
 
174
 * The widths_done bit is set after the widths and print formats are setup
 
175
 * to do the correct width. A width change could be done by unsetting
 
176
 * the widths_done bit and then recalculating the widths in the ifields
 
177
 * and resetting the print_format strings in the ielems.
 
178
 */
 
179
typedef struct index_cache_entry {
 
180
    IFIELD_S     *ifield;               /* list of fields */
 
181
    COLOR_PAIR   *linecolor;
 
182
    char         *charset;
 
183
    unsigned      color_lookup_done:1;  /* efficiency hacks */
 
184
    unsigned      widths_done:1;
 
185
    unsigned      to_us:1;
 
186
    unsigned      cc_us:1;
 
187
    int           plus;
 
188
    unsigned long id;                   /* hash value */
 
189
    struct index_cache_entry *tice;     /* thread index header line */
 
190
} ICE_S;
 
191
 
 
192
 
 
193
/*
 
194
 * Pieces needed to construct a valid folder index entry, and to
 
195
 * control what can be fetched when (due to callbacks and such)
 
196
 */
 
197
typedef struct index_data {
 
198
    MAILSTREAM *stream;
 
199
    ADDRESS    *from,                   /* always valid */
 
200
               *to,                     /* check valid bit, fetch as req'd */
 
201
               *cc,                     /* check valid bit, fetch as req'd */
 
202
               *sender;                 /* check valid bit, fetch as req'd */
 
203
    char       *newsgroups,             /* check valid bit, fetch as req'd */
 
204
               *subject,                /* always valid */
 
205
               *date;                   /* always valid */
 
206
    long        msgno,                  /* tells us what we're looking at */
 
207
                rawno,
 
208
                size;                   /* always valid */
 
209
    unsigned    no_fetch:1,             /* lit when we're in a callback */
 
210
                bogus:2,                /* lit when there were problems */
 
211
                valid_to:1,             /* trust struct's "to" pointer */
 
212
                valid_cc:1,             /* trust struct's "cc" pointer */
 
213
                valid_sender:1,         /* trust struct's "sender" pointer */
 
214
                valid_news:1,           /* trust struct's "news" pointer */
 
215
                valid_resent_to:1,      /* trust struct's "resent-to" ptr */
 
216
                resent_to_us:1;         /* lit when we know its true */
 
217
} INDEXDATA_S;
 
218
 
 
219
 
 
220
/*
 
221
 * Line_hash can't return LINE_HASH_N, so we use it in a couple places as
 
222
 * a special value that we can assign knowing it can't be a real hash value.
 
223
 */
 
224
#define LINE_HASH_N     0xffffffff
 
225
 
 
226
 
 
227
typedef enum {NoKW, KW, KWInit} SubjKW;
 
228
 
 
229
 
 
230
/* exported protoypes */
 
231
 
 
232
 
 
233
#endif /* PITH_INDXTYPE_INCLUDED */