Add support for tab-completion when selecting by rule
[alpine.git] / pith / foldertype.h
blob24344ac68316a2095ef7934c084802576f771d69
1 /*
2 * $Id: foldertype.h 768 2007-10-24 00:10:03Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2006-2007 University of Washington
6 * Copyright 2013-2022 Eduardo Chappa
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_FOLDERTYPE_INCLUDED
18 #define PITH_FOLDERTYPE_INCLUDED
21 #include "../pith/conftype.h"
22 #include "../pith/string.h"
26 * Type definitions for folder and context structures.
30 /*------------------------------
31 Used for displaying as well as
32 keeping track of folders.
33 ----*/
34 typedef struct folder {
35 unsigned char name_len; /* name length */
36 unsigned isfolder:1; /* is it a folder? */
37 unsigned isdir:1; /* is it a directory? */
38 /* isdual is only set if the user has the separate
39 directory and folder display option set. Otherwise,
40 we can tell it's dual use because both isfolder
41 and isdir will be set. */
42 unsigned isdual:1; /* dual use */
43 unsigned haschildren:1; /* dir known to have children */
44 unsigned hasnochildren:1; /* known not to have children */
45 unsigned scanned:1; /* scanned by c-client */
46 unsigned selected:1; /* selected by user */
47 unsigned subscribed:1; /* selected by user */
48 unsigned unseen_valid:1; /* unseen count is valid */
49 unsigned long varhash; /* hash of var for incoming */
50 imapuid_t uidvalidity; /* only for #move folder */
51 imapuid_t uidnext; /* only for #move folder */
52 char *nickname; /* folder's short name */
53 unsigned long unseen; /* for monitoring unseen */
54 unsigned long new; /* for monitoring unseen */
55 unsigned long total; /* for monitoring unseen */
56 time_t last_unseen_update; /* see LUU_ constants below */
57 char name[1]; /* folder's name */
58 } FOLDER_S;
61 /* special values stored in last_unseen_update */
62 #define LUU_INIT ((time_t) 0) /* before first check is done */
63 #define LUU_NEVERCHK ((time_t) 1) /* don't check this folder */
64 #define LUU_NOMORECHK ((time_t) 2) /* check failed so stop checking */
66 /* this value is eligible for checking */
67 #define LUU_YES(luu) (((luu) != LUU_NEVERCHK) && ((luu) != LUU_NOMORECHK))
71 * Folder List Structure - provides for two ways to access and manage
72 * folder list data. One as an array of pointers
73 * to folder structs or
75 typedef struct folder_list {
76 unsigned used;
77 unsigned allocated;
78 FOLDER_S **folders; /* array of pointers to folder structs */
79 } FLIST;
83 * digested form of context including pointer to the parent
84 * level of hierarchy...
86 typedef struct folder_dir {
87 char *ref, /* collection location */
88 *desc, /* Optional description */
89 delim, /* dir/file delimiter */
90 status; /* folder data's status */
91 struct {
92 char *user,
93 *internal;
94 } view; /* file's within dir */
96 FLIST *folders; /* folder data */
97 struct folder_dir *prev; /* parent directory */
98 } FDIR_S;
101 typedef struct selected_s {
102 char *reference; /* location of selected */
103 STRLIST_S *folders; /* list of selected */
104 unsigned zoomed:1; /* zoomed state */
105 struct selected_s *sub;
106 } SELECTED_S;
109 /*------------------------------
110 Structure to keep track of the various folder collections being
111 dealt with.
112 ----*/
113 typedef struct context {
114 FDIR_S *dir; /* directory stack */
115 char *context, /* raw context string */
116 *server, /* server name/parms */
117 *nickname, /* user provided nickname */
118 *label, /* Description */
119 *comment, /* Optional comment */
120 last_folder[MAXFOLDER+1]; /* last folder used */
121 struct {
122 struct variable *v; /* variable where defined */
123 short i; /* index into config list */
124 } var;
126 time_t update; /* update state */
127 unsigned short use, /* use flags (see below) */
128 d_line; /* display line for labels */
129 SELECTED_S selected;
130 struct context *next, /* next context struct */
131 *prev; /* previous context struct */
132 } CONTEXT_S;
135 * Flags to indicate context (i.e., folder collection) use
137 #define CNTXT_PSEUDO 0x0001 /* fake folder entry exists */
138 #define CNTXT_INCMNG 0x0002 /* inbox collection */
139 #define CNTXT_SAVEDFLT 0x0004 /* default save collection */
140 #define CNTXT_PARTFIND 0x0008 /* partial find done */
141 #define CNTXT_NOFIND 0x0010 /* no find done in context */
142 #define CNTXT_FINDALL 0x0020 /* Do a find_all on context */
143 #define CNTXT_NEWS 0x0040 /* News namespace collection */
144 #define CNTXT_SUBDIR 0x0080 /* subdirectory within col'n */
145 #define CNTXT_PRESRV 0x0100 /* preserve/restore selected */
146 #define CNTXT_ZOOM 0x0200 /* context display narrowed */
147 #define CNTXT_INHERIT 0x1000
151 * Macros to help users of above two structures...
153 #define NEWS_TEST(c) ((c) && ((c)->use & CNTXT_NEWS))
155 #define FOLDERS(c) ((c)->dir->folders)
156 #define FLDR_NAME(X) ((X) ? ((X)->nickname ? (X)->nickname : (X)->name) :"")
157 #define ALL_FOUND(X) (((X)->dir->status & CNTXT_NOFIND) == 0 && \
158 ((X)->dir->status & CNTXT_PARTFIND) == 0)
161 /* exported prototypes */
164 #endif /* PITH_FOLDERTYPE_INCLUDED */