TextCompleter class
Namespace: Arlecchino.Editing · Assembly: Arlecchino
Finishing the word being typed, hung on any line of text. The first press fills in what every candidate agrees on, later presses step through them, and typing on leaves the offer behind.
public sealed class TextCompleter
Constructors
| Member | Summary |
|---|---|
TextCompleter(ITextEntry, ISuggestsWords, ICutsWords, ArlecchinoKeymap) | Hangs completion on a line. |
Properties
| Member | Summary |
|---|---|
ChosenIndex | Which of TextCompleter.Words is on the line now, or -1 while the line holds only as much as they all agree on and none of them in particular. |
Words | What the last press found, for an application that draws them. It is empty while nothing has been offered and empties itself once the line has been typed into again. |
Methods
| Member | Summary |
|---|---|
Complete(bool) | Finishes the word being typed. Where the words are known already, this steps through them instead of asking for them again. |
Forget() | Drops what was offered and gives up whatever is still being asked for. A line that is closed or wiped calls it; a line that is only typed into need not, since an offer outlives no edit. |
Handle(KeyPress) | Finishes the word, or steps to the next of what was offered for it. Any other key is left alone and this can be asked before the editing keys are. |
Constructors in detail
TextCompleter(ITextEntry, ISuggestsWords, ICutsWords, ArlecchinoKeymap)
public TextCompleter(
ITextEntry entry,
ISuggestsWords words,
ICutsWords cuts,
ArlecchinoKeymap keymap);
Hangs completion on a line.
Parameters
| Name | Type | Description |
|---|---|---|
entry | ITextEntry | The line being typed into. |
words | ISuggestsWords | Where the words come from. |
cuts | ICutsWords | Which part of the line is the word being finished. |
keymap | ArlecchinoKeymap | The keys the application obeys, which TextCompleter.Handle reads by. |
Properties in detail
ChosenIndex
public int ChosenIndex { get; }
Which of TextCompleter.Words is on the line now, or -1 while the line holds only as much as they all agree on and none of them in particular.
Type int
Words
public IReadOnlyList<string> Words { get; }
What the last press found, for an application that draws them. It is empty while nothing has been offered and empties itself once the line has been typed into again.
Type IReadOnlyList<T><string>
Methods in detail
Complete(bool)
public void Complete(bool forward);
Finishes the word being typed. Where the words are known already, this steps through them instead of asking for them again.
Parameters
| Name | Type | Description |
|---|---|---|
forward | bool | true to step to the next of them, false to the one before. |
Forget()
public void Forget();
Drops what was offered and gives up whatever is still being asked for. A line that is closed or wiped calls it; a line that is only typed into need not, since an offer outlives no edit.
Handle(KeyPress)
public bool Handle(KeyPress key);
Finishes the word, or steps to the next of what was offered for it. Any other key is left alone and this can be asked before the editing keys are.
Parameters
| Name | Type | Description |
|---|---|---|
key | KeyPress | The key that arrived. |
Returns bool — true when the key was one of these and has been dealt with.
Example
var completer = new TextCompleter(entry, new WordList(() => Commands), new SpaceWords(), keymap);
if (completer.Handle(key))
{
return true;
}