Page MenuHomePhabricator
Paste P2057

Masterwork From Distant Lands
ActivePublic

Authored by alexmv on Jun 1 2017, 3:35 AM.
Tags
None
Referenced Files
F4985626: Masterwork From Distant Lands
Jun 1 2017, 3:35 AM
Subscribers
None
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);

Event Timeline

alexmv changed the title of this paste from untitled to Masterwork From Distant Lands.
alexmv updated the paste's language from autodetect to autodetect.