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+ };
0 commit comments