Skip to content

[Console] Fixed output glitches when trying to use sectioned output larger then terminal and made terminal utility aware of resizes #41266

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

Closed
wants to merge 21 commits into from

Conversation

arnegroskurth
Copy link
Contributor

@arnegroskurth arnegroskurth commented May 18, 2021

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #24224 , Fix #29746 , Fix #35012
Tickets (maybe) Fix #37304
License MIT
Doc PR -

The current console section utility implementation was not aware of the output terminals dimensions causing a variety of rendering glitches when trying to cear or overwrite section contents that are larger then the displaying terminal.

Root of the problem is the inability to move the cursor above the terminal home position using ANSI/VT100 control escape sequences. The implementation has been extended to:

  • compute and apply partial differences limited to the visible part of the terminal
  • react on terminal window resizes by redrawing the now visible part of the section
  • keep track of dirty lines above the terminal that are still to be cleared/overwritten in case they are loaded back onto the terminal due to the terminal being resized

However, there a couple of things I'm not sure about:

  • To detect terminal window resizes, the implementation uses the pcntl extension to listen for the POSIX SIGWINCH signal - is there anything similar to this on Windows?

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@arnegroskurth arnegroskurth marked this pull request as draft May 18, 2021 15:03
@fancyweb
Copy link
Contributor

It might fix #35012

@arnegroskurth arnegroskurth changed the base branch from 5.x to 4.4 May 18, 2021 21:19
…n terminal

The current console section utility implementation was not aware of the output terminals dimensions causing a variety of rendering glitches when trying to overwrite section contents that are larger then the displaying terminal.

Root of the problem is the inability to move the cursor above the terminal home position using ANSI/VT100 control escape sequences. The implementation has been extended to compute and apply partial differences limited to the visible part of the terminal.
@arnegroskurth arnegroskurth changed the title [ConsoleComponent] Implemented support for output sections larger then terminal [ConsoleComponent] Fixed output glitches when trying to use sectioned output larger then terminal May 19, 2021
@arnegroskurth arnegroskurth changed the title [ConsoleComponent] Fixed output glitches when trying to use sectioned output larger then terminal [ConsoleComponent] Fixed output glitches when trying to use sectioned output larger then terminal and made terminal utility aware of resizes May 19, 2021
@carsonbot carsonbot changed the title [ConsoleComponent] Fixed output glitches when trying to use sectioned output larger then terminal and made terminal utility aware of resizes [Console] [ConsoleComponent] Fixed output glitches when trying to use sectioned output larger then terminal and made terminal utility aware of resizes May 20, 2021
@derrabus derrabus changed the title [Console] [ConsoleComponent] Fixed output glitches when trying to use sectioned output larger then terminal and made terminal utility aware of resizes [Console] Fixed output glitches when trying to use sectioned output larger then terminal and made terminal utility aware of resizes May 20, 2021
@chalasr
Copy link
Member

chalasr commented Dec 14, 2021

@arnegroskurth What is the state of this PR? Do you plan to finish it at some point? If not, any hint about what needs to be done in order to finish it would be appreciated, so that someone else can take over.

@chalasr
Copy link
Member

chalasr commented Jun 9, 2022

Closing due to the lack of feedback. Thanks for starting this, hope someone will take over.

@chalasr chalasr closed this Jun 9, 2022
if ($message !== '' && substr($message, -1) !== PHP_EOL) {
$message .= PHP_EOL;
$messageWithNewline = $message;
if ($messageWithNewline !== '' && substr($messageWithNewline, -1) !== PHP_EOL) {
Copy link
Contributor

@bhujagendra-ishaya bhujagendra-ishaya Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note, PHP_EOL can be two characters long (on Windows): https://heap.space/xref/php-src/main/php.h?r=bf29ee69#66

Hence, something like str_ends_with($messageWithNewline, \PHP_EOL) (From php 8.0 or polifill) would be required here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants