diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-13 23:52:01 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-13 23:52:01 +0100 |
commit | 66bde3c43d543cbadd617f68240f4bd8c22d10d9 (patch) | |
tree | fa45084a22bb67249f43503d24fae930cb4062f7 /qbuffers.h | |
parent | 074c64232f8be3bc34b40a9d5e92f28e6aa922fb (diff) | |
download | sciteco-66bde3c43d543cbadd617f68240f4bd8c22d10d9.tar.gz |
EF command to close a buffer
can be rubbed out!!!
this works because when a buffer is closed, it is not deallocated but transferred to the undo
token object which then (if run) reinserts it into the ring list. if the undo token is destroyed
before it is run (eg. <ESC><ESC> pressed), the buffer will finally be deallocated.
Diffstat (limited to 'qbuffers.h')
-rw-r--r-- | qbuffers.h | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -143,6 +143,7 @@ class Buffer { run(void) { buffer->close(); + /* NOTE: the buffer is NOT deleted on Token destruction */ delete buffer; } }; @@ -168,7 +169,7 @@ public: g_free(filename); } - inline Buffer * + inline Buffer *& next(void) { return LIST_NEXT(this, buffers); @@ -206,6 +207,26 @@ public: }; extern class Ring { + /* + * Emitted after a buffer close + * The pointer is the only remaining reference to the buffer! + */ + class UndoTokenEdit : public UndoToken { + Ring *ring; + Buffer *buffer; + + public: + UndoTokenEdit(Ring *_ring, Buffer *_buffer) + : UndoToken(), ring(_ring), buffer(_buffer) {} + ~UndoTokenEdit() + { + if (buffer) + delete buffer; + } + + void run(void); + }; + LIST_HEAD(Head, Buffer) head; public: |