aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ring.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-18 23:17:18 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-22 01:18:05 +0100
commit753dacacbcc2d45d35a044bfe2512fc4cd564b5c (patch)
tree0836f965a306b33449d60c4c7b579eab06f6bc2b /src/ring.h
parente0a47e8fcd592585030384faf6d42a2bf74f43ad (diff)
downloadsciteco-753dacacbcc2d45d35a044bfe2512fc4cd564b5c.tar.gz
clean up QRegister vs. Buffer redundancies using TECODocument class
* also encapsulates data properly (previously there were many public attributes to avoid permission issues) * new class also cares about saving/and restoring scroll state. now, buffer/q-reg edits and temporary accesses do not reset the scroll state anymore.
Diffstat (limited to 'src/ring.h')
-rw-r--r--src/ring.h36
1 files changed, 11 insertions, 25 deletions
diff --git a/src/ring.h b/src/ring.h
index 608b752..4ca7a5d 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -30,6 +30,7 @@
#include "sciteco.h"
#include "interface.h"
#include "undo.h"
+#include "document.h"
#include "qregisters.h"
#include "parser.h"
@@ -53,7 +54,7 @@ gchar *get_absolute_path(const gchar *path);
* Classes
*/
-class Buffer {
+class Buffer : public TECODocument {
class UndoTokenClose : public UndoToken {
Buffer *buffer;
@@ -68,24 +69,13 @@ public:
TAILQ_ENTRY(Buffer) buffers;
gchar *filename;
- gint dot;
-
gint savepoint_id;
-
bool dirty;
-private:
- typedef void document;
- document *doc;
-
-public:
- Buffer() : filename(NULL), dot(0), savepoint_id(0), dirty(false)
- {
- doc = (document *)interface.ssm(SCI_CREATEDOCUMENT);
- }
+ Buffer() : TECODocument(),
+ filename(NULL), savepoint_id(0), dirty(false) {}
~Buffer()
{
- interface.ssm(SCI_RELEASEDOCUMENT, 0, (sptr_t)doc);
g_free(filename);
}
@@ -114,16 +104,14 @@ public:
inline void
edit(void)
{
- interface.ssm(SCI_SETDOCPOINTER, 0, (sptr_t)doc);
- interface.ssm(SCI_GOTOPOS, dot);
+ TECODocument::edit();
interface.info_update(this);
}
inline void
undo_edit(void)
{
interface.undo_info_update(this);
- undo.push_msg(SCI_GOTOPOS, dot);
- undo.push_msg(SCI_SETDOCPOINTER, 0, (sptr_t)doc);
+ TECODocument::undo_edit();
}
bool load(const gchar *filename);
@@ -207,7 +195,7 @@ public:
inline void
undo_edit(void)
{
- current->dot = interface.ssm(SCI_GETCURRENTPOS);
+ current->update();
undo.push_var(QRegisters::current);
undo.push_var(current)->undo_edit();
}
@@ -248,16 +236,14 @@ namespace States {
extern StateSaveFile savefile;
}
-/* FIXME: clean up current_save_dot() usage */
+/* FIXME: clean up current_doc_update() usage */
static inline void
-current_save_dot(void)
+current_doc_update(void)
{
- gint dot = interface.ssm(SCI_GETCURRENTPOS);
-
if (ring.current)
- ring.current->dot = dot;
+ ring.current->update();
else if (QRegisters::current)
- QRegisters::current->dot = dot;
+ QRegisters::current->update_string();
}
#endif