Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sixel support #4828

Merged
merged 17 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ silentwithprogress
Silverlight
simplesave
simpletest
sixel
sixels
sln
sqlbuilder
sqliteicu
Expand Down
3 changes: 3 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
ISQ
ISVs
itr
IWIC
iwr
JArray
JDictionary
Expand Down Expand Up @@ -476,7 +477,7 @@
securestring
seof
servercert
servercertificate

Check warning on line 480 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`rowids` is ignored by check spelling because another more general variant is also in expect. (ignored-expect-variant)
setmetadatabymanifestid
SETTINGCHANGE
SETTINGMAPPING
Expand Down Expand Up @@ -556,7 +557,7 @@
UNMARSHALING
unparsable
Unregisters
unvirtualized

Check warning on line 560 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`Templating` is ignored by check spelling because another more general variant is also in expect. (ignored-expect-variant)
UParse
upgradable
upgradecode
Expand All @@ -582,8 +583,10 @@
wfsopen
wgetenv
Whatif
WIC
wildcards
WINAPI
wincodec
windir
windowsdeveloper
winerror
Expand Down Expand Up @@ -611,7 +614,7 @@
wwinmain
WZDNCRFJ
xcopy
XFile

Check warning on line 617 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`websites` is ignored by check spelling because another more general variant is also in expect. (ignored-expect-variant)
XManifest
XMUGIWARAMODULE
XName
Expand Down
22 changes: 16 additions & 6 deletions doc/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ Replaces some known folder paths with their respective environment variable. Def
},
```

### enableSixels

Enables output of sixel images in certain contexts. Defaults to false.

```json
"visual": {
"enableSixels": true
},
```

## Install Behavior

The `installBehavior` settings affect the default behavior of installing and upgrading (where applicable) packages.
Expand Down Expand Up @@ -97,12 +107,12 @@ The 'skipDependencies' behavior affects whether dependencies are installed for a
"installBehavior": {
"skipDependencies": true
},
```
### Archive Extraction Method
The 'archiveExtractionMethod' behavior affects how installer archives are extracted. Currently there are two supported values: `Tar` or `ShellApi`.
`Tar` indicates that the archive should be extracted using the tar executable ('tar.exe') while `shellApi` indicates using the Windows Shell API. Defaults to `shellApi` if value is not set or is invalid.
```

### Archive Extraction Method
The 'archiveExtractionMethod' behavior affects how installer archives are extracted. Currently there are two supported values: `Tar` or `ShellApi`.
`Tar` indicates that the archive should be extracted using the tar executable ('tar.exe') while `shellApi` indicates using the Windows Shell API. Defaults to `shellApi` if value is not set or is invalid.

```json
"installBehavior": {
"archiveExtractionMethod": "tar" | "shellApi"
Expand Down
9 changes: 8 additions & 1 deletion schemas/JSON/settings/settings.schema.0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@
"enum": [
"accent",
"rainbow",
"retro"
"retro",
"sixel",
"disabled"
]
},
"anonymizeDisplayedPaths": {
"description": "Replaces some known folder paths with their respective environment variable",
"type": "boolean",
"default": true
},
"enableSixels": {
"description": "Enables output of sixel images in certain contexts",
"type": "boolean",
"default": false
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@
<ClInclude Include="ContextOrchestrator.h" />
<ClInclude Include="COMContext.h" />
<ClInclude Include="Public\ConfigurationSetProcessorFactoryRemoting.h" />
<ClInclude Include="Sixel.h" />
<ClInclude Include="Workflows\ConfigurationFlow.h" />
<ClInclude Include="Workflows\DependenciesFlow.h" />
<ClInclude Include="ExecutionArgs.h" />
Expand Down Expand Up @@ -451,6 +452,7 @@
<ClCompile Include="ConfigurationWingetDscModuleUnitValidation.cpp" />
<ClCompile Include="ConfigureExportCommand.cpp" />
<ClCompile Include="ContextOrchestrator.cpp" />
<ClCompile Include="Sixel.cpp" />
<ClCompile Include="Workflows\ConfigurationFlow.cpp" />
<ClCompile Include="Workflows\DependenciesFlow.cpp" />
<ClCompile Include="PackageCollection.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@
<ClInclude Include="Commands\ConfigureListCommand.h">
<Filter>Commands</Filter>
</ClInclude>
<ClInclude Include="Sixel.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand Down Expand Up @@ -484,6 +487,9 @@
<ClCompile Include="Commands\ConfigureListCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
<ClCompile Include="Sixel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
12 changes: 11 additions & 1 deletion src/AppInstallerCLICore/ChannelStreams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ namespace AppInstaller::CLI::Execution
m_enabled = false;
}

