2021-08-13 11:16:57 -04:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Aviat\Kilo;
|
|
|
|
|
|
|
|
use Aviat\Kilo\Enum\Color;
|
2022-08-26 15:44:00 -04:00
|
|
|
use Aviat\Kilo\Enum\Color256;
|
2021-08-13 11:16:57 -04:00
|
|
|
use Aviat\Kilo\Enum\Highlight;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configure syntax highlighting colors
|
|
|
|
*
|
2021-12-03 11:59:42 -05:00
|
|
|
* @param Highlight $hl
|
2022-08-26 15:44:00 -04:00
|
|
|
* @return Color | Color256 | int
|
2021-08-13 11:16:57 -04:00
|
|
|
*/
|
2022-08-26 15:44:00 -04:00
|
|
|
function get_syntax_color(Highlight $hl): Color | Color256 | int {
|
2021-08-13 11:16:57 -04:00
|
|
|
return match ($hl)
|
|
|
|
{
|
2021-12-03 11:59:42 -05:00
|
|
|
Highlight::Comment => Color::FG_CYAN,
|
|
|
|
Highlight::MultiLineComment => Color::FG_BRIGHT_BLACK,
|
|
|
|
Highlight::Keyword1 => Color::FG_YELLOW,
|
|
|
|
Highlight::Keyword2 => Color::FG_GREEN,
|
|
|
|
Highlight::String => Color::FG_MAGENTA,
|
|
|
|
Highlight::Character => Color::FG_BRIGHT_MAGENTA,
|
|
|
|
Highlight::Number => Color::FG_BRIGHT_RED,
|
|
|
|
Highlight::Operator => Color::FG_BRIGHT_GREEN,
|
|
|
|
Highlight::Variable => Color::FG_BRIGHT_CYAN,
|
|
|
|
Highlight::Delimiter => Color::FG_BLUE,
|
|
|
|
Highlight::Invalid => Color::BG_BRIGHT_RED,
|
|
|
|
Highlight::SearchMatch => Color::INVERT,
|
|
|
|
Highlight::Identifier => Color::FG_BRIGHT_WHITE,
|
2021-08-13 11:16:57 -04:00
|
|
|
default => Color::FG_WHITE,
|
|
|
|
};
|
|
|
|
}
|