Compare commits

...

2 Commits

Author SHA1 Message Date
Dustin L. Howett
ad93566c08 Rewrite the OSC color table functions 2024-11-22 21:35:56 -06:00
Dustin L. Howett
6047f37e84 build: fix arm64 vcpkg triplet selection error (#18239)
microsoft/vcpkg-tool#1474 now validates that the target triplet is
valid. Unfortunately, `ARM64` is not valid... despite VS defaulting to
it.

VS 17.12 moved to the newer version of the vcpkg tool.

Given that we still want to build on VS 17.12, this commit adds a local
workaround.

See DD-2302065 for the internal tracking bug.
 
See microsoft/vcpkg#42182 for the upstream fix.
2024-11-22 13:52:48 -08:00
2 changed files with 67 additions and 9 deletions

View File

@@ -275,6 +275,9 @@
<VcpkgOSTarget>windows</VcpkgOSTarget>
<VcpkgUseStatic>true</VcpkgUseStatic>
<!-- BODGY - work around DD#2302065. vcpkg now validates target triplets, and is *case sensitive* -->
<VcpkgPlatformTarget Condition="'$(Platform)'=='ARM64'">arm64</VcpkgPlatformTarget>
<VcpkgAdditionalInstallOptions>--x-feature=terminal</VcpkgAdditionalInstallOptions>
<!--
Since we link everything statically, we don't need to copy anything.

View File

@@ -16,6 +16,58 @@ using namespace Microsoft::Console::VirtualTerminal;
constexpr COLORREF COLOR_INQUIRY_COLOR = 0xfeffffff; // It's like INVALID_COLOR but special
bool _GetOscSetColorTableStrided(const std::wstring_view string,
std::vector<size_t>& tableIndexes,
std::vector<DWORD>& rgbs,
size_t startIndex,
bool indexed)
{
using namespace std::string_view_literals;
const auto parts = Utils::SplitString(string, L';');
if (parts.size() < (indexed ? 2 : 1))
{
return false;
}
std::vector<size_t> newTableIndexes;
std::vector<DWORD> newRgbs;
for (size_t i = 0; i < parts.size() - (indexed ? 1 : 0); ++i)
{
unsigned int tableIndex = gsl::narrow_cast<unsigned int>(startIndex + i);
if (indexed)
{
auto&& index = til::at(parts, i++);
const auto indexSuccess = Utils::StringToUint(index, tableIndex);
if (!indexSuccess)
{
// Index failed, skip the color too
++i;
continue;
}
}
auto&& color = til::at(parts, i);
newTableIndexes.push_back(tableIndex);
if (color == L"?"sv) [[unlikely]]
{
newRgbs.push_back(COLOR_INQUIRY_COLOR);
continue;
}
const auto colorOptional = Utils::ColorFromXTermColor(color);
newRgbs.push_back(colorOptional.has_value() ? static_cast<DWORD>(*colorOptional) : INVALID_COLOR);
}
tableIndexes.swap(newTableIndexes);
rgbs.swap(newRgbs);
return tableIndexes.size() > 0 && rgbs.size() > 0;
}
// takes ownership of pDispatch
OutputStateMachineEngine::OutputStateMachineEngine(std::unique_ptr<ITermDispatch> pDispatch) :
_dispatch(std::move(pDispatch)),
@@ -758,7 +810,7 @@ bool OutputStateMachineEngine::ActionOscDispatch(const size_t parameter, const s
{
std::vector<size_t> tableIndexes;
std::vector<DWORD> colors;
if (_GetOscSetColorTable(string, tableIndexes, colors))
if (_GetOscSetColorTableStrided(string, tableIndexes, colors, 0, true))
{
for (size_t i = 0; i < tableIndexes.size(); i++)
{
@@ -768,7 +820,7 @@ bool OutputStateMachineEngine::ActionOscDispatch(const size_t parameter, const s
{
_dispatch->RequestColorTableEntry(tableIndex);
}
else
else if (rgb != INVALID_COLOR)
{
_dispatch->SetColorTableEntry(tableIndex, rgb);
}
@@ -781,19 +833,22 @@ bool OutputStateMachineEngine::ActionOscDispatch(const size_t parameter, const s
case OscActionCodes::SetCursorColor:
case OscActionCodes::SetHighlightColor:
{
std::vector<size_t> tableIndexes;
std::vector<DWORD> colors;
if (_GetOscSetColor(string, colors))
size_t resource = static_cast<size_t>(parameter);
if (_GetOscSetColorTableStrided(string, tableIndexes, colors, resource, false))
{
auto resource = parameter;
for (auto&& color : colors)
for (size_t i = 0; i < tableIndexes.size(); i++)
{
if (color == COLOR_INQUIRY_COLOR)
const auto tableIndex = til::at(tableIndexes, i);
const auto rgb = til::at(colors, i);
if (rgb == COLOR_INQUIRY_COLOR)
{
_dispatch->RequestXtermColorResource(resource);
_dispatch->RequestXtermColorResource(tableIndex);
}
else if (color != INVALID_COLOR)
else if (rgb != INVALID_COLOR)
{
_dispatch->SetXtermColorResource(resource, color);
_dispatch->SetXtermColorResource(tableIndex, color);
}
resource++;
}