Skip to content

Commit 7e9bf4c

Browse files
committed
thusfar
1 parent 0f14cb0 commit 7e9bf4c

9 files changed

Lines changed: 375 additions & 15 deletions

File tree

src/Nether/Console/Client.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ public function
510510

511511
////////
512512

513-
if(isset($Argv['Colour']) && is_string($Argv['Colour']))
513+
if(isset($Argv['Colour']) && is_string($Argv['Colour']) && $Argv['Colour'])
514514
$Argv['Colour'] = new Colour($Argv['Colour']);
515515

516516
////////
@@ -688,25 +688,25 @@ public function
688688
#[Common\Meta\Date('2023-11-14')]
689689
#[Common\Meta\Info('Returns theme-styled content suitable for an H1 division with an extra line break after.')]
690690
public function
691-
FormatH1(string $Text):
691+
FormatH1(string $Text, string $Preset=Theme::Prime):
692692
string {
693693

694694
return sprintf(
695695
'%s%s',
696-
$this->FormatHeaderLine($Text, Theme::Prime),
696+
$this->FormatHeaderLine($Text, $Preset),
697697
PHP_EOL
698698
);
699699
}
700700

701701
#[Common\Meta\Date('2023-11-14')]
702702
#[Common\Meta\Info('Returns theme-styled content suitable for an H2 division with an extra line break after.')]
703703
public function
704-
FormatH2(string $Text):
704+
FormatH2(string $Text, string $Preset=Theme::Accent):
705705
string {
706706

707707
return sprintf(
708708
'%s%s',
709-
$this->FormatHeaderLine($Text, Theme::Accent),
709+
$this->FormatHeaderLine($Text, $Preset),
710710
PHP_EOL
711711
);
712712
}
@@ -848,20 +848,20 @@ public function
848848

849849
#[Common\Meta\Date('2023-11-16')]
850850
protected function
851-
PrintH1(string $Text):
851+
PrintH1(string $Text, string $Preset=Theme::Prime):
852852
static {
853853

854-
$this->PrintLn($this->FormatH1($Text));
854+
$this->PrintLn($this->FormatH1($Text, $Preset));
855855

856856
return $this;
857857
}
858858

859859
#[Common\Meta\Date('2023-11-16')]
860860
protected function
861-
PrintH2(string $Text):
861+
PrintH2(string $Text, string $Preset=Theme::Accent):
862862
static {
863863

864-
$this->PrintLn($this->FormatH2($Text));
864+
$this->PrintLn($this->FormatH2($Text, $Preset));
865865

866866
return $this;
867867
}

src/Nether/Console/Elements/H1.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php ##########################################################################
2+
################################################################################
3+
4+
namespace Nether\Console\Elements;
5+
6+
use Nether\Common;
7+
use Nether\Console;
8+
use Nether\Dye;
9+
10+
################################################################################
11+
################################################################################
12+
13+
class H1
14+
extends Common\Prototype {
15+
16+
public Console\Client
17+
$Client;
18+
19+
public string
20+
$Text = '';
21+
22+
public string
23+
$BorderCharH = '';
24+
25+
public string
26+
$BorderCharV = '';
27+
28+
public ?Dye\Colour
29+
$BorderColour = NULL;
30+
31+
public ?Dye\Colour
32+
$TextColour = NULL;
33+
34+
////////////////////////////////////////////////////////////////
35+
////////////////////////////////////////////////////////////////
36+
37+
public function
38+
FetchTerminalWidth():
39+
int {
40+
41+
return $this->Client->Size->X;
42+
}
43+
44+
////////////////////////////////////////////////////////////////
45+
////////////////////////////////////////////////////////////////
46+
47+
public function
48+
Print(int $Newlines=1):
49+
void {
50+
51+
$CharMax = $this->FetchTerminalWidth();
52+
$LinePrefix = sprintf('%s%s', $this->BorderCharV, $this->BorderCharH);
53+
$LineText = sprintf(' %s ', $this->Text);
54+
$LineSuffix = sprintf('%s%s', str_repeat($this->BorderCharH, ($CharMax - mb_strlen($LinePrefix.$LineText) - 1)), $this->BorderCharV);
55+
56+
$Line = sprintf(
57+
'%s%s%s',
58+
$this->Client->Format($LinePrefix, C: $this->BorderColour),
59+
$this->Client->Format($LineText, C: $this->TextColour),
60+
$this->Client->Format($LineSuffix, C: $this->BorderColour)
61+
);
62+
63+
$this->Client->PrintLn($Line, $Newlines);
64+
65+
return;
66+
}
67+
68+
////////////////////////////////////////////////////////////////
69+
////////////////////////////////////////////////////////////////
70+
71+
static public function
72+
New(Console\Client $Client, ?string $Text=NULL, ?Dye\Colour $BorderColour=NULL, ?Dye\Colour $TextColour=NULL):
73+
static {
74+
75+
$Output = new static([
76+
'Client' => $Client,
77+
'Text' => $Text ?? '',
78+
'BorderColour' => $BorderColour,
79+
'TextColour' => $TextColour
80+
]);
81+
82+
return $Output;
83+
}
84+
85+
};

