Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signals: need a way to determine if the host is capable of displaying emojis #115

Open
3 tasks done
plastikfan opened this issue Feb 7, 2021 · 8 comments
Open
3 tasks done
Assignees
Labels
feature New feature or request

Comments

@plastikfan
Copy link
Collaborator

plastikfan commented Feb 7, 2021

The standard console on windows does not render emojis and the same probably applies to PowerShell ISE. We need to detect if the host can render emojis. We need to define an alternate scheme which uses ascii characeters instead of unicode characters.

The following needs to be implemented

  • Define mutiple functions on a per platfrom level to determine if emojis can be displayed
  • The data structure holding signals will contain an extra field contain non emoji representation of the signal
  • Change Show-Signals to use the new table functionality to display the signals in a coloured table (this will act as a show-case for the table functionality)
@plastikfan plastikfan added the feature New feature or request label Feb 7, 2021
@plastikfan plastikfan self-assigned this Feb 7, 2021
@plastikfan
Copy link
Collaborator Author

plastikfan commented Feb 7, 2021

@plastikfan
Copy link
Collaborator Author

plastikfan commented Feb 8, 2021

It looks as though this is not easily solvable at the moment. As a result of raising this issue ( How to determine if the current host can display emoji characters programmically ), the best solution for now is to perform multiple application specific checks and invoke via invoke-ByPlatform.

For windows:

  • Windows Terminal: check if $env:WT_SESSION is set
  • Fluent terminal: $env:TERM_PROGRAM => FluentTerminal
    (PS: $env:TERM_PROGRAM not supported by WC or WT)

the rest tbd

@plastikfan
Copy link
Collaborator Author

@plastikfan
Copy link
Collaborator Author

plastikfan commented Mar 15, 2021

Changing Krayola's use of pair is way too destructive. Another aolution will be required instead. We need to maintain the pair structure and can do so by creating a new function that takes the original pair and a non unicode chacter sequence and create the actual pair depending on what info has been gleened from the execution environment. initialize-Signals assumes the signals are defined as pairs. So we can change this so that it only expects an array, which will now be a 3 element array, with the 3rd element being the non unicode defintion.

@plastikfan
Copy link
Collaborator Author

plastikfan commented Mar 16, 2021

NB: it was initially thought that I would have to modify Update-CustomSignals to provide a non unicode representation of the custom override signal. However, it soon transpired that this was not necessary. An example usage of the override definied in the user profile would look something like this:

[hashtable]$MySignals = @{
  'PATTERN' = $(kp(@('Pattern', '🎃')));
  'WHAT-IF' = $(kp(@('What If', '💜')));
}
Update-CustomSignals -Signals $MySignals;

Note, the creation of a pair instance via kp. Since Update-CustomSignals is working in the 'pair', realm as opposed to the 'array' realm, no change is required. Initialize-Signals, now take a hash of 3 item arrays (the array realm) and coverts that to a hash of pairs (the pairs realm).

@plastikfan
Copy link
Collaborator Author

NB: this representation (About Special Characters):

"`u{1F4A9}"

of a unicode character is only supported on Powershell version 7.0+

@plastikfan
Copy link
Collaborator Author

plastikfan commented Mar 16, 2021

Argh, just discovered that Show-AsTable is at fault. It is still using ApiFormat on Krayon when it should be migrated to use the Scribbler.

Actually, this isnt as bad as initially thought. ApiFormatWithArg and ApiFormat are still defined on the Krayon, but its better to use the Snippets function on the Scribbler (which refers to ApiFormatWithArg and ApiFormat anyway).

@plastikfan
Copy link
Collaborator Author

plastikfan commented Mar 18, 2021

I have refrained from completing this:

  • Use unicode string to represent emojis, eg "`u{1F4A9}"

for the time being because that representation is only supported on powershell 7.1, but more importantly, if this change were made, the source fle (globals.ps1) would become human unreadable. There is a balancing act here, because I'm not sure if its ok to have a source code file as UTF-8 with BOM (as it currently is, with the embedded emojis which clearly aids human readability). Not quite a hobson's choice, but there is a problem.

See: about_Character_Encoding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant