Ticket #2977: mc.qview1.diff

File mc.qview1.diff, 20.6 KB (added by szaszg, 11 years ago)

this patch fixup ticket#2976 too'

  • lib/util.c

    diff --git a/lib/util.c b/lib/util.c
    index 4c4aeb0..e6cfa56 100644
    a b get_compression_type (int fd, const char *name) 
    846846        } 
    847847    } 
    848848 
     849    /* JPEG files GIF8 */ 
     850    if (((magic[0] == 'G') && (magic[1] == 'I') && (magic[2] == 'F') && (magic[3] == '8')) || /* GIF */ 
     851        ((magic[0] == 0x89) && (magic[1] == 'P') && (magic[2] == 'N') && (magic[3] == 'G')) || /* PNG */ 
     852        ((magic[0] == 0xff) && (magic[1] == 0xd8) && (magic[2] == 0xff) && ((magic[3]&0xfe) == 0xe0)) /* JFIF or EXIF ff d8 ff e{0,1} */ 
     853    ) 
     854    { 
     855        return COMPRESSION_IMG; 
     856    } 
     857 
    849858    /* Support for LZMA (only utils format with magic in header). 
    850859     * This is the default format of LZMA utils 4.32.1 and later. */ 
    851860 
    decompress_extension (int type) 
    890899        return "/ulzma" VFS_PATH_URL_DELIMITER; 
    891900    case COMPRESSION_XZ: 
    892901        return "/uxz" VFS_PATH_URL_DELIMITER; 
     902    case COMPRESSION_IMG: 
     903        return "/img" VFS_PATH_URL_DELIMITER; 
    893904    } 
    894905    /* Should never reach this place */ 
    895906    fprintf (stderr, "Fatal: decompress_extension called with an unknown argument\n"); 
  • lib/util.h

    diff --git a/lib/util.h b/lib/util.h
    index f0c0ee2..d4a3c0f 100644
    a b enum compression_type 
    4444    COMPRESSION_BZIP, 
    4545    COMPRESSION_BZIP2, 
    4646    COMPRESSION_LZMA, 
    47     COMPRESSION_XZ 
     47    COMPRESSION_XZ, 
     48 
     49    COMPRESSION_IMG, 
    4850}; 
    4951 
    5052/*** structures declarations (and typedefs of structures)*****************************************/ 
  • misc/ext.d/image.sh

    diff --git a/misc/ext.d/image.sh b/misc/ext.d/image.sh
    index 61e3bc2..747b6b4 100644
    a b  
    66action=$1 
    77filetype=$2 
    88 
     9IMG2TXT=img2txt 
     10command -v img2txt -h 1>/dev/null 2>&1 || IMG2TXT='echo -n ""' 
    911[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open" 
    1012 
    1113do_view_action() { 
    do_view_action() { 
    1315 
    1416    case "${filetype}" in 
    1517    jpeg) 
    16         identify "${MC_EXT_FILENAME}"; test -x /usr/bin/exif && echo && exif "${MC_EXT_FILENAME}" 2>/dev/null 
     18        identify "${MC_EXT_FILENAME}" 
     19        $IMG2TXT "${MC_EXT_FILENAME}"; test -x /usr/bin/exif && echo "[9999m" && exif "${MC_EXT_FILENAME}" 2>/dev/null 
    1720        ;; 
    1821    xpm) 
    1922        sxpm "${MC_EXT_FILENAME}" 
    2023        ;; 
    2124    *) 
    2225        identify "${MC_EXT_FILENAME}" 
     26        $IMG2TXT "${MC_EXT_FILENAME}" 
    2327        ;; 
    2428    esac 
    2529} 
  • src/vfs/extfs/helpers/sfs.ini

    diff --git a/src/vfs/extfs/helpers/sfs.ini b/src/vfs/extfs/helpers/sfs.ini
    index 522cca1..cc564c6 100644
    a b cr/1 fromdos < %1 > %3 
    2626url:2   lynx -source `echo "%2" | sed 's-|-/-g'` > %3 
    2727nop/1   cat %1 > %3 
    2828strings/1       strings %1 > %3 
     29 
     30img/1   img2txt > %3 %1 
  • src/viewer/Makefile.am

    diff --git a/src/viewer/Makefile.am b/src/viewer/Makefile.am
    index 53bc7a4..d92d1f4 100644
    a b libmcviewer_la_SOURCES = \ 
    1717        move.c \ 
    1818        nroff.c \ 
    1919        plain.c \ 
     20        ansi.c \ 
    2021        search.c 
    2122 
    2223AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CPPFLAGS) 
  • new file src/viewer/ansi.c

    diff --git a/src/viewer/ansi.c b/src/viewer/ansi.c
    new file mode 100644
    index 0000000..e30b504
    - +  
     1/* 
     2   Internal file viewer for the Midnight Commander 
     3   Function for raw (ansi) view 
     4 
     5   Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 
     6   2004, 2005, 2006, 2007, 2009, 2011 
     7   The Free Software Foundation, Inc. 
     8 
     9   Written by: 
     10   Gergely Szasz 2013 
     11 
     12   This file is part of the Midnight Commander. 
     13 
     14   The Midnight Commander is free software: you can redistribute it 
     15   and/or modify it under the terms of the GNU General Public License as 
     16   published by the Free Software Foundation, either version 3 of the License, 
     17   or (at your option) any later version. 
     18 
     19   The Midnight Commander is distributed in the hope that it will be useful, 
     20   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     21   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     22   GNU General Public License for more details. 
     23 
     24   You should have received a copy of the GNU General Public License 
     25   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     26 */ 
     27 
     28#include <config.h> 
     29 
     30#include "lib/global.h" 
     31#include "lib/tty/tty.h" 
     32#include "lib/skin.h" 
     33#include "lib/util.h"           /* is_printable() */ 
     34#ifdef HAVE_CHARSET 
     35#include "lib/charsets.h" 
     36#endif 
     37 
     38#include "src/setup.h"          /* option_tab_spacing */ 
     39 
     40#include "internal.h" 
     41#include "mcviewer.h"           /* mcview_show_eof */ 
     42 
     43/*** global variables ****************************************************************************/ 
     44 
     45/*** file scope macro definitions ****************************************************************/ 
     46/* we play maximum 1M files */ 
     47#define MAX_ANSI_SIZE (1024*1024) 
     48 
     49/*** file scope type declarations ****************************************************************/ 
     50 
     51/*** file scope variables ************************************************************************/ 
     52static const char *color_names[] = { 
     53    "black", "red", "green", "brown", "blue", "magenta", "cyan", "lightgray", 
     54    "gray", "brightred", "brightgreen", "yellow", "brightblue", "brightmagenta", "brightcyan", "white", 
     55}; 
     56 
     57/*** file scope functions ************************************************************************/ 
     58/* --------------------------------------------------------------------------------------------- */ 
     59static const char *get_color (int color, int bright) { 
     60    return bright ? color_names[0 + color] : color_names[8 + color]; 
     61} 
     62 
     63/* --------------------------------------------------------------------------------------------- */ 
     64/*** public functions ****************************************************************************/ 
     65/* --------------------------------------------------------------------------------------------- */ 
     66/* --------------------------------------------------------------------------------------------- */ 
     67 
     68enum nroff_high_type 
     69get_nroff_high_type (mcview_t * view) 
     70{ 
     71    int c, state = 0; 
     72    off_t i = 0; 
     73 
     74    if (mcview_get_filesize(view) > MAX_ANSI_SIZE) 
     75      return NROFF_HIGH_NROFF; 
     76 
     77    while (i < 256) 
     78    { 
     79        if (!mcview_get_byte (view, i++, &c)) 
     80          break; 
     81        if (state == 0 && c == 033) 
     82        { 
     83            state = 1; 
     84        } 
     85        else if (state == 1 && c == '[') 
     86        { 
     87            state = 2; 
     88        } 
     89        else if (state == 2 && c >= '0' && c <= '9') 
     90        { 
     91            return NROFF_HIGH_ANSI; 
     92        } 
     93        else 
     94        { 
     95            state = 0; 
     96        } 
     97    } 
     98    return NROFF_HIGH_NROFF; 
     99} 
     100 
     101/* --------------------------------------------------------------------------------------------- */ 
     102 
     103#define ANSI_NONE 0 
     104#define ANSI_ESC 1 
     105#define ANSI_SQUARE 2 
     106#define ANSI_ANSI 3 
     107 
     108void 
     109mcview_display_ansi (mcview_t * view) 
     110{ 
     111    const screen_dimen left = view->data_area.left; 
     112    const screen_dimen top = view->data_area.top; 
     113    const screen_dimen width = view->data_area.width; 
     114    const screen_dimen height = view->data_area.height; 
     115    screen_dimen row = 0, col = 0; 
     116    off_t from, chk_from = 0; 
     117    int cw = 1; 
     118    int c, prev_ch = 0; 
     119    gboolean last_row = TRUE; 
     120/*    struct hexedit_change_node *curr = view->change_list; */ 
     121    int ansi_state = ANSI_NONE, ansi_check = 0, fg = 0, bg = 0, br = 0, bl = 0; 
     122    int ansi_puffer_idx = -1, ansi_puffer_i = 0; 
     123    char ansi_puffer[128]; 
     124 
     125    mcview_display_clean (view); 
     126    mcview_display_ruler (view); 
     127 
     128    /* Find the first displayable changed byte */ 
     129    from = view->dpy_start; 
     130    if (from > 0) 
     131    { 
     132         c = 'x'; 
     133         chk_from = from; 
     134         while (from > 0) 
     135         { 
     136             mcview_get_byte (view, --from, &c); 
     137             if (c == '\r' || c == '\n') { 
     138               from++; 
     139               break; 
     140             } 
     141         } 
     142         ansi_check = 1; /* now from == start of line; chck_from = real from*/ 
     143     } 
     144/*    while ((curr != NULL) && (curr->offset < from)) 
     145        curr = curr->next; */ 
     146 
     147    tty_setcolor (NORMAL_COLOR); 
     148    while (TRUE) 
     149    { 
     150 
     151        if (row >= height) 
     152            break; 
     153 
     154        if (ansi_state != ANSI_NONE && ansi_puffer_idx >= 127) { 
     155            ansi_puffer_idx = -1; 
     156            ansi_state = ANSI_NONE; 
     157        } 
     158        if (ansi_state == ANSI_NONE && ansi_puffer_idx >= 0) { 
     159          c = ansi_puffer[ansi_puffer_i++]; 
     160          ansi_puffer_idx--; 
     161        } else { 
     162#ifdef HAVE_CHARSET 
     163            if (view->utf8) 
     164            { 
     165                gboolean read_res = TRUE; 
     166 
     167                c = mcview_get_utf (view, from, &cw, &read_res); 
     168                if (!read_res) 
     169                    break; 
     170            } 
     171            else 
     172#endif 
     173            if (!mcview_get_byte (view, from, &c)) 
     174                break; 
     175            from++; 
     176            if (cw > 1) 
     177                from += cw - 1; 
     178        } 
     179 
     180        last_row = FALSE; 
     181 
     182        if (ansi_state == ANSI_NONE && c == '\033') { /* ESC? */ 
     183          ansi_state = ANSI_ESC; 
     184          ansi_puffer[(ansi_puffer_i = ansi_puffer_idx = 0)] = c; 
     185          continue; 
     186        } else if (ansi_state == ANSI_ESC) { /* ^[ ? */ 
     187            ansi_puffer[++ansi_puffer_idx] = c; 
     188            if (c == '[') { 
     189                ansi_state = ANSI_SQUARE; 
     190                continue; 
     191             } else { 
     192                ansi_puffer_idx = -1; 
     193                ansi_state = ANSI_NONE; 
     194            } 
     195        } else if (ansi_state == ANSI_SQUARE) { /* ^[ ? */ 
     196            ansi_puffer[++ansi_puffer_idx] = c; 
     197            if (c == ';' || (c >= '0' && c <= '9')) { 
     198                ansi_state = ANSI_SQUARE; 
     199                continue; 
     200            } else if (c == 'm') {    /* ^[#;#;#m */ 
     201                int color; 
     202                int num = 0, n = 0, i = 2; 
     203 
     204                ansi_puffer[ansi_puffer_idx++] = ';'; /* ^[#;#;#; */ 
     205                ansi_puffer[ansi_puffer_idx] = '\0'; 
     206                while (sscanf(ansi_puffer+i, "%d;%n", &num, &n) == 1) { 
     207                    if (num == 0 ) 
     208                      br = bl = 0; 
     209                    else if (num == 1) 
     210                      br = 1; 
     211                    else if (num == 5) 
     212                      bl = 1; 
     213                    else if (num >= 30 && num <= 37) 
     214                      fg = num - 30; 
     215                    else if (num >= 40 && num <= 47) 
     216                      bg = num - 40; 
     217                    else if (num == 9999) 
     218                      fg = -1; 
     219                    i += n; 
     220                } 
     221                if (fg == -1) 
     222                { 
     223                    tty_setcolor (NORMAL_COLOR); 
     224                } 
     225                else 
     226                { 
     227                    color = tty_try_alloc_color_pair(get_color(fg, br), get_color(bg, bl), NULL); 
     228                    tty_setcolor(color); 
     229                } 
     230                ansi_puffer_idx = -1; 
     231                ansi_state = ANSI_NONE; 
     232                continue; 
     233             } else { 
     234                ansi_puffer_idx = -1; 
     235                ansi_state = ANSI_NONE; 
     236                continue; 
     237            } 
     238        } 
     239        if (ansi_check && from < chk_from) 
     240        { 
     241            continue; 
     242        } 
     243        else if (ansi_check && from >= chk_from) 
     244        { 
     245            ansi_check = 0; 
     246        } 
     247 
     248        if (c != '\n' && prev_ch == '\r') 
     249        { 
     250            if (++row >= height) 
     251                break; 
     252 
     253            col = 0; 
     254        } 
     255 
     256        prev_ch = c; 
     257        if (c == '\r') 
     258            continue; 
     259 
     260        if (c == '\n') 
     261        { 
     262            col = 0; 
     263            row++; 
     264            continue; 
     265        } 
     266 
     267 
     268        if (c == '\t') 
     269        { 
     270            col += (option_tab_spacing - col % option_tab_spacing); 
     271            continue; 
     272        } 
     273 
     274        if (0 && view->search_start <= from && from < view->search_end) /****INFO no search highlite */ 
     275            tty_setcolor (SELECTED_COLOR); 
     276 
     277        if (((off_t) col >= view->dpy_text_column) 
     278            && ((off_t) col - view->dpy_text_column < (off_t) width)) 
     279        { 
     280            widget_move (view, top + row, left + ((off_t) col - view->dpy_text_column)); 
     281#ifdef HAVE_CHARSET 
     282            if (mc_global.utf8_display) 
     283            { 
     284                if (!view->utf8) 
     285                    c = convert_from_8bit_to_utf_c ((unsigned char) c, view->converter); 
     286                if (!g_unichar_isprint (c)) 
     287                    c = '.'; 
     288            } 
     289            else if (view->utf8) 
     290                c = convert_from_utf_to_current_c (c, view->converter); 
     291            else 
     292#endif 
     293            { 
     294#ifdef HAVE_CHARSET 
     295                c = convert_to_display_c (c); 
     296#endif 
     297                if (!is_printable (c)) 
     298                    c = '.'; 
     299            } 
     300 
     301            tty_print_anychar (c); 
     302        } 
     303 
     304        col++; 
     305 
     306#ifdef HAVE_CHARSET 
     307        if (view->utf8) 
     308        { 
     309            if (g_unichar_iswide (c)) 
     310                col++; 
     311            else if (g_unichar_iszerowidth (c)) 
     312                col--; 
     313        } 
     314#endif 
     315    } 
     316 
     317    view->dpy_end = from; 
     318    if (mcview_show_eof != NULL && mcview_show_eof[0] != '\0') 
     319    { 
     320        if (last_row && mcview_get_byte (view, from - 1, &c)) 
     321            if (c != '\n') 
     322                row--; 
     323        while (++row < height) 
     324        { 
     325            widget_move (view, top + row, left); 
     326            tty_print_string (mcview_show_eof); 
     327        } 
     328    } 
     329} 
     330 
     331/* --------------------------------------------------------------------------------------------- */ 
  • src/viewer/display.c

    diff --git a/src/viewer/display.c b/src/viewer/display.c
    index 41606c5..9780cf6 100644
    a b mcview_display (mcview_t * view) 
    235235    } 
    236236    else if (view->text_nroff_mode) 
    237237    { 
    238         mcview_display_nroff (view); 
     238        if (view->nroff_high_type ==  NROFF_HIGH_ANSI) 
     239            mcview_display_ansi (view); 
     240        else 
     241            mcview_display_nroff (view); 
    239242    } 
    240243    else 
    241244    { 
  • src/viewer/internal.h

    diff --git a/src/viewer/internal.h b/src/viewer/internal.h
    index 79728d2..0dc6033 100644
    a b extern const off_t OFFSETTYPE_MAX; 
    2626 
    2727/*** enums ***************************************************************************************/ 
    2828 
     29#define WRAP_MODE_DISABLED(view) (view->text_nroff_mode && view->nroff_high_type == NROFF_HIGH_ANSI) 
     30#define TEXT_WRAP_MODE(view) (view->text_wrap_mode && !WRAP_MODE_DISABLED(view)) 
     31 
    2932/* data sources of the view */ 
    3033enum view_ds 
    3134{ 
    enum ccache_type 
    4245    CCACHE_LINECOL 
    4346}; 
    4447 
     48enum nroff_high_type 
     49{ 
     50    NROFF_HIGH_UNCHECKED = -1, 
     51    NROFF_HIGH_NROFF = 0, 
     52    NROFF_HIGH_ANSI = 1, 
     53}; 
     54 
    4555typedef enum 
    4656{ 
    4757    NROFF_TYPE_NONE = 0, 
    typedef struct mcview_struct 
    131141    gboolean magic_mode;        /* Preprocess the file using external programs */ 
    132142    gboolean hexedit_lownibble; /* Are we editing the last significant nibble? */ 
    133143    gboolean locked;            /* We hold lock on current file */ 
     144    enum nroff_high_type nroff_high_type;  /* Instead of nroff style highliting, do other (e.g. ANSI) */ 
    134145 
    135146    gboolean utf8;              /* It's multibyte file codeset */ 
    136147 
    int mcview_nroff_seq_prev (mcview_nroff_t *); 
    322333/* plain.c: */ 
    323334void mcview_display_text (mcview_t *); 
    324335 
     336/* ansi.c: */ 
     337enum nroff_high_type get_nroff_high_type (mcview_t * view); 
     338void mcview_display_ansi (mcview_t *); 
     339 
    325340/* search.c: */ 
    326341mc_search_cbret_t mcview_search_cmd_callback (const void *user_data, gsize char_offset, 
    327342                                              int *current_char); 
  • src/viewer/lib.c

    diff --git a/src/viewer/lib.c b/src/viewer/lib.c
    index c99197f..f467d91 100644
    a b mcview_toggle_magic_mode (mcview_t * view) 
    9393    view->dir = NULL; 
    9494    view->dir_count = NULL; 
    9595    view->dir_idx = NULL; 
     96    view->nroff_high_type = NROFF_HIGH_UNCHECKED; 
    9697    mcview_done (view); 
    9798    mcview_init (view); 
    9899    mcview_load (view, command, filename, 0); 
    mcview_toggle_magic_mode (mcview_t * view) 
    111112void 
    112113mcview_toggle_wrap_mode (mcview_t * view) 
    113114{ 
    114     if (view->text_wrap_mode) 
     115    if (TEXT_WRAP_MODE(view)) 
    115116        view->dpy_start = mcview_bol (view, view->dpy_start, 0); 
    116117    view->text_wrap_mode = !view->text_wrap_mode; 
    117118    view->dpy_bbar_dirty = TRUE; 
  • src/viewer/mcviewer.c

    diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c
    index 93908f3..4e002fd 100644
    a b do_mcview_event (mcview_t * view, Gpm_Event * event, int *result) 
    124124    y = local.y; 
    125125 
    126126    /* Scrolling left and right */ 
    127     if (!view->text_wrap_mode) 
     127    if (!TEXT_WRAP_MODE(view)) 
    128128    { 
    129129        if (x < view->data_area.width * 1 / 4) 
    130130        { 
    mcview_new (int y, int x, int lines, int cols, gboolean is_panel) 
    208208    view->text_nroff_mode = FALSE; 
    209209    view->text_wrap_mode = FALSE; 
    210210    view->magic_mode = FALSE; 
     211    view->nroff_high_type = NROFF_HIGH_UNCHECKED; 
    211212 
    212213    view->dpy_frame_size = is_panel ? 1 : 0; 
    213214    view->converter = str_cnv_from_term; 
    mcview_load (mcview_t * view, const char *command, const char *file, int start_l 
    375376            if (view->magic_mode && (type != COMPRESSION_NONE)) 
    376377            { 
    377378                char *tmp_filename; 
     379                vfs_path_t *vpath1 = NULL; 
     380                int fd1; 
    378381 
    379                 vfs_path_free (view->filename_vpath); 
    380382                tmp_filename = g_strconcat (file, decompress_extension (type), (char *) NULL); 
    381                 view->filename_vpath = vfs_path_from_str (tmp_filename); 
     383                vpath1 = vfs_path_from_str (tmp_filename); 
     384                fd1 = mc_open (vpath1, O_RDONLY | O_NONBLOCK); 
     385                if (fd1 == -1) 
     386                { 
     387                    g_snprintf (tmp, sizeof (tmp), _("Cannot open \"%s\" in magic mode\n%s"), 
     388                                file, unix_error_string (errno)); 
     389                    mcview_show_error (view, tmp); 
     390                } 
     391                else 
     392                { 
     393                    mc_close (fd); 
     394                    fd = fd1; 
     395                    mc_fstat (fd, &st); 
     396                } 
     397                vfs_path_free (vpath1); 
    382398                g_free (tmp_filename); 
    383399            } 
    384400            mcview_set_datasource_file (view, fd, &st); 
  • src/viewer/move.c

    diff --git a/src/viewer/move.c b/src/viewer/move.c
    index 23ab022..8550ad4 100644
    a b mcview_move_up (mcview_t * view, off_t lines) 
    110110        { 
    111111            if (view->dpy_start == 0) 
    112112                break; 
    113             if (view->text_wrap_mode) 
     113            if (TEXT_WRAP_MODE(view)) 
    114114            { 
    115115                new_offset = mcview_bol (view, view->dpy_start, view->dpy_start - (off_t) 1); 
    116116                /* check if dpy_start == BOL or not (then new_offset = dpy_start - 1, 
    mcview_move_down (mcview_t * view, off_t lines) 
    178178        { 
    179179            while (lines-- > 0) 
    180180            { 
    181                 if (view->text_wrap_mode) 
     181                if (TEXT_WRAP_MODE(view)) 
    182182                    view->dpy_end = 
    183183                        mcview_eol (view, view->dpy_end, 
    184184                                    view->dpy_end + (off_t) view->data_area.width); 
    185185                else 
    186186                    view->dpy_end = mcview_eol (view, view->dpy_end, last_byte); 
    187187 
    188                 if (view->text_wrap_mode) 
     188                if (TEXT_WRAP_MODE(view)) 
    189189                    new_offset = 
    190190                        mcview_eol (view, view->dpy_start, 
    191191                                    view->dpy_start + (off_t) view->data_area.width); 
    mcview_move_down (mcview_t * view, off_t lines) 
    202202            off_t i; 
    203203            for (i = 0; i < lines && new_offset < last_byte; i++) 
    204204            { 
    205                 if (view->text_wrap_mode) 
     205                if (TEXT_WRAP_MODE(view)) 
    206206                    new_offset = 
    207207                        mcview_eol (view, view->dpy_start, 
    208208                                    view->dpy_start + (off_t) view->data_area.width); 
    mcview_moveto_bol (mcview_t * view) 
    343343    { 
    344344        view->hex_cursor -= view->hex_cursor % view->bytes_per_line; 
    345345    } 
    346     else if (!view->text_wrap_mode) 
     346    else if (!TEXT_WRAP_MODE(view)) 
    347347    { 
    348348        view->dpy_start = mcview_bol (view, view->dpy_start, 0); 
    349349    } 
  • src/viewer/nroff.c

    diff --git a/src/viewer/nroff.c b/src/viewer/nroff.c
    index a8a77af..b79f033 100644
    a b mcview_display_nroff (mcview_t * view) 
    107107    int c_next = 0; 
    108108    struct hexedit_change_node *curr = view->change_list; 
    109109 
     110    if (view->nroff_high_type == NROFF_HIGH_UNCHECKED) { 
     111        view->nroff_high_type = get_nroff_high_type (view); 
     112        if (view->nroff_high_type == NROFF_HIGH_ANSI) 
     113        { 
     114            mcview_display_ansi (view); 
     115            return; 
     116        } 
     117    } 
     118 
    110119    mcview_display_clean (view); 
    111120    mcview_display_ruler (view); 
    112121