Skip to content

Commit

Permalink
Remove "Notepad++ binary text length" clipboard format support
Browse files Browse the repository at this point in the history
We now have other means to store data length, NP++ changed it on their side and we were doing it wrong anyway.
  • Loading branch information
alabuzhev committed Aug 6, 2023
1 parent 0c78f0b commit ba64682
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions far/platform.clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ namespace os::clipboard
preferred_drop_effect,
ms_dev_column_select,
borland_ide_dev_block,
notepad_plusplus_binary_text_length,

count
};
Expand All @@ -250,7 +249,6 @@ namespace os::clipboard
{ CFSTR_PREFERREDDROPEFFECT, 0 },
{ L"MSDEVColumnSelect", 0 },
{ L"Borland IDE Block Type", 0 },
{ L"Notepad++ binary text length", 0 },
};

static_assert(std::size(FormatNames) == static_cast<size_t>(clipboard_format::count));
Expand Down Expand Up @@ -292,16 +290,6 @@ namespace os::clipboard
LOGWARNING(L"global::copy(): {}"sv, last_error());
}

// 'Notepad++ binary text length'
// return value is ignored - non-critical feature
if (const auto Format = RegisterFormat(clipboard_format::notepad_plusplus_binary_text_length))
{
if (auto Size = memory::global::copy((static_cast<uint32_t>(Str.size()) + 1) * sizeof(decltype(Str)::value_type)))
set_data(Format, std::move(Size));
else
LOGWARNING(L"global::copy(): {}"sv, last_error());
}

// return value is ignored - non-critical feature
if (auto Locale = memory::global::copy(GetUserDefaultLCID()))
set_data(CF_LOCALE, std::move(Locale));
Expand Down Expand Up @@ -591,18 +579,6 @@ namespace os::clipboard
return static_cast<size_t>(*ClipData);
}

if (const auto SizeFormat = RegisterFormat(clipboard_format::notepad_plusplus_binary_text_length))
{
if (const auto ClipData = get_as<uint32_t>(SizeFormat))
{
// it's ambiguous now 🤦
// https://forum.farmanager.com/viewtopic.php?p=175357#p175357
return *ClipData <= TextPtr.size / sizeof(wchar_t)?
*ClipData :
*ClipData / sizeof(wchar_t) - 1;
}
}

const string_view DataView(TextPtr.get(), TextPtr.size / sizeof(*TextPtr));
return static_cast<size_t>(std::find(ALL_CONST_RANGE(DataView), L'\0') - DataView.cbegin());
}
Expand Down

0 comments on commit ba64682

Please sign in to comment.