From dc726add2e8fe52be1f6859ea7cbe4651498eeb8 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sun, 11 Nov 2007 23:32:42 +0100 Subject: [PATCH] mutt_enter_string is only used for _mutt_get_field for real. Hide it. Note: I'd like to get rid of that poo and replace with a proper readline-like ncurses-aware widget that comes with all the vi/emacs bindings ready :/ Signed-off-by: Pierre Habouzit --- account.c | 1 - alias.cpkg | 1 - browser.c | 1 - commands.c | 1 - compose.c | 1 - crypt.cpkg | 1 - imap/browse.c | 2 -- lib-ui/curs_lib.c | 23 ----------------------- lib-ui/curses.h | 11 +++++++++++ lib-ui/enter.c | 41 ++++++++++++++++++++++++++++++++--------- lib-ui/enter.h | 38 -------------------------------------- lib-ui/menu.c | 1 - muttlib.c | 1 - pager.c | 1 - pattern.c | 1 - postpone.c | 3 +-- recvattach.c | 1 - recvcmd.c | 1 - send.c | 1 - sendlib.c | 1 - 20 files changed, 44 insertions(+), 88 deletions(-) delete mode 100644 lib-ui/enter.h diff --git a/account.c b/account.c index 78f80c6..e9ce50e 100644 --- a/account.c +++ b/account.c @@ -10,7 +10,6 @@ /* remote host account manipulation (POP/IMAP) */ #include -#include #include #include "mutt.h" diff --git a/alias.cpkg b/alias.cpkg index 10e2d8c..a3b8d8d 100644 --- a/alias.cpkg +++ b/alias.cpkg @@ -30,7 +30,6 @@ #include #include -#include #include #include "alias.h" diff --git a/browser.c b/browser.c index 19fc098..8075655 100644 --- a/browser.c +++ b/browser.c @@ -14,7 +14,6 @@ #include #include -#include #include #include diff --git a/commands.c b/commands.c index eb7c6df..710fd7b 100644 --- a/commands.c +++ b/commands.c @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/compose.c b/compose.c index b6a6bde..5b55a8d 100644 --- a/compose.c +++ b/compose.c @@ -17,7 +17,6 @@ #include #include -#include #include #include diff --git a/crypt.cpkg b/crypt.cpkg index 7047775..10a33b2 100644 --- a/crypt.cpkg +++ b/crypt.cpkg @@ -17,7 +17,6 @@ #include #include -#include #include #include diff --git a/imap/browse.c b/imap/browse.c index 3c741b1..85a64b1 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -12,8 +12,6 @@ #include -#include - #include "mutt.h" #include "imap_private.h" diff --git a/lib-ui/curs_lib.c b/lib-ui/curs_lib.c index 891e20f..2268e5b 100644 --- a/lib-ui/curs_lib.c +++ b/lib-ui/curs_lib.c @@ -21,7 +21,6 @@ #include #include "menu.h" -#include "enter.h" #include "mutt.h" #include "pager.h" @@ -61,28 +60,6 @@ event_t mutt_getch (void) return (ch == ctrl ('G') ? err : ret); } -int _mutt_get_field ( const char *field, char *buf, ssize_t buflen, - int complete, int multiple, char ***files, int *numfiles) -{ - int ret; - int x, y; - - ENTER_STATE *es = mutt_new_enter_state (); - - do { - CLEARLINE(stdscr, LINES - 1); - waddstr (stdscr, field); - mutt_refresh (); - getyx (stdscr, y, x); - ret = mutt_enter_string(buf, buflen, y, x, complete, multiple, files, - numfiles, es); - } while (ret == 1); - CLEARLINE(stdscr, LINES - 1); - mutt_free_enter_state (&es); - - return (ret); -} - int mutt_get_field_unbuffered (char *msg, char *buf, ssize_t buflen, int flags) { int rc; diff --git a/lib-ui/curses.h b/lib-ui/curses.h index 9df89be..cab58af 100644 --- a/lib-ui/curses.h +++ b/lib-ui/curses.h @@ -74,6 +74,17 @@ enum { MT_COLOR_MAX }; +/* flags for mutt_get_field() */ +#define M_ALIAS (1<<0) /* do alias "completion" by calling up the alias-menu */ +#define M_FILE (1<<1) /* do file completion */ +#define M_EFILE (1<<2) /* do file completion, plus incoming folders */ +#define M_CMD (1<<3) /* do completion on previous word */ +#define M_PASS (1<<4) /* password mode (no echo) */ +#define M_CLEAR (1<<5) /* clear input if printable character is pressed */ +#define M_COMMAND (1<<6) /* do command completion */ +#define M_PATTERN (1<<7) /* pattern mode - only used for history classes */ +#define M_LASTFOLDER (1<<8) /* last-folder mode - hack hack hack */ + typedef struct color_line { regex_t rx; char *pattern; diff --git a/lib-ui/enter.c b/lib-ui/enter.c index cb5478b..44ccb69 100644 --- a/lib-ui/enter.c +++ b/lib-ui/enter.c @@ -10,7 +10,6 @@ #include -#include "enter.h" #include "menu.h" #include "mutt.h" @@ -19,6 +18,15 @@ #include "history.h" #include "buffy.h" +typedef struct { + wchar_t *wbuf; + size_t wbuflen; + size_t lastchar; + size_t curpos; + size_t begin; + int tabs; +} ENTER_STATE; + /* redraw flags for mutt_enter_string() */ enum { M_REDRAW_INIT = 1, /* go to end of line and redraw */ @@ -164,9 +172,10 @@ static void replace_part (ENTER_STATE *state, size_t from, const char *buf) p_delete(&savebuf); } -int mutt_enter_string (char *buf, size_t buflen, int y, int x, - int flags, int multiple, char ***files, int *numfiles, - ENTER_STATE * state) +static int +mutt_enter_string(char *buf, size_t buflen, int y, int x, int flags, + int multiple, char ***files, int *numfiles, + ENTER_STATE *state) { int width = COLS - x - 1; int redraw; @@ -645,13 +654,27 @@ bye: return rv; } -void mutt_free_enter_state (ENTER_STATE ** esp) +int _mutt_get_field(const char *field, char *buf, ssize_t buflen, int flags, + int multiple, char ***files, int *numfiles) { - if (!esp) - return; + int ret; + int x, y; + ENTER_STATE es; + + p_clear(&es, 1); - p_delete(&(*esp)->wbuf); - p_delete(esp); + do { + CLEARLINE(stdscr, LINES - 1); + waddstr (stdscr, field); + mutt_refresh (); + getyx (stdscr, y, x); + ret = mutt_enter_string(buf, buflen, y, x, flags, multiple, files, + numfiles, &es); + } while (ret == 1); + CLEARLINE(stdscr, LINES - 1); + + p_delete(&es.wbuf); + return (ret); } /* diff --git a/lib-ui/enter.h b/lib-ui/enter.h deleted file mode 100644 index 69df037..0000000 --- a/lib-ui/enter.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright notice from original mutt: - * Copyright (C) 1996-2000 Michael R. Elkins - * - * This file is part of mutt-ng, see http://www.muttng.org/. - * It's licensed under the GNU General Public License, - * please see the file GPL in the top level source directory. - */ -#ifndef _MUTT_ENTER_H -#define _MUTT_ENTER_H - -/* flags for mutt_enter_string() */ -#define M_ALIAS 1 /* do alias "completion" by calling up the alias-menu */ -#define M_FILE (1<<1) /* do file completion */ -#define M_EFILE (1<<2) /* do file completion, plus incoming folders */ -#define M_CMD (1<<3) /* do completion on previous word */ -#define M_PASS (1<<4) /* password mode (no echo) */ -#define M_CLEAR (1<<5) /* clear input if printable character is pressed */ -#define M_COMMAND (1<<6) /* do command completion */ -#define M_PATTERN (1<<7) /* pattern mode - only used for history classes */ -#define M_LASTFOLDER (1<<8) /* last-folder mode - hack hack hack */ - -typedef struct { - wchar_t *wbuf; - size_t wbuflen; - size_t lastchar; - size_t curpos; - size_t begin; - int tabs; -} ENTER_STATE; - -#define mutt_new_enter_state() p_new(ENTER_STATE, 1) - -void mutt_free_enter_state (ENTER_STATE **); -int mutt_enter_string (char *, size_t, int, int, int, int, char ***, int *, - ENTER_STATE *); - -#endif /* !_MUTT_ENTER_H */ diff --git a/lib-ui/menu.c b/lib-ui/menu.c index d0b8c54..dc53571 100644 --- a/lib-ui/menu.c +++ b/lib-ui/menu.c @@ -9,7 +9,6 @@ #include -#include "enter.h" #include "menu.h" #include "mutt.h" diff --git a/muttlib.c b/muttlib.c index 1dcd5eb..fbbd6e6 100644 --- a/muttlib.c +++ b/muttlib.c @@ -14,7 +14,6 @@ #include #include -#include #include #include diff --git a/pager.c b/pager.c index 7fad6c6..f6ec60e 100644 --- a/pager.c +++ b/pager.c @@ -14,7 +14,6 @@ #include #include -#include #include #include #include diff --git a/pattern.c b/pattern.c index cd3ba3b..3ba5e62 100644 --- a/pattern.c +++ b/pattern.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include diff --git a/postpone.c b/postpone.c index 44cbdb2..16d3584 100644 --- a/postpone.c +++ b/postpone.c @@ -12,9 +12,8 @@ #include -#include -#include #include +#include #include #include diff --git a/recvattach.c b/recvattach.c index 29fbb9f..f4ab2a3 100644 --- a/recvattach.c +++ b/recvattach.c @@ -14,7 +14,6 @@ #include #include -#include #include #include diff --git a/recvcmd.c b/recvcmd.c index 88cec92..6b8a093 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/send.c b/send.c index 05536b8..55b8854 100644 --- a/send.c +++ b/send.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include "alias.h" diff --git a/sendlib.c b/sendlib.c index 91318ed..33129ed 100644 --- a/sendlib.c +++ b/sendlib.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include -- 2.20.1