gpforge
An advanced bitmap font editor
Loading...
Searching...
No Matches
undo.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright (C) 2026 Cyril Hrubis <metan@ucw.cz>
4 */
18#ifndef GPFORGE_UNDO_H
19#define GPFORGE_UNDO_H
20
21#include "font.h"
22
23struct gpf_undo;
24
31struct gpf_undo *gpf_undo_new(void);
32
38void gpf_undo_free(struct gpf_undo *self);
39
51void gpf_undo_group_begin(struct gpf_undo *self);
52
64void gpf_undo_group_end(struct gpf_undo *self);
65
79int gpf_undo_begin(struct gpf_undo *self, struct gpf_font *font,
80 enum gpf_variant_id id, uint32_t code);
81
96int gpf_undo_retarget(struct gpf_undo *self, struct gpf_font *font,
97 enum gpf_variant_id id, uint32_t code);
98
107void gpf_undo_commit(struct gpf_undo *self, struct gpf_font *font);
108
124int gpf_undo_family(struct gpf_undo *self, struct gpf_font *font,
125 const struct gpf_family_meta *meta,
126 const struct gpf_author *authors);
127
143
155enum gpf_undo_what gpf_undo(struct gpf_undo *self, struct gpf_font *font,
156 enum gpf_variant_id *id, uint32_t *code);
157
169enum gpf_undo_what gpf_redo(struct gpf_undo *self, struct gpf_font *font,
170 enum gpf_variant_id *id, uint32_t *code);
171
180void gpf_undo_saved(struct gpf_undo *self);
181
191int gpf_undo_is_saved(struct gpf_undo *self);
192
199int gpf_undo_can_undo(struct gpf_undo *self);
200
207int gpf_undo_can_redo(struct gpf_undo *self);
208
209#endif /* GPFORGE_UNDO_H */
The in-memory font model.
gpf_variant_id
Font face variant.
Definition font.h:34
A font author, one author line of the family file.
Definition font.h:218
Font family meta data.
Definition font.h:230
A font family.
Definition font.h:274
struct gpf_undo * gpf_undo_new(void)
Creates a new undo.
Definition undo.c:49
void gpf_undo_commit(struct gpf_undo *self, struct gpf_font *font)
Finishes an undo on a glyph started by gpf_undo_begin().
Definition undo.c:220
void gpf_undo_free(struct gpf_undo *self)
Frees undo.
Definition undo.c:85
void gpf_undo_group_begin(struct gpf_undo *self)
Starts an undo group.
Definition undo.c:65
int gpf_undo_can_undo(struct gpf_undo *self)
Returns if undo is possible.
Definition undo.c:485
gpf_undo_what
Undo type.
Definition undo.h:131
@ GPF_UNDO_FAMILY
The family metadata or the authors changed.
Definition undo.h:141
@ GPF_UNDO_GLYPH
A glyph changed.
Definition undo.h:139
@ GPF_UNDO_NONE
The journal had nothing at that end.
Definition undo.h:133
int gpf_undo_can_redo(struct gpf_undo *self)
Returns if redo is possible.
Definition undo.c:490
enum gpf_undo_what gpf_redo(struct gpf_undo *self, struct gpf_font *font, enum gpf_variant_id *id, uint32_t *code)
Redoes the next entry, or group of entries.
Definition undo.c:448
int gpf_undo_family(struct gpf_undo *self, struct gpf_font *font, const struct gpf_family_meta *meta, const struct gpf_author *authors)
Sets the font metadata and authors and saves the old ones into the undo journal.
Definition undo.c:282
void gpf_undo_group_end(struct gpf_undo *self)
Ends an undo group.
Definition undo.c:70
void gpf_undo_saved(struct gpf_undo *self)
Marks the current state as the one written to the file.
Definition undo.c:475
int gpf_undo_retarget(struct gpf_undo *self, struct gpf_font *font, enum gpf_variant_id id, uint32_t code)
Finishes a snapshot and starts a snapshot for a different glyph.
Definition undo.c:173
int gpf_undo_is_saved(struct gpf_undo *self)
Returns if the font is in the state written to the file.
Definition undo.c:480
enum gpf_undo_what gpf_undo(struct gpf_undo *self, struct gpf_font *font, enum gpf_variant_id *id, uint32_t *code)
Undoes the last entry, or group of entries.
Definition undo.c:421
int gpf_undo_begin(struct gpf_undo *self, struct gpf_font *font, enum gpf_variant_id id, uint32_t code)
Snapshots a glyph before it is changed.
Definition undo.c:154