Theming #59
Replies: 5 comments 14 replies
|
Yes, we should add one image that describes what each theme property means. I'll consider adding that. Regarding the human-readable display, I haven't looked into it but is it something we can acheive by the PowerShell formating system? |
|
Another idea, which I know is not trivial, would be to revise the theming system to use ANSI escape sequences and $PSStyle. |
|
I like the theme settings now in 0.10.0 PS C:\> (Get-PSRunDefaultSelectorOption).theme
CanvasHeightPercentage : 60
PreviewSizePercentage : 60
NameWidthPercentage : 30
PreviewPosition : Bottom
CanvasTopMargin : 1
CanvasBorderFlags : None
CanvasBorderSymbol : │ ─ ╭ ╮ ╰ ╯
CanvasBorderForegroundColor : Yellow
CanvasBorderBackgroundColor :
DefaultForegroundColor :
DefaultBackgroundColor :
CursorEnable : True
Cursor : ▸
Marker : ✓
PromptSymbol : >
PromptForegroundColor : BrightGreenThe next step is to make it easier for the user to set these values. First, the user should be able to use a command like this in the configuration script: $option.Theme.CursorForegroundColor = "Magenta"But this won't work. The user is forced to know the class name. $option.Theme.CursorForegroundColor = [PowerShellRun.FontColor]::MagentaI think related to this is what happens when I try to export theme settings. I have settings defined. PS C:\> (Get-PSRunDefaultSelectorOption).theme | select *foregroundcolor
CanvasBorderForegroundColor : Yellow
DefaultForegroundColor :
PromptForegroundColor : BrightGreen
QueryForegroundColor :
SearchBarBorderForegroundColor : BrightGreen
...I'd like to export the settings so I can import them in a script. But defined values are empty. Now, cliXML will work. (Get-PSRunDefaultSelectorOption).theme | select *foregroundcolor | Export-Clixml -Path d:\temp\p.xmlHowever, this doesn't necessarily make it easier to import settings. The user should be able to define settings by the enum value without requiring the full name. And JSON exports should work. |
|
This is do-able. I exported theme settings to a JSON file and manually set the colors. {
"ConsoleCursorShape": 0,
"KeyRemapModeConsoleCursorShape": 6,
"CanvasHeightPercentage": 75,
"PreviewSizePercentage": 60,
"NameWidthPercentage": 30,
"PreviewPosition": 1,
"CanvasTopMargin": 1,
"CanvasBorderFlags": 0,
"CanvasBorderSymbol": {
"Vertical": "│",
"Horizontal": "─",
"TopLeft": "╭",
"TopRight": "╮",
"BottomLeft": "╰",
"BottomRight": "╯"
},
"CanvasBorderForegroundColor": "Yellow",
"CursorEnable": true,
"Cursor": " 👉 ",
"Marker": "✓ ",
"PromptSymbol": null,
"PromptForegroundColor": "BrightGreen",
"QueryStyle": 0,
"SearchBarBorderFlags": 8,
"SearchBarBorderSymbol": {
"Vertical": "│",
"Horizontal": "─",
"TopLeft": "┌",
"TopRight": "┐",
"BottomLeft": "└",
"BottomRight": "┘"
},
"SearchBarBorderForegroundColor": "BrightGreen",
"CursorForegroundColor": "Magenta",
"MarkerForegroundColor": "Yellow",
"IconEnable": true,
"IconForegroundColor": null,
"NameStyle": 0,
"NameHighlightForegroundColor": "Cyan",
"NameHighlightStyle": 0,
"NameFocusStyle": 4,
"NameFocusHighlightBackgroundColor": "Magenta",
"NameFocusHighlightStyle": 4,
"DescriptionEnable": true,
"DescriptionForegroundColor": "BrightBlue",
"DescriptionStyle": 0,
"DescriptionHighlightForegroundColor": "Cyan",
"DescriptionHighlightStyle": 0,
"DescriptionFocusStyle": 4,
"DescriptionFocusHighlightForegroundColor": "Magenta",
"DescriptionFocusHighlightStyle": 4,
"EntryBorderFlags": 0,
"EntryBorderSymbol": {
"Vertical": "│",
"Horizontal": "─",
"TopLeft": "┌",
"TopRight": "┐",
"BottomLeft": "└",
"BottomRight": "┘"
},
"PreviewEnable": true,
"PreviewStyle": 0,
"PreviewBorderFlags": 15,
"PreviewBorderSymbol": {
"Vertical": "│",
"Horizontal": "─",
"TopLeft": "╭",
"TopRight": "╮",
"BottomLeft": "╰",
"BottomRight": "╯"
},
"PreviewBorderForegroundColor": "BrightYellow",
"ActionWindowKeyStyle": 0,
"ActionWindowKeyFocusStyle": 4,
"ActionWindowDescriptionForegroundColor": "BrightBlue",
"ActionWindowDescriptionStyle": 0,
"ActionWindowDescriptionFocusStyle": 4,
"ActionWindowBorderEnable": true,
"ActionWindowBorderSymbol": {
"Vertical": "│",
"Horizontal": "─",
"TopLeft": "╭",
"TopRight": "╮",
"BottomLeft": "╰",
"BottomRight": "╯"
},
"ActionWindowBorderForegroundColor": "BrightYellow",
"ActionWindowScrollBarForegroundColor": "Magenta",
"TabSize": 6
}In my configuration script, I can import this file and set the theme properties. $option = [PowerShellRun.SelectorOption]::new()
$data = Get-Content C:\Temp\psruntheme.json | ConvertFrom-Json
$option.Prompt = 'Hey Jeff! 🤓 --> '
($option.theme.PSObject.Properties).ForEach({
if ($_.Name -match "color" -AND $data.$($_.Name)) {
#Write-Host "Color: $($_.Name) = $($data.$($_.Name))"
$_.Value = [PowerShellRun.FontColor]::$($data.$($_.Name))
}
else {
$_.Value = $data.$($_.Name)
}
})I need an extra step to set the color. But I can live with it. |







Uh oh!
There was an error while loading. Please reload this page.
I am starting to experiment with theming. One thing that would really help is an annotated layout or some sort of documentation that defines theme properties. For example, what does
CanvasBorderrefer to?It would also help to be able to resolve settings to human-readable values. For example, if I look at
$o.theme.MarkerForegroundColorall I see isPowerShellRun.FontColor. I have no way of knowing what the actual color is.All reactions