Skip to content

Commit 64d6d13

Browse files
authored
Merge pull request #94 from Lynesth/patch-12
Reuse parent terminal if available
2 parents c799acf + c1d5166 commit 64d6d13

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/CliMenuBuilder.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ class CliMenuBuilder
8484
public function __construct(CliMenuBuilder $parent = null)
8585
{
8686
$this->parent = $parent;
87-
$this->terminal = TerminalFactory::fromSystem();
87+
$this->terminal = $this->parent !== null
88+
? $this->parent->getTerminal()
89+
: TerminalFactory::fromSystem();
8890
$this->style = MenuStyle::getDefaultStyleValues();
8991
}
9092

@@ -269,6 +271,11 @@ public function setTerminal(Terminal $terminal) : self
269271
return $this;
270272
}
271273

274+
public function getTerminal() : Terminal
275+
{
276+
return $this->terminal;
277+
}
278+
272279
private function getDefaultItems() : array
273280
{
274281
$actions = [];

0 commit comments

Comments
 (0)