| 
					
				 | 
			
			
				@@ -5,6 +5,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #include "boxes.h" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #include "logging.h" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#include "utils.h" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 Dispatch::Dispatch(Director &d) : director{d} {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 Dispatch::~Dispatch(){}; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -31,7 +32,8 @@ void Dispatch::chain_client_input(const std::string &input) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-void Dispatch::chain_server_line(const std::string &line, const std::string &raw_line) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void Dispatch::chain_server_line(const std::string &line, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                 const std::string &raw_line) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   if (chain) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     chain->chain_server_line(line, raw_line); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -47,7 +49,8 @@ void Dispatch::chain_server_prompt(const std::string &prompt) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-void Dispatch::server_line(const std::string &line, const std::string &raw_line) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void Dispatch::server_line(const std::string &line, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                           const std::string &raw_line) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void Dispatch::server_prompt(const std::string &prompt) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void Dispatch::client_input(const std::string &input) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -166,7 +169,8 @@ void MainDispatch::deactivate(void) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   notify(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-void MainDispatch::server_line(const std::string &line, const std::string &raw_line) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void MainDispatch::server_line(const std::string &line, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                               const std::string &raw_line) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   BUGZ_LOG(info) << "MDSL: " << line; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   to_client("SL: "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   to_client(line); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -211,11 +215,47 @@ void InputDispatch::activate(void) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void InputDispatch::deactivate(void) { notify(); } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-void InputDispatch::server_line(const std::string &line, const std::string &raw_line) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // TO FIX: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // clear user input and input prompt, display server_line, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // and re-display prompt. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void InputDispatch::server_line(const std::string &line, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                const std::string &raw_line) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (line.empty()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  std::string temp = repr(raw_line); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  BUGZ_LOG(fatal) << "Input:SL(" << temp << ")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (startswith(line, "Command [TL=")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  temp = raw_line; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  clean_string(temp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  BUGZ_LOG(fatal) << "InputDispatch::server_line(" << temp << ")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  temp = prompt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  ansi_clean(temp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  size_t total = temp.length() + input.length(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  to_client("\x1b[0m");  // reset colors 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  while (total > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    to_client("\b \b"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    --total; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Lines line "\[[1A\[[1;36mphil \[[0;32mwarps into the sector.\[[0m" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  temp = raw_line; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  replace(temp, "\x1b[1A", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // replace(temp, "\x1[2J", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  to_client(temp);  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  to_client("\n\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Doesn't matter if it is one or two calls. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  temp = prompt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  temp.append(input); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  to_client(temp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // to_client(prompt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // to_client(input); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // void InputDispatch::server_prompt(const std::string &prompt) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void InputDispatch::client_input(const std::string &cinput) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -362,7 +402,8 @@ void MenuDispatch::calculate_widths(void) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   instant = max_option_width == 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-void MenuDispatch::server_line(const std::string &line, const std::string &raw_line) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void MenuDispatch::server_line(const std::string &line, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                               const std::string &raw_line) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // TODO: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Clear prompt, display raw server line, restore prompt. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -460,7 +501,8 @@ void CoreDispatch::deactivate(void) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   notify(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-void CoreDispatch::server_line(const std::string &line, const std::string &raw_line) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void CoreDispatch::server_line(const std::string &line, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                               const std::string &raw_line) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void CoreDispatch::server_prompt(const std::string &prompt) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void CoreDispatch::client_input(const std::string &input) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   BUGZ_LOG(warning) << "Got: " << input << " prompt=" << get_prompt(); 
			 |