samer@0: package samer.silk; samer@0: import samer.core.*; samer@0: import java.util.*; samer@0: import org.gnu.readline.*; samer@0: import jsint.*; samer@0: samer@0: public class SilkCompleter implements ReadlineCompleter { samer@0: Iterator it; samer@0: public String completer(String text, int state) samer@0: { samer@0: if (state == 0) { samer@0: // first call to completer(): initialize iterator samer@0: // it=Symbol.symbolTable.entrySet().iterator(); samer@0: it=Symbol.symbolTable.values().iterator(); samer@0: } samer@0: while (it.hasNext()) { samer@0: // Map.Entry entry = (Map.Entry)it.next(); samer@0: // Symbol symbol=(Symbol)entry.getValue(); samer@0: // String name=(String)entry.getKey(); samer@0: Symbol symbol=(Symbol)it.next(); samer@0: String name=(String)symbol.toString(); samer@0: if (name.startsWith(text) && symbol.isDefined()) return name; samer@0: } samer@0: return null; // we reached the last choice. samer@0: } samer@0: }