Jelajahi Sumber

Added ANSIColor class for color codes.

Steve Thielemann 3 tahun lalu
induk
melakukan
9d2255008e
6 mengubah file dengan 427 tambahan dan 287 penghapusan
  1. 2 2
      CMakeLists.txt
  2. 288 0
      ansicolor.cpp
  3. 116 0
      ansicolor.h
  4. 19 29
      director.cpp
  5. 2 152
      dispatchers.cpp
  6. 0 104
      session.cpp

+ 2 - 2
CMakeLists.txt

@@ -60,7 +60,7 @@ add_executable(test-galaxy test-galaxy.cpp galaxy.cpp config.cpp utils.cpp buyse
 add_dependencies(test-galaxy gtest)
 target_link_libraries(test-galaxy gtest_main ${Boost_LIBRARIES} yaml-cpp)
 
-add_executable(test-director test-director.cpp galaxy.cpp utils.cpp buysell.cpp director.cpp dispatchers.cpp boxes.cpp scripts.cpp config.cpp)
+add_executable(test-director test-director.cpp galaxy.cpp utils.cpp buysell.cpp director.cpp dispatchers.cpp boxes.cpp scripts.cpp config.cpp ansicolor.cpp)
 add_dependencies(test-director gtest)
 target_link_libraries(test-director gtest_main ${Boost_LIBRARIES} yaml-cpp)
 
@@ -71,7 +71,7 @@ add_test(NAME test-director
   COMMAND test-director)
 
 # dispatchers.cpp 
-ADD_EXECUTABLE( twproxy twproxy.cpp utils.cpp session.cpp boxes.cpp director.cpp galaxy.cpp dispatchers.cpp scripts.cpp buysell.cpp config.cpp)
+ADD_EXECUTABLE( twproxy twproxy.cpp utils.cpp session.cpp boxes.cpp director.cpp galaxy.cpp dispatchers.cpp scripts.cpp buysell.cpp config.cpp ansicolor.cpp)
 TARGET_LINK_LIBRARIES( twproxy ${Boost_LIBRARIES} pthread yaml-cpp)
 
 target_precompile_headers(twproxy PRIVATE pch.hpp)

+ 288 - 0
ansicolor.cpp

@@ -0,0 +1,288 @@
+#include "ansicolor.h"
+
+#include <string>
+
+/**
+ * @file
+ * @brief ANSIColor
+ */
+
+/**
+ * Construct a new ANSIColor::ANSIColor object
+ * with sensible defaults (White on Black).
+ *
+ */
+ANSIColor::ANSIColor()
+    : fg(COLOR::WHITE),
+      bg(COLOR::BLACK),
+      reset(0),
+      bold(0),
+      blink(0),
+      inverse(0) {}
+
+/**
+ * Construct a new ANSIColor::ANSIColor object
+ * with attribute set.
+ *
+ * @param[in] a ATTR
+ */
+ANSIColor::ANSIColor(ATTR a) : ANSIColor() { Attr(a); }
+
+/* // This won't work.  There's no clear way to set bold colors easily.
+ANSIColor::ANSIColor(int c1) {}
+
+ANSIColor::ANSIColor(int c1, int c2) {}
+*/
+
+/**
+ * Construct a new ANSIColor::ANSIColor object
+ * with a foreground color.
+ *
+ * @param[in] f COLOR
+ */
+ANSIColor::ANSIColor(COLOR f) : ANSIColor() { fg = f; }
+
+/**
+ * Construct a new ANSIColor::ANSIColor object
+ * with a foreground color and attribute.
+ *
+ * @param[in] f COLOR
+ * @param[in] a ATTR
+ */
+ANSIColor::ANSIColor(COLOR f, ATTR a) : ANSIColor() {
+  fg = f;
+  Attr(a);
+}
+
+/**
+ * Construct a new ANSIColor::ANSIColor object
+ * with a foreground color and attributes.
+ *
+ * @param[in] f COLOR
+ * @param[in] a1 ATTR
+ * @param[in] a2 ATTR
+ */
+ANSIColor::ANSIColor(COLOR f, ATTR a1, ATTR a2) : ANSIColor() {
+  fg = f;
+  Attr(a1);
+  Attr(a2);
+}
+
+/**
+ * Construct a new ANSIColor::ANSIColor object
+ * with a foreground and background color.
+ *
+ * @param[in] f foreground COLOR
+ * @param[in] b background COLOR
+ */
+ANSIColor::ANSIColor(COLOR f, COLOR b) : ANSIColor() {
+  fg = f;
+  bg = b;
+}
+
+/**
+ * Construct a new ANSIColor::ANSIColor object
+ * with a foreground color, background color,
+ * and attribute.
+ *
+ * @param[in] f foreground COLOR
+ * @param[in] b background COLOR
+ * @param[in] a ATTR
+ */
+ANSIColor::ANSIColor(COLOR f, COLOR b, ATTR a) : ANSIColor() {
+  fg = f;
+  bg = b;
+  Attr(a);
+}
+
+/**
+ * Construct a new ANSIColor::ANSIColor object
+ * with foreground, background color and attributes.
+ *
+ * @param[in] f foreground COLOR
+ * @param[in] b background COLOR
+ * @param[in] a1 ATTR
+ * @param[in] a2 ATTR
+ */
+ANSIColor::ANSIColor(COLOR f, COLOR b, ATTR a1, ATTR a2) : ANSIColor() {
+  fg = f;
+  bg = b;
+  Attr(a1);
+  Attr(a2);
+}
+
+/**
+ * Set attribute.  We return the object so
+ * calls can be chained.
+ *
+ * @param[in] a ATTR
+ * @return ANSIColor&
+ */
+ANSIColor &ANSIColor::Attr(ATTR a) {
+  switch (a) {
+    case ATTR::RESET:
+      reset = 1;
+      break;
+    case ATTR::BOLD:
+      bold = 1;
+      break;
+    case ATTR::BLINK:
+      blink = 1;
+      break;
+    case ATTR::INVERSE:
+      inverse = 1;
+      break;
+  }
+  return *this;
+}
+
+/**
+ * Equal operator.
+ *
+ * This compares colors and attributes, but ignores reset.
+ *
+ * @param[in] c const ANSIColor &
+ * @return bool
+ */
+bool ANSIColor::operator==(const ANSIColor &c) const {
+  return ((fg == c.fg) and (bg == c.bg) and (bold == c.bold) and
+          (blink == c.blink) and (inverse == c.inverse));
+}
+
+/**
+ * Not-equal operator.
+ *
+ * This compares colors and attributes, but ignores reset.
+ *
+ * @param[in] c const ANSIColor &
+ * @return bool
+ */
+bool ANSIColor::operator!=(const ANSIColor &c) const {
+  return !((fg == c.fg) and (bg == c.bg) and (bold == c.bold) and
+           (blink == c.blink) and (inverse == c.inverse));
+}
+
+/**
+ * @brief Set foreground color
+ *
+ * @param[in] f foreground COLOR
+ */
+void ANSIColor::setFg(COLOR f) {
+  fg = f;
+  reset = 0;
+  bold = 0;
+  blink = 0;
+  inverse = 0;
+}
+
+/**
+ * @brief Set foreground color and attribute
+ *
+ * @param[in] f foreground COLOR
+ * @param[in] a ATTR
+ */
+void ANSIColor::setFg(COLOR f, ATTR a) {
+  fg = f;
+  attr(a);
+}
+
+/**
+ * @brief Set background color
+ *
+ * @param[in] b background COLOR
+ */
+void ANSIColor::setBg(COLOR b) { bg = b; }
+
+/**
+ * @brief Set attribute
+ *
+ * This clears all the attributes before setting the selected ATTR.
+ *
+ * @param[in] a ATTR
+ */
+void ANSIColor::attr(ATTR a) {
+  // first, clear all attributes
+  reset = 0;
+  bold = 0;
+  blink = 0;
+  inverse = 0;
+  Attr(a);
+}
+
+/**
+ * Output the full ANSI codes for attributes and color.
+ * This does not look at the previous values.
+ */
+std::string ANSIColor::output(void) const {
+  std::string clr(CSI);
+
+  // check for special cases
+  if (reset and (fg == COLOR::BLACK) and (bg == COLOR::BLACK)) {
+    clr += "0m";
+    return clr;
+  }
+
+  if (reset and (fg == COLOR::WHITE) and (bg == COLOR::BLACK)) {
+    clr += "0m";
+    return clr;
+  }
+
+  if (reset) {
+    clr += "0;";
+  }
+
+  if (bold) {
+    if (blink) {
+      clr += "5;";
+    }
+    clr += "1;";
+  } else {
+    if (!reset) clr += "0;";
+    if (blink) {
+      clr += "5;";
+    }
+  }
+
+  clr += std::to_string(30 + (int)fg) + ";";
+  clr += std::to_string(40 + (int)bg) + "m";
+
+  return clr;
+}
+
+std::string ANSIColor::operator()(void) const {
+  std::string clr(CSI);
+
+  // check for special cases
+  if (reset and (fg == COLOR::BLACK) and (bg == COLOR::BLACK)) {
+    clr += "0m";
+    return clr;
+  }
+
+  if (reset and (fg == COLOR::WHITE) and (bg == COLOR::BLACK)) {
+    clr += "0m";
+    return clr;
+  }
+
+  if (reset) {
+    clr += "0;";
+  }
+
+  if (bold) {
+    if (blink) {
+      clr += "5;";
+    }
+    clr += "1;";
+  } else {
+    if (!reset) clr += "0;";
+    if (blink) {
+      clr += "5;";
+    }
+  }
+
+  clr += std::to_string(30 + (int)fg) + ";";
+  clr += std::to_string(40 + (int)bg) + "m";
+
+  return clr;
+}
+
+ANSIColor reset(ATTR::RESET);

+ 116 - 0
ansicolor.h

@@ -0,0 +1,116 @@
+#ifndef ANSICOLOR_H
+#define ANSICOLOR_H
+
+#include <cstdint>
+#include <string>
+
+#define CSI "\x1b["
+
+/**
+ * ANSI Color codes
+ */
+
+/**
+ * @brief The colors available under ANSI-BBS
+ */
+enum class COLOR : std::int8_t {
+  /// BLACK (0)
+  BLACK,
+  /// RED (1)
+  RED,
+  /// GREEN (2)
+  GREEN,
+  /// BROWN (3)
+  BROWN,
+  /// YELLOW (3)
+  YELLOW = 3,
+  /// BLUE (4)
+  BLUE,
+  /// MAGENTA (5)
+  MAGENTA,
+  /// CYAN (6)
+  CYAN,
+  /// WHITE (7)
+  WHITE
+};
+
+/**
+ * @brief ANSI-BBS text attributes
+ */
+enum class ATTR : std::int8_t {
+  /// RESET forces all attributes (and Colors) to be sent.
+  RESET,
+  /// BOLD is the same as BRIGHT.
+  BOLD,
+  /// BRIGHT is the same as BOLD.
+  BRIGHT = 1,
+  /// SLOW BLINK
+  BLINK = 5,
+  /// INVERSE is Background on Foreground.
+  INVERSE = 7
+};
+
+/**
+ * @class ANSIColor
+ * This holds foreground, background and ANSI-BBS attribute
+ * information.
+ * The special attribute RESET forces attribute and color
+ * output always.
+ *
+ * @brief Foreground, Background and Attributes
+ *
+ */
+class ANSIColor {
+  /** Foreground color */
+  COLOR fg;
+  /** Background color */
+  COLOR bg;
+  // Track attributes (ATTR)
+  /** reset flag / always send color and attributes */
+  unsigned int reset : 1;
+  /** bold / bright flag */
+  unsigned int bold : 1;
+  /** blink slow blinking text */
+  unsigned int blink : 1;
+  /** inverse */
+  unsigned int inverse : 1;
+
+public:
+  ANSIColor();
+  ANSIColor(ATTR a);
+  ANSIColor(COLOR f);
+  ANSIColor(COLOR f, ATTR a);
+  ANSIColor(COLOR f, ATTR a1, ATTR a2);
+  ANSIColor(COLOR f, COLOR b);
+  ANSIColor(COLOR f, COLOR b, ATTR a);
+  ANSIColor(COLOR f, COLOR b, ATTR a1, ATTR a2);
+  /*
+  ANSIColor(int c1);
+  ANSIColor(int c1, int c2);
+  */
+
+  ANSIColor &Attr(ATTR a);
+  bool operator==(const ANSIColor &c) const;
+  bool operator!=(const ANSIColor &c) const;
+  void setFg(COLOR f);
+  void setFg(COLOR f, ATTR a);
+  void setBg(COLOR b);
+  /**
+   * Get the foreground color
+   * @return COLOR
+   */
+  COLOR getFg() { return fg; };
+  /**
+   * Get the background color
+   * @return COLOR
+   */
+  COLOR getBg() { return bg; };
+  void attr(ATTR a);
+
+  std::string output(void) const;
+  std::string operator()(void) const;
+};
+
+extern ANSIColor reset;
+
+#endif

+ 19 - 29
director.cpp

@@ -3,6 +3,7 @@
 #include <boost/format.hpp>
 #include <cctype>
 
+#include "ansicolor.h"
 #include "boxes.h"
 #include "galaxy.h"
 #include "logging.h"
@@ -68,16 +69,24 @@ void Director::client_input(const std::string &input) {
     // easter-eggs:
 
     if (prompt == "Enter your choice: ") {
-      to_client(
-          "\n\r\x1b[1;36mI'd choose \x1b[1;37m`T`\x1b[1;36m, but "
-          "that's how I was coded.\n\r");
+      ANSIColor c1(COLOR::CYAN, ATTR::BOLD);
+      ANSIColor c2(COLOR::WHITE, ATTR::BOLD);
+
+      to_client(std::string("\n\r") + c1() + "I'd choose " +
+                c2() + "`T`" + c1() +
+                ", but that's how I was coded.\n\r");
+      //          "\n\r\x1b[1;36mI'd choose \x1b[1;37m`T`\x1b[1;36m, but "
+      //          "that's how I was coded.\n\r");
+
       to_client(current_raw_prompt);
       return;
     }
 
     // easter-egg
     if (prompt == "[Pause]") {
-      to_client(" \x1b[1;36mPAWS\x1b[0m\n\r");
+      ANSIColor c1(COLOR::CYAN, ATTR::BOLD);
+      to_client(std::string(" ") + c1() + "PAWS" + reset() +
+                "\n\r");
       to_client(current_raw_prompt);
       return;
     }
@@ -90,23 +99,6 @@ void Director::client_input(const std::string &input) {
       return;
     }
 
-    //
-    // The command prompt that we're looking for:
-    //
-    // "Command [TL=00:00:00]:[242] (?=Help)? : "
-    // the time, and the sector number vary...
-    /*
-        if (startswith(prompt, "Command [")) {
-          // if (prompt.substr(0, 9) == "Command [") {
-          //  int len = prompt.length();
-          if (endswith(prompt, "] (?=Help)? : ")) {
-            // if (prompt.substr(len - 14) == "] (?=Help)? : ") {
-            proxy_activate();
-            return;
-          }
-        }
-      }
-    */
     if (at_command_prompt(prompt)) {
       proxy_activate();
       return;
@@ -114,11 +106,6 @@ void Director::client_input(const std::string &input) {
   }
   // Ok...
   if (talk_direct) to_server(input);
-
-  /*
-  if (emit_client_input)
-    emit_client_input(line);
-  */
 }
 
 void Director::server_line(const std::string &line,
@@ -280,10 +267,13 @@ void Director::server_prompt(const std::string &prompt,
 void Director::build_menu(void) {
   main_menu = std::make_shared<MenuDispatch>(*this);
   MenuDispatch *md = static_cast<MenuDispatch *>(&(*main_menu));
-  md->menu_box_color = "\x1b[1;33;44m";
-  md->menu_text_color = "\x1b[1;37;44m";
+  ANSIColor bcolor(COLOR::YELLOW, COLOR::BLUE, ATTR::BOLD);
+  ANSIColor tcolor(COLOR::WHITE, COLOR::BLUE, ATTR::BOLD);
+  ANSIColor mocolor(COLOR::CYAN, ATTR::BOLD);
+  md->menu_box_color = bcolor(); // "\x1b[1;33;44m";
+  md->menu_text_color = tcolor(); // "\x1b[1;37;44m";
   md->menu_title = "Proxy Menu";
-  md->menu_options_color = "\x1b[1;36;40m";
+  md->menu_options_color = mocolor(); // "\x1b[1;36;40m";
 
   md->menu_prompt =
       "\x1b[0;31;40m\xdb\xb2\xb1\xb0 \x1b[31;40mRED "

+ 2 - 152
dispatchers.cpp

@@ -57,156 +57,6 @@ void Dispatch::client_input(const std::string &input) {
   deactivate();
 }
 
-#ifdef NOMORE
-MainDispatch::MainDispatch(Director &d) : Dispatch{d}, id{d}, md{d} {
-  BUGZ_LOG(warning) << "MainDispatch()";
-}
-
-MainDispatch::~MainDispatch() { BUGZ_LOG(warning) << "~MainDispatch()"; }
-
-void MainDispatch::activate(void) {
-  count = 0;
-  old_prompt = get_prompt();
-
-  /*
-  ╔══════════════════════════════╗
-  ║    TradeWars Proxy Active    ║
-  ╚══════════════════════════════╝
-     -=>
-  */
-
-  Boxes box(30, 1, true);
-  box.boxcolor = "\x1b[1;33;44m";
-  box.textcolor = "\x1b[1;33;44m";
-  to_client("\n\r");
-  to_client(box.top());
-  std::string output = "    TradeWars Proxy \x1b[5mActive\x1b[0;1;33;44m    ";
-  to_client(box.row(output));
-  to_client(box.bottom());
-
-  // to_client("\n\r\x1b[1;34mWELCOME!  You are now in the proxy zone...\n\r");
-  id.prompt = "\x1b[0m    \x1b[1;33;44m-=>\x1b[0m \x1b[1;37;44m";
-  id.max_length = 15;
-  id.setNotify([this]() { this->have_input(); });
-  id.activate();
-}
-
-void MainDispatch::have_input(void) {
-  ++count;
-  std::string output =
-      str(boost::format("Your Input (%2%): [%1%]\n\r") % id.input % count);
-  to_client("\x1b[0m");
-  to_client(output);
-  if (id.input == "?") {
-    // Maybe?  Maybe not.
-  }
-
-  if (id.input == "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 = " --==>> ";
-
-    // bold white to white ---  black to green
-    // md.menu_prompt = "\x1b[1;37;47m\xdb\xb2\xb1\xb0\x1b[0;30;47m RED GREEN
-    // \x1b[30;42m\xdb\xb2\xb1\xb0\x1b[0m : ";
-
-    // md.menu_prompt = "\x1b[0;31;47m\xdb\xb2\xb1\xb0\x1b[0;30;47m RED
-    // GREEN\x1b[37;42m\xdb\xb2\xb1\xb0\x1b[0m : ";
-    const char *CP437_GRADIENT = "\xdb\xb2\xb1\xb0 ";  // 100, 75, 50, 25, 0
-
-    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(); });
-    md.activate();
-    return;
-  }
-
-  if (id.input == "menu2") {
-    md.lazy = false;
-    md.setNotify([this]() { this->menu_choice(); });
-    md.activate();
-    return;
-  }
-  if (id.input.empty()) {
-    // if (count >= 5) {
-    auto lines = Boxes::alert(" Returning you to the game... ", "",
-                              "\x1b[1;32m", 30, 1, true);
-    // I'm not setting the box color, so the last color bleeds over.
-    to_client("\x1b[0m");
-    for (auto line : lines) {
-      to_client(line);
-    };
-    to_client("Returning you to the game...\n\r");
-    deactivate();
-  } else {
-    // prompt it again, sam.
-    id.setNotify([this]() { this->have_input(); });
-    id.activate();
-  }
-}
-
-void MainDispatch::menu_choice(void) {
-  if (md.input.empty()) {
-    to_client("Menu abort.\n\r");
-  } else {
-    std::string text = "Back from menu [";
-    text.append(md.input);
-    text.append("] was your selection.\n\r");
-    to_client(text);
-  }
-
-  id.max_length = 15;
-  id.setNotify([this]() { this->have_input(); });
-  id.activate();
-}
-
-void MainDispatch::deactivate(void) {
-  // Since we're the main thing there --
-  // sess->show_client = true;
-  // sess->talk_direct = true;
-
-  notify();
-}
-
-void MainDispatch::server_line(const std::string &line,
-                               const std::string &raw_line) {
-  BUGZ_LOG(info) << "MDSL: " << line;
-  to_client("SL: ");
-  to_client(line);
-  to_client("\n\r");
-}
-
-void MainDispatch::server_prompt(const std::string &prompt) {
-  BUGZ_LOG(info) << "MDSP: " << prompt;
-}
-
-#ifdef NEVERMORE
-void MainDispatch::client_input(const std::string &input) {
-  // I don't care what the old prompt looked liked at this point.
-  BUGZ_LOG(warning) << "Got: " << input;  //  << " prompt=" << get_prompt();
-
-  // Serious problem when the input = "\x1b" ESC.  The output gets gummed/locked
-  // up.
-  if (input == "\x1b") {
-    return;
-  }
-
-  ++count;
-  std::string output = str(boost::format("MSG %1%: [%2%]\n\r") % count % input);
-  to_client(output);
-  if (count >= 5) {
-    to_client("And we're outta here!\n\r");
-    deactivate();
-  }
-}
-#endif
-#endif
-
 InputDispatch::InputDispatch(Director &d) : Dispatch(d) {
   BUGZ_LOG(warning) << "InputDispatch()";
   numeric = false;
@@ -645,7 +495,7 @@ void MoveDispatch::server_line(const std::string &line,
     // [344 > 23328 > 2981 > 10465 > 14016 > 8979 > 1916 > 18734 > 5477 > 131 >
     // 27464 >] watch for <Move> it contains >
     // if ((line != "<Move>") && in(line, " > ")) {
-    if ((line != "<Move>") && (in(line, " > ") || !warp_lane.empty())) {      
+    if ((line != "<Move>") && (in(line, " > ") || !warp_lane.empty())) {
       bool more = false;
       std::string work = line;
 
@@ -1185,7 +1035,7 @@ void TraderDispatch::server_prompt(const std::string &prompt) {
                                       << " is burnt " << x << " burnt = true";
                       burnt = true;
                     }
-                  } 
+                  }
                 }
               }
             }

+ 0 - 104
session.cpp

@@ -448,111 +448,7 @@ void Session::client_input(const std::string &input) {
   BUGZ_LOG(info) << "CI: [" << temp << "]";
   director.client_input(input);
 
-#ifdef DECOUPLE
-  // Is "proxy" active
-  if (active) {
-    // do something amazing with the user's input.
-  } else {
-    if (input == "\x1b" || input == "~") {
-      std::string prompt = clean_string(get_prompt());
-      BUGZ_LOG(trace) << "CI: ACTIVATE prompt shows: [" << prompt << "]";
-
-      if (prompt == "Selection (? for menu): ") {
-        to_client(
-            "\n\rThere's not much we can do here.  Activate in-game at a "
-            "Command prompt.\n\r");
-        to_client(get_prompt());
-        return;
-      }
-
-      // easter-eggs:
-
-      if (prompt == "Enter your choice: ") {
-        to_client(
-            "\n\r\x1b[1;36mI'd choose \x1b[1;37m`T`\x1b[1;36m, but "
-            "that's how I was coded.\n\r");
-        to_client(get_prompt());
-        return;
-      }
-
-      // easter-egg
-      if (prompt == "[Pause]") {
-        to_client(" \x1b[1;36mMeow\x1b[0m\n\r");
-        to_client(get_prompt());
-        return;
-      }
-
-      //
-      // The command prompt that we're looking for:
-      //
-      // "Command [TL=00:00:00]:[242] (?=Help)? : "
-      // the time, and the sector number vary...
-      if (prompt.substr(0, 9) == "Command [") {
-        int len = prompt.length();
-        if (prompt.substr(len - 14) == "] (?=Help)? : ") {
-          proxy_activate();
-          /*
-          to_client("\n\r\x1b[1;34mWELCOME!  This is where the proxy would "
-                    "activate.\n\r");
-          // active = true;
-          // show_client = true;  // because if something comes (unexpected)
-          // from the server? talk_direct = false;
-
-          // but we aren't activating (NNY)
-          to_client(get_prompt());
-          */
-          return;
-        }
-      }
-
-      // eat this input.
-      BUGZ_LOG(warning) << "CI: unable to activate, prompt was: [" << prompt
-                        << "]";
-      return;
-    }
-  }
-
-  // as the above code matures, talk_direct might get changed.
-  // keep this part here (and not above).
-  if (talk_direct) {
-    to_server(input);
-  }
-
-  if (emit_client_input) {
-    emit_client_input(input);
-  }
-#endif
-}
-
-/*
-DispatchSettings Session::save_settings(void) {
-  DispatchSettings ss{emit_server_line, emit_server_prompt, emit_client_input,
-                      show_client, talk_direct};
-  return ss;
-}
-
-void Session::restore_settings(const DispatchSettings &ss) {
-  emit_server_line = ss.server_line;
-  emit_server_prompt = ss.server_prompt;
-  emit_client_input = ss.client_input;
-  show_client = ss.show_client;
-  talk_direct = ss.talk_direct;
-}
-
-void Session::proxy_activate(void) {
-  active = true;
-  start_keepin_alive();  // kickstart the keepalive timer
-  main.setNotify([this](void) { this->proxy_deactivate(); });
-  main.activate();
-}
-
-void Session::proxy_deactivate(void) {
-  // Ok, how do we return?
-  active = false;
-  to_client(get_prompt());
-  // to_client(" \b");
 }
-*/
 
 void Session::client_read(void) {
   auto self(shared_from_this());