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

Info is mis-aligned when the window height is less than the image height #1

Open
TMA-2 opened this issue Jan 19, 2025 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@TMA-2
Copy link
Owner

TMA-2 commented Jan 19, 2025

Description

Due to how the information is written (first the image, then each function output to the right), if the console height is too small and auto-scrolls with output, the function output will start being written at $img.length - [Console]::WindowHeight, sometimes being cut off depending on the terminal being used. This is usually seen in terminals with limited space like the terminal within an IDE.

Examples

Windows Terminal, squashed down to a height of 13

PS C:\> [System.Console]::WindowHeight
13

PS C:\> winfetch.ps1

 lllllllllllllll   lllllllllllllll
 lllllllllllllll   lllllllllllllll
 lllllllllllllll   lllllllllllllll
 lllllllllllllll   lllllllllllllll
 lllllllllllllll   lllllllllllllll  tma2@VOID
 lllllllllllllll   lllllllllllllll  ---------
 lllllllllllllll   lllllllllllllll  Shell: PowerShell v5.1.26100.2161
                                    Terminal: Windows Terminal
 lllllllllllllll   lllllllllllllll  OS: Windows 11 Home [64-bit]
 lllllllllllllll   lllllllllllllll  Kernel: 10.0.26100.0
 lllllllllllllll   lllllllllllllll  CPU: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.419GHz
 lllllllllllllll   lllllllllllllll  GPU: Intel(R) Iris(R) Xe Graphics
 lllllllllllllll   lllllllllllllll  Resolution: 2736x1824 @ 59Hz
 lllllllllllllll   lllllllllllllll  Uptime: 3 days 8 hours 1 minute
 lllllllllllllll   lllllllllllllll  PS Packages: 3 Modules
                                    Applications: 206 installed

VS Code

PS C:\> [System.Console]::WindowHeight
24

PS C:\> winfetch.ps1

                     ....,,:;+ccllll
       ...,,+:;  cllllllllllllllllll
 ,cclllllllllll  lllllllllllllllllll
 llllllllllllll  lllllllllllllllllll
 llllllllllllll  lllllllllllllllllll
 llllllllllllll  lllllllllllllllllll
 llllllllllllll  lllllllllllllllllll  tma2@VM1
 llllllllllllll  lllllllllllllllllll  Shell: PowerShell v5.1.19041.5369
                                      Terminal: Visual Studio Code
 llllllllllllll  lllllllllllllllllll  --------
 llllllllllllll  lllllllllllllllllll  PSReadLine Ver.: 2.3.4
 llllllllllllll  lllllllllllllllllll  MECM Ver.: 5.2403.1171.2400
 llllllllllllll  lllllllllllllllllll  Tanium Ver.: 7.6.4.2010
 llllllllllllll  lllllllllllllllllll  .NET Version: 4.8.4772.0
 `'ccllllllllll  lllllllllllllllllll  PS Packages: 19 Modules
       `' \\*::  :ccllllllllllllllll  --------
                        ````''*::cll  OS: Windows 10 Enterprise [64-bit]
                                  ``  Kernel: 10.0.19045.0
                                      Uptime: 11 hours 35 minutes
                                      CPU Usage: [ ■■■■■----- ] 270 processes
                                      Memory:    [ ■■■■■■---- ] 10.25 GiB / 16 GiB
                                      Disk (C:): [ ■■■■■■■■-- ] 163 GiB / 217 GiB
                                      Local IP: xx.xx.xx.xx

Then, after entering another command and re-sizing the terminal, some lines repeated (~line 17):

                     ....,,:;+ccllll
       ...,,+:;  cllllllllllllllllll
 ,cclllllllllll  lllllllllllllllllll
 llllllllllllll  lllllllllllllllllll
 llllllllllllll  lllllllllllllllllll
 llllllllllllll  lllllllllllllllllll
 llllllllllllll  lllllllllllllllllll  tma2@VM1
 llllllllllllll  lllllllllllllllllll  Shell: PowerShell v5.1.19041.5369
                                      Terminal: Visual Studio Code
 llllllllllllll  lllllllllllllllllll  --------
 llllllllllllll  lllllllllllllllllll  PSReadLine Ver.: 2.3.4
 llllllllllllll  lllllllllllllllllll  MECM Ver.: 5.2403.1171.2400
 llllllllllllll  lllllllllllllllllll  Tanium Ver.: 7.6.4.2010
 llllllllllllll  lllllllllllllllllll  .NET Version: 4.8.4772.0
 `'ccllllllllll  lllllllllllllllllll  PS Packages: 19 Modules
       `' \\*::  :ccllllllllllllllll  --------
       `' \\*::  :ccllllllllllllllll  --------
       `' \\*::  :ccllllllllllllllll  --------
       `' \\*::  :ccllllllllllllllll  --------
                        ````''*::cll  OS: Windows 10 Enterprise [64-bit]
                                  ``  Kernel: 10.0.19045.0
                                      Uptime: 11 hours 35 minutes
                                      CPU Usage: [ ■■■■■----- ] 270 processes
                                      Memory:    [ ■■■■■■---- ] 10.25 GiB / 16 GiB
                                      Disk (C:): [ ■■■■■■■■-- ] 163 GiB / 217 GiB
                                      Local IP: xx.xx.xx.xx

Expected Behavior

The information and image should always be aligned, regardless of the console size.

Actual Behavior

The information column is mis-aligned when the terminal window height is smaller than the image height. This is due to the order of events. The image $img is drawn, then the cursor is moved back to the top to its right with Write-Output "$e[$($img.Length + 1)A".

If there's a way to move the cursor in such a way independent of the terminal size or where it's scrolled, that would be ideal. About everything is done with VT control codes in winfetch, but there are plenty of .NET methods in [Console] that might be used.

@TMA-2 TMA-2 added the bug Something isn't working label Jan 19, 2025
@TMA-2 TMA-2 self-assigned this Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant