aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/document.cpp8
-rw-r--r--src/document.h10
2 files changed, 12 insertions, 6 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;
diff --git a/src/document.h b/src/document.h
index 2ef71ba..0f02a9e 100644
--- a/src/document.h
+++ b/src/document.h
@@ -41,9 +41,8 @@ class TECODocument {
SciDoc doc;
/* updated/restored only when required */
- gint dot;
- gint first_line;
- gint xoffset;
+ gint anchor, dot;
+ gint first_line, xoffset;
public:
TECODocument() : doc(NULL)
@@ -69,6 +68,7 @@ public:
inline void
update(const TECODocument &from)
{
+ anchor = from.anchor;
dot = from.dot;
first_line = from.first_line;
xoffset = from.xoffset;
@@ -77,11 +77,13 @@ public:
inline void
reset(void)
{
- dot = first_line = xoffset = 0;
+ anchor = dot = 0;
+ first_line = xoffset = 0;
}
inline void
undo_reset(void)
{
+ undo.push_var(anchor);
undo.push_var(dot);
undo.push_var(first_line);
undo.push_var(xoffset);