Skip to content

Commit a7bad84

Browse files
committed
Add pwsh scripts to generate markdown artifact(s) for VT support across
conhost and windows terminal
1 parent 89925eb commit a7bad84

File tree

3 files changed

+388
-0
lines changed

3 files changed

+388
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
#requires -version 6.1
2+
3+
[cmdletbinding()]
4+
param(
5+
$solutionRoot = "..\..",
6+
$interfacePath = @(join-path $solutionRoot "src\terminal\adapter\ITermDispatch.hpp"),
7+
$consoleAdapterPath = $(join-path $solutionRoot "src\terminal\adapter\adaptDispatch.hpp"),
8+
$terminalAdapterPath = $(join-path $solutionRoot "src\cascadia\terminalcore\terminaldispatch.hpp")
9+
)
10+
11+
$base = @{}
12+
$conhost = @{}
13+
$terminal = @{}
14+
$prefix = "https://vt100.net/docs/vt510-rm/"
15+
16+
# extract base interface
17+
$baseScanner = [regex]'(?x)virtual\s\w+\s(?<method>\w+)(?s)[^;]+;(?-s).*?(?<seq>(?<=\/\/\s).+)'
18+
19+
$baseScanner.Matches((get-content -raw $interfacePath)) | foreach-object {
20+
$match = $_
21+
$_.groups["seq"].value.split(",") | ForEach-Object {
22+
$base[$_.trim()] = $match.groups["method"].value
23+
}
24+
}
25+
26+
# match overrides of ITermDispatch
27+
$scanner = [regex]'(?x)\s+\w+\s(?<method>\w+)(?s)[^;]+override;'
28+
29+
$scanner.Matches((Get-Content -raw $consoleAdapterPath)) | ForEach-Object {
30+
#write-verbose $_.groups[0].value
31+
$conhost[$_.groups["method"].value] = $true
32+
}
33+
34+
$scanner.Matches((Get-Content -raw $terminalAdapterPath)) | ForEach-Object {
35+
#write-verbose $_.groups[0].value
36+
$terminal[$_.groups["method"].value] = $true
37+
}
38+
39+
# "Sequence","Associated","Description","Origin","Heading","Subheading", "ImplementedBy", "ConsoleHost","Terminal"
40+
$sequences = import-csv .\sequences.csv
41+
42+
$heading = $null
43+
$subheading = $null
44+
45+
@"
46+
# VT Function Support
47+
48+
## Table of Contents
49+
50+
* [Code Extension Functions](#code-extension-functions)
51+
* [Control Coding](#control-coding)
52+
* [Character Coding](#character-coding)
53+
* [Graphic Character Sets](#graphic-character-sets)
54+
* [Terminal Management Functions](#terminal-management-functions)
55+
* [Identification, status, and Initialization](#identification-status-and-initialization)
56+
* [Emulations](#emulations)
57+
* [Set-Up](#set-up)
58+
* [Display Coordinate System and Addressing](#display-coordinate-system-and-addressing)
59+
* [Active Position and Cursor](#active-position-and-cursor)
60+
* [Margins and Scrolling](#margins-and-scrolling)
61+
* [Cursor Movement](#cursor-movement)
62+
* [Horizontal Tabulation](#horizontal-tabulation)
63+
* [Page Size and Arrangement](#page-size-and-arrangement)
64+
* [Page Movement](#page-movement)
65+
* [Status Display](#status-display)
66+
* [Right to Left](#right-to-left)
67+
* [Window Management](#window-management)
68+
* [Visual Attributes and Renditions](#visual-attributes-and-renditions)
69+
* [Line Renditions](#line-renditions)
70+
* [Character Renditions](#character-renditions)
71+
* [Audible Indicators](#audible-indicators)
72+
* [Mode States](#mode-states)
73+
* [ANSI](#ansi)
74+
* [DEC Private](#dec-private)
75+
* [Editing Functions](#editing-functions)
76+
* [OLTP Features](#oltp-features)
77+
* [Rectangular Area Operations](#rectangular-area-operations)
78+
* [Data Integrity](#data-integrity)
79+
* [Macros](#macros)
80+
* [Saving and Restoring Terminal State](#saving-and-restoring-terminal-state)
81+
* [Cursor Save Buffer](#cursor-save-buffer)
82+
* [Terminal State Interrogation](#terminal-state-interrogation)
83+
* [Keyboard Processing Functions](#keyboard-processing-functions)
84+
* [Soft Key Mapping (UDK)](#soft-key-mapping-udk)
85+
* [Soft Fonts (DRCS)](#soft-fonts-drcs)
86+
* [Printing](#printing)
87+
* [Terminal Communication and Synchronization](#terminal-communication-and-synchronization)
88+
* [Text Locator Extension](#text-locator-extension)
89+
* [Session Management Extension](#session-management-extension)
90+
* [Documented Exceptions](#documented-exceptions)
91+
92+
$($sequences | ForEach-Object {
93+
if ($method = $base[$_.sequence]) {
94+
$_.ImplementedBy = $method
95+
$_.ConsoleHost = $conhost[$method]
96+
$_.Terminal = $terminal[$method]
97+
}
98+
# "Sequence","Associated","Description","Origin","Heading","Subheading", "ImplementedBy", "ConsoleHost","Terminal"
99+
100+
$shouldRenderHeader = $false
101+
102+
if ($heading -ne $_.heading) {
103+
$heading = $_.heading
104+
@"
105+
106+
## $heading
107+
108+
"@
109+
$shouldRenderHeader = $true
110+
}
111+
112+
if ($subheading -ne $_.subheading) {
113+
$subheading = $_.subheading
114+
@"
115+
116+
### $subheading
117+
118+
"@
119+
$shouldRenderHeader = $true
120+
}
121+
122+
if ($shouldRenderHeader) {
123+
@"
124+
125+
|Symbol|Function|Origin&nbsp;&#x1F5B3;|Console Host|Terminal|
126+
|:-|:--|:--:|:--:|:--:|
127+
"@
128+
}
129+
@"
130+
131+
|[$($_.Sequence)]($prefix$($_.sequence).html)|$($_.description)|$($_.origin)|$(if ($_.consolehost) {"&#x2713;"})|$(if ($_.terminal) {"&#x2713;"})|
132+
"@
133+
})
134+
135+
---
136+
Generated on $(get-date -DisplayHint DateTime)
137+
"@

0 commit comments

Comments
 (0)