summaryrefslogtreecommitdiffstats
path: root/src/interp.c
diff options
context:
space:
mode:
authorAndrés <andmarti@gmail.com>2021-04-01 13:00:10 -0300
committerAndrés <andmarti@gmail.com>2021-04-01 13:00:10 -0300
commit8e397ff0d4df30db3ea429052968a44862531576 (patch)
tree8095431eb9bc684dc1013f9c4f8e734c7d31aa46 /src/interp.c
parent877aecba58951524cc549a02f1e86143f22a0b6e (diff)
Revert "Improve undo / yank using malloc for batches"
Diffstat (limited to 'src/interp.c')
-rw-r--r--src/interp.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/src/interp.c b/src/interp.c
index b1483e4..b26ca62 100644
--- a/src/interp.c
+++ b/src/interp.c
@@ -2342,7 +2342,7 @@ void fill(struct ent *v1, struct ent *v2, double start, double inc) {
#ifdef UNDO
create_undo_action();
- copy_to_undostruct(minr, minc, maxr, maxc, UNDO_DEL, IGNORE_DEPS, NULL);
+ copy_to_undostruct(minr, minc, maxr, maxc, UNDO_DEL);
#endif
if (calc_order == BYROWS) {
@@ -2372,7 +2372,7 @@ void fill(struct ent *v1, struct ent *v2, double start, double inc) {
sc_error(" Internal error calc_order");
}
#ifdef UNDO
- copy_to_undostruct(minr, minc, maxr, maxc, UNDO_ADD, IGNORE_DEPS, NULL);
+ copy_to_undostruct(minr, minc, maxr, maxc, UNDO_ADD);
end_undo_action();
#endif
}
@@ -2404,7 +2404,7 @@ void lock_cells(struct ent * v1, struct ent * v2) {
#ifdef UNDO
create_undo_action();
- copy_to_undostruct(minr, minc, maxr, maxc, UNDO_DEL, IGNORE_DEPS, NULL);
+ copy_to_undostruct(minr, minc, maxr, maxc, UNDO_DEL);
#endif
for (r = minr; r <= maxr; r++)
for (c = minc; c <= maxc; c++) {
@@ -2412,7 +2412,7 @@ void lock_cells(struct ent * v1, struct ent * v2) {
n->flags |= is_locked;
}
#ifdef UNDO
- copy_to_undostruct(minr, minc, maxr, maxc, UNDO_ADD, IGNORE_DEPS, NULL);
+ copy_to_undostruct(minr, minc, maxr, maxc, UNDO_ADD);
end_undo_action();
#endif
}
@@ -2444,7 +2444,7 @@ void unlock_cells(struct ent * v1, struct ent * v2) {
#ifdef UNDO
create_undo_action();
- copy_to_undostruct(minr, minc, maxr, maxc, UNDO_DEL, IGNORE_DEPS, NULL);
+ copy_to_undostruct(minr, minc, maxr, maxc, UNDO_DEL);
#endif
for (r = minr; r <= maxr; r++)
for (c = minc; c <= maxc; c++) {
@@ -2452,7 +2452,7 @@ void unlock_cells(struct ent * v1, struct ent * v2) {
n->flags &= ~is_locked;
}
#ifdef UNDO
- copy_to_undostruct(minr, minc, maxr, maxc, UNDO_ADD, IGNORE_DEPS, NULL);
+ copy_to_undostruct(minr, minc, maxr, maxc, UNDO_ADD);
end_undo_action();
#endif
}
@@ -2472,12 +2472,17 @@ void let(struct ent * v, struct enode * e) {
if (locked_cell(v->row, v->col)) return;
#ifdef UNDO
+ int i;
extern struct ent_ptr * deps;
if (!loading) {
create_undo_action();
+ copy_to_undostruct(v->row, v->col, v->row, v->col, UNDO_DEL);
+
// here we save in undostruct, all the ents that depends on the deleted one (before change)
ents_that_depends_on_range(v->row, v->col, v->row, v->col);
- copy_to_undostruct(v->row, v->col, v->row, v->col, UNDO_DEL, HANDLE_DEPS, NULL);
+ if (deps != NULL)
+ for (i = 0; i < deps->vf; i++)
+ copy_to_undostruct(deps[i].vp->row, deps[i].vp->col, deps[i].vp->row, deps[i].vp->col, UNDO_DEL);
}
#endif
//if (getVertex(graph, lookat(v->row, v->col), 0) != NULL) {
@@ -2552,9 +2557,11 @@ void let(struct ent * v, struct enode * e) {
}
#ifdef UNDO
if (!loading) {
- // here we also save in undostruct, all the ents that depends on the deleted ones (after change)
- copy_to_undostruct(v->row, v->col, v->row, v->col, UNDO_ADD, HANDLE_DEPS, NULL);
+ copy_to_undostruct(v->row, v->col, v->row, v->col, UNDO_ADD);
+ // here we save in undostruct, all the ents that depends on the deleted one (after change)
if (deps != NULL) {
+ for (i = 0; i < deps->vf; i++)
+ copy_to_undostruct(deps[i].vp->row, deps[i].vp->col, deps[i].vp->row, deps[i].vp->col, UNDO_ADD);
free(deps);
deps = NULL;
}
@@ -2580,11 +2587,15 @@ void slet(struct ent * v, struct enode * se, int flushdir) {
#ifdef UNDO
extern struct ent_ptr * deps;
+ int i;
if (!loading) {
+ create_undo_action();
+ copy_to_undostruct(v->row, v->col, v->row, v->col, UNDO_DEL);
+
// here we save in undostruct, all the ents that depends on the deleted one (before change)
ents_that_depends_on_range(v->row, v->col, v->row, v->col);
- create_undo_action();
- copy_to_undostruct(v->row, v->col, v->row, v->col, UNDO_DEL, HANDLE_DEPS, NULL);
+ for (i = 0; deps != NULL && i < deps->vf; i++)
+ copy_to_undostruct(deps[i].vp->row, deps[i].vp->col, deps[i].vp->row, deps[i].vp->col, UNDO_DEL);
}
#endif
// No debe borrarse el vertex. Ver comentario en LET
@@ -2641,17 +2652,19 @@ void slet(struct ent * v, struct enode * se, int flushdir) {
modflg++;
if (( v->trigger ) && ((v->trigger->flag & TRG_WRITE) == TRG_WRITE)) do_trigger(v,TRG_WRITE);
-#ifdef UNDO
+ #ifdef UNDO
if (!loading) {
- // here we also save in undostruct, all the ents that depends on the deleted ones (after change)
- copy_to_undostruct(v->row, v->col, v->row, v->col, UNDO_ADD, HANDLE_DEPS, NULL);
+ copy_to_undostruct(v->row, v->col, v->row, v->col, UNDO_ADD);
+ // here we save in undostruct, all the ents that depends on the deleted one (after change)
if (deps != NULL) {
+ for (i = 0; i < deps->vf; i++)
+ copy_to_undostruct(deps[i].vp->row, deps[i].vp->col, deps[i].vp->row, deps[i].vp->col, UNDO_ADD);
free(deps);
deps = NULL;
}
end_undo_action();
}
-#endif
+ #endif
return;
}
@@ -3344,7 +3357,7 @@ int dateformat(struct ent *v1, struct ent *v2, char * fmt) {
#ifdef UNDO
create_undo_action();
- copy_to_undostruct(minr, minc, maxr, maxc, UNDO_DEL, IGNORE_DEPS, NULL);
+ copy_to_undostruct(minr, minc, maxr, maxc, UNDO_DEL);
#endif
for (r = minr; r <= maxr; r++) {
for (c = minc; c <= maxc; c++) {
@@ -3372,7 +3385,7 @@ int dateformat(struct ent *v1, struct ent *v2, char * fmt) {
}
}
#ifdef UNDO
- copy_to_undostruct(minr, minc, maxr, maxc, UNDO_ADD, IGNORE_DEPS, NULL);
+ copy_to_undostruct(minr, minc, maxr, maxc, UNDO_DEL);
end_undo_action();
#endif
modflg++; // increase just one time