Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
UpdateViasforaTheme
param([String]$VSSettingsFile, [String]$ThemeFile)
$entryMap = @{
'Viasfora Rainbow Brace 1' = 'viasfora.rainbow.1';
'Viasfora Rainbow Brace 2' = 'viasfora.rainbow.2';
'Viasfora Rainbow Brace 3' = 'viasfora.rainbow.3';
'Viasfora Rainbow Brace 4' = 'viasfora.rainbow.4';
'Viasfora Rainbow Brace 5' = 'viasfora.rainbow.5';
'Viasfora Rainbow Brace 6' = 'viasfora.rainbow.6';
'Viasfora Rainbow Brace 7' = 'viasfora.rainbow.7';
'Viasfora Rainbow Brace 8' = 'viasfora.rainbow.8';
'Viasfora Rainbow Brace 9' = 'viasfora.rainbow.9';
'Viasfora Rainbow Brace Error' = 'viasfora.rainbow.error';
'viasfora.rainbow.tip.highlight' = 'viasfora.rainbow.tip.highlight';
'Viasfora Flow Control Keyword' = 'viasfora.keyword.flowcontrol';
'Viasfora Visibility Keyword' = 'viasfora.keyword.visibility';
'Viasfora Query Operator' = 'viasfora.keyword.linq';
'Viasfora String Escape Sequence' = 'viasfora.string.escape_sequence';
'viasfora.format.specifier' = 'viasfora.string.format.specifier';
'viasfora.razor.closing.element' = 'viasfora.razor.closing.element';
'XMLCloseTag' = 'viasfora.xml.closing';
'XMLPrefix' = 'viasfora.xml.closing.prefix';
'Viasfora Current Column' = 'viasfora.column.current';
'viasfora.dev.margin' = 'viasfora.dev.margin';
'viasfora.text.obfuscated' = 'viasfora.text.obfuscated';
}
function Convert-FontStyle($isBold) {
if ( $isBold -eq 'No' ) {
return 'None'
} else {
return 'Bold'
}
}
function Convert-Color($color) {
if ( $color.StartsWith('0x02') ) {
return 'automatic'
} else {
$rgb = $color.substring(4,6)
$red = $rgb.substring(4,2)
$green = $rgb.substring(2,2)
$blue = $rgb.substring(0,2)
return "#$red$green$blue"
}
}
$xml = [xml](Get-Content $VSSettingsFile)
$entries = Select-Xml -Xml $xml -XPath "//Category[@GUID='{75A05685-00A8-4DED-BAE5-E7A50BFA929A}']/Items/Item"
$themeEntries = @{}
foreach ( $entry in $entries ) {
$mappedEntry = $entryMap[$entry.Node.Name];
if ( $mappedEntry -ne $null ) {
$themeEntries[$mappedEntry] = [PSCustomObject]@{
'foreground' = Convert-Color $entry.Node.Foreground;
'background' = Convert-Color $entry.Node.Background;
'style' = Convert-FontStyle $entry.Node.BoldFont;
}
}
}
$themeEntries | ConvertTo-Json | Set-Content -Encoding UTF8 -Path $ThemeFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment