diff -r 3492f8f0ee7e -r b4466472aecd sources/interface.cpp --- a/sources/interface.cpp Fri Jul 24 04:31:17 2015 +0300 +++ b/sources/interface.cpp Sat Jan 09 17:20:25 2016 +0200 @@ -827,7 +827,13 @@ break; case INPUTSTATE_NORMAL: - if (Session.send_command (current_input())) + if (current_input()[0] == '/') + { + handle_command(current_input()); + InputHistory.insert (0, ""); + NeedInputRender = true; + } + else if (Session.send_command (current_input())) { InputHistory.insert (0, ""); NeedInputRender = true; @@ -1027,4 +1033,51 @@ } } -END_ZFC_NAMESPACE \ No newline at end of file +// ------------------------------------------------------------------------------------------------- +// +void Interface::handle_command(const String& input) +{ + if (input[0] != '/') + return; + + StringList args = input.right(input.length() - 1).split(" "); + String command = args[0].to_lowercase(); + args.remove_at(0); + + if (command == "connect") + { + if (args.size() != 2) + print_error("Usage: /connect
"); + else + { + IPAddress address; + + try + { + address = IPAddress::from_string(args[0]); + } + catch (std::exception& e) + { + print_error("%s\n", e.what()); + return; + } + + if (address.port == 0) + address.port = 10666; + + Session.set_password(args[1]); + Session.disconnect(); + Session.connect(CurrentAddress = address); + } + } + else if (command == "quit") + { + Session.disconnect(); + endwin(); + throw Exitception(); + } + else + print_error("Unknown command %s\n", command.chars()); +} + +END_ZFC_NAMESPACE