diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-11-08 03:23:47 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-11-09 20:32:24 +0100 |
commit | a475ea8eacfcce8a3f0112f121400e37fffc0934 (patch) | |
tree | 063bff5a8dcc48deadf28cbb939b1e204cb70ecd /src/parser.cpp | |
parent | 1c3b2a9cf7bc298941f1165885fb1a3c76105878 (diff) | |
download | sciteco-a475ea8eacfcce8a3f0112f121400e37fffc0934.tar.gz |
current_doc_must_undo(): check for undo-necessity when operating on the current document
if the current document is a local q-register from a macro call,
we must not generate undo tokens, since the local documents
are discarded on macro termination.
Diffstat (limited to 'src/parser.cpp')
-rw-r--r-- | src/parser.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index e99f406..1510352 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -581,7 +581,8 @@ StateStart::insert_integer(tecoInt v) interface.ssm(SCI_ENDUNDOACTION); ring.dirtify(); - undo.push_msg(SCI_UNDO); + if (current_doc_must_undo()) + undo.push_msg(SCI_UNDO); } tecoInt @@ -622,7 +623,9 @@ StateStart::move_chars(tecoInt n) return FAILURE; interface.ssm(SCI_GOTOPOS, pos + n); - undo.push_msg(SCI_GOTOPOS, pos); + if (current_doc_must_undo()) + undo.push_msg(SCI_GOTOPOS, pos); + return SUCCESS; } @@ -636,7 +639,9 @@ StateStart::move_lines(tecoInt n) return FAILURE; interface.ssm(SCI_GOTOLINE, line); - undo.push_msg(SCI_GOTOPOS, pos); + if (current_doc_must_undo()) + undo.push_msg(SCI_GOTOPOS, pos); + return SUCCESS; } @@ -685,7 +690,8 @@ StateStart::delete_words(tecoInt n) } undo.push_msg(SCI_GOTOPOS, pos); - undo.push_msg(SCI_UNDO); + if (current_doc_must_undo()) + undo.push_msg(SCI_UNDO); ring.dirtify(); return SUCCESS; @@ -1059,9 +1065,10 @@ StateStart::custom(gchar chr) interface.ssm(SCI_BEGINUNDOACTION); interface.ssm(SCI_CLEARALL); interface.ssm(SCI_ADDTEXT, cmdline_pos-1, (sptr_t)cmdline); - /* FIXME: scroll into view */ + interface.ssm(SCI_SCROLLCARET); interface.ssm(SCI_ENDUNDOACTION); + /* must always support undo on global register */ undo.push_msg(SCI_UNDO); break; @@ -1116,8 +1123,9 @@ StateStart::custom(gchar chr) BEGIN_EXEC(this); v = expressions.pop_num_calc(1, 0); if (Validate::pos(v)) { - undo.push_msg(SCI_GOTOPOS, - interface.ssm(SCI_GETCURRENTPOS)); + if (current_doc_must_undo()) + undo.push_msg(SCI_GOTOPOS, + interface.ssm(SCI_GETCURRENTPOS)); interface.ssm(SCI_GOTOPOS, v); if (eval_colon()) @@ -1254,7 +1262,8 @@ StateStart::custom(gchar chr) break; } if (v < 0) { - undo.push_msg(SCI_GOTOPOS, pos); + if (current_doc_must_undo()) + undo.push_msg(SCI_GOTOPOS, pos); if (eval_colon()) expressions.push(SUCCESS); } else { @@ -1417,8 +1426,10 @@ StateStart::custom(gchar chr) if (len == 0 || IS_FAILURE(rc)) break; - undo.push_msg(SCI_GOTOPOS, interface.ssm(SCI_GETCURRENTPOS)); - undo.push_msg(SCI_UNDO); + if (current_doc_must_undo()) { + undo.push_msg(SCI_GOTOPOS, interface.ssm(SCI_GETCURRENTPOS)); + undo.push_msg(SCI_UNDO); + } interface.ssm(SCI_BEGINUNDOACTION); interface.ssm(SCI_DELETERANGE, from, len); @@ -2110,7 +2121,8 @@ StateInsert::initial(void) interface.ssm(SCI_ENDUNDOACTION); ring.dirtify(); - undo.push_msg(SCI_UNDO); + if (current_doc_must_undo()) + undo.push_msg(SCI_UNDO); } void @@ -2123,7 +2135,8 @@ StateInsert::process(const gchar *str, gint new_chars) interface.ssm(SCI_ENDUNDOACTION); ring.dirtify(); - undo.push_msg(SCI_UNDO); + if (current_doc_must_undo()) + undo.push_msg(SCI_UNDO); } State * |