std::ostream& BaseStream::Get()
{
return m_out;
}

OutputStream::OutputStream(BaseStream& out, bool enabled, bool VTEnabled) :
m_out(out),
m_enabled(enabled),
Expand All @@ -82,6 +87,11 @@ namespace AppInstaller::CLI::Execution
m_format.Append(sequence);
}

void OutputStream::ClearFormat()
{
m_format.Clear();
}

void OutputStream::ApplyFormat()
{
// Only apply format if m_applyFormatAtOne == 1 coming into this function.
Expand Down Expand Up @@ -152,4 +162,4 @@ namespace AppInstaller::CLI::Execution
return *this;

}
}
}
5 changes: 5 additions & 0 deletions src/AppInstallerCLICore/ChannelStreams.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ namespace AppInstaller::CLI::Execution

void Disable();

std::ostream& Get();

private:
template <typename T>
void Write(const T& t, bool bypass)
Expand All @@ -60,6 +62,9 @@ namespace AppInstaller::CLI::Execution
// Adds a format to the current value.
void AddFormat(const VirtualTerminal::Sequence& sequence);

// Clears the current format value.
void ClearFormat();

template <typename T>
OutputStream& operator<<(const T& t)
{
Expand Down
34 changes: 33 additions & 1 deletion src/AppInstallerCLICore/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "pch.h"
#include "Command.h"
#include "Resources.h"
#include "Sixel.h"
#include <winget/UserSettings.h>
#include <AppInstallerRuntime.h>
#include <winget/Locale.h>
Expand Down Expand Up @@ -42,8 +43,39 @@ namespace AppInstaller::CLI

void Command::OutputIntroHeader(Execution::Reporter& reporter) const
{
auto infoOut = reporter.Info();
VirtualTerminal::ConstructedSequence indent;

if (reporter.SixelsEnabled())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to try CATCH_LOG since I saw a bunch of THROW_IF_FAILED in sixels.cpp code?

{
try
{
std::filesystem::path imagePath = Runtime::GetPathTo(Runtime::PathName::ImageAssets);

if (!imagePath.empty())
{
// This image matches the target pixel size. If changing the target size, choose the most appropriate image.
imagePath /= "AppList.targetsize-40.png";

VirtualTerminal::Sixel::Image wingetIcon{ imagePath };

// Using a height of 2 to match the two lines of header.
UINT imageHeightCells = 2;
UINT imageWidthCells = 2 * imageHeightCells;

wingetIcon.RenderSizeInCells(imageWidthCells, imageHeightCells);
wingetIcon.RenderTo(infoOut);

indent = VirtualTerminal::Cursor::Position::Forward(static_cast<int16_t>(imageWidthCells));
infoOut << VirtualTerminal::Cursor::Position::Up(static_cast<int16_t>(imageHeightCells) - 1);
}
}
CATCH_LOG();
}

auto productName = Runtime::IsReleaseBuild() ? Resource::String::WindowsPackageManager : Resource::String::WindowsPackageManagerPreview;
reporter.Info() << productName(Runtime::GetClientVersion()) << std::endl << Resource::String::MainCopyrightNotice << std::endl;
infoOut << indent << productName(Runtime::GetClientVersion()) << std::endl
<< indent << Resource::String::MainCopyrightNotice << std::endl;
}

void Command::OutputHelp(Execution::Reporter& reporter, const CommandException* exception) const
Expand Down
Loading
Loading