Ticket #1519: mc-4.7.0-pre1.search_in_selection.patch

File mc-4.7.0-pre1.search_in_selection.patch, 2.4 KB (added by dborca, 15 years ago)
  • edit/edit-widget.h

    diff -Naur mc-4.7.0-pre1~/edit/edit-widget.h mc-4.7.0-pre1/edit/edit-widget.h
    old new  
    6262    int replace_mode; 
    6363    int replace_backwards; 
    6464    int replace_case; 
     65    int replace_in_selection; 
    6566    int all_codepages; 
    6667 
    6768    long search_start;          /* First character to start searching from */ 
  • edit/editcmd.c

    diff -Naur mc-4.7.0-pre1~/edit/editcmd.c mc-4.7.0-pre1/edit/editcmd.c
    old new  
    12761276static gboolean 
    12771277editcmd_find (WEdit *edit, gsize *len) 
    12781278{ 
     1279    long search_lo = 0; 
     1280    long search_hi = edit->last_byte; 
     1281 
    12791282    gsize search_start = edit->search_start; 
    12801283    gsize search_end; 
    12811284 
     1285    if (edit->replace_in_selection) { 
     1286        if (eval_marks(edit, &search_lo, &search_hi)) { 
     1287            edit->search->error = MC_SEARCH_E_NOTFOUND; 
     1288            edit->search->error_str = g_strdup(_(" Search string not found ")); 
     1289            return FALSE; 
     1290        } 
     1291        if (edit->replace_backwards) { 
     1292            if (search_start > search_hi) { 
     1293                search_start = search_hi; 
     1294            } 
     1295        } else { 
     1296            if (search_start < search_lo) { 
     1297                search_start = search_lo; 
     1298            } 
     1299        } 
     1300    } 
     1301 
    12821302    if (edit->replace_backwards) { 
    1283         search_end = edit->curs1-1; 
    1284         while ((int) search_start >= 0) { 
    1285             if (search_end - search_start > edit->search->original_len && mc_search_is_fixed_search_str(edit->search)) 
    1286                 search_end = search_start + edit->search->original_len +1; 
    1287             if ( mc_search_run(edit->search, (void *) edit, search_start, search_end, len)) 
     1303        search_end = search_hi; 
     1304        while ((int) search_start >= search_lo) { 
     1305            if (search_end > search_start + edit->search->original_len && mc_search_is_fixed_search_str(edit->search)) 
     1306                search_end = search_start + edit->search->original_len; 
     1307            if ( mc_search_run(edit->search, (void *) edit, search_start, search_end, len) 
     1308                && edit->search->normal_offset == search_start ) 
    12881309            { 
    12891310                return TRUE; 
    12901311            } 
     
    12921313        } 
    12931314        edit->search->error_str = g_strdup(_(" Search string not found ")); 
    12941315    } else { 
    1295         return mc_search_run(edit->search, (void *) edit, edit->search_start, edit->last_byte, len); 
     1316        return mc_search_run(edit->search, (void *) edit, search_start, search_hi, len); 
    12961317    } 
    12971318    return FALSE; 
    12981319}