From f83bebcddee0fe24c2058b9ec772278b298e94bd Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Thu, 24 Aug 2006 18:32:33 +0000 Subject: [PATCH] Save the settings of the find window when reopening it (just like R5's terminal) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18612 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/FindDlg.cpp | 17 +++++++++++++++-- src/apps/terminal/FindDlg.h | 3 ++- src/apps/terminal/TermWindow.cpp | 14 ++++++++------ src/apps/terminal/TermWindow.h | 2 ++ 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/apps/terminal/FindDlg.cpp b/src/apps/terminal/FindDlg.cpp index 0262025c36..ce7a6dbb7c 100644 --- a/src/apps/terminal/FindDlg.cpp +++ b/src/apps/terminal/FindDlg.cpp @@ -54,7 +54,8 @@ const uint32 MSG_FIND_HIDE = 'Fhid'; // FindDlg // Constructer ////////////////////////////////////////////////////////////////////////////// -FindDlg::FindDlg (BRect frame, TermWindow *win) +FindDlg::FindDlg (BRect frame, TermWindow *win , BString &str, + bool findselection, bool matchword, bool matchcase, bool forwardsearch) : BWindow(frame, "Find", B_FLOATING_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) { @@ -99,17 +100,23 @@ FindDlg::FindDlg (BRect frame, TermWindow *win) fTextRadio = new BRadioButton(BRect(14, textRadioTop, textRadioRight, textRadioBottom), "fTextRadio", "Use Text: ", NULL); fFindView->AddChild(fTextRadio); - fTextRadio->SetValue(1); //enable first option fFindLabel = new BTextControl(BRect(textRadioRight + 4, textRadioTop, frame.Width() - 14, textRadioBottom), "fFindLabel", "", "", NULL); fFindLabel->SetDivider(0); fFindView->AddChild(fFindLabel); + if (!findselection) + fFindLabel->SetText(str.String()); fFindLabel->MakeFocus(true); fSelectionRadio = new BRadioButton(BRect(14, selectionRadioTop, frame.Width() - 14, selectionRadioBottom), "fSelectionRadio", "Use Selection", NULL); fFindView->AddChild(fSelectionRadio); + + if (findselection) + fSelectionRadio->SetValue(B_CONTROL_ON); + else + fTextRadio->SetValue(B_CONTROL_ON); fSeparator = new BBox(BRect(6, dividerHeight, frame.Width() - 6, dividerHeight + 1)); fFindView->AddChild(fSeparator); @@ -117,14 +124,20 @@ FindDlg::FindDlg (BRect frame, TermWindow *win) fForwardSearchBox = new BCheckBox(BRect(14, forwardsearchTop, frame.Width() - 14, forwardsearchBottom), "fForwardSearchBox", "Search Forward", NULL); fFindView->AddChild(fForwardSearchBox); + if (forwardsearch) + fForwardSearchBox->SetValue(B_CONTROL_ON); fMatchCaseBox = new BCheckBox(BRect(14, matchcaseTop, frame.Width() - 14, matchcaseBottom), "fMatchCaseBox", "Match Case", NULL); fFindView->AddChild(fMatchCaseBox); + if (matchcase) + fMatchCaseBox->SetValue(B_CONTROL_ON); fMatchWordBox = new BCheckBox(BRect(14, matchwordTop, frame.Width() - 14, matchwordBottom), "fMatchWordBox", "Match Word", NULL); fFindView->AddChild(fMatchWordBox); + if (matchword) + fMatchWordBox->SetValue(B_CONTROL_ON); fFindButton = new BButton(BRect(searchbuttonLeft, buttonsTop, searchbuttonRight, frame.Height() - 14), "fFindButton", "Find", new BMessage(MSG_FIND)); diff --git a/src/apps/terminal/FindDlg.h b/src/apps/terminal/FindDlg.h index 2a380a88ae..d1eb6859c2 100644 --- a/src/apps/terminal/FindDlg.h +++ b/src/apps/terminal/FindDlg.h @@ -48,7 +48,8 @@ class BCheckBox; class FindDlg : public BWindow { public: - FindDlg (BRect frame, TermWindow *win); + FindDlg (BRect frame, TermWindow *win, BString &str, + bool findselection, bool matchword, bool matchcase, bool forwardsearch); ~FindDlg (); private: diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 80a93d8040..6110cb6a9d 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -178,6 +178,8 @@ TermWindow::InitWindow(void) // Init find parameters fMatchCase = false; fMatchWord = false; + fFindSelection = false; + fForwardSearch = false; // Initialize MessageRunner. fWindowUpdate = new BMessageRunner(BMessenger(this), @@ -285,7 +287,7 @@ TermWindow::MessageReceived(BMessage *message) BRect r; BFont halfFont; BFont fullFont; - bool findselection, forwardsearch, findresult; + bool findresult; switch (message->what) { case MENU_SWITCH_TERM: { @@ -319,7 +321,7 @@ TermWindow::MessageReceived(BMessage *message) r.top += 20; r.right = r.left + 260; r.bottom = r.top + 190; - fFindPanel = new FindDlg(r, this); + fFindPanel = new FindDlg(r, this, fFindString, fFindSelection, fMatchWord, fMatchCase, fForwardSearch); } else fFindPanel->Activate(); @@ -327,8 +329,8 @@ TermWindow::MessageReceived(BMessage *message) } case MSG_FIND: { fFindPanel->PostMessage(B_QUIT_REQUESTED); - message->FindBool("findselection", &findselection); - if (!findselection) + message->FindBool("findselection", &fFindSelection); + if (!fFindSelection) message->FindString("findstring", &fFindString); else fTermView->GetSelection(fFindString); @@ -342,10 +344,10 @@ TermWindow::MessageReceived(BMessage *message) break; } - message->FindBool("forwardsearch", &forwardsearch); + message->FindBool("forwardsearch", &fForwardSearch); message->FindBool("matchcase", &fMatchCase); message->FindBool("matchword", &fMatchWord); - findresult = fTermView->Find(fFindString, forwardsearch, fMatchCase, fMatchWord); + findresult = fTermView->Find(fFindString, fForwardSearch, fMatchCase, fMatchWord); if (!findresult) { BAlert *alert = new BAlert("find failed", "Not Found.", "Okay", NULL, diff --git a/src/apps/terminal/TermWindow.h b/src/apps/terminal/TermWindow.h index 7a32c8276d..4ee022b90c 100644 --- a/src/apps/terminal/TermWindow.h +++ b/src/apps/terminal/TermWindow.h @@ -91,6 +91,8 @@ private: BString fFindString; BMenuItem *fFindForwardMenuItem; BMenuItem *fFindBackwardMenuItem; + bool fFindSelection; + bool fForwardSearch; bool fMatchCase; bool fMatchWord; };