MCPcopy Create free account
hub / github.com/SpartanJ/eepp / main

Function main

src/examples/ui_html/ui_html.cpp:6–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include <iostream>
5
6EE_MAIN_FUNC int main( int argc, char** argv ) {
7 args::ArgumentParser parser( "eepp HTML Example" );
8 args::HelpFlag help( parser, "help", "Display this help menu", { 'h', "help" } );
9
10 args::Positional<std::string> url( parser, "URL", "The URL to request" );
11 args::ValueFlag<std::string> prefersColorScheme(
12 parser, "prefers-color-scheme",
13 "Set the preferred color scheme (\"light\", \"dark\" or \"system\")",
14 { 'c', "prefers-color-scheme" } );
15 args::Flag hnDark( parser, "hn-dark",
16 "Force a custom CSS style for Hacker News site to be dark.", { "hn-dark" } );
17 args::Flag benchmarkMode( parser, "benchmark-mode",
18 "Render as much as possible to measure the rendering performance.",
19 { "benchmark-mode" } );
20 args::ValueFlag<Float> pixelDensityConf( parser, "pixel-density",
21 "Set default application pixel density",
22 { 'd', "pixel-density" } );
23
24 try {
25 parser.ParseCLI( Sys::parseArguments( argc, argv ) );
26 } catch ( const args::Help& ) {
27 std::cout << parser;
28 return EXIT_SUCCESS;
29 } catch ( const args::ParseError& e ) {
30 std::cerr << e.what() << std::endl;
31 std::cerr << parser;
32 return EXIT_FAILURE;
33 } catch ( args::ValidationError& e ) {
34 std::cerr << e.what() << std::endl;
35 std::cerr << parser;
36 return EXIT_FAILURE;
37 }
38
39 UIApplication app(
40 WindowSettings{ 1280, 720, "eepp - UI HTML Example" },
41 UIApplication::Settings( {}, pixelDensityConf ? pixelDensityConf.Get() : 0.f ),
42 ContextSettings(
43 false, benchmarkMode.Get() ? 0 : ContextSettings::FrameRateLimitScreenRefreshRate ) );
44
45 Log::instance()->setLogLevelThreshold( LogLevel::Debug );
46 Log::instance()->setLogToStdOut( true );
47 Log::instance()->setLiveWrite( true );
48
49 Http::setDefaultUserAgent( "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like "
50 "Gecko) Chrome/146.0.0.0 Safari/537.36" );
51
52 auto win = app.getWindow();
53 auto ui = app.getUI();
54
55 FontTrueType* remixIconFont = FontTrueType::New( "icon", "assets/fonts/remixicon.ttf" );
56 FontTrueType* noniconsFont = FontTrueType::New( "nonicons", "assets/fonts/nonicons.ttf" );
57 FontTrueType* codIconFont = FontTrueType::New( "codicon", "assets/fonts/codicon.ttf" );
58 ui->getUIIconThemeManager()->setCurrentTheme(
59 IconManager::init( "icons", remixIconFont, noniconsFont, codIconFont ) );
60
61 ui->setColorSchemePreference(
62 !prefersColorScheme.Get().empty()
63 ? ColorSchemePreferences::fromStringExt( prefersColorScheme.Get() )

Callers

nothing calls this directly

Calls 15

ContextSettingsClass · 0.85
hashFunction · 0.85
SecondsFunction · 0.85
formatFunction · 0.85
setLogLevelThresholdMethod · 0.80
setLogToStdOutMethod · 0.80
setLiveWriteMethod · 0.80
getUIMethod · 0.80
setCurrentThemeMethod · 0.80
getUIIconThemeManagerMethod · 0.80
loadLayoutFromStringMethod · 0.80

Tested by

no test coverage detected