mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-02 11:10:31 +03:00
eterm: Allow support for custom color schemes.
This commit is contained in:
@@ -9,6 +9,24 @@ Clock secondsCounter;
|
|||||||
Time frameTime{ Time::Zero };
|
Time frameTime{ Time::Zero };
|
||||||
bool benchmarkMode{ false };
|
bool benchmarkMode{ false };
|
||||||
std::string windowStringData;
|
std::string windowStringData;
|
||||||
|
std::map<std::string, TerminalColorScheme> terminalColorSchemes;
|
||||||
|
|
||||||
|
void loadColorSchemes( const std::string& resPath ) {
|
||||||
|
auto configPath = Sys::getConfigPath( "eterm" );
|
||||||
|
auto colorSchemes =
|
||||||
|
TerminalColorScheme::loadFromFile( resPath + "colorschemes/terminalcolorschemes.conf" );
|
||||||
|
auto colorSchemesPath = configPath + FileSystem::getOSSlash() + "colorschemes";
|
||||||
|
if ( FileSystem::isDirectory( colorSchemesPath ) ) {
|
||||||
|
auto colorSchemesFiles = FileSystem::filesGetInPath( colorSchemesPath );
|
||||||
|
for ( auto& file : colorSchemesFiles ) {
|
||||||
|
auto colorSchemesInFile = TerminalColorScheme::loadFromFile( file );
|
||||||
|
for ( auto& coloScheme : colorSchemesInFile )
|
||||||
|
colorSchemes.emplace_back( coloScheme );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ( auto colorScheme : colorSchemes )
|
||||||
|
terminalColorSchemes.insert( { colorScheme.getName(), colorScheme } );
|
||||||
|
}
|
||||||
|
|
||||||
void inputCallback( InputEvent* event ) {
|
void inputCallback( InputEvent* event ) {
|
||||||
if ( !terminal || event->Type == InputEvent::EventsSent )
|
if ( !terminal || event->Type == InputEvent::EventsSent )
|
||||||
@@ -134,6 +152,10 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
|||||||
args::ValueFlag<std::string> executeInShell(
|
args::ValueFlag<std::string> executeInShell(
|
||||||
parser, "execute-in-shell", "execute program in shell", { 'e', "execute" }, "" );
|
parser, "execute-in-shell", "execute program in shell", { 'e', "execute" }, "" );
|
||||||
args::Flag vsync( parser, "vsync", "Enable vsync", { "vsync" } );
|
args::Flag vsync( parser, "vsync", "Enable vsync", { "vsync" } );
|
||||||
|
args::ValueFlag<std::string> colorScheme( parser, "color-scheme", "Load color scheme",
|
||||||
|
{ "color-scheme" }, "" );
|
||||||
|
args::Flag listColorSchemes( parser, "color-schemes", "Lists color schemes",
|
||||||
|
{ "list-color-schemes" } );
|
||||||
args::ValueFlag<Uint32> maxFPS( parser, "max-fps",
|
args::ValueFlag<Uint32> maxFPS( parser, "max-fps",
|
||||||
"Maximum rendering frames per second of the terminal. Default "
|
"Maximum rendering frames per second of the terminal. Default "
|
||||||
"value will be the refresh rate of the screen.",
|
"value will be the refresh rate of the screen.",
|
||||||
@@ -177,6 +199,16 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
|||||||
resPath += "assets";
|
resPath += "assets";
|
||||||
FileSystem::dirAddSlashAtEnd( resPath );
|
FileSystem::dirAddSlashAtEnd( resPath );
|
||||||
|
|
||||||
|
if ( listColorSchemes.Get() || colorScheme )
|
||||||
|
loadColorSchemes( resPath );
|
||||||
|
|
||||||
|
if ( listColorSchemes.Get() ) {
|
||||||
|
std::cout << "Color schemes:\n";
|
||||||
|
for ( auto colorScheme : terminalColorSchemes )
|
||||||
|
std::cout << "\t" << colorScheme.first << "\n";
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
displayManager->enableScreenSaver();
|
displayManager->enableScreenSaver();
|
||||||
displayManager->enableMouseFocusClickThrough();
|
displayManager->enableMouseFocusClickThrough();
|
||||||
displayManager->disableBypassCompositor();
|
displayManager->disableBypassCompositor();
|
||||||
@@ -244,6 +276,12 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
if ( colorScheme ) {
|
||||||
|
auto selColorScheme = terminalColorSchemes.find( colorScheme.Get() );
|
||||||
|
if ( selColorScheme != terminalColorSchemes.end() )
|
||||||
|
terminal->setColorScheme( selColorScheme->second );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !executeInShell.Get().empty() )
|
if ( !executeInShell.Get().empty() )
|
||||||
terminal->executeFile( executeInShell.Get() );
|
terminal->executeFile( executeInShell.Get() );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user