mirror of
https://github.com/zeroflag/fcl.git
synced 2025-01-11 20:01:10 +01:00
filter out -impl words from auto complete list
+font size fix
This commit is contained in:
parent
9019abff9b
commit
3bc5060985
2 changed files with 19 additions and 5 deletions
|
@ -8,6 +8,19 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
public class Dictionary {
|
||||
public interface Filter {
|
||||
boolean shouldInclude(String name);
|
||||
Filter ALL = new Filter() {
|
||||
public boolean shouldInclude(String name) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
Filter NO_IMPLS = new Filter() {
|
||||
public boolean shouldInclude(String name) {
|
||||
return !name.endsWith("-impl");
|
||||
}
|
||||
};
|
||||
}
|
||||
private final List<Word> dict = new ArrayList<>();
|
||||
private final Fcl fcl;
|
||||
|
||||
|
@ -34,9 +47,10 @@ public class Dictionary {
|
|||
dict.remove(existing);
|
||||
}
|
||||
|
||||
public Set<String> wordList() {
|
||||
public Set<String> wordList(Filter filter) {
|
||||
Set<String> result = new HashSet<>();
|
||||
for (Word word : dict) {
|
||||
if (filter.shouldInclude(word.name()))
|
||||
result.add(word.name());
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -451,7 +451,7 @@ public class Fcl {
|
|||
addPrimitive("abort", () -> { throw new Aborted(stack.pop().asStr().value()); });
|
||||
addPrimitive("eval", () -> eval(stack.pop().asStr().value()));
|
||||
addPrimitive("words", () -> {
|
||||
List<String> words = new ArrayList<>(wordList());
|
||||
List<String> words = new ArrayList<>(wordList(Dictionary.Filter.ALL));
|
||||
Collections.sort(words);
|
||||
for (String each : words) {
|
||||
transcript.show(each);
|
||||
|
@ -709,7 +709,7 @@ public class Fcl {
|
|||
rstack.clean();
|
||||
}
|
||||
|
||||
public Set<String> wordList() {
|
||||
return dict.wordList();
|
||||
public Set<String> wordList(Dictionary.Filter filter) {
|
||||
return dict.wordList(filter);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue