Ferreteria/v0.6/clade/IO/O/View/TTY/Table
Jump to navigation
Jump to search
|
The item documented here has been removed and is no longer in use.
|
| ||||||||||||
Code
Entire contents of file, as removed on 2026-01-26:
<?php namespace Woozalia\Ferret\IO\O\View\TTY;
/**
* PURPOSE: Table-class podling for TTY mode
* HISTORY:
2021-10-27 started
2023-10-22 renamespacing for v0.6
* 2024-09-17
* * moved from [WF]IO\O\Screen\TTY -> [WF]IO\O\Screen\Render\TTY
* * adding subclasses for Row and Cell so we can track layout data better
* 2024-10-18 fixing/revamping class family to handle TTY-mode indentation better
* 2024-10-20 moved from [WF]IO\O\Screen\Render\TTY -> IO\O\Render\TTY
*/
use Woozalia\Ferret\IO\O\Data\Element\Branch\grid\caTable as BaseClass;
use Woozalia\Ferret\Sys\Data\Things\Array\cDStor as ArrayClass;
use Woozalia\Ferret\Sys\Data\Things\iArray as ArrayIface;
class cTable extends BaseClass {
// ++ CONFIG ++ //
// CEMENT: BaseClass
protected function RowClass() : string { return cRow::class; }
// -- CONFIG -- //
// ++ API: output ++ //
public function Render() : string {
$oScrn = self::Screen();
$arRows = $this->GetRows();
#echo 'ROW COUNT: ['.count($arRows).']'.CRLF;
$out = '';
$arWds = $this->ColumnWidths();
foreach ($arRows as $oRow) {
$sRow = $oRow->RenderWidths($arWds);
$out .= $sRow;
}
return $out;
}
// -- API -- //
// ++ CALC ++ //
public function ColumnWidths() : array {
$arRows = $this->GetRows();
#$arWds = [];
$oaWds = ArrayClass::AsNew();
foreach ($arRows as $dxRow => $oRow) {
$arCells = $oRow->GetCells();
foreach ($arCells as $dxCol => $oCell) {
$nWd = $oCell->VisibleLength();
/*
if (ArrayStatic::Nz($arWds,$dxCol,0) < $nWd) {
$arWds[$dxCol] = $nWd;
}
*/
if ($oaWds->GetItNz($dxCol,0) < $nWd) {
$oaWds->SetIt($dxCol,$nWd);
}
}
}
return $oaWds->GetStore();
}
// -- CALC -- //
}