(List<String> args)
| 895 | } |
| 896 | |
| 897 | private static void Key_Bind_f(List<String> args) { |
| 898 | |
| 899 | if (args.size() < 2) { |
| 900 | Com.Printf("bind <key> [command] : attach a command to a key\n"); |
| 901 | return; |
| 902 | } |
| 903 | int key = StringToKeynum(args.get(1)); |
| 904 | if (key == -1) { |
| 905 | Com.Printf("\"" + args.get(1) + "\" isn't a valid key\n"); |
| 906 | return; |
| 907 | } |
| 908 | |
| 909 | // show current binding |
| 910 | if (args.size() == 2) { |
| 911 | if (ClientGlobals.keybindings[key] != null) |
| 912 | Com.Printf("\"" + args.get(1) + "\" = \"" + ClientGlobals.keybindings[key] + "\"\n"); |
| 913 | else |
| 914 | Com.Printf("\"" + args.get(1) + "\" is not bound\n"); |
| 915 | return; |
| 916 | } |
| 917 | |
| 918 | // copy the rest of the command line |
| 919 | String cmd = ""; // start out with a null string |
| 920 | for (int i = 2; i < args.size(); i++) { |
| 921 | cmd += args.get(i); |
| 922 | if (i != (args.size() - 1)) |
| 923 | cmd += " "; |
| 924 | } |
| 925 | |
| 926 | SetBinding(key, cmd); |
| 927 | } |
| 928 | |
| 929 | static void SetBinding(int keynum, String binding) { |
| 930 | if (keynum == -1) |
nothing calls this directly
no test coverage detected