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
This commit is contained in:
@@ -54,7 +54,8 @@ const uint32 MSG_FIND_HIDE = 'Fhid';
|
|||||||
// FindDlg
|
// FindDlg
|
||||||
// Constructer
|
// 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",
|
: BWindow(frame, "Find",
|
||||||
B_FLOATING_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
|
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 = new BRadioButton(BRect(14, textRadioTop, textRadioRight, textRadioBottom),
|
||||||
"fTextRadio", "Use Text: ", NULL);
|
"fTextRadio", "Use Text: ", NULL);
|
||||||
fFindView->AddChild(fTextRadio);
|
fFindView->AddChild(fTextRadio);
|
||||||
fTextRadio->SetValue(1); //enable first option
|
|
||||||
|
|
||||||
fFindLabel = new BTextControl(BRect(textRadioRight + 4, textRadioTop, frame.Width() - 14, textRadioBottom),
|
fFindLabel = new BTextControl(BRect(textRadioRight + 4, textRadioTop, frame.Width() - 14, textRadioBottom),
|
||||||
"fFindLabel", "", "", NULL);
|
"fFindLabel", "", "", NULL);
|
||||||
fFindLabel->SetDivider(0);
|
fFindLabel->SetDivider(0);
|
||||||
fFindView->AddChild(fFindLabel);
|
fFindView->AddChild(fFindLabel);
|
||||||
|
if (!findselection)
|
||||||
|
fFindLabel->SetText(str.String());
|
||||||
fFindLabel->MakeFocus(true);
|
fFindLabel->MakeFocus(true);
|
||||||
|
|
||||||
fSelectionRadio = new BRadioButton(BRect(14, selectionRadioTop, frame.Width() - 14, selectionRadioBottom),
|
fSelectionRadio = new BRadioButton(BRect(14, selectionRadioTop, frame.Width() - 14, selectionRadioBottom),
|
||||||
"fSelectionRadio", "Use Selection", NULL);
|
"fSelectionRadio", "Use Selection", NULL);
|
||||||
fFindView->AddChild(fSelectionRadio);
|
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));
|
fSeparator = new BBox(BRect(6, dividerHeight, frame.Width() - 6, dividerHeight + 1));
|
||||||
fFindView->AddChild(fSeparator);
|
fFindView->AddChild(fSeparator);
|
||||||
@@ -117,14 +124,20 @@ FindDlg::FindDlg (BRect frame, TermWindow *win)
|
|||||||
fForwardSearchBox = new BCheckBox(BRect(14, forwardsearchTop, frame.Width() - 14, forwardsearchBottom),
|
fForwardSearchBox = new BCheckBox(BRect(14, forwardsearchTop, frame.Width() - 14, forwardsearchBottom),
|
||||||
"fForwardSearchBox", "Search Forward", NULL);
|
"fForwardSearchBox", "Search Forward", NULL);
|
||||||
fFindView->AddChild(fForwardSearchBox);
|
fFindView->AddChild(fForwardSearchBox);
|
||||||
|
if (forwardsearch)
|
||||||
|
fForwardSearchBox->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
fMatchCaseBox = new BCheckBox(BRect(14, matchcaseTop, frame.Width() - 14, matchcaseBottom),
|
fMatchCaseBox = new BCheckBox(BRect(14, matchcaseTop, frame.Width() - 14, matchcaseBottom),
|
||||||
"fMatchCaseBox", "Match Case", NULL);
|
"fMatchCaseBox", "Match Case", NULL);
|
||||||
fFindView->AddChild(fMatchCaseBox);
|
fFindView->AddChild(fMatchCaseBox);
|
||||||
|
if (matchcase)
|
||||||
|
fMatchCaseBox->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
fMatchWordBox = new BCheckBox(BRect(14, matchwordTop, frame.Width() - 14, matchwordBottom),
|
fMatchWordBox = new BCheckBox(BRect(14, matchwordTop, frame.Width() - 14, matchwordBottom),
|
||||||
"fMatchWordBox", "Match Word", NULL);
|
"fMatchWordBox", "Match Word", NULL);
|
||||||
fFindView->AddChild(fMatchWordBox);
|
fFindView->AddChild(fMatchWordBox);
|
||||||
|
if (matchword)
|
||||||
|
fMatchWordBox->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
fFindButton = new BButton(BRect(searchbuttonLeft, buttonsTop, searchbuttonRight, frame.Height() - 14),
|
fFindButton = new BButton(BRect(searchbuttonLeft, buttonsTop, searchbuttonRight, frame.Height() - 14),
|
||||||
"fFindButton", "Find", new BMessage(MSG_FIND));
|
"fFindButton", "Find", new BMessage(MSG_FIND));
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ class BCheckBox;
|
|||||||
class FindDlg : public BWindow
|
class FindDlg : public BWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FindDlg (BRect frame, TermWindow *win);
|
FindDlg (BRect frame, TermWindow *win, BString &str,
|
||||||
|
bool findselection, bool matchword, bool matchcase, bool forwardsearch);
|
||||||
~FindDlg ();
|
~FindDlg ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -178,6 +178,8 @@ TermWindow::InitWindow(void)
|
|||||||
// Init find parameters
|
// Init find parameters
|
||||||
fMatchCase = false;
|
fMatchCase = false;
|
||||||
fMatchWord = false;
|
fMatchWord = false;
|
||||||
|
fFindSelection = false;
|
||||||
|
fForwardSearch = false;
|
||||||
|
|
||||||
// Initialize MessageRunner.
|
// Initialize MessageRunner.
|
||||||
fWindowUpdate = new BMessageRunner(BMessenger(this),
|
fWindowUpdate = new BMessageRunner(BMessenger(this),
|
||||||
@@ -285,7 +287,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
BRect r;
|
BRect r;
|
||||||
BFont halfFont;
|
BFont halfFont;
|
||||||
BFont fullFont;
|
BFont fullFont;
|
||||||
bool findselection, forwardsearch, findresult;
|
bool findresult;
|
||||||
|
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case MENU_SWITCH_TERM: {
|
case MENU_SWITCH_TERM: {
|
||||||
@@ -319,7 +321,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
r.top += 20;
|
r.top += 20;
|
||||||
r.right = r.left + 260;
|
r.right = r.left + 260;
|
||||||
r.bottom = r.top + 190;
|
r.bottom = r.top + 190;
|
||||||
fFindPanel = new FindDlg(r, this);
|
fFindPanel = new FindDlg(r, this, fFindString, fFindSelection, fMatchWord, fMatchCase, fForwardSearch);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fFindPanel->Activate();
|
fFindPanel->Activate();
|
||||||
@@ -327,8 +329,8 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
case MSG_FIND: {
|
case MSG_FIND: {
|
||||||
fFindPanel->PostMessage(B_QUIT_REQUESTED);
|
fFindPanel->PostMessage(B_QUIT_REQUESTED);
|
||||||
message->FindBool("findselection", &findselection);
|
message->FindBool("findselection", &fFindSelection);
|
||||||
if (!findselection)
|
if (!fFindSelection)
|
||||||
message->FindString("findstring", &fFindString);
|
message->FindString("findstring", &fFindString);
|
||||||
else
|
else
|
||||||
fTermView->GetSelection(fFindString);
|
fTermView->GetSelection(fFindString);
|
||||||
@@ -342,10 +344,10 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
message->FindBool("forwardsearch", &forwardsearch);
|
message->FindBool("forwardsearch", &fForwardSearch);
|
||||||
message->FindBool("matchcase", &fMatchCase);
|
message->FindBool("matchcase", &fMatchCase);
|
||||||
message->FindBool("matchword", &fMatchWord);
|
message->FindBool("matchword", &fMatchWord);
|
||||||
findresult = fTermView->Find(fFindString, forwardsearch, fMatchCase, fMatchWord);
|
findresult = fTermView->Find(fFindString, fForwardSearch, fMatchCase, fMatchWord);
|
||||||
|
|
||||||
if (!findresult) {
|
if (!findresult) {
|
||||||
BAlert *alert = new BAlert("find failed", "Not Found.", "Okay", NULL,
|
BAlert *alert = new BAlert("find failed", "Not Found.", "Okay", NULL,
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ private:
|
|||||||
BString fFindString;
|
BString fFindString;
|
||||||
BMenuItem *fFindForwardMenuItem;
|
BMenuItem *fFindForwardMenuItem;
|
||||||
BMenuItem *fFindBackwardMenuItem;
|
BMenuItem *fFindBackwardMenuItem;
|
||||||
|
bool fFindSelection;
|
||||||
|
bool fForwardSearch;
|
||||||
bool fMatchCase;
|
bool fMatchCase;
|
||||||
bool fMatchWord;
|
bool fMatchWord;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user