From bcc5cc6df6db0106a1d5a001e3c00f37573d0937 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sun, 3 Jan 2021 18:32:46 +0100 Subject: [PATCH] Added write-marquee.ps1 --- Data/scripts.csv | 1 + README.md | 1 + Scripts/write-marquee.ps1 | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 Scripts/write-marquee.ps1 diff --git a/Data/scripts.csv b/Data/scripts.csv index e59412ac..b4752084 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -84,6 +84,7 @@ write-blue.ps1, writes the given text in a blue foreground color write-braille.ps1, writes the given text in Braille write-green.ps1, writes the given text in a green foreground color write-logbook.ps1, writes the given text to the logbook +write-marquee.ps1, writes the given text as marquee write-morse-code.ps1, writes the given text in Morse code write-motd.ps1, writes the message of the day (MOTD) write-red.ps1, writes the given text in a red foreground color diff --git a/README.md b/README.md index c17e6e4a..58c42d73 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol * [write-braille.ps1](Scripts/write-braille.ps1) - writes the given text in Braille * [write-green.ps1](Scripts/write-green.ps1) - writes the given text in a green foreground color * [write-logbook.ps1](Scripts/write-logbook.ps1) - writes the given text to the logbook +* [write-marquee.ps1](Scripts/write-marquee.ps1) - writes the given text as marquee * [write-morse-code.ps1](Scripts/write-morse-code.ps1) - writes the given text in Morse code * [write-motd.ps1](Scripts/write-motd.ps1) - writes the message of the day (MOTD) * [write-red.ps1](Scripts/write-red.ps1) - writes the given text in a red foreground color diff --git a/Scripts/write-marquee.ps1 b/Scripts/write-marquee.ps1 new file mode 100644 index 00000000..612c2e8d --- /dev/null +++ b/Scripts/write-marquee.ps1 @@ -0,0 +1,39 @@ +#!/snap/bin/powershell +<# +.SYNTAX ./write-marquee.ps1 [] ] +.DESCRIPTION writes the given text as marquee +.LINK https://github.com/fleschutz/PowerShell +.NOTES Author: Markus Fleschutz / License: CC0 +#> + +param([string]$Text = "", [int]$Speed = 60) # 60 ms pause +if ($Text -eq "") { + $Text = "PowerShell is powerful! PowerShell is cross-platform! PowerShell is open-source! PowerShell is easy to learn! Powershell is fully documented" +} + +function StartMarquee { param([string]$text) + $Length = $text.Length + $Start = 1 + $End = ($Length - 80) + + clear-host + write-output "" + write-output "------------------------------------------------------------------------------------" + $StartPosition = $HOST.UI.RawUI.CursorPosition + $StartPosition.X = 2 + write-output "| |" + write-output "------------------------------------------------------------------------------------" + + foreach ($Pos in $Start .. $End) { + $HOST.UI.RawUI.CursorPosition = $StartPosition + $TextToDisplay = $text.Substring($Pos, 80) + write-host -nonewline $TextToDisplay + start-sleep -milliseconds $Speed + } + write-output "" + write-output "" + write-output "" +} + +StartMarquee " +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text" +exit 0