Skip to content

Commit 3f792d4

Browse files
committed
fix: use 21m to reset bold intensity
1 parent 00ef935 commit 3f792d4

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

src/Themes/TerminalStyle.php

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ enum TerminalStyle: string
88
{
99
case ESC = "\033[";
1010
case RESET = "0m";
11+
case RESET_INTENSITY = "22m";
12+
case RESET_ITALIC = "23m";
13+
case VISIBLE = "28m";
14+
case RESET_UNDERLINE = "24m";
15+
case RESET_OVERLINE = "55m";
16+
case RESET_STRIKETHROUGH = "29m";
17+
case NON_REVERSE_TEXT = "27m";
1118

1219
case FG_BLACK = "30m";
1320
case FG_DARK_RED = "31m";
@@ -44,10 +51,18 @@ enum TerminalStyle: string
4451
case BG_WHITE = "107m";
4552

4653
case BOLD = "1m";
54+
case DIM = "2m";
55+
case ITALIC = "3m";
4756
case UNDERLINE = "4m";
48-
case NO_UNDERLINE = "24m";
57+
case OVERLINE = "53m";
58+
case HIDDEN = "8m";
59+
case STRIKETHROUGH = "9m";
4960
case REVERSE_TEXT = "7m";
50-
case NON_REVERSE_TEXT = "27m";
61+
62+
public static function STYLE(self $style, string $text): string
63+
{
64+
return self::ESC->value . $style->value . $text;
65+
}
5166

5267
public static function RESET(string $text = ''): string
5368
{
@@ -216,26 +231,41 @@ public static function BG_WHITE(string $text = ''): string
216231

217232
public static function BOLD(string $text = ''): string
218233
{
219-
return self::ESC->value . self::BOLD->value . $text . self::ESC->value . self::RESET->value;
234+
return self::ESC->value . self::BOLD->value . $text . self::ESC->value . self::RESET_INTENSITY->value;
235+
}
236+
237+
public static function DIM(string $text = ''): string
238+
{
239+
return self::ESC->value . self::DIM->value . $text . self::ESC->value . self::RESET_INTENSITY->value;
240+
}
241+
242+
public static function ITALIC(string $text = ''): string
243+
{
244+
return self::ESC->value . self::ITALIC->value . $text . self::ESC->value . self::RESET_ITALIC->value;
220245
}
221246

222247
public static function UNDERLINE(string $text = ''): string
223248
{
224-
return self::ESC->value . self::UNDERLINE->value . $text . self::ESC->value . self::RESET->value;
249+
return self::ESC->value . self::UNDERLINE->value . $text . self::ESC->value . self::RESET_UNDERLINE->value;
225250
}
226251

227-
public static function NO_UNDERLINE(string $text = ''): string
252+
public static function OVERLINE(string $text = ''): string
228253
{
229-
return self::ESC->value . self::NO_UNDERLINE->value . $text . self::ESC->value . self::RESET->value;
254+
return self::ESC->value . self::OVERLINE->value . $text . self::ESC->value . self::RESET_OVERLINE->value;
230255
}
231256

232-
public static function REVERSE_TEXT(string $text = ''): string
257+
public static function HIDDEN(string $text = ''): string
233258
{
234-
return self::ESC->value . self::REVERSE_TEXT->value . $text . self::ESC->value . self::RESET->value;
259+
return self::ESC->value . self::HIDDEN->value . $text . self::ESC->value . self::VISIBLE->value;
235260
}
236261

237-
public static function NON_REVERSE_TEXT(string $text = ''): string
262+
public static function STRIKETHROUGH(string $text = ''): string
263+
{
264+
return self::ESC->value . self::STRIKETHROUGH->value . $text . self::ESC->value . self::RESET_STRIKETHROUGH->value;
265+
}
266+
267+
public static function REVERSE_TEXT(string $text = ''): string
238268
{
239-
return self::ESC->value . self::NON_REVERSE_TEXT->value . $text . self::ESC->value . self::RESET->value;
269+
return self::ESC->value . self::REVERSE_TEXT->value . $text . self::ESC->value . self::NON_REVERSE_TEXT->value;
240270
}
241271
}

0 commit comments

Comments
 (0)