summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--html/whiteboard.js6
-rw-r--r--webassembly/Makefile4
-rw-r--r--whiteboard.cpp3
3 files changed, 8 insertions, 5 deletions
diff --git a/html/whiteboard.js b/html/whiteboard.js
index 938e910..a6dc089 100644
--- a/html/whiteboard.js
+++ b/html/whiteboard.js
@@ -48,7 +48,7 @@ function on_getfile(data, rev, pos)
textAreaSetPos("board", pos);
}
-function on_getdiff(diff, rev)
+function on_getdiff(diff, rev, pos)
{
if (rev != revision + 1)
alert("Revision skipped: " + rev + " after " + revision);
@@ -66,6 +66,7 @@ function on_getdiff(diff, rev)
revision = rev;
baseline = data;
+ textAreaSetPos("board", pos);
}
function on_getpos(pos)
@@ -110,7 +111,8 @@ function on_message(e) {
parseInt(xmlDocument.getElementsByTagName("pos")[0].textContent));
} else if (type == "getdiff") {
on_getdiff(xmlDocument.getElementsByTagName("diff")[0],
- parseInt(xmlDocument.getElementsByTagName("revision")[0].textContent));
+ parseInt(xmlDocument.getElementsByTagName("revision")[0].textContent),
+ parseInt(xmlDocument.getElementsByTagName("pos")[0].textContent));
} else if (type == "getpos") {
on_getpos(parseInt(xmlDocument.getElementsByTagName("pos")[0].textContent));
} else if (type == "modify") {
diff --git a/webassembly/Makefile b/webassembly/Makefile
index 41d106e..49a5ed3 100644
--- a/webassembly/Makefile
+++ b/webassembly/Makefile
@@ -5,8 +5,8 @@ OBJS=diff.o
CXX=em++
-CXXFLAGS=-I./include -Os -std=c++20
-LDFLAGS=-Os -s WASM=1 -s EXPORTED_FUNCTIONS=_diff_create,_diff_apply,_free
+CXXFLAGS=-I./include -O2 -std=c++20
+LDFLAGS=-s WASM=1 -s EXPORTED_FUNCTIONS=_diff_create,_diff_apply,_free
# Note: Instead of the above explicit EXPORTED_FUNCTIONS, the following causes ~7x wasm file size:
#-s LINKABLE=1 -s EXPORT_ALL=1
diff --git a/whiteboard.cpp b/whiteboard.cpp
index a49ef73..fcfdca8 100644
--- a/whiteboard.cpp
+++ b/whiteboard.cpp
@@ -107,7 +107,8 @@ void Whiteboard::notify_other_connections_diff(Whiteboard::connection& c, const
boost::beast::flat_buffer buffer;
pt::ptree ptree {make_ptree({
{"type", "getdiff"},
- {"revision", std::to_string(m_storage->getRevision(id)) }
+ {"revision", std::to_string(m_storage->getRevision(id))},
+ {"pos", std::to_string(m_storage->getCursorPos(id)) }
})};
ptree.put_child("serverinfo.diff", diff.get_structure().get_child("diff"));
boost::beast::ostream(buffer) << Reichwein::XML::plain_xml(ptree);