- Timestamp:
- 03/12/11 14:12:57 (6 months ago)
- Location:
- branches/e4fix/EDIT4
- Files:
-
- 4 modified
-
ED4_edit_string.cxx (modified) (1 diff)
-
ED4_root.cxx (modified) (5 diffs)
-
ED4_search.cxx (modified) (5 diffs)
-
ed4_search.hxx (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/e4fix/EDIT4/ED4_edit_string.cxx
r8275 r8277 777 777 } 778 778 case 'S': { // CTRL-S = Repeat last search 779 ad_err = ED4_repeat_last_search( );779 ad_err = ED4_repeat_last_search(current_ed4w()); 780 780 seq_pos = current_cursor().get_sequence_pos(); 781 781 cursor_jump = ED4_JUMP_KEEP_POSITION; -
branches/e4fix/EDIT4/ED4_root.cxx
r8276 r8277 1132 1132 static void insert_search_fields(AW_window_menu_modes *awmm, 1133 1133 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) 1136 1136 { 1137 1137 char buf[200]; … … 1143 1143 1144 1144 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); 1146 1146 awmm->create_button(cat(buf, macro_prefix, "_SEARCH_NEXT"), "#edit/next.bitmap"); 1147 1147 1148 1148 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); 1150 1150 awmm->create_button(cat(buf, macro_prefix, "_SEARCH_LAST"), "#edit/last.bitmap"); 1151 1151 1152 1152 awmm->at(cat(buf, label_prefix, "d")); 1153 awmm->callback(AW_POPUP, (AW_CL)ED4_create_search_window, (AW_CL)t ype);1153 awmm->callback(AW_POPUP, (AW_CL)ED4_create_search_window, (AW_CL)taw); 1154 1154 awmm->create_button(cat(buf, macro_prefix, "_SEARCH_DETAIL"), "#edit/detail.bitmap"); 1155 1155 … … 1549 1549 sprintf(menu_entry_name, "%s Search", id); 1550 1550 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)); 1553 1554 } 1554 1555 } … … 1885 1886 1886 1887 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 ) 1888 1897 1889 1898 INSERT_SEARCH_FIELDS(0, u1, USER1); … … 1900 1909 1901 1910 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()); 1903 1912 awmm->create_button("ALL_SEARCH_LAST", "#edit/last.bitmap"); 1904 1913 1905 1914 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()); 1907 1916 awmm->create_button("ALL_SEARCH_NEXT", "#edit/next.bitmap"); 1908 1917 -
branches/e4fix/EDIT4/ED4_search.cxx
r8275 r8277 727 727 728 728 if (settings[type]->get_autoJump() && (action & DO_AUTO_JUMP)) { // auto jump 729 ED4_MostRecentWinContext context; 730 ED4_cursor *cursor = ¤t_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 = ¤t_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 748 744 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 } 753 756 } 754 757 } 755 } 756 757 if (bestPos!=-1) {758 if (bestPos == pos) {759 jumped = true; // already there760 }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 } 769 772 } 770 773 } … … 773 776 bool old_update = ED4_update_global_cursor_awars_allowed; 774 777 ED4_update_global_cursor_awars_allowed = false; 775 ED4_ROOT->refresh_all_windows( 0);778 ED4_ROOT->refresh_all_windows(1); 776 779 ED4_update_global_cursor_awars_allowed = old_update; 777 780 } … … 1333 1336 static AW_CL last_searchDescriptor = -1; 1334 1337 1335 GB_ERROR ED4_repeat_last_search( ) {1338 GB_ERROR ED4_repeat_last_search(ED4_window *ed4w) { 1336 1339 if (int(last_searchDescriptor)==-1) { 1337 1340 return GBS_global_string("You have to search first, before you can repeat a search."); 1338 1341 } 1339 1342 1340 ED4_search (0, last_searchDescriptor);1343 ED4_search_cb(0, last_searchDescriptor, (AW_CL)ed4w); 1341 1344 return 0; 1342 1345 } 1343 1346 1344 void ED4_search(AW_window *aww , AW_CL searchDescriptor) { 1345 ED4_MostRecentWinContext context; 1346 int direction; // @@@ fix locals 1347 void 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; 1347 1356 ED4_SearchPositionType pattern; 1348 int searchOnlyForShownPatterns;1349 1350 last_searchDescriptor = searchDescriptor;1351 1357 decodeSearchDescriptor(searchDescriptor, &direction, &pattern); 1352 searchOnlyForShownPatterns = pattern==ED4_ANY_PATTERN; 1358 1359 int searchOnlyForShownPatterns = pattern==ED4_ANY_PATTERN; 1353 1360 1354 1361 // detect position where to start searching … … 1737 1744 1738 1745 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; 1746 AW_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; 1743 1752 1744 1753 ED4_aws_init(root, aws, "%s_search", "%s Search", ED4_SearchPositionTypeId[type]); … … 1762 1771 1763 1772 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); 1765 1774 aws->create_button("SEARCH_NEXT", "#edit/next.bitmap", "N"); 1766 1775 1767 1776 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); 1769 1778 aws->create_button("SEARCH_LAST", "#edit/last.bitmap", "L"); 1770 1779 -
branches/e4fix/EDIT4/ed4_search.hxx
r7812 r8277 28 28 }; 29 29 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); 30 void ED4_search_cb(AW_window *aww, AW_CL searchDescriptor, AW_CL cl_ed4w); 31 32 GB_ERROR ED4_repeat_last_search(class ED4_window *ed4w); 33 AW_window *ED4_create_search_window(AW_root *root, AW_CL cl_type_and_ed4w); 34 35 void ED4_create_search_awars(AW_root *root); 34 36 35 37 // -------------------------------------------------------------------------------- … … 49 51 ED4_SIG3_PATTERN, 50 52 ED4_ANY_PATTERN 53 }; 54 55 struct 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_) {} 51 61 }; 52 62
