terminal/tools/GenerateHeaderForJson.ps1
Leonard Hecker 10b12ac90c
Introduce vk() and sc() key chord specifiers (#10666)
This commit introduces an alternative to specifying key bindings as a combination of key modifiers and a character. It allows you to specify an explicit virtual key as `vk(nnn)`.
Additionally this commit makes it possible to bind actions to scan codes. As scan code 41 appears to be the button below the Escape key on virtually all keyboards, we'll be able to bind the quake mode hotkey to `win+sc(41)` and have it work consistently across most if not all keyboard layouts.

## PR Checklist
* [x] Closes #7539, Closes #10203
* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed

The following was tested both on US and DE keyboard layouts:
* Ctrl+, opens settings ✔️
* Win+` opens quake mode window ✔️
* Ctrl+plus/minus increase/decrease font size ✔️
2021-07-20 22:34:51 +00:00

28 lines
788 B
PowerShell

# This script is used for taking a json file and stamping it into a header with
# the contents of that json files as a constexpr string_view in the header.
param (
[parameter(Mandatory = $true)]
[string]$JsonFile,
[parameter(Mandatory = $true)]
[string]$OutPath,
[parameter(Mandatory = $true)]
[string]$VariableName
)
$fullPath = Resolve-Path $JsonFile
$jsonData = Get-Content $JsonFile
@(
"// Copyright (c) Microsoft Corporation",
"// Licensed under the MIT license.",
"",
"// THIS IS AN AUTO-GENERATED FILE",
"// Generated from $($fullPath.Path)",
"constexpr std::string_view $($VariableName){",
($jsonData | ForEach-Object { "R`"#($_`n)#`"" }),
"};"
) | Out-File -FilePath $OutPath -Encoding utf8