Skip to main content

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

MemberSummary
TextCompleter(ITextEntry, ISuggestsWords, ICutsWords, ArlecchinoKeymap)Hangs completion on a line.

Properties

MemberSummary
ChosenIndexWhich 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.
WordsWhat 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

MemberSummary
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

NameTypeDescription
entryITextEntryThe line being typed into.
wordsISuggestsWordsWhere the words come from.
cutsICutsWordsWhich part of the line is the word being finished.
keymapArlecchinoKeymapThe 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

NameTypeDescription
forwardbooltrue 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

NameTypeDescription
keyKeyPressThe key that arrived.

Returns booltrue 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;
}