Skip to content

Commit

Permalink
initial draft of VT function support spec (#1884)
Browse files Browse the repository at this point in the history
conhost and windows terminal

renamed files; updated script to do summary output only, also quiet mode and option file path for output (else stdout)

added -quiet and fixed -summaryonly parameters

added hyperlink directly to soruce implementation for conhost and terminal seqs

Update doc/reference/master-sequence-list.csv

Co-Authored-By: James Holderness <j4_james@hotmail.com>

Apply suggestions from code review

Co-Authored-By: James Holderness <j4_james@hotmail.com>

Co-authored-by: James Holderness <j4_james@hotmail.com>
  • Loading branch information
oising and j4james authored Nov 13, 2020
1 parent e3fcfcc commit d4b6355
Show file tree
Hide file tree
Showing 3 changed files with 478 additions and 0 deletions.
239 changes: 239 additions & 0 deletions doc/reference/Build-SupportedSequenceIndex.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
#requires -version 6.1

<#
.SYNOPSIS
Scan source code and build a list of supported VT sequences.
.DESCRIPTION
Scan source code and build a list of supported VT sequences.
TODO: add more details
#>
[cmdletbinding(DefaultParameterSetName="stdout")]
param(
[parameter(ParameterSetName="file", mandatory)]
[string]$OutFile,
[parameter(ParameterSetName="file")]
[switch]$Force, # for overwriting $OutFile if it exists

[parameter(ParameterSetName="stdout")]
[parameter(ParameterSetName="file")]
[switch]$NoLogo, # no logo in summary
[parameter(ParameterSetName="stdout")]
[switch]$SummaryOnly, # no markdown generated
[parameter(ParameterSetName="stdout")]
[parameter(ParameterSetName="file")]
[switch]$Quiet, # no summary or logo

[parameter(ParameterSetName="file")]
[parameter(ParameterSetName="stdout")]
[string]$SolutionRoot = "..\..",
[parameter(ParameterSetName="file")]
[parameter(ParameterSetName="stdout")]
[string]$InterfacePath = $(join-path $solutionRoot "src\terminal\adapter\ITermDispatch.hpp"),
[parameter(ParameterSetName="file")]
[parameter(ParameterSetName="stdout")]
[string]$ConsoleAdapterPath = $(join-path $solutionRoot "src\terminal\adapter\adaptDispatch.hpp"),
[parameter(ParameterSetName="file")]
[parameter(ParameterSetName="stdout")]
[string]$TerminalAdapterPath = $(join-path $solutionRoot "src\cascadia\terminalcore\terminaldispatch.hpp")
)

if ($PSCmdlet.ParameterSetName -eq "stdout") {
Write-Verbose "Emitting markdown to STDOUT"
}

<#
GLOBALS
#>

[semver]$myVer = "0.6-beta"
$sequences = import-csv ".\master-sequence-list.csv"
$base = @{}
$conhost = @{}
$terminal = @{}
$prefix = "https://vt100.net/docs/vt510-rm/"
$repo = "https://github.com/oising/terminal/tree/master"
$conhostUrl = $ConsoleAdapterPath.TrimStart($SolutionRoot).replace("\", "/")
$terminalurl = $TerminalAdapterPath.TrimStart($SolutionRoot).replace("\", "/")

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

$baseScanner.Matches(($src = get-content -raw $interfacePath)) | foreach-object {
$match = $_
#$line = (($src[0..$_.Index] -join "") -split "`n").Length
#$decl = $_.groups[0].value
$_.groups["seq"].value.split(",") | ForEach-Object {
$SCRIPT:base[$_.trim()] = $match.groups["method"].value
}
}

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

$scanner.Matches(($src = Get-Content -raw $consoleAdapterPath)) | ForEach-Object {
$line = (($src[0..$_.Index] -join "") -split "`n").Length
$SCRIPT:conhost[$_.groups["method"].value] = $line
}

$scanner.Matches(($src = Get-Content -raw $terminalAdapterPath)) | ForEach-Object {
$line = (($src[0..$_.Index] -join "") -split "`n").Length
#write-verbose $_.groups[0].value
$SCRIPT:terminal[$_.groups["method"].value] = $line
}
}

function Get-SequenceIndexMarkdown {
# "Sequence","Parent","Description","Origin","Heading","Subheading", "ImplementedBy", "ConsoleHost","Terminal"

$heading = $null
$subheading = $null
<#
Emit markdown
TODO:
- autogenerate TOC
#>
@"
# 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"
$c0 = "[$($_.Sequence)]($prefix$($_.sequence).html ""View page on vt100.net"")"
$c1 = "$($_.description)"
$c2 = "$($_.origin)"
$c3 = $(if ($_.consolehost) {"[&#x2713;](${repo}/${conhostUrl}#L$($_.consolehost) ""View console host implementation"")"})
$c4 = $(if ($_.terminal) {"[&#x2713;](${repo}/${terminalUrl}#L$($_.terminal)} ""View windows terminal implementation"")"})
$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|
|:-|:--|:--:|:--:|:--:|
"@
}
@"
|$c0|$c1|$c2|$c3|$c4|
"@
})
---
Generated on $(get-date -DisplayHint DateTime)
"@
}

