X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=curs_lib.c;h=6e55a2b2e7ab8c437a52dc6c7cba78df249d5856;hp=a764b6ab17e13706af4a44c20ebc49e320de10bd;hb=1bdbccb7f3e83735873bd0f66cd9f66d5d008342;hpb=f353d90d89bbdaa8ff3f3c619384948ec8fe9c14 diff --git a/curs_lib.c b/curs_lib.c index a764b6a..6e55a2b 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -1,5 +1,6 @@ /* * Copyright (C) 1996-2002 Michael R. Elkins + * Copyright (C) 2004 g10 Code GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,6 +17,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include "mutt.h" #include "mutt_menu.h" #include "mutt_curses.h" @@ -57,6 +62,20 @@ void mutt_refresh (void) refresh (); } +/* Make sure that the next refresh does a full refresh. This could be + optmized by not doing it at all if DISPLAY is set as this might + indicate that a GUI based pinentry was used. Having an option to + customize this is of course the Mutt way. */ +void mutt_need_hard_redraw (void) +{ + if (!getenv ("DISPLAY")) + { + keypad (stdscr, TRUE); + clearok (stdscr, TRUE); + set_option (OPTNEEDREDRAW); + } +} + event_t mutt_getch (void) { int ch; @@ -119,29 +138,6 @@ int _mutt_get_field (/* const */ char *field, char *buf, size_t buflen, int comp return (ret); } -int _mutt_get_field_att (/* const */ char *field, char *buf, size_t buflen, int complete, int multiple, char ***files, int *numfiles) -{ - int ret; - int x, y; - - ENTER_STATE *es = mutt_new_enter_state(); - - do - { - CLEARLINE (LINES-1); - addstr (field); - mutt_refresh (); - getyx (stdscr, y, x); - ret = _mutt_enter_string_att (buf, buflen, y, x, complete, multiple, files, numfiles, es); - } - while (ret == 1); - CLEARLINE (LINES-1); - mutt_free_enter_state (&es); - - return (ret); -} - - int mutt_get_password (char *msg, char *buf, size_t buflen) { int rc; @@ -162,6 +158,19 @@ void mutt_clear_error (void) CLEARLINE (LINES-1); } +static void fix_end_of_file (const char *data) +{ + FILE *fp; + int c; + + if ((fp = safe_fopen (data, "a+")) == NULL) + return; + fseek (fp,-1,SEEK_END); + if ((c = fgetc(fp)) != '\n') + fputc ('\n', fp); + safe_fclose (&fp); +} + void mutt_edit_file (const char *editor, const char *data) { char cmd[LONG_STRING]; @@ -170,6 +179,7 @@ void mutt_edit_file (const char *editor, const char *data) mutt_expand_file_fmt (cmd, sizeof (cmd), editor, data); if (mutt_system (cmd) == -1) mutt_error (_("Error running \"%s\"!"), cmd); + fix_end_of_file (data); keypad (stdscr, TRUE); clearok (stdscr, TRUE); } @@ -286,6 +296,7 @@ void mutt_query_exit (void) void mutt_curses_error (const char *fmt, ...) { + char TmpErrorbuf[STRING]; va_list ap; va_start (ap, fmt); @@ -293,8 +304,9 @@ void mutt_curses_error (const char *fmt, ...) va_end (ap); dprint (1, (debugfile, "%s\n", Errorbuf)); - mutt_format_string (Errorbuf, sizeof (Errorbuf), + mutt_format_string (TmpErrorbuf, sizeof (TmpErrorbuf), 0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf), 0); + snprintf(Errorbuf,sizeof(Errorbuf),"%s",TmpErrorbuf); /* overkill */ if (!option (OPTKEEPQUIET)) { @@ -311,14 +323,16 @@ void mutt_curses_error (const char *fmt, ...) void mutt_curses_message (const char *fmt, ...) { + char TmpErrorbuf[STRING]; va_list ap; va_start (ap, fmt); vsnprintf (Errorbuf, sizeof (Errorbuf), fmt, ap); va_end (ap); - mutt_format_string (Errorbuf, sizeof (Errorbuf), + mutt_format_string (TmpErrorbuf, sizeof (TmpErrorbuf), 0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf), 0); + snprintf(Errorbuf,sizeof(Errorbuf),"%s",TmpErrorbuf); /* overkill */ if (!option (OPTKEEPQUIET)) {