Skip to content

Commit

Permalink
Slight update to replace 1 unicode-space by another
Browse files Browse the repository at this point in the history
Space sent by BioScan plagin was not drawn properly on overlay.
  • Loading branch information
alexzk1 committed May 18, 2024
1 parent fc5ea9d commit 70ac833
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cpp/strutils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef STDSTRINGFMT_H
#define STDSTRINGFMT_H
#pragma once

#include <string>
#include <vector>
Expand Down Expand Up @@ -237,5 +236,6 @@ namespace utility
{
return ltrim(rtrim(s, t), t);
}

}
#endif // STDSTRINGFMT_H

15 changes: 14 additions & 1 deletion cpp/xoverlayoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <mutex>
#include <vector>
#include <unordered_map>
#include <cwchar>


// Events for normal windows
constexpr static long BASIC_EVENT_MASK = StructureNotifyMask | ExposureMask | PropertyChangeMask |
Expand Down Expand Up @@ -334,6 +334,19 @@ class XPrivateAccess
Window g_win{0};
opaque_ptr<_XGC> single_gc{nullptr};

static int utf8CharactersCount(const std::string& str)
{
int count = 0;
for (const auto& c : str)
{
if ((c & 0x80) == 0 || (c & 0xc0) == 0xc0)
{
++count;
}
}
return count;
}

void drawUtf8String(const opaque_ptr<XftFont>& aFont, const std::string& aColor,
int aX, int aY,
const std::string& aString, bool aRectangle) const
Expand Down
5 changes: 3 additions & 2 deletions edmcoverlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ def _stop(self):
self._send_raw_text("NEED_TO_STOP")

def _send_raw_text(self, inpstr: str):
bstr = bytes(inpstr, "UTF-8")
inpstr = inpstr.replace("\\u202f", "\\u00a0")
bstr = inpstr.encode("utf-8")
for retries in range(1, 7):
try:
with self.__lock:
conn = socket.socket()
conn.connect((self._host, self._port))
conn.send(str(len(bstr)).encode() + b"#" + bstr)
conn.send(str(len(bstr)).encode("utf-8") + b"#" + bstr)
conn.close()
break
except socket.error as e:
Expand Down

0 comments on commit 70ac833

Please sign in to comment.