function Show-Summary {
write-host "`n$(' '*7)Windows Terminal Sequencer v${myVer}"
if (-not $NoLogo.IsPresent) {
Get-Content .\windows-terminal-logo.ans | ForEach-Object { Write-Host $_ }
}
$summary = @"
`e[1mSequence Support:`e[0m
`e[7m {0:000} `e[0m known in master-sequence-list.csv.
`e[7m {1:000} `e[0m common members in ITermDispatch base, of which:
`e[7m {2:000} `e[0m are implemented by ConsoleHost.
`e[7m {3:000} `e[0m are implemented by Windows Terminal.
"@ -f $sequences.Count, $base.count, $conhost.count, $terminal.Count

write-host $summary
}

<#
Entry Point
#>

Read-SourceFiles

if (-not $SummaryOnly.IsPresent) {

$markdown = Get-SequenceIndexMarkdown

if ($PSCmdlet.ParameterSetName -eq "file") {
# send to file and overwrite
$markdown | Out-File -FilePath $OutFile -Force:$Force.IsPresent -Encoding utf8NoBOM
} else {
# send to STDOUT
$markdown
}

if (-not $Quiet.IsPresent) {
Show-Summary
}
} else {
# summary only
Show-Summary
}
Loading

1 comment on commit d4b6355

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New misspellings found, please review:

  • Answerback
  • autogenerate
  • Autorepeat
  • cmdletbinding
  • consolehost
  • CRM
  • Cterm
  • DECAAM
  • DECARM
  • DECARSM
  • DECBI
  • DECBKM
  • DECCANSM
  • DECCAPSLK
  • DECCARA
  • DECCKD
  • DECCKSR
  • DECCRA
  • DECCRTSM
  • DECDC
  • DECDHLB
  • DECDHLT
  • DECDLD
  • DECDMAC
  • DECDWL
  • DECEFR
  • DECELR
  • DECERA
  • DECES
  • DECESKM
  • DECFI
  • DECFRA
  • DECHCCM
  • DECHCEM
  • DECHEBM
  • DECHPDXM
  • DECIC
  • DECID
  • DECINVM
  • DECKBD
  • DECKBUM
  • DECKLHIM
  • DECLANS
  • DECLBAN
  • DECLFC
  • DECLFKC
  • DECLKD
  • DECLL
  • DECLRP
  • DECLTOD
  • DECMCM
  • DECNAKB
  • DECNCSM
  • DECNULM
  • DECNUMLK
  • DECOSCNM
  • DECPAK
  • DECPCCM
  • DECPEX
  • DECPFF
  • DECPFK
  • DECPKA
  • DECRARA
  • DECRLCM
  • DECRQCRA
  • DECRQDE
  • DECRQKD
  • DECRQKT
  • DECRQLP
  • DECRQPKFM
  • DECRQPSR
  • DECRQSS
  • DECRQTSR
  • DECRQUPSS
  • DECRSPS
  • DECSACE
  • DECSCL
  • DECSCLM
  • DECSCP
  • DECSDDT
  • DECSDPT
  • DECSERA
  • DECSFC
  • DECSKCV
  • DECSLCK
  • DECSLE
  • DECSMBV
  • DECSNLS
  • DECSPP
  • DECSPPCS
  • DECSPRTT
  • DECSRC
  • DECSRFR
  • DECSSCLS
  • DECSSDT
  • DECSSL
  • DECST
  • DECSTRL
  • DECSTUI
  • DECSWBV
  • DECSWL
  • DECTID
  • DECTME
  • DECTST
  • DECUDK
  • DECVCCM
  • DECXRLM
  • drcs
  • erminaldispatch
  • Keyclick
  • oltp
  • Overscan
  • Proprinter
  • semver
  • terminalurl
  • udk
  • XCPR
  • XOFF
  • XON
To accept these changes, run the following commands
perl -e '
my @expect_files=qw('".github/actions/spell-check/expect/5757ec679b03a4240130c3c53766c91bbc5cd6a7.txt
.github/actions/spell-check/expect/655f007265b351e140d20b3976792523ad689241.txt
.github/actions/spell-check/expect/alphabet.txt
.github/actions/spell-check/expect/expect.txt
.github/actions/spell-check/expect/web.txt"');
@ARGV=@expect_files;
my @stale=qw('"AAAAA Bopomofo CParams CSV DECRST DECSC GENERATEPROJECTPRIFILE hhhh Inlines renamer
 rgus SGRXY UDKs Unfocus xe xlang "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^($re)(?:$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spell-check/expect/d4b635589c39c16c4fb1cb1777b652ede7df73c0.txt";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"Answerback autogenerate Autorepeat cmdletbinding consolehost CRM csv Cterm DECAAM DECARM DECARSM DECBI DECBKM DECCANSM DECCAPSLK DECCARA DECCKD DECCKSR DECCRA DECCRTSM DECDC DECDHLB DECDHLT DECDLD DECDMAC DECDWL DECEFR DECELR DECERA DECES DECESKM DECFI DECFRA DECHCCM DECHCEM DECHEBM DECHPDXM DECIC DECID DECINVM DECKBD DECKBUM DECKLHIM DECLANS DECLBAN DECLFC DECLFKC DECLKD DECLL DECLRP DECLTOD DECMCM DECNAKB DECNCSM DECNULM DECNUMLK DECOSCNM DECPAK DECPCCM DECPEX DECPFF DECPFK DECPKA DECRARA DECRLCM DECRQCRA DECRQDE DECRQKD DECRQKT DECRQLP DECRQPKFM DECRQPSR DECRQSS DECRQTSR DECRQUPSS DECRSPS decrst DECSACE decsc DECSCL DECSCLM DECSCP DECSDDT DECSDPT DECSERA DECSFC DECSKCV DECSLCK DECSLE DECSMBV DECSNLS DECSPP DECSPPCS DECSPRTT DECSRC DECSRFR DECSSCLS DECSSDT DECSSL DECST DECSTRL DECSTUI DECSWBV DECSWL DECTID DECTME DECTST DECUDK DECVCCM DECXRLM drcs erminaldispatch inlines Keyclick oltp Overscan Proprinter Renamer semver terminalurl udk unfocus XCPR XOFF XON "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
git add .github/actions/spell-check/expect || echo '... you want to ensure .github/actions/spell-check/expect/d4b635589c39c16c4fb1cb1777b652ede7df73c0.txt is added to your repository...'
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. You can copy the contents of each perl command excluding the outer ' marks and dropping any '"/"' quotation mark pairs into a file and then run perl file.pl from the root of the repository to run the code. Alternatively, you can manually insert the items...

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spell-check/dictionary/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spell-check/dictionary/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spell-check/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spell-check/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The :check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

⚠️ Reviewers

At present, the action that triggered this message will not show its ❌ in this PR unless the branch is within this repository.
Thus, you should make sure that this comment has been addressed before encouraging the merge bot to merge this PR.

Please sign in to comment.