825 set_input_state (INPUTSTATE_NORMAL); |
825 set_input_state (INPUTSTATE_NORMAL); |
826 } |
826 } |
827 break; |
827 break; |
828 |
828 |
829 case INPUTSTATE_NORMAL: |
829 case INPUTSTATE_NORMAL: |
830 if (Session.send_command (current_input())) |
830 if (current_input()[0] == '/') |
|
831 { |
|
832 handle_command(current_input()); |
|
833 InputHistory.insert (0, ""); |
|
834 NeedInputRender = true; |
|
835 } |
|
836 else if (Session.send_command (current_input())) |
831 { |
837 { |
832 InputHistory.insert (0, ""); |
838 InputHistory.insert (0, ""); |
833 NeedInputRender = true; |
839 NeedInputRender = true; |
834 } |
840 } |
835 break; |
841 break; |
1025 CursorPosition = complete.length(); |
1031 CursorPosition = complete.length(); |
1026 NeedInputRender = true; |
1032 NeedInputRender = true; |
1027 } |
1033 } |
1028 } |
1034 } |
1029 |
1035 |
|
1036 // ------------------------------------------------------------------------------------------------- |
|
1037 // |
|
1038 void Interface::handle_command(const String& input) |
|
1039 { |
|
1040 if (input[0] != '/') |
|
1041 return; |
|
1042 |
|
1043 StringList args = input.right(input.length() - 1).split(" "); |
|
1044 String command = args[0].to_lowercase(); |
|
1045 args.remove_at(0); |
|
1046 |
|
1047 if (command == "connect") |
|
1048 { |
|
1049 if (args.size() != 2) |
|
1050 print_error("Usage: /connect <address> <password>"); |
|
1051 else |
|
1052 { |
|
1053 IPAddress address; |
|
1054 |
|
1055 try |
|
1056 { |
|
1057 address = IPAddress::from_string(args[0]); |
|
1058 } |
|
1059 catch (std::exception& e) |
|
1060 { |
|
1061 print_error("%s\n", e.what()); |
|
1062 return; |
|
1063 } |
|
1064 |
|
1065 if (address.port == 0) |
|
1066 address.port = 10666; |
|
1067 |
|
1068 Session.set_password(args[1]); |
|
1069 Session.disconnect(); |
|
1070 Session.connect(CurrentAddress = address); |
|
1071 } |
|
1072 } |
|
1073 else if (command == "quit") |
|
1074 { |
|
1075 Session.disconnect(); |
|
1076 endwin(); |
|
1077 throw Exitception(); |
|
1078 } |
|
1079 else |
|
1080 print_error("Unknown command %s\n", command.chars()); |
|
1081 } |
|
1082 |
1030 END_ZFC_NAMESPACE |
1083 END_ZFC_NAMESPACE |