95 |
|
|
96 |
/* create new undo state at end of undo chain */ |
/* create new undo state at end of undo chain */ |
97 |
int undo_chain_length = 0; |
int undo_chain_length = 0; |
98 |
undo_state_t **undo_stateP = &appdata->undo_state; |
undo_state_t **undo_stateP = &appdata->undo.state; |
99 |
while(*undo_stateP) { |
while(*undo_stateP) { |
100 |
undo_chain_length++; |
undo_chain_length++; |
101 |
undo_stateP = &(*undo_stateP)->next; |
undo_stateP = &(*undo_stateP)->next; |
106 |
|
|
107 |
/* delete first entry if the chain is too long */ |
/* delete first entry if the chain is too long */ |
108 |
if(undo_chain_length >= UNDO_QUEUE_LEN) { |
if(undo_chain_length >= UNDO_QUEUE_LEN) { |
109 |
undo_state_t *second = appdata->undo_state->next; |
undo_state_t *second = appdata->undo.state->next; |
110 |
undo_state_free(appdata->undo_state); |
undo_state_free(appdata->undo.state); |
111 |
appdata->undo_state = second; |
appdata->undo.state = second; |
112 |
} |
} |
113 |
|
|
114 |
printf("UNDO: current chain length = %d\n", undo_chain_length); |
printf("UNDO: current chain length = %d\n", undo_chain_length); |
185 |
g_assert(orig); |
g_assert(orig); |
186 |
g_assert(orig->flags & OSM_FLAG_DELETED); |
g_assert(orig->flags & OSM_FLAG_DELETED); |
187 |
way_chain_t *wchain = |
way_chain_t *wchain = |
188 |
osm_node_delete(appdata->osm, NULL, orig, TRUE, TRUE); |
osm_node_delete(appdata->osm, &appdata->icon, orig, TRUE, TRUE); |
189 |
g_assert(!wchain); |
g_assert(!wchain); |
190 |
|
|
191 |
/* then restore old node */ |
/* then restore old node */ |
192 |
osm_node_dump(node); |
osm_node_dump(node); |
193 |
osm_node_restore(appdata->osm, node); |
osm_node_restore(appdata->osm, node); |
194 |
|
josm_elemstyles_colorize_node(appdata->map->style, node); |
195 |
map_node_draw(appdata->map, node); |
map_node_draw(appdata->map, node); |
196 |
obj->data.ptr = NULL; |
obj->data.ptr = NULL; |
197 |
} break; |
} break; |
220 |
|
|
221 |
/* undo the last undo_state */ |
/* undo the last undo_state */ |
222 |
void undo(appdata_t *appdata) { |
void undo(appdata_t *appdata) { |
223 |
undo_state_t *state = appdata->undo_state; |
undo_state_t *state = appdata->undo.state; |
224 |
printf("user selected undo\n"); |
printf("user selected undo\n"); |
225 |
|
|
226 |
/* search last (newest) entry */ |
/* search last (newest) entry */ |
245 |
} |
} |
246 |
|
|
247 |
/* remove this entry from chain */ |
/* remove this entry from chain */ |
248 |
undo_state_t **stateP = &appdata->undo_state; |
undo_state_t **stateP = &appdata->undo.state; |
249 |
while(*stateP && (*stateP)->next) stateP = &(*stateP)->next; |
while(*stateP && (*stateP)->next) stateP = &(*stateP)->next; |
250 |
|
|
251 |
undo_state_free(*stateP); |
undo_state_free(*stateP); |