fix cursor visibility in OSX

This commit is contained in:
2019-03-11 18:39:11 +01:00
parent c111495cae
commit 5bef9c7286
7 changed files with 43 additions and 23 deletions

View File

@@ -115,10 +115,13 @@ std::wstring BinaryStreamReader::rwstring(size_t len)
// std::swap(ptr[i * 2], ptr[i * 2 + 1]);
// right trim trailing zeroes
auto wptr = (uint16_t*)ptr;
for (int i = len - 1; i >= 0; i--)
if (wptr[i] == 0) len--;
if (len > 0)
{
auto wptr = (uint16_t*)ptr;
for (size_t i = len - 1; i >= 0 && len > 0; i--)
if (wptr[i] == 0) len--;
}
// wide to UTF-16le
std::wstring_convert<std::codecvt_utf16<wchar_t, 0x10ffff>> converter;
return converter.from_bytes(ptr, ptr + len * 2);
@@ -257,7 +260,7 @@ void BinaryStreamWriter::wdbl(double v)
void BinaryStreamWriter::wstring(std::string s)
{
wu32(s.size());
wu32((int)s.size());
write(s.data(), s.size());
}
@@ -268,7 +271,7 @@ void BinaryStreamWriter::wstring_raw(std::string s)
void BinaryStreamWriter::wwstring(std::wstring s)
{
wu32(s.size());
wu32((int)s.size());
std::wstring_convert<std::codecvt_utf16<wchar_t, 0x10ffff>> converter;
wstring_raw(converter.to_bytes(s));
}
@@ -287,13 +290,13 @@ void BinaryStreamWriter::wpascal(std::string s)
void BinaryStreamWriter::wraw(std::vector<uint8_t> raw)
{
wu32(raw.size());
wu32((int)raw.size());
write(raw.data(), raw.size());
}
void BinaryStreamWriter::wrle(std::vector<uint8_t> data)
{
int idx = 0;
size_t idx = 0;
auto ptr = data.data();
// find the next sequence and return the position