From 9abb6857918960af55433274d71829832a74a47d Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Sun, 29 May 2016 17:40:39 -0600 Subject: * The TAB key allows autocomplete in the Fcc field in the composer headers, as well as autocompletes automatically when only one possibility exists for the ^J attach command. --- alpine/folder.c | 34 ++++++++++++++++++++++++++++++++++ alpine/folder.h | 2 +- alpine/send.c | 2 +- pico/file.c | 14 ++++++++++++-- pith/pine.hlp | 4 ++++ 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/alpine/folder.c b/alpine/folder.c index be084ed8..b94c9068 100644 --- a/alpine/folder.c +++ b/alpine/folder.c @@ -6889,6 +6889,40 @@ get_post_list(char **post_host) } +int +fcc_tab_complete (char *prefix, char **answer, int tabtab, unsigned flags) +{ + char tmp[MAILTMPLEN+1]; + int n; + CONTEXT_S *mc; + + if(prefix == NULL || *prefix == '\0') + return 0; + + for(mc = ps_global->context_list; mc != NULL; mc = mc->next) + if(mc->use & CNTXT_SAVEDFLT) + break; + + if(mc == NULL) return 0; + + strncpy(tmp, prefix, sizeof(tmp)); + tmp[sizeof(tmp)-1] = '\0'; + + if(!folder_complete(mc, tmp, sizeof(tmp), &n)){ + if(n){ + if(tabtab) + display_folder_list(&mc, tmp, 1,folders_for_goto); + } + else + Writechar(BELL, 0); + } + if(n) + *answer = cpystr(tmp); + return n == 0 ? 0 : n == 1 ? 2 : 1; +} + + + #ifdef _WINDOWS int folder_list_popup(sparms, in_handle) diff --git a/alpine/folder.h b/alpine/folder.h index 6e9fbee5..f5996efb 100644 --- a/alpine/folder.h +++ b/alpine/folder.h @@ -34,6 +34,6 @@ char *context_edit_screen(struct pine *, char *, char *, char *, char *, char int add_new_folder(CONTEXT_S *, EditWhich, int, char *, size_t, MAILSTREAM *, char *); char *next_folder(MAILSTREAM **, char *, size_t, char *, CONTEXT_S *, long *, int *); char *news_group_selector(char **); - +int fcc_tab_complete(char *, char **, int, unsigned); #endif /* PINE_FOLDER_INCLUDED */ diff --git a/alpine/send.c b/alpine/send.c index dfba59f3..90561345 100644 --- a/alpine/send.c +++ b/alpine/send.c @@ -929,7 +929,7 @@ static struct headerentry he_template[]={ news_build, NULL, NULL, news_group_selector, "To NwsGrps", NULL, NULL, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, KS_NONE}, {"Fcc : ", "Fcc", h_composer_fcc, 10, 0, NULL, - NULL, NULL, NULL, folders_for_fcc, "To Fldrs", NULL, NULL, + NULL, NULL, NULL, folders_for_fcc, "To Fldrs", NULL, fcc_tab_complete, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, KS_NONE}, {"Lcc : ", "Lcc", h_composer_lcc, 10, 0, NULL, build_addr_lcc, NULL, NULL, addr_book_compose_lcc,"To AddrBk", NULL, abook_nickname_complete, diff --git a/pico/file.c b/pico/file.c index 149971f0..1b41f181 100644 --- a/pico/file.c +++ b/pico/file.c @@ -1016,7 +1016,7 @@ int pico_fncomplete(char *dirarg, char *fn, size_t fnlen) { char *p, *dlist, tmp[NLINE], dir[NLINE]; - int n, i, match = -1; + int n, i, match = -1, orign; #ifdef DOS #define FILECMP(x, y) (toupper((unsigned char)(x))\ == toupper((unsigned char)(y))) @@ -1027,9 +1027,16 @@ pico_fncomplete(char *dirarg, char *fn, size_t fnlen) strncpy(dir, dirarg, sizeof(dir)); dir[sizeof(dir)-1] = '\0'; pfnexpand(dir, sizeof(dir)); - if(*fn && (dlist = p = getfnames(dir, fn, &n, NULL, 0))){ + if((dlist = p = getfnames(dir, fn, &n, NULL, 0))){ + orign = n; memset(tmp, 0, sizeof(tmp)); while(n--){ /* any names in it */ + if(strcmp(p, ".") == 0 || strcmp(p, "..") == 0){ + p += strlen(p) + 1; + orign--; + continue; + } + for(i = 0; i < sizeof(tmp)-1 && fn[i] && FILECMP(p[i], fn[i]); i++) ; @@ -1054,6 +1061,9 @@ pico_fncomplete(char *dirarg, char *fn, size_t fnlen) free(dlist); } + if(fn[0] == '\0' && orign != 1) + match = -1; + if(match >= 0){ strncpy(fn, tmp, fnlen); fn[fnlen-1] = '\0'; diff --git a/pith/pine.hlp b/pith/pine.hlp index 2a02cc2b..23c88ea6 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -207,6 +207,10 @@ Additions include: subcommand ^N to decode the file name and save the file with the decoded name. +
  • The TAB key allows autocomplete in the Fcc field in the composer headers, + as well as autocompletes automatically when only one possibility exists + for the ^J attach command. +
  • Ignore message from smtp server after a successful authentication challenge. -- cgit v1.2.3-70-g09d2