diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-17 01:42:54 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-17 01:42:54 +0100 |
commit | 79495eb1e3cf282cce515d15c5be925587b8c483 (patch) | |
tree | 2ef69e61c269cbbd4c9d41e7d6365a9a9cc4fea5 | |
parent | 3c12d015023a48bf6c48dea4ae1a60045b2c9c04 (diff) | |
download | sciteco-79495eb1e3cf282cce515d15c5be925587b8c483.tar.gz |
use special flag to temporarily disable buffer dirty checks when a Q-Register is (temporarily) edited without changing the current document
-rw-r--r-- | main.cpp | 3 | ||||
-rw-r--r-- | qbuffers.cpp | 21 | ||||
-rw-r--r-- | qbuffers.h | 2 |
3 files changed, 22 insertions, 4 deletions
@@ -58,7 +58,8 @@ Interface::process_notify(SCNotification *notify) g_printf("SCINTILLA SAVEPOINT LEFT\n"); #endif - if (!ring.current || ring.current->dirty) + if (!dirty_check_enabled || + !ring.current || ring.current->dirty) break; undo.push_msg(SCI_SETSAVEPOINT); diff --git a/qbuffers.cpp b/qbuffers.cpp index 09888a4..4a45fd4 100644 --- a/qbuffers.cpp +++ b/qbuffers.cpp @@ -38,6 +38,13 @@ namespace States { Ring ring; QRegisterTable qregisters; +/* + * Can be used to temporarily disable SCN_SAVEPOINTLEFT processing since + * a Q-Register may be modified without changing the logical current + * document and we don't want the wrong file to get modified. + */ +bool dirty_check_enabled = true; + static QRegister *register_argument = NULL; /* FIXME: clean up current_save_dot() usage */ @@ -67,9 +74,11 @@ QRegister::set_string(const gchar *str) edit(); dot = 0; + dirty_check_enabled = false; interface.ssm(SCI_BEGINUNDOACTION); interface.ssm(SCI_SETTEXT, 0, (sptr_t)str); interface.ssm(SCI_ENDUNDOACTION); + dirty_check_enabled = true; current_edit(); } @@ -120,10 +129,12 @@ QRegister::load(const gchar *filename) edit(); dot = 0; + dirty_check_enabled = false; interface.ssm(SCI_BEGINUNDOACTION); interface.ssm(SCI_CLEARALL); interface.ssm(SCI_APPENDTEXT, size, (sptr_t)contents); interface.ssm(SCI_ENDUNDOACTION); + dirty_check_enabled = true; g_free(contents); @@ -161,13 +172,17 @@ Buffer::load(const gchar *filename) gchar *contents; gsize size; - edit(); - interface.ssm(SCI_CLEARALL); - /* FIXME: prevent excessive allocations by reading file into buffer */ if (!g_file_get_contents(filename, &contents, &size, NULL)) return false; + + edit(); + + interface.ssm(SCI_BEGINUNDOACTION); + interface.ssm(SCI_CLEARALL); interface.ssm(SCI_APPENDTEXT, size, (sptr_t)contents); + interface.ssm(SCI_ENDUNDOACTION); + g_free(contents); interface.ssm(SCI_SETSAVEPOINT); @@ -379,4 +379,6 @@ namespace States { extern StateCopyToQReg copytoqreg; } +extern bool dirty_check_enabled; + #endif |