Mono.Terminal.Entry.ProcessKey C# (CSharp) Method

ProcessKey() public method

public ProcessKey ( int key ) : bool
key int
return bool
        public override bool ProcessKey(int key)
        {
            switch (key){
            case 127:
            case Curses.KeyBackspace:
                if (point == 0)
                    return true;

                SetText (text.Substring (0, point - 1) + text.Substring (point));
                point--;
                Adjust ();
                break;

            case Curses.KeyHome:
            case 1: // Control-a, Home
                point = 0;
                Adjust ();
                break;

            case Curses.KeyLeft:
            case 2: // Control-b, back character
                if (point > 0){
                    point--;
                    Adjust ();
                }
                break;

            case 4: // Control-d, Delete
                if (point == text.Length)
                    break;
                SetText (text.Substring (0, point) + text.Substring (point+1));
                Adjust ();
                break;

            case 5: // Control-e, End
                point = text.Length;
                Adjust ();
                break;

            case Curses.KeyRight:
            case 6: // Control-f, forward char
                if (point == text.Length)
                    break;
                point++;
                Adjust ();
                break;

            case 11: // Control-k, kill-to-end
                kill = text.Substring (point);
                SetText (text.Substring (0, point));
                Adjust ();
                break;

            case 25: // Control-y, yank
                if (kill == null)
                    return true;

                if (point == text.Length){
                    SetText (text + kill);
                    point = text.Length;
                } else {
                    SetText (text.Substring (0, point) + kill + text.Substring (point));
                    point += kill.Length;
                }
                Adjust ();
                break;

            case (int) 'b' + Curses.KeyAlt:
                int bw = WordBackward (point);
                if (bw != -1)
                    point = bw;
                Adjust ();
                break;

            case (int) 'f' + Curses.KeyAlt:
                int fw = WordForward (point);
                if (fw != -1)
                    point = fw;
                Adjust ();
                break;

            default:
                // Ignore other control characters.
                if (key < 32 || key > 255)
                    return false;

                if (used){
                    if (point == text.Length){
                        SetText (text + (char) key);
                    } else {
                        SetText (text.Substring (0, point) + (char) key + text.Substring (point));
                    }
                    point++;
                } else {
                    SetText ("" + (char) key);
                    first = 0;
                    point = 1;
                }
                used = true;
                Adjust ();
                return true;
            }
            used = true;
            return true;
        }