@@ -68,33 +68,9 @@ FindWindow::MessageReceived(BMessage* message)
6868 std::string replaceText (fReplaceTC ->TextLength (), ' \0 ' );
6969 fFindTC ->GetText (0 , findText.size () + 1 , &findText[0 ]);
7070 fReplaceTC ->GetText (0 , replaceText.size () + 1 , &replaceText[0 ]);
71- {
72- const int32 mruMax = 10 ;
73- int32 count = 0 ;
74- std::string lastFind;
75- if (fFindHistory .GetInfo (" mru" , nullptr , &count) == B_OK) {
76- lastFind = fFindHistory .GetString (" mru" , count - 1 , " " );
77- }
78- if (lastFind != findText)
79- fFindHistory .AddString (" mru" , findText.c_str ());
80- while (count >= mruMax) {
81- fFindHistory .RemoveData (" mru" , 0 );
82- count--;
83- }
84-
85- if (message->what != FINDWINDOW_FIND) {
86- count = 0 ;
87- std::string lastReplace;
88- if (fReplaceHistory .GetInfo (" mru" , nullptr , &count) == B_OK) {
89- lastReplace = fReplaceHistory .GetString (" mru" , count - 1 , " " );
90- }
91- if (lastReplace != replaceText)
92- fReplaceHistory .AddString (" mru" , replaceText.c_str ());
93- while (count >= mruMax) {
94- fReplaceHistory .RemoveData (" mru" , 0 );
95- count--;
96- }
97- }
71+ _AppendHistoryString (fFindHistory , findText);
72+ if (message->what != FINDWINDOW_FIND) {
73+ _AppendHistoryString (fReplaceHistory , replaceText);
9874 }
9975 bool newSearch = (fFlagsChanged
10076 || fOldFindText != findText
@@ -118,6 +94,22 @@ FindWindow::MessageReceived(BMessage* message)
11894 fFlagsChanged = false ;
11995 }
12096 } break ;
97+ case FINDWINDOW_BOOKMARKALL: {
98+ std::string findText (fFindTC ->TextLength (), ' \0 ' );
99+ fFindTC ->GetText (0 , findText.size () + 1 , &findText[0 ]);
100+ if (findText.empty () == true ) {
101+ return ;
102+ }
103+ _AppendHistoryString (fFindHistory , findText);
104+ message->AddString (" findText" , findText.c_str ());
105+ message->AddBool (" matchCase" , IsChecked (fMatchCaseCB ));
106+ message->AddBool (" matchWord" , IsChecked (fMatchWordCB ));
107+ message->AddBool (" wrapAround" , IsChecked (fWrapAroundCB ));
108+ message->AddBool (" regex" , IsChecked (fRegexCB ));
109+ message->AddBool (" backwards" , IsChecked (fBackwardsCB ));
110+ message->AddBool (" inSelection" , IsChecked (fInSelectionCB ));
111+ be_app->PostMessage (message);
112+ } break ;
121113 case FINDWINDOW_QUITTING: {
122114 if (LockLooper ())
123115 Quit ();
@@ -226,6 +218,8 @@ FindWindow::_InitInterface()
226218 fReplaceFindButton ->SetExplicitMaxSize (BSize (B_SIZE_UNLIMITED, B_SIZE_UNSET));
227219 fReplaceAllButton = new BButton (B_TRANSLATE (" Replace all" ), new BMessage ((uint32) FINDWINDOW_REPLACEALL));
228220 fReplaceAllButton ->SetExplicitMaxSize (BSize (B_SIZE_UNLIMITED, B_SIZE_UNSET));
221+ fBookmarkAllButton = new BButton (B_TRANSLATE (" Bookmark all" ), new BMessage ((uint32) FINDWINDOW_BOOKMARKALL));
222+ fBookmarkAllButton ->SetExplicitMaxSize (BSize (B_SIZE_UNLIMITED, B_SIZE_UNSET));
229223
230224 fMatchCaseCB = new BCheckBox (" matchCase" , B_TRANSLATE (" Match case" ), new BMessage ((uint32) Actions::MATCH_CASE));
231225 fMatchWordCB = new BCheckBox (" matchWord" , B_TRANSLATE (" Match entire words" ), new BMessage ((uint32) Actions::MATCH_WORD));
@@ -249,6 +243,7 @@ FindWindow::_InitInterface()
249243 .Add (fReplaceButton )
250244 .Add (fReplaceFindButton )
251245 .Add (fReplaceAllButton )
246+ .Add (fBookmarkAllButton )
252247 .AddGlue ()
253248 .End ()
254249 .End ()
@@ -300,3 +295,21 @@ FindWindow::_SaveHistory()
300295 backupFileGuard.SaveSuccessful ();
301296 }
302297}
298+
299+
300+ void
301+ FindWindow::_AppendHistoryString (BMessage& historyMessage, std::string& itemString)
302+ {
303+ const int32 mruMax = 10 ;
304+ int32 count = 0 ;
305+ std::string lastItemString;
306+ if (historyMessage.GetInfo (" mru" , nullptr , &count) == B_OK) {
307+ lastItemString = historyMessage.GetString (" mru" , count - 1 , " " );
308+ }
309+ if (lastItemString != itemString)
310+ historyMessage.AddString (" mru" , itemString.c_str ());
311+ while (count >= mruMax) {
312+ historyMessage.RemoveData (" mru" , 0 );
313+ count--;
314+ }
315+ }
0 commit comments