/** * Creates a new EvalTextArea. */ public EvalTextArea(SwingGui debugGui) { this.debugGui = debugGui; history = Collections.synchronizedList(new ArrayList<String>()); Document doc = getDocument(); doc.addDocumentListener(this); addKeyListener(this); setLineWrap(true); setFont(new Font("Monospaced", 0, 12)); append("% "); outputMark = doc.getLength(); }
/** * Called when a key is typed. */ public void keyTyped(KeyEvent e) { int keyChar = e.getKeyChar(); if (keyChar == 0x8 /* KeyEvent.VK_BACK_SPACE */) { if (outputMark == getCaretPosition()) { e.consume(); } } else if (getCaretPosition() < outputMark) { setCaretPosition(outputMark); } }
int code = e.getKeyCode(); if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) { if (outputMark == getCaretPosition()) { e.consume(); int caretPos = getCaretPosition(); if (caretPos == outputMark) { e.consume(); if (!e.isControlDown()) { if (e.isShiftDown()) { moveCaretPosition(outputMark); } else { setCaretPosition(outputMark); returnPressed(); e.consume(); } else if (code == KeyEvent.VK_UP) { int len = getDocument().getLength(); replaceRange(str, outputMark, len); int caretPos = outputMark + str.length(); select(caretPos, caretPos); } else { historyIndex++; historyIndex++; if (historyIndex < 0) {historyIndex = 0;} int len = getDocument().getLength();
/** * Creates a new EvalWindow. */ public EvalWindow(String name, SwingGui debugGui) { super(name, true, false, true, true); evalTextArea = new EvalTextArea(debugGui); evalTextArea.setRows(24); evalTextArea.setColumns(80); JScrollPane scroller = new JScrollPane(evalTextArea); setContentPane(scroller); //scroller.setPreferredSize(new Dimension(600, 400)); pack(); setVisible(true); }
/** * Called when Enter is pressed. */ private synchronized void returnPressed() { Document doc = getDocument(); int len = doc.getLength(); Segment segment = new Segment(); try { doc.getText(outputMark, len - outputMark, segment); } catch (javax.swing.text.BadLocationException ignored) { ignored.printStackTrace(); } String text = segment.toString(); if (debugGui.dim.stringIsCompilableUnit(text)) { if (text.trim().length() > 0) { history.add(text); historyIndex = history.size(); } append("\n"); String result = debugGui.dim.eval(text); if (result.length() > 0) { append(result); append("\n"); } append("% "); outputMark = doc.getLength(); } else { append("\n"); } }
left.add(tabs); evaluator = new Evaluator(debugGui); cmdLine = new EvalTextArea(debugGui);
int code = e.getKeyCode(); if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) { if (outputMark == getCaretPosition()) { e.consume(); int caretPos = getCaretPosition(); if (caretPos == outputMark) { e.consume(); if (!e.isControlDown()) { if (e.isShiftDown()) { moveCaretPosition(outputMark); } else { setCaretPosition(outputMark); returnPressed(); e.consume(); } else if (code == KeyEvent.VK_UP) { int len = getDocument().getLength(); replaceRange(str, outputMark, len); int caretPos = outputMark + str.length(); select(caretPos, caretPos); } else { historyIndex++; historyIndex++; if (historyIndex < 0) {historyIndex = 0;} int len = getDocument().getLength();
/** * Creates a new EvalWindow. */ public EvalWindow(String name, SwingGui debugGui) { super(name, true, false, true, true); evalTextArea = new EvalTextArea(debugGui); evalTextArea.setRows(24); evalTextArea.setColumns(80); JScrollPane scroller = new JScrollPane(evalTextArea); setContentPane(scroller); //scroller.setPreferredSize(new Dimension(600, 400)); pack(); setVisible(true); }
/** * Called when a key is typed. */ public void keyTyped(KeyEvent e) { int keyChar = e.getKeyChar(); if (keyChar == 0x8 /* KeyEvent.VK_BACK_SPACE */) { if (outputMark == getCaretPosition()) { e.consume(); } } else if (getCaretPosition() < outputMark) { setCaretPosition(outputMark); } }
/** * Called when Enter is pressed. */ private synchronized void returnPressed() { Document doc = getDocument(); int len = doc.getLength(); Segment segment = new Segment(); try { doc.getText(outputMark, len - outputMark, segment); } catch (javax.swing.text.BadLocationException ignored) { ignored.printStackTrace(); } String text = segment.toString(); if (debugGui.dim.stringIsCompilableUnit(text)) { if (text.trim().length() > 0) { history.add(text); historyIndex = history.size(); } append("\n"); String result = debugGui.dim.eval(text); if (result.length() > 0) { append(result); append("\n"); } append("% "); outputMark = doc.getLength(); } else { append("\n"); } }
left.add(tabs); evaluator = new Evaluator(debugGui); cmdLine = new EvalTextArea(debugGui);
int code = e.getKeyCode(); if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) { if (outputMark == getCaretPosition()) { e.consume(); int caretPos = getCaretPosition(); if (caretPos == outputMark) { e.consume(); if (!e.isControlDown()) { if (e.isShiftDown()) { moveCaretPosition(outputMark); } else { setCaretPosition(outputMark); returnPressed(); e.consume(); } else if (code == KeyEvent.VK_UP) { int len = getDocument().getLength(); replaceRange(str, outputMark, len); int caretPos = outputMark + str.length(); select(caretPos, caretPos); } else { historyIndex++; historyIndex++; if (historyIndex < 0) {historyIndex = 0;} int len = getDocument().getLength();
/** * Creates a new EvalTextArea. */ public EvalTextArea(SwingGui debugGui) { this.debugGui = debugGui; history = Collections.synchronizedList(new ArrayList<String>()); Document doc = getDocument(); doc.addDocumentListener(this); addKeyListener(this); setLineWrap(true); setFont(new Font("Monospaced", 0, 12)); append("% "); outputMark = doc.getLength(); }
/** * Creates a new EvalWindow. */ public EvalWindow(String name, SwingGui debugGui) { super(name, true, false, true, true); evalTextArea = new EvalTextArea(debugGui); evalTextArea.setRows(24); evalTextArea.setColumns(80); JScrollPane scroller = new JScrollPane(evalTextArea); setContentPane(scroller); //scroller.setPreferredSize(new Dimension(600, 400)); pack(); setVisible(true); }