Changeset 8277

Show
Ignore:
Timestamp:
03/12/11 14:12:57 (6 months ago)
Author:
westram
Message:
  • pass ED4_window to ED4_search_cb to ensure the search is performed in the correct window
  • after changing search params
    • perform autojump in all windows
    • redraw all windows
Location:
branches/e4fix/EDIT4
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/e4fix/EDIT4/ED4_edit_string.cxx

    r8275 r8277  
    777777                        } 
    778778                        case 'S': { // CTRL-S = Repeat last search 
    779                             ad_err      = ED4_repeat_last_search(); 
     779                            ad_err      = ED4_repeat_last_search(current_ed4w()); 
    780780                            seq_pos     = current_cursor().get_sequence_pos(); 
    781781                            cursor_jump = ED4_JUMP_KEEP_POSITION; 
  • branches/e4fix/EDIT4/ED4_root.cxx

    r8276 r8277  
    11321132static void insert_search_fields(AW_window_menu_modes *awmm, 
    11331133                                 const char *label_prefix, const char *macro_prefix, 
    1134                                  const char *pattern_awar_name, ED4_SearchPositionType type, const char *show_awar_name, 
    1135                                  int short_form) 
     1134                                 const char *pattern_awar_name, const char *show_awar_name, 
     1135                                 int short_form, ED4_search_type_and_ed4w *taw) 
    11361136{ 
    11371137    char buf[200]; 
     
    11431143 
    11441144    awmm->at(cat(buf, label_prefix, "n")); 
    1145     awmm->callback(ED4_search, ED4_encodeSearchDescriptor(+1, type)); 
     1145    awmm->callback(ED4_search_cb, ED4_encodeSearchDescriptor(+1, taw->type), (AW_CL)taw->ed4w); 
    11461146    awmm->create_button(cat(buf, macro_prefix, "_SEARCH_NEXT"), "#edit/next.bitmap"); 
    11471147 
    11481148    awmm->at(cat(buf, label_prefix, "l")); 
    1149     awmm->callback(ED4_search, ED4_encodeSearchDescriptor(-1, type)); 
     1149    awmm->callback(ED4_search_cb, ED4_encodeSearchDescriptor(-1, taw->type), (AW_CL)taw->ed4w); 
    11501150    awmm->create_button(cat(buf, macro_prefix, "_SEARCH_LAST"), "#edit/last.bitmap"); 
    11511151 
    11521152    awmm->at(cat(buf, label_prefix, "d")); 
    1153     awmm->callback(AW_POPUP, (AW_CL)ED4_create_search_window, (AW_CL)type); 
     1153    awmm->callback(AW_POPUP, (AW_CL)ED4_create_search_window, (AW_CL)taw); 
    11541154    awmm->create_button(cat(buf, macro_prefix, "_SEARCH_DETAIL"), "#edit/detail.bitmap"); 
    11551155 
     
    15491549            sprintf(menu_entry_name, "%s Search", id); 
    15501550 
    1551             hotkey[0] = hotkeys[s]; 
    1552             awmm->insert_menu_topic(macro_name, menu_entry_name, hotkey, "e4_search.hlp", AWM_ALL, AW_POPUP, AW_CL(ED4_create_search_window), AW_CL(type)); 
     1551            hotkey[0]                     = hotkeys[s]; 
     1552            ED4_search_type_and_ed4w *taw = new ED4_search_type_and_ed4w(type, current_ed4w()); 
     1553            awmm->insert_menu_topic(macro_name, menu_entry_name, hotkey, "e4_search.hlp", AWM_ALL, AW_POPUP, AW_CL(ED4_create_search_window), AW_CL(taw)); 
    15531554        } 
    15541555    } 
     
    18851886 
    18861887    awmm->button_length(0); 
    1887 #define INSERT_SEARCH_FIELDS(Short, label_prefix, prefix) insert_search_fields(awmm, #label_prefix, #prefix, ED4_AWAR_##prefix##_SEARCH_PATTERN, ED4_##prefix##_PATTERN, ED4_AWAR_##prefix##_SEARCH_SHOW, Short) 
     1888#define INSERT_SEARCH_FIELDS(Short, label_prefix, prefix)                                                               \ 
     1889    insert_search_fields(awmm,                                                                                          \ 
     1890                         #label_prefix,                                                                                 \ 
     1891                         #prefix,                                                                                       \ 
     1892                         ED4_AWAR_##prefix##_SEARCH_PATTERN,                                                            \ 
     1893                         ED4_AWAR_##prefix##_SEARCH_SHOW,                                                               \ 
     1894                         Short,                                                                                         \ 
     1895                         new ED4_search_type_and_ed4w(ED4_##prefix##_PATTERN, current_ed4w())                           \ 
     1896        ) 
    18881897 
    18891898    INSERT_SEARCH_FIELDS(0, u1, USER1); 
     
    19001909 
    19011910    awmm->at("alast"); 
    1902     awmm->callback(ED4_search, ED4_encodeSearchDescriptor(-1, ED4_ANY_PATTERN)); 
     1911    awmm->callback(ED4_search_cb, ED4_encodeSearchDescriptor(-1, ED4_ANY_PATTERN), (AW_CL)current_ed4w()); 
    19031912    awmm->create_button("ALL_SEARCH_LAST", "#edit/last.bitmap"); 
    19041913 
    19051914    awmm->at("anext"); 
    1906     awmm->callback(ED4_search, ED4_encodeSearchDescriptor(+1, ED4_ANY_PATTERN)); 
     1915    awmm->callback(ED4_search_cb, ED4_encodeSearchDescriptor(+1, ED4_ANY_PATTERN), (AW_CL)current_ed4w()); 
    19071916    awmm->create_button("ALL_SEARCH_NEXT", "#edit/next.bitmap"); 
    19081917 
  • branches/e4fix/EDIT4/ED4_search.cxx

    r8275 r8277  
    727727 
    728728    if (settings[type]->get_autoJump() && (action & DO_AUTO_JUMP)) { // auto jump 
    729         ED4_MostRecentWinContext context; 
    730         ED4_cursor *cursor = &current_cursor(); 
    731         bool        jumped = false; 
    732  
    733         if (cursor->owner_of_cursor && cursor->owner_of_cursor->is_sequence_terminal()) { 
    734             int pos = cursor->get_sequence_pos(); 
    735             ED4_sequence_terminal *seq_term = cursor->owner_of_cursor->to_sequence_terminal(); 
    736             ED4_SearchResults *result = &seq_term->results(); 
    737  
    738             result->search(seq_term); 
    739             ED4_SearchPosition *found = result->get_last_starting_before(type, pos+1, 0); 
    740             int bestPos = -1; 
    741  
    742             if (found) { 
    743                 bestPos = found->get_start_pos(); 
    744             } 
    745  
    746             if (pos>=1) { 
    747                 found = result->get_first_starting_after(type, pos-1, 0); 
     729        for (ED4_window *win = ED4_ROOT->first_window; win; win = win->next) { 
     730            ED4_LocalWinContext uses(win); 
     731 
     732            ED4_cursor *cursor = &current_cursor(); 
     733            bool        jumped = false; 
     734 
     735            if (cursor->owner_of_cursor && cursor->owner_of_cursor->is_sequence_terminal()) { 
     736                int pos = cursor->get_sequence_pos(); 
     737                ED4_sequence_terminal *seq_term = cursor->owner_of_cursor->to_sequence_terminal(); 
     738                ED4_SearchResults *result = &seq_term->results(); 
     739 
     740                result->search(seq_term); 
     741                ED4_SearchPosition *found = result->get_last_starting_before(type, pos+1, 0); 
     742                int bestPos = -1; 
     743 
    748744                if (found) { 
    749                     int next_pos = found->get_start_pos(); 
    750  
    751                     if (abs(pos-next_pos)<abs(pos-bestPos)) { 
    752                         bestPos = next_pos; 
     745                    bestPos = found->get_start_pos(); 
     746                } 
     747 
     748                if (pos>=1) { 
     749                    found = result->get_first_starting_after(type, pos-1, 0); 
     750                    if (found) { 
     751                        int next_pos = found->get_start_pos(); 
     752 
     753                        if (abs(pos-next_pos)<abs(pos-bestPos)) { 
     754                            bestPos = next_pos; 
     755                        } 
    753756                    } 
    754757                } 
    755             } 
    756  
    757             if (bestPos!=-1) { 
    758                 if (bestPos == pos) { 
    759                     jumped = true; // already there 
    760                 } 
    761                 else { 
    762                     jumped = seq_term->setCursorTo(cursor, bestPos, 1, ED4_JUMP_KEEP_POSITION); 
    763                 } 
    764             } 
    765         } 
    766  
    767         if (!jumped) { 
    768             ED4_search(0, ED4_encodeSearchDescriptor(+1, type)); 
     758 
     759                if (bestPos!=-1) { 
     760                    if (bestPos == pos) { 
     761                        jumped = true; // already there 
     762                    } 
     763                    else { 
     764                        jumped = seq_term->setCursorTo(cursor, bestPos, 1, ED4_JUMP_KEEP_POSITION); 
     765                    } 
     766                } 
     767            } 
     768 
     769            if (!jumped) { 
     770                ED4_search_cb(0, ED4_encodeSearchDescriptor(+1, type), (AW_CL)current_ed4w()); 
     771            } 
    769772        } 
    770773    } 
     
    773776        bool old_update                        = ED4_update_global_cursor_awars_allowed; 
    774777        ED4_update_global_cursor_awars_allowed = false; 
    775         ED4_ROOT->refresh_all_windows(0); 
     778        ED4_ROOT->refresh_all_windows(1); 
    776779        ED4_update_global_cursor_awars_allowed = old_update; 
    777780    } 
     
    13331336static AW_CL last_searchDescriptor = -1; 
    13341337 
    1335 GB_ERROR ED4_repeat_last_search() { 
     1338GB_ERROR ED4_repeat_last_search(ED4_window *ed4w) { 
    13361339    if (int(last_searchDescriptor)==-1) { 
    13371340        return GBS_global_string("You have to search first, before you can repeat a search."); 
    13381341    } 
    13391342 
    1340     ED4_search(0, last_searchDescriptor); 
     1343    ED4_search_cb(0, last_searchDescriptor, (AW_CL)ed4w); 
    13411344    return 0; 
    13421345} 
    13431346 
    1344 void ED4_search(AW_window *aww , AW_CL searchDescriptor) { 
    1345     ED4_MostRecentWinContext context; 
    1346     int direction; // @@@ fix locals 
     1347void ED4_search_cb(AW_window *, AW_CL searchDescriptor, AW_CL cl_ed4w) { 
     1348    ED4_window *ed4w = (ED4_window*)cl_ed4w; 
     1349    e4_assert(ed4w); 
     1350 
     1351    ED4_LocalWinContext uses(ed4w); 
     1352 
     1353    last_searchDescriptor = searchDescriptor; 
     1354 
     1355    int                    direction; 
    13471356    ED4_SearchPositionType pattern; 
    1348     int searchOnlyForShownPatterns; 
    1349  
    1350     last_searchDescriptor = searchDescriptor; 
    13511357    decodeSearchDescriptor(searchDescriptor, &direction, &pattern); 
    1352     searchOnlyForShownPatterns = pattern==ED4_ANY_PATTERN; 
     1358 
     1359    int searchOnlyForShownPatterns = pattern==ED4_ANY_PATTERN; 
    13531360 
    13541361    // detect position where to start searching 
     
    17371744 
    17381745 
    1739 AW_window *ED4_create_search_window(AW_root *root, AW_CL cl) { 
    1740     ED4_SearchPositionType  type     = ED4_SearchPositionType(cl); 
    1741     SearchAwarList         *awarList = &awar_list[type]; 
    1742     AW_window_simple       *aws      = new AW_window_simple; 
     1746AW_window *ED4_create_search_window(AW_root *root, AW_CL cl_type_and_ed4w) { 
     1747    ED4_search_type_and_ed4w *taw      = (ED4_search_type_and_ed4w*)cl_type_and_ed4w; 
     1748    ED4_SearchPositionType    type     = taw->type; 
     1749    ED4_window               *ed4w     = taw->ed4w; 
     1750    SearchAwarList           *awarList = &awar_list[type]; 
     1751    AW_window_simple         *aws      = new AW_window_simple; 
    17431752 
    17441753    ED4_aws_init(root, aws, "%s_search", "%s Search", ED4_SearchPositionTypeId[type]); 
     
    17621771 
    17631772    aws->at("next"); 
    1764     aws->callback(ED4_search, (AW_CL)ED4_encodeSearchDescriptor(+1, type)); 
     1773    aws->callback(ED4_search_cb, (AW_CL)ED4_encodeSearchDescriptor(+1, type), (AW_CL)ed4w); 
    17651774    aws->create_button("SEARCH_NEXT", "#edit/next.bitmap", "N"); 
    17661775 
    17671776    aws->at("previous"); 
    1768     aws->callback(ED4_search, (AW_CL)ED4_encodeSearchDescriptor(-1, type)); 
     1777    aws->callback(ED4_search_cb, (AW_CL)ED4_encodeSearchDescriptor(-1, type), (AW_CL)ed4w); 
    17691778    aws->create_button("SEARCH_LAST", "#edit/last.bitmap", "L"); 
    17701779 
  • branches/e4fix/EDIT4/ed4_search.hxx

    r7812 r8277  
    2828}; 
    2929 
    30 void       ED4_search(AW_window *aww, AW_CL searchDescriptor); 
    31 GB_ERROR   ED4_repeat_last_search(); 
    32 AW_window *ED4_create_search_window(AW_root *root, AW_CL type); 
    33 void       ED4_create_search_awars(AW_root *root); 
     30void ED4_search_cb(AW_window *aww, AW_CL searchDescriptor, AW_CL cl_ed4w); 
     31 
     32GB_ERROR ED4_repeat_last_search(class ED4_window *ed4w); 
     33AW_window *ED4_create_search_window(AW_root *root, AW_CL cl_type_and_ed4w); 
     34 
     35void ED4_create_search_awars(AW_root *root); 
    3436 
    3537// -------------------------------------------------------------------------------- 
     
    4951    ED4_SIG3_PATTERN, 
    5052    ED4_ANY_PATTERN 
     53}; 
     54 
     55struct ED4_search_type_and_ed4w { 
     56    ED4_SearchPositionType  type; 
     57    ED4_window             *ed4w; 
     58 
     59    ED4_search_type_and_ed4w(ED4_SearchPositionType type_, ED4_window *ed4w_) 
     60        : type(type_), ed4w(ed4w_) {} 
    5161}; 
    5262