Page MenuHomePhabricator

Masterwork From Distant Lands

Authored By
alexmv
Jun 1 2017, 3:35 AM
Size
2 KB
Referenced Files
None
Subscribers
None

Masterwork From Distant Lands

diff --git a/src/console/view/PhutilConsoleTable.php b/src/console/view/PhutilConsoleTable.php
index 7c29f99..d19141d 100644
--- a/src/console/view/PhutilConsoleTable.php
+++ b/src/console/view/PhutilConsoleTable.php
@@ -30,6 +30,7 @@ final class PhutilConsoleTable extends PhutilConsoleView {
private $borders = false;
private $padding = 1;
private $showHeader = true;
+ private $escape = true;
const ALIGN_LEFT = 'left';
const ALIGN_CENTER = 'center';
@@ -54,6 +55,11 @@ final class PhutilConsoleTable extends PhutilConsoleView {
return $this;
}
+ public function setEscapeContents($escape) {
+ $this->escape = $escape;
+ return $this;
+ }
+
/* -( Data )--------------------------------------------------------------- */
@@ -88,6 +94,16 @@ final class PhutilConsoleTable extends PhutilConsoleView {
/* -( Drawing )------------------------------------------------------------ */
+ public function drawConsoleString() {
+ if ($this->escape) {
+ return parent::drawConsoleString();
+ }
+
+ $view = $this->drawView();
+ $parts = $this->reduceView($view);
+ return implode('', $parts);
+ }
+
protected function drawView() {
return $this->drawLines(
array_merge(
diff --git a/src/console/view/PhutilConsoleView.php b/src/console/view/PhutilConsoleView.php
index 85f5b8f..96087ca 100644
--- a/src/console/view/PhutilConsoleView.php
+++ b/src/console/view/PhutilConsoleView.php
@@ -41,7 +41,7 @@ abstract class PhutilConsoleView extends Phobject {
* @return string Console-printable string.
* @task draw
*/
- final public function drawConsoleString() {
+ public function drawConsoleString() {
$view = $this->drawView();
$parts = $this->reduceView($view);
@@ -61,7 +61,7 @@ abstract class PhutilConsoleView extends Phobject {
* @return list<wild> List of unnested drawables.
* @task draw
*/
- private function reduceView($view) {
+ protected function reduceView($view) {
if ($view instanceof PhutilConsoleView) {
$view = $view->drawView();
return $this->reduceView($view);

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
673429
Default Alt Text
Masterwork From Distant Lands (2 KB)

Event Timeline