aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/cmdline.cpp4
-rw-r--r--src/interface.cpp6
-rw-r--r--src/interface.h7
-rw-r--r--src/main.cpp7
-rw-r--r--src/ring.cpp9
-rw-r--r--src/ring.h22
6 files changed, 45 insertions, 10 deletions
diff --git a/src/cmdline.cpp b/src/cmdline.cpp
index 8b2d412..78c0bdb 100644
--- a/src/cmdline.cpp
+++ b/src/cmdline.cpp
@@ -258,7 +258,9 @@ process_edit_cmd(gchar key)
throw Quit();
undo.clear();
- interface.ssm(SCI_EMPTYUNDOBUFFER);
+ /* also empties all Scintilla undo buffers */
+ ring.set_scintilla_undo(true);
+ QRegisters::view.set_scintilla_undo(true);
Goto::table->clear();
expressions.clear();
diff --git a/src/interface.cpp b/src/interface.cpp
index a726e01..fc46f53 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -55,6 +55,12 @@ template <class ViewImpl>
void
View<ViewImpl>::setup(void)
{
+ /*
+ * Start with or without undo collection,
+ * depending on undo.enabled.
+ */
+ ssm(SCI_SETUNDOCOLLECTION, undo.enabled);
+
ssm(SCI_SETFOCUS, TRUE);
ssm(SCI_SETCARETSTYLE, CARETSTYLE_BLOCK);
diff --git a/src/interface.h b/src/interface.h
index a883a5f..4b5de7f 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -131,6 +131,13 @@ public:
undo.push(new UndoTokenSetRepresentations(impl()));
}
+ inline void
+ set_scintilla_undo(bool state)
+ {
+ ssm(SCI_EMPTYUNDOBUFFER);
+ ssm(SCI_SETUNDOCOLLECTION, state);
+ }
+
protected:
void setup(void);
};
diff --git a/src/main.cpp b/src/main.cpp
index 463cdfd..9123224 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -357,8 +357,9 @@ main(int argc, char **argv)
QRegisters::globals.insert("\x1B");
Goto::table = &cmdline_goto_table;
- interface.ssm(SCI_EMPTYUNDOBUFFER);
undo.enabled = true;
+ ring.set_scintilla_undo(true);
+ QRegisters::view.set_scintilla_undo(true);
interface.event_loop();
@@ -368,8 +369,10 @@ main(int argc, char **argv)
* in non-interactive mode again.
*/
undo.enabled = false;
- interface.ssm(SCI_EMPTYUNDOBUFFER);
undo.clear();
+ /* also empties all Scintilla undo buffers */
+ ring.set_scintilla_undo(false);
+ QRegisters::view.set_scintilla_undo(false);
try {
QRegisters::hook(QRegisters::HOOK_QUIT);
diff --git a/src/ring.cpp b/src/ring.cpp
index df80246..0d617c0 100644
--- a/src/ring.cpp
+++ b/src/ring.cpp
@@ -251,6 +251,15 @@ Ring::close(void)
}
}
+void
+Ring::set_scintilla_undo(bool state)
+{
+ Buffer *cur;
+
+ TAILQ_FOREACH(cur, &head, buffers)
+ cur->set_scintilla_undo(state);
+}
+
Ring::~Ring()
{
Buffer *buffer, *next;
diff --git a/src/ring.h b/src/ring.h
index 1fc135f..d259500 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -38,6 +38,8 @@ namespace SciTECO {
*/
class Buffer : private IOView {
+ TAILQ_ENTRY(Buffer) buffers;
+
class UndoTokenClose : public UndoToken {
Buffer *buffer;
@@ -48,9 +50,13 @@ class Buffer : private IOView {
void run(void);
};
-public:
- TAILQ_ENTRY(Buffer) buffers;
+ inline void
+ undo_close(void)
+ {
+ undo.push(new UndoTokenClose(this));
+ }
+public:
gchar *filename;
bool dirty;
@@ -115,11 +121,11 @@ public:
}
void save(const gchar *filename = NULL);
- inline void
- undo_close(void)
- {
- undo.push(new UndoTokenClose(this));
- }
+ /*
+ * Ring manages the buffer list and has privileged
+ * access.
+ */
+ friend class Ring;
};
/* object declared in main.cpp */
@@ -195,6 +201,8 @@ public:
{
current->undo_close();
}
+
+ void set_scintilla_undo(bool state);
} ring;
/*