Terminal: Move the find window under your cursor
on open moving the window back into the screen if necessary.
This commit is contained in:
@@ -98,8 +98,6 @@ FindWindow::FindWindow(BMessenger messenger, const BString& str,
|
|||||||
fFindButton->MakeDefault(true);
|
fFindButton->MakeDefault(true);
|
||||||
|
|
||||||
AddShortcut((uint32)'W', B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE));
|
AddShortcut((uint32)'W', B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE));
|
||||||
|
|
||||||
Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <PrintJob.h>
|
#include <PrintJob.h>
|
||||||
|
#include <Rect.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
@@ -730,9 +731,32 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MENU_FIND_STRING:
|
case MENU_FIND_STRING:
|
||||||
if (!fFindPanel) {
|
if (fFindPanel == NULL) {
|
||||||
fFindPanel = new FindWindow(this, fFindString, fFindSelection,
|
fFindPanel = new FindWindow(this, fFindString, fFindSelection,
|
||||||
fMatchWord, fMatchCase, fForwardSearch);
|
fMatchWord, fMatchCase, fForwardSearch);
|
||||||
|
|
||||||
|
// position the window under the mouse pointer
|
||||||
|
BPoint where;
|
||||||
|
uint32 buttons;
|
||||||
|
ChildAt(0)->GetMouse(&where, &buttons);
|
||||||
|
fFindPanel->MoveTo(ConvertToScreen(where));
|
||||||
|
|
||||||
|
// move window if outside of screen frame
|
||||||
|
BRect screenFrame = (BScreen(this)).Frame();
|
||||||
|
BRect frame = fFindPanel->Frame();
|
||||||
|
float extra = 30.0f;
|
||||||
|
if (frame.bottom + extra * 2 > screenFrame.bottom) {
|
||||||
|
fFindPanel->MoveBy(0,
|
||||||
|
screenFrame.bottom - frame.bottom - extra * 2);
|
||||||
|
} else if (frame.top - extra < screenFrame.top)
|
||||||
|
fFindPanel->MoveBy(0, screenFrame.top - frame.top + extra);
|
||||||
|
|
||||||
|
if (frame.right + extra > screenFrame.right) {
|
||||||
|
fFindPanel->MoveBy(screenFrame.right - frame.right
|
||||||
|
- extra, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fFindPanel->Show();
|
||||||
} else
|
} else
|
||||||
fFindPanel->Activate();
|
fFindPanel->Activate();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user