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;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Dictionary {
|
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 List<Word> dict = new ArrayList<>();
|
||||||
private final Fcl fcl;
|
private final Fcl fcl;
|
||||||
|
|
||||||
|
@ -34,10 +47,11 @@ public class Dictionary {
|
||||||
dict.remove(existing);
|
dict.remove(existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> wordList() {
|
public Set<String> wordList(Filter filter) {
|
||||||
Set<String> result = new HashSet<>();
|
Set<String> result = new HashSet<>();
|
||||||
for (Word word : dict) {
|
for (Word word : dict) {
|
||||||
result.add(word.name());
|
if (filter.shouldInclude(word.name()))
|
||||||
|
result.add(word.name());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,7 +451,7 @@ public class Fcl {
|
||||||
addPrimitive("abort", () -> { throw new Aborted(stack.pop().asStr().value()); });
|
addPrimitive("abort", () -> { throw new Aborted(stack.pop().asStr().value()); });
|
||||||
addPrimitive("eval", () -> eval(stack.pop().asStr().value()));
|
addPrimitive("eval", () -> eval(stack.pop().asStr().value()));
|
||||||
addPrimitive("words", () -> {
|
addPrimitive("words", () -> {
|
||||||
List<String> words = new ArrayList<>(wordList());
|
List<String> words = new ArrayList<>(wordList(Dictionary.Filter.ALL));
|
||||||
Collections.sort(words);
|
Collections.sort(words);
|
||||||
for (String each : words) {
|
for (String each : words) {
|
||||||
transcript.show(each);
|
transcript.show(each);
|
||||||
|
@ -709,7 +709,7 @@ public class Fcl {
|
||||||
rstack.clean();
|
rstack.clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> wordList() {
|
public Set<String> wordList(Dictionary.Filter filter) {
|
||||||
return dict.wordList();
|
return dict.wordList(filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue