diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-11-24 02:51:31 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-11-24 05:07:06 +0100 |
commit | d503c3b07c2157658f699294c44ad5be244727a5 (patch) | |
tree | f25b9927f5bdcfca98a82f3bc917548cbec5962b /src/ring.h | |
parent | 355cae277c29104b982f4dc7aa3e05fc06945325 (diff) | |
download | sciteco-d503c3b07c2157658f699294c44ad5be244727a5.tar.gz |
factored out file loading and saving into the View specialisation IOView
this will allow us to use the same algorithms for loading and saving
Q-Registers (from/to file).
* Saving with EW when a Q-Reg is edited has been fixed (was broken earlier)
* SciTECO save point files are now named .teco-X-BASENAME
When using IOView for Q-Regs, there will be no way to sensible count
the save points. Each write of a Q-Reg may be to another file.
Therefore, we number save-points globally.
If the sequence of writes has to be reconstructed manually,
one can still look at the save point files' modification dates
* give more informative error messages when saving a file fails
Diffstat (limited to 'src/ring.h')
-rw-r--r-- | src/ring.h | 54 |
1 files changed, 16 insertions, 38 deletions
@@ -21,8 +21,6 @@ #include <bsd/sys/queue.h> #include <glib.h> -#include <glib/gprintf.h> -#include <glib/gstdio.h> #include <Scintilla.h> @@ -31,25 +29,15 @@ #include "undo.h" #include "qregisters.h" #include "parser.h" +#include "ioview.h" namespace SciTECO { /* - * Auxiliary functions - */ - -/* - * Get absolute/full version of a possibly relative path. - * Works with existing and non-existing paths (in the latter case, - * heuristics may be applied.) - */ -gchar *get_absolute_path(const gchar *path); - -/* * Classes */ -class Buffer : private ViewCurrent { +class Buffer : private IOView { class UndoTokenClose : public UndoToken { Buffer *buffer; @@ -64,11 +52,9 @@ public: TAILQ_ENTRY(Buffer) buffers; gchar *filename; - gint savepoint_id; bool dirty; - Buffer() : ViewCurrent(), - filename(NULL), savepoint_id(0), dirty(false) + Buffer() : filename(NULL), dirty(false) { initialize(); /* only have to do this once: */ @@ -115,7 +101,19 @@ public: interface.undo_show_view(this); } - void load(const gchar *filename); + inline void + load(const gchar *filename) + { + IOView::load(filename); + +#if 0 /* NOTE: currently buffer cannot be dirty */ + interface.undo_info_update(this); + undo.push_var(dirty) = false; +#endif + + set_filename(filename); + } + void save(const gchar *filename = NULL); inline void undo_close(void) @@ -146,24 +144,6 @@ extern class Ring { void run(void); }; - class UndoTokenRemoveFile : public UndoToken { - gchar *filename; - - public: - UndoTokenRemoveFile(const gchar *_filename) - : filename(g_strdup(_filename)) {} - ~UndoTokenRemoveFile() - { - g_free(filename); - } - - void - run(void) - { - g_unlink(filename); - } - }; - TAILQ_HEAD(Head, Buffer) head; public: @@ -208,8 +188,6 @@ public: undo.push_var(current)->undo_edit(); } - bool save(const gchar *filename); - void close(Buffer *buffer); void close(void); inline void |