#include // #include #include #include #include #include #include "graph_browser.hpp" std::function callback_wrapper; void callback_function( int value ) { callback_wrapper(value); } // templateT conveter(T){}; // template<>std::string conveter(const std::string& s){retun s;} inline std::string atoa(const std::string s) { return s; } int main(int argc, char* argv[]) { if (argc != 2) { std::cout << "Usage: " << argv[0] << " [graph file]" << std::endl; return 1; } const std::string graph_file(argv[1]); Graph g; try { g = readGraphFromPlainText(graph_file, atoa); } catch (std::runtime_error &e) { std::cerr << e.what() << std::endl; return 1; } GraphBrowser::init(); { GraphBrowser gb(g); if (!empty(g)) gb.setStartVertex(*g.begin()); callback_wrapper = std::bind(&GraphBrowser::terminalResizedEvent, &gb, std::placeholders::_1); struct sigaction act; act.sa_handler = callback_function; sigaction(SIGWINCH, &act, NULL); gb.mainLoop(); } GraphBrowser::destroy(); writeGraphToPlainText(g, graph_file, atoa); return EXIT_SUCCESS; }