- Fix Enter key detection: handle multiple Enter key formats (\n, \r, \r\n) - Reduce flickering: lower render frequency from 60 FPS to 30 FPS - Fix menu bar visibility: re-render menu bar after content to prevent overwriting - Fix content positioning: explicit line positioning for categories and commands - Fix line shifting: clear lines before writing, control newlines manually - Limit visible items: prevent overflow with maxVisibleCategories/Commands - Improve CPU usage: increase sleep interval when no events processed This fixes: - Enter key not working for selection - Strong flickering of the application - Menu bar not visible or being overwritten - Top half of selection list not displayed - Lines being shifted/misaligned
154 lines
3.0 KiB
PHP
154 lines
3.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Framework\Console\Helpers;
|
|
|
|
/**
|
|
* Mock terminal capabilities for testing
|
|
*/
|
|
final class MockTerminal
|
|
{
|
|
private bool $isTerminal = true;
|
|
|
|
private bool $supportsAnsi = true;
|
|
|
|
private bool $supportsColors = true;
|
|
|
|
private bool $supportsTrueColor = false;
|
|
|
|
private int $width = 80;
|
|
|
|
private int $height = 24;
|
|
|
|
private bool $supportsMouse = false;
|
|
|
|
private string $termType = 'xterm-256color';
|
|
|
|
public function __construct()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Create a mock terminal with specific capabilities
|
|
*/
|
|
public static function create(
|
|
bool $isTerminal = true,
|
|
bool $supportsAnsi = true,
|
|
int $width = 80,
|
|
int $height = 24
|
|
): self {
|
|
$mock = new self();
|
|
$mock->isTerminal = $isTerminal;
|
|
$mock->supportsAnsi = $supportsAnsi;
|
|
$mock->width = $width;
|
|
$mock->height = $height;
|
|
|
|
return $mock;
|
|
}
|
|
|
|
/**
|
|
* Create a non-terminal mock (e.g., for CI environments)
|
|
*/
|
|
public static function nonTerminal(): self
|
|
{
|
|
return self::create(isTerminal: false, supportsAnsi: false);
|
|
}
|
|
|
|
/**
|
|
* Create a minimal terminal mock
|
|
*/
|
|
public static function minimal(): self
|
|
{
|
|
return self::create(isTerminal: true, supportsAnsi: true, width: 40, height: 10);
|
|
}
|
|
|
|
/**
|
|
* Create a full-featured terminal mock
|
|
*/
|
|
public static function fullFeatured(): self
|
|
{
|
|
$mock = self::create(isTerminal: true, supportsAnsi: true, width: 120, height: 40);
|
|
$mock->supportsTrueColor = true;
|
|
$mock->supportsMouse = true;
|
|
|
|
return $mock;
|
|
}
|
|
|
|
public function isTerminal(): bool
|
|
{
|
|
return $this->isTerminal;
|
|
}
|
|
|
|
public function supportsAnsi(): bool
|
|
{
|
|
return $this->supportsAnsi;
|
|
}
|
|
|
|
public function supportsColors(): bool
|
|
{
|
|
return $this->supportsColors;
|
|
}
|
|
|
|
public function supportsTrueColor(): bool
|
|
{
|
|
return $this->supportsTrueColor;
|
|
}
|
|
|
|
public function getWidth(): int
|
|
{
|
|
return $this->width;
|
|
}
|
|
|
|
public function getHeight(): int
|
|
{
|
|
return $this->height;
|
|
}
|
|
|
|
public function supportsMouse(): bool
|
|
{
|
|
return $this->supportsMouse;
|
|
}
|
|
|
|
public function getTermType(): string
|
|
{
|
|
return $this->termType;
|
|
}
|
|
|
|
public function setWidth(int $width): self
|
|
{
|
|
$this->width = $width;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setHeight(int $height): self
|
|
{
|
|
$this->height = $height;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setTermType(string $termType): self
|
|
{
|
|
$this->termType = $termType;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setSupportsMouse(bool $supports): self
|
|
{
|
|
$this->supportsMouse = $supports;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setSupportsTrueColor(bool $supports): self
|
|
{
|
|
$this->supportsTrueColor = $supports;
|
|
|
|
return $this;
|
|
}
|
|
}
|
|
|