aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-02-04 20:16:54 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-02-04 20:16:54 +0100
commitbf9fc971602cff5907528da14cb6428a971b598f (patch)
tree18802720b1266fba72326dd2c0517f2485c70f01
parent8f755d71be03c11be6669afe9b6ae25537952da1 (diff)
downloadvis-bf9fc971602cff5907528da14cb6428a971b598f.tar.gz
vis-bf9fc971602cff5907528da14cb6428a971b598f.tar.xz
view: reduce redraws upon selection changes
-rw-r--r--view.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/view.c b/view.c
index 1985f58..2992d95 100644
--- a/view.c
+++ b/view.c
@@ -1249,7 +1249,7 @@ void view_cursors_selection_start(Cursor *c) {
Text *txt = c->view->text;
c->sel->anchor = text_mark_set(txt, pos);
c->sel->cursor = c->sel->anchor;
- view_draw(c->view);
+ c->view->need_update = true;
}
void view_cursors_selection_restore(Cursor *c) {
@@ -1266,8 +1266,6 @@ void view_cursors_selection_restore(Cursor *c) {
if (!(c->sel = view_selections_new(c->view, c)))
return;
view_selections_set(c->sel, &sel);
- view_cursors_selection_sync(c);
- view_draw(c->view);
}
void view_cursors_selection_stop(Cursor *c) {
@@ -1276,7 +1274,7 @@ void view_cursors_selection_stop(Cursor *c) {
void view_cursors_selection_clear(Cursor *c) {
view_selections_free(c->sel);
- view_draw(c->view);
+ c->view->need_update = true;
}
void view_cursors_selection_swap(Cursor *c) {
@@ -1301,13 +1299,15 @@ Filerange view_cursors_selection_get(Cursor *c) {
void view_cursors_selection_set(Cursor *c, const Filerange *r) {
if (!text_range_valid(r))
return;
- if (!c->sel && !(c->sel = view_selections_new(c->view, c)))
+ bool new = !c->sel;
+ if (new && !(c->sel = view_selections_new(c->view, c)))
return;
-
view_selections_set(c->sel, r);
- size_t pos = view_cursors_pos(c);
- if (!text_range_contains(r, pos))
- view_cursors_selection_sync(c);
+ if (!new) {
+ size_t pos = view_cursors_pos(c);
+ if (!text_range_contains(r, pos))
+ view_cursors_selection_sync(c);
+ }
}
Selection *view_selections_new(View *view, Cursor *c) {
@@ -1409,7 +1409,7 @@ void view_selections_set(Selection *s, const Filerange *r) {
s->anchor = text_mark_set(txt, r->start);
s->cursor = text_mark_set(txt, end);
}
- view_draw(s->view);
+ s->view->need_update = true;
}
Text *view_text(View *view) {