From bbf6cdb7927090d0bc2b82b6c416c19921ed8a7e Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Sun, 22 Sep 2002 07:40:56 +0000 Subject: [PATCH] * util.c (is_printable): Disable "Full 8 bits output" on xterm, fall back to "ISO 8859-1" due to problems with gnome-terminal, which identifies itself as xterm. Reported by Miven Dooligan --- src/ChangeLog | 5 +++++ src/util.c | 62 +++++++++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c63d68dff..8be0df911 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2002-09-22 Pavel Roskin + * util.c (is_printable): Disable "Full 8 bits output" on xterm, + fall back to "ISO 8859-1" due to problems with gnome-terminal, + which identifies itself as xterm. + Reported by Miven Dooligan + * mouse.h: Put return codes from the mouse callback to an enum. Remove MOU_ENDLOOP and MOU_LOCK - they are interpreted like MOU_NORMAL. Adjust all dependencies. diff --git a/src/util.c b/src/util.c index c45a41de4..81fc58dad 100644 --- a/src/util.c +++ b/src/util.c @@ -42,6 +42,7 @@ #include "cmd.h" /* guess_message_value */ #include "../vfs/vfs.h" #include "mountlist.h" +#include "win.h" /* xterm_flag */ #ifdef HAVE_CHARSET #include "charsets.h" @@ -52,39 +53,46 @@ static const char app_text [] = "Midnight-Commander"; int easy_patterns = 1; -int is_printable (int c) +static inline int +is_7bit_printable (unsigned char c) { - static const unsigned char xterm_printable[] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0, - 1,1,1,1,0,0,1,1,0,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,1,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 - }; + return (c > 31 && c < 127); +} - extern int xterm_flag; +static inline int +is_iso_printable (unsigned char c) +{ + return ((c > 31 && c < 127) || c >= 160); +} - c &= 0xff; -#ifdef HAVE_CHARSET +static inline int +is_8bit_printable (unsigned char c) +{ + /* "Full 8 bits output" doesn't work on xterm */ if (xterm_flag) - return xterm_printable[c]; - else - return (c > 31 && c != 127 && c != 155); + return is_iso_printable (c); + + return (c > 31 && c != 127 && c != 155); +} + +int +is_printable (int c) +{ + c &= 0xff; + +#ifdef HAVE_CHARSET + /* "Display bits" is ignored, since the user controls the output + by setting the output codepage */ + return is_8bit_printable (c); #else - if (eight_bit_clean){ - if (full_eight_bits){ - if (xterm_flag) - return xterm_printable [c]; - else - return (c > 31 && c != 127 && c != 155); - } else - return ((c >31 && c < 127) || c >= 160); + if (!eight_bit_clean) + return is_7bit_printable (c); + + if (full_eight_bits) { + return is_8bit_printable (c); } else - return (c > 31 && c < 127); -#endif /* !HAVE_CHARSET */ + return is_iso_printable (c); +#endif /* !HAVE_CHARSET */ } /* Returns the message dimensions (lines and columns) */