From 0719849bf72f1e5631e6423145b6ccaf076fba5d Mon Sep 17 00:00:00 2001 From: AntonBogun <70374466+AntonBogun@users.noreply.github.com> Date: Wed, 9 Aug 2023 04:00:52 +0300 Subject: [PATCH] reset blink when cursor updates (#483) * reset blink when cursor updates * fix formatting --- src/document.h | 15 +++++++++++++-- src/main.cpp | 1 + src/selection.h | 1 + src/system.h | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/document.h b/src/document.h index cd43664d..3681d4a6 100755 --- a/src/document.h +++ b/src/document.h @@ -325,18 +325,28 @@ struct Document { } } - void Blink() { + void HandleBlink(bool reset) { if (redrawpending) return; #ifndef SIMPLERENDER wxClientDC dc(sw); sw->DoPrepareDC(dc); ShiftToCenter(dc); DrawSelect(dc, selected, false, true); - blink = !blink; + if (reset) blink = 1; + else blink = !blink; DrawSelect(dc, selected, true, true); #endif } + void Blink() { + HandleBlink(false); + } + + void ResetBlink() { + sys->frame->bt.Start(BLINK_TIME); + HandleBlink(true); + } + void ResetCursor() { if (selected.g) selected.SetCursorEdit(this, selected.TextEdit()); } @@ -372,6 +382,7 @@ struct Document { isctrlshiftdrag = isctrlshift; DrawSelectMove(dc, selected); ResetCursor(); + ResetBlink(); return; } diff --git a/src/main.cpp b/src/main.cpp index 218e0fc8..6e513406 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,6 +18,7 @@ static const int g_max_launches = 20; static const int g_deftextsize_default = 12; static const int g_mintextsize_delta = 8; static const int g_maxtextsize_delta = 32; +static const int BLINK_TIME = 400; static int g_deftextsize = g_deftextsize_default; static int g_mintextsize() { return g_deftextsize - g_mintextsize_delta; } diff --git a/src/selection.h b/src/selection.h index 12c733ce..749cbc7d 100755 --- a/src/selection.h +++ b/src/selection.h @@ -284,6 +284,7 @@ class Selection { }; } doc->DrawSelectMove(dc, *this); + doc->ResetBlink(); }; } diff --git a/src/system.h b/src/system.h index 1c76f0bc..d9c55604 100755 --- a/src/system.h +++ b/src/system.h @@ -193,7 +193,7 @@ struct System { // Refresh(); - frame->bt.Start(400); + frame->bt.Start(BLINK_TIME); every_second_timer.Start(1000); }