src/Nether/Console/Elements/H2.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php ##########################################################################
2+
################################################################################
3+
4+
namespace Nether\Console\Elements;
5+
6+
use Nether\Common;
7+
use Nether\Console;
8+
use Nether\Dye;
9+
10+
################################################################################
11+
################################################################################
12+
13+
class H2
14+
extends H1 {
15+
16+
public string
17+
$BorderCharH = '';
18+
19+
public string
20+
$BorderCharV = '';
21+
22+
};

src/Nether/Console/Elements/H3.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php ##########################################################################
2+
################################################################################
3+
4+
namespace Nether\Console\Elements;
5+
6+
use Nether\Common;
7+
use Nether\Console;
8+
use Nether\Dye;
9+
10+
################################################################################
11+
################################################################################
12+
13+
class H3
14+
extends H1 {
15+
16+
17+
public string
18+
$BorderCharH = '';
19+
20+
public string
21+
$BorderCharV = '';
22+
23+
};

src/Nether/Console/Elements/H4.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php ##########################################################################
2+
################################################################################
3+
4+
namespace Nether\Console\Elements;
5+
6+
use Nether\Common;
7+
use Nether\Console;
8+
use Nether\Dye;
9+
10+
################################################################################
11+
################################################################################
12+
13+
class H4
14+
extends H1 {
15+
16+
17+
public string
18+
$BorderCharH = '·';
19+
20+
public string
21+
$BorderCharV = '·';
22+
23+
};
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php ##########################################################################
2+
################################################################################
3+
4+
namespace Nether\Console\Elements;
5+
6+
use Nether\Common;
7+
use Nether\Console;
8+
use Nether\Dye;
9+
10+
################################################################################
11+
################################################################################
12+
13+
class ListBullet
14+
extends Common\Prototype {
15+
16+
public Console\Client
17+
$Client;
18+
19+
public Common\Datastore
20+
$Items;
21+
22+
public string
23+
$DelimChar;
24+
25+
public string
26+
$BulletChar;
27+
28+
public ?Dye\Colour
29+
$BulletColour = NULL;
30+
31+
public ?Dye\Colour
32+
$TextColour = NULL;
33+
34+
public string
35+
$IndentChar;
36+
37+
public int
38+
$IndentCount = 0;
39+
40+
////////////////////////////////////////////////////////////////
41+
////////////////////////////////////////////////////////////////
42+
43+
public function
44+
Print(int $Newlines=1):
45+
void {
46+
47+
$Line = NULL;
48+
$Item = NULL;
49+
$Prefix = NULL;
50+
$Text = NULL;
51+
52+
////////
53+
54+
foreach($this->Items as $Item) {
55+
$Prefix = sprintf('%s%s', str_repeat($this->IndentChar, $this->IndentCount), $this->BulletChar);
56+
$Text = sprintf(' %s', $Item);
57+
58+
$Line = sprintf(
59+
'%s%s',
60+
$this->Client->Format($Prefix, C: $this->BulletColour),
61+
$this->Client->Format($Text, C: $this->TextColour)
62+
);
63+
64+
$this->Client->PrintLn($Line);
65+
}
66+
67+
$this->Client->PrintLn('', $Newlines);
68+
69+
return;
70+
}
71+
72+
////////////////////////////////////////////////////////////////
73+
////////////////////////////////////////////////////////////////
74+
75+
static public function
76+
New(
77+
Console\Client $Client,
78+
array $Items = [],
79+
string $BulletChar = "*",
80+
?Dye\Colour $BulletColour = NULL,
81+
string $DelimChar = ':',
82+
string $IndentChar = "\t",
83+
int $IndentCount = 0,
84+
?Dye\Colour $TextColour = NULL
85+
):
86+
static {
87+
88+
$Output = new static([
89+
'Client' => $Client,
90+
'Items' => Common\Datastore::FromArray($Items),
91+
'DelimChar' => $DelimChar,
92+
'BulletChar' => $BulletChar,
93+
'BulletColour' => $BulletColour,
94+
'IndentChar' => $IndentChar,
95+
'IndentCount' => $IndentCount,
96+
'TextColour' => $TextColour
97+
]);
98+
99+
return $Output;
100+
}
101+
102+
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php ##########################################################################
2+
################################################################################
3+
4+
namespace Nether\Console\Elements;
5+
6+
use Nether\Common;
7+
use Nether\Console;
8+
use Nether\Dye;
9+
10+
################################################################################
11+
################################################################################
12+
13+
class ListNamed
14+
extends ListBullet {
15+
16+
public function
17+
Print(int $Newlines=1):
18+
void {
19+
20+
$Line = NULL;
21+
$Name = NULL;
22+
$Item = NULL;
23+
$Prefix = NULL;
24+
$Name = NULL;
25+
26+
////////
27+
28+
foreach($this->Items as $Name => $Item) {
29+
30+
$Prefix = sprintf(
31+
'%s%s%s ',
32+
str_repeat($this->IndentChar, $this->IndentCount),
33+
$Name,
34+
$this->DelimChar
35+
);
36+
37+
$Line = sprintf(
38+
'%s%s',
39+
$this->Client->Format($Prefix, C: $this->BulletColour),
40+
$this->Client->Format($Item, C: $this->TextColour)
41+
);
42+
43+
$this->Client->PrintLn($Line);
44+
}
45+
46+
$this->Client->PrintLn('', $Newlines);
47+
48+
return;
49+
}
50+
51+
};

0 commit comments

Comments
 (0)