Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 32 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
## WT64
# WT64
![alt text](https://github.com/KillerFeature/WT64/raw/master/WT64_hero.png)
A Commodore 64 Experience for Windows Terminal

![Video](https://github.com/KillerFeature/WT64/raw/master/video.gif "Video")

### Features
- Native C64 style commands like LOAD "$",8
- Native C64 LIST layout for directory listing with size reporting and Blocks free indication.
### FEATURES
- Native C64 style commands like `LOAD "$",8`
- Native C64 LIST layout for directory listing with size reporting and Blocks free indication
- Startup screen with actual PowerShell version and memory reporting

### Supported commands:
1. LIST <path> [Lists the files in local or path directory in C64 disk style]
2. LOAD "$",8 [Shows the classic loading sequence]
3. SYS64738 [Shows the opening prompt]
4. EDIT <filename> [Shorthand for nano]
### SUPPORTED COMMANDS
- **`LIST <path>`** Lists the files in local or path directory in C64 disk style
- **`LOAD "$",8`** Shows the classic loading sequence
- **`SYS64738`** Shows the opening prompt
- **`EDIT <filename>`** Alias for Nano
- **`RUN <filename>`** Run a file

### PREREQUISITES
1. [Windows Terminal](https://aka.ms/terminal) © Microsoft
2. [PowerShell 7](https://github.com/PowerShell/PowerShell/releases/latest) © Microsoft
3. [C64 font](https://www.dafont.com/commodore-64.font) © Devin Cook

### INSTALLATION
0. Make sure the prerequisites are installed
1. Clone the repo
2. Open Profile.json and cut paste the list item and colorschemen into your Windows Terminal Settings file
3. Change the places in your WT Settings where it says [INSERT YOUR REPO PATH HERE]
4. Start Windows Terminal open the WT64 teminal
2. Move or copy the files `commands.ps1`, `icon.png`, `P64_bg.png` & `reset.ps1` to a folder of your liking
I use a folder `WT64` in `Program Files`
3. Open `Profile.json`, cut & paste the **list item** and **colorscheme** into your Windows Terminal Settings file
`%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json`
4. Replace where it says `[INSERT YOUR REPO PATH HERE]` with the path of the folder you created in step 2 and save
5. Start Windows Terminal & open a WT64 terminal

### BACKGROUND
The standard background doesn't always scale properly, you can use the `P64_bg.svg` to create a new background that will have a 75px border and fit your screenresolution by followin these steps:
**1. Edit SVG**
Open the SVG in any text-editor and edit the width and height on the first in the viewBox & third line in the width and height attributes
It should be your screen width and your screen height minus taskbar (40px) and window header (36px)
If you don't use the taskbar or have it on the side of your screen adjust the height and width in the SVG accordingly
**2. Convert the SVG to PNG**
Open the SVG in an SVG capable photo-editor and save as P64_bg.png.
I use photopea.com for this, online, easy & free!
* Drag SVG onto center area or use `File > Open...`
* Select `File > Export as > PNG`
* Click `Save`
* If necessary rename the PNG-file to P64_bg.png
### BACKGROUND ISSUES
The standard background doesn’t always scale properly, you can use the `P64_bg.svg` to create a new background that will have a 75px border and fit your screenresolution by following these steps:
#### 1. Edit SVG
Open the SVG in any text-editor, edit the width and height on the first line in the viewBox attribute & third line in the width and height attributes and save
It should be your full screen width and height minus taskbar (40px) and window header (36px)
If you don’t use the taskbar or have it on the side of your screen adjust the height and width in the SVG accordingly
#### 2. Convert the SVG to PNG
Open the updated SVG in an SVG capable photo-editor and save as `P64_bg.png`

**3. Replace the background**
I use [PhotoPea](https://photopea.com) for this, online, easy & free!
- Drag the SVG-file onto center area or use `File > Open...`
- Select `File > Export as > PNG`
- Click `Save`
- If necessary rename the PNG-file to `P64_bg.png`
#### 3. Replace the background
Replace the current background with this newly created one by overwriting the current one in the location you have stored WT64
**4. Done!**
#### 4. Done!
Restart Windows Terminal and see the new background in action
222 changes: 130 additions & 92 deletions commands.ps1
Original file line number Diff line number Diff line change
@@ -1,134 +1,172 @@
$e = "$([char]27)"
#
# Public functions = C64 commands
#

function CenterText([string]$inputLine,[int]$textWidth,[string]$wrapChar) {
If (($inputLine.length + ($wrapChar.Length *2)) -ge $textWidth) {
function LIST([string]$dirName)
{
$midWidth = [int] (Get-Host).UI.RawUI.MaxWindowSize.Width - 4

return -join($wrapChar,$inputLine.Substring(0,$textWidth-2*$wrapChar.Length),$wrapChar)}
else {
$diff = ($textWidth+(2*$wrapChar.Length)) - $inputLine.Length
$spaceCount = [math]::Floor($diff/2)
$leadingSpaces = $(" " * $spaceCount)
if (-join( $wrapChar, $leadingSpaces, $inputLine, $leadingSpaces,$wrapChar).Length -lt $textWidth) {
return -join( $wrapChar, $leadingSpaces, $inputLine, $leadingSpaces,$wrapChar, " ")
} else {
return -join( $wrapChar, $leadingSpaces, $inputLine, $leadingSpaces,$wrapChar)

}
}
}
function LeftText([string]$inputLine,[int]$textWidth,[string]$wrapChar) {
If ($inputLine.length -ge $textWidth) {
return -join($inputLine.Substring(0,$textWidth))
if ($dirName.Length -gt 0)
{
$folderName = [System.IO.Path]::GetDirectoryName($dirName).toUpper().split("\")[-1]
}
else {
$diff = $textWidth- $inputLine.Length
$leadingSpaces = $(" " * $diff)
return -join($inputLine,$leadingSpaces)
else
{
$folderName = (Get-Location).toString().toUpper().split("\")[-1]
}

-join("0 $e[44m$e[94m$e[7m", (CenterText $folderName ($midWidth - 6)), "$e[27m$e[0m")
Get-ChildItem $dirName -directory | ForEach-Object { -join((LeftText ([math]::Round($_.Length/100)).ToString() 6), ' ', (RightText $_.name.toUpper() ($midWidth - 14) '"')) }
Get-ChildItem $dirName -file .* | ForEach-Object { -join((LeftText ([math]::Round($_.Length/100)).ToString() 6), ' ', (RightText $_.name.toUpper() ($midWidth - 14) '"')) }
Get-ChildItem $dirName -file *.* | ForEach-Object { if ($_.name.toUpper().Split('.')[0].Length -gt 0) { -join( (LeftText ([math]::Round($_.Length/100)).ToString() 6), ' ', (RightText ($_.BaseName.toUpper() -replace $_.Extension, '') ($midWidth - 14) '"'), ' ', $_.Extension.toUpper().TrimStart('.') ) } }
-join((Get-PSDrive c).Free, " BLOCKS FREE.")
"READY."
}

function RightText([string]$inputLine,[int]$textWidth,[string]$wrapChar) {
If (($inputLine.length+(2*$wrapChar.Length)) -ge $textWidth-1) {
$trimmed = $textWidth - (2*$wrapChar.Length)
return -join($wrapChar,$inputLine.Substring(0, $trimmed-2),$wrapChar," ")
}
else {
$diff = $textWidth - ($inputLine.Length+(2*$wrapChar.Length))

$leadingSpaces = $(" " * $diff)
return -join($wrapChar, $inputLine, $wrapChar, $leadingSpaces)
}

}
function LIST ([string]$dirName){
$midWidth = [int] (Get-Host).UI.RawUI.MaxWindowSize.Width - 4
if ($dirName.Length -gt 0) {
$folderName = [System.IO.Path]::GetDirectoryName($dirName).toUpper().split("\")[-1]
} else {
$folderName = (Get-Location).toString().toUpper().split("\")[-1]
}
$e = "$([char]27)"
-join("0 $e[44m$e[94m$e[7m",(CenterText $folderName ($midWidth-6)),"$e[27m$e[0m")
Get-ChildItem $dirName| ForEach-Object { -join((LeftText ([math]::Round($_.Length/100)).ToString() 6), ' ', (RightText $_.name.toUpper().Split(".")[0] ($midWidth-14) '"')," ", (RightText $_.name.toUpper().Split(".")[1] 10 ))}
-join((Get-PSDrive c).Free, " BLOCKS FREE.")
"READY."
}
function SYS64738() {
"$e[0m"
function SYS64738()
{
"$e[0m"
Clear-Host
""
$line1 = "**** WINDOWS TERMINAL POWERSHELL V" + $PSVersionTable.PSVersion.Major + "." + $PSVersionTable.PSVersion.Minor + " ****"
$line2 = " " + $mem + "K SYSTEM RAM "+ $free +"000 BASIC BYTES FREE"

CenterText $line1 ((Get-Host).UI.RawUI.MaxWindowSize.Width)
" "
CenterText $line2 ((Get-Host).UI.RawUI.MaxWindowSize.Width)
" "
"READY."
""
$line1 = "**** WINDOWS TERMINAL POWERSHELL V" + $PSVersionTable.PSVersion.Major + "." + $PSVersionTable.PSVersion.Minor + " ****"
$line2 = " " + $mem + "K SYSTEM RAM " + $free + "000 BASIC BYTES FREE"

CenterText $line1 ((Get-Host).UI.RawUI.MaxWindowSize.Width)
" "
CenterText $line2 ((Get-Host).UI.RawUI.MaxWindowSize.Width)
" "
"READY."
}

function LOAD([string]$inputLn) {
if ($inputLn -eq '$ 8') {
function LOAD([string]$inputLn)
{
if ($inputLn -eq '$ 8')
{
"SEARCHING FOR $"
Start-Sleep -Seconds 2
"LOADING"
Start-Sleep -Seconds 1
"READY."

} else {
}
else
{
"SYNTAX ERROR"
}
}
function EDIT ($File){
$File = $File -replace “\\”, “/” -replace “ “, “\ “
bash -c "nano $File"

function EDIT($File)
{
$File = $File -replace "\\", "/" -replace " ", "\ "

bash -c "nano $File"
}

function RUN($File)
{
Invoke-Item $File
}

function LET([string]$inputLn)
{
$regex = "^\s*$varNameRegEx\s*=\s*$expressionRegEx\s*"

if ($inputLn -notmatch $regex)
{
"SYNTAX ERROR"
}
else
{
$varName = $Matches[1]
$varType = $Matches[2]
$varCalculus = $Matches[3]
$varValue = (_CalculateExpressionValue $varCalculus)
Set-Variable -Name $varName -Value $varValue -Scope Global
# TODO: Include Type also
}
}

function PRINT([string]$inputLn)
{
Write-Host (_CalculateExpressionValue $inputLn)
}

#
# Internal commands (should be hidden inside of a module)
#

$varNameRegEx='([a-zA-Z]+)([\$|\%]?)' # returns name and type
$expressionRegEx='\s*(\S+)\s*' # returns expression
$e = "$([char]27)"
$varNameRegEx = '([a-zA-Z]+)([\$|\%]?)' # returns name and type
$expressionRegEx = '\s*(\S+)\s*' # returns expression

function _CalculateExpressionValue([string]$Expression) {
function _CalculateExpressionValue([string]$Expression)
{
# TODO: Hide this in module
while ($Expression -match $varNameRegEx) {
while ($Expression -match $varNameRegEx)
{
$Expression = $Expression -replace $Matches[0], [string](Get-Variable -Name $Matches[1] -ValueOnly -Scope Global)
}
try {

try
{
return (Invoke-Expression $Expression)
} catch {
}
catch
{
"SYNTAX ERROR"
}
}

function CenterText([string]$inputLine, [int]$textWidth, [string]$wrapChar)
{
if (($inputLine.length + ($wrapChar.Length * 2)) -ge $textWidth)
{
return -join($wrapChar, $inputLine.Substring(0, $textWidth - 2 * $wrapChar.Length), $wrapChar)
}
else
{
$diff = ($textWidth + (2 * $wrapChar.Length)) - $inputLine.Length
$spaceCount = [math]::Floor($diff / 2)
$leadingSpaces = $(" " * $spaceCount)

#
# Public functions = C64 commands
#

function RUN ($File){
Invoke-Item $File
if (-join( $wrapChar, $leadingSpaces, $inputLine, $leadingSpaces, $wrapChar).Length -lt $textWidth)
{
return -join( $wrapChar, $leadingSpaces, $inputLine, $leadingSpaces, $wrapChar, " ")
}
else
{
return -join( $wrapChar, $leadingSpaces, $inputLine, $leadingSpaces, $wrapChar)
}
}
}

function LET([string]$inputLn) {
$regex = "^\s*$varNameRegEx\s*=\s*$expressionRegEx\s*"
if ($inputLn -notmatch $regex) {
"SYNTAX ERROR"
exit
function LeftText([string]$inputLine, [int]$textWidth, [string]$wrapChar)
{
if ($inputLine.length -ge $textWidth)
{
return -join($inputLine.Substring(0, $textWidth))
}
else
{
$diff = $textWidth - $inputLine.Length
$leadingSpaces = $(" " * $diff)

$varName = $Matches[1]
$varType = $Matches[2]
$varCalculus = $Matches[3]
$varValue = (_CalculateExpressionValue $varCalculus)
Set-Variable -Name $varName -Value $varValue -Scope Global
# TODO: Include Type also
return -join($inputLine, $leadingSpaces)
}
}

function PRINT([string]$inputLn) {
Write-Host (_CalculateExpressionValue $inputLn)
function RightText([string]$inputLine, [int]$textWidth, [string]$wrapChar)
{
if (($inputLine.length + (2 * $wrapChar.Length)) -ge $textWidth - 1)
{
$trimmed = $textWidth - (2 * $wrapChar.Length)

return -join($wrapChar, $inputLine.Substring(0, $trimmed - 2), $wrapChar, " ")
}
else
{
$diff = $textWidth - ($inputLine.Length + (2 * $wrapChar.Length))
$leadingSpaces = $(" " * $diff)

return -join($wrapChar, $inputLine, $wrapChar, $leadingSpaces)
}
}
22 changes: 2 additions & 20 deletions reset.ps1
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
"LOADING PLEASE WAIT ..."
$e = "$([char]27)"
$mem = [regex]::Match((wmic OS get TotalVisibleMemorySize /Value),'[0-9]+').Value + ''
$free = [regex]::Match((wmic OS get FreePhysicalMemory /Value),'[0-9]+').Value + ''
$mem = [regex]::Match((wmic OS get TotalVisibleMemorySize /Value), '[0-9]+').Value + ''
$free = [regex]::Match((wmic OS get FreePhysicalMemory /Value), '[0-9]+').Value + ''

# This will display READY.\n as prompt
# function prompt {"READY.`n"}
function prompt {"`r"}
function CenterText([string]$inputLine,[int]$textWidth,[string]$wrapChar) {
If (($inputLine.length + ($wrapChar.Length *2)) -ge $textWidth) {

return -join($wrapChar,$inputLine.Substring(0,$textWidth-2*$wrapChar.Length),$wrapChar)}
else {
$diff = ($textWidth+(2*$wrapChar.Length)) - $inputLine.Length
$spaceCount = [math]::Floor($diff/2)
$leadingSpaces = $(" " * $spaceCount)
if (-join( $wrapChar, $leadingSpaces, $inputLine, $leadingSpaces,$wrapChar).Length -lt $textWidth) {
return -join( $wrapChar, $leadingSpaces, $inputLine, $leadingSpaces,$wrapChar, " ")

} else {
return -join( $wrapChar, $leadingSpaces, $inputLine, $leadingSpaces,$wrapChar)

}
}

}
$scriptRoot = Split-Path -parent $PSCommandPath
. "$scriptRoot\commands.ps1"

SYS64738