Terminal: Make blinking cursor settings live
Change-Id: I51b2f4753c4c331c075293a7d531b26a2fbdc457 Reviewed-on: https://review.haiku-os.org/479 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
@@ -774,7 +774,8 @@ TermView::SetTermFont(const BFont *font)
|
|||||||
|
|
||||||
fCursorStyle = PrefHandler::Default() == NULL ? BLOCK_CURSOR
|
fCursorStyle = PrefHandler::Default() == NULL ? BLOCK_CURSOR
|
||||||
: PrefHandler::Default()->getCursor(PREF_CURSOR_STYLE);
|
: PrefHandler::Default()->getCursor(PREF_CURSOR_STYLE);
|
||||||
fCursorBlinking = PrefHandler::Default()->getBool(PREF_BLINK_CURSOR);
|
bool blinking = PrefHandler::Default()->getBool(PREF_BLINK_CURSOR);
|
||||||
|
SwitchCursorBlinking(blinking);
|
||||||
|
|
||||||
fEmulateBold = PrefHandler::Default() == NULL ? false
|
fEmulateBold = PrefHandler::Default() == NULL ? false
|
||||||
: PrefHandler::Default()->getBool(PREF_EMULATE_BOLD);
|
: PrefHandler::Default()->getBool(PREF_EMULATE_BOLD);
|
||||||
@@ -797,6 +798,26 @@ TermView::SetScrollBar(BScrollBar *scrollBar)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TermView::SwitchCursorBlinking(bool blinkingOn)
|
||||||
|
{
|
||||||
|
fCursorBlinking = blinkingOn;
|
||||||
|
if (blinkingOn) {
|
||||||
|
if (fCursorBlinkRunner == NULL) {
|
||||||
|
BMessage blinkMessage(kBlinkCursor);
|
||||||
|
fCursorBlinkRunner = new (std::nothrow) BMessageRunner(
|
||||||
|
BMessenger(this), &blinkMessage, kCursorBlinkInterval);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// make sure the cursor becomes visible
|
||||||
|
fCursorState = 0;
|
||||||
|
_InvalidateTextRect(fCursor.x, fCursor.y, fCursor.x, fCursor.y);
|
||||||
|
delete fCursorBlinkRunner;
|
||||||
|
fCursorBlinkRunner = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::Copy(BClipboard *clipboard)
|
TermView::Copy(BClipboard *clipboard)
|
||||||
{
|
{
|
||||||
@@ -914,30 +935,11 @@ TermView::_DetachShell()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TermView::_SwitchCursorBlinking(bool blinkingOn)
|
|
||||||
{
|
|
||||||
if (blinkingOn) {
|
|
||||||
if (fCursorBlinkRunner == NULL) {
|
|
||||||
BMessage blinkMessage(kBlinkCursor);
|
|
||||||
fCursorBlinkRunner = new (std::nothrow) BMessageRunner(
|
|
||||||
BMessenger(this), &blinkMessage, kCursorBlinkInterval);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// make sure the cursor becomes visible
|
|
||||||
fCursorState = 0;
|
|
||||||
_InvalidateTextRect(fCursor.x, fCursor.y, fCursor.x, fCursor.y);
|
|
||||||
delete fCursorBlinkRunner;
|
|
||||||
fCursorBlinkRunner = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::_Activate()
|
TermView::_Activate()
|
||||||
{
|
{
|
||||||
fActive = true;
|
fActive = true;
|
||||||
_SwitchCursorBlinking(fCursorBlinking);
|
SwitchCursorBlinking(fCursorBlinking);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -948,7 +950,7 @@ TermView::_Deactivate()
|
|||||||
fCursorState = 0;
|
fCursorState = 0;
|
||||||
_InvalidateTextRect(fCursor.x, fCursor.y, fCursor.x, fCursor.y);
|
_InvalidateTextRect(fCursor.x, fCursor.y, fCursor.x, fCursor.y);
|
||||||
|
|
||||||
_SwitchCursorBlinking(false);
|
SwitchCursorBlinking(false);
|
||||||
|
|
||||||
fActive = false;
|
fActive = false;
|
||||||
}
|
}
|
||||||
@@ -1792,10 +1794,8 @@ TermView::MessageReceived(BMessage *msg)
|
|||||||
fCursorStyle = style;
|
fCursorStyle = style;
|
||||||
|
|
||||||
bool blinking = fCursorBlinking;
|
bool blinking = fCursorBlinking;
|
||||||
if (msg->FindBool("blinking", &blinking) == B_OK) {
|
if (msg->FindBool("blinking", &blinking) == B_OK)
|
||||||
fCursorBlinking = blinking;
|
SwitchCursorBlinking(blinking);
|
||||||
_SwitchCursorBlinking(fCursorBlinking);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hidden = fCursorHidden;
|
bool hidden = fCursorHidden;
|
||||||
if (msg->FindBool("hidden", &hidden) == B_OK)
|
if (msg->FindBool("hidden", &hidden) == B_OK)
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ public:
|
|||||||
void MakeDebugSnapshots();
|
void MakeDebugSnapshots();
|
||||||
void StartStopDebugCapture();
|
void StartStopDebugCapture();
|
||||||
|
|
||||||
|
void SwitchCursorBlinking(bool blinkingOn);
|
||||||
|
|
||||||
// edit functions
|
// edit functions
|
||||||
void Copy(BClipboard* clipboard);
|
void Copy(BClipboard* clipboard);
|
||||||
void Paste(BClipboard* clipboard);
|
void Paste(BClipboard* clipboard);
|
||||||
@@ -191,7 +193,6 @@ private:
|
|||||||
|
|
||||||
void _Activate();
|
void _Activate();
|
||||||
void _Deactivate();
|
void _Deactivate();
|
||||||
void _SwitchCursorBlinking(bool blinkingOn);
|
|
||||||
|
|
||||||
void _DrawLinePart(int32 x1, int32 y1, uint32 attr,
|
void _DrawLinePart(int32 x1, int32 y1, uint32 attr,
|
||||||
char* buffer, int32 width,
|
char* buffer, int32 width,
|
||||||
|
|||||||
@@ -838,6 +838,18 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case MSG_BLINK_CURSOR_CHANGED:
|
||||||
|
{
|
||||||
|
bool blinkingCursor
|
||||||
|
= PrefHandler::Default()->getBool(PREF_BLINK_CURSOR);
|
||||||
|
|
||||||
|
for (int32 i = 0; i < fTabView->CountTabs(); i++) {
|
||||||
|
TermView* view = _TermViewAt(i);
|
||||||
|
view->SwitchCursorBlinking(blinkingCursor);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MSG_HALF_FONT_CHANGED:
|
case MSG_HALF_FONT_CHANGED:
|
||||||
case MSG_FULL_FONT_CHANGED:
|
case MSG_FULL_FONT_CHANGED:
|
||||||
case MSG_ALLOW_BOLD_CHANGED:
|
case MSG_ALLOW_BOLD_CHANGED:
|
||||||
|
|||||||
Reference in New Issue
Block a user