From 1cacc970e999167a83dfb6417cdc83ce2f6af81e Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Tue, 17 Oct 2000 15:10:51 +0000 Subject: [PATCH] Fix pager and index display when non-printable space characters are encountered. From EGE. --- commands.c | 2 +- curs_lib.c | 38 ++++++++++++++++++++++++++++---------- hdrline.c | 7 ++++--- menu.c | 2 +- protos.h | 3 ++- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/commands.c b/commands.c index 915312ea..3d1af3d8 100644 --- a/commands.c +++ b/commands.c @@ -241,7 +241,7 @@ void ci_bounce_message (HEADER *h, int *redraw) (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf); mutt_format_string (prompt, sizeof (prompt), 0, COLS-extra_space, 0, 0, - prompt, sizeof (prompt)); + prompt, sizeof (prompt), 0); strcat (prompt, "...?"); if (mutt_yesorno (prompt, 1) != 1) { diff --git a/curs_lib.c b/curs_lib.c index 081d64dc..6a9d269c 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -250,7 +250,7 @@ void mutt_curses_error (const char *fmt, ...) dprint (1, (debugfile, "%s\n", Errorbuf)); mutt_format_string (Errorbuf, sizeof (Errorbuf), - 0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf)); + 0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf), 0); if (!option (OPTKEEPQUIET)) { @@ -274,7 +274,7 @@ void mutt_message (const char *fmt, ...) va_end (ap); mutt_format_string (Errorbuf, sizeof (Errorbuf), - 0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf)); + 0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf), 0); if (!option (OPTKEEPQUIET)) { @@ -524,7 +524,8 @@ int mutt_addwch (wchar_t wc) void mutt_format_string (char *dest, size_t destlen, int min_width, int max_width, int right_justify, char pad_char, - const char *s, size_t n) + const char *s, size_t n, + int arboreal) { char *p; wchar_t wc; @@ -544,7 +545,7 @@ void mutt_format_string (char *dest, size_t destlen, k = (k == (size_t)(-1)) ? 1 : n; wc = replacement_char (); } - if (wc < M_TREE_MAX) + if (arboreal && wc < M_TREE_MAX) w = 1; /* hack */ else { @@ -590,10 +591,11 @@ void mutt_format_string (char *dest, size_t destlen, * the number of character cells when printed. */ -void mutt_format_s (char *dest, - size_t destlen, - const char *prefix, - const char *s) +static void mutt_format_s_x (char *dest, + size_t destlen, + const char *prefix, + const char *s, + int arboreal) { int right_justify = 1; char *p; @@ -612,12 +614,28 @@ void mutt_format_s (char *dest, } mutt_format_string (dest, destlen, min_width, max_width, - right_justify, ' ', s, mutt_strlen (s)); + right_justify, ' ', s, mutt_strlen (s), arboreal); +} + +void mutt_format_s (char *dest, + size_t destlen, + const char *prefix, + const char *s) +{ + mutt_format_s_x (dest, destlen, prefix, s, 0); +} + +void mutt_format_s_tree (char *dest, + size_t destlen, + const char *prefix, + const char *s) +{ + mutt_format_s_x (dest, destlen, prefix, s, 1); } /* * mutt_paddstr (n, s) is almost equivalent to - * mutt_format_string (bigbuf, big, n, n, 0, ' ', s, big), addstr (bigbuf) + * mutt_format_string (bigbuf, big, n, n, 0, ' ', s, big, 0), addstr (bigbuf) */ void mutt_paddstr (int n, const char *s) diff --git a/hdrline.c b/hdrline.c index 989e1c9d..7c9c064f 100644 --- a/hdrline.c +++ b/hdrline.c @@ -531,11 +531,12 @@ hdr_format_str (char *dest, { if (flags & M_FORMAT_FORCESUBJ) { - snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, NONULL (hdr->env->subject)); - mutt_format_s (dest, destlen, prefix, buf2); + mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject)); + snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest); + mutt_format_s_tree (dest, destlen, prefix, buf2); } else - mutt_format_s (dest, destlen, prefix, hdr->tree); + mutt_format_s_tree (dest, destlen, prefix, hdr->tree); } else mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject)); diff --git a/menu.c b/menu.c index ee7dfdb4..39e4d729 100644 --- a/menu.c +++ b/menu.c @@ -136,7 +136,7 @@ void menu_pad_string (char *s, size_t l) l = COLS - shift; /* Let's just pad the string anyway ... */ - mutt_format_string (s, INT_MAX, l, l, 0, ' ', s, n); + mutt_format_string (s, INT_MAX, l, l, 0, ' ', s, n, 1); return; #if !defined (HAVE_BKGDSET) && !defined (USE_SLANG_CURSES) diff --git a/protos.h b/protos.h index 1b096e92..11a9f16e 100644 --- a/protos.h +++ b/protos.h @@ -162,8 +162,9 @@ void mutt_expand_fmt (char *, size_t, const char *, const char *); void mutt_expand_link (char *, const char *, const char *); void mutt_fix_reply_recipients (ENVELOPE *env); void mutt_folder_hook (char *); -void mutt_format_string (char *, size_t, int, int, int, char, const char *, size_t); +void mutt_format_string (char *, size_t, int, int, int, char, const char *, size_t, int); void mutt_format_s (char *, size_t, const char *, const char *); +void mutt_format_s_tree (char *, size_t, const char *, const char *); void mutt_forward_intro (FILE *fp, HEADER *cur); void mutt_forward_trailer (FILE *fp); void mutt_free_alias (ALIAS **); -- 2.40.0