\r
+ listener/plugin:\r
\r
+- listener: if too many things popped off the stack, complain\r
- gracefully handle non-working cfactor\r
- don't show listener on certain commands\r
- NPE in ErrorHighlight\r
- some way to not have previous definitions from a source file\r
clutter the namespace\r
-- finish ExternalFactor VocabularyLookup\r
- maple-like: press enter at old commands to evaluate there\r
- completion in the listener\r
- special completion for USE:/IN:\r
return new FactorStream(client);
} //}}}
+ //{{{ getVocabularies() method
+ public Cons getVocabularies()
+ {
+ Cons vocabs = super.getVocabularies();
+
+ try
+ {
+ Cons moreVocabs = (Cons)parseObject(eval("vocabs.")).car;
+ while(moreVocabs != null)
+ {
+ String vocab = (String)moreVocabs.car;
+ if(!Cons.contains(vocabs,vocab))
+ vocabs = new Cons(vocab,vocabs);
+ moreVocabs = moreVocabs.next();
+ }
+ }
+ catch(Exception e)
+ {
+ Log.log(Log.ERROR,this,e);
+ }
+ return vocabs;
+ } //}}}
+
//{{{ searchVocabulary() method
/**
* Search through the given vocabulary list for the given word.
}
} //}}}
+ //{{{ getCompletions() method
+ public void getCompletions(String vocab, String word, List completions,
+ boolean anywhere)
+ {
+ super.getCompletions(vocab,word,completions,anywhere);
+
+ try
+ {
+ /* We can't send words across the socket at this point in
+ human history, because of USE: issues. so we send name/vocab
+ pairs. */
+ Cons moreCompletions = (Cons)parseObject(eval(
+ FactorReader.unparseObject(word)
+ + " "
+ + FactorReader.unparseObject(vocab)
+ + " "
+ + (anywhere ? "vocab-apropos" : "vocab-completions")
+ + " [ dup word-name swap word-vocabulary 2list ] map .")).car;
+
+ while(moreCompletions != null)
+ {
+ Cons completion = (Cons)moreCompletions.car;
+ completions.add(searchVocabulary(completion.next(),
+ (String)completion.car));
+ moreCompletions = moreCompletions.next();
+ }
+ }
+ catch(Exception e)
+ {
+ Log.log(Log.ERROR,this,e);
+ }
+ } //}}}
+
//{{{ close() method
/**
* Close communication session. Factor will then exit.
}
} //}}}
- //{{{ getCompletions() method
- /**
- * @param anywhere If true, matches anywhere in the word name are
- * returned; otherwise, only matches from beginning.
- */
- public static List getCompletions(Iterator use, String word, boolean anywhere)
- {
- try
- {
- List completions = new ArrayList();
-
- while(use.hasNext())
- {
- String vocab = (String)use.next();
- getExternalInstance().getCompletions(
- vocab,word,completions,anywhere);
- }
-
- Collections.sort(completions,
- new MiscUtilities.StringICaseCompare());
-
- return completions;
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
- } //}}}
-
//{{{ getCompletions() method
/**
* @param anywhere If true, matches anywhere in the word name are
private static FactorWord[] findAllWordsNamed(View view, String word)
throws Exception
{
+ ExternalFactor external = getExternalInstance();
+
ArrayList words = new ArrayList();
- Iterator vocabs = getExternalInstance().getVocabularies();
- while(vocabs.hasNext())
+
+ Cons vocabs = external.getVocabularies();
+ while(vocabs != null)
{
- Map vocab = (Map)vocabs.next();
- FactorWord w = (FactorWord)vocab.get(word);
+ String vocab = (String)vocabs.car;
+ FactorWord w = (FactorWord)external.searchVocabulary(
+ new Cons(vocab,null),word);
if(w != null)
words.add(w);
+ vocabs = vocabs.next();
}
return (FactorWord[])words.toArray(new FactorWord[words.size()]);
} //}}}
2drop
] ifte ;
+: vocab-completions ( substring vocab -- list )
+ #! Used by jEdit plugin. Like vocab-apropos, but only
+ #! matches at the start of a word name are considered.
+ words [ word-name over str-head? ] subset nip ;
+
: apropos. ( substring -- )
#! List all words that contain a string.
vocabs [ dupd vocab-apropos. ] each drop ;