示例#1
0
        // TODO - Support petcat-style control codes?

        private static void Type(Config config, string[] args)
        {
            try
            {
                // Combine all the arguments into a single string.
                string[] vals = args.SubArray(2, args.Length - 2);
                string   text = String.Join(" ", vals);

                // Automatically add RETURN?
                if (text.StartsWith("-n "))
                {
                    text = text.Replace("-n ", "");
                }
                else
                {
                    text += "\r";   // RETURN
                }

                // Convert into char array
                char[] textAsChars = text.ToCharArray();

                // List of bytes to send.  Has to be bytes to handle 8-bit control characters in escape sequences.
                List <byte> bytesToSend = new List <byte>();

                // Loop through input string
                for (int i = 0; i < textAsChars.Length; i++)
                {
                    char c = textAsChars[i];

                    if (c == ESCAPE)
                    {
                        byte cc = SubstituteControlChar(textAsChars[++i]);  // Skips over control char on next loop
                        bytesToSend.Add(cc);
                    }
                    else
                    {
                        byte pet = Utilities.ASCIItoPETSCII(c);
                        bytesToSend.Add(pet);
                    }
                }

                Ultimate64Commands.SendKeyboardBytes(config, bytesToSend.ToArray());
            }
            catch (Exception e)
            {
                Handle(e);
            }
        }