Ticket #257: 00-77-utf8-filename-search-highlight.patch

File 00-77-utf8-filename-search-highlight.patch, 1.0 KB (added by egmont, 10 years ago)

Fix quick filename search

  • src/screen.c

    Quick filename search (^S) highlights correct width.
    
    diff -Naur mc-4.6.2.orig/src/screen.c mc-4.6.2/src/screen.c
    old new  
    788788 
    789789    if (panel->searching){ 
    790790        attrset (INPUT_COLOR); 
     791#ifdef UTF8 
     792        if (SLsmg_Is_Unicode) { 
     793            int j; 
     794            char search_buffer_valid_utf8 [sizeof (panel->search_buffer)]; 
     795            mbstate_t mbs; 
     796            int pos = 0; 
     797            int l = strlen (panel->search_buffer); 
     798            strcpy (search_buffer_valid_utf8, panel->search_buffer); 
     799            while (pos < l) { 
     800                memset (&mbs, 0, sizeof(mbs)); 
     801                j = mbrlen (search_buffer_valid_utf8 + pos, l - pos, &mbs); 
     802                if (j <= 0) break; 
     803                pos += j; 
     804            } 
     805            search_buffer_valid_utf8[pos] = '\0'; 
     806            j = columns_to_bytes (search_buffer_valid_utf8, panel->widget.cols-3); 
     807            tty_printf ("/%-*s", j, search_buffer_valid_utf8); 
     808        } else 
     809#endif 
    791810        tty_printf ("/%-*s", panel->widget.cols-3, panel->search_buffer); 
    792811        attrset (NORMAL_COLOR); 
    793812        return;