Exemplo n.º 1
0
        public void ApplyOnKeyUp(DelayBuffer output, KeyboardKey thisKeyPress, bool isShifted, bool altPressed, bool ctlPressed, bool logoPressed)
        {
            var  c            = KeyboardTables.KeyToChar(thisKeyPress, isShifted);
            bool thisKeyValid = (c != '\0' && !altPressed && !ctlPressed && !logoPressed);

            if (!thisKeyValid)
            {
                // If this isn't valid, reset the previously memorised key.
                _LastChar = '\0';
                return;
            }

            // If this keypress corresponds to a typable character and no modifier keys are pressed and the last character is valid: transpose them.
            if (_LastChar != '\0')
            {
                // Delete the two characters.
                output.KeyPress(KeyboardKey.BackSpace);
                output.KeyPress(KeyboardKey.BackSpace);

                // Echo them in reverse order.
                output.KeyPressWithModifier(KeyboardTables.CharToKeyStroke(c));
                output.KeyPressWithModifier(KeyboardTables.CharToKeyStroke(_LastChar));

                // That's the end of this fiddle.
                _IsComplete = true;
                return;
            }

            // Memorise the key for next call.
            _LastChar = c;
        }
Exemplo n.º 2
0
        public void ApplyOnKeyUp(DelayBuffer output, KeyboardKey thisKeyPress, bool isShifted, bool altPressed, bool ctlPressed, bool logoPressed)
        {
            // Ensure the phrase is inserted at the end of a sentence or paragraph.
            bool atEndOfSentence = (thisKeyPress == KeyboardKey.Space) &&
                                   Array.IndexOf(KeyboardTables.EndOfSentenceCharacters, _LastLetterPressed) != -1;

            if (atEndOfSentence)
            {
                // Actually insert the phrase!!
                var s = _Phrases[_SelectedPhrase];
                for (int i = 0; i < s.Length; i++)
                {
                    var keyStroke = KeyboardTables.CharToKeyStroke(s[i]);
                    output.KeyPressWithModifier(keyStroke);
                }
                // Append a space.
                if (s[s.Length - 1] != ' ')
                {
                    output.KeyPress(KeyboardKey.Space);
                }

                // Mark completion.
                _IsComplete = true;
            }
            else
            {
                // Capture the last keypress as a character.
                var c = KeyboardTables.KeyToChar(thisKeyPress, isShifted);
                if (c != (char)0)
                {
                    _LastLetterPressed = c;
                }
            }
        }
Exemplo n.º 3
0
        public void ApplyOnKeyUp(DelayBuffer output, KeyboardKey thisKeyPress, bool isShifted, bool altPressed, bool ctlPressed, bool logoPressed)
        {
            // If this keypress corresponds to a typable character and no modifier keys are pressed: queue a backspace to delete it.
            var c = KeyboardTables.KeyToChar(thisKeyPress, isShifted);

            if (c != '\0' && !altPressed && !ctlPressed && !logoPressed)
            {
                output.KeyPress(KeyboardKey.BackSpace);
                _IsComplete = true;
            }
        }