-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlainUserInterface.php
54 lines (51 loc) · 1.32 KB
/
PlainUserInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Phpcraft;
use Asyncore\stdin;
/**
* Plain user interface, e.g. writing logs to a file.
*/
class PlainUserInterface extends UserInterface
{
/**
* Note that from this point forward, STDIN is in the hands of pas, if it wasn't already, so make sure to register a "stdin_line" event handler with pas if you'd like input to work.
*
* @param string|null $title The title that the terminal window will be given or null.
*/
function __construct($title = null)
{
parent::__construct($title);
stdin::init(null, false);
if(Phpcraft::isWindows() && version_compare(PHP_VERSION, "7.2.0", ">=") && php_uname("r") == "10.0" && explode(" ", php_uname("v"))[1] >= 10586)
{
sapi_windows_vt100_support(STDOUT, true);
}
}
/**
* Does nothing. Only available in accordance with UserInterface.
*/
function render(): void
{
}
/**
* Prints the given message.
* Only available in accordance with UserInterface, appending messages is not supported here.
*
* @param string $message
* @return PlainUserInterface $this
*/
function append(string $message): PlainUserInterface
{
return $this->add($message);
}
/**
* Prints the given message.
*
* @param string $message
* @return PlainUserInterface $this
*/
function add(string $message): PlainUserInterface
{
echo $message."\n";
return $this;
}
}