aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/document.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-22 21:18:14 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-22 21:18:14 +0100
commit1b636e3cc7326e9139ff107b2818703181c6e7f7 (patch)
tree21f7f1e35f9898638c85a533e13b3bf813fd4992 /src/document.cpp
parent99f6da572f455b0ba17c341ec1a63c5826de3ecf (diff)
downloadsciteco-1b636e3cc7326e9139ff107b2818703181c6e7f7.tar.gz
save/restore anchor position along with dot (current position) when editing documents
* fixes search-replace commands when function keys are used since they rely on selections not being disturbed * will also be useful later when there may be other selections
Diffstat (limited to 'src/document.cpp')
-rw-r--r--src/document.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/document.cpp b/src/document.cpp
index b6a99f5..eba0279 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -37,13 +37,13 @@ TECODocument::edit(void)
interface.ssm(SCI_SETDOCPOINTER, 0, (sptr_t)doc);
interface.ssm(SCI_SETFIRSTVISIBLELINE, first_line);
interface.ssm(SCI_SETXOFFSET, xoffset);
- interface.ssm(SCI_GOTOPOS, dot);
+ interface.ssm(SCI_SETSEL, anchor, (sptr_t)dot);
}
void
TECODocument::undo_edit(void)
{
- undo.push_msg(SCI_GOTOPOS, dot);
+ undo.push_msg(SCI_SETSEL, anchor, (sptr_t)dot);
undo.push_msg(SCI_SETXOFFSET, xoffset);
undo.push_msg(SCI_SETFIRSTVISIBLELINE, first_line);
undo.push_msg(SCI_SETDOCPOINTER, 0, (sptr_t)doc);
@@ -52,6 +52,7 @@ TECODocument::undo_edit(void)
void
TECODocument::update(void)
{
+ anchor = interface.ssm(SCI_GETANCHOR);
dot = interface.ssm(SCI_GETCURRENTPOS);
first_line = interface.ssm(SCI_GETFIRSTVISIBLELINE);
xoffset = interface.ssm(SCI_GETXOFFSET);
@@ -65,16 +66,19 @@ void
TECODocument::exchange(TECODocument &other)
{
SciDoc temp_doc = doc;
+ gint temp_anchor = anchor;
gint temp_dot = dot;
gint temp_first_line = first_line;
gint temp_xoffset = xoffset;
doc = other.doc;
+ anchor = other.anchor;
dot = other.dot;
first_line = other.first_line;
xoffset = other.xoffset;
other.doc = temp_doc;
+ other.anchor = temp_anchor;
other.dot = temp_dot;
other.first_line = temp_first_line;
other.xoffset = temp_xoffset;