stamen

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

example_cpp.cpp (1047B)


      1 #include <iostream>
      2 #include <span>
      3 
      4 #include "demo_menu.hpp"
      5 #include "stamen/stamen.hpp"
      6 
      7 int test_display(const char* title, const stamen::item_t itemv[], size_t size)
      8 {
      9   const auto items = std::span(itemv, itemv + size);
     10 
     11   std::cout << title << std::endl;
     12   for (auto i = 0UL; i < size; i++)
     13   {
     14     std::cout << i + 1 << ": " << items[i].prompt << '\n';
     15   }
     16   std::cout << "Auto calling option 1...\n";
     17   items[1].callback(1);
     18   return 0;
     19 }
     20 
     21 int operation1(size_t /* unused */)
     22 {
     23   std::cout << "operation 1" << std::endl;
     24   std::cout << "Some operation is done" << std::endl;
     25   return 1;
     26 }
     27 
     28 int operation2(size_t /* unused */)
     29 {
     30   std::cout << "operation 2" << std::endl;
     31   std::cout << "Some other operation is done" << std::endl;
     32   return 1;
     33 }
     34 
     35 int operation3(size_t /* unused */)
     36 {
     37   std::cout << "operation 3" << std::endl;
     38   std::cout << "Yet another operation is done" << std::endl;
     39   return 1;
     40 }
     41 
     42 int finish(size_t /* unused */)
     43 {
     44   std::cout << "finishing..." << std::endl;
     45   exit(0);
     46 }
     47 
     48 int main()
     49 {
     50   menu_main(0);
     51   return 0;
     52 }