From 79495eb1e3cf282cce515d15c5be925587b8c483 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 17 Nov 2012 01:42:54 +0100 Subject: use special flag to temporarily disable buffer dirty checks when a Q-Register is (temporarily) edited without changing the current document --- qbuffers.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'qbuffers.cpp') 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); -- cgit v1.2.3