chore: update console components, logging, router and add subdomain support
This commit is contained in:
@@ -130,12 +130,19 @@ final class InputParser
|
||||
$parts = explode(';', $data);
|
||||
|
||||
if (count($parts) < 3) {
|
||||
// Invalid mouse event format, discard
|
||||
return null;
|
||||
}
|
||||
|
||||
$buttonCode = (int) $parts[0];
|
||||
$x = (int) $parts[1];
|
||||
$y = (int) $parts[2];
|
||||
|
||||
// Validate coordinates (basic sanity check to catch corrupted events)
|
||||
if ($x < 1 || $y < 1 || $x > 1000 || $y > 1000) {
|
||||
// Invalid coordinates, likely corrupted event - discard silently
|
||||
return null;
|
||||
}
|
||||
|
||||
// Decode button and modifiers
|
||||
// Bit flags in button code:
|
||||
@@ -143,7 +150,8 @@ final class InputParser
|
||||
// Bit 2: Shift
|
||||
// Bit 3: Meta/Alt
|
||||
// Bit 4: Ctrl
|
||||
// Bit 5-6: Polarity (64=scroll up, 65=scroll down)
|
||||
// Bit 5: Mouse move (32 = 0x20)
|
||||
// Bit 6-7: Scroll (64=scroll up, 65=scroll down)
|
||||
|
||||
$button = $buttonCode & 0x03;
|
||||
$shift = ($buttonCode & 0x04) !== 0;
|
||||
@@ -153,6 +161,10 @@ final class InputParser
|
||||
// Handle scroll events (button codes 64 and 65)
|
||||
if ($buttonCode >= 64 && $buttonCode <= 65) {
|
||||
$button = $buttonCode;
|
||||
} elseif (($buttonCode & 0x20) !== 0) {
|
||||
// Mouse move (button code 32 or bit 5 set)
|
||||
// Store full button code to detect mouse move
|
||||
$button = $buttonCode;
|
||||
}
|
||||
|
||||
$pressed = $buffer[-1] === 'M';
|
||||
@@ -238,5 +250,34 @@ final class InputParser
|
||||
usleep(1000); // 1ms
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Discard any remaining input characters from STDIN
|
||||
*/
|
||||
private function discardRemainingInput(): void
|
||||
{
|
||||
// Read and discard up to 50 characters to clear partial escape sequences
|
||||
$maxDiscard = 50;
|
||||
$discarded = 0;
|
||||
|
||||
while ($discarded < $maxDiscard) {
|
||||
$read = [STDIN];
|
||||
$write = null;
|
||||
$except = null;
|
||||
|
||||
$result = stream_select($read, $write, $except, 0, 1000); // 1ms
|
||||
|
||||
if ($result === false || $result === 0) {
|
||||
break; // No more input
|
||||
}
|
||||
|
||||
$char = fgetc(STDIN);
|
||||
if ($char === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
$discarded++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user