Ticket #113: 3001-mcedit-visible-ws.diff

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

    RCS file: /cvsroot/mc/mc/edit/editdraw.c,v
    retrieving revision 1.42
    diff -U2 -r1.42 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 
     
    237238        } 
    238239 
    239         if (style & MOD_BOLD) { 
    240             set_color (EDITOR_BOLD_COLOR); 
    241         } else if (style & MOD_MARKED) { 
    242             set_color (EDITOR_MARKED_COLOR); 
     240        if (style & MOD_WHITESPACE) { 
     241            if (style & MOD_MARKED) { 
     242                textchar = ' '; 
     243                set_color (EDITOR_MARKED_COLOR); 
     244            } else { 
     245#if 0 
     246                if (color != EDITOR_NORMAL_COLOR) { 
     247                    textchar = ' '; 
     248                    lowlevel_set_color (color); 
     249                } else 
     250#endif 
     251                    set_color (EDITOR_WHITESPACE_COLOR); 
     252            } 
    243253        } else { 
    244             lowlevel_set_color (color); 
     254            if (style & MOD_BOLD) { 
     255                set_color (EDITOR_BOLD_COLOR); 
     256            } else if (style & MOD_MARKED) { 
     257                set_color (EDITOR_MARKED_COLOR); 
     258            } else { 
     259                lowlevel_set_color (color); 
     260            } 
    245261        } 
    246262 
     
    257273    static unsigned int line[MAX_LINE_LEN]; 
    258274    unsigned int *p = line; 
    259     long m1 = 0, m2 = 0, q, c1, c2; 
     275    long m1 = 0, m2 = 0, q, c1, c2, tws; 
    260276    int col, start_col_real; 
    261277    unsigned int c; 
     
    280296 
    281297        if (row <= edit->total_lines - edit->start_line) { 
     298            if (use_colors) { 
     299                tws = edit_eol (edit, b); 
     300                while (tws > b && edit_get_byte (edit, tws - 1) == ' ') 
     301                    tws--; 
     302            } 
     303 
    282304            while (col <= end_col - edit->start_col) { 
    283305                *p = 0; 
     
    306328                    *p |= book_mark << 16; 
    307329                } 
    308                 q++; 
    309330                switch (c) { 
    310331                case '\n': 
     
    314335                case '\t': 
    315336                    i = TAB_SIZE - ((int) col % TAB_SIZE); 
    316                     *p |= ' '; 
    317                     c = *(p++) & ~MOD_CURSOR; 
    318337                    col += i; 
    319                     while (--i) 
    320                         *(p++) = c; 
     338                    if (use_colors) { 
     339                        c = (*p & ~MOD_CURSOR) | MOD_WHITESPACE; 
     340                        if (i > 2) { 
     341                            *(p++) |= '<' | MOD_WHITESPACE; 
     342                            while (--i > 1) 
     343                                *(p++) = c | '-'; 
     344                            *(p++) = c | '>'; 
     345                        } else if (i > 1) { 
     346                            *(p++) |= '<' | MOD_WHITESPACE; 
     347                            *(p++) = c | '>'; 
     348                        } else 
     349                            *(p++) |= '>' | MOD_WHITESPACE; 
     350                    } else { 
     351                        *p |= ' '; 
     352                        c = *(p++) & ~MOD_CURSOR; 
     353                        while (--i) 
     354                            *(p++) = c; 
     355                    } 
    321356                    break; 
     357                case ' ': 
     358                    if (use_colors && q >= tws) { 
     359                        *(p++) |= '.' | MOD_WHITESPACE; 
     360                        col++; 
     361                        break; 
     362                    } 
     363                    /* fallthrough */ 
    322364                default: 
    323365                    c = convert_to_display_c (c); 
     
    345387                    break; 
    346388                } 
     389                q++; 
    347390            } 
    348391        } 
  • 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