oriches/Simple.Wpf.Terminal — pull request #5 by Dige (2014-04-09 12:34:51+00:00)
Title: Autocompletion support

Adds support for autocompleting lines by pressing tab. First Tab press retrieves the list of possible completions from the bound list and replaces the line with the first possible completion. The consecutive presses will traverse through the same list. The list of possible completions will be refreshed if any other key than Tab is pressed.

Example of a bound property for AutoCompletionsSource in a ViewModel:

```
private string _line;
public string Line
{
get { return _line; }
set
{
_line = value;
RaisePropertyChanged(() => AutoCompletionItems);
}
}

public IEnumerable AutoCompletionItems
{
get
{
var line = Line.Trim();
if (line.Contains(" "))
{
var beginningPart = line.Substring(0, line.LastIndexOf(' ') + 1);
var partToBeCompleted = line.Substring(line.LastIndexOf(' ') + 1);

return ScriptHost.GetCompletions(partToBeCompleted).Select(c => beginningPart + c);
}
return ScriptHost.GetCompletions(line);
}
}
```

Example of XAML:
```