Mercurial > hg > jslab
annotate src/samer/silk/SilkCompleter.java @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | bf79fb79ee13 |
children |
rev | line source |
---|---|
samer@0 | 1 package samer.silk; |
samer@0 | 2 import samer.core.*; |
samer@0 | 3 import java.util.*; |
samer@0 | 4 import org.gnu.readline.*; |
samer@0 | 5 import jsint.*; |
samer@0 | 6 |
samer@0 | 7 public class SilkCompleter implements ReadlineCompleter { |
samer@0 | 8 Iterator it; |
samer@0 | 9 public String completer(String text, int state) |
samer@0 | 10 { |
samer@0 | 11 if (state == 0) { |
samer@0 | 12 // first call to completer(): initialize iterator |
samer@0 | 13 // it=Symbol.symbolTable.entrySet().iterator(); |
samer@0 | 14 it=Symbol.symbolTable.values().iterator(); |
samer@0 | 15 } |
samer@0 | 16 while (it.hasNext()) { |
samer@0 | 17 // Map.Entry entry = (Map.Entry)it.next(); |
samer@0 | 18 // Symbol symbol=(Symbol)entry.getValue(); |
samer@0 | 19 // String name=(String)entry.getKey(); |
samer@0 | 20 Symbol symbol=(Symbol)it.next(); |
samer@0 | 21 String name=(String)symbol.toString(); |
samer@0 | 22 if (name.startsWith(text) && symbol.isDefined()) return name; |
samer@0 | 23 } |
samer@0 | 24 return null; // we reached the last choice. |
samer@0 | 25 } |
samer@0 | 26 } |