class InputToken {
String lexable; // "sqrt(", for parsing
String display; // "√(", for displaying
InputToken(String lexable, String display) {
this.lexable = lexable;
this.display = display;
}
}
public static Map<String, InputToken> inputTokensMap = new HashMap<>();
inputTokensMap.put("square_root", new InputToken("sqrt(", "√("));
//rest of input tokens ...
public static List<InputToken> inputTokens = new ArrayList<>(); //for adding or removing tokens and to store them.
public static int cursorPos = 0; //where the cursor is
public static void removeInputTokenAt (int i) {/*...*/}
public static void addInputTokenAt (int i, String keyId) {/*...*/}
public static void updateMatrixDisplay () {/*...*/} //this is called by methods above to update the matrix display
//From key inputs, will be routed to methods above
public static void inputToken (String keyId) {/*...*/} //possible to handle both overwrite and insert mode, but for now, only do insert mode
public static void deleteToken (String keyId) {/*...*/} //from DEL button
Possible implementation
This is how Procal will handle key inputs.