if test "$gt_cv_func_gettext_libc" != "yes"; then
AC_CHECK_LIB(intl, bindtextdomain,
- [AC_CACHE_CHECK([for gettext in libintl],
- gt_cv_func_gettext_libintl,
- [AC_CHECK_LIB(intl, gettext,
- gt_cv_func_gettext_libintl=yes,
- gt_cv_func_gettext_libintl=no)],
+ [AC_CHECK_LIB(intl, gettext,
+ gt_cv_func_gettext_libintl=yes,
gt_cv_func_gettext_libintl=no)])
fi
int t = -1;
int i, done = 0;
char helpstr[SHORT_STRING];
+ int savedmenu = CurrentMenu;
if (!aliases)
{
menu->make_entry = alias_entry;
menu->search = alias_search;
menu->tag = alias_tag;
- menu->menu = MENU_ALIAS;
+ menu->menu = CurrentMenu = MENU_ALIAS;
menu->title = _("Aliases");
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_ALIAS, AliasHelp);
rfc822_write_address (buf, buflen, AliasTable[t]->addr);
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
safe_free ((void **) &AliasTable);
}
MUTTMENU *menu;
struct stat st;
int i, killPrefix = 0;
+ int savedmenu = CurrentMenu;
memset (&state, 0, sizeof (struct browser_state));
return;
menu = mutt_new_menu ();
- menu->menu = MENU_FOLDER;
+ menu->menu = CurrentMenu = MENU_FOLDER;
menu->make_entry = folder_entry;
menu->search = select_file_search;
menu->title = title;
destroy_state (&state);
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
return;
case OP_BROWSER_TELL:
mutt_error _("Error scanning directory.");
destroy_state (&state);
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
return;
}
}
{
mutt_error _("Error scanning directory.");
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
return;
}
killPrefix = 0;
{
int reverse = 0;
+ event_t ch;
move (LINES - 1, 0);
if (i == OP_SORT_REVERSE)
}
clrtoeol ();
- while ((i = mutt_getch ()) != EOF && i != 'a' && i != 'd' && i != 'z'
- && i != 'n')
+ FOREVER
{
- if (i == ERR || CI_is_return (i))
+ ch = mutt_getch();
+ if (ch.ch == EOF || ch.ch == 'a' || ch.ch == 'd' || ch.ch == 'z' || ch.ch == 'n')
+ break;
+
+ if (ch.ch == ERR || CI_is_return (ch.ch))
break;
else
BEEP ();
}
- if (i != EOF)
+ if (ch.ch != EOF)
{
- switch (i)
+ switch (ch.ch)
{
case 'a':
BrowserSort = reverse | SORT_SUBJECT;
strfcpy (f, buf, flen);
destroy_state (&state);
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
return;
}
MAYBE_REDRAW (menu->redraw);
mutt_set_flag (Context, cur, M_READ, 1);
if (option (OPTPROMPTAFTER))
{
- mutt_ungetch (mutt_any_key_to_continue _("Command: "));
+ mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
rc = km_dokey (MENU_PAGER);
}
else
int mutt_select_sort (int reverse)
{
int method = Sort; /* save the current method in case of abort */
- int ch;
+ event_t ch;
Sort = 0;
while (!Sort)
_("Rev-Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore?: ") :
_("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore?: "));
ch = mutt_getch ();
- if (ch == ERR || CI_is_return (ch))
+ if (ch.ch == -1 || CI_is_return (ch.ch))
{
Sort = method;
CLEARLINE (LINES-1);
return (-1);
}
- switch (ch)
+ switch (ch.ch)
{
case 'c':
Sort = SORT_SCORE;
/* Sort, SortAux could be changed in mutt_index_menu() */
int oldSort = Sort, oldSortAux = SortAux;
struct stat st;
+ int savedmenu = CurrentMenu;
idx = mutt_gen_attach_list (msg->content, idx, &idxlen, &idxmax, 0, 1);
menu = mutt_new_menu ();
- menu->menu = MENU_COMPOSE;
+ menu->menu = CurrentMenu = MENU_COMPOSE;
menu->offset = HDR_ATTACH;
menu->max = idxlen;
menu->make_entry = snd_entry;
}
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
if (idxlen)
{
-ALL_LINGUAS="de"
+ALL_LINGUAS="de ru"
# Make sure we can run config.sub.
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
- echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6
-echo "configure:4329: checking for gettext in libintl" >&5
-if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
echo $ac_n "checking for gettext in -lintl""... $ac_c" 1>&6
-echo "configure:4334: checking for gettext in -lintl" >&5
+echo "configure:4329: checking for gettext in -lintl" >&5
ac_lib_var=`echo intl'_'gettext | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lintl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4342 "configure"
+#line 4337 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
gettext()
; return 0; }
EOF
-if { (eval echo configure:4353: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
gt_cv_func_gettext_libintl=no
fi
-fi
-
-echo "$ac_t""$gt_cv_func_gettext_libintl" 1>&6
else
echo "$ac_t""no" 1>&6
fi
# Extract the first word of "msgfmt", so it can be a program name with args.
set dummy msgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4392: checking for $ac_word" >&5
+echo "configure:4384: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
for ac_func in dcgettext
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4426: checking for $ac_func" >&5
+echo "configure:4418: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4431 "configure"
+#line 4423 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:4454: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4446: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
# Extract the first word of "gmsgfmt", so it can be a program name with args.
set dummy gmsgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4481: checking for $ac_word" >&5
+echo "configure:4473: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "xgettext", so it can be a program name with args.
set dummy xgettext; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4513: checking for $ac_word" >&5
+echo "configure:4505: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fi
cat > conftest.$ac_ext <<EOF
-#line 4545 "configure"
+#line 4537 "configure"
#include "confdefs.h"
int main() {
return _nl_msg_cat_cntr
; return 0; }
EOF
-if { (eval echo configure:4553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
CATOBJEXT=.gmo
DATADIRNAME=share
if test "$CATOBJEXT" = "NONE"; then
echo $ac_n "checking whether catgets can be used""... $ac_c" 1>&6
-echo "configure:4576: checking whether catgets can be used" >&5
+echo "configure:4568: checking whether catgets can be used" >&5
# Check whether --with-catgets or --without-catgets was given.
if test "${with_catgets+set}" = set; then
withval="$with_catgets"
if test "$nls_cv_use_catgets" = "yes"; then
echo $ac_n "checking for main in -li""... $ac_c" 1>&6
-echo "configure:4589: checking for main in -li" >&5
+echo "configure:4581: checking for main in -li" >&5
ac_lib_var=`echo i'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-li $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4597 "configure"
+#line 4589 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:4604: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
fi
echo $ac_n "checking for catgets""... $ac_c" 1>&6
-echo "configure:4632: checking for catgets" >&5
+echo "configure:4624: checking for catgets" >&5
if eval "test \"`echo '$''{'ac_cv_func_catgets'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4637 "configure"
+#line 4629 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char catgets(); below. */
; return 0; }
EOF
-if { (eval echo configure:4660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_catgets=yes"
else
# Extract the first word of "gencat", so it can be a program name with args.
set dummy gencat; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4682: checking for $ac_word" >&5
+echo "configure:4674: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GENCAT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "gmsgfmt", so it can be a program name with args.
set dummy gmsgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4714: checking for $ac_word" >&5
+echo "configure:4706: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "msgfmt", so it can be a program name with args.
set dummy msgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4747: checking for $ac_word" >&5
+echo "configure:4739: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "xgettext", so it can be a program name with args.
set dummy xgettext; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4782: checking for $ac_word" >&5
+echo "configure:4774: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "msgfmt", so it can be a program name with args.
set dummy msgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4840: checking for $ac_word" >&5
+echo "configure:4832: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "gmsgfmt", so it can be a program name with args.
set dummy gmsgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4874: checking for $ac_word" >&5
+echo "configure:4866: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "xgettext", so it can be a program name with args.
set dummy xgettext; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4906: checking for $ac_word" >&5
+echo "configure:4898: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
LINGUAS=
else
echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6
-echo "configure:4999: checking for catalogs to be installed" >&5
+echo "configure:4991: checking for catalogs to be installed" >&5
NEW_LINGUAS=
for lang in ${LINGUAS=$ALL_LINGUAS}; do
case "$ALL_LINGUAS" in
if test "$CATOBJEXT" = ".cat"; then
ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6
-echo "configure:5027: checking for linux/version.h" >&5
+echo "configure:5019: checking for linux/version.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5032 "configure"
+#line 5024 "configure"
#include "confdefs.h"
#include <linux/version.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5037: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5029: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(mutt, 0.94.10)
-ALL_LINGUAS="de"
+ALL_LINGUAS="de ru"
AC_CANONICAL_HOST
* buffering routines.
*/
static short UngetCount = 0;
-
#define UngetBufLen 128
-static int UngetBuf[UngetBufLen];
+static event_t KeyEvent[UngetBufLen] = { {0,0} };
void mutt_refresh (void)
{
refresh ();
}
-int mutt_getch (void)
+event_t mutt_getch (void)
{
int ch;
+ event_t err = {-1,0}, ret;
if (UngetCount)
- return (UngetBuf[--UngetCount]);
+ return (KeyEvent[--UngetCount]);
Signals &= ~S_INTERRUPT;
mutt_query_exit ();
if(ch == -1)
- return ch;
+ return err;
if ((ch & 0x80) && option (OPTMETAKEY))
{
/* send ALT-x as ESC-x */
ch &= ~0x80;
- mutt_ungetch (ch);
- return ('\033');
+ mutt_ungetch (ch, 0);
+ ret.ch = '\033';
+ ret.op = 0;
+ return ret;
}
- return (ch == ctrl ('G') ? ERR : ch);
+ ret.ch = ch;
+ ret.op = 0;
+ return (ch == ctrl ('G') ? err : ret);
}
int mutt_get_field (/* const */ char *field, char *buf, size_t buflen, int complete)
int mutt_yesorno (const char *msg, int def)
{
- int ch;
+ event_t ch;
const char *yes = _("yes");
const char *no = _("no");
{
mutt_refresh ();
ch = mutt_getch ();
- if (ch == ERR) return(-1);
- if (CI_is_return (ch))
+ if (ch.ch == ERR) return(-1);
+ if (CI_is_return (ch.ch))
break;
- else if (tolower(ch) == tolower(*yes))
+ else if (tolower(ch.ch) == tolower(*yes))
{
def = 1;
break;
}
- else if (tolower(ch) == tolower(*no))
+ else if (tolower(ch.ch) == tolower(*no))
{
def = 0;
break;
int mutt_enter_fname (const char *prompt, char *buf, size_t blen, int *redraw, int buffy)
{
- int i;
+ event_t ch;
mvaddstr (LINES-1, 0, (char *) prompt);
addstr (_(" ('?' for list): "));
clrtoeol ();
mutt_refresh ();
- if ((i = mutt_getch ()) == ERR)
+ ch = mutt_getch();
+ if (ch.ch == -1)
{
CLEARLINE (LINES-1);
return (-1);
}
- else if (i == '?')
+ else if (ch.ch == '?')
{
mutt_refresh ();
buf[0] = 0;
char *pc = safe_malloc (strlen (prompt) + 3);
sprintf (pc, "%s: ", prompt);
- mutt_ungetch (i);
+ mutt_ungetch (ch.ch, 0);
if (mutt_get_field (pc, buf, blen, (buffy ? M_EFILE : M_FILE) | M_CLEAR)
!= 0)
buf[0] = 0;
/* FOO - this could be made more efficient by allocating/deallocating memory
* instead of using a fixed array
*/
-void mutt_ungetch (int ch)
+void mutt_ungetch (int ch, int op)
{
+ event_t tmp;
+
+ tmp.ch = ch;
+ tmp.op = op;
+
if (UngetCount < UngetBufLen) /* make sure not to overflow */
- UngetBuf[UngetCount++] = ch;
+ KeyEvent[UngetCount++] = tmp;
}
void mutt_flushinp (void)
int mutt_index_menu (void)
{
char buf[LONG_STRING], helpstr[SHORT_STRING];
- int op = OP_NULL; /* function to execute */
+ int op = OP_NULL;
+ event_t event = {OP_NULL, 0};
int done = 0; /* controls when to exit the "event" loop */
int i = 0, j;
int tag = 0; /* has the tag-prefix command been pressed? */
int do_buffy_notify = 1;
int close = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
int attach_msg = option(OPTATTACHMSG);
+ int savedmenu = CurrentMenu;
menu = mutt_new_menu ();
- menu->menu = MENU_MAIN;
+ menu->menu = CurrentMenu = MENU_MAIN;
menu->offset = 1;
menu->pagelen = LINES - 3;
menu->make_entry = index_make_entry;
if (Timeout > 0)
{
timeout (Timeout * 1000); /* milliseconds */
- op = mutt_getch ();
+ event = mutt_getch ();
timeout (-1); /* restore blocking operation */
- if (op != -1)
+ if (event.ch != -1)
{
- mutt_ungetch (op);
+ mutt_ungetch (event.ch, event.op);
op = km_dokey (MENU_MAIN);
}
}
else
op = km_dokey (MENU_MAIN);
- mutt_curs_set (1);
+ mutt_curs_set (1);
+
#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
if (Signals & S_SIGWINCH)
{
mutt_flushinp ();
mutt_resize_screen ();
menu->redraw = REDRAW_FULL;
- menu->menu = MENU_MAIN;
+ menu->menu = CurrentMenu = MENU_MAIN;
Signals &= ~S_SIGWINCH;
menu->top = 0; /* so we scroll the right amount */
continue;
case OP_JUMP:
CHECK_MSGCOUNT;
- mutt_ungetch (LastKey);
+ mutt_ungetch (LastKey, 0);
buf[0] = 0;
if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
|| !buf[0])
menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
}
- menu->menu = MENU_PAGER;
+ menu->menu = CurrentMenu = MENU_PAGER;
menu->oldcurrent = menu->current;
continue;
case OP_ENTER_COMMAND:
+ CurrentMenu = MENU_MAIN;
mutt_enter_command ();
mutt_check_rescore (Context);
if (option (OPTNEEDRESORT) && Context && Context->msgcount)
if (menu->menu == MENU_PAGER)
{
- menu->menu = MENU_MAIN;
+ menu->menu = CurrentMenu = MENU_MAIN;
menu->redraw = REDRAW_FULL;
set_option (OPTWEED); /* turn header weeding back on. */
}
}
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
return (close);
}
int mutt_enter_string (unsigned char *buf, size_t buflen, int y, int x,
int flags)
{
+ event_t event;
int curpos = 0; /* the location of the cursor */
int lastchar = 0; /* offset of the last char in the string */
int begin = 0; /* first character displayed on the line */
return (-1);
}
- if (ch != 0)
+ if (ch != OP_NULL)
{
first = 0; /* make sure not to clear the buffer */
if (ch != OP_EDITOR_COMPLETE)
case OP_EDITOR_QUOTE_CHAR:
ADDCH (LastKey);
- LastKey = mutt_getch ();
+ event = mutt_getch ();
+ LastKey = event.ch;
move (y, x + curpos - begin);
goto self_insert;
first = 0;
if (IsPrint (ch))
{
- mutt_ungetch (ch);
+ mutt_ungetch (ch, 0);
buf[0] = 0;
redraw = M_REDRAW_INIT;
continue;
int mutt_change_flag (HEADER *h, int bf)
{
int i, flag;
+ event_t event;
- mvprintw (LINES - 1, 0, "? (D/N/O/r/*/!): ", bf ? _("Set %s flag") :
- _("Clear %s flag"));
+ mvprintw (LINES - 1, 0, "%s flag? (D/N/O/r/*/!): ", bf ? _("Set") : _("Clear"));
clrtoeol ();
- if ((i = mutt_getch ()) == ERR)
+ event = mutt_getch();
+ i = event.ch;
+ if (i == -1)
{
CLEARLINE (LINES-1);
return (-1);
/* vector to store received signals */
WHERE short Signals INITVAL (0);
+WHERE int CurrentMenu;
+
WHERE ALIAS *Aliases INITVAL (0);
WHERE LIST *UserHeader INITVAL (0);
#include "mutt_curses.h"
#include "mutt_regex.h"
#include "history.h"
+#include "keymap.h"
#ifdef _PGPPATH
strncpy (pt, Completed, buffer + len - pt - spaces);
}
+ else if (!strncmp (buffer, "exec", 4))
+ {
+ struct binding_t *menu = km_get_table (CurrentMenu);
+
+ if (!menu && CurrentMenu != MENU_PAGER)
+ menu = OpGeneric;
+
+ pt++;
+ /* first TAB. Collect all the matches */
+ if (numtabs == 1)
+ {
+ Num_matched = 0;
+ strfcpy (User_typed, pt, sizeof (User_typed));
+ memset (Matches, 0, sizeof (Matches));
+ memset (Completed, 0, sizeof (Completed));
+ for (num = 0; menu[num].name; num++)
+ candidate (Completed, User_typed, menu[num].name, sizeof (Completed));
+ /* try the generic menu */
+ if (Completed[0] == 0 && CurrentMenu != MENU_PAGER)
+ {
+ menu = OpGeneric;
+ for (num = 0; menu[num].name; num++)
+ candidate (Completed, User_typed, menu[num].name, sizeof (Completed));
+ }
+ Matches[Num_matched++] = User_typed;
+
+ /* All matches are stored. Longest non-ambiguous string is ""
+ * i.e. dont change 'buffer'. Fake successful return this time */
+ if (User_typed[0] == 0)
+ return 1;
+ }
+
+ if (Completed[0] == 0 && User_typed[0])
+ return 0;
+
+ /* Num_matched will _always_ be atleast 1 since the initial
+ * user-typed string is always stored */
+ if (numtabs == 1 && Num_matched == 2)
+ snprintf(Completed, sizeof(Completed),"%s", Matches[0]);
+ else if (numtabs > 1 && Num_matched > 2)
+ /* cycle thru all the matches */
+ snprintf(Completed, sizeof(Completed), "%s",
+ Matches[(numtabs - 2) % Num_matched]);
+
+ strncpy (pt, Completed, buffer + len - pt - spaces);
+ }
else
return 0;
for (i = 0; MuttVars[i].option; i++)
mutt_restore_default (&MuttVars[i]);
+ CurrentMenu = MENU_MAIN;
+
#ifndef LOCALES_HACK
/* Do we have a locale definition? */
if (((p = getenv ("LC_ALL")) != NULL && p[0]) ||
{ "color", mutt_parse_color, 0 },
{ "uncolor", mutt_parse_uncolor, 0 },
#endif
+ { "exec", mutt_parse_exec, 0 },
{ "fcc-hook", mutt_parse_hook, M_FCCHOOK },
{ "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
{ "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
km_bind (s, menu, op, NULL, NULL);
}
+static int get_op (struct binding_t *bindings, const char *start, size_t len)
+{
+ int i;
+
+ for (i = 0; bindings[i].name; i++)
+ {
+ if (!strncasecmp (start, bindings[i].name, len))
+ return bindings[i].op;
+ }
+
+ return OP_NULL;
+}
+
+static char *get_func (struct binding_t *bindings, int op)
+{
+ int i;
+
+ for (i = 0; bindings[i].name; i++)
+ {
+ if (bindings[i].op == op)
+ return bindings[i].name;
+ }
+
+ return NULL;
+}
+
static void push_string (char *s)
{
char *pp, *p = s + strlen (s) - 1;
size_t l;
- int i;
+ int i, op = OP_NULL;
while (p >= s)
{
if (KeyNames[i].name)
{
/* found a match */
- mutt_ungetch (KeyNames[i].value);
+ mutt_ungetch (KeyNames[i].value, 0);
+ p = pp - 1;
+ continue;
+ }
+
+ /* See if it is a valid command
+ * skip the '<' and the '>' when comparing */
+ for (i = 0; Menus[i].name; i++)
+ {
+ struct binding_t *binding = km_get_table (Menus[i].value);
+ if (binding)
+ {
+ op = get_op (binding, pp + 1, l - 2);
+ if (op != OP_NULL)
+ break;
+ }
+ }
+
+ if (op != OP_NULL)
+ {
+ mutt_ungetch (0, op);
p = pp - 1;
continue;
}
}
}
- mutt_ungetch (*p--);
+ mutt_ungetch (*p--, 0);
}
}
if (menu != MENU_EDITOR && menu != MENU_GENERIC && menu != MENU_PAGER)
{
if (lastkey)
- mutt_ungetch (lastkey);
+ mutt_ungetch (lastkey, 0);
for (; keyslen; keyslen--)
- mutt_ungetch (keys[keyslen - 1]);
+ mutt_ungetch (keys[keyslen - 1], 0);
return (km_dokey (MENU_GENERIC));
}
if (menu != MENU_EDITOR)
*/
int km_dokey (int menu)
{
+ event_t tmp;
struct keymap_t *map = Keymaps[menu];
int pos = 0;
int n = 0;
+ int i;
if (!map)
return (retry_generic (menu, NULL, 0, 0));
FOREVER
{
- if ((LastKey = mutt_getch ()) == ERR)
- return (-1);
+ tmp = mutt_getch();
+ LastKey = tmp.ch;
+ if (LastKey == -1)
+ return -1;
+ /* do we have an op already? */
+ if (tmp.op)
+ {
+ char *func = NULL;
+ struct binding_t *bindings;
+
+ /* is this a valid op for the current menu? */
+ bindings = km_get_table (CurrentMenu);
+ if ((func = get_func (bindings, tmp.op)))
+ return tmp.op;
+ if (CurrentMenu != MENU_PAGER)
+ {
+ /* check generic menu */
+ bindings = OpGeneric;
+ if ((func = get_func (bindings, tmp.op)))
+ return tmp.op;
+ }
+
+ /* Sigh. Valid function but not in this context.
+ * Find the literal string and push it back */
+ for (i = 0; Menus[i].name; i++)
+ {
+ bindings = km_get_table (Menus[i].value);
+ if (bindings)
+ {
+ func = get_func (bindings, tmp.op);
+ if (func)
+ {
+ /* careful not to feed the <..> as one token. otherwise
+ * push_string() will push the bogus op right back! */
+ mutt_ungetch ('>', 0);
+ push_string (func);
+ mutt_ungetch ('<', 0);
+ break;
+ }
+ }
+ }
+ /* continue to chew */
+ if (func)
+ continue;
+ }
+
+ /* Nope. Business as usual */
while (LastKey > map->keys[pos])
{
if (pos > map->eq || !map->next)
if (++pos == map->len)
{
+
if (map->op != OP_MACRO)
- return (map->op);
+ return map->op;
if (n++ == 10)
{
mutt_flushinp ();
mutt_error _("Macro loop detected.");
- return (-1);
+ return -1;
}
push_string (map->macro);
FREE (&key);
return (r);
}
+
+/* exec command-name */
+int mutt_parse_exec (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+{
+ int op = OP_NULL;
+ char *command = NULL;
+ struct binding_t *bindings = NULL;
+
+ if (!MoreArgs (s))
+ {
+ strfcpy (err->data, _("exec: too few arguments"), err->dsize);
+ return (-1);
+ }
+
+ mutt_extract_token (buf, s, 0);
+ command = safe_strdup (buf->data);
+
+ if (MoreArgs (s))
+ {
+ strfcpy (err->data, _("too many arguments"), err->dsize);
+ return (-1);
+ }
+
+ if ((bindings = km_get_table (CurrentMenu)) == NULL)
+ bindings = OpGeneric;
+
+ op = get_op (bindings, command, strlen(command));
+ if (op == OP_NULL)
+ op = get_op (OpGeneric, command, strlen(command));
+
+ if (op == OP_NULL)
+ {
+ mutt_flushinp ();
+ mutt_error (_("%s: no such command"), command);
+ FREE (&command);
+ return (-1);
+ }
+
+ mutt_ungetch (0, op);
+ FREE (&command);
+ return 0;
+}
if (menu->max)
{
- mutt_ungetch (LastKey);
+ mutt_ungetch (LastKey, 0);
buf[0] = 0;
if (mutt_get_field (_("Jump to: "), buf, sizeof (buf), 0) == 0 && buf[0])
{
break;
case OP_ENTER_COMMAND:
+ CurrentMenu = menu->menu;
mutt_enter_command ();
if (option (OPTFORCEREDRAWINDEX))
{
int destroy; /* destroy `data' when done? */
} BUFFER;
+typedef struct
+{
+ int ch; /* raw key pressed */
+ int op; /* function op */
+} event_t;
+
/* flags for _mutt_system() */
#define M_DETACH_PROCESS 1 /* detach subprocess from group */
#define CI_is_return(c) ((c) == '\r' || (c) == '\n' || (c) == KEY_ENTER)
-int mutt_getch (void);
+event_t mutt_getch (void);
void mutt_endwin (const char *);
void mutt_flushinp (void);
void mutt_refresh (void);
void mutt_resize_screen (void);
-void mutt_ungetch (int);
+void mutt_ungetch (int, int);
/* ----------------------------------------------------------------------------
* Support for color
old_markers = option (OPTMARKERS);
old_PagerIndexLines = PagerIndexLines;
+ CurrentMenu = MENU_PAGER;
mutt_enter_command ();
if (option (OPTNEEDRESORT))
FILE *fp, *devnull;
pid_t thepid;
KEYINFO *info;
+ int savedmenu = CurrentMenu;
for (i = 0, l = keys; l; l = l->next)
menu->max = keymax;
menu->make_entry = pgp_entry;
menu->search = pgp_search;
- menu->menu = MENU_PGP;
+ menu->menu = CurrentMenu = MENU_PGP;
menu->help = helpstr;
menu->data = KeyTable;
}
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
safe_free ((void **) &KeyTable);
return (info);
MUTTMENU *menu;
int i, done=0, r=-1;
char helpstr[SHORT_STRING];
+ int savedmenu = CurrentMenu;
menu = mutt_new_menu ();
menu->make_entry = post_entry;
- menu->menu = MENU_POST;
+ menu->menu = CurrentMenu = MENU_POST;
menu->max = PostContext->msgcount;
menu->title = _("Postponed Messages");
menu->data = PostContext;
}
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
return (r > -1 ? PostContext->hdrs[r] : NULL);
}
int mutt_needs_mailcap (BODY *);
int mutt_num_postponed (void);
int mutt_parse_bind (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+int mutt_parse_exec (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_parse_color (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_parse_uncolor (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_parse_hook (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int op;
char helpstr[SHORT_STRING];
char title[STRING];
+ int savedmenu = CurrentMenu;
+
snprintf (title, sizeof (title), _("Query")); /* FIXME */
menu = mutt_new_menu ();
menu->make_entry = query_entry;
menu->search = query_search;
menu->tag = query_tag;
- menu->menu = MENU_QUERY;
+ menu->menu = CurrentMenu = MENU_QUERY;
menu->title = title;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp);
}
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
}
short idxmax = 0;
int flags = 0;
int op;
+ int savedmenu = CurrentMenu;
/* make sure we have parsed this message */
mutt_parse_mime_message (Context, hdr);
menu->max = idxlen;
menu->make_entry = attach_entry;
menu->tag = mutt_tag_attach;
- menu->menu = MENU_ATTACH;
+ menu->menu = CurrentMenu = MENU_ATTACH;
menu->title = _("Attachments");
menu->data = idx;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
mutt_menuDestroy (&menu);
+ CurrentMenu = savedmenu;
return;
}
}