diff --git a/PSCalendar.psd1 b/PSCalendar.psd1 index cfd2527..67e6bbb 100644 --- a/PSCalendar.psd1 +++ b/PSCalendar.psd1 @@ -7,7 +7,7 @@ RootModule = 'PSCalendar.psm1' # Version number of this module. - ModuleVersion = '1.9.0' + ModuleVersion = '1.10.0' # Supported PSEditions CompatiblePSEditions = @("Desktop", "Core") @@ -22,7 +22,7 @@ CompanyName = 'JDH Information Technology Solutions, Inc.' # Copyright statement for this module - Copyright = '(c) 2018-19 JDH Information Technology Solutions, Inc. All rights reserved.' + Copyright = '(c) 2018-2020 JDH Information Technology Solutions, Inc. All rights reserved.' # Description of the functionality provided by this module Description = 'A PowerShell module to display a calendar in the console.' diff --git a/README.md b/README.md index cb43bb9..702da9e 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ [![PSGallery Version](https://img.shields.io/powershellgallery/v/PSCalendar.png?style=for-the-badge&logo=powershell&label=PowerShell%20Gallery)](https://www.powershellgallery.com/packages/PSCalendar/) [![PSGallery Downloads](https://img.shields.io/powershellgallery/dt/PSCalendar.png?style=for-the-badge&label=Downloads)](https://www.powershellgallery.com/packages/PSCalendar/) -This module contains a few functions for displaying a calendar in the PowerShell console. The primary function is based on code originally published by Lee Holmes at [http://www.leeholmes.com/blog/2008/12/03/showing-calendars-in-your-oof-messages/](http://www.leeholmes.com/blog/2008/12/03/showing-calendars-in-your-oof-messages/) -. +This module contains a few functions for displaying a calendar in the PowerShell console. The primary function is based on code originally published by Lee Holmes at [http://www.leeholmes.com/blog/2008/12/03/showing-calendars-in-your-oof-messages/](http://www.leeholmes.com/blog/2008/12/03/showing-calendars-in-your-oof-messages/). You can install this module from the PowerShell Gallery. @@ -57,10 +56,43 @@ PS C:\> Show-GuiCalendar 12/2018 2/2019 -highlight 12/24/18,12/25/18,12/31/18,1/ The calendar form is transparent. But you should be able to click on it to drag it around your screen. You can also use the + and - keys to increase or decrease the calendar's opacity. Be aware that if you close the PowerShell session that launched the calendar, the calendar too will close. -This function requires the WPF-related assemblies. It should work in Windows PowerShell. For PowerShell Core and later it might or might not work depending on your platform. You will receive a warning if any incompatibility is detected. +This function requires the WPF-related assemblies. It should work in Windows PowerShell and PowerShell 7. You will receive a warning if any incompatibility is detected. + +## A Console Calendar Prompt + +One way you might want to use this is in your PowerShell console. You can use prompt function like this: + +```powershell + +Function prompt { + + #define a buffercell fill + $fill = [system.management.automation.host.buffercell]::new(" ",$host.ui.RawUI.BackgroundColor,$host.ui.RawUI.BackgroundColor,"complete") + + #define a rectangle with an upper left corner at 100,0 + $r = [System.Management.Automation.Host.Rectangle]::new(100,0,$host.ui.rawui.windowsize.width,15) + + #clear the area for the calendar display + $host.ui.rawui.SetBufferContents($r,$fill) + + #show the calendar in the upper right corner of the console + Show-Calendar -Position ([system.management.automation.host.coordinates]::new($host.ui.RawUI.WindowSize.width - 42,0)) + + "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "; + +# .Link +# https://go.microsoft.com/fwlink/?LinkID=225750 +# .ExternalHelp System.Management.Automation.dll-help.xml + +} +``` + +Assuming the width of your console is at least 120, this code should work. Otherwise, you might need to tweak positioning. This should also work in Windows Terminal. If you add some highlighted dates using `$PSDefaultParameterValues`, then you'll have a calendar right in front of you. + +![console calendar](assets/console-calendar.png) ## Potential Issues I have tried to make this module culture aware. Testing across cultures is not an easy process. If you encounter a problem and are not running PowerShell under the EN-US culture, run the command you are trying to use with -Verbose and post the results in a new issue. -last updated 2019-11-08 19:17:27Z UTC +last updated 2020-01-30 20:05:00Z UTC diff --git a/assets/console-calendar.png b/assets/console-calendar.png new file mode 100644 index 0000000..df9357e Binary files /dev/null and b/assets/console-calendar.png differ diff --git a/calendar-functions.ps1 b/calendar-functions.ps1 index 93f6682..9a975f6 100644 --- a/calendar-functions.ps1 +++ b/calendar-functions.ps1 @@ -241,6 +241,7 @@ Function Show-Calendar { if ($position) { #save current cursor location $here = $host.ui.RawUI.CursorPosition + # New-WPFMessageBox $here [void]$PSBoundParameters.remove("Position") } @@ -317,7 +318,6 @@ Function Show-Calendar { } else { Write-Host "$(($day).PadLeft($l," "))$spacer" -nonewline - } } @@ -334,7 +334,6 @@ Function Show-Calendar { if ($Position) { #set cursor position back - $here.y++ $host.ui.RawUI.CursorPosition = $here } @@ -373,7 +372,6 @@ Function Show-GuiCalendar { [ValidateSet("Segoi UI", "QuickType", "Tahoma", "Lucida Console", "Century Gothic")] [string]$Font = "Segoi UI", - [Parameter(HelpMessage = "Select a font style for your calendar." )] [ValidateSet("Normal", "Italic", "Oblique")] [string]$FontStyle = "Normal", diff --git a/changelog.md b/changelog.md index 55d47b8..28f6568 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Change Log for PSCalendar +## v1.10.0 + ++ Fixed cursor positioning in `Show-Calendar` ++ Refreshed some of the help examples ++ Updated `README.md` + ## v1.9.0 + Modified manifest to export all public functions and aliases diff --git a/docs/Get-Calendar.md b/docs/Get-Calendar.md index 0428127..36c630a 100644 --- a/docs/Get-Calendar.md +++ b/docs/Get-Calendar.md @@ -36,16 +36,15 @@ This command displays a visual representation of a calendar. It supports multipl ```powershell PS C:\> Get-Calendar - September 2018 - -Sun Mon Tue Wed Thu Fri Sat ---- --- --- --- --- --- --- - 26 27 28 29 30 31 1 - 2 3 4 5 6 7 8 - 9 10 11 12 13 14 15 - 16 17 18 19 20 21 22 - 23 24 25 *26* 27 28 29 - 30 1 2 3 4 5 6 + January 2020 + + Sun Mon Tue Wed Thu Fri Sat +---- ---- ---- ---- ---- ---- ---- + 29 30 31 1 2 3 4 + 5 6 7 8 9 10 11 + 12 13 14 15 16 17 18 + 19 20 21 22 23 24 25 + 26 27 28 29 * 30* 31 1 ``` Show the current calendar and highlight today. The month name will be centered in your output. @@ -53,53 +52,52 @@ Show the current calendar and highlight today. The month name will be centered i ### EXAMPLE 2 ```powershell -PS C:\> Get-Calendar -start "3/1/2019" -end "5/1/2019" - - March 2019 - -Sun Mon Tue Wed Thu Fri Sat ---- --- --- --- --- --- --- - 24 25 26 27 28 1 2 - 3 4 5 6 7 8 9 - 10 11 12 13 14 15 16 - 17 18 19 20 21 22 23 - 24 25 26 27 28 29 30 - 31 1 2 3 4 5 6 - - April 2019 - -Sun Mon Tue Wed Thu Fri Sat ---- --- --- --- --- --- --- - 7 8 9 10 11 12 13 - 14 15 16 17 18 19 20 - 21 22 23 24 25 26 27 - 28 29 30 1 2 3 4 - - May 2019 - -Sun Mon Tue Wed Thu Fri Sat ---- --- --- --- --- --- --- - 5 6 7 8 9 10 11 - 12 13 14 15 16 17 18 - 19 20 21 22 23 24 25 - 26 27 28 29 30 31 1 -``` +PS C:\> Get-Calendar -start "3/1/2020" -end "5/1/2020" + + March 2020 + + Sun Mon Tue Wed Thu Fri Sat +---- ---- ---- ---- ---- ---- ---- + 1 2 3 4 5 6 7 + 8 9 10 11 12 13 14 + 15 16 17 18 19 20 21 + 22 23 24 25 26 27 28 + 29 30 31 1 2 3 4 + + April 2020 + + Sun Mon Tue Wed Thu Fri Sat +---- ---- ---- ---- ---- ---- ---- + 5 6 7 8 9 10 11 + 12 13 14 15 16 17 18 + 19 20 21 22 23 24 25 +* 26* * 27* * 28* * 29* * 30* 1 2 + + May 2020 + + Sun Mon Tue Wed Thu Fri Sat +---- ---- ---- ---- ---- ---- ---- + 3 4 5 6 7 8 * 9* + 10 11 * 12* 13 14 15 16 + 17 18 19 20 21 22 23 + 24 25 26 27 28 29 30 + 31 1 2 3 4 5 6``` ### EXAMPLE 3 ```powershell -PS C:\> Get-Calendar -Start 12/1/2018 -end 12/1/2018 -HighlightDate 12/25/2018 - - December 2018 - -Sun Mon Tue Wed Thu Fri Sat ---- --- --- --- --- --- --- - 25 26 27 28 29 30 1 - 2 3 4 5 6 7 8 - 9 10 11 12 13 14 15 - 16 17 18 19 20 21 22 - 23 24 *25* 26 27 28 29 - 30 31 1 2 3 4 5 +PS C:\> Get-Calendar December -HighlightDate 12/4/2020,12/25/2020,12/24/2020,12/31/2020 + + + December 2020 + + Sun Mon Tue Wed Thu Fri Sat +---- ---- ---- ---- ---- ---- ---- + 29 30 1 2 3 * 4* 5 + 6 7 8 9 10 11 12 + 13 14 15 16 17 18 19 + 20 21 22 23 * 24* * 25* 26 + 27 28 29 30 * 31* 1 2 ``` Display a month and highlight a specific date. diff --git a/docs/Show-Calendar.md b/docs/Show-Calendar.md index c054696..c94f19b 100644 --- a/docs/Show-Calendar.md +++ b/docs/Show-Calendar.md @@ -36,10 +36,10 @@ Display a colorized version of the current month. The current day will also be c ### EXAMPLE 2 ```powershell -PS C:\> Show-Calendar -Month February -Year 2019 -HighlightDate 2/22/19 -HighlightColor red +PS C:\> Show-Calendar -Month February -Year 2020 -HighlightDate 2/22/20 -HighlightColor red ``` -Display February 2019 and highlight the 22nd in red. +Display February 2020 and highlight the 22nd in red. ### Example 3 diff --git a/docs/Show-GuiCalendar.md b/docs/Show-GuiCalendar.md index 77db3f2..df18288 100644 --- a/docs/Show-GuiCalendar.md +++ b/docs/Show-GuiCalendar.md @@ -37,7 +37,7 @@ Display the current month as a graphical calendar. ### Example 2 ```powershell -PS C:\> Show-GuiCalendar -start 12/2018 -end 2/2019 -highlight 12/24/18,12/25/18,12/31/18,1/1/19,2/14/19 -font 'Century Gothic' -FontStyle italic +PS C:\> Show-GuiCalendar -start 12/2019 -end 2/2020 -highlight 12/24/19,12/25/19,12/31/19,1/1/20,2/14/20 -font 'Century Gothic' -FontStyle italic ``` Display 3 months with selected dates highlighted and style the calendar to font settings. diff --git a/en-us/PSCalendar-help.xml b/en-us/PSCalendar-help.xml index 7330467..7e87db2 100644 --- a/en-us/PSCalendar-help.xml +++ b/en-us/PSCalendar-help.xml @@ -176,70 +176,69 @@ -------------------------- EXAMPLE 1 -------------------------- PS C:\> Get-Calendar - September 2018 + January 2020 -Sun Mon Tue Wed Thu Fri Sat ---- --- --- --- --- --- --- - 26 27 28 29 30 31 1 - 2 3 4 5 6 7 8 - 9 10 11 12 13 14 15 - 16 17 18 19 20 21 22 - 23 24 25 *26* 27 28 29 - 30 1 2 3 4 5 6 + Sun Mon Tue Wed Thu Fri Sat +---- ---- ---- ---- ---- ---- ---- + 29 30 31 1 2 3 4 + 5 6 7 8 9 10 11 + 12 13 14 15 16 17 18 + 19 20 21 22 23 24 25 + 26 27 28 29 * 30* 31 1 Show the current calendar and highlight today. The month name will be centered in your output. -------------------------- EXAMPLE 2 -------------------------- - PS C:\> Get-Calendar -start "3/1/2019" -end "5/1/2019" + PS C:\> Get-Calendar -start "3/1/2020" -end "5/1/2020" - March 2019 + March 2020 -Sun Mon Tue Wed Thu Fri Sat ---- --- --- --- --- --- --- - 24 25 26 27 28 1 2 - 3 4 5 6 7 8 9 - 10 11 12 13 14 15 16 - 17 18 19 20 21 22 23 - 24 25 26 27 28 29 30 - 31 1 2 3 4 5 6 + Sun Mon Tue Wed Thu Fri Sat +---- ---- ---- ---- ---- ---- ---- + 1 2 3 4 5 6 7 + 8 9 10 11 12 13 14 + 15 16 17 18 19 20 21 + 22 23 24 25 26 27 28 + 29 30 31 1 2 3 4 - April 2019 + April 2020 -Sun Mon Tue Wed Thu Fri Sat ---- --- --- --- --- --- --- - 7 8 9 10 11 12 13 - 14 15 16 17 18 19 20 - 21 22 23 24 25 26 27 - 28 29 30 1 2 3 4 + Sun Mon Tue Wed Thu Fri Sat +---- ---- ---- ---- ---- ---- ---- + 5 6 7 8 9 10 11 + 12 13 14 15 16 17 18 + 19 20 21 22 23 24 25 +* 26* * 27* * 28* * 29* * 30* 1 2 - May 2019 + May 2020 -Sun Mon Tue Wed Thu Fri Sat ---- --- --- --- --- --- --- - 5 6 7 8 9 10 11 - 12 13 14 15 16 17 18 - 19 20 21 22 23 24 25 - 26 27 28 29 30 31 1 + Sun Mon Tue Wed Thu Fri Sat +---- ---- ---- ---- ---- ---- ---- + 3 4 5 6 7 8 * 9* + 10 11 * 12* 13 14 15 16 + 17 18 19 20 21 22 23 + 24 25 26 27 28 29 30 + 31 1 2 3 4 5 6 -------------------------- EXAMPLE 3 -------------------------- - PS C:\> Get-Calendar -Start 12/1/2018 -end 12/1/2018 -HighlightDate 12/25/2018 + PS C:\> Get-Calendar December -HighlightDate 12/4/2020,12/25/2020,12/24/2020,12/31/2020 - December 2018 -Sun Mon Tue Wed Thu Fri Sat ---- --- --- --- --- --- --- - 25 26 27 28 29 30 1 - 2 3 4 5 6 7 8 - 9 10 11 12 13 14 15 - 16 17 18 19 20 21 22 - 23 24 *25* 26 27 28 29 - 30 31 1 2 3 4 5 + December 2020 + + Sun Mon Tue Wed Thu Fri Sat +---- ---- ---- ---- ---- ---- ---- + 29 30 1 2 3 * 4* 5 + 6 7 8 9 10 11 12 + 13 14 15 16 17 18 19 + 20 21 22 23 * 24* * 25* 26 + 27 28 29 30 * 31* 1 2 Display a month and highlight a specific date. @@ -529,9 +528,9 @@ Sun Mon Tue Wed Thu Fri Sat -------------------------- EXAMPLE 2 -------------------------- - PS C:\> Show-Calendar -Month February -Year 2019 -HighlightDate 2/22/19 -HighlightColor red + PS C:\> Show-Calendar -Month February -Year 2020 -HighlightDate 2/22/20 -HighlightColor red - Display February 2019 and highlight the 22nd in red. + Display February 2020 and highlight the 22nd in red. @@ -567,7 +566,7 @@ Sun Mon Tue Wed Thu Fri Sat - If you are running Windows PowerShell, you can display a graphical calendar. You can specify up to 3 months. There are also parameters to fine tune the calendar style. The calendar form is transparent. But you should be able to click on it to drag it around your screen. You can also use the + and - keys to increase or decrease the calendar's opacity. You may have to click on a calendar before making any adjustments. + If you are running Windows PowerShell or a version of PowerShell that supports Windows Presentation Foundation (WPF), you can display a graphical calendar. You can specify up to 3 months. There are also parameters to fine tune the calendar style. The calendar form itself is transparent, but you should be able to click on it to drag it around your screen. You can also use the + and - keys to increase or decrease the calendar's opacity. You may have to click on a calendar before making any adjustments. This command launches the calendar in a separate runspace so that it doesn't block your prompt. However, if you close the PowerShell session that launched the calendar, the calendar will also automatically close. @@ -761,6 +760,7 @@ Sun Mon Tue Wed Thu Fri Sat + This function requires the WPF-related assemblies. It should work in Windows PowerShell. For PowerShell Core and later it might or might not work depending on your platform. You will receive a warning if any incompatibility is detected. This command should have an alias of gcal. Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ @@ -775,7 +775,7 @@ Sun Mon Tue Wed Thu Fri Sat -------------------------- Example 2 -------------------------- - PS C:\> Show-GuiCalendar -start 12/2018 -end 2/2019 -highlight 12/24/18,12/25/18,12/31/18,1/1/19,2/14/19 -font 'Century Gothic' -FontStyle italic + PS C:\> Show-GuiCalendar -start 12/2019 -end 2/2020 -highlight 12/24/19,12/25/19,12/31/19,1/1/20,2/14/20 -font 'Century Gothic' -FontStyle italic Display 3 months with selected dates highlighted and style the calendar to font settings. diff --git a/license.txt b/license.txt index 97ba7d2..5cd6776 100644 --- a/license.txt +++ b/license.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2019 JDH Information Technology Solutions, Inc. +Copyright (c) 2018-2020 JDH Information Technology Solutions, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy