Skip to content

Commit

Permalink
reset blink when cursor updates (#483)
Browse files Browse the repository at this point in the history
* reset blink when cursor updates

* fix formatting
  • Loading branch information
AntonBogun authored Aug 9, 2023
1 parent e7ebdbc commit 0719849
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -372,6 +382,7 @@ struct Document {
isctrlshiftdrag = isctrlshift;
DrawSelectMove(dc, selected);
ResetCursor();
ResetBlink();
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
1 change: 1 addition & 0 deletions src/selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class Selection {
};
}
doc->DrawSelectMove(dc, *this);
doc->ResetBlink();
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ struct System {

// Refresh();

frame->bt.Start(400);
frame->bt.Start(BLINK_TIME);
every_second_timer.Start(1000);
}

Expand Down

0 comments on commit 0719849

Please sign in to comment.