The cursor didn't start blinking, unless the window was activated (by clicking outside and then inside the window).
Copied the BTextView mechanism: Activate and Deactivate the view on MakeFocus and WindowActivated. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34061 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
34bdaab8bd
commit
61646809a3
@ -170,6 +170,7 @@ TermView::TermView(BRect frame, int32 argc, const char** argv, int32 historySize
|
||||
fColumns(COLUMNS_DEFAULT),
|
||||
fRows(ROWS_DEFAULT),
|
||||
fEncoding(M_UTF8),
|
||||
fActive(false),
|
||||
fScrBufSize(historySize),
|
||||
fReportX10MouseEvent(false),
|
||||
fReportNormalMouseEvent(false),
|
||||
@ -187,6 +188,7 @@ TermView::TermView(int rows, int columns, int32 argc, const char** argv,
|
||||
fColumns(columns),
|
||||
fRows(rows),
|
||||
fEncoding(M_UTF8),
|
||||
fActive(false),
|
||||
fScrBufSize(historySize),
|
||||
fReportX10MouseEvent(false),
|
||||
fReportNormalMouseEvent(false),
|
||||
@ -215,6 +217,7 @@ TermView::TermView(BMessage* archive)
|
||||
fColumns(COLUMNS_DEFAULT),
|
||||
fRows(ROWS_DEFAULT),
|
||||
fEncoding(M_UTF8),
|
||||
fActive(false),
|
||||
fScrBufSize(1000),
|
||||
fReportX10MouseEvent(false),
|
||||
fReportNormalMouseEvent(false),
|
||||
@ -752,6 +755,33 @@ TermView::_DetachShell()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TermView::_Activate()
|
||||
{
|
||||
fActive = true;
|
||||
|
||||
if (fCursorBlinkRunner == NULL) {
|
||||
BMessage blinkMessage(kBlinkCursor);
|
||||
fCursorBlinkRunner = new (std::nothrow) BMessageRunner(
|
||||
BMessenger(this), &blinkMessage, kCursorBlinkInterval);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TermView::_Deactivate()
|
||||
{
|
||||
// DoIMConfirm();
|
||||
// make sure the cursor becomes visible
|
||||
fCursorState = 0;
|
||||
_InvalidateTextRect(fCursor.x, fCursor.y, fCursor.x, fCursor.y);
|
||||
delete fCursorBlinkRunner;
|
||||
fCursorBlinkRunner = NULL;
|
||||
|
||||
fActive = false;
|
||||
}
|
||||
|
||||
|
||||
//! Draw part of a line in the given view.
|
||||
void
|
||||
TermView::_DrawLinePart(int32 x1, int32 y1, uint16 attr, char *buf,
|
||||
@ -1111,21 +1141,27 @@ void
|
||||
TermView::WindowActivated(bool active)
|
||||
{
|
||||
BView::WindowActivated(active);
|
||||
if (active) {
|
||||
// start cursor blinking
|
||||
if (fCursorBlinkRunner == NULL) {
|
||||
BMessage blinkMessage(kBlinkCursor);
|
||||
fCursorBlinkRunner = new (std::nothrow) BMessageRunner(
|
||||
BMessenger(this), &blinkMessage, kCursorBlinkInterval);
|
||||
}
|
||||
if (active && IsFocus()) {
|
||||
if (!fActive)
|
||||
_Activate();
|
||||
} else {
|
||||
// DoIMConfirm();
|
||||
if (fActive)
|
||||
_Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the cursor becomes visible
|
||||
fCursorState = 0;
|
||||
_InvalidateTextRect(fCursor.x, fCursor.y, fCursor.x, fCursor.y);
|
||||
delete fCursorBlinkRunner;
|
||||
fCursorBlinkRunner = NULL;
|
||||
|
||||
void
|
||||
TermView::MakeFocus(bool focusState)
|
||||
{
|
||||
BView::MakeFocus(focusState);
|
||||
|
||||
if (focusState && Window() && Window()->IsActive()) {
|
||||
if (!fActive)
|
||||
_Activate();
|
||||
} else {
|
||||
if (fActive)
|
||||
_Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,7 @@ protected:
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void WindowActivated(bool active);
|
||||
virtual void MakeFocus(bool focusState = true);
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
|
||||
virtual void MouseDown(BPoint where);
|
||||
@ -122,6 +123,9 @@ private:
|
||||
status_t _AttachShell(Shell* shell);
|
||||
void _DetachShell();
|
||||
|
||||
void _Activate();
|
||||
void _Deactivate();
|
||||
|
||||
void _AboutRequested();
|
||||
|
||||
void _DrawLinePart(int32 x1, int32 y1, uint16 attr,
|
||||
@ -217,7 +221,7 @@ private:
|
||||
int fRows;
|
||||
|
||||
int fEncoding;
|
||||
|
||||
bool fActive;
|
||||
// Object pointer.
|
||||
TerminalBuffer* fTextBuffer;
|
||||
BasicTerminalBuffer* fVisibleTextBuffer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user