|
@@ -146,7 +146,7 @@ void Director::server_prompt(const std::string &prompt,
|
|
|
void Director::proxy_activate(void) {
|
|
|
active = true; // yes, set keep-alive timer.
|
|
|
to_server(" "); // start keep-alive timer.
|
|
|
-
|
|
|
+
|
|
|
// set other values we need
|
|
|
talk_direct = false;
|
|
|
show_client = false;
|
|
@@ -174,6 +174,23 @@ void Director::proxy_activate(void) {
|
|
|
to_client(box.row(output));
|
|
|
to_client(box.bottom());
|
|
|
|
|
|
+ std::shared_ptr<Dispatch> menu = std::make_shared<MenuDispatch>(*this);
|
|
|
+ chain = menu;
|
|
|
+ MenuDispatch *md = static_cast<MenuDispatch *>(&(*menu));
|
|
|
+ md->menu_box_color = "\x1b[1;33;44m";
|
|
|
+ md->menu_text_color = "\x1b[1;37;44m";
|
|
|
+ md->menu_title = "Proxy Menu";
|
|
|
+ md->menu_options_color = "\x1b[1;36;40m";
|
|
|
+
|
|
|
+ md->menu_prompt =
|
|
|
+ "\x1b[0;31;40m\xdb\xb2\xb1\xb0 \x1b[31;40mRED "
|
|
|
+ "\x1b[32;40mGREEN\x1b[30;42m\xdb\xb2\xb1\xb0 \x1b[0m : ";
|
|
|
+ md->lazy = true;
|
|
|
+ md->menu = {{"A", "Apple"}, {"B", "Blue"}, {"R", "Rabbit"}, {"Z", "ZOOO!"}};
|
|
|
+ md->setNotify([this]() { this->menu_choice(); });
|
|
|
+ menu->activate();
|
|
|
+/*
|
|
|
+ // Using InputDispatch -- and see have_input
|
|
|
std::shared_ptr<Dispatch> readline = std::make_shared<InputDispatch>(*this);
|
|
|
chain = readline;
|
|
|
InputDispatch *id = static_cast<InputDispatch *>(&(*readline));
|
|
@@ -181,6 +198,24 @@ void Director::proxy_activate(void) {
|
|
|
id->max_length = 15;
|
|
|
id->setNotify([this]() { this->have_input(); });
|
|
|
readline->activate();
|
|
|
+*/
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void Director::menu_choice(void) {
|
|
|
+ MenuDispatch * md = dynamic_cast<MenuDispatch *>(&(*chain));
|
|
|
+ if (md) {
|
|
|
+ if (md->input.empty()) {
|
|
|
+ to_client("Menu aborted.\n\r");
|
|
|
+ proxy_deactivate();
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ std::string text = str(boost::format( "Back from Menu [%1%] was selected.\n\r") % md->input);
|
|
|
+ to_client(text);
|
|
|
+
|
|
|
+ md->activate();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void Director::have_input(void) {
|