summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alpine/mailcmd.c124
-rw-r--r--pith/conf.c7
-rw-r--r--pith/conf.h1
-rw-r--r--pith/conftype.h1
-rw-r--r--pith/hist.c51
-rw-r--r--pith/hist.h3
-rw-r--r--pith/pine.hlp38
7 files changed, 184 insertions, 41 deletions
diff --git a/alpine/mailcmd.c b/alpine/mailcmd.c
index e35bcead..4d519897 100644
--- a/alpine/mailcmd.c
+++ b/alpine/mailcmd.c
@@ -4207,26 +4207,47 @@ get_export_filename(struct pine *ps, char *filename, char *deefault,
char *lister_msg, ESCKEY_S *optsarg, int *rflags,
int qline, int flags, HISTORY_S **history)
{
- char dir[MAXPATH+1], dir2[MAXPATH+1];
+ char dir[MAXPATH+1], dir2[MAXPATH+1], orig_dir[MAXPATH+1];
char precolon[MAXPATH+1], postcolon[MAXPATH+1];
char filename2[MAXPATH+1], tmp[MAXPATH+1], *fn, *ill;
- int l, i, ku = -1, r, fatal, homedir = 0, was_abs_path=0, avail, ret = 0;
+ int l, i, ku = -1, kp = -1, r, fatal, homedir = 0, was_abs_path=0, avail, ret = 0;
int allparts = 0, binary = 0;
char prompt_buf[400];
char def[500];
ESCKEY_S *opts = NULL;
struct variable *vars = ps->vars;
static HISTORY_S *dir_hist = NULL;
+ static char *last;
+ int pos, hist_len = 0;
- if(flags & GE_ALLPARTS || history){
+
+ /* we will fake a history with the ps_global->VAR_HISTORY variable
+ * We fake that we combine this variable into a history variable
+ * by stacking VAR_HISTORY on top of dir_hist. We keep track of this
+ * by looking at the variable pos.
+ */
+ if(ps_global->VAR_HISTORY != NULL)
+ for(hist_len = 0; ps_global->VAR_HISTORY[hist_len]
+ && ps_global->VAR_HISTORY[hist_len][0]; hist_len++)
+ ;
+
+ pos = hist_len + items_in_hist(dir_hist);
+
+ if(dir_hist == NULL)
+ init_hist(&dir_hist, HISTSIZE);
+
+ if(flags & GE_ALLPARTS || history || dir_hist){
/*
* Copy the opts and add one to the end of the list.
*/
for(i = 0; optsarg[i].ch != -1; i++)
;
+ if(dir_hist || hist_len > 0)
+ i += 2;
+
if(history)
- i += 4;
+ i += dir_hist || hist_len > 0 ? 2 : 4;
if(flags & GE_ALLPARTS)
i++;
@@ -4261,6 +4282,19 @@ get_export_filename(struct pine *ps, char *filename, char *deefault,
opts[i++].label = N_("Binary");
}
+ if(dir_hist || hist_len > 0){
+ opts[i].ch = ctrl('Y');
+ opts[i].rval = 32;
+ opts[i].name = "";
+ kp = i;
+ opts[i++].label = "";
+
+ opts[i].ch = ctrl('V');
+ opts[i].rval = 33;
+ opts[i].name = "";
+ opts[i++].label = "";
+ }
+
if(history){
opts[i].ch = KEY_UP;
opts[i].rval = 30;
@@ -4272,24 +4306,13 @@ get_export_filename(struct pine *ps, char *filename, char *deefault,
opts[i].rval = 31;
opts[i].name = "";
opts[i++].label = "";
-
- opts[i].ch = ctrl('Y');
- opts[i].rval = 32;
- opts[i].name = "";
- opts[i++].label = "";
-
- opts[i].ch = ctrl('V');
- opts[i].rval = 33;
- opts[i].name = "";
- opts[i++].label = "";
}
-
+
opts[i].ch = -1;
- if(history){
+ if(history)
init_hist(history, HISTSIZE);
- init_hist(&dir_hist, HISTSIZE);
- }
+ init_hist(&dir_hist, HISTSIZE); /* reset history to the end */
}
else
opts = optsarg;
@@ -4314,6 +4337,8 @@ get_export_filename(struct pine *ps, char *filename, char *deefault,
dir[1] = '\0';
homedir=1;
}
+ strncpy(orig_dir, dir, sizeof(orig_dir));
+ orig_dir[sizeof(orig_dir)-1] = '\0';
postcolon[0] = '\0';
strncpy(precolon, dir, sizeof(precolon));
@@ -4440,24 +4465,27 @@ get_export_filename(struct pine *ps, char *filename, char *deefault,
snprintf(prompt_buf, sizeof(prompt_buf), "%s%s%s%s%s", p1, p2, p3, p4, p5);
prompt_buf[sizeof(prompt_buf)-1] = '\0';
+ if(kp >= 0){
+ if(items_in_hist(dir_hist) > 0 || hist_len > 0){ /* any directories */
+ opts[kp].name = "^Y";
+ opts[kp].label = "Prev Dir";
+ opts[kp+1].name = "^V";
+ opts[kp+1].label = "Next Dir";
+ }
+ else{
+ opts[kp].name = "";
+ opts[kp].label = "";
+ opts[kp+1].name = "";
+ opts[kp+1].label = "";
+ }
+ }
+
if(ku >= 0){
if(items_in_hist(*history) > 0){
opts[ku].name = HISTORY_UP_KEYNAME;
opts[ku].label = HISTORY_KEYLABEL;
opts[ku+1].name = HISTORY_DOWN_KEYNAME;
opts[ku+1].label = HISTORY_KEYLABEL;
- if(items_in_hist(dir_hist) > 0){ /* any directories */
- opts[ku+2].name = "^Y";
- opts[ku+2].label = "Prev Dir";
- opts[ku+3].name = "^V";
- opts[ku+3].label = "Next Dir";
- }
- else{
- opts[ku+2].name = "";
- opts[ku+2].label = "";
- opts[ku+3].name = "";
- opts[ku+3].label = "";
- }
}
else{
opts[ku].name = "";
@@ -4748,15 +4776,32 @@ get_export_filename(struct pine *ps, char *filename, char *deefault,
else if(r >= 30 && r <= 33){
char *p = NULL;
- if(history){
- switch(r){
- case 30: p = get_prev_hist(*history, filename, 0, NULL); break;
- case 31: p = get_next_hist(*history, filename, 0, NULL); break;
- case 32: p = get_prev_hist(dir_hist, NULL, 0, NULL); break;
- case 33: p = get_next_hist(dir_hist, NULL, 0, NULL); break;
- default: alpine_panic("Impossible case in save attachment"); break;
+ if(r == 30 || r == 31){
+ if(history){
+ if(r == 30)
+ p = get_prev_hist(*history, filename, 0, NULL);
+ else if (r == 31)
+ p = get_next_hist(*history, filename, 0, NULL);
+ }
+ }
+
+ if(r == 32 || r == 33){
+ int nitems = items_in_hist(dir_hist);
+ if(dir_hist || hist_len > 0){
+ if(r == 32){
+ if(pos > 0)
+ p = hist_in_pos(--pos, ps_global->VAR_HISTORY, hist_len, dir_hist, nitems);
+ else p = last;
}
+ else if (r == 33){
+ if(pos < hist_len + nitems)
+ p = hist_in_pos(++pos, ps_global->VAR_HISTORY, hist_len, dir_hist, nitems);
+ }
+ if(p == NULL || *p == '\0')
+ p = orig_dir;
+ }
}
+ last = p; /* save it! */
if(p != NULL && *p != '\0'){
if(r == 30 || r == 31){
@@ -4936,7 +4981,10 @@ done:
tmp[MAXPATH] = '\0';
if((fn = strrchr(tmp, C_FILESEP)) != NULL)
*fn = '\0';
- save_hist(dir_hist, tmp, 0, NULL);
+ else
+ tmp[0] = '\0';
+ if(tmp[0])
+ save_hist(dir_hist, tmp, 0, NULL);
}
if(opts && opts != optsarg)
diff --git a/pith/conf.c b/pith/conf.c
index 6e320527..79243222 100644
--- a/pith/conf.c
+++ b/pith/conf.c
@@ -244,6 +244,8 @@ CONF_TXT_T cf_text_image_viewer[] = "Program to view images (e.g. GIF or TIFF at
CONF_TXT_T cf_text_browser[] = "List of programs to open Internet URLs (e.g. http or ftp references).";
+CONF_TXT_T cf_text_history[] = "List of directories that are preferred locations to save or export attachments.";
+
CONF_TXT_T cf_text_inc_startup[] = "Sets message which cursor begins on. Choices: first-unseen, first-recent,\n# first-important, first-important-or-unseen, first-important-or-recent,\n# first, last. Default: \"first-unseen\".";
CONF_TXT_T cf_pruning_rule[] = "Allows a default answer for the prune folder questions. Choices: yes-ask,\n# yes-no, no-ask, no-no, ask-ask, ask-no. Default: \"ask-ask\".";
@@ -656,6 +658,8 @@ static struct variable variables[] = {
NULL, cf_text_mimetype_path},
{"url-viewers", 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0,
"URL-Viewers", cf_text_browser},
+{"default-directories", 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0,
+ "Extra Directories for Save", cf_text_history},
{"max-remote-connections", 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0,
"Maximum Remote Connections", cf_text_maxremstreams},
{"stay-open-folders", 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0,
@@ -2018,6 +2022,7 @@ init_vars(struct pine *ps, void (*cmds_f) (struct pine *, char **))
#endif /* _WINDOWS */
set_current_val(&vars[V_IMAGE_VIEWER], TRUE, TRUE);
set_current_val(&vars[V_BROWSER], TRUE, TRUE);
+ set_current_val(&vars[V_HISTORY], TRUE, TRUE);
set_current_val(&vars[V_SMTP_SERVER], TRUE, TRUE);
set_current_val(&vars[V_COMP_HDRS], TRUE, TRUE);
set_current_val(&vars[V_CUSTOM_HDRS], TRUE, TRUE);
@@ -7868,6 +7873,8 @@ config_help(int var, int feature)
return(h_config_newsrc_path);
case V_BROWSER :
return(h_config_browser);
+ case V_HISTORY :
+ return(h_config_history);
#if defined(DOS) || defined(OS2)
case V_FILE_DIR :
return(h_config_file_dir);
diff --git a/pith/conf.h b/pith/conf.h
index acdf7868..1fb95fcd 100644
--- a/pith/conf.h
+++ b/pith/conf.h
@@ -343,6 +343,7 @@
#define GLO_THREAD_EXP_CHAR vars[V_THREAD_EXP_CHAR].global_val.p
#define VAR_THREAD_LASTREPLY_CHAR vars[V_THREAD_LASTREPLY_CHAR].current_val.p
#define GLO_THREAD_LASTREPLY_CHAR vars[V_THREAD_LASTREPLY_CHAR].global_val.p
+#define VAR_HISTORY vars[V_HISTORY].current_val.l
#if defined(DOS) || defined(OS2)
#define VAR_FILE_DIR vars[V_FILE_DIR].current_val.p
diff --git a/pith/conftype.h b/pith/conftype.h
index afae74ec..9549e49d 100644
--- a/pith/conftype.h
+++ b/pith/conftype.h
@@ -126,6 +126,7 @@ typedef enum { V_PERSONAL_NAME = 0
, V_MAILCAP_PATH
, V_MIMETYPE_PATH
, V_BROWSER
+ , V_HISTORY
, V_MAXREMSTREAM
, V_PERMLOCKED
, V_INCCHECKTIMEO
diff --git a/pith/hist.c b/pith/hist.c
index d42b67a6..9d5022c9 100644
--- a/pith/hist.c
+++ b/pith/hist.c
@@ -57,6 +57,57 @@ free_hist(HISTORY_S **history)
}
}
+char *
+hist_in_pos(int pos, char **list, int llen, HISTORY_S *hist, int n)
+{
+ char *p;
+ int i;
+
+ if(pos < 0 || pos > llen + n)
+ return NULL;
+
+ if(pos < llen)
+ return list[pos];
+
+ hist->curindex = hist->origindex; /* reset history */
+ for(i = 0; i < n-1; i++)
+ p = get_prev_hist_dir(hist);
+ p = get_prev_hist_dir(hist);
+ for(i = 0; i < pos - llen; i++)
+ p = get_next_hist_dir(hist);
+ return p;
+}
+
+
+char *
+get_next_hist_dir(HISTORY_S *history)
+{
+ return get_next_hist(history, NULL, 0, NULL);
+}
+
+
+char *
+get_prev_hist_dir(HISTORY_S *history)
+{
+ int nextcurindex;
+
+ if(!(history && history->histsize > 0))
+ return NULL;
+
+ nextcurindex = (history->curindex + 1) % history->histsize;
+
+ /* already at start of history */
+ if(nextcurindex == history->origindex
+ || !(history->hist[nextcurindex] && history->hist[nextcurindex]->str
+ && history->hist[nextcurindex]->str[0]))
+ return NULL;
+
+ history->curindex = nextcurindex;
+
+ return((history->hist[history->curindex] && history->hist[history->curindex]->str)
+ ? history->hist[history->curindex]->str : NULL);
+}
+
char *
get_prev_hist(HISTORY_S *history, char *savethis, unsigned saveflags, void *cntxt)
diff --git a/pith/hist.h b/pith/hist.h
index 8217bc5b..65082998 100644
--- a/pith/hist.h
+++ b/pith/hist.h
@@ -43,6 +43,9 @@ void init_hist(HISTORY_S **, int);
void free_hist(HISTORY_S **);
char *get_prev_hist(HISTORY_S *, char *, unsigned, void *);
char *get_next_hist(HISTORY_S *, char *, unsigned, void *);
+char *get_prev_hist_dir(HISTORY_S *);
+char *get_next_hist_dir(HISTORY_S *);
+char *hist_in_pos(int, char **, int, HISTORY_S *, int);
void save_hist(HISTORY_S *, char *, unsigned, void *);
int items_in_hist(HISTORY_S *);
void add_to_histlist(HISTORY_S **);
diff --git a/pith/pine.hlp b/pith/pine.hlp
index 9eb5575b..af5b06b7 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -194,6 +194,13 @@ Additions include:
that allows users to ignore errors in the computation of the size
of a message from defective servers.
+ <LI> Add the configuration variable "default-directories", which is called
+ <A href="h_config_history"><!--#echo var="VAR_default-directories"--></A>
+ variable saves a list of directories that are readily accessible
+ for save or export of attachments. This makes it easier to save
+ attachments in directories that are hard to navigate to, or that
+ are accessed frequently.
+
<LI> Ignore message from smtp server after a successful authentication
challenge.
@@ -4123,6 +4130,7 @@ There are also additional details on
<li><a href="h_config_upload_cmd">OPTION: <!--#echo var="VAR_upload-command"--></a>
<li><a href="h_config_upload_prefix">OPTION: <!--#echo var="VAR_upload-command-prefix"--></a>
<li><a href="h_config_browser">OPTION: <!--#echo var="VAR_url-viewers"--></a>
+<li><a href="h_config_history">OPTION: <!--#echo var="VAR_default-directories"--></a>
<li><a href="h_config_domain_name">OPTION: <!--#echo var="VAR_use-only-domain-name"--></a>
<li><a href="h_config_user_dom">OPTION: <!--#echo var="VAR_user-domain"--></a>
<li><a href="h_config_user_id">OPTION: <!--#echo var="VAR_user-id"--></a>
@@ -20483,9 +20491,9 @@ example.
<DD>This option makes sense only for IMAP servers that do not perform
a SEARCH command correctly. If your filtering rules
fail to filter some messages, that should have been filtered, then this
-option will make Alpine download all data necessary to perform that search.
-There is a performance penalty when using this option. Downloading the
-data to perfom the search will take longer than requesting the IMAP
+option will make Alpine download all data necessary data to perform that
+search. There is a performance penalty when using this option. Downloading
+the data to perfom the search will take longer than requesting the IMAP
server to perform the filtering, but the filtering will be done correctly.
<P>
</DD>
@@ -27227,6 +27235,30 @@ local computing support staff.
&lt;End of help on this topic&gt;
</BODY>
</HTML>
+====== h_config_history =====
+<HTML>
+<HEAD>
+<TITLE>OPTION: <!--#echo var="VAR_default-directories"--></TITLE>
+</HEAD>
+<BODY>
+<H1>OPTION: <!--#echo var="VAR_default-directories"--></H1>
+<P>
+This option allows you to input a list of directories that Alpine will offer
+for you to use when you are saving or exporting attachments. This is useful
+when navigating to specific directories becomes too tedious, or when you
+need to do this on a daily basis, and want Alpine to remember this on a
+permanent basis.
+<P>
+The list of directories saved here can be accessed using the ^Y and ^V commands
+in the save prompt for attachments, or the export command.
+
+<P><UL>
+<LI><A HREF="h_finding_help">Finding more information and requesting help</A>
+</UL>
+<P>
+&lt;End of help on this topic&gt;
+</BODY>
+</HTML>
====== h_config_browser_xterm =====
<HTML>
<HEAD>