refactoring
This commit is contained in:
@@ -33,21 +33,24 @@ int main(int argc, char** argv)
|
|||||||
//screen.ForceHandleCtrlZ(true);
|
//screen.ForceHandleCtrlZ(true);
|
||||||
option.on_enter = screen.ExitLoopClosure();
|
option.on_enter = screen.ExitLoopClosure();
|
||||||
auto menu = ftxui::Menu(&examples, &selectedExample, option);
|
auto menu = ftxui::Menu(&examples, &selectedExample, option);
|
||||||
bool emergencyExit = false;
|
bool shouldExit = false;
|
||||||
menu |= ftxui::CatchEvent(
|
menu |= ftxui::CatchEvent(
|
||||||
[&](ftxui::Event event)
|
[&](ftxui::Event event)
|
||||||
{
|
{
|
||||||
if (event == ftxui::Event::CtrlC || event == ftxui::Event::CtrlZ)
|
if (event == ftxui::Event::CtrlC || event == ftxui::Event::CtrlZ)
|
||||||
{
|
{
|
||||||
screen.ExitLoopClosure()();
|
screen.ExitLoopClosure()();
|
||||||
emergencyExit = true;
|
shouldExit = true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
screen.Loop(menu);
|
screen.Loop(menu);
|
||||||
|
|
||||||
if (!emergencyExit)
|
if (shouldExit)
|
||||||
{
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedExample >= examples.size())
|
if (selectedExample >= examples.size())
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Invalid menu selection!");
|
throw std::runtime_error("Invalid menu selection!");
|
||||||
@@ -57,6 +60,5 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
GraphicsAppManager manager(app.get());
|
GraphicsAppManager manager(app.get());
|
||||||
manager.Run();
|
manager.Run();
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user