Skip to content

Commit 78b2f18

Browse files
committed
Switch screen functionality
There's 2 "screens" that I've called primary and secondary here Switching the screen allows doing things without impact the primary one vim and less use this which is why when you quit you have no evidance of it
1 parent c3a87b9 commit 78b2f18

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/UnixTerminal.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ public function moveCursorToColumn(int $column) : void
229229
$this->output->write(sprintf("\033[%dC", $column));
230230
}
231231

232+
public function showSecondaryScreen() : void
233+
{
234+
$this->output->write("\033[?47h");
235+
}
236+
237+
public function showPrimaryScreen() : void
238+
{
239+
$this->output->write("\033[?47l");
240+
}
241+
232242
/**
233243
* Read bytes from the input stream
234244
*/

test/UnixTerminalTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,28 @@ public function testMoveCursorToColumn() : void
229229
self::assertEquals("\033[10C", $output->fetch());
230230
}
231231

232+
public function testShowAlternateScreen() : void
233+
{
234+
$input = $this->createMock(InputStream::class);
235+
$output = new BufferedOutput;
236+
237+
$terminal = new UnixTerminal($input, $output);
238+
$terminal->showSecondaryScreen();
239+
240+
self::assertEquals("\033[?47h", $output->fetch());
241+
}
242+
243+
public function testShowMainScreen() : void
244+
{
245+
$input = $this->createMock(InputStream::class);
246+
$output = new BufferedOutput;
247+
248+
$terminal = new UnixTerminal($input, $output);
249+
$terminal->showPrimaryScreen();
250+
251+
self::assertEquals("\033[?47l", $output->fetch());
252+
}
253+
232254
public function testRead() : void
233255
{
234256
$tempStream = fopen('php://temp', 'r+');

0 commit comments

Comments
 (0)