stamen

Stamen - static menu generator
git clone git://git.dimitrijedobrota.com/stamen.git
Log | Files | Refs | README | LICENSE

dynamic.cpp (884B)


      1 #include <iostream>
      2 #include <span>
      3 
      4 #include "stamen/menu.hpp"
      5 
      6 int finish(size_t /* unused */)
      7 {
      8   exit(0);
      9 }
     10 
     11 int operation1(size_t /* unused */)
     12 {
     13   std::cout << "1" << std::endl;
     14   return 1;
     15 }
     16 
     17 int operation2(size_t /* unused */)
     18 {
     19   std::cout << "2" << std::endl;
     20   return 1;
     21 }
     22 
     23 int operation3(size_t /* unused */)
     24 {
     25   std::cout << "3" << std::endl;
     26   return 1;
     27 }
     28 
     29 int main(int argc, char* argv[])
     30 {
     31   const std::span args(argv, argv + argc);
     32 
     33   // read the configuration
     34   for (const auto& arg : args.subspan(1)) stamen::menu::read(arg);
     35 
     36   // register free functions
     37   stamen::menu::insert("finish", finish);
     38   stamen::menu::insert("operation1", operation1);
     39   stamen::menu::insert("operation2", operation2);
     40   stamen::menu::insert("operation3", operation3);
     41 
     42   // start the menu on specific panel
     43   stamen::menu::dynamic("menu_main", stamen::builtin_display);
     44 
     45   return 0;
     46 }