// Tab across to the next stop, or perform tab completion. private void Tab() { if (TabComplete == null) { // Add the TAB character and repaint the line. AddChar('\t'); } else { if (_state != ReadlineState.Completing) { CollectLastWord('\0'); _state = ReadlineState.Completing; } // Perform tab completion and insert the results. var e = new TabCompleteEventArgs(_lastWord.ToString(), ++_tabCount); TabComplete(this, e); if (e.Insert != null) { _savePosn = _posn; // Insert the value that we found. var saveOverwrite = _overwrite; _overwrite = false; _savePosn = e.Insert.Length; _state = ReadlineState.Completing; foreach (var 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?.Invoke(this, new PrintAlternativesEventArgs(e.Alternatives)); WritePrompt?.Invoke(this, EventArgs.Empty); _posn = _savePosn; _state = ReadlineState.Completing; Redraw(); } else { if (e.Error) { ResetComplete(ReadlineState.MoreInput); } // No alternatives, or alternatives not supplied yet. Console.Beep(); } } }
private void ReadlineOnTabComplete(object sender, TabCompleteEventArgs e) { var buff = ((Readline.Readline)sender).LineBuffer; lock (_lock) { var complete = _container.CompleteInput(this, buff).ToArray(); if (complete.Length == 1) { e.Output = complete.First() + " "; } else if (complete.Length > 1) { e.Alternatives = complete; } } }