-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoCompleter.js
46 lines (46 loc) · 1015 Bytes
/
AutoCompleter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class AutoCompleter
{
constructor(parser)
{
this.parser = parser;
this.text = null;
this.index = 0;
this.options = [];
}
fillNext(reverseDirection)
{
if(this.text == null)
{
this.text = this.parser.text;
this.index = 0;
this.options = this.parser.__getAutoCompletionOptions();
}
if(this.options.length <= 0)
{
return;
}
this.parser.text = this.options[this.index];
if(reverseDirection)//Opposite direction
{
this.index--;
if(this.index < 0)
{
this.index = this.options.length - 1;
}
}
else
{
this.index++;
if(this.index >= this.options.length)
{
this.index = 0;
}
}
}
disable()
{
this.text = null;
this.options = [];
}
}
module.exports = AutoCompleter