Skip to content

Commit e9ff237

Browse files
committed
undo: have a single delta for both undo and redo
1 parent 8323ec1 commit e9ff237

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

include/clap/ext/draft/undo.h

+20-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "../../plugin.h"
44

5-
static CLAP_CONSTEXPR const char CLAP_EXT_UNDO[] = "clap.undo/2";
5+
static CLAP_CONSTEXPR const char CLAP_EXT_UNDO[] = "clap.undo/3";
66

77
#ifdef __cplusplus
88
extern "C" {
@@ -76,14 +76,23 @@ typedef struct clap_plugin_undo {
7676
bool(CLAP_ABI *can_use_delta_format_version)(const clap_plugin_t *plugin,
7777
clap_id format_version);
7878

79-
// Applies synchronously a delta.
79+
// Undo using the delta.
8080
// Returns true on success.
8181
//
8282
// [main-thread]
83-
bool(CLAP_ABI *apply_delta)(const clap_plugin_t *plugin,
84-
clap_id format_version,
85-
const void *delta,
86-
size_t delta_size);
83+
bool(CLAP_ABI *undo)(const clap_plugin_t *plugin,
84+
clap_id format_version,
85+
const void *delta,
86+
size_t delta_size);
87+
88+
// Redo using the delta.
89+
// Returns true on success.
90+
//
91+
// [main-thread]
92+
bool(CLAP_ABI *redo)(const clap_plugin_t *plugin,
93+
clap_id format_version,
94+
const void *delta,
95+
size_t delta_size);
8796

8897
// Sets the undo context.
8998
// flags: bitmask of clap_undo_context_flags values
@@ -112,7 +121,7 @@ typedef struct clap_host_undo {
112121
//
113122
// name: mandatory null terminated string describing the change, this is displayed to the user
114123
//
115-
// deltas: optional, they are binary blobs used to perform the undo and redo. When not available
124+
// delta: optional, it is a binary blobs used to perform the undo and redo. When not available
116125
// the host will save the plugin state and use state->load() to perform undo and redo.
117126
//
118127
// Note: the provided delta may be used for incremental state saving and crash recovery. The
@@ -128,18 +137,16 @@ typedef struct clap_host_undo {
128137
// [main-thread]
129138
void(CLAP_ABI *change_made)(const clap_host_t *host,
130139
const char *name,
131-
const void *redo_delta,
132-
size_t redo_delta_size,
133-
const void *undo_delta,
134-
size_t undo_delta_size);
140+
const void *delta,
141+
size_t delta_size);
135142

136143
// Asks the host to perform the next undo step.
137-
// This operation may be asynchronous.
144+
// This operation may be asynchronous and isn't available while the host is within a change.
138145
// [main-thread]
139146
void(CLAP_ABI *undo)(const clap_host_t *host);
140147

141148
// Asks the host to perform the next redo step.
142-
// This operation may be asynchronous.
149+
// This operation may be asynchronous and isn't available while the host is within a change.
143150
// [main-thread]
144151
void(CLAP_ABI *redo)(const clap_host_t *host);
145152

0 commit comments

Comments
 (0)