Ticket #113: 2079-mcedit-visible-ws-v2.diff

File 2079-mcedit-visible-ws-v2.diff, 4.7 KB (added by slavazanko, 15 years ago)
  • edit/editdraw.c

    RCS file: /sources/mc/mc/edit/editdraw.c,v
    retrieving revision 1.46
    diff -U2 -r1.46 editdraw.c
     
    5252#define MOD_MARKED              (1 << 10) 
    5353#define MOD_CURSOR              (1 << 11) 
     54#define MOD_WHITESPACE          (1 << 12) 
    5455 
    5556#define FONT_OFFSET_X 0 
     
    244245        } 
    245246 
    246         if (style & MOD_BOLD) { 
    247             set_color (EDITOR_BOLD_COLOR); 
    248         } else if (style & MOD_MARKED) { 
    249             set_color (EDITOR_MARKED_COLOR); 
     247        if (style & MOD_WHITESPACE) { 
     248            if (style & MOD_MARKED) { 
     249                textchar = ' '; 
     250                set_color (EDITOR_MARKED_COLOR); 
     251            } else { 
     252#if 0 
     253                if (color != EDITOR_NORMAL_COLOR) { 
     254                    textchar = ' '; 
     255                    lowlevel_set_color (color); 
     256                } else 
     257#endif 
     258                    set_color (EDITOR_WHITESPACE_COLOR); 
     259            } 
    250260        } else { 
    251             lowlevel_set_color (color); 
     261            if (style & MOD_BOLD) { 
     262                set_color (EDITOR_BOLD_COLOR); 
     263            } else if (style & MOD_MARKED) { 
     264                set_color (EDITOR_MARKED_COLOR); 
     265            } else { 
     266                lowlevel_set_color (color); 
     267            } 
    252268        } 
    253269 
     
    257273} 
    258274 
     275int visible_tabs = 1, visible_tws = 1; 
     276 
    259277/* b is a pointer to the beginning of the line */ 
    260278static void 
     
    264282    static unsigned int line[MAX_LINE_LEN]; 
    265283    unsigned int *p = line; 
    266     long m1 = 0, m2 = 0, q, c1, c2; 
     284    long m1 = 0, m2 = 0, q, c1, c2, tws; 
    267285    int col, start_col_real; 
    268286    unsigned int c; 
     
    287305 
    288306        if (row <= edit->total_lines - edit->start_line) { 
     307            if (use_colors && visible_tws) { 
     308                tws = edit_eol (edit, b); 
     309                while (tws > b && ((c = edit_get_byte (edit, tws - 1)) == ' ' 
     310                                   || c == '\t')) 
     311                    tws--; 
     312            } 
     313 
    289314            while (col <= end_col - edit->start_col) { 
    290315                *p = 0; 
     
    313338                    *p |= book_mark << 16; 
    314339                } 
    315                 q++; 
    316340                switch (c) { 
    317341                case '\n': 
     
    321345                case '\t': 
    322346                    i = TAB_SIZE - ((int) col % TAB_SIZE); 
    323                     *p |= ' '; 
    324                     c = *(p++) & ~MOD_CURSOR; 
    325347                    col += i; 
    326                     while (--i) 
    327                         *(p++) = c; 
     348                    if (use_colors && visible_tabs) { 
     349                        c = (*p & ~MOD_CURSOR) | MOD_WHITESPACE; 
     350                        if (i > 2) { 
     351                            *(p++) |= '<' | MOD_WHITESPACE; 
     352                            while (--i > 1) 
     353                                *(p++) = c | '-'; 
     354                            *(p++) = c | '>'; 
     355                        } else if (i > 1) { 
     356                            *(p++) |= '<' | MOD_WHITESPACE; 
     357                            *(p++) = c | '>'; 
     358                        } else 
     359                            *(p++) |= '>' | MOD_WHITESPACE; 
     360                    } else if (use_colors && visible_tws && q >= tws) { 
     361                        *p |= '.' | MOD_WHITESPACE; 
     362                        c = *(p++) & ~MOD_CURSOR; 
     363                        while (--i) 
     364                            *(p++) = c; 
     365                    } else { 
     366                        *p |= ' '; 
     367                        c = *(p++) & ~MOD_CURSOR; 
     368                        while (--i) 
     369                            *(p++) = c; 
     370                    } 
    328371                    break; 
     372                case ' ': 
     373                    if (use_colors && visible_tws && q >= tws) { 
     374                        *(p++) |= '.' | MOD_WHITESPACE; 
     375                        col++; 
     376                        break; 
     377                    } 
     378                    /* fallthrough */ 
    329379                default: 
    330380                    c = convert_to_display_c (c); 
     
    352402                    break; 
    353403                } 
     404                q++; 
    354405            } 
    355406        } 
  • src/color.c

    RCS file: /cvsroot/mc/mc/src/color.c,v
    retrieving revision 1.41
    diff -U2 -r1.41 color.c
     
    100100    { "editbold=",       0, 0 },        /* search->found */ 
    101101    { "editmarked=",     0, 0 },        /* marked/selected */ 
     102    { "editwhitespace=", 0, 0 },        /* whitespace */ 
    102103 
    103 /* error dialog colors start at 37 */ 
    104     { "errdhotnormal=",  0, 0 }, /* Error dialog normal/hot */ /* 37 */ 
     104/* error dialog colors start at 38 */ 
     105    { "errdhotnormal=",  0, 0 }, /* Error dialog normal/hot */ /* 38 */ 
    105106    { "errdhotfocus=",   0, 0 }, /* Error dialog focused/hot */ 
    106107}; 
     
    165166"editbold=yellow,blue:" 
    166167"editmarked=black,cyan:" 
     168"editwhitespace=brightblue,blue:" 
    167169"errdhotnormal=yellow,red:" 
    168170"errdhotfocus=yellow,lightgray"; 
  • src/color.h

    RCS file: /cvsroot/mc/mc/src/color.h,v
    retrieving revision 1.21
    diff -U2 -r1.21 color.h
     
    7272 
    7373/* 
    74  * editor colors - only 3 for normal, search->found, and select, respectively 
     74 * editor colors - only 4 for normal, search->found, select, and whitespace 
     75 * respectively 
    7576 * Last is defined to view color. 
    7677 */ 
     
    7980#define EDITOR_BOLD_COLOR            IF_COLOR (35, A_BOLD) 
    8081#define EDITOR_MARKED_COLOR          IF_COLOR (36, A_REVERSE) 
     82#define EDITOR_WHITESPACE_COLOR      IF_COLOR (37, 0 /* irrelevant */) 
    8183 
    8284/* Error dialog colors */ 
    83 #define ERROR_HOT_NORMAL   IF_COLOR (37, 0) 
    84 #define ERROR_HOT_FOCUS    IF_COLOR (38, 0) 
     85#define ERROR_HOT_NORMAL   IF_COLOR (38, 0) 
     86#define ERROR_HOT_FOCUS    IF_COLOR (39, 0) 
    8587 
    8688#ifdef HAVE_SLANG