diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-07-17 13:24:03 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-07-17 13:24:03 +0200 |
| commit | 4b2fcdb0199182c43f007096a29ba59c9c8d6d55 (patch) | |
| tree | 3e8f94f1269d16cc745c5cb24801e5a7c5730e43 /editor.c | |
| parent | 4c329c7e62ad3fca16a469056b20c5565154e7ea (diff) | |
| download | vis-4b2fcdb0199182c43f007096a29ba59c9c8d6d55.tar.gz vis-4b2fcdb0199182c43f007096a29ba59c9c8d6d55.tar.xz | |
Implement modification detection
Diffstat (limited to 'editor.c')
| -rw-r--r-- | editor.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -85,6 +85,7 @@ struct Editor { Piece begin, end; /* sentinel nodes which always exists but don't hold any data */ Action *redo, *undo; /* two stacks holding all actions performed to the file */ Action *current_action; /* action holding all file changes until a snapshot is performed */ + Action *saved_action; /* the last action at the time of the save operation */ size_t size; /* current file content size in bytes */ const char *filename; /* filename of which data was loaded */ struct stat info; /* stat as proped on load time */ @@ -411,7 +412,10 @@ int editor_save(Editor *ed, const char *filename) { } if (close(fd) == -1) return -1; - return rename(tmpname, filename); + if (rename(tmpname, filename) == -1) + return -1; + ed->saved_action = ed->undo; + editor_snapshot(ed); err: close(fd); return -1; @@ -591,6 +595,5 @@ void editor_free(Editor *ed) { } bool editor_modified(Editor *ed) { - // TODO: not correct after save - return ed->undo != NULL; + return ed->saved_action != ed->undo; } |
