-
Notifications
You must be signed in to change notification settings - Fork 10
/
acecustomautocomplete.html
60 lines (56 loc) · 1.25 KB
/
acecustomautocomplete.html
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ace custom autocomplete test</title>
<script src="https://ajaxorg.github.io/ace-builds/src-min-noconflict/ace.js"></script>
<script src="https://ajaxorg.github.io/ace-builds/src-min-noconflict/ext-language_tools.js"></script>
<style>
body {
overflow: hidden;
}
#editorWidget {
margin: 0;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body>
<pre id="editorWidget"></pre>
</body>
<script>
var langTools = ace.require("ace/ext/language_tools");
var aceEditor = ace.edit("editorWidget").setOptions({
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
enableSnippets: false
});
var myList = [
"/dev/sda1",
"/dev/sda2",
"PARTLABEL=foobar_boot",
"PARTLABEL=foobar_root"
]
var myCompleter = {
identifierRegexps: [/[^\s]+/],
getCompletions: function(editor, session, pos, prefix, callback) {
console.info("myCompleter prefix:", prefix);
callback(
null,
myList.filter(entry=>{
return entry.includes(prefix);
}).map(entry=>{
return {
value: entry
};
})
);
}
}
langTools.addCompleter(myCompleter);
</script>
</html>