View Javadoc
1 /* 2 */ 3 4 package net.sf.plb4jedit.plb; 5 import java.util.List; 6 import java.util.regex.Pattern; 7 8 import javax.swing.DefaultListCellRenderer; 9 import javax.swing.ListCellRenderer; 10 11 import org.gjt.sp.jedit.View; 12 import org.gjt.sp.jedit.textarea.JEditTextArea; 13 import org.gjt.sp.util.Log; 14 15 import sidekick.SideKickCompletion; 16 import sidekick.SideKickParsedData; 17 /*** 18 * unused yet. for testing only 19 * 20 * @author schaefer 21 */ 22 //}}} 23 24 public class PlbCompletion implements SideKickCompletion { 25 //{{{ PlbCompletion constructor 26 public PlbCompletion(View view, SideKickParsedData data) { 27 this.view = view; 28 textArea = view.getTextArea(); 29 this.data = data; 30 } //}}} 31 32 //{{{ size() method 33 public int size() { 34 if (isCompleteable()) { 35 Log.log(Log.DEBUG, this, "size=" + items.size()); 36 return items.size(); 37 } else { 38 Log.log(Log.DEBUG, this, "size=0"); 39 return 0; 40 } 41 } //}}} 42 43 //{{{ get() method 44 public Object get(int index) { 45 //Log.log(Log.DEBUG,this,"get("+index+")="+items.get(index)); 46 return items.get(index); 47 } //}}} 48 49 //{{{ getRenderer() method 50 public ListCellRenderer getRenderer() { 51 return new DefaultListCellRenderer(); 52 } //}}} 53 54 //{{{ getTokenLength() method 55 public int getTokenLength() { 56 //Log.log(Log.DEBUG,this,"getTokenLength="+5); 57 return 10; 58 } //}}} 59 60 //{{{ handleKeystroke() method 61 public boolean handleKeystroke(int index, char ch) { 62 Log.log(Log.DEBUG, this, "handleKeystroke(" + index + "," + ch + ")"); 63 if (index > -1) { 64 int caret = textArea.getCaretPosition(); 65 textArea.setSelectedText((String) this.get(index)); 66 return false; 67 } else { 68 textArea.userInput(ch); 69 return true; 70 } 71 72 } //}}} 73 74 //{{{ getCompletionDescription() method 75 public String getCompletionDescription(int index) { 76 Log.log( 77 Log.DEBUG, 78 this, 79 "getCompletionDescription(" + index + ")=TODO..."); 80 return "TODO: give a description"; 81 } //}}} 82 83 //{{{ isCompletionSelectable() method 84 public boolean isCompletionSelectable(int index) { 85 Log.log(Log.DEBUG, this, "isCompletionSelectable(" + index + ")"); 86 return true; 87 } //}}} 88 89 //{{{ Private members 90 private View view; 91 private JEditTextArea textArea; 92 private List items; 93 private SideKickParsedData data; 94 //}}} 95 96 private static Pattern completeable = 97 Pattern.compile(".*(call | move )//s+(//w+)"); 98 private boolean isCompleteable() { 99 return false; 100 /*String line = textArea.getLineText(textArea.getCaretLine()); 101 Log.log(Log.DEBUG,this,"isCompletionLine line="+line+"/"+word); 102 return (line.indexOf("call ") > 0 ); 103 */ 104 } 105 }

This page was automatically generated by Maven