// Tab across to the next stop, or perform tab completion. private static void Tab(String prompt) { if (TabComplete == null) { // Add the TAB character and repaint the line. AddChar('\t'); } else { if (state != State.Completing) { CollectLastWord('\0'); state = State.Completing; } // Perform tab completion and insert the results. TabCompleteEventArgs e = new TabCompleteEventArgs(lastWord.ToString(), ++tabCount); TabComplete(null, e); if (e.Insert != null) { if (tabCount > 0) { GoBack(insertedCount); Delete(insertedCount); } insertedCount = e.Insert.Length; savePosn = posn; // Insert the value that we found. bool saveOverwrite = overwrite; overwrite = false; savePosn = e.Insert.Length; state = State.Completing; foreach (char ch in e.Insert) { AddChar(ch); } overwrite = saveOverwrite; } else if (e.Alternatives != null && e.Alternatives.Length > 0) { // Print the alternatives for the user. savePosn = posn; EndLine(); PrintAlternatives(e.Alternatives); if (prompt != null) { Console.Write(prompt); } posn = savePosn; state = State.Completing; Redraw(); } else { if (e.Error) ResetComplete(State.MoreInput); // No alternatives, or alternatives not supplied yet. Console.Beep(); } } }
// Tab across to the next stop, or perform tab completion. private static void Tab(String prompt) { if (TabComplete == null) { // Add the TAB character and repaint the line. AddChar('\t'); } else { if (state != State.Completing) { CollectLastWord('\0'); state = State.Completing; } // Perform tab completion and insert the results. TabCompleteEventArgs e = new TabCompleteEventArgs(lastWord.ToString(), ++tabCount); TabComplete(null, e); if (e.Insert != null) { if (tabCount > 0) { GoBack(insertedCount); Delete(insertedCount); } insertedCount = e.Insert.Length; savePosn = posn; // Insert the value that we found. bool saveOverwrite = overwrite; overwrite = false; savePosn = e.Insert.Length; state = State.Completing; foreach (char ch in e.Insert) { AddChar(ch); } overwrite = saveOverwrite; } else if (e.Alternatives != null && e.Alternatives.Length > 0) { // Print the alternatives for the user. savePosn = posn; EndLine(); PrintAlternatives(e.Alternatives); if (prompt != null) { Console.Write(prompt); } posn = savePosn; state = State.Completing; Redraw(); } else { if (e.Error) { ResetComplete(State.MoreInput); } // No alternatives, or alternatives not supplied yet. Console.Beep(); } } }