Skip to content

Commit

Permalink
Add pwsh scripts to generate markdown artifact(s) for VT support across
Browse files Browse the repository at this point in the history
conhost and windows terminal
  • Loading branch information
oising committed Aug 7, 2019
1 parent 89925eb commit a7bad84
Show file tree
Hide file tree
Showing 3 changed files with 388 additions and 0 deletions.
137 changes: 137 additions & 0 deletions doc/reference/Build-VTSequenceIndex.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#requires -version 6.1

[cmdletbinding()]
param(
$solutionRoot = "..\..",
$interfacePath = @(join-path $solutionRoot "src\terminal\adapter\ITermDispatch.hpp"),
$consoleAdapterPath = $(join-path $solutionRoot "src\terminal\adapter\adaptDispatch.hpp"),
$terminalAdapterPath = $(join-path $solutionRoot "src\cascadia\terminalcore\terminaldispatch.hpp")
)

$base = @{}
$conhost = @{}
$terminal = @{}
$prefix = "https://vt100.net/docs/vt510-rm/"

# extract base interface
$baseScanner = [regex]'(?x)virtual\s\w+\s(?<method>\w+)(?s)[^;]+;(?-s).*?(?<seq>(?<=\/\/\s).+)'

$baseScanner.Matches((get-content -raw $interfacePath)) | foreach-object {
$match = $_
$_.groups["seq"].value.split(",") | ForEach-Object {
$base[$_.trim()] = $match.groups["method"].value
}
}

# match overrides of ITermDispatch
$scanner = [regex]'(?x)\s+\w+\s(?<method>\w+)(?s)[^;]+override;'

$scanner.Matches((Get-Content -raw $consoleAdapterPath)) | ForEach-Object {
#write-verbose $_.groups[0].value
$conhost[$_.groups["method"].value] = $true
}

$scanner.Matches((Get-Content -raw $terminalAdapterPath)) | ForEach-Object {
#write-verbose $_.groups[0].value
$terminal[$_.groups["method"].value] = $true
}

# "Sequence","Associated","Description","Origin","Heading","Subheading", "ImplementedBy", "ConsoleHost","Terminal"
$sequences = import-csv .\sequences.csv

$heading = $null
$subheading = $null

@"
# VT Function Support
## Table of Contents
* [Code Extension Functions](#code-extension-functions)
* [Control Coding](#control-coding)
* [Character Coding](#character-coding)
* [Graphic Character Sets](#graphic-character-sets)
* [Terminal Management Functions](#terminal-management-functions)
* [Identification, status, and Initialization](#identification-status-and-initialization)
* [Emulations](#emulations)
* [Set-Up](#set-up)
* [Display Coordinate System and Addressing](#display-coordinate-system-and-addressing)
* [Active Position and Cursor](#active-position-and-cursor)
* [Margins and Scrolling](#margins-and-scrolling)
* [Cursor Movement](#cursor-movement)
* [Horizontal Tabulation](#horizontal-tabulation)
* [Page Size and Arrangement](#page-size-and-arrangement)
* [Page Movement](#page-movement)
* [Status Display](#status-display)
* [Right to Left](#right-to-left)
* [Window Management](#window-management)
* [Visual Attributes and Renditions](#visual-attributes-and-renditions)
* [Line Renditions](#line-renditions)
* [Character Renditions](#character-renditions)
* [Audible Indicators](#audible-indicators)
* [Mode States](#mode-states)
* [ANSI](#ansi)
* [DEC Private](#dec-private)
* [Editing Functions](#editing-functions)
* [OLTP Features](#oltp-features)
* [Rectangular Area Operations](#rectangular-area-operations)
* [Data Integrity](#data-integrity)
* [Macros](#macros)
* [Saving and Restoring Terminal State](#saving-and-restoring-terminal-state)
* [Cursor Save Buffer](#cursor-save-buffer)
* [Terminal State Interrogation](#terminal-state-interrogation)
* [Keyboard Processing Functions](#keyboard-processing-functions)
* [Soft Key Mapping (UDK)](#soft-key-mapping-udk)
* [Soft Fonts (DRCS)](#soft-fonts-drcs)
* [Printing](#printing)
* [Terminal Communication and Synchronization](#terminal-communication-and-synchronization)
* [Text Locator Extension](#text-locator-extension)
* [Session Management Extension](#session-management-extension)
* [Documented Exceptions](#documented-exceptions)
$($sequences | ForEach-Object {
if ($method = $base[$_.sequence]) {
$_.ImplementedBy = $method
$_.ConsoleHost = $conhost[$method]
$_.Terminal = $terminal[$method]
}
# "Sequence","Associated","Description","Origin","Heading","Subheading", "ImplementedBy", "ConsoleHost","Terminal"
$shouldRenderHeader = $false
if ($heading -ne $_.heading) {
$heading = $_.heading
@"
## $heading
"@
$shouldRenderHeader = $true
}
if ($subheading -ne $_.subheading) {
$subheading = $_.subheading
@"
### $subheading
"@
$shouldRenderHeader = $true
}
if ($shouldRenderHeader) {
@"
|Symbol|Function|Origin&nbsp;&#x1F5B3;|Console Host|Terminal|
|:-|:--|:--:|:--:|:--:|
"@
}
@"
|[$($_.Sequence)]($prefix$($_.sequence).html)|$($_.description)|$($_.origin)|$(if ($_.consolehost) {"&#x2713;"})|$(if ($_.terminal) {"&#x2713;"})|
"@
})
---
Generated on $(get-date -DisplayHint DateTime)
"@
Loading

0 comments on commit a7bad84

Please sign in to